06 Interpolation Direct
06 Interpolation Direct
Interpolation
1
What is Interpolation ?
Given (𝑥0 , 𝑦0 ), (𝑥1 , 𝑦1 ), …… (𝑥𝑛 , 𝑦𝑛 ), find the
value of ‘𝑦’ at a value of ‘𝑥’ that is not given.
http://numericalmethods.eng.usf.edu 2
Interpolants
• Polynomials are the most common choice of interpolants because they are easy to:
Evaluate
Differentiate, and
Integrate.
http://numericalmethods.eng.usf.edu 3
Direct Interpolation
• Given 𝑛 + 1 data points 𝑥0 , 𝑦0 , 𝑥1 , 𝑦1 , … , 𝑥𝑛 , 𝑦𝑛 .
• Step1: Choose the interpolant. In this course, it will 𝑦
be a polynomial of order 𝑚 , where 𝑚 ≤ 𝑛. 𝑚
𝑚
𝑓 𝑥 = 𝑎𝑖 𝑥 𝑖
(𝑥3 , 𝑦3 )
𝑦 = 𝑓 𝑥 = 𝑎𝑖 𝑥𝑖 = 𝑎0 + 𝑎1 𝑥 + ⋯ + 𝑎𝑚 𝑥𝑚 𝑖=0
𝑖=0 (𝑥1 , 𝑦1 )
http://numericalmethods.eng.usf.edu 4
Direct Linear Interpolation (𝑚 = 1)
• Given 𝑛 + 1 data points 𝑥0 , 𝑦0 , 𝑥1 , 𝑦1 , … , 𝑥𝑛 , 𝑦𝑛 .
• Step1: The interpolant is a polynomial of order 1. 𝑦
𝑦 = 𝑓 𝑥 = 𝑎0 + 𝑎1 𝑥
𝑓 𝑥 = 𝑎0 + 𝑎1 𝑥
• Step2: Choose 2 points as a subset of the given points (𝑥3 , 𝑦3 )
that are close to the point that we are interested in (𝑥1 , 𝑦1 )
(𝑥𝑑 ).
𝑥1 , 𝑦1 , 𝑎𝑛𝑑 𝑥2 , 𝑦2
• Step3: Apply the interpolation conditions (𝑥𝑑 , 𝑦𝑑 )
(𝑥2 , 𝑦2 )
𝑓 𝑥1 = 𝑎0 + 𝑎1 𝑥1 = 𝑦1
𝑓 𝑥2 = 𝑎0 + 𝑎1 𝑥2 = 𝑦2
• Step4: Solve the system to find the coefficients (𝑥0 , 𝑦0 )
(𝑎0 , 𝑎𝑛𝑑 𝑎1 ).
1 𝑥1 𝑎0 𝑦1
= 𝑦2
1 𝑥2 𝑎1
𝑥
• Step5: Evaluate or differentiate the data at the
desired location (𝑥𝑑 ).
http://numericalmethods.eng.usf.edu 5
Example1
• The upward velocity of a rocket is given as a
function of time in Table. Using linear direct 𝒕 𝒗(𝒕)
interpolation +00.0 000.00
http://numericalmethods.eng.usf.edu 6
Example 1
• Step1: The linear interpolant is
𝑣 𝑡 = 𝑎0 + 𝑎1 𝑡
𝑦
• Step2: The closest two values of time to 𝑡 = 16 are 15
and 20. Hence, the two points are 𝑣 𝑥 = 𝑎0 + 𝑎1 𝑡
15, 362.78 , 𝑎𝑛𝑑 20, 517.35 (15,362.78) (22.5,602.97)
• Step3: To solve the coefficients (𝑎0 , 𝑎𝑛𝑑 𝑎1 ), it is
required to apply the interpolation conditions
𝑣 15 = 𝑎0 + 15𝑎1 = 362.78 (16, 𝑣(16))
(20,517.35)
𝑣 20 = 𝑎0 + 20𝑎1 = 517.35
• Step4: Solve the system of equations
1 15 𝑎0 362.78
=
1 20 𝑎1 517.35 (10,227.04)
𝑎0 −1
1 15 362.78 −100.930
𝑎1 = =
1 20 517.35 +30.914
𝑣 𝑡 = −100.930 + 30.914 𝑡 15 ≤ 𝑡 ≤ 20 𝑥
http://numericalmethods.eng.usf.edu 7
Example 1
• The velocity at 𝑡 = 16 is •
16
The integration 15 𝑣 𝑡 𝑑𝑡 can be evaluated since our
𝑣 16 = −100.930 + 30.914 16 = 393.7 𝑚/𝑠 function is valid in this range.
16 16
• The acceleration at 𝑡 = 16 is 𝑡2
න 𝑣 𝑡 𝑑𝑡 = 𝑎0 𝑡 + 𝑎1
𝑑𝑣 𝑡 𝑑[𝑎0 + 𝑎1 𝑡 ] 2
𝑎 𝑡 = = = 𝑎1 = 30.914 𝑚/𝑠 2 15 15
𝑑𝑡 𝑑𝑡 (16)2 15 2
= −100.93(16) + 30.914 − −100.93 15 + 30.914
2 2
= 378.237
• The distance covered between 𝑡 = 11 and 𝑡 = 16
15
16 • The integration11 𝑣 𝑡 𝑑𝑡 cannot be evaluated with our
𝑆 16 − 𝑆 11 = න 𝑣 𝑡 𝑑𝑡 interpolation. A new linear interpolation should be
performed for the interval 10 ≤ 𝑡 ≤ 15.
11
𝑣 𝑡 = −44.44 + 27.148 𝑡 10 ≤ 𝑡 ≤ 15
The integration should be divided since our function is only 15 15
valid in the range of 15 ≤ 𝑡 ≤ 20. 𝑡2
න 𝑣 𝑡 𝑑𝑡 = 𝑎0 𝑡 + 𝑎1
15 16 2 11
11
𝑆 16 − 𝑆 11 = න 𝑣 𝑡 𝑑𝑡 + න 𝑣 𝑡 𝑑𝑡 (15)2 (11)2
= −44.44(15) + 27.148 − −44.44(11) + 27.148
11 15 2 2
𝑆 16 − 𝑆 11 = 1251.2 + 378.237 = 1629.437 𝑚 = 1251.2
http://numericalmethods.eng.usf.edu 8
Direct Quadratic Interpolation (𝑚 = 2)
• Given 𝑛 + 1 data points 𝑥0 , 𝑦0 , 𝑥1 , 𝑦1 , … , 𝑥𝑛 , 𝑦𝑛 .
http://numericalmethods.eng.usf.edu 9
Example2
• The upward velocity of a rocket is given as a
function of time in Table. Using quadratic direct 𝒕 𝒗(𝒕)
interpolation +00.0 000.00
http://numericalmethods.eng.usf.edu 10
Example2
• Step1: The linear interpolant is
𝑣 𝑡 = 𝑎0 + 𝑎1 𝑡 + 𝑎2 𝑡 2
𝑦
• Step2: The closest two values of time to 𝑡 = 16 are 15 and 20.
Hence, the two points are 𝑣 𝑡 = 𝑎0 + 𝑎1 𝑡 + 𝑎2 𝑡 2
10, 227.04 , 15, 362.78 , 20, 517.35
(15,362.78)
• Step3: To solve the coefficients (𝑎0 , 𝑎1 𝑎𝑛𝑑 𝑎2 ), it is required to (22.5,602.97)
apply the interpolation conditions
𝑣 10 = 𝑎0 + 10𝑎1 + 102 𝑎2 = 227.04
(16, 𝑣(16))
𝑣 15 = 𝑎0 + 15𝑎1 + 152 𝑎2 = 362.78
𝑣 20 = 𝑎0 + 20𝑎1 + 202 𝑎2 = 517.35 (20,517.35)
http://numericalmethods.eng.usf.edu 11
Example 2
• The velocity at 𝑡 = 16 is
𝑣 16 = 12.05 + 17.733 16 + 0.3766(16)2 = 392.188 𝑚/𝑠
𝑑𝑣 𝑡 𝑑[𝑎0 + 𝑎1 𝑡 + 𝑎2 𝑡 2 ] 500
𝑎 𝑡 = = = 𝑎1 + 2 𝑎2 𝑡
𝑑𝑡 𝑑𝑡
𝑎 16 = 17.73 + 2 × 0.3766 × 16 = 29.78 𝑚/𝑠 2 450
ys
http://numericalmethods.eng.usf.edu 12
Direct Cubic Interpolation (𝑚 =3)
• Given 𝑛 + 1 data points 𝑥0 , 𝑦0 , 𝑥1 , 𝑦1 , … , 𝑥𝑛 , 𝑦𝑛 .
http://numericalmethods.eng.usf.edu 13
Example3
𝒕 𝒗(𝒕)
• The upward velocity of a rocket is given as a +00.0 000.00
function of time in Table. Using cuboc direct +10.0 227.04
interpolation +15.0 362.78
+20.0 517.35
• Find the velocity at 𝑡 = 16 seconds +22.5 602.97
+30.0 901.67
• Find the acceleration at 𝑡 = 16 seconds
http://numericalmethods.eng.usf.edu 14
Example3
• Step1: The linear interpolant is
𝑣 𝑡 = 𝑎0 + 𝑎1 𝑡 + 𝑎2 𝑡 2 + 𝑎3 𝑡 3
• Step2: The closest two values of time to 𝑡 = 16 are 15 and 20. Hence, the two points 𝑦
are
10, 227.04 , 15, 362.78 , 20, 517.35 , 22.5, 602.97 𝑣 𝑡 = 𝑎0 + 𝑎1 𝑡 + 𝑎2 𝑡 2 + 𝑎3 𝑡 3
(22.5,602.97)
• Step3: To solve the coefficients (𝑎0 , 𝑎1 , 𝑎2 𝑎𝑛𝑑 𝑎3 ), it is required to apply the (15,362.78)
interpolation conditions
𝑣 10.0 = 𝑎0 + 10.0𝑎1 + 10.02 𝑎2 + 10.03 𝑎3 = 227.04
𝑣 15.0 = 𝑎0 + 15.0𝑎1 + 15.02 𝑎2 + 15.03 𝑎3 = 362.78
𝑣 20.0 = 𝑎0 + 20.0𝑎1 + 20.02 𝑎2 + 20.03 𝑎3 = 517.35
𝑣 22.5 = 𝑎0 + 22.5𝑎1 + 22.52 𝑎2 + 22.53 𝑎3 = 602.97
(16, 𝑣(16))
• Step4: Solve the system of equations
(20,517.35)
1 10.0 10.02 10.03 𝑎0 227.04
2 3 𝑎1 362.78
1 15.0 15.0 15.0
2 3 𝑎2 = 517.35
1 20.0 20.0 20.0
1 22.5 22.52 22.53 𝑎3 602.97
𝑎0 −1
1 10.0 10.02 10.03 227.04 −04.2 54000
(10,227.04)
𝑎1 1 15.0 15.0 2
15.0 3 362.78 +21.226000
𝑎2 = 1 20.0 20.02 20.03 517.35
=
+00.132040
𝑎3 2
1 22.5 22.5 22.5 3 602.97 +0.0054347
𝑣 𝑡 = −4.254 + 21.2655𝑡 + 0.13204𝑡 2 + 0.0054347𝑡 3 10 ≤ 𝑡 ≤ 22.5
𝑥
• Step5: Use the obtained function to evaluate or differentiate the data at the
desired location (𝑡 = 16).
http://numericalmethods.eng.usf.edu 15
Example 3
• The velocity at 𝑡 = 16 is
𝑣 16
2
= −4.254 + 21.2655 16 + 0.13204 16 + 0.0054347 (16)3
700
= 392.06 𝑚/𝑠 602.97
• The acceleration at 𝑡 = 16 is
600
𝑑𝑣 𝑡 𝑑[𝑎0 + 𝑎1 𝑡 + 𝑎2 𝑡 2 + 𝑎3 𝑡 3 ]
𝑎 𝑡 = = = 𝑎1 + 2 𝑎2 𝑡 + 3 𝑎3 𝑡 2
𝑑𝑡 𝑑𝑡
𝑎 16 = 21.226 + 2 × 0.13204 × 16 + 3 × 0.0054347 × 16 2 ys 500
= 29.665 𝑚/𝑠 2
f ( range)
http://numericalmethods.eng.usf.edu 16
Comparison Tables
• Order of
1 2 3
Polynomial
𝑣 16 393.7 392.19 392.06
𝜀𝑠 N/A 0.38410% 0.033269%
Order of
1 2 3
Polynomial
𝑎 16 30.914 29.78 29.665
𝜀𝑠 N/A 3.668% 0.3877%
Order of
1 2 3
Polynomial
𝑆 16 − 𝑆 11 1629.437 1604.3272 1605
𝜀𝑠 N/A 1.565% 0.04192%
http://numericalmethods.eng.usf.edu 17