Symbolic execution of the
parabolic approximation



If we leave some parameters unassigned, like the input vector x, we can execute the procedure symbolically in a computer algebra system. (Not all parameters can be left unassigned, those used for loops or in if statements must have a value, in this case n and m).

> read `MovingParabApprox.map`;
> macro(m=5):  macro(n=10):
> x := array(1..n):  a0 := array(1..n):
> a1 := array(1..n):  a2 := array(1..n):
>     MovingParabApprox(n,m,x,a0,a1,a2);
> print(a0);
[                                                      19
[x[1], x[2], x[3], 1/20 x[1] - 3/20 x[2] + 3/20 x[3] + -- x[4],
[                                                      20

                                                   31
    3/35 x[1] - 1/7 x[2] - 3/35 x[3] + 9/35 x[4] + -- x[5],
                                                   35

                                                   31
    3/35 x[2] - 1/7 x[3] - 3/35 x[4] + 9/35 x[5] + -- x[6],
                                                   35

                                                   31
    3/35 x[3] - 1/7 x[4] - 3/35 x[5] + 9/35 x[6] + -- x[7],
                                                   35

                                                   31
    3/35 x[4] - 1/7 x[5] - 3/35 x[6] + 9/35 x[7] + -- x[8],
                                                   35

                                                   31
    3/35 x[5] - 1/7 x[6] - 3/35 x[7] + 9/35 x[8] + -- x[9],
                                                   35

                                                   31      ]
    3/35 x[6] - 1/7 x[7] - 3/35 x[8] + 9/35 x[9] + -- x[10]]
                                                   35      ]

A symbolic execution, when it is possible, provides some level of program verification. In this case, we can verify that the output for the first three entries of a0 is correct. Using tables or further symbolic computation, we could verify all entries. We can see that each entry uses the right number of terms, and that all entries past the 4th use the same formula applied to a sliding number of input values. (The approximation was based on 5 points). We can also verify that the coefficients for each entry add up to 1. This can be easily seen to be necessary from a constant value for x[i].