Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 tableStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started