Moving parabolic
approximation (in Maple)




This is the functionMovingParabApprox converted into Maple. The conversion was done by the OMtoMaple function (written in Maple). Except for wrapping around two long lines, the result shown here is the exact output of the converter.

MovingParabApprox := proc(n::integer, m::integer, x::array, a0::array,
    a1::array, a2::array )
local i, sjx, sx, sj2x, t9, t11, t12, t13, t14, t15;
if m < 3 then
     ERROR(`Parabolic order not large enough`);
     fi;
if 1 <= n then
         a0[1] := x[1];
         a1[1] := 0;
         a2[1] := 0;
     fi;
if 2 <= n then
         a0[2] := x[2];
         a1[2] := x[2]-x[1];
         a2[2] := 0;
     fi;
# The definitions of sx, sjx, and sj2x are:
#      m - 1                m - 1                   m - 1
#      -----                -----                   -----
#       \                    \                       \     2
#        )   x[i - j] = sx,   )   j x[i - j] = sjx,   )   j  x[i - j] = sj2x
#       /                    /                       /
#      -----                -----                   -----
#      j = 0                j = 0                   j = 0
if 3 <= n then
         sx := x[1]+x[2];
         sjx := x[1];
         sj2x := x[1];
     fi;
for i from 3 to min(m,n) do
        sj2x := sj2x+2*sjx+sx;
        sjx := sjx+sx;
        sx := sx+x[i];
            t15 := sjx*i;
            t9 := i^2;
            t14 := sx*t9;
            t13 := 6*sjx+(-3*i+2)*sx;
            t12 := 1/(i+1)/(i+2)/i;
            t11 := 1/(i-2)/(i-1)*t12;
            a0[i] := 3*(3*t14-12*t15+10*sj2x+t13)*t12;
            a1[i] := -6*((30*i-30)*sj2x+(60*i-32*t9-22)*
                sjx+(-21*t9-6+(6*t9+21)*i)*sx)*t11;
            a2[i] := 30*(t14-6*t15+6*sj2x+t13)*t11;
    od;
for i from m+1 to n do
        sj2x := sj2x-x[i-m]*(m-1)^2;
        sjx := sjx-x[i-m]*(m-1);
        sx := sx-x[i-m];
        sj2x := sj2x+2*sjx+sx;
        sjx := sjx+sx;
        sx := sx+x[i];
            t15 := sjx*m;
            t9 := m^2;
            t14 := sx*t9;
            t13 := 6*sjx+(-3*m+2)*sx;
            t12 := 1/(m+1)/(m+2)/m;
            t11 := 1/(m-2)/(m-1)*t12;
            a0[i] := 3*(3*t14-12*t15+10*sj2x+t13)*t12;
            a1[i] := -6*((30*m-30)*sj2x+(60*m-32*t9-22)*
                sjx+(-21*t9-6+(6*t9+21)*m)*sx)*t11;
            a2[i] := 30*(t14-6*t15+6*sj2x+t13)*t11;
    od;
RETURN();
end: