Dr. Jie Zou PHY Chapter 7 Numerical Differentiation: 1 Lecture (I) 1 Ref: “Applied Numerical Methods with MATLAB for Engineers and Scientists”, Steven Chapra, 2 nd ed., McGraw Hill, 2008.
Dr. Jie Zou PHY Outline Engineering and scientific applications Definition of the derivative-a review of calculus Numerical differentiation (1) Basic finite-difference approximations for both the 1 st and 2 nd derivatives (I) Forward difference (II) Backward difference (III) Centered difference (2) Higher-accuracy finite-difference approximations (Lecture II)
Dr. Jie Zou PHY Engineering and scientific applications The mathematical models of most engineering and science problems involve differentiation. Examples: Mechanics: Newton’s 2 nd law (1D), F = md 2 x/dt 2. Heat conduction: Fourier’s law (1D), q = - kdT/dx. Electrical conduction: Ohm’s law (1D), J = - dV/dx. When do we need apply methods of numerical differentiation? When it is difficult to differentiate analytically; When the function is unknown and defined only by measurement at discrete points. Heat flow and temperature gradient (Ref. Fig. 19.2)
4 Definition of the derivative (First) derivative: The rate of change of a dependent variable, such as y, with respect to an independent variable, such as x. Graphical representation Difference approximation Definition of the derivative
Dr. Jie Zou PHY Definition of the derivative (cont.) Second derivative: The derivative of the first derivative. Mathematical definition: The 1 st derivative tells us the slope of the tangent to the curve at a given point. The 2 nd derivative tells us how fast the slope is changing. It is also called the curvature. Partial derivatives of f(x, y):
Dr. Jie Zou PHY Basic finite-difference approximations Taylor series expansion of f(x) about a point x i : Evaluating f(x) at point x i+1, we have: Truncating the series after the first derivative term, we have: Forward difference approx. of the 1 st derivative: h: The step size - the length of the interval over which the approximation is made; h = x i+1 – x i.
7 Basic finite-difference approximations (cont.) Backward difference approx. of the 1 st derivative: Centered difference approx. of the 1 st derivative: Note: The truncation error in the Centered difference approx. is of the order of h 2 ; the truncation error in the Forward and Backward difference approx. is of the order of h. Centered difference approx. is more accurate than the Forward or Backward difference approx.
Dr. Jie Zou PHY Basic finite-difference approximations (cont.) Finite-difference approximations of the 2 nd derivatives: Second forward finite difference: Second backward finite difference: Second centered finite difference:
Dr. Jie Zou PHY Example (Ref. example 4.4) Use a forward, backward, and centered difference approximation to estimate the 1 st derivative of f(x) = -0.1x 4 – 0.15x 3 – 0.5x 2 – 0.25x at x = 0.5 using a step size h = 0.5. Repeat the computation using h = Find the percent error of the estimation relative to the true value.
Dr. Jie Zou PHY Results (Example 4.4) h=0.5Backward O(h) Centered O(h 2 ) Forward O(h) Estimate |t||t| 39.7%9.6%58.9% h=0.25Backward O(h) Centered O(h 2 ) Forward O(h) Estimate |t||t| 21.7%2.4%26.5% True value: f’(0.5) =