Effects of round-off error

Let us consider more formally the effect of round-off error. Consider the centered three-point difference

[Maple Math] .

Assume that in calculating [Maple Math] and [Maple Math] some round-off error is made, such that instead of the correct values, we obtain results [Maple Math] and [Maple Math] , with

[Maple Math] , [Maple Math] .

Therefore, the error made in the approximation is

[Maple Math] .

When we assume that the round-off errors are bounded by some quantity [Maple Math] and that [Maple Math] then the total error is bounded by

> maxerr:=epsilon/h+h^2*M/6;

[Maple Math]

For

> epsilon:=5*10^(-10);M:=10;maxerr;

>

[Maple Math]

[Maple Math]

[Maple Math]

> plot(maxerr,h=0..0.003);

[Maple Plot]

The minimum error then occurs for

> fsolve(diff(maxerr,h)=0,h);

[Maple Math]

Which we can verify numerically:

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

[Maple Math]

> df:=D(f):ddf:=D(df):dddf:=D(ddf):

> for i from 1 to 10 do h:=0.0001+0.0001*i: df1b:=1/(2*h)*(f(0.4+h)-f(0.4-h)): acterrb:=abs(df1b-df(0.4)): print(h,df1b,acterrb);od:

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]