Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Chapter 21 Numerical Differentiation
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2 Numerical Differentiation Chapter 21 Numerical differentiation has been introduced several times in this course. In this chapter more accurate formulas that retain more terms will be developed.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. First Let’s Review A little We were first introduced to numerical differentiation in Chapter 4 – section
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 Numerical Differentiation First forward difference
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 5 Numerical Differentiation First backward difference
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 6 Numerical Differentiation First centered difference
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Consider some data 7 Time, sDistance, mVelocity, m/s Forward difference Backward difference Centered difference
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Consider some data 8 Time, sDistance, mVelocity, m/s Forward difference Backward difference Centered difference
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Consider some data 9 Time, sDistance, mVelocity, m/s Forward difference Backward difference Centered difference
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Consider some data 10 Time, sDistance, m Velocity, m/s Forward difference Backward difference Centered difference Actual
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Consider some data 11 Time, sDistance, m Velocity, m/s Forward difference Backward difference Centered difference Actual
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. What if you wanted to find the acceleration, based on this data? 12 Time, sDistance, mVelocity,m/sAcceleration Forward difference
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 13 h hh h h h Equation 4.24
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Now that we’ve reviewed let’s look at some more sophisticated methods for finding derivatives – in chapter 21 14
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 15 High Accuracy Differentiation Formulas High-accuracy divided-difference formulas can be generated by including additional terms from the Taylor series expansion. Solve for
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 16 Inclusion of the 2 nd derivative term has improved the accuracy to O(h 2 ). Similar improved versions can be developed for the backward and centered formulas as well as for the approximations of the higher derivatives.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 17
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 18
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 19
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 20 Richardson Extrapolation We’ve looked at two ways to improve derivative estimates when employing finite divided differences: –Decrease the step size, or –Use a higher-order formula that employs more points. A third approach, based on Richardson extrapolation, uses two derivative estimates to compute a third, more accurate approximation.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 21 For centered difference approximations with O(h 2 ). The application of this formula yields a new derivative estimate of O(h 4 ). Recall that Richardson extrapolation was used in Romberg integration
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 22 Derivatives of Unequally Spaced Data Data from experiments or field studies are often collected at unequal intervals. One way to handle such data is to fit a second-order Lagrange interpolating polynomial. x is the value at which you want to estimate the derivative.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 23 Derivatives and Integrals for Data with Errors Differentiation tends to amplify errors Integration tends to smooth out errors
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Built-In Matlab Functions diff –Assumes a spacing of 1 gradient –Forward difference –Central difference –Backward difference –A single input assumes a spacing of 1 –Second field is available to specify the spacing 24
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 25
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 26
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 27
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 28
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 29
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 30 gradient can be used to calculate partial derivatives
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 31
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Summary Higher Order Derivative Approximations Richardson Extrapolation Built-In MATLAB functions –diff –gradient Quiver Plots 32