% Richardson extraplation 
% 
% f(x) = sin(x^2);  
% f'(x) = 2*x*cos(x^2); 
% 

x = 1; 
fpexact = 2*x*cos(x^2) 

h = 0.01 
alpha = 0.5 
Dhf = (sin((x+h)^2) - sin(x^2))/h 
Dahf = (sin((x+alpha*h)^2) - sin(x^2))/(alpha*h) 

%Richardson extrapolation
Richardson = (-alpha/(1-alpha))*Dhf + (1/(1-alpha))*Dahf

Error1 =  (Dhf - 2*x*cos(x^2))/(2*x*cos(x^2))
Error2 =  (Richardson - 2*x*cos(x^2))/(2*x*cos(x^2))


