N 5
N 5
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
2
3
4
5
What is Interpolation ?
Given (x0,y0), (x1,y1), …… (xn,yn), find the value of ‘y’
at a value of ‘x’ that is not given.
6
Interpolants
Polynomials are the most common choice of
interpolants because they are easy to:
Evaluate
Differentiate, and
Integrate.
7
5.1
Lagrange Interpolation
8
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Polynomial Interpolation
For a given set of N + 1 data points
9
Lagrange Interpolation
Lagrangian interpolating polynomial is given by
n
f n ( x) Li ( x) f ( xi )
i 0
where ‘ n ’ in f n (x) stands for the n th order polynomial that approximates the function y f (x)
10
Linear Interpolation: Lagrangian interpolating polynomi
n
f n ( x) Li ( x) f ( x
Consider the two points: i 0
Temperature Depth
T (oC) z (m)
19.1 0
19.1 -1
19 -2
18.8 -3
18.7 -4
18.3 -5
18.2 -6
17.6 -7
11.7 -8
9.9 -9
9.1 -10
Temperature vs. depth of a lake
12
Example 1
Solution 17.6
18
17
z 0 8, T z 0 11.7
16
ys
15
f ( range)
13
12
z zj z z1
11.7 11
1
L0 ( z )
15 10 5 0
x s 10
0
x s range x de sire d x s 10
1
j 0 z0 z j z0 z1
j 0
1 z zj z z0
L1 ( z )
j 0 z1 z j z1 z0
j 1 13
Example 1
Solution
z z1 z z0
T1 ( z ) T ( z0 ) T ( z1 )
z0 z1 z1 z0
z7 z 8
(11.7) (17.6)
8 7 7 8
for 8 z 7
7.5 7 7.5 8
T1 (7.5) (11.7) (17.6)
8 7 7 8
0.5(11.7) 0.5(17.6)
14.65 C
14
Quadratic Interpolation:
j 0 xi x j f n ( x) Li ( x) f ( xi )
j i i 0
Example 2
We are given the temperature vs. depth plot for a lake. Determine
the value of the temperature at z = −7.5 using the Lagrange method
for quadratic interpolation.
Temperature Depth
T (oC) z (m)
19.1 0
19.1 -1
19 -2
18.8 -3
18.7 -4
18.3 -5
18.2 -6
17.6 -7
11.7 -8
9.9 -9
9.1 -10
Temperature vs. depth of a lake
16
Example 2
Solution
18
17.6
16
z o 9, T z o 9.9
ys 14
f x de sire d
12
z 2 7, T z 2 17.6
10
9.89238 8
9 8.5 8 7.5 7
9 x s range x de sire d 7
17
Example 2
Solution
2 z zj z z1 z z 2 7.5 8 7.5 7
L0 ( z ) = = 0.125
j 0 z 0 z j z 0 z1 z 0 z 2 9 8 9 7
j 0
2 z zj z z 0 z z 2 7.5 9 7.5 7
L1 ( z ) = 0.75
j 0 z1 z j z1 z 0 z1 z 2 8 9 8 7
j 1
2 z zj z z 0 z z1 7.5 9 7.5 8
L2 ( z ) = 0.375
j 0 z 2 z j z 2 z 0 z 2 z1 7 9 7 8
j 2
T2 z L0 z T z0 L1 z T z1 L2 z T z2
3 x xj x x1 x x2 x x3
L0 ( x)
18
j 0 x0 z j x0 x1 x0 x2 x0 x3 Lagrangian interpolating polynomial is given
16
j 0 ys
n
f n ( x) Li ( x) f ( xi )
f ( range)
14
f x de sire d
3 x xj x x0 x x2 x x3 i 0
L1 ( x)
12
L2 ( x)
9 8.5 8 7.5 7 6.5 6
9 x s range x de sire d 6
j 0 x2 x j x2 x0 x2 x1 x2 x3 n x xj
j 2
Li ( x)
0 xi x j
Lagrangian interpolatingjj polynomial is given
3 x xj x x0 x x1 x x2 i
L3 ( x)
x3 x j x3 x0 x3 x1 x3 x2 n
j 0
j 3
Li (x) is a weighting
omitted.
f n ( x) function
i 0
Li ( x)that
f ( xincludes
i ) a
19
Example 3
We are given the temperature vs. depth plot for a lake. Determine
the value of the temperature at z = −7.5 using the Lagrange method
for cubic interpolation.
Temperature Depth
T (oC) z (m)
19.1 0
19.1 -1
19 -2
18.8 -3
18.7 -4
18.3 -5
18.2 -6
17.6 -7
11.7 -8
9.9 -9
9.1 -10
Temperature vs. depth of a lake
20
Example 3
Solution
20
19.19774
z o 9, T z o 9.9 18
f ( range)
z 2 7, T z 2 17.6
14
f x de sire d
12
9.44745 8
9 8.5 8 7.5 7 6.5 6
9 x s range x de sire d 6
21
Example 3
z z1 z z2 z z3 7.5 8 7.5 7 7.5 6
L0 z = 0.0625
0 1 0 2 0 3
z z z z z z 9 8 9 7 9 6
T3 z L0 z T z0 L1 z T z1 L2 z T z2 L3 z T z3
23
5.2
Divided Differences
Copyright © 2006 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Divided Differences
25
Divided Differences
26
Divided Differences
Substitute
Substitute
27
Divided Differences
General form
f 2 ( x) b0 b1 ( x x0 ) b2 ( x x0 )( x x1 )
where
b0 f [ x0 ] f ( x0 )
f ( x1 ) f ( x 0 )
b1 f [ x1 , x0 ]
x1 x0
f ( x 2 ) f ( x1 ) f ( x1 ) f ( x0 )
f [ x 2 , x1 ] f [ x1 , x0 ] x 2 x1 x1 x0
b2 f [ x 2 , x1 , x0 ]
x 2 x0 x 2 x0
Rewriting
f 2 ( x) f [ x0 ] f [ x1 , x0 ]( x x0 ) f [ x2 , x1 , x0 ]( x x0 )( x x1 )
28
Divided Differences
General form
Given (n 1) data points, x0 , y0 , x1 , y1 ,......, xn1 , y n1 , xn , y n ,
f n ( x) b0 b1 ( x x0 ) .... bn ( x x0 )( x x1 )...( x xn1 )
where
b0 f [ x0 ] b0 f [ x0 ] f ( x0 )
b1 f [ x1 , x0 ] f ( x1 ) f ( x 0 )
b1 f [ x1 , x0 ]
b2 f [ x2 , x1 , x0 ] x1 x0
f (x
bn1 f [ xn1 , xn2 ,...., x0 ] f [ x 2 , x1 ] f [ x1 , x0 ]
b2 f [ x 2 , x1 , x0 ]
x 2 x0
bn f [ xn , xn1 ,...., x0 ]
29
Divided Differences
General form
The third order polynomial, given ( x0 , y0 ), ( x1 , y1 ), ( x2 , y 2 ), and ( x3 , y3 ), is
f 3 ( x) f [ x0 ] f [ x1 , x0 ]( x x0 ) f [ x2 , x1 , x0 ]( x x0 )( x x1 )
f [ x3 , x2 , x1 , x0 ]( x x0 )( x x1 )( x x2 )
b0
x0 f ( x0 ) b1
f [ x1 , x0 ] b2
x1 f ( x1 ) f [ x2 , x1 , x0 ] b3
f [ x2 , x1 ] f [ x3 , x2 , x1 , x0 ]
x2 f ( x2 ) f [ x3 , x2 , x1 ]
f [ x3 , x 2 ]
x3 f ( x3 )
30
Divided Differences
General form
31
Example 4
32
Solution
33
Solution
Solution
Solution
36
Example 5
Predict f(1.5) from the experimental data shown in the
following table using the divided-difference method.
37
Solution
38
Solution
39
Solution
40
Solution
41
Solution
42
Solution
43
Example 6
We are given the temperature vs. depth plot for a lake. Determine
the value of the temperature at z = −7.5 using the Divided
Difference method for cubic interpolation.
Temperature Depth
T (oC) z (m)
19.1 0
19.1 -1
19 -2
18.8 -3
18.7 -4
18.3 -5
18.2 -6
17.6 -7
11.7 -8
9.9 -9
9.1 -10
Temperature vs. depth of a lake
44
Example 6
Solution
45
Example 6
b0
z 0 9, 9.9 b1
1.8 b2
z1 8, 11.7 2.05 b3
5.9 1.5667
z 2 7, 17.6 2.65
0.6
z 3 6, 18.2
T ( z ) b0 b1 ( z z 0 ) b2 ( z z 0 )( z z1 ) b3 ( z z 0 )( z z1 )( z z 2 )
9.9 1.8( z 9) 2.05( z 9)( z 8) 1.5667( z 9)( z 8)( z 7)
At z 7.5,
47