Example

Let us derive the centered three-point formula again, keeping explicitly terms up to order [Maple Math] :

> restart;

> tayl:=convert(taylor(f(x),x=x0,9),polynom);

[Maple Math]
[Maple Math]

The error term is given by

> err:=(D@@9)(f)(xi(x))*(x-x0)^9/9!;

[Maple Math]

so that,

> f(x)=tayl+err;

[Maple Math]
[Maple Math]
[Maple Math]

We can then evaluate this expansion at the two neighbouring points:

> expr1:=f(xo+h)=subs(x=x0+h,tayl+err);

[Maple Math]
[Maple Math]

> expr2:=f(x0-h)=subs(x=x0-h,tayl+err);

[Maple Math]
[Maple Math]

We can eliminate the second derivative terms by subtracting both expressions :

> lhs(expr1)-lhs(expr2)=rhs(expr1)-rhs(expr2);

[Maple Math]
[Maple Math]

which gives the centered three-point difference formula. When [Maple Math] is continuous over [Maple Math] then the Intermediate Value Theorem says that

[Maple Math] ,

with [Maple Math] in the interval [Maple Math] .

Therefore, the three-point difference formula becomes:

> expr:=D(f)(x[0])=(f(x[0]+h)-f(x[0]-h))/(2*h)+C[1]*h^2+C[2]*h^4+c[3]*h^6 + O(h^8);

[Maple Math]

So we should be able to apply Richardson Extrapolation up to [Maple Math] :

> restart:f:=x->ln(cos(x));

[Maple Math]

> df:=D(f):

> h:=0.8:df1[1]:=1/(2*h)*(f(0.4+h)-f(0.4-h)):acterr:=abs(df1[1]-df(0.4)): print(h,df1[1],acterr);

[Maple Math]

> for i from 2 to 8 do h:=0.8/(2^(i-1)): df1[i]:=1/(2*h)*(f(0.4+h)-f(0.4-h)): N[2,i]:=(4*df1[i]-df1[i-1])/3: newerr:=abs(N[2,i]-df(0.4)): print(h,df1[i],N[2,i],newerr);od:

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

The next sequence generated by Richardson extrapolation is

> for i from 3 to 8 do h:=0.8/(2^(i-1)):N[3,i]:=(16*N[2,i]-N[2,i-1])/15: newerr:=abs(N[3,i]-df(0.4)): print(h,N[3,i],newerr);od:

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

and finally:

> for i from 4 to 8 do h:=0.8/(2^(i-1)):N[4,i]:=(64*N[3,i]-N[3,i-1])/63: newerr:=abs(N[4,i]-df(0.4)): print(h,N[4,i],newerr);od:

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

Always take into account, as illustrated in the numbers above, that round-off errors will be present.