Question
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
f=@(x)sin(x)x0=1.2;
n=-20:0.5:0;
h=10.^n;
forward_diffs=(f(x0+h)-f(x0))./h;
figure;
loglog(h,abs(cos(x0)-forward_diffs),h,abs(.5*sin(x0)./h),'Linewidth',2);
xlabel('log h');
ylabel('log error');
legend('Absolute Error','Discretization Error','Location', 'best');
title('Forward Difference Derivative Errors');...