0% found this document useful (0 votes)
16 views17 pages

06 Interpolation Direct

ث فن ن

Uploaded by

rushdiabdulsalam
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)
16 views17 pages

06 Interpolation Direct

ث فن ن

Uploaded by

rushdiabdulsalam
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/ 17

Direct Method of

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 )

• Step2: Choose 𝑚 + 1 points as a subset of the given


points that are close to the point that we are
interested in (𝑥𝑑 ). (𝑥𝑑 , 𝑦𝑑 )
(𝑥2 , 𝑦2 )
𝑥0 , 𝑦0 , 𝑥1 , 𝑦1 , … , 𝑥𝑚 , 𝑦𝑚
• Step3: To solve the coefficients (𝑎0 , 𝑎1 , … , 𝑎𝑚 ), it is
required to apply the interpolation conditions
𝑚 (𝑥0 , 𝑦0 )
𝑖 𝑚
𝑓 𝑥𝑘 = ෍ 𝑎𝑖 𝑥𝑘 = 𝑎0 + 𝑎1 𝑥𝑘 + ⋯ + 𝑎𝑚 𝑥𝑘 = 𝑦𝑘 𝑘
𝑖=0
= 0…𝑚 𝑥

• Step4: Solve the system and use the coefficients to


evaluate, differentiate, or integrate the data.

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

a) Find the velocity at 𝑡 = 16 seconds +10.0 227.04


+15.0 362.78

b) Find the acceleration at 𝑡 = 16 seconds +20.0 517.35


+22.5 602.97
c)Find the distance covered between 𝑡 = 11 and 𝑡 = +30.0 901.67
16

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 𝑥

Step5: Use the obtained function to evaluate or


differentiate the data at the desired location (𝑡 = 16).

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 integration‫׬‬11 𝑣 𝑡 𝑑𝑡 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 , … , 𝑥𝑛 , 𝑦𝑛 .

• Step1: The interpolant is a polynomial of order 2. 𝑦


𝑦 = 𝑓 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2
𝑓 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2
• Step2: Choose 3 points as a subset of the given points that (𝑥3 , 𝑦3 )
are close to the point that we are interested in (𝑥𝑑 ). (𝑥1 , 𝑦1 )
𝑥0 , 𝑦0 , 𝑥1 , 𝑦1 , 𝑎𝑛𝑑 𝑥2 , 𝑦2
(𝑥𝑑 , 𝑦𝑑 )
• Step3: Apply the interpolation conditions
𝑓 𝑥1 = 𝑎0 + 𝑎1 𝑥0 + 𝑎2 𝑥02 = 𝑦0 (𝑥2 , 𝑦2 )
𝑓 𝑥1 = 𝑎0 + 𝑎1 𝑥1 + 𝑎2 𝑥12 = 𝑦1
𝑓 𝑥2 = 𝑎0 + 𝑎1 𝑥2 + 𝑎2 𝑥22 = 𝑦2

• Step4: Solve the system to find the coefficients (𝑎0 ,


𝑎1 , 𝑎𝑛𝑑 𝑎2 ). (𝑥0 , 𝑦0 )
1 𝑥0 𝑥02 𝑎0 𝑦0
2 𝑎
1 𝑥1 𝑥1 1 = 𝑦1
1 𝑥2 𝑥22 𝑎2 𝑦2 𝑥

• Step5: Evaluate or differentiate the data at the desired


location (𝑥𝑑 ).

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

a) Find the velocity at 𝑡 = 16 seconds +10.0 227.04


+15.0 362.78

b) Find the acceleration at 𝑡 = 16 seconds +20.0 517.35


+22.5 602.97
c)Find the distance covered between 𝑡 = 11 and 𝑡 = +30.0 901.67
16

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)

• Step4: Solve the system of equations


1 10 102 𝑎0 227.04
2 𝑎1 = 362.78
1 15 15
1 20 202 𝑎2 517.35 (10,227.04)
𝑎0 2 −1 227.04 12.050
1 10 10
𝑎1 = 1 15 152 362.78 = 17.733
𝑎2 1 20 20 2 517.35 0.3766
2 𝑥
𝑣 𝑡 = 12.050 + 17.733 𝑡 + 0.3766𝑡 10 ≤ 𝑡 ≤ 20

Step5: Use the obtained function to evaluate or differentiate the


data at the desired location (𝑡 = 16).

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 𝑚/𝑠

• The acceleration at 𝑡 = 16 is 517.35


550

𝑑𝑣 𝑡 𝑑[𝑎0 + 𝑎1 𝑡 + 𝑎2 𝑡 2 ] 500
𝑎 𝑡 = = = 𝑎1 + 2 𝑎2 𝑡
𝑑𝑡 𝑑𝑡
𝑎 16 = 17.73 + 2 × 0.3766 × 16 = 29.78 𝑚/𝑠 2 450

ys

The distance covered between 𝑡 = 11 and 𝑡 = 16. Note


400
• f ( range)

: no need to divide the integration since our function (


f x desi red ) 350

is valid over the whole range of integration.


16 16 300
𝑡2 𝑡3
𝑆 16 − 𝑆 11 = න 𝑣 𝑡 𝑑𝑡 = 𝑎0 𝑡 + 𝑎1 + 𝑎2 250
2 3 11
11
2 3 227.04
16 16 200
10 12 14 16 18 20
= 16 𝑎0 + 𝑎1 + 𝑎2 10 x s  range  x desi red 20
2 3
11 2 11 3
− 11 𝑎0 + 𝑎1 + 𝑎2 = 1604.3272 𝑚
2 3

http://numericalmethods.eng.usf.edu 12
Direct Cubic Interpolation (𝑚 =3)
• Given 𝑛 + 1 data points 𝑥0 , 𝑦0 , 𝑥1 , 𝑦1 , … , 𝑥𝑛 , 𝑦𝑛 .

• Step1: The interpolant is a polynomial of order 3.


𝑦
𝑦 = 𝑓 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3
𝑓 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3
• Step2: Choose 4 points as a subset of the given points that are (𝑥3 , 𝑦3 )
close to the point that we are interested in (𝑥𝑑 ). (𝑥1 , 𝑦1 )
𝑥0 , 𝑦0 , 𝑥1 , 𝑦1 , 𝑥2 , 𝑦2 , 𝑎𝑛𝑑 𝑥3 , 𝑦3
(𝑥𝑑 , 𝑦𝑑 )
• Step3: Apply the interpolation conditions
𝑓 𝑥1 = 𝑎0 + 𝑎1 𝑥0 + 𝑎2 𝑥02 + 𝑎3 𝑥03 = 𝑦0
𝑓 𝑥1 = 𝑎0 + 𝑎1 𝑥1 + 𝑎2 𝑥12 + 𝑎3 𝑥13 = 𝑦1
𝑓 𝑥2 = 𝑎0 + 𝑎1 𝑥2 + 𝑎2 𝑥22 + 𝑎3 𝑥23 = 𝑦2 (𝑥2 , 𝑦2 )
𝑓 𝑥3 = 𝑎0 + 𝑎1 𝑥3 + 𝑎2 𝑥32 + 𝑎3 𝑥33 = 𝑦3

• Step4: Solve the system to find the coefficients (𝑎0 , 𝑎1 , 𝑎2 , 𝑎𝑛𝑑 𝑎3 ).


1 𝑥0 𝑥02 𝑥03 𝑎0 𝑦0 (𝑥0 , 𝑦0 )
2 3 𝑎 𝑦1
1 𝑥1 𝑥1 𝑥1 1
= 𝑦2
1 𝑥2 𝑥22 𝑥23 𝑎2
𝑎3 𝑦3
1 𝑥3 𝑥32 𝑥23 𝑥

• Step5: Evaluate or differentiate the data at the desired location


(𝑥𝑑 ).

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

• Find the distance covered between 𝑡 = 11 and 𝑡 =


16

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)

• The distance covered between 𝑡 = 11 and 𝑡 = 16. Note : no (


f x desi red )
400
need to divide the integration since our function is valid over
the whole range of integration.
16 16
𝑡2 𝑡3 𝑡4 300
𝑆 16 − 𝑆 11 = න 𝑣 𝑡 𝑑𝑡 = 𝑎0 𝑡 + 𝑎1 + 𝑎2 + 𝑎3
2 3 4 11
11
2 3 4
16 16 16 227.04
= 16 𝑎0 + 𝑎1 + 𝑎2 + 𝑎3 200
10 12 14 16 18 20 22 24
2 3 4
10 x s  range  x desi red 22.5
11 2 11 3 11 4
− 11 𝑎0 + 𝑎1 + 𝑎2 + 𝑎3 = 1605 𝑚
2 3 4

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

You might also like