Question: Write a Matlab script to obtain the first derivative estimates of the following unequally spaced data: x 1 f(x) 0.6767 1.5 0.3734 1.6 0.3261
Write a Matlab script to obtain the first derivative estimates of the following unequally spaced data: x 1 f(x) 0.6767 1.5 0.3734 1.6 0.3261 2.5 3.5 0.08422 0.01596 In fact, the data belongs to f(x)=5xe2x. Compare numerical and analytical derivatives by plotting them on the same graph. Algorithm: Step 1: Enter data points Step 2: Calculate derivative for each point using 2nd order Lagrange polynomial (see the formula below). Step 3: Calculate the analytical derivatives for each point. Step 4: Compare the results by plot the numerical and analytical derivatives on the same graph (do not forget to include labels and the legend) 2x-x-1-X1+1 + f(x)- (x-x-1)(xX1+1) Formula for 2nd order Lagrange polynomial: f(x) = f(x-1) 2x-xj-Xj+1 (x-1-x)(x-1-X1+1) + f(x1+1)- 2x-x-1-x (X+1-X-1)(x+1-x)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
