%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%% SCRIPT %%%%%%% %%%%%% phi.m %%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function y=phi(h) y=(exp(1+h)-exp(1-h))/(2*h); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%% SCRIPT %%%%%%% %%%%%% der_first_order.m %%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all, m=40, format long e n=1:m; h=1./2.^n; e=exp(1); err= (exp(1+h)-e)./h - e; [h' err'] figure(1), plot(h,err) figure(2), plot(log(h),log(abs(err))) %%%%%%%%% END %%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%% SCRIPT %%%%%%% %%%%%% der_sec_order.m %%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all format long m=40 n=1:m; h=1./2.^n; e=exp(1); err_2 = phi(2/(2.^n))-e; [h' err_2'] figure(1), plot(h,err_2) figure(2), plot(log(h),log(abs(err_2))) %%%%%%%%% END %%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%% SCRIPT %%%%%%% %%%%%% Richardson.m %%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all, N=8, h=1 format long, e=exp(1) for i=1:N, a(i)=phi(h/(2^i)); error(i)=a(i)-e; end [a' error'], pause V=1 for j=1:N-1, V=4*V; for i=N:-1:j+1, a(i)=a(i) + (a(i)-a(i-1))/(V-1); error(i)=a(i)-e; end end error' %%%%%%%%% END %%%%%%%%%%%%%%%%%%%%%%%%