Question: I need help writing this MATLAB function. Write a Matlab function y-fprime (E, a, h, c,b) that will approximate the derivative f(a) with the following

I need help writing this MATLAB function.
Write a Matlab function y-fprime (E, a, h, c,b) that will approximate the derivative f(a) with the following formula: f'(a) For example, fprime(, a,h,,-1.,,11 would give you the 2-point forward-difference formmla: f(a +h)-f(a) f(a) and fprime (E,a, h, -,1,-1,2]) would give you the 3-point centered-difference formula: f'(a) f(a + h) f(a- h) 2h Test your function with the following values: > y-fprime ( (x) log (x), 1,0.01,1,-11.1,0,1) 0.995033085316809 > y-fprime (8 (x) log (x),1,0.01,.-11.1.-1.21) 1.000033335333477 a) What are the actual errors and theor bounds for the above approximations? Remember that in Matlab log (x) represents In b) Use your function to determine the order (O(h), (h), ete) of the following approximation f'(a) Hint Let)le) ompare the actual errors for the approximation of '() when h takes on thelowing value h = 10-1, 10-2 , 10-5, Write a Matlab function y-fprime (E, a, h, c,b) that will approximate the derivative f(a) with the following formula: f'(a) For example, fprime(, a,h,,-1.,,11 would give you the 2-point forward-difference formmla: f(a +h)-f(a) f(a) and fprime (E,a, h, -,1,-1,2]) would give you the 3-point centered-difference formula: f'(a) f(a + h) f(a- h) 2h Test your function with the following values: > y-fprime ( (x) log (x), 1,0.01,1,-11.1,0,1) 0.995033085316809 > y-fprime (8 (x) log (x),1,0.01,.-11.1.-1.21) 1.000033335333477 a) What are the actual errors and theor bounds for the above approximations? Remember that in Matlab log (x) represents In b) Use your function to determine the order (O(h), (h), ete) of the following approximation f'(a) Hint Let)le) ompare the actual errors for the approximation of '() when h takes on thelowing value h = 10-1, 10-2 , 10-5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
