Question: Solve and provide MATLAB code. (b) Write a function, MyCenteredDifference, that takes in a function f, a point (or points) x, and a step size

(b) Write a function, MyCenteredDifference, that takes in a function f, a point (or points) x, and a step Solve and provide MATLAB code.

(b) Write a function, MyCenteredDifference, that takes in a function f, a point (or points) x, and a step size h that represents the spacing between the x points. The function should return an approximated derivative of f using centered differences at each x point. Using your function, approximate the derivative Dh f' using step sizes h = for n = 1,2, 3, ..., 15 on the interval [1, 2]. Compare the results of your function to the true derivatives f'(x) = 3x + cos(x) by computing the error 2n En = max |f'(x) - Dh(x)| X Print your results in and the error ratio a table that has as columns: n, the error En(x), En (x) En-1(a) where E (x) Eo (x) 1. =

Step by Step Solution

3.34 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Define the function fx and its true derivative fx fX 3x2cosx trueder... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!