Maple may be used as follows to find the derivative using Richardson extrapolation:
f := x -> exp(-x) * sin(x) - 0.5 * exp(-x) * cos(x);
x := 1;
h := 0.5;
eps_step := 0.00001;
R[0, 0] := (f(x + h) - f(x - h))/(2*h);
for i from 1 to 100 do
h := h/2;
R[i, 0] := (f(x + h) - f(x - h))/(2*h);
for j from 1 to i do
R[i, j] := (4^j*R[i, j - 1] - R[i - 1, j - 1])/(4^j - 1);
end do;
if abs( R[i,i] - R[i - 1, i - 1] ) < eps_step then
break;
elif i = 100 then
error "Richardson extrapolation failed to converge";
end if;
end do;
Copyright ©2005 by Douglas Wilhelm Harder. All rights reserved.


