Effects of round-off error
Let us consider more formally the effect of round-off error. Consider the centered three-point difference
.
Assume that in calculating
and
some round-off error is made, such that instead of the correct values, we obtain results
and
, with
,
.
Therefore, the error made in the approximation is
.
When we assume that the round-off errors are bounded by some quantity
and that
then the total error is bounded by
> maxerr:=epsilon/h+h^2*M/6;
For
> epsilon:=5*10^(-10);M:=10;maxerr;
>
> plot(maxerr,h=0..0.003);
The minimum error then occurs for
> fsolve(diff(maxerr,h)=0,h);
Which we can verify numerically:
> restart:f:=x->ln(cos(x));
> 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: