You are on page 1of 16

http://numericalmethods.eng.usf.

edu 1
Spline Interpolation Method

Major: All Engineering Majors

Authors: Autar Kaw, Jai Paul

http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates



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
Interpolants
Polynomials are the most common
choice of interpolants because they
are easy to:

Evaluate
Differentiate, and
Integrate.


http://numericalmethods.eng.usf.edu 4
Why Splines ?
2
25 1
1
) (
x
x f
+
=
Table : Six equidistantly spaced points in [-1, 1]












Figure : 5
th
order polynomial vs. exact function
x
2
25 1
1
x
y
+
=
-1.0 0.038461
-0.6 0.1
-0.2 0.5
0.2 0.5
0.6 0.1
1.0 0.038461

http://numericalmethods.eng.usf.edu 5
Linear Interpolation
Given ( ) ( ) ( )( )
n n n n
y x y x y x y x , , ,......, , , ,
1 1 1 1 0 0
, fit linear splines to the data. This simply involves
forming the consecutive data through straight lines. So if the above data is given in an ascending
order, the linear splines are given by ( ) ) (
i i
x f y =
Figure : Linear splines

http://numericalmethods.eng.usf.edu 6
Linear Interpolation (contd)
), (
) ( ) (
) ( ) (
0
0 1
0 1
0
x x
x x
x f x f
x f x f

+ =
1 0
x x x s s
), (
) ( ) (
) (
1
1 2
1 2
1
x x
x x
x f x f
x f

+ =
2 1
x x x s s
.
.
.
), (
) ( ) (
) (
1
1
1
1

+ =
n
n n
n n
n
x x
x x
x f x f
x f
n n
x x x s s
1

Note the terms of

1
1
) ( ) (

i i
i i
x x
x f x f

in the above function are simply slopes between
1 i
x and
i
x .

http://numericalmethods.eng.usf.edu 7
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 linear splines.



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

http://numericalmethods.eng.usf.edu 8
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
,




, 15
0
= t 78 . 362 ) (
0
= t v
, 20
1
= t 35 . 517 ) (
1
= t v
) (
) ( ) (
) ( ) (
0
0 1
0 1
0
t t
t t
t v t v
t v t v

+ =
) 15 (
15 20
78 . 362 35 . 517
78 . 362

+ = t
) 15 ( 913 . 30 78 . 362 ) ( + = t t v
At , 16 = t
) 15 16 ( 913 . 30 78 . 362 ) 16 ( + = v
7 . 393 = m/s

http://numericalmethods.eng.usf.edu 9
Quadratic Interpolation
Given ( ) ( ) ( ) ( )
n n n n
y x y x y x y x , , , ,......, , , ,
1 1 1 1 0 0
, fit quadratic splines through the data. The splines
are given by
, ) (
1 1
2
1
c x b x a x f + + =
1 0
x x x s s
,
2 2
2
2
c x b x a + + =
2 1
x x x s s
.
.
.
,
2
n n n
c x b x a + + =
n n
x x x s s
1

Find ,
i
a ,
i
b ,
i
c = i 1, 2, , n


http://numericalmethods.eng.usf.edu 10
Quadratic Spline Example
The upward velocity of a rocket is given as a function of time.
Using quadratic splines
a) Find the velocity at t=16 seconds
b) Find the acceleration at t=16 seconds
c) Find the distance covered between t=11 and t=16 seconds
Table Velocity as a
function of time
Figure. Velocity vs. time data
for the rocket example
(s) (m/s)
0 0
10 227.04
15 362.78
20 517.35
22.5 602.97
30 901.67
t
) (t v

http://numericalmethods.eng.usf.edu 11
Solution

, ) (
1 1
2
1
c t b t a t v + + =
10 0 s s t
,
2 2
2
2
c t b t a + + =
15 10 s s t
,
3 3
2
3
c t b t a + + =
20 15 s st
,
4 4
2
4
c t b t a + + =
5 . 22 20 s s t
,
5 5
2
5
c t b t a + + =
30 5 . 22 s s t





Let us set up the equations

http://numericalmethods.eng.usf.edu 12
Each Spline Goes Through
Two Consecutive Data Points
, ) (
1 1
2
1
c t b t a t v + + =
10 0 s s t
0 ) 0 ( ) 0 (
1 1
2
1
= + + c b a
04 . 227 ) 10 ( ) 10 (
1 1
2
1
= + + c b a

http://numericalmethods.eng.usf.edu 13
Final Set of Equations
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(

(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(

(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(
(

=




0
0
0
0
0
67 . 901
97 . 602
97 . 602
35 . 517
35 . 517
78 . 362
78 . 362
04 . 227
04 . 227
0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
0 1 45 0 1 45 0 0 0 0 0 0 0 0 0
0 0 0 0 1 40 0 1 40 0 0 0 0 0 0
0 0 0 0 0 0 0 1 30 0 1 30 0 0 0
0 0 0 0 0 0 0 0 0 0 1 20 0 1 20
1 30 900 0 0 0 0 0 0 0 0 0 0 0 0
1 5 . 22 25 . 506 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 5 . 22 25 . 506 0 0 0 0 0 0 0 0 0
0 0 0 1 20 400 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 20 400 0 0 0 0 0 0
0 0 0 0 0 0 1 15 225 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1 15 225 0 0 0
0 0 0 0 0 0 0 0 0 1 10 100 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 1 10 100
0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
5
5
5
4
4
4
3
3
3
2
2
2
1
1
1
c
b
a
c
b
a
c
b
a
c
b
a
c
b
a

http://numericalmethods.eng.usf.edu 14
Coefficients of Spline
i a
i
b
i
c
i

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
Additional Resources
For all resources on this topic such as digital audiovisual
lectures, primers, textbook chapters, multiple-choice
tests, worksheets in MATLAB, MATHEMATICA, MathCad
and MAPLE, blogs, related physical problems, please
visit

http://numericalmethods.eng.usf.edu/topics/spline_met
hod.html


THE END



http://numericalmethods.eng.usf.edu

You might also like