Question: Let f(x) = sin(x) cos(x). (a) Construct MATLAB functions to approximate the derivative of f(x) using the following three formulae: D1 [f(x)] = (f(x +

Let f(x) = sin(x) cos(x).

(a) Construct MATLAB functions to approximate the derivative of f(x) using the following three formulae:

D1 [f(x)] = (f(x + h) f(x)) / h ,

D2 [f(x)] = (f(x + h) f(x h)) / 2h ,

D3 [f(x)] = (f(x + 2h) + 4f(x + h) 3f(x)) / 2h .

Each of your MATLAB functions should accept x and h as arguments and produce an approximate derivative as output. Also construct a separate MATLAB function to evaluate the exact derivative f'(x).

(b) Using your MATLAB functions, calculate the relative errors for the approximate derivatives at the points x = 0 and x = 0.6. Use values of h given by h = 10^-d where d = 1, 2, . . ., 10. For each value of x, create a table of results with the headings h, D1error, D2error, and D3error.

(c) Provide an explanation of the various behaviors that you observe. Hint, look at the values of h where each approximation yields the most accurate result.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!