CS计算机代考程序代写 matlab %MATLAB script to illustrate Richardson’s extrapolation for derivative

%MATLAB script to illustrate Richardson’s extrapolation for derivative
%%
MyFunc=@(x) x.^2.*cos(x)
MyDeriv=@(x)x.*(2.*cos(x)-x.*sin(x))
%%
Dexact=MyDeriv(2)
%%
xi=2;
Delta1=0.2;
xim1=xi-Delta1;
xip1=xi+Delta1;

D1=(MyFunc(xip1)-MyFunc(xim1))/(2*Delta1)
%%
Delta2=0.1;
xim1=xi-Delta2;
xip1=xi+Delta2;
D2=(MyFunc(xip1)-MyFunc(xim1))/(2*Delta2)
%%
D=D2*(1+1/((Delta1/Delta2)^2-1))-D1*(1/((Delta1/Delta2)^2-1))