Example

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

[Maple Math]

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

[Maple Math]

> plot(ddf,-1..1);

[Maple Plot]

So the second derivative is bounded by 3.5. Let us now apply the forward-difference formula to estimate the derivative at [Maple Math] :

> for i from 1 to 5 do h:=10.^(-i): df1:=(f(0.4+h)-f(0.4))/h: maxerr:=h*3.5/2: acterr:=df1-df(0.4): print(h,df1,maxerr,acterr); od:

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

A good estimate is obtained for sufficiently small values of [Maple Math] . But the trend does not continue much longer:

> for i from 5 to 10 do h:=10.^(-i): df1:=(f(0.4+h)-f(0.4))/h: maxerr:=h*3.5/2: acterr:=df1-df(0.4): print(h,df1,maxerr,acterr); od:

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

This is caused by round-off error. Generally, there will be some optimal value for [Maple Math] .