Question: please use matlab to solve (a) (10 points) Write a program, using double-precision floating-point numbers, to compute an ap- proximate value for the derivative of

please use matlab to solveplease use matlab to solve (a) (10 points) Write a program, using

(a) (10 points) Write a program, using double-precision floating-point numbers, to compute an ap- proximate value for the derivative of a function using the finite difference formula f(x + h) f(x) f'(2) h Test your program using the function tan(x) for x = 1, and determines the error by comparing with tan(x)2 + 1. It prints out the magnitude of the error for h = 10-k, k = 0, ..., 16, and plots the magnitude of error as a function of h using log scale. - 2 What is the minimum value for the magnitude of the error? How does the corresponding value for h compare with the "rule of thumb" hr mach? (b) (5 points) Repeat part (a) using single-precision floating-point numbers. (C) (10 points) Repeat the exercise using the centered difference approximation f(x + h) f (x h) 2h using both double-precision and single-precision floating point arithmetic

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!