Question: Matlab required. 1.7. (a) Write a program to compute an approx- imate value for the derivative of a function using the finite-difference formula f'(x) f(x


Matlab required.
1.7. (a) Write a program to compute an approx- imate value for the derivative of a function using the finite-difference formula f'(x) f(x + h) f(1) h Test your program using the function tan(x) for I = 1. Determine the error by comparing with the square of the built-in function sec(). Plot the magnitude of the error as a function of h, for h = 10-k, k = 0,..., 16. You should use log scale for h and for the magnitude of the error. Is there a minimum value for the magnitude of the error? How does the corresponding value for h compare with the rule of thumb h mach derived in Example 1.32 (b) Repeat the exercise using the centered differ- ence approximation f'() = f(x+h) - f(x-h) 2h
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
