Question: Develop an M-file function that computes first and second derivative estimates of order O(h 2 ) based on the formulas in Figs. 21.3 through 21.5.
Develop an M-file function that computes first and second derivative estimates of order O(h2) based on the formulas in Figs. 21.3 through 21.5. The function’s first line should be set up as function [dydx, d2ydx2] = diffeq(x,y) where x and y are input vectors of length n containing the values of the independent and dependent variables, respectively, and dydx and dy2dx2 are output vectors of length n containing the first- and second-derivative estimates at each value of the independent variable. The function should generate a plot of dydx and dy2dx2 versus x. Have your M-file return an error message if
(a) The input vectors are not the same length, or
(b) The values for the independent variable are not equally spaced. Test your program with the data from Prob. 21.11.
Data From Problem 21.11
The following data were collected for the distance traveled versus time for a rocket:

Use numerical differentiation to estimate the rocket’s velocity and acceleration at each time.
ts y, km 0 0 25 32 50 58 75 78 100 92 125 100
Step by Step Solution
3.32 Rating (164 Votes )
There are 3 Steps involved in it
To solve this problem we will use the formulas for first and second derivative estimates of order Oh... View full answer
Get step-by-step solutions from verified subject matter experts
