Differentiation Formulae

Let us use mathematica to find rules for differenting.  

We are going to be working with an undefined function, f[x].  Lets first make sure that it is not defined:

Clear[f]

Lets try differentiating first.  We are going to interpolate this function at (Subscript[x, 0]), (Subscript[x, 0])+h and (Subscript[x, 0])+2h.

p[x_]=Expand[InterpolatingPolynomial[{{x0,f[x0]},{x0+h,f[x0+h]},{x0+2 h,f[x0+2 h]}},x]]

Lets differentiate this.

Dp[x_]=(∂_x)p[x]

We can get a three point formulae by setting x = (Subscript[x, 0]).

Simplify[Dp[x0]]

Now, lets try to work out the error term.  We have a formula for the error term of the interpolating polynomial. z(x) is the unknown point.

error[x_]=((((∏_(n=0)^2)(x-(x0+n h))) Derivative[3][f][ξ[x]])/(3!))

Lets differentiate it.

Differror[x_]=(∂_x)error[x]

Notice that the expression includes ξ'[x], whose value we don't know.

Now lets substitute x for (Subscript[x, 0]), to get our error term:

Differror[x0]

Lets try a five point formula.  Lets interpolate at (Subscript[x, 0])-2h, (Subscript[x, 0])-h, (Subscript[x, 0]), (Subscript[x, 0])+h, (Subscript[x, 0])+2h.

list=Table[{x0+n h,f[x0+n h]},{n,-2,2}]

Dp[x_]=(∂_x)Expand[InterpolatingPolynomial[list,x]];
Simplify[Dp[x0]]

The error term:

Differror[x_]=(∂_x)((((∏_(n=-2)^2)(x-(x0+n h))) Derivative[5][f][ξ[x]])/(5!));
Differror[x0]

How about a 9 point formula?

list=Table[{x0+n h,f[x0+n h]},{n,-4,4}];
Dp[x_]=(∂_x)Expand[InterpolatingPolynomial[list,x]];
Simplify[Dp[x0]]
Differror[x_]=(∂_x)((((∏_(n=-4)^4)(x-(x0+n h))) Derivative[9][f][ξ[x]])/(5!));
Differror[x0]