Transcript PPT

Lagrangian Interpolation
Civil 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 maximize a catch of bass in a lake, it is suggested to throw the line to
the depth of the thermocline. The characteristic feature of this area is the
sudden change in temperature. We are given the temperature vs. depth plot
for a lake. Determine the value of the temperature at z = −7.5 using the
Lagragian method for linear interpolation.
Temperature
T (oC)
19.1
19.1
19
18.8
18.7
18.3
18.2
17.6
11.7
9.9
9.1
6
Depth
z (m)
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
Temperature vs. depth of a lake
http://numericalmethods.eng.usf.edu
Linear Interpolation
17.6
18
1
T ( z )   Li ( z )T ( z i )
17
i 0
 L0 ( z )T ( z 0 )  L1 ( z )T ( z1 )
16
ys
15
f ( range)

f x desired

14
13
z 0  8, T z 0   11.7
z1  7, T z1   17.6
7
12
11.7
11
15
x s  10
0
10
5
0
x s  range  x desired
http://numericalmethods.eng.usf.edu
x s  10
1
Linear Interpolation (contd)
z  zj
z  z1
L0 ( z )  

z0  z1
j 0 z0  z j
1
j 0
1
z  zj
z  z0
L1 ( z )  

z1  z0
j 0 z1  z j
j 1
T ( z) 
z  z0
z  z1
z7
z 8
T ( z0 ) 
T ( z1 ) 
(11.7) 
(17.6),  8  z  7
z0  z1
z1  z0
8 7
78
 7.5  7
 7.5  8
T (7.5) 
(11.7) 
(17.6)  0.5(11.7)  0.5(17.6)
8 7
78
 14.65 C
8
http://numericalmethods.eng.usf.edu
Quadratic Interpolation
For the second order polynomial interpolatio n (also called quadratic interpolation), we
choose the velocity given by
2
v (t )   Li ( t ) v(t i )
i 0
 L0 (t )v (t 0 )  L1 (t ) v( t1 )  L2 (t ) v( t 2 )
9
http://numericalmethods.eng.usf.edu
Example
To maximize a catch of bass in a lake, it is suggested to throw the line to
the depth of the thermocline. The characteristic feature of this area is the
sudden change in temperature. We are given the temperature vs. depth plot
for a lake. Determine the value of the temperature at z = −7.5 using the
Lagragian method for quadratic interpolation.
Temperature
T (oC)
19.1
19.1
19
18.8
18.7
18.3
18.2
17.6
11.7
9.9
9.1
10
Depth
z (m)
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
Temperature vs. depth of a lake
http://numericalmethods.eng.usf.edu
Quadratic Interpolation (contd)
z o  9, T z o   9.9
17.6
z1  8, T z1   11.7
z 2  7, T z 2   17.6
2
L0 ( z )  
j 0
j 0
2
L1 ( z )  
j 0
j 1
2
L2 ( z )  
j 0
j 2
11
z  zj
 z  z1  z  z 2 


 
z 0  z j  z 0  z1  z 0  z 2 
16
ys
14
f ( range)

f x desired

12
10
z  zj
 z  z 0  z  z 2 


 
z1  z j  z1  z 0  z1  z 2 
18
9.89238
8
9
9
8.5
8
7.5
x s  range  x desired
z  zj
 z  z 0  z  z1 


 
z 2  z j  z 2  z 0  z 2  z1 
http://numericalmethods.eng.usf.edu
7
7
Quadratic Interpolation (contd)
 z  z1  z  z2 
 z  z0  z  z2 
 z  z0  z  z1 









T z2 




T ( z)  
T z0  
T z1  






 z0  z1  z0  z2 
 z1  z0  z1  z2 
 z2  z0  z2  z1 
 7.5  8 7.5  7  9.9   7.5  9 7.5  7  11.7    7.5  9 7.5  8 17.6
T  7.5 
 9  8 9  7 
 8  9 8  7 
 7  9 7  8
  0.1259.9  0.7511.7   0.37517.6 
 14.138C
The absolute relative approximate error a obtained between the results from the first and second
order polynomial is
a 
14.138  14.65
 100
14.138
 3.6251%
12
http://numericalmethods.eng.usf.edu
Cubic Interpolation
For the third order polynomial (also called cubic interpolation), we choose the
temperature given by
3
T ( z )   Li ( z )T ( z i )
i 0
 L0 ( z )T ( z 0 )  L1 ( z )T ( z1 )  L2 ( z )T ( z 2 )  L3 ( z )T ( z 3 )
19.19774
20
18
16
ys
f ( range)

f x desired

14
12
10
9.44745
13
8
9
9
8.5
8
7.5
x s  range  x desired
7
6.5
6
6
http://numericalmethods.eng.usf.edu
Example
To maximize a catch of bass in a lake, it is suggested to throw the line to
the depth of the thermocline. The characteristic feature of this area is the
sudden change in temperature. We are given the temperature vs. depth plot
for a lake. Determine the value of the temperature at z = −7.5 using the
Lagragian method for cubic interpolation.
Temperature
T (oC)
19.1
19.1
19
18.8
18.7
18.3
18.2
17.6
11.7
9.9
9.1
14
Depth
z (m)
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
Temperature vs. depth of a lake
http://numericalmethods.eng.usf.edu
Cubic Interpolation (contd)
z o  9, T z o   9.9
z1  8, T z1   11.7
z 2  7, T z 2   17.6
z 3  6, T z 3   18.2
3
L0 ( z )  
j 0
j 0
z  zj
 z  z1  z  z 2  z  z 3 



 
z

z
z

z
z

z
z 0  z j  0 1  0
2  0
3 
z  zj
 z  z 0  z  z 2  z  z 3 



 
L1 ( z )  
z

z
z

z
z

z
j  0 z1  z j
2  1
3 
 1 0  1
3
j 1
19.19774
18
16
ys
f ( range)

f x desired

z  zj
 z  z 0  z  z1  z  z 3 



 
L2 ( z )  
z

z
z

z
z

z
j 0 z 2  z j
0  2
1  2
3 
 2
3
20
14
12
10
j 2
z  zj
 z  z 0  z  z1  z  z 2 



 
L3 ( z )  
z

z
z

z
z

z
j 0 z 3  z j
0  3
1  3
2 
 3
3
9.44745
8
9
8.5
9
8
7.5
7
6.5
x s  range  x desired
j 3
15
http://numericalmethods.eng.usf.edu
6
6
Cubic Interpolation (contd)
 z  z1  z  z 2  z  z3 
 z  z0  z  z 2  z  z3 


T z0   

T z1 

T z   
 z0  z1  z0  z 2  z0  z3 
 z1  z0  z1  z 2  z1  z3 
 z  z0  z  z1  z  z3 
 z  z0  z  z1  z  z 2 


T z 2   


T  z3 
 
z

z
z

z
z

z
z

z
z

z
z

z
 2 0  0 1  0 3 
 3 0  3 1  3 2 
z 0  z  z3
 7.5  8 7.5  7 7.5  6 9.9   7.5  9 7.5  7  7.5  6 11.7 
 9  8 9  7  9  6
 8  9 8  7 8  6
 7.5  9 7.5  8 7.5  6 17.6   7.5  9 7.5  8 7.5  7 18.2

 7  9 7  8 7  6
 6  9 6  8 6  7
T  7.5 
  0.06259.9  0.562511.7  0.562517.6   0.062518.2
 14.725C
The absolute relative approximate error a obtained between the results from the second and
third order polynomial is
a 
14.725  14.138
 100
14.725
 3.9898%
16
http://numericalmethods.eng.usf.edu
Comparison Table
17
Order of
Polynomial
1
2
3
Temperature °C
14.65
14.138
14.725
Absolute Relative
Approximate Error
----------
3.6251 %
3.9898 %
http://numericalmethods.eng.usf.edu
Thermocline
What is the value of depth at which the thermocline
exists?
2
d T
The position where the thermocline exists is given where
0
2
dz
z  8z  7 z  6 9.9  z  9z  7 z  6 11.7 
T z  
 9  8 9  7  9  6
 8  9 8  7  8  6
z  9z  8z  6 17.6  z  9z  8z  7  18.2

 7  9 7  8 7  6
 6  9 6  8 6  7 
 615.9  262.58 z  35.55 z 2  1.5667 z 3 ,
 9  z  6
dT
 262.58  71.1z  4.7 z 2 ,
 9  z  6
dz
d 2T
 71.1  9.4 z,
 9  z  6
dz 2
Simply setting this expression equal to zero, we get
0  71.1  9.4 z ,
z  7.5638 m
18
 9  z  6
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