Develop an M-file function that computes first and second derivative estimates of order O(h 2 ) based

Question:

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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: