Anda di halaman 1dari 27

CE 341/441 - Lecture 13 - Fall 2004

p. 13.1
LECTURE 13
NUMERICAL DIFFERENTIATION FORMULAE BY INTERPOLATING POLY-
NOMIALS
Relationship Between Polynomials and Finite Difference Derivative Approximations
We noted that N
th
degree accurate Finite Difference (FD) expressions for rst derivatives
have an associated error
If f(x) is an N
th
degree polynomial then,
and the FD approximation to the rst derivative is exact!
Thus if we know that a FD approximation to a polynomial function is exact, we can
derive the form of that polynomial by integrating the previous equation.
E h
Nd
N 1 +
f
dx
N 1 +
-----------------
d
N 1 +
f
dx
N 1 +
------------------ 0 =
f x ( ) a
1
x
N
a
2
x
N 1
a
N 1 +
+ + +
CE 341/441 - Lecture 13 - Fall 2004
p. 13.2
This implies that a distinct relationship exists between polynomials and FD expressions
for derivatives (different relationships for higher order derivatives).
We can in fact develop FD approximations from interpolating polynomials
Developing Finite Difference Formulae by Differentiating Interpolating Polynomials
Concept
The approximation for the derivative of some function can be found by
taking the derivative of a polynomial approximation, , of the function
.
Procedure
Establish a polynomial approximation of degree such that
is forced to be exactly equal to the functional value at data points or nodes
The derivative of the polynomial is an approximation to the derivative of
p
th
f x ( )
p
th
g x ( )
f x ( )
g x ( ) N N p
g x ( ) N 1 +
p
th
g x ( ) p
th
f x ( )
CE 341/441 - Lecture 13 - Fall 2004
p. 13.3
Approximations to First and Second Derivatives Using Quadratic Interpolation
We will illustrate the use of interpolation to derive FD approximations to rst and
second derivatives using a 3 node quadratic interpolation function
For rst derivatives p=1 and we must establish at least an interpolating polynomial of
degree N=1 with N+1=2 nodes
For second derivatives p=2 and we must establish at least an interpolating polyno-
mial of degree N=2 with N+1=3 nodes
Thus a quadratic interpolating function will allow us to establish both rst and
second derivative approximations
Apply a shifted coordinate system to simplify the derivation without affecting the gener-
ality of the derivation
h h x
0
x
1
x
2
f
0
f
1
f
2
x
shifted x axis h 2h 0
CE 341/441 - Lecture 13 - Fall 2004
p. 13.4
Develop a quadratic interpolating polynomial
We apply the Power Series method to derive the appropriate interpolating polynomial
Alternatively we could use either Lagrange basis functions or Newton forward or
backward interpolation approaches in order to establish the interpolating polyno-
mial
The 3 node quadratic interpolating polynomial has the form
The approximating Lagrange polynomial must match the functional values at all
data points or nodes ( , , )



g x ( ) a
o
x
2
a
1
x a
2
+ + =
N 1 +
x
o
0 = x
1
h = x
2
2h =
g x
o
( ) f
o
= a
o
0
2
a
1
0 a
2
+ + f
o
=
g x
1
( ) f
1
= a
o
h
2
a
1
h a
2
+ + f
1
=
g x
2
( ) f
2
= a
o
2h ( )
2
a
1
2h ( ) a
2
+ + f
2
=
CE 341/441 - Lecture 13 - Fall 2004
p. 13.5
Setting up the constraints as a system of simultaneous equations
Solve for , ,
, ,
The interpolating polynomial and its derivative are equal to:
0 0 1
h
2
h 1
4h
2
2h 1
a
o
a
1
a
2
f
o
f
1
f
2
=
a
o
a
1
a
2
a
o
f
2
2 f
1
f
o
+
2h
2
--------------------------------- = a
1
4 f
1
f
2
3 f
o

2h
------------------------------------ = a
2
f
o
=
g x ( )
f
2
2 f
1
f
o
+
2h
2
---------------------------------- x
2
4 f
1
f
2
3 f
o

2h
------------------------------------- x f
o
+ + =
g
1 ( )
x ( )
f
2
2 f
1
f
o
+
h
2
---------------------------------- x
4 f
1
f
2
3 f
o

2h
------------------------------------- + =
CE 341/441 - Lecture 13 - Fall 2004
p. 13.6
Evaluating g
(1)
(x
o
) to obtain a forward difference approximation to the rst derivative
Evaluating the derivative of the interpolating function at

Since the function is approximated by the interpolating function
Substituting in for the expression for
x
o
0 =
g
1 ( )
x
o
( ) g
1 ( )
0 ( ) =
g
1 ( )
x
o
( )
3 f
o
4 f
1
f
2
+
2h
----------------------------------------- =
f x ( ) g x ( )
f
1 ( )
x
o
g
1 ( )
x
o
( )
g
1 ( )
x
o
( )
f
1 ( )
x
o
3 f
o
4 f
1
f
2
+
2h
-----------------------------------------
CE 341/441 - Lecture 13 - Fall 2004
p. 13.7
Generalize the node numbering for the approximation
This results in the generic 3 node forward difference approximation to the rst derivative
at node i
i i+1 i+2
generalized nodal numbering
x
0
x
1
x
2
f
i
1 ( )
3 f
i
4 f
i 1 +
f
i 2 +
+
2h
-----------------------------------------------------
CE 341/441 - Lecture 13 - Fall 2004
p. 13.8
Evaluating g
(1)
(x
1
) to obtain a central difference approximation to the rst derivative
Evaluating the derivative of the interpolating function at


Again since the function is approximated by the interpolating function
Substituting in for the expression for
x
1
h =
g
1 ( )
x
1
( ) g
1 ( )
h ( ) =
g
1 ( )
x
1
( )
f
2
2 f
1
f
o
+ ( )
h
2
--------------------------------------h
4 f
1
f
2
3 f
o

2h
------------------------------------ + =
g
1 ( )
x
1
( )
f
2
f
o

2h
----------------- =
f x ( ) g x ( )
f
1 ( )
x
1
g
1 ( )
x
1
( )
g
1 ( )
x
1
( )
f
1 ( )
x
1
f
2
f
o

2h
-----------------
CE 341/441 - Lecture 13 - Fall 2004
p. 13.9
Generalize the node numbering
This results in the generic expression for the three node central difference approxima-
tion to the rst derivative
x
0
i-1
x
1
x
2
i i+1
f
i
1 ( )
f
i 1 +
f
i 1

2h
------------------------------
CE 341/441 - Lecture 13 - Fall 2004
p. 13.10
Evaluating g
(1)
(x
2
) to obtain a backward difference approximation to the rst derivative
Evaluating the derivative of the interpolating function at


Again since the function is approximated by the interpolating function
Substituting in for the expression for
x
2
2h =
g
1 ( )
x
2
( ) g
1 ( )
2h ( ) =
g
1 ( )
x
2
( )
f
2
2 f
1
f
o
+ ( )
h
2
--------------------------------------2h
4 f
1
f
2
3 f
o

2h
------------------------------------ + =
g
1 ( )
x
2
( )
3 f
2
4 f
1
f
o
+
2h
------------------------------------ =
f x ( ) g x ( )
f
1 ( )
x
2
g
1 ( )
x
2
( )
g
1 ( )
x
2
( )
f
1 ( )
x
2
3 f
2
4 f
1
f
o
+
2h
------------------------------------
CE 341/441 - Lecture 13 - Fall 2004
p. 13.11
Generalizing the node numbering
This results in the generic expression for a three node backward difference approxima-
tion to the rst derivative
x
0
i-1
x
1
x
2
i i-2
f
i
1 ( )
3 f
i
4 f
i 1
f
i 2
+
2h
------------------------------------------------
CE 341/441 - Lecture 13 - Fall 2004
p. 13.12
Evaluating g
(2)
(x
o
) to obtain a forward difference approximation to the second derivative
We note that in general can be computed as:
Evaluating the second derivative of the interpolating function at :

Again since the function is approximated by the interpolating function , the
second derivative at node x
o
is approximated as:
g
2 ( )
x ( )
g
2 ( )
x ( )
f
2
2 f
1
f
o
+
h
2
---------------------------------- =
x
o
0 =
g
2 ( )
x
o
( ) g
2 ( )
0 ( ) =
g
2 ( )
x
o
( )
f
2
2 f
1
f
o
+
h
2
--------------------------------- =
f x ( ) g x ( )
f
2 ( )
x
o
g
2 ( )
x
o
( )
CE 341/441 - Lecture 13 - Fall 2004
p. 13.13
Substituting in for the expression for
Generalizing the node numbering
This results in the generic expression for a three node forward difference approximation
to the second derivative
g
2 ( )
x
o
( )
f
2 ( )
x
o
f
2
2 f
1
f
o
+
h
2
---------------------------------
x
2
i+2
x
1
i+1
x
0
i
f
i
2 ( )
f
i 2 +
2 f
i 1 +
f
i
+
h
2
---------------------------------------------
CE 341/441 - Lecture 13 - Fall 2004
p. 13.14
Evaluating g
(2)
(x
1
) to obtain a central difference approximation to the second derivative
Evaluating the second derivative of the interpolating function at :

Again since the function is approximated by the interpolating function , the
second derivative at node x
1
is approximated as:
Substituting in for the expression for
x
1
h =
g
2 ( )
x
1
( ) g
2 ( )
h ( ) =
g
2 ( )
x
1
( )
f
2
2 f
1
f
o
+
h
2
--------------------------------- =
f x ( ) g x ( )
f
2 ( )
x
1
g
2 ( )
x
1
( )
g
2 ( )
x
1
( )
f
2 ( )
x
1
f
2
2 f
1
f
o
+
h
2
---------------------------------
CE 341/441 - Lecture 13 - Fall 2004
p. 13.15
Generalizing node numbering
This results in the generic expression for a three node central difference approximation
to the second derivative
Notes on developing differentiation formulae by interpolating polynomials
In general we can use any of the interpolation techniques to develop an interpolation
function of degree . We can then simply differentiate the interpolating function
and evaluate it at any of the nodal points used for interpolation in order to derive an
approximation for the p
th
derivative.
Orders of accuracy may vary due to the accuracy of the interpolating function varying.
Exact accuracy can be obtained by substituting in Taylor series expansions or by consid-
ering the accuracy of the approximating polynomial g(x).
x
0
x
1
x
2
i i+1 i-1
f
i
2 ( )
f
i 1 +
2 f
i
f
i 1
+
h
2
---------------------------------------------
N p
CE 341/441 - Lecture 13 - Fall 2004
p. 13.16
Approximations and Associated Error Estimates to First and Second Derivatives Us-
ing Quadratic Interpolation
We can derive an error estimate when using interpolating polynomials to establish
nite difference formulae by simply differentiating the error estimate associated with
the interpolating function.
We will illustrate the use of a 3 node Newton forward interpolation formula to derive:
A central approximation to the rst derivative with its associated error estimate
A forward approximation to the second derivative with its associated error estimate
Developing a 3 node interpolating function using Newton forward interpolation
A quadratic interpolating polynomial ( ) has 3 associated nodes ( ) or
interpolating points. We again assume that the nodes are evenly distributed as:
With a quadratic interpolating polynomial, we can derive differentiation formulae for
both the rst and second derivatives but no higher
N 2 = N 1 + 3 =
x
0
x
1
x
2
f
0
f
1
f
2
h h
x
CE 341/441 - Lecture 13 - Fall 2004
p. 13.17
The approximating or interpolating function is dened using Newton forward interpola-
tion as:
The error can be approximately expressed in either of the following forms:
These latter two forms which do not involve are more suitable for the necessary differ-
entiation w.r.t. x since is functionally dependent on x, i.e.
f x ( ) g x ( ) e x ( ) + =
g x ( ) f
o
x x
o
( )
f
o
h
---------
1
2!
----- x x
o
( ) x x
1
( )

2
f
o
h
2
------------ + + =
e x ( )
x x
o
( ) x x
1
( ) x x
2
( )
3!
--------------------------------------------------------- f
3 ( )
( ) = x
o
x
2
< <
e x ( )
x x
o
( ) x x
1
( ) x x
2
( )
3!
--------------------------------------------------------- f
o
3 ( )

e x ( )
x x
o
( ) x x
1
( ) x x
2
( )
3!
---------------------------------------------------------

3
f
o
h
3
------------

x ( ) =
CE 341/441 - Lecture 13 - Fall 2004
p. 13.18
The forward difference operators are dened as:
Deriving a central approximation to the rst derivative and the associated error estimate
Evaluating the rst derivative of the function at :
f
o
f
1
f
o

2
f
o
f
2
2 f
1
f
o
+
x
1
f
1 ( )
x x
1
=
g
1 ( )
x
1
( ) e
1 ( )
x
1
( ) + =
x
0
x
1
x
2
central
CE 341/441 - Lecture 13 - Fall 2004
p. 13.19
Evaluating in the previous expression g
1 ( )
x ( )
f
1 ( )
x x
1
=
f
o
h
---------
1
2!
----- x x
o
( )

2
f
o
h
2
------------
1
2!
----- x x
1
( )

2
f
o
h
2
------------ e
1 ( )
x ( ) + + +
x x
1
=
=
f
1 ( )
x x
1
=
f
o
h
---------
1
2!
----- x
1
x
o
( )

2
f
o
h
2
------------ e
1 ( )
x
1
( ) + + =
f
1 ( )
x x
1
=
f
1
f
o

h
-----------------
1
2
---
h
h
2
----- f
2
2 f
1
f
o
+ ( ) e
1 ( )
x
1
( ) + + =
f
1 ( )
x x
1
=
f
2
f
o

2h
----------------- e
1 ( )
x
1
( ) + =
CE 341/441 - Lecture 13 - Fall 2004
p. 13.20
Now evaluate using a non dependent expression for the error term and evalu-
ating this expression at
Substituting for results in:
e
1 ( )
x ( )
x
1
e
1 ( )
x
1
( )
1
3!
----- f
3 ( )
x
o
( ) x x
1
( ) x x
2
( ) x x
o
( ) x x
2
( ) x x
o
( ) x x
1
( ) + + [ ]
x x
1
=

e
1 ( )
x
1
( )
1
3!
----- f
3 ( )
x
o
( ) x
1
x
o
( ) x
1
x
2
( )
e
1 ( )
x
1
( )
h
2
3!
----- f
3 ( )
x
o
( )
e
1 ( )
x
1
( )
f
1 ( )
x x
1
=
f
2
f
o

2h
-----------------
h
2
3!
----- f
3 ( )
x
o
( )
CE 341/441 - Lecture 13 - Fall 2004
p. 13.21
Generalizing node numbering as:
This results in the generic expression for a three node central difference approximation
to the rst derivative with an appropriate error estimate
x
0
x
1
x
2
i i+1 i-1
f
i
1 ( )
f
i 1 +
f
i 1

2h
------------------------------ E + =
E
h
2
6
----- f
3 ( )
x
i 1
( )
CE 341/441 - Lecture 13 - Fall 2004
p. 13.22
Notes
The same discrete differentiation formulae can be derived using the Taylor series
approach.
The results for the error estimates are the same regardless of whether you:
Apply differentiation to , which represents the error estimate for .
Apply a Taylor series analysis to the differentiation formula you derived.
The error estimate for the interpolating function with is most precise in a
formal sense (i.e. it includes all H.O.T. as well!). However there is a weak depen-
dence of on and therefore some inaccuracies may be incurred when differenti-
ating to obtain an error estimate for the corresponding nite difference
approximation.
Practically, for estimating the error of the differentiating formula derived by esti-
mating , we can apply the procedure used and examine an estimate of the
error which does not depend on . This is equivalent to examining the leading order
term in the truncated series.
Note that the derivative in the error formula on the previous page may also be esti-
mated at
e x ( ) g x ( )
g x ( )
x
e x ( )
e
1 ( )
x ( )

x
i
CE 341/441 - Lecture 13 - Fall 2004
p. 13.23
Deriving a forward difference approximation to the second derivative and the associated
error estimate
Evaluating the second derivative of the function at :
Evaluate and substitute
x
o
f
2 ( )
x x
o
=
g
2 ( )
x
o
( ) e
2 ( )
x
o
( ) + =
x
0
x
1
x
2
forward
g
2 ( )
x ( )
f
2 ( )
x x
o
=
1
2!
-----

2
f
o
h
2
------------
1
2!
-----

2
f
o
h
2
------------ e
2 ( )
x ( ) + +
x x
o
=
=
f
2 ( )
x x
o
=

2
f
o
h
2
------------ e
2 ( )
x
o
( ) + =
f
2 ( )
x x
o
=
f
2
2 f
1
f
o
+
h
2
--------------------------------- e
2 ( )
x
o
( ) + =
CE 341/441 - Lecture 13 - Fall 2004
p. 13.24
Now evaluate using a non dependent expression for the error term and evalu-
ating this expression at
Substituting for results in:
e
2 ( )
x ( )
x
o
e
2 ( )
x
o
( )
1
3!
----- f
3 ( )
x
o
( ) x x
1
( ) x x
2
( ) x x
o
( ) x x
2
( ) x x
o
( ) x x
1
( ) + + + + + [ ]
x x
o
=

e
2 ( )
x
o
( )
1
3!
----- f
3 ( )
x
o
( ) x
o
x
1
( ) x
o
x
2
( ) x
o
x
o
( ) x
o
x
2
( ) x
o
x
o
( ) x
o
x
1
( ) + + + + + [ ]
e
2 ( )
x
o
( )
1
3!
----- f
3 ( )
x
o
( ) h 2h 0 2h 0 h + + [ ]
e
2 ( )
x
o
( ) h f
3 ( )
x
o
( )
e
2 ( )
x
o
( )
f
2 ( )
x x
o
=
f
2
2 f
1
f
o
+
h
2
--------------------------------- h f
3 ( )
x
o
( )
CE 341/441 - Lecture 13 - Fall 2004
p. 13.25
Generalizing the node numbering:
This results in the generic expression for a three node forward difference approximation
to the second derivative with an appropriate error estimate
x
0
x
1
x
2
i i+2 i+1
f
2 ( )
f
i 2 +
2 f
i 1 +
f
i

h
2
--------------------------------------------- E + =
E h f
3 ( )
x
i
( )
CE 341/441 - Lecture 13 - Fall 2004
p. 13.26
SUMMARY OF LECTURE 11, 12 AND 13
Difference formulae can be developed such that linear combinations of functional values
at various nodes approximate a derivative at a node.
In general, to develop a difference formula for you need nodes for accu-
racy and nodes for O(h)
N
accuracy. Central approximations for even order deriva-
tives require fewer nodes due to a fortunate cancelation of error terms.
The generic form to evaluate a difference formula
when nodes are used
Substitute in Taylor series expansions for , etc. about node , re-arrange equa-
tions such that coefcients multiply equal order derivatives at node and generate
algebraic equations by setting the coefcient of equal to 1 and the
other coefcients equal to zero.
Solve for , , ...
f
i
p ( )
p 1 + O h ( )
p N +
f
i
p ( )
E
a

+ + +
h
p
--------------------------------------------------------------------- =
E O h ( )
N
= p N +
f

i
i
f
i
p ( )
p N 1 +
a

CE 341/441 - Lecture 13 - Fall 2004


p. 13.27
Forward, central and backward difference operators can be manipulated in ways analo-
gous to differentiation to develop higher order differences
Formulae to approximate differentiation using the difference operators can be estab-
lished. However, general formulae for any order accuracy are difcult to establish. Also
you still need Taylor series analysis to derive the accuracy of the approximations.
Numerical differentiation formulae can be established by dening an interpolating poly-
nomial for at least nodes (to evaluate the derivative). Any interpolating tech-
nique formula can be used. The numerical differencing formula is simply the
differentiated interpolating polynomial evaluated at one of the nodes used for interpola-
tion. The node at which the formula is evaluated establishes whether the approximation
is forward, backward, central, etc.
p 1 + p
th

Anda mungkin juga menyukai