Question: Write a matlab code to solve the following problem Problem 1 In this problem we will calculate the first and second derivatives of a function

Write a matlab code to solve the following problem

Write a matlab code to solve the following problem Problem 1 In

Problem 1 In this problem we will calculate the first and second derivatives of a function and examine the effect of method and step size Turn in (parts b-d): a table of the results organized by methods and step size. value of the numerical derivative percent error from the true (analytical) derivative Comment on the effects of method and step size. (a) Write three different functions to calculate the derivative: using the backward difference, forward difference, and central difference formulae. These functions should be general enough that you can use them in future problems (Probs. 2-4 below) (b) Calculate and plot the derivative of - over the range [3, 4] for all three methods, along with the actual value of the derivative. Try at least two different step sizes. In your table, report the error for each method and each step size at x -3.5. [Watch out: the arrays for the derivatives are different lengths, so make sure you're reporting the derivatives at the right point in the array] (c) Using the derivatives you calculated in part (b), calculate and plot the second derivative using all three methods. (For the second derivative using backward difference, use the first derivative you calculated using backward difference, and so on for the others). Also make a table for the error of the second derivate of the value at x-3.5. (d) Another way to calculate the second derivative is to use the formula f"(x) (Ar) Calculate and plot the second derivative using the function above. Calculate the error and add this result to your table

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!