Reference no: EM132201304
Question :
Write a MATLAB function which calculates and plots the error of both the forward and central difference approximations of the first derivative of a polynomial as a function of the step size. The function will have three inputs:
1. a vector whose elements are the coefficients of the polynomial,
2. the point at which the derivative of the function is to be approximated, and
3. the initial step size. The output should be a log-log plot of the error as a function of the step size.
This function should call the functions from problems 1 and 2 to approximate the derivative at the specified point using the initial step size. This should be repeated 10 times using progressively smaller step sizes (by factors of 10).
The error for each step size should then be calculated based on the known value of the derivative at the specified point and then plotted.
The plot should be publishable quality. Write an explanation of the results which discusses the following:
a. A comparison (qualitative and quantitative) of the error of the two finite difference methods (include a comparison of the expected and actual order of error for both methods).
b. An explanation of how and why the error changed with changing step size.