Question: (c) (20 marks) Write a C program to compute the first derivative off(x) ex2) at 2 using the central-difference approximation scheme. In the program, you

 (c) (20 marks) Write a C program to compute the first

(c) (20 marks) Write a C program to compute the first derivative off(x) ex2) at 2 using the central-difference approximation scheme. In the program, you should also compute the exact value f, using the analytic expression (what is it?). Calculate the differences E(h) = ltoact-fnarn(h)| for h = 10-2,5 10-3, 10-3,5 10-4, and 10-4, where lfnurn (h)I represents the numerical value obtained by using step size h. Plot In(E(h)) against In(h). Determine the slope of the line and verify that the error has the expected order of accuracy. [Optional: Improve your code to take arbitrary xo and h provided by the user; further improvement includes processing multiple h and writing the results into an output file, whose name is provided by the user.] (d) (20 marks) write a C program. to compute the second derivative off(x) = exp(x2) at X = 2 using Eq. (6). Repeat the error analysis of part (c) for this case

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!