5 a) Implement the backward difference approximation D_f(x) and the central difference approximation D0f(x) to compute the derivative f'(x) (defined in the class) in MATLAB.
5 b) Let f(x) = cos x. Compute D0f and D_f at x = π/3 for h = 0.1, 0.05, 0.025, 0.0125. Report the errors for each h by comparing against the analytical solution. What is the order of accuracy for each method?
4. The forward and backward finite-difference operators are defined by f(x+h)-f(x) and f(x)-f(x-h). These operators can be applied sequentially, e.g., D+D-f(x) = D+(D-f()).
5 a) Implement the backward difference approximation D-f(x) and the central difference approximation Dof(x) to compute the derivative f'(x) (defined in the class) in MATLAB.
5 b) Let f(x) = cos x. Compute Dof and D_f at x = T/3 for h = 0.1, 0.05, 0.025, 0.0125. Report the errors for each h by comparing against the analytical solution. What is the order of accuracy for each method?