Tester of parabolic
approximation




This is a main program which defines the necessary vectors and assigns to the dependent variable an easily recognizable sequence, calls the approximating function and prints the results.

This program is also written in OpenMath.

Declaration( m=Constant(5), n=Constant(10) ),

Program( TestParabolicApproximation,
  Block(
    Declaration(
      i = [Local,Integer],
      [x,a0,a1,a2] = [Local,Array(n,Float)] ),
    ForLoop(i,1,1,n,Assign(x[i],3+2*i+i^2)),
    MovingParabApprox(n,m,x,a0,a1,a2),
    ForLoop(i,1,1,n,
      APPLY( printf,
        "%2d %10.3f %10.3f %10.3f %10.3f\n",
        i, x[i], a0[i], a1[i], a2[i] )),
    Return
    )
  )
Notes:

The printf function call is not represented in functional form, but with explicit function application. This is equivalent to

 printf( "%2d %10.3f %10.3f %10.3f %10.3f\n",
    i, x[i], a0[i], a1[i], a2[i] )),