Transcript PPT

Lagrangian Interpolation
Chemical Engineering Majors
Authors: Autar Kaw, Jai Paul
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
http://numericalmethods.eng.usf.edu
1
Lagrange Method of
Interpolation
http://numericalmethods.eng.usf.edu
What is Interpolation ?
Given (x0,y0), (x1,y1), …… (xn,yn), find the
value of ‘y’ at a value of ‘x’ that is not given.
3
http://numericalmethods.eng.usf.edu
Interpolants
Polynomials are the most common
choice of interpolants because they
are easy to:
Evaluate
Differentiate, and
Integrate.
4
http://numericalmethods.eng.usf.edu
Lagrangian 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
Li ( x)  
j 0
j i
x  xj
xi  x j
Li (x) is a weighting function that includes a product of (n  1) terms with terms of j  i
omitted.
5
http://numericalmethods.eng.usf.edu
Example
To find how much heat is required to bring a kettle of water to
boiling point, you are asked to calculate the specific heat of water
at 610C. Use a first, second and third order Lagrange polynomial to
determine the value of the specific heat at T = 61°C.
Table 1 Specific heat of water as a
function of temperature.
Temperature,
Specific heat,
22
42
52
82
100
4181
4179
4186
4199
4217
T C
 J 

C p 
 kg  C 
Figure 2 Specific heat of water vs. temperature.
6
http://numericalmethods.eng.usf.edu
Linear Interpolation
4.19910
3 4200
1
C p (T )   Li (T )C p (Ti )
i 0
 L0 (T )C p (T0 )  L1 (T )C p (T1 )
4195
ys
f ( range)

f x desired

4190
T0  52, C p T0   4186
T1  82, C p T1   4199
4.18610
3
4185
50
x s  10
0
7
60
70
x s  range  x desired
80
90
x s  10
http://numericalmethods.eng.usf.edu
1
Linear Interpolation (contd)
T  Tj
T  T1
L0 T   

T

T
T0  T1
j 0 0
j
1
j 0
1
L1 T   
j 0
j 1
CpT  
T1  T j

T  T0
T1  T0
T  T0
T  T1
T  82
4186  T  52 4199, 52  T  82
CpT0  
CpT1  
T0  T1
T1  T0
52  82
82  52
Cp61 
8
T  Tj
61  82 4186  61  52 4199  4189.9
52  82
82  52
J
kg  C
http://numericalmethods.eng.usf.edu
Quadratic Interpolation
For the second order polynomial interpolation (also called quadratic interpolation), we choose
the specific heat given by
2
C p (T )   Li (T )C p (Ti )
i 0
 L0 (T )C p (T0 )  L1 (T )C p (T1 )  L2 (T )C p (T2 )
9
http://numericalmethods.eng.usf.edu
Quadratic Interpolation (contd)
T0  42,
T1  52,
T2  82,
C p T0   4179
C p T1   4186
C p T2   4199
4.19910
3
4200
4195
ys
4190
f ( range)
T  Tj
 T  T1  T  T2

L0 (T )  
 
j  0 T0  T j
 T0  T1  T0  T2
2
j 0
T  Tj
 T  T0
L1 (T )  
 
j  0 T1  T j
 T1  T0
2
j 1
T  Tj
 T  T2

 T1  T2






 T  T0  T  T1 


L2 (T )  
 
j  0 T2  T j
 T2  T0  T2  T1 
2

f x desired

4185
4180
4.17910
3
4175
40
42
45
50
55
60
65
x s  range  x desired
70
75
80
85
82
j 2
10
http://numericalmethods.eng.usf.edu
Quadratic Interpolation (contd)
 T  T1  T  T2 
 T  T0  T  T2 
 T  T0  T  T1 

C p (T0 )  


C p (T1 )  
C p (T2 )
C p (T )  
 T0  T1  T0  T2 
 T1  T0  T1  T2 
 T2  T0  T2  T1 
T1  T  T2
(61  52)(61  82)
(61  42)(61  82)
(61  42)(61  52)
C p (61) 
(4179) 
(4186) 
(4199)
(42  52)( 42  82)
(52  42)(52  82)
(82  42)(82  52)
 (0.4725)( 4179)  (1.33)( 4186)  (0.1425)( 4199)
 4191.2
J
kg   C
The absolute relative approximate error a obtained between the results from the first and
second order polynomial is
a 
11
4191.2  4189.9
 100
4191.2
 0.030063%
http://numericalmethods.eng.usf.edu
Cubic Interpolation
For the third order polynomial (also called cubic interpolation), we choose the
specific heat given by
3
C p (T )   Li (T )C p (Ti )
i 0
 L0 (T )C p (T0 )  L1 (T )C p (T1 )  L2 (T )C p (T2 )  L3 (T )C p (T3 )
Cubic interpolation
4.21710
3
4220
4210
ys
4200
f 3( range)

f 3 x desired

4190
4180
4.17910
12
3
4170
40
42
50
60
70
x s  range  x desired
80
90
100
100
http://numericalmethods.eng.usf.edu
Cubic Interpolation (contd)
3
L0 (T )  
To  42, C p To   4179
T1  52, C p T1   4186
T2  82, C p T2   4199
T3  100, C p T3   4217
j 0
j 0
T0  T j
 T  T1  T  T2

 
T

T
1  T0  T2
 0
L1 (T )  
 T  T2

 T1  T2
T  Tj
 T  T1  T  T3 



 T2  T1  T2  T3 
T  Tj
 T  T1  T  T2


 T3  T1  T3  T2
j 1
 T  T0


L2 (T )  
j  0 T2  T j
 T2  T0
3
j 2
 T  T0
 
j  0 T3  T j
 T3  T0
3
L3 (T )  
 T  T3 


T

T
3 
 0
T  Tj
 T  T0
 
j  0 T1  T j
 T1  T0
3
j 3
13
T  Tj
 T  T3 


 T1  T3 



http://numericalmethods.eng.usf.edu
Cubic Interpolation (contd)
 T  T1  T  T2

C p (T )  
 T0  T1  T0  T2
 T  T0
 
 T2  T0
 T  T3 
 T  T0

C p (T0 )  
 T0  T3 
 T1  T0
 T  T1  T  T3 
 T  T0

C p (T2 )  

 T2  T1  T2  T3 
 T3  T0
 T  T2

 T1  T2
 T  T3 
C p (T1 )

 T1  T3 
 T  T1  T  T2


 T3  T1  T3  T2

C p (T3 )

(61  52)(61  82)(61  100)
(61  42)(61  82)(61  100)
(4179) 
(4186)
(42  52)( 42  82)( 42  100)
(52  42)(52  82)(52  100)
(61  42)(61  52)(61  100)
(61  42)(61  52)(61  82)

(4199) 
(4217)
(82  42)(82  52)(82  100)
(100  42)(100  52)(100  82)
C p (61) 
 (0.31772)( 4179)  (1.0806)( 4186)  (0.30875 )(4199 )  (0.071659 )(4217 )
 4190.0
14
J
kg   C
http://numericalmethods.eng.usf.edu
Cubic Interpolation (contd)
The absolute relative approximate error obtained between the
results from the second and third order polynomial is
a 
4190.0  4191.2
 100  0.027295%
4190.0
Cubic interpolation
4.21710
3
4220
4210
ys
4200
f 3( range)

f 3 x desired

4190
4180
4.17910
3
4170
40
42
15
50
60
70
x s  range  x desired
80
90
100
100
http://numericalmethods.eng.usf.edu
Comparison Table
Order of
Polynomial
J
C p T 
kg   C
Absolute Relative
Approximate Error
16
1
2
3
4189.9
4191.2
4190.0
----------
0.030063%
0.027295%
http://numericalmethods.eng.usf.edu
Additional Resources
For all resources on this topic such as digital audiovisual
lectures, primers, textbook chapters, multiple-choice
tests, worksheets in MATLAB, MATHEMATICA, MathCad
and MAPLE, blogs, related physical problems, please
visit
http://numericalmethods.eng.usf.edu/topics/lagrange_
method.html
THE END
http://numericalmethods.eng.usf.edu