Beruflich Dokumente
Kultur Dokumente
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.
http://numericalmethods.eng.usf.edu
Interpolants
Polynomials are the most common
choice of interpolants because they
are easy to:
Evaluate
Differentiate, and
Integrate.
3
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
http://numericalmethods.eng.usf.edu
Example
We are given the temperature vs. depth plot for a lake.
Determine the value of the temperature at z = -7.5
using the Lagrangian method for linear interpolation.
Depth
m
10
15
20
25
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-2
Depth (m)
Temperature
o
C
19.1
19.1
19
18.8
18.7
18.3
18.2
17.6
11.7
9.9
9.1
-4
-6
-8
-10
-12
o
Temp (C )
Linear Interpolation
17.6
18
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
12
11.7
11
15
x s 10
0
10
x s , range, x desired
http://numericalmethods.eng.usf.edu
x s + 10
1
L0 ( z ) =
j =0
j 0
1
L1 ( z ) =
j =0
j 1
z zj
z0 z j
z zj
z1 z j
z z1
z 0 z1
z z0
z1 z 0
z z0
z z1
z+7
z +8
T ( z0 ) +
T ( z1 ) =
(11.7) +
(17.6)
z 0 z1
z1 z 0
8+ 7
7+8
7.5 + 7
7.5 + 8
(11.7) +
(17.6)
T ( 7.5) =
8+ 7
7+8
T (z) =
= 0.5(11.7) + 0.5(17.6)
= 14.65C
7
http://numericalmethods.eng.usf.edu
Quadratic Interpolation
For the second order polynomial interpolation (also called quadratic interpolation), we choose
the temperature given by
2
T ( z ) = Li ( z )T ( z i )
i =0
= L0 ( z )T ( z 0 ) + L1 ( z )T ( z1 ) + L2 ( z )T ( z 2 )
http://numericalmethods.eng.usf.edu
Example
We are given the temperature vs. depth plot for a lake.
Determine the value of the temperature at z = -7.5
using the Lagrangian method for quadratic interpolation.
Depth
m
10
15
20
25
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-2
Depth (m)
Temperature
o
C
19.1
19.1
19
18.8
18.7
18.3
18.2
17.6
11.7
9.9
9.1
-4
-6
-8
-10
-12
o
Temp (C )
17.6
z1 = 8, T ( z1 ) = 11.7
16
z 2 = 7, T (z 2 ) = 17.6
ys
z zj
z z1 z z 2
=
L0 ( z ) =
j =0 z 0 z j
z 0 z1 z 0 z 2
2
j 0
2
L1 ( z ) =
j =0
j 1
2
L2 ( z ) =
j =0
j 2
10
z zj
z z0
=
z1 z j z1 z 0
18
z z 2
z1 z 2
14
f ( range)
f x desired
12
10
9.89238
9
9
z zj
z z0
=
z2 z j z2 z0
8.5
7.5
x s , range, x desired
z z1
z 2 z1
http://numericalmethods.eng.usf.edu
7
7
T ( z 0 ) +
T ( z1 ) +
T ( z ) =
z 0 z1 z 0 z 2
z1 z 0 z1 z 2
z2 z0
(7.5 + 8)(7.5 + 7)
( 7.5 + 9)(7.5 + 7)
T ( 7.5) =
(9.9) +
(11.7)
(9 + 8)(9 + 7)
(8 + 9)(8 + 7)
(7.5 + 9)(7.5 + 8)
(17.6)
+
(7 + 9)(7 + 8)
z z1
T ( z 2 )
z
z
1
2
= 14.138C
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%
11
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)
14
f x desired
12
10
9.44745
12
9
9
8.5
7.5
x s , range, x desired
6.5
6
6
http://numericalmethods.eng.usf.edu
Example
We are given the temperature vs. depth plot for a lake.
Determine the value of the temperature at z = -7.5
using the Lagrangian method for cubic interpolation.
13
Depth
m
10
15
20
25
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-2
Depth (m)
Temperature
o
C
19.1
19.1
19
18.8
18.7
18.3
18.2
17.6
11.7
9.9
9.1
-4
-6
-8
-10
-12
o
Temp (C )
z1 = 8, T ( z1 ) = 11.7
z 2 = 7, T ( z 2 ) = 17.6
z 3 = 6, T ( z 3 ) = 18.2
19.19774
L0 ( z ) =
j =0
j 0
L1 ( z ) =
j =0
j 1
z zj
z z1 z z 2 z z 3
=
z 0 z j z 0 z1 z 0 z 2 z 0 z 3
20
18
16
z zj
z z0
=
z1 z j z1 z 0
z z 2 z z 3
z
z
z
z
2 1
3
1
ys
f ( range)
14
f x desired
12
L2 ( z ) =
j =0
j 2
3
L3 ( z ) =
14
j =0
j 3
z zj
z z0
=
z2 z j z2 z0
z z1 z z 3
z
z
z
z
1 2
3
2
10
9.44745
z zj
z z0
=
z3 z j z3 z0
z z1 z z 2
z
z
3 1 z 3 z 2
9
9
8.5
7.5
6.5
x s , range, x desired
http://numericalmethods.eng.usf.edu
6
6
T ( z 0 ) +
T ( z1 )
T ( z ) =
z
z
z
z
z
z
z
z
z
z
z
z
1 0
2 0
3
0 1
2 1
3
0
1
z z 0 z z1 z z 2
z z 0 z z1 z z 3
T ( z 3 )
T ( z 2 ) +
+
z 3 z 0 z 3 z1 z 3 z 2
z 2 z 0 z 2 z1 z 2 z 3
(7.5 + 8)(7.5 + 7)(7.5 + 6)
(7.5 + 9)(7.5 + 7)(7.5 + 6)
(9.9) +
(11.7)
T (7.5) =
(9 + 8)(9 + 7)(9 + 6)
(8 + 9)(8 + 7)(7.5 + 6)
(7.5 + 9)(7.5 + 8)(7.5 + 6)
(7.5 + 9)(7.5 + 8)(7.5 + 7)
+
(17.6) +
(18.2)
(7 + 9)(7 + 8)(7 + 6)
(6 + 9)(6 + 8)(6 + 7)
= ( 0.0625)(9.9) + (0.5625)(11.7) + (0.5625 )(17.6 ) + (0.0625 )(18.2 )
= 14.725C
The absolute relative approximate error a obtained between the results from the second and
third order polynomial is
a =
15
14.725 14.138
100
14.725
= 3.9898%
http://numericalmethods.eng.usf.edu
Comparison Table
Order of
Polynomial
14.65
14.138
14.725
----------
3.6251%
3.9898 %
Temperature
o
C
Absolute Relative
Approximate Error
16
http://numericalmethods.eng.usf.edu
Thermocline
What is the value of depth at which the thermocline
exists?
2
d T
=0
2
dz
T (z) =
9 z 6
z = 7.5638 m
http://numericalmethods.eng.usf.edu