Numeric PPT (Chapter 5)
Numeric PPT (Chapter 5)
INTERPOLATIONS
and y .
x: x0 x1 x2 x3 .... xn
y: y0 y1 y2 y3 .... yn
interpolation.
the interval ( x0 , x n ) .
By: Habtamu Garoma April 9, 2020
Cont’d
3
Let y f (x) be the function taking the values y 0 , y1 , y 2 , y3 ,..., y n corresponding
practical cases we have to find y f (x) such that y i f ( xi ) , from the given
data. This is not an easy task because there are infinitely many functions
y x such that yi xi .
the given set of data points, for instance trigonometric, exponential, etc.
functions.
y a0 a1 x .......... .......... an x .
n
t , s vt , m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67 Figure 2 Velocity vs. time data for the
rocket example
By: Habtamu Garoma April 9, 2020
Linear Interpolation
9
y
vt a0 a1t
x1, y1
v15 a0 a1 15 362.78
v20 a0 a1 20 517.35 x0 , y0
f1 x
Solving the above two equations gives,
x
a0 100.93 a1 30.914 Figure 3: Linear interpolation.
Hence
vt 100.93 30.914t , 15 t 20.
v16 100.93 30.91416 393.7 m/s
By: Habtamu Garoma April 9, 2020
Example 2
10
The upward velocity of a rocket is given as a
function of time in Table 2. Find the velocity at
t=16 seconds using the direct method for quadratic
interpolation.
Table 2 Velocity as a function
of time.
t , s vt , m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67 Figure 5 Velocity vs. time data for the
rocket example
By: Habtamu Garoma April 9, 2020
Quadratic Interpolation
y
f 2 x
v20 a0 a1 20 a2 20 517.35
2
x0 , y 0
x
550
517.35
ys
f x desired 350
250
227.04 200
10 12 14 16 18 20
10 x s range x desired 20
t , s vt , m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67 Figure 6 Velocity vs. time data for the
rocket example
By: Habtamu Garoma April 9, 2020
Cubic Interpolation
14
x3 , y3
vt a0 a1t a2t a3t
2 3
x1 , y1
v10 227.04 a0 a1 10 a2 10 a3 10
2 3
f 3 x
x2 , y2
v15 362.78 a0 a1 15 a2 15 a3 15
2 3
x0 , y0
392.06 m/s
700
f x desired
392.06 392.19
400
300
a 100
392.06
227.04 200
10
10
12 14 16 18
x s range x desired
20 22 24
22.5
0.033269%
Order of
1 2 3
Polynomial
vt 16 m/s 393.7 392.19 392.06
Absolute Relative
---------- 0.38410 % 0.033269 %
Approximate Error
11
16
t2 t3 t4
4.2540t 21.266 0.13204 0.0054347
2 3 4 11
1605 m
at vt
d
dt
d
dt
4.2540 21.266t 0.13204t 2 0.0054347t 3
21.289 0.26130t 0.016382t 2 , 10 t 22.5
29.665 m/s2
Lagrange Method of
Interpolation
Evaluate
Differentiate, and
Integrate.
By: Habtamu Garoma April 9, 2020
Lagrangian Interpolation
22
where ‘ n ’ in f n (x) stands for the n th order polynomial that approximates the function y f (x)
Table Velocity as a
function of time
t (s) v(t ) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
550
517.35
1
v(t ) Li (t )v(ti ) 500
i 0
L0 (t )v (t 0 ) L1 (t )v (t1 ) ys
f ( range)
450
f x desired
t 0 15, t 0 362.78
400
1 t tj t t1
L0 (t )
j 0 t0 t j t 0 t1
j 0
1 t tj t t0
L1 (t )
j 0 t1 t j t1 t 0
j 1
t t1 t t0 t 20 t 15
v(t ) v(t 0 ) v(t1 ) (362.78) (517.35)
t 0 t1 t1 t 0 15 20 20 15
16 20 16 15
v(16) (362.78) (517.35)
15 20 20 15
0.8(362.78) 0.2(517.35)
393.7 m/s.
For the second order polynomial interpolation (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( t2 )
ys
400
f ( range)
2 t tj t t1 t t 2
L0 (t )
f x desired 350
j 0 t0 t j t
0 1 0 2
t t t
j 0
300
2 t t j t t0 t t 2
L1 (t )
j 0 t1 t j t1 t 0 t1 t 2 250
j 1
j 0 t2 t j
2 0 2 1
t t t t 10 x s range x desired 20
j 2
t t1 t t 2 t t0 t t 2 t t0 t t1
vt vt0 vt1 vt2
t0 t1 t0 t 2 t1 t0 t1 t 2 t 2 t0 t 2 t1
16 15 16 20 16 10 16 20 16 10 16 15
v16 227 . 04 362 . 78 517.35
10 15 10 20 15 10 15 20 20 10 20 15
0.08227.04 0.96362.78 0.12527.35
392.19 m/s
The absolute relative approximate error a obtained between the
results from the first and second order polynomial is
392.19 393.70
a 100
392.19
0.38410%
By: Habtamu Garoma April 9, 2020
Cubic Interpolation
30
For the third order polynomial (also called cubic interpolation), we choose the velocity given by
3
v (t) Li ( t) v(t i )
i 0
600
y s 500
f ( range)
f x desired
400
300
227.04 200
10 12 14 16 18 20 22 24
10 x s range x desired 22.5
Table Velocity as a
function of time
t (s) v(t ) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
3 t tj t t 1 t t 2 t t 3
L0 (t ) ;
j 0 t0 t j t 0 t 1 t 0 t 2 t 0 t 3 602.97
700
j 0
3 t t j t t0 t t 2 t t 3
L1 (t ) 600
j 0 t1 t j t1 t 0 t1 t 2 t1 t 3
j 1
3 t tj t t 0 t t1 t t 3 ys 500
L2 (t ) ;
t2 t j
2 0 2 1 t 2 t 3
f ( range)
j 0 t t t t
j 2
f x desired
400
3 t tj t t 0 t t1 t t 2
L3 ( t )
j 0 t3 t j t3 t 0 t 3 t1 t3 t 2 300
j 3
227.04 200
10 12 14 16 18 20 22 24
10 x s range x desired 22.5
t t1 t t 2 t t3 t t0 t t 2 t t3
vt vt1 vt 2
t
0 1 0 2 0 3
t t t t t t
1 0 1 2 1 3
t t t t t
t t0 t t1 t t3 t t1 t t1 t t 2
vt 2 vt3
t
2 0 2 1 2 3
t t t t t t
3 1 3 1 3 2
t t t t t
16 15 16 20 16 22.5 16 10 16 20 16 22.5
v16 227.04 362.78
10 15 10 20 10 22.5 15 10 15 20 15 22.5
16 10 16 15 16 22.5 16 10 16 15 16 20
517.35 602.97
20 10 20 15 20 22.5 22 .5 10 22. 5 15 22. 5 20
0.0416227.04 0.832362.78 0.312517.35 0.1024602.97
392.06 m/s
The absolute relative approximate error a obtained between the
results from the first and second order polynomial is
392.06 392.19
a 100
392.06
0.033269%
By: Habtamu Garoma April 9, 2020
Comparison Table
34
Order of Polynomial 1 2 3
Absolute Relative
-------- 0.38410% 0.033269%
Approximate Error
16
( 4.245 21.265t 0.13195t 2 0.00544t 3 ) dt
11
t2 t3 t 4 16
[ 4.245t 21.265 0.13195 0.00544 ]11
2 3 4
By: Habtamu Garoma 1605 m April 9, 2020
Acceleration from Velocity Profile
36
dt dt
29.665 m / s 2
Newton’s Divided
Difference Method of
Interpolation
Evaluate
Differentiate, and
Integrate.
where
b0 f ( x0 )
f ( x1 ) f ( x0 )
b1
x1 x0
t (s) v (t ) ( m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Figure. Velocity vs. time data
By: Habtamu Garoma
for the rocket example April 9, 2020
Linear Interpolation
42
v(t ) b0 b1 (t t 0 ) 517.35
550
b0 v(t 0 ) 362.78
f ( range)
450
f x desired
v(t1 ) v(t 0 )
b1 30.914
t1 t 0 400
362.78 350
10 12 14 16 18 20 22 24
x s 10 x s range x desired x s 10
0 1
500
y s
f ( rang e)
450
f x desired
400
362.78 350
10 12 14 16 18 20 22 24
x s 10 x s rang e x desired x s 10
0 1
v(t ) b0 b1 (t t 0 )
362.78 30.914(t 15), 15 t 20
At t 16
v(16) 362.78 30.914(16 15)
By: Habtamu Garoma 393.69 m/s April 9, 2020
Quadratic Interpolation
44
f 2 ( x) b0 b1 ( x x0 ) b2 ( x x0 )( x x1 )
b0 f ( x0 )
f ( x1 ) f ( x0 )
b1
x1 x0
f ( x 2 ) f ( x1 ) f ( x1 ) f ( x0 )
x 2 x1 x1 x0
b2
x 2 x0
t (s) v (t ) ( m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Figure. Velocity vs. time data
By: Habtamu Garoma
for the rocket example April 9, 2020
Quadratic Interpolation (contd)
550
517.35
500
450
y s
400
f ( rang e)
f x desired 350
300
250
227.04 200
10 12 14 16 18 20
10 x s rang e x desired 20
b0 v(t 0 )
227.04
v(t ) v(t 0 ) 362.78 227.04
b1 1
t1 t 0 15 10
27.148
v(t ) b0 b1 (t t 0 ) b2 (t t 0 )(t t1 )
227.04 27.148(t 10) 0.37660(t 10)(t 15), 10 t 20
At t 16,
v(16) 227.04 27.148(16 10) 0.37660(16 10)(16 15) 392.19 m/s
The absolute relative approximate errora obtained between the results from the first
order and second order polynomial is
= 0.38502 %
By: Habtamu Garoma April 9, 2020
General Form
49
f 2 ( x) b0 b1 ( x x0 ) b2 ( x x0 )( x x1 )
where
b0 f [ x0 ] f ( x0 )
f ( x1 ) f ( x 0 )
b1 f [ x1 , x0 ]
x1 x0
f ( x 2 ) f ( x1 ) f ( x1 ) f ( x0 )
f [ x 2 , x1 ] f [ x1 , x0 ] x 2 x1 x1 x0
b2 f [ x 2 , x1 , x0 ]
x 2 x0 x 2 x0
Rewriting
f 2 ( x) f [ x0 ] f [ x1 , x0 ]( x x0 ) f [ x 2 , x1 , x0 ]( x x0 )( x x1 )
By: Habtamu Garoma April 9, 2020
General Form
50
f 3 ( x) f [ x0 ] f [ x1 , x0 ]( x x0 ) f [ x2 , x1 , x0 ]( x x0 )(x x1 )
f [ x3 , x2 , x1 , x0 ]( x x0 )(x x1 )(x x2 )
b0
x0 f ( x0 ) b1
f [ x1 , x0 ] b2
x1 f ( x1 ) f [ x 2 , x1 , x0 ] b3
f [ x2 , x1 ] f [ x3 , x 2 , x1 , x0 ]
x2 f ( x2 ) f [ x3 , x 2 , x1 ]
f [ x3 , x 2 ]
x3 f ( x3 )
t (s) v (t ) ( m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Figure. Velocity vs. time data
By: Habtamu Garoma
for the rocket example April 9, 2020
Cont’d
53
b0
t0 10 227.04 b1
27.148 b2
t1 15, 362.78 0.37660 b3
30.914 5.4347 103
t2 20, 517.35 0.44453
34.248
t3 22.5, 602.97
Hence
v (t ) b0 b1 (t t 0 ) b2 (t t0 )( t t1 ) b3 (t t0 )( t t1 )(t t 2 )
227.04 27.148( t 10) 0.37660(t 10)(t 15)
5.4347 * 10 3 (t 10)( t 15)( t 20)
At t 16,
v (16) 227.04 27.148(16 10) 0.37660(16 10)(16 15)
5.4347 * 10 3 (16 10)(16 15)(16 20)
392.06 m/s
= 0.033427 %
By: Habtamu Garoma April 9, 2020
Comparison Table
56
Order of 1 2 3
Polynomial
v(t=16) 393.69 392.19 392.06
m/s
Absolute Relative ---------- 0.38502 % 0.033427 %
Approximate Error
1. Using Newton’s divided difference formula, find the values of f (2) , f (8)
x: 4 5 7 10 11 13
x f (x ) f x 2 f x 3 f x 4 f x
4 48
52
15
5 100
97 1
7 294 21
202 0
1
10 900 27
310 0
33 1
11 1210
409
13 2028
1. From the following table find f (x ) and hence f (12) using Newton’s
interpolation formula.
x: 1 2 7 8
f (x ) : 1 5 5 4
x f (x ) f x 2 f x 3 f x 4 f x
1 1
4 4
2 5
6 1
0
7 5 1 14
-1 6
8 4
1. Find the function f from the following table and find f(3)
x: 0 1 2 4 5 7
f x
x
xx 1x 4
12
Now 2 3
22 12 4
f 5 600 f 7
5 30 and 7 58
54 1 20 763
x x f x 2 f x
2 3
9
5 30 1
14
7 58
= 3 9 x 18 x 2 7 x 10 = x 2 2 x 5
16
( 4.2541 21.265t 0.13204t 0.0054347t 3 ) dt
2
11
16
t2 t3 t4
4.2541t 21.265 0.13204 0.0054347
2 3 4 11
29.664 m / s 2