Title: Lecture 18 Numerical Differentiation
1Lecture 18 - Numerical Differentiation
2Lectures Goals
- Finite Difference Schemes
- Taylor Series Expansion for Differentiation
- Basic Numerical Integration
- Trapezoidal Rule
- Simpsons Rule
- Midpoint
- Gaussian Quadrature
3Calculus - Numerical Methods
Differentiation
Integration
4Numerical 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)
5Numerical Differentiation
- Represent the function by Taylor polynomials or
Lagrange interpolation - Evaluate the derivatives of the interpolation
polynomial at selected nodal points
6Numerical Differentiation
A Taylor series or Lagrange interpolation of
points can be used to find the derivatives. The
Taylor series expansion is defined as
7First Derivative at a Point
i-2 i-1 i
i1 i2
8Numerical Differentiation
Use the Taylor series expansion to represent
three points about single location
9Numerical Differentiation
Assume that the data points are equally spaced
and the equations can be written as
10Forward Differentiation
For a forward first derivative, subtract eqn2
from eqn1
Rearrange the equation
11Forward Differentiation
As the Dx gets smaller the error will get smaller
The error is defined as
12Backward Differentiation
Subtract eqn3 from eqn2
The error is defined as
13Central Differentiation
Subtract eqn3 from eqn1
The error is defined as
14Differential 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.
15Numerical Differentiation
If you want to improve the accuracy and decrease
the error you will need to eliminate terms
16Higher Order Errors in Differentiation
The terms become
The terms become A-3, B 4 and C-1
17Higher Order 1st Derivative
Parabolic curve
i-2 i-1 i
i1 i2
18Higher 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.
192nd Derivative of the Function
It will require three terms to get a central 2nd
derivative of discrete set of data.
202nd Order Central Difference
The terms become
The terms become A1,B-2 and C1. Therefore
21Lagrange Differentiation
Another form of differentiation is to use the
Lagrange interpolation between three points. The
values can be determine for unevenly spaced
points. Given
22Lagrange Differentiation
Differentiate the Lagrange interpolation
Assume a constant spacing
23Lagrange Differentiation
Differentiate the Lagrange interpolation
Various locations
24Lagrange Differentiation
To find a higher order derivative from the
Lagrange interpolation for a three point Lagrange
Take the derivative
25Partial Derivatives
- Straightforward extension of one-dimensional
formula
(i, j2)
(i, j1)
(i1, j1)
(i-1, j1)
(i-2, j)
(i-1, j)
(i, j)
(i1, j)
(i2, j)
(i, j-1)
(i-1, j-1)
(i1, j-1)
(i, j-2)
26(i, j2)
(i, j1)
(i1, j1)
(i-1, j1)
(i-2, j)
(i-1, j)
(i, j)
(i1, j)
(i2, j)
(i, j-1)
(i-1, j-1)
(i1, j-1)
(i, j-2)
27Partial Derivatives
Laplacian Operator
j1
j
j-1
i-1
i
i1
28Partial Derivatives
Mixed Derivative
j1
j
j-1
i-1
i
i1
29Bi-harmonic Operator
j2
j1
j
j-1
j-2
i-1
i1
i-2
i2
i
30Richardson 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
31Richardson Extrapolation
The central difference can be defined as
Write the equation with different grid sizes
32Richardson Extrapolation
Expand the terms
33Richardson Extrapolation
Multiply eqn 2 by 4 and subtract eqn 1 from
it.
34Richardson Extrapolation
The equation can be rewritten as
It can be rewritten in the form
35Richardson Extrapolation
The technique can be extrapolated to include the
higher order error elimination by using a finer
grid.
36Richardson Extrapolation Example
The function is given
Find the first derivative at x1.25 using a
central difference scheme and Dh 0.25. The
exact solution
37Richardson Extrapolation Example
The data points are
The derivatives using central difference
38Richardson Extrapolation Example
The results of the central difference scheme are
The Richardson Extrapolation uses these results
to find a better solution
39Summary
- Finite Difference Techniques
- Taylor Series
- Lagrange Polynomials
- Error Calculation
40Summary
- Finite Difference Techniques
- Forward Difference Scheme
- Backward Difference Scheme
- Central Difference Scheme
41Homework
- Check the Homework webpage