%
% show that we cannot expect more than half machine precision
% in a forward different 
%
% f(x) = sin(x); 
% f'(x) = cos(x); 

x = pi/3.2 
for i = 1:14, 
    h(i) = 10^(-i);  
    Dhf(i) = ( sin(x + h(i)) - sin(x) )/h(i);
    relerror(i) = abs( Dhf(i) - cos(x) )/cos(x);
end 

format short e
[h' Dhf' relerror'] 
semilogy([1:14],relerror,'r-*','LineWidth',3) 
xlabel('h') 
ylabel('Relative errors') 
