Question: 2. (20 pts.) Let f(x) = sin(x) cos(x). (a) Construct MATLAB functions to approximate the derivative of f(x) using the following three formulae: h Di

 2. (20 pts.) Let f(x) = sin(x) cos(x). (a) Construct MATLAB

2. (20 pts.) Let f(x) = sin(x) cos(x). (a) Construct MATLAB functions to approximate the derivative of f(x) using the following three formulae: h Di [f(x)) = f(x+h) f(x) D2 [F()) f(x + h) f (x h) 2h _ -f(x + 2h) + 4f(x + h) 3f (:) 2h Each of your MATLAB functions should accept 2 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 deriva- tives 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!