Question: Language: Matlab Write a program to compute an approximate value for the derivative of a function using the finite-difference formula f'(x) f(x + h) -

 Language: Matlab Write a program to compute an approximate value for

Language: Matlab

Write a program to compute an approximate value for the derivative of a function using the finite-difference formula f'(x) f(x + h) - f(x)/h Test your program using the function sin(x) for x = 1. Determine the error by comparing with the built-in function cos(x). Plot the magnitude of the error as a function of h, for h = 1/2, 1/4, 1/8 ... You should use a 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 Repeat the exercise using the centered difference approximation f' f(x + h) - f (x - h)/2h

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!