1.64k likes | 4.09k Views
Lecture 18 - Numerical Differentiation. CVEN 302 July 19, 2002. Lecture’s Goals. Finite Difference Schemes Taylor Series Expansion for Differentiation Basic Numerical Integration Trapezoidal Rule Simpson’s Rule Midpoint Gaussian Quadrature. v. v. dv. dt. t. t. a. y. t.
E N D
Lecture 18 - Numerical Differentiation CVEN 302 July 19, 2002
Lecture’s Goals • Finite Difference Schemes • Taylor Series Expansion for Differentiation • Basic Numerical Integration • Trapezoidal Rule • Simpson’s Rule • Midpoint • Gaussian Quadrature
v v dv dt t t a y t Calculus - Numerical Methods Differentiation Integration
Numerical Differentiation • Estimate the derivatives (slope, curvature, etc.) of a function by using the function values at only a set of discrete points • Ordinary differential equation (ODE) • Partial differential equation (PDE)
Numerical Differentiation • Represent the function by Taylor polynomials or Lagrange interpolation • Evaluate the derivatives of the interpolation polynomial at selected nodal points
Numerical Differentiation A Taylor series or Lagrange interpolation of points can be used to find the derivatives. The Taylor series expansion is defined as:
First Derivative at a Point i-2 i-1 i i+1 i+2
Numerical Differentiation Use the Taylor series expansion to represent three points about single location:
Numerical Differentiation Assume that the data points are “equally spaced” and the equations can be written as:
Forward Differentiation For a forward first derivative, subtract eqn[2] from eqn[1]: Rearrange the equation:
Forward Differentiation As the Dx gets smaller the error will get smaller The error is defined as:
Backward Differentiation Subtract eqn[3] from eqn[2]: The error is defined as:
Central Differentiation Subtract eqn[3] from eqn[1]: The error is defined as:
Differential Error Notice that the errors of the forward and backward 1st derivative of the equations have an error of the order of O(Dx) and the central differentiation has an error of order O(Dx2). The central difference has an better accuracy and lower error that the others. This can be improved by using more terms to model the first derivative.
= 0 = 0 0 Numerical Differentiation If you want to improve the accuracy and decrease the error you will need to eliminate terms :
Higher Order Errors in Differentiation The terms become : The terms become A=-3, B= 4 and C=-1
Forward difference Backward difference Higher Order 1st Derivative Parabolic curve i-2 i-1 i i+1 i+2
Higher Order Derivatives To find higher derivatives, use the Taylor series expansions of term and eliminate the terms from the sum of equations. To improve the error in the problem add additional terms.
= 0 = 0 = # 2nd Derivative of the Function It will require three terms to get a central 2nd derivative of discrete set of data.
2nd Order Central Difference The terms become : The terms become A=1,B=-2 and C=1. Therefore
Lagrange Differentiation Another form of differentiation is to use the Lagrange interpolation between three points. The values can be determine for unevenly spaced points. Given:
Lagrange Differentiation Differentiate the Lagrange interpolation Assume a constant spacing
Lagrange Differentiation Differentiate the Lagrange interpolation Variouslocations
Lagrange Differentiation To find a higher order derivative from the Lagrange interpolation for a three point Lagrange Take the derivative
Partial Derivatives • Straightforward extension of one-dimensional formula (i, j+2) (i-1, j+1) (i, j+1) (i+1, j+1) (i-2, j) (i-1, j) (i, j) (i+1, j) (i+2, j) (i-1, j-1) (i, j-1) (i+1, j-1) (i, j-2)
(i, j+2) (i-1, j+1) (i, j+1) (i+1, j+1) (i-2, j) (i-1, j) (i, j) (i+1, j) (i+2, j) (i-1, j-1) (i, j-1) (i+1, j-1) (i, j-2)
Partial Derivatives Laplacian Operator j+1 j j-1 i-1 i i+1
Partial Derivatives Mixed Derivative j+1 j j-1 i-1 i i+1
Bi-harmonic Operator j+2 j+1 j j-1 j-2 i-2 i-1 i+1 i+2 i
Richardson Extrapolation This technique uses the concept of variable grid sizes to reduce the error. The technique uses a simple method for eliminating the error. Consider a second order central difference technique. Write the equation in the form:
Richardson Extrapolation The central difference can be defined as Write the equation with different grid sizes
Richardson Extrapolation Expand the terms:
Richardson Extrapolation Multiply eqn [2] by 4 and subtract eqn [1] from it.
Richardson Extrapolation The equation can be rewritten as: It can be rewritten in the form
Richardson Extrapolation The technique can be extrapolated to include the higher order error elimination by using a finer grid.
Richardson Extrapolation Example The function is given: Find the first derivative at x=1.25 using a central difference scheme and Dh = 0.25. The exact solution:
Richardson Extrapolation Example The data points are: The derivatives using central difference
Richardson Extrapolation Example The results of the central difference scheme are: The Richardson Extrapolation uses these results to find a better solution
Summary • Finite Difference Techniques • Taylor Series • Lagrange Polynomials • Error Calculation
Summary • Finite Difference Techniques • Forward Difference Scheme • Backward Difference Scheme • Central Difference Scheme
Homework • Check the Homework webpage