0% found this document useful (0 votes)
11 views

N 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

N 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

Chapter 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

{(x0, y0), (x1, y1), . . . , (xN, yN)},

we want to find the coefficients of an Nth-degree


polynomial function to match them:

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)

given at (n  1) data points as x0 , y 0 , x1 , y1 ,......,  x n 1 , y n 1 , x n , y n  , and


n x  xj
Li ( x)  
j 0 xi  x j
j i

Li (x) is a weighting function that includes a product of (n  1) terms with terms of j  i


omitted.

10
Linear Interpolation: Lagrangian interpolating polynomi
n
f n ( x)   Li ( x) f ( x
Consider the two points: i 0

where ‘ n ’ in f n (x) stands for the

given at (n  1) data points as x0 ,


n x  xj
Li ( x)  
j 0 xi  x j
j i

Li (x) is a weighting function that i


The linear function P(x) passing through points omitted.
Lagrangian interpolating polynomial i
n
f n ( x)   Li ( x) f ( xi )
f1 ( x)  L0 ( x) f ( x0 )  L1 ( x) f ( x1 ) i 0

where ‘ n ’ in f n (x) stands for the n th

given at (n  1) data points as x0 , 11


y0 
Example 1
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 linear 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
12
Example 1
Solution 17.6
18

17

z 0  8, T z 0   11.7
16

ys
15
f ( range)

z1  7, T z1   17.6



f x de sire d 14

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
z7 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:

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 approxima


f 2 ( x)  L0 ( x) f ( x0 )  L1 ( x) f ( x1 )  L2 ( x) f ( x2 )
given at (n  1) data points as x0 , y 0 , x1 , y1 ,......,  x n 1 , y n 1 , x n , y n  ,
Lagrangian interpolating polynomial i
n x  xj
Li ( x)   n

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

z1  8, T z1   11.7


f ( range)


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 

T2  7.5   0.125 9.9    0.7511.7    0.375 17.6 


 14.138C 18
Cubic Interpolation:
f3 ( x)  L0 ( x) f ( x0 )  L1 ( x) f ( x1 )  L2 ( x) f ( x2 )  L3 ( x) f ( x3 )
20
19.19774

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

j 0 x1  x j  x1  x0   x1  x2   x1  x3  where ‘ n ’ in f n (x) stands for the n th order p


j 1 10

3 x  xj  x  x0   x  x1   x  x3  given at (n  1) data points as x0 , y 0 , x1 , y1 


9.44745 8

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

z1  8, T z1   11.7


16
ys

f ( range)

z 2  7, T z 2   17.6
14

f x de sire d
12

z3  6, T z3   18.2 10

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 

 z  z0   z  z2   z  z3   7.5  9  7.5  7  7.5  6 


L1  z       = 0.5625
 
 1 0  1 2  1 3 
z z z z z  z  8  9  8  7  8  6 

 z  z0  z  z1  z  z3   7.5  9  7.5  8 7.5  6 


L2  z       = 0.5625
 
 2 0  0 1  0 3 
z z z z z  z  7  9  7  8  7  6 

 z  z0  z  z1  z  z2   7.5  9  7.5  8 7.5  7 


L3  z       = 0.0625
 
 3 0  3 1  3 2 
z z z z z  z  6  9  6  8  6  7 

T3  z   L0  z  T  z0   L1  z  T  z1   L2  z  T  z2   L3  z  T  z3 

T3  7.5   0.0625 9.9    0.562511.7    0.562517.6    0.062518.2 


22
 14.725C
Comparison Table
Order of
1 2 3
Polynomial
Temperature °C 14.65 14.138 14.725

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

Need to find the constants

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 ,......, xn1 , y n1 , xn , y n  ,
f n ( x)  b0  b1 ( x  x0 )  ....  bn ( x  x0 )( x  x1 )...( x  xn1 )
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

bn1  f [ xn1 , xn2 ,...., x0 ] f [ x 2 , x1 ]  f [ x1 , x0 ]
b2  f [ x 2 , x1 , x0 ]  
x 2  x0
bn  f [ xn , xn1 ,...., 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

Use Newton’s divided-difference method to compute


f(2) from the experimental data shown in the following
table:

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

The temperature profile is chosen as


T ( z)  b0  b1 ( z  z 0 )  b2 ( z  z 0 )( z  z1 )  b3 ( z  z 0 )( z  z1 )( z  z 2 )
We need to choose four data points that are closest to z  7.5
z 0  9, T ( z 0 )  9.9
z1  8, T ( z1 )  11.7
z 2  7, T ( z 2 )  17.6
z 3  6, T ( z 3 )  18.2

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

The values of the constants are obtained as


b0  9.9 b1  1.8 b2  2.05 b3  1.5667
46
http://numericalmethods.eng.usf.edu
Example 6

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,

T (7.5)  9.9  1.8(7.5  9)  2.05(7.5  9)(7.5  8)


 1.5667(7.5  9)(7.5  8)(7.5  7)
 14.725C

47

You might also like