clear all N =17; % number of approximations to calculate x0 =1; exact = 9*x0^8; h = 5*10.^(-(1:N)); df_dx = ((x0+h).^9 - x0^9)./h; Er = abs(df_dx - exact); loglog(h,Er,'-',h,Er,'*'); axis([1e-18 1 5e-8 1e2]); xlabel('h') ylabel('|error|'); set(gca,'Xtick',[1e-17 1e-13 1e-8 1],'Ytick',[1e-7 1e-3 1e1 1e2]); title('Error of forward differencing formula'); shg