Professional Documents
Culture Documents
LECTURE 7
• Use Newton Interpolation which is based on developing difference tables for a given set
of data points
p. 7.1
CE 341/441 - Lecture 7 - Fall 2004
f f2 = f(x2)
f1 = f(x1) f3 = f(x3)
f0 = f(x0) fN = f(xN )
x
x0 x1 x2 x3 xN
0 1 2 3 N (i)
h = interval size
p. 7.2
CE 341/441 - Lecture 7 - Fall 2004
2
∆ fi ≡ ∆fi+1 – ∆fi (Second order forward difference)
2
∆ f i = ( f i + 2 – f i + 1) – ( f i + 1 – f i)
2
∆ fi = fi+2 – 2fi+1 + fi
3 2 2
∆ fi ≡ ∆ fi+1 – ∆ fi (Third order forward difference)
3
∆ f i = ( f i + 3 – 2 f i + 2 + f i + 1) – ( f i + 2 – 2 f i + 1 + f i)
3
∆ fi = fi+3 – 3fi+2 + 3fi+1 – fi
k k–1 k–1
∆ fi = ∆ fi+1 – ∆ f i (kth order forward difference)
p. 7.3
CE 341/441 - Lecture 7 - Fall 2004
i fi ∆fi 2
∆ fi
3
∆ fi
4
∆ fi
2 3 2 2 4 3 3
0 fo ∆fo = f1 – fo ∆ fo = ∆f1 – ∆fo ∆ fo = ∆ f1 – ∆ fo ∆ fo = ∆ f1 – ∆ fo
2 3 2 2
1 f1 ∆f1 = f2 – f1 ∆ f1 = ∆f2 – ∆f1 ∆ f1 = ∆ f2 – ∆ f1
2
2 f2 ∆f2 = f3 – f2 ∆ f2 = ∆f3 – ∆f2
3 f3 ∆f3 = f4 – f3
4 f4
• Note that to compute higher order differences in the tables, we take forward differences
of previous order differences instead of using expanded formulae.
• The order of the differences that can be computed depends on how many total data
points, x o, …, x N , are available
p. 7.4
CE 341/441 - Lecture 7 - Fall 2004
Example 1
i xi fi ∆fi 2
∆ fi
3
∆ fi
4
∆ fi
5
∆ fi
0 2 -7 4 5 5 3 1
1 4 -3 9 10 8 4
2 6 6 19 18 12
3 8 25 37 30
4 10 62 67
5 12 129
p. 7.5
CE 341/441 - Lecture 7 - Fall 2004
f(x)
f2
f3
f1
f0 fN
x
x0 x1 x2 x3 xN
• Summary of Steps
• Step 1: Develop a general Taylor series expansion for f ( x ) about x o .
• Step 2: Express the various order forward differences at x o in terms of f ( x ) and its
derivatives evaluated at x o . This will allow us to express the actual derivatives eval-
uated at x o in terms of forward differences.
• Step 3: Using the general Taylor series expansion developed in Step 1, sequentially
substitute in for the derivatives evaluated at x o in terms of forward differences (i.e.
substitute in the expressions developed in Step 2).
p. 7.6
CE 341/441 - Lecture 7 - Fall 2004
Step 1
Step 2a
• Express first order forward difference in terms of f o , f (o1 ), …
∆fo ≡ f1 – fo
• However since f 1 = f ( x 1 ) , we can use the Taylor series given in Step 1 to express f 1 in
terms of f o and its derivatives:
p. 7.7
CE 341/441 - Lecture 7 - Fall 2004
• Now, substitute in for f 1 into the definition of the first order forward differences
• Note that the first order forward difference divided by h is in fact an approximation to
the first derivative to O ( h ) . However, we will use all the terms given in this sequence.
p. 7.8
CE 341/441 - Lecture 7 - Fall 2004
Step 2b
(1)
• Express second order forward difference in terms of f o, f o , …
2
∆ fo ≡ f2 – 2f1 + fo
• For f 2 = f ( x 2 ) we use the T.S. given in Step 1 to express f 2 in terms of f o and deriva-
tives of f evaluated at x o
• We note that x 2 – x o = 2h
p. 7.9
CE 341/441 - Lecture 7 - Fall 2004
• Now substitute in for f 2 and f 1 into the definition of the second order forward difference
operator
2
(2) ∆ fo (3) 2
fo = -----------
2
- – h f o + O ( h )
h
• Note that the second order forward difference divided by h 2 is in fact an approximation
to f (o2 ) to O ( h ) . However, we will use all terms in the expression.
p. 7.10
CE 341/441 - Lecture 7 - Fall 2004
Step 2c
(1)
• Express the third order forward difference in terms of f o, f o …
3
∆ fo ≡ f3 – 3f2 + 3f1 – fo
• Noting that x 3 – x o = 3h
p. 7.11
CE 341/441 - Lecture 7 - Fall 2004
• Substituting in for f 3 , f 2 and f 1 into the definition of the third order forward difference
formula.
3 (1) 9 2 (2) 9 3 (3) 4 ( 1 ) 12 2 ( 2 ) 24 3 ( 3 ) 4
∆ f o = f o + 3h f o + --- h f o + --- h f o + O ( h ) – 3 f o – 6h f o – ------ h f o – ------ h f o + O ( h )
2 2 2 3!
3 3 (3) 4
∆ f o = h f o + O(h)
3
(3) ∆ fo
fo - + O(h)
= -----------
3
h
p. 7.12
CE 341/441 - Lecture 7 - Fall 2004
Step 3a
• Consider the general T.S. expansion presented in Step 1 to define f ( x ) and substitute in
(1)
for f o using the result in Step 2a.
• Note that now we are not evaluating the T.S. at a data point but at any x
∆f 1 (2) 1 2 (3) 3
f ( x ) = f o + ( x – x o ) ---------o – ----- h f o – ----- h f o – O ( h )
h 2! 3!
1 2 (2) 1 3 (3) 4
+ ----- ( x – x o ) f o + ----- ( x – x o ) f o + O ( x – x o )
2! 3!
x – xo 1 2 (2)
f ( x ) = f o + -------------- ∆ f o + ----- [ – ( x – x o )h + ( x – x o ) ] f o
h 2!
1 2 3 (3) 4
+ ----- [ – ( x – x o )h + ( x – x o ) ] f o + O ( h )
3!
p. 7.13
CE 341/441 - Lecture 7 - Fall 2004
Step 3b
2
x – xo 1 2 ∆ fo (3) 2
f ( x ) = f o + -------------- ∆ f o + ----- [ – ( x – x o )h + ( x – x o ) ] -----------
- – h f o + O ( h )
h 2! h
2
1 2 3 (3) 4
+ ----- [ – ( x – x o ) h + ( x – x o ) ] f o + O ( h )
3!
2
x – xo 1 ( x – xo ) ( x – xo ) 2
f ( x ) = f o + -------------- ∆ f o + ----- – ------------------
- + --------------------
- ∆ fo
h 2! h h
2
1 2 3 2 (3) 4
+ ----- [ 2 ( x – x o )h + ( x – x o ) – 3 ( x – x o ) h ] f o + O ( h )
3!
p. 7.14
CE 341/441 - Lecture 7 - Fall 2004
Step 3c
(3)
• Substitute in for f o from Step 2c
2
( x – xo ) 1 ( x – xo ) ( x – xo ) 2
f ( x) = f o + ------------------
- ∆ f o + - – ------------------- + --------------------
---- - ∆ fo
h 2! h h
2
3
1 2 3 2 ∆ fo 4
+ ----- [ 2 ( x – x o )h + ( x – x o ) – 3 ( x – x o ) h ] -----------
3
- + O ( h )
3! h
2
∆fo 1 ∆ fo
f ( x ) = f o + ( x – x o ) --------- + ----- ( x – x o ) [ – h + ( x – x o ) ] -----------
2
-
h 2! h
3
1 2 2 ∆ fo 4
+ ----- ( x – x o ) [ 2h + ( x – x o ) – 3 ( x – x o )h ] -----------
3
- + O ( h ) + HOT
3! h
p. 7.15
CE 341/441 - Lecture 7 - Fall 2004
2
∆fo 1 ∆ fo
f ( x ) = f o + ( x – x o ) --------- + ----- ( x – x o ) [ x – ( x o + h ) ] -----------
2
-
h 2! h
3
1 ∆ fo 4
+ ----- ( x – x o ) [ ( x – ( x o + h ) ) ( x – ( x o + 2h ) ) ] -----------
3
- + O ( h ) + HOT
3! h
2 3
∆ fo 1 ∆ fo 1 ∆ fo
g ( x ) = f o + ( x – x o ) ---------- + ----- ( x – x o ) ( x – x 1 ) -----------
2
- + ----
- ( x – x o ) ( x – x 1 ) ( x – x 2 ) -----------
3
-
h 2! h 3! h
N
1 ∆ fo
+ … + ------ ( x – x o ) ( x – x 1 ) ( x – x 2 )… ( x – x N – 1 ) -------------
N
N! h
p. 7.16
CE 341/441 - Lecture 7 - Fall 2004
g ( xo ) = f o
f1 – fo f 1 – f o
g ( x 1 ) = f o + ( x 1 – x o ) ----------------- = f o + h ----------------- = f 1
h h
f1 – fo
g ( x 2 ) = f o + ( x 2 – x o ) ----------------- + --- ( x 2 – x o ) ( x 2 – x 1 ) ----2- ( f 2 – 2 f 1 + f o )
1 1
h 2
h
⇒
2h ( 2h )h
g ( x 2 ) = f o + ------ ( f 1 – f o ) + -------------
2
-( f 2 – 2 f 1 + f o)
h 2h
⇒
g ( x2 ) = f o + 2 f 1 – 2 f o + f 2 – 2 f 1 + f o = f 2
• In general
g ( xi ) = f i i = 0, N
p. 7.17
CE 341/441 - Lecture 7 - Fall 2004
• It can be readily shown that the error at any x is: (by carrying through error terms in the
T.S.)
( x – x o ) ( x – x 1 )… ( x – x N ) ( N + 1 )
e ( x ) = f ( x ) – g ( x ) = -------------------------------------------------------------------- f (ξ) xo < ξ < x N
( N + 1 )!
• This error function is identical to that for Lagrange Interpolation (since the polynomial
approximation is the same).
N+1
• However we note that f ( x ) can be approximated as (can be shown by T.S.)
N+1
(N + 1) ∆ fo
f ( x o ) ≅ -------------------
N+1
-
h
N+1
(N + 1) ∆ fo
f ( ξ ) ≅ -------------------
N+1
-
h
p. 7.18
CE 341/441 - Lecture 7 - Fall 2004
• Notes
• Approximation for e ( x ) is equal to the term that would follow the last term in the
th
N degree polynomial series for g ( x )
p. 7.19
CE 341/441 - Lecture 7 - Fall 2004
Example 2
(Part a)
• 3 data points ⇒ N = 2
2
∆fo 1 ∆ fo
g 3 ( x ) = f o + ( x – x o ) --------- + ----- ( x – x o ) ( x – x 1 ) -----------
2
-
h 2! h
with
xo = 2 x1 = 4 x2 = 6 and h = 2
p. 7.20
CE 341/441 - Lecture 7 - Fall 2004
• f o, ∆ f o and ∆ 2 f o are obtained by simply picking values off of the difference table
(across the row i = 0 )
2
f o = –7 ∆ f o = 4 ∆ f o = 5
4 1 5
g 3 ( x ) = – 7 + ( x – 2 ) --- + ----- ( x – 2 ) ( x – 4 ) ---
2 2! 4
( x – xo ) ( x – x1 ) ( x – x2 ) 1 3
e 3 ( x ) = --------------------------------------------------------- ----3- ∆ f o
3! h
3
• Simply substitute in for x o , x 1 , x 2 , h and pick off ∆ f o = 5 from the table in Example 1
( x – 2)( x – 4)( x – 6) 1 5
e 3 ( x ) = ---------------------------------------------------- ⋅ ----3- ⋅ 5 = ( x – 2 ) ( x – 4 ) ( x – 6 ) ------
6 2 48
p. 7.21
CE 341/441 - Lecture 7 - Fall 2004
(Part b)
• 4 data points x o = 2 , x 1 = 4 , x 2 = 6 , x 3 = 8 ⇒ N = 3
3
e 4 ( x ) = ( x – 2 ) ( x – 4 ) ( x – 6 ) ( x – 8 ) ---------
384
p. 7.22
CE 341/441 - Lecture 7 - Fall 2004
(Part c)
• Pick off f o, ∆ f o and ∆ 2 f o from the same difference table with a shifted index
2
f o = 6, ∆ f o = 19 , ∆ f o = 18
• Substituting
19 1 18
g 3/s ( x ) = 6 + ( x – 6 ) ------ + ----- ( x – 6 ) ( x – 8 ) -----2-
2 2! 2
p. 7.23
CE 341/441 - Lecture 7 - Fall 2004
o
∇ fi ≡ fi Zeroth order backward difference
2
∇ fi = ∇fi – ∇fi–1 Second order backward difference
k k–1 k–1
∇ fi = ∇ fi – ∇ fi–1 kth order backward difference
p. 7.24
CE 341/441 - Lecture 7 - Fall 2004
2
∇ fN 1 ∇ fN
g ( x ) = f N + ( x – x N ) ------------ + ----- ( x – x N ) ( x – x N – 1 ) -------------
2
-
h 2! h
3
1 ∇ fN
+ ----- ( x – x N ) ( x – x N – 1 ) ( x – x N – 2 ) -------------
3
-
3! h
N
1 ∇ fN
+ ------ ( x – x N ) ( x – x N – 1 )… ( x – x 1 ) --------------
N
-
N! h
• Note that we are really expanding about the right most point to the left. Therefore we
must develop f N , ∇ f N etc. in the difference table
x0 x1 xN - 1 xN
p. 7.25
CE 341/441 - Lecture 7 - Fall 2004
• Newton interpolation can be readily extended to deal with non-uniformly spaced data
points
x
x0 x1 x2 x3 x4
• The difference table for non-uniformly spaced nodes is developed and an appropriate
interpolation formula is developed and used
p. 7.26
CE 341/441 - Lecture 7 - Fall 2004
SUMMARY OF LECTURE 7
• Error is readily established and estimated from the difference table (as long as you have
one more data point than used in interpolation)
• Newton interpolation through N + 1 data points gives the same N th degree polynomial as
Lagrange interpolation
• Newton interpolation is more efficient than Lagrange interpolation and is easily imple-
mented
p. 7.27