Вы находитесь на странице: 1из 16

http://numericalmethods.eng.usf.

edu 1
Interpolation

Topic: Direct Method

Major: General


http://numericalmethods.eng.usf.edu 2
What is Interpolation ?

Given (x
0
,y
0
), (x
1
,y
1
), (x
n
,y
n
), find the
value of y at a value of x that is not given.


http://numericalmethods.eng.usf.edu 3
Velocity vs Time

http://numericalmethods.eng.usf.edu 4
Interpolants
Polynomials are the most common
choice of interpolants because they
are easy to:
Evaluate
Differentiate, and
Integrate

http://numericalmethods.eng.usf.edu 5
Direct Method
Given n+1 data points (x
0
,y
0
), (x
1
,y
1
),.. (x
n
,y
n
),
pass a polynomial of order n through the data as given
below:



where a
0
, a
1
,. a
n
are real constants.
Set up n+1 equations to find n+1 constants.
To find the value y at a given value of x, simply
substitute the value of x in the above polynomial.

. .......... ..........
1 0
n
n
x a x a a y + + + =

http://numericalmethods.eng.usf.edu 6
Example
The upward velocity of a rocket is given as a
function of time in Table 1. Find the velocity
at t=16 seconds using the direct method for
linear interpolation.



t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Velocity as a function of time
Velocity vs. time data for the rocket example

http://numericalmethods.eng.usf.edu 7
Linear Interpolation
10 12 14 16 18 20 22 24
350
400
450
500
550
517.35
362.78
y
s
f range ( )
f x
desired
( )
x
s
1
10 + x
s
0
10 x
s
range , x
desired
,
( ) t a a t v
1 0
+ =
( ) ( ) 78 . 362 15 15
1 0
= + = a a v
( ) ( ) 35 . 517 20 20
1 0
= + = a a v
Solving the above two equations gives,

91 . 100
0
= a

913 . 30
1
= a
Hence
( ) . 20 15 , 913 . 30 91 . 100 s s + = t t t v

( ) ( ) 16 913 . 30 91 . 100 16 + = v

s m/ 7 . 393 =

http://numericalmethods.eng.usf.edu 8
Example
The upward velocity of a rocket is given as a function
of time in Table 1. Find the velocity at t=16 seconds
using the direct method for quadratic interpolation.



t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Velocity as a function of time
Velocity vs. time data for the rocket example

http://numericalmethods.eng.usf.edu 9
Quadratic Interpolation


( )
2
2 1 0
t a t a a t v + + =
( ) ( ) ( ) 04 . 227 10 10 10
2
2 1 0
= + + = a a a v
( ) ( ) ( ) 78 . 362 15 15 15
2
2 1 0
= + + = a a a v
( ) ( ) ( ) 35 . 517 20 20 20
2
2 1 0
= + + = a a a v
Solving the above three equations gives

001 . 12
0
= a 740 . 17
1
= a
37637 . 0
2
= a

Quadratic Interpolation

http://numericalmethods.eng.usf.edu 10
Quadratic Interpolation (contd)
10 12 14 16 18 20
200
250
300
350
400
450
500
550
517.35
227.04
y
s
f range ( )
f x
desired ( )
20 10 x
s
range , x
desired
,
( ) 20 10 , 37637 . 0 740 . 17 001 . 12
2
s s + + = t t t t v
( ) ( ) ( )
2
16 37637 . 0 16 740 . 17 001 . 12 16 + + = v
s m/ 19 . 392 =
The absolute relative approximate error
a
e obtained between the results from the first and
second order polynomial is
100
19 . 392
70 . 393 19 . 392

= e
a

% 38502 . 0 =

http://numericalmethods.eng.usf.edu 11
Example
The upward velocity of a rocket is given as a function
of time in Table 1. Find the velocity at t=16 seconds
using the direct method for cubic interpolation.



t v(t)
s m/s
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
Velocity as a function of time
Velocity vs. time data for the rocket example

http://numericalmethods.eng.usf.edu 12
Cubic Interpolation




( )
3
3
2
2 1 0
t a t a t a a t v + + + =
( ) ( ) ( ) ( )
3
3
2
2 1 0
10 10 10 04 . 227 10 a a a a v + + + = =
( ) ( ) ( ) ( )
3
3
2
2 1 0
15 15 15 78 . 362 15 a a a a v + + + = =
( ) ( ) ( ) ( )
3
3
2
2 1 0
20 20 20 35 . 517 20 a a a a v + + + = =
( ) ( ) ( ) ( )
3
3
2
2 1 0
5 . 22 5 . 22 5 . 22 97 . 602 5 . 22 a a a a v + + + = =
3810 . 4
0
= a 289 . 21
1
= a
13065 . 0
2
= a
0054606 . 0
3
= a

http://numericalmethods.eng.usf.edu 13
Cubic Interpolation (contd)
10 12 14 16 18 20 22 24
200
300
400
500
600
700
602.97
227.04
y
s
f range ( )
f x
desired ( )
22.5 10 x
s
range , x
desired
,
( ) 5 . 22 10 , 0054606 . 0 13064 . 0 289 . 21 3810 . 4
3 2
s s + + + = t t t t t v
( ) ( ) ( ) ( )
3 2
16 0054606 . 0 16 13064 . 0 16 289 . 21 3810 . 4 16 + + + = v s m/ 06 . 392 =
The absolute percentage relative approximate error,
a
e between second and third order
polynomial is
100
06 . 392
19 . 392 06 . 392

= e
a

% 033427 . 0 =

http://numericalmethods.eng.usf.edu 14
Comparison Table
Order of
Polynomial
1 2 3
v(t=16)
m/s
393.69 392.19 392.06
Absolute Relative
Approximate Error
---------- 0.38502 %

0.033427 %


http://numericalmethods.eng.usf.edu 15
Distance from Velocity Profile
Find the distance covered by the rocket from t=11s to
t=16s ?
( ) 5 . 22 10 , 0054606 . 0 13064 . 0 289 . 21 3810 . 4
3 2
s s + + + = t t t t t v
( ) ( ) ( )
}
=
16
11
11 16 dt t v s s

( )dt t t t
}
+ + + ~
16
11
3 2
0054606 . 0 13065 . 0 289 . 21 3810 . 4
=
16
11
4 3 2
4
0054606 . 0
3
13065 . 0
2
289 . 21 3810 . 4
(

+ + + =
t t t
t
m 1605 =

http://numericalmethods.eng.usf.edu 16
Acceleration from Velocity Profile
given that
( ) 5 . 22 10 , 0054606 . 0 13065 . 0 289 . 21 3810 . 4
3 2
s s + + + = t t t t t v
,
Find the acceleration of the rocket at t=16s
( ) ( ) ( )
3 2
0054606 . 0 13064 . 0 289 . 21 3810 . 4 t t t
dt
d
t v
dt
d
t a + + + = =

5 . 22 10 , 016382 . 0 26130 . 0 289 . 21
2
s s + + = t t t
( ) ( ) ( )
2
16 016382 . 0 16 26130 . 0 289 . 21 16 + + = a
2
/ 664 . 29 s m =