Sei sulla pagina 1di 72

 At the end of the period, you should be

able to:
 Determine the approximate value of a
function at a certain number using
interpolating polynomials.
 Approximate a function using Newton’s
divided-difference interpolating
polynomials.
 Approximate a function using Lagrange
interpolating polynomials .
 Use spline interpolation to find a
function that can approximate a group
of ordered data points.
DIRECT METHOD
OF INTERPOLATION
What is Interpolation ?
Given (x0,y0), (x1,y1), …… (xn,yn), find
the value of ‘y’ at a value of ‘x’ that is
not given.
Interpolants:
Polynomials are the most common
choice of interpolants because they
are easy to:
Evaluate
Differentiate
Integrate
Given ‘n+1’ data points
(x0, y0), (x1, y1), . . . , (xn, yn)
pass a polynomial of order ‘n’ through
the data.
Set up ‘n+1’ equations of the form

y  a0  a1 x  .......... ..........  an x n

to find ‘n+1’ constants.


Then, solve for
a0 , a1 , . . . , an
where a0, a1,…, an are real constants.
To find the value ‘y’ at a given value of
‘x’, simply substitute the value of ‘x’ in
the resulting polynomial.
n
y  a0  a1 x  .......... ..........  a n x .
Example 1:
The upward t V(t)
velocity of a 0 0
rocket is given as a 10 227.04
function of time. 15 362.78
Find the velocity 20 517.35
at t=16 seconds 22.5 602.97
using linear 30 901.67
interpolation.
Answer 1:
Using linear function. v t   a0  a1t

Solving for a0 and a1


v t   100.93  30.914t , 15  t  20.

Solving for v(16)


v 16  100.93  30.91416  393.7 m/s
Example 2:
The upward t V(t)
velocity of a 0 0
rocket is given as a 10 227.04
function of time. 15 362.78
Find the velocity 20 517.35
at t=16 seconds 22.5 602.97
using quadratic 30 901.67
interpolation.
Answer 2:
Using a quadratic function.
vt   a0  a1t  a2t 2
Solving for a0, a1 and a2 using t=10, 15,
20
v10   a0  a1 10   a2 10   227 .04
2

v15  a0  a1 15  a2 15  362 .78


2

v20   a0  a1 20   a2 20   517 .35


2
Answer 2:
Solving for v(16)
vt   12.05  17.733t  0.3766 t , 10  t  20
2

v 16  392.19 m/s


Example 3:
The upward t V(t)
velocity of a 0 0
rocket is given as a 10 227.04
function of time. 15 362.78
Find the velocity 20 517.35
at t=16 seconds 22.5 602.97
using cubic 30 901.67
interpolation.
Answer 3:
Using a cubic function.
vt   a0  a1t  a2t 2  a3t 3
Solving for a0, a1 and a2 using t=10, 15,
20, 22.5
v10   227 .04  a0  a1 10   a2 10   a3 10 
2 3

v15  362 .78  a0  a1 15  a2 15  a3 15


2 3

v20   517 .35  a0  a1 20   a2 20   a3 20 


2 3

      
v 22.5  602 .97  a0  a1 22.5  a2 22.5  a3 22.5
2
3
Answer 3:
Solving for v(16)
vt   4.2540  21.266t  0.13204 t 2  0.0054347 t 3 , 10  t  22.5

v16   4.2540  21.266 16   0.13204 16   0.0054347 16 


2 3

 392 .06 m/s


Example:

t V(t)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Comparison Table
Order of
1 2 3
Polynomial
vt  16 m/s 393.7 392.19 392.06
Absolute
Relative 0.38410 0.033269
----------
Approximate % %
Error
Example 4:
Find the distance covered by the
rocket from t=11s to t=16s ?
v t   4.2540  21.266t  0.13204t 2  0.0054347t 3 ,
10  t  22.5
Answer 4:
16
s16  s11   v t dt
11

  4.2540  21.266t  0.13204t 


16
 2
 0.0054347t 3 dt
11
16
 t 2
t 3
t  4
   4.2540t  21.266  0.13204  0.0054347 
 2 3 4  11
 1605 m
Example 5:
Find the acceleration of the rocket at
t=16s.
v t   4.2540  21.266t  0.13204t 2  0.0054347t 3 ,
10  t  22.5
Answer 5:

a t   v t 
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

    
a 16  21.266  0.26408 16  0.016304 16 2

 29.665 m/s 2
Newton’s Divided Difference
Polynomial Method of Interpolation
Linear interpolation:
Given two points pass a linear
interpolant through the data

f1 ( x)  b0  b1 ( x  x0 )
where

f ( x1 )  f ( x0 )
b0  f ( x0 ) b1 
x1  x0
Example 1:
The upward velocity of a t V(t)
rocket is given as a 0 0
function of time. 10 227.04
Find the velocity at t=16 15 362.78
seconds using 20 517.35
Newton Divided 22.5 602.97
Difference method for 30 901.67
linear interpolation.
Answer 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)
 393.69 m/s
Quadratic interpolation:
Given three points pass a quadratic
interpolant through the data
f 2 ( x )  b0  b1 ( x  x0 )  b2 ( x  x0 )( x  x1 )

where f ( x1 )  f ( x0 )
b0  f ( x0 ) b1 
x1  x0

f ( x2 )  f ( x1 ) f ( x1 )  f ( x0 )

x2  x1 x1  x0
b2 
x 2  x0
Example 2:
The upward velocity of a t V(t)
rocket is given as a 0 0
function of time. 10 227.04
Find the velocity at t=16 15 362.78
seconds using 20 517.35
Newton Divided 22.5 602.97
Difference method for 30 901.67
quadratic interpolation.
Answer 2:
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 2 )  v(t1 ) v(t1 )  v(t 0 ) 517.35  362.78 362.78  227.04


 
t 2  t1 t1  t 0 20  15 15  10
b2  
t 2  t0 20  10
30.914  27.148

10
 0.37660
Answer 2:
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
General Form
Given (n  1) data points, x0 , y 0 , x1 , y1 ,......,xn 1 , y n 1 , xn , y n  as
f n ( x)  b0  b1 ( x  x0 )  ....  bn ( x  x0 )( x  x1 )...( x  x n1 )
where
b0  f [ x0 ]
b1  f [ x1 , x0 ]
b2  f [ x 2 , x1 , x0 ]

bn1  f [ xn 1 , xn2 ,...., x0 ]
bn  f [ xn , x n 1 ,...., x0 ]
General Form
The third order polynomial, given ( x0 , y 0 ), ( x1 , y1 ), ( x2 , y2 ), and ( x3 , y 3 ), is
f 3 ( x)  f [ x0 ]  f [ x1 , x0 ]( x  x0 )  f [ x 2 , x1 , x0 ]( x  x0 )( x  x1 )
 f [ x3 , x 2 , x1 , x0 ]( x  x0 )( x  x1 )( x  x 2 )
b0
x0 f ( x0 ) b1
f [ x1 , x0 ] b2
x1 f ( x1 ) f [ x2 , x1 , x0 ] b3
f [ x2 , x1 ] f [ x3 , x2 , x1 , x0 ]
x2 f ( x2 ) f [ x3 , x2 , x1 ]
f [ x3 , x 2 ]
x3 f ( x3 )
Example 3:
The upward velocity of a t V(t)
rocket is given as a 0 0
function of time. 10 227.04
Find the velocity at t=16 15 362.78
seconds using 20 517.35
Newton Divided 22.5 602.97
Difference method for 30 901.67
cubic interpolation.
Answer 3:
b0
t0  10 227.04 b1
27.148 b2
t1  15, 362.78 0.37660 b3
30.914 5.4347 x10 3
t2  20, 517.35 0.44453
34.248
t3  22.5, 602.97

b0 = 227.04; b1 = 27.148; b2 = 0.37660; b3 = 5.4347*10-3


Answer 3:
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
Comparison:
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
Lagrange Method of
Interpolation
Given ‘n+1’ data points
(x0, y0), (x1, y1), . . . , (xn, yn)
The Lagrangian interpolating polynomial
is given by n
f n ( x )   Li ( x ) f ( xi )
i 0

where n x xj
Li ( x )  
j  0 xi  xj
ji
Example 1:
The upward velocity t V(t)
of a rocket is given 0 0
as a function of time
10 227.04
in Table 1.
15 362.78
Find the velocity at
t=16 seconds using 20 517.35
the Lagrangian 22.5 602.97
method for linear 30 901.67
interpolation.
Answer 1:
1
v(t )   Li (t )v(ti )
i 0

 L0 (t )v (t 0 )  L1 (t )v (t1 )
Quadratic:
For the second order polynomial, we
have
Example 2:
The upward velocity of a
t V(t)
rocket is given as a
0 0
function of time in
Table 1. 10 227.04
15 362.78
Find the velocity at t=16
20 517.35
seconds using the
Lagrangian method for 22.5 602.97
quadratic interpolation. 30 901.67
Answer 2:
Answer 2:
 t  t1  t  t 2   t  t 0  t  t 2   t  t 0  t  t1 
v t   
 
 
 
 v t 0   
 
 
 
 v t1     v t 2 
 t0  t1  t 0  t 2   t1  t 0  t1  t 2   t 2  t 0  t 2  t1 
 16  15  16  20 
v 16    227.04
 10  15  10  20 
 16  10  16  20 
  362.78
 15  10  15  20 
 16  10  16  15 
  517.35
 20  10  20  15 
  0.08227.04  0.96362.78  0.12527.35
 392.19 m/s
 Cubic:
 For the third order polynomial, we have
Example 3:
The upward velocity t V(t)
of a rocket is given
0 0
as a function of time
in Table 1. 10 227.04
15 362.78
Find the velocity at
t=16 seconds using 20 517.35
the Lagrangian 22.5 602.97
method for cubic 30 901.67
interpolation.
Answer 3:
Answer 3:
 t  t1  t  t 2  t  t 3   t  t 0  t  t 2  t  t 3 
v t      v t 0      v t1 
 t 0  t1  t 0  t 2  t 0  t 3   t1  t 0  t1  t 2  t1  t 3 
 t  t 0  t  t1  t  t 3   t  t1  t  t1  t  t 2 
    v t 2      v t 3 
 t 
 2 0  2 1  2 3 
t t t t  t t  t t 
 3 1   3 1  3 2 
t t  t
 16  15  16  20  16  22.5   16  10  16  20  16  22.5 
v 16     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.0416227.04  0.832362.78  0.312517.35   0.1024602.97
 392.06 m/s
 Comparison:

Order of
1 2 3
Polynomial
v(t=16) m/s 393.69 392.19 392.06

Absolute Relative
-------- 0.38410% 0.033269%
Approximate Error
Spline Method of Interpolation
Why Splines ?

1
f ( x) 
1  25 x 2
1
Why Splines ? f ( x) 
1  25 x 2

1.2

0.8

0.4
y

0
-1 -0.5 0 0.5 1
-0.4

-0.8
x
19th Order Polynomial f (x) 5th Order Polynomial
Given ‘n+1’ data points
(x0, y0), (x1, y1), . . . , (xn, yn)
fit linear splines to the data.
The linear splines are given by:
Given ‘n+1’ data points
(x0, y0), (x1, y1), . . . , (xn, yn)
fit quadratic splines to the data.
The quadratic splines are given by:
Each quadratic splines goes trough two
data points.
At the interior points.
This gives us ‘3n’ equations and ‘3n’
unknowns.
Once we find the ‘3n’ constants, we can
find the function value of ‘x’ using the
splines.
 Example:
 The upward velocity of a
rocket is given as a function t V(t)
of time. Using quadratic 0 0
splines 10 227.04
Find the velocity and the 15 362.78
acceleration at t=16
20 517.35
seconds.
22.5 602.97
Find the distance
covered between t=11 and 30 901.67
t=16 seconds.
Solution:
Set up the equations.
Solution:
Each spline goes through two
consecutive data points.
Each spline goes through two
consecutive data points.
Derivatives are continuous at interior
data points
Derivatives are continuous at interior
data points.

Last Equation: (Assuming the first


spline is linear) a  0
1
 Final Set of Equations:
0 0 1 0 0 0 0 0 0 0 0 0 0 0 0  a1   0 
100 10 1 0 0 0 0 0 0 0 0 0 0 0 0  b1  227.04
0 0 0 100 10 1 0 0 0 0 0 0 0 0
 
0 c1
227.04
    
0 0 0 225 15 1 0 0 0 0 0 0 0 0 0 a2  362.78
0 0 0 0 0 0 225 15 1 0 0 0 0 0 0  b2  362.78
0 0 0 0 0 0 400 20 1 0 0 0 0 0 0 c2
  517.35
    
0 0 0 0 0 0 0 0 0 400 20 1 0 0 0  a3  517.35
0 0 0 0 0 0 0 0 0 506.25 22.5 1 0 0 0  b3   602.97
0 0 0 0 0 0 0 0 0 0 0 0 506.25 22.5 1   c3  602.97
    
0 0 0 0 0 0 0 0 0 0 0 0 900 30 1  a4  901.67 
 20 1 0  20  1 0 0 0 0 0 0 0 0 0 0  b4   0 
0 0 0 30 1 0  30  1 0 0 0 0 0 0 0  c4   0 
    
 40 1 0  a5 
0 0 0 0 0 0 40 1 0 0 0 0
  0

0 0 0 0 0 0 0 0 0 45 1 0  45  1 0  b5   0 
 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0  c5   0 
Coefficients of Spline:

i ai bi ci
1 0 22.704 0
2 0.8888 4.928 88.88
3 −0.1356 35.66 −141.61
4 1.6048 −33.956 554.55
5 0.20889 28.86 −152.13
Final equations:

Velocity at t=16 s
v16   0.1356 16   35.6616   141 .61
2

 394 .24 m/s


Acceleration at t=16 s
Distance covered by the rocket from
t=11s to t=16s.
16 15 16
S 16  S 11  v t dt  v t dt  v t dt
  
11 11 15

 0.8888t    0.1356t 
15 16
2 2
  4.928t  88.88 dt   35.66t  141.61 dt
11 15
 1595.9 m
 Numerical Methods Using Matlab, 4th Edition,
2004 by John H. Mathews and Kurtis K. Fink
 Holistic Numerical Methods Institute by Autar
Kaw and Jai Pau.
 Numerical Methods for Engineers by Chapra
and Canale
 Systems of Nonlinear equations by Power
show.com

Potrebbero piacerti anche