Spline Interpolation Method Power Point
Download
Report
Transcript Spline Interpolation Method Power Point
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
1
Spline Method of
Interpolation
http://numericalmethods.eng.usf.edu
What is Interpolation ?
Given (x0,y0), (x1,y1), …… (xn,yn), find the
value of ‘y’ at a value of ‘x’ that is not given.
3
http://numericalmethods.eng.usf.edu
Interpolants
Polynomials are the most common
choice of interpolants because they
are easy to:
Evaluate
Differentiate, and
Integrate.
4
http://numericalmethods.eng.usf.edu
Why Splines ?
f ( x)
1
1 25 x
2
Ta ble : S ix e q uid is tant ly s pace d poin ts in [-1, 1]
x
1
1 25 x
- 1.0
0.038461
- 0.6
0.1
- 0.2
0.5
0.2
0.5
0.6
0.1
1.0
5
y
0.038461
2
Fig u re : 5
th
orde r po ly no mia l vs . e xact fu nct io n
http://numericalmethods.eng.usf.edu
Why Splines ?
1.2
0.8
y
0.4
0
-1
-0.5
0
0.5
1
-0.4
-0.8
x
19th Order Polynomial
f (x)
5th Order Polynomial
Figure : Higher order polynomial interpolation is a bad idea
6
http://numericalmethods.eng.usf.edu
Linear Interpolation
G ive n
x 0 , y 0 , x 1 , y 1 ,......, x n 1 , y n 1 x n , y n , fit
linea r sp lines to the da ta. T his s im p ly invo lves
fo r m ing the co ns ec utive data thro ugh s tra ight lines. S o if the abo ve data is give n in a n a sce nd ing
order, the linea r sp lines a re give n b y
yi
f ( xi )
Fig u re : L ine ar s p line s
7
http://numericalmethods.eng.usf.edu
Linear Interpolation (contd)
f ( x ) f ( x0 )
f ( x1 )
f ( x1 ) f ( x 0 )
x1 x 0
f ( x 2 ) f ( x1 )
x2 x1
( x x 0 ),
x 0 x x1
( x x 1 ),
x1 x x 2
.
.
.
f ( x n 1 )
f ( x n ) f ( x n 1 )
x n x n 1
( x x n 1 ), x n 1 x x n
N o te th e t erm s o f
f ( xi ) f ( x i1 )
xi x i1
in the ab o ve func t io n are s im p ly s lo p es b etween x i 1 and x i .
8
http://numericalmethods.eng.usf.edu
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
t (s)
0
10
15
20
22.5
30
9
(m/s)
0
227.04
362.78
517.35
602.97
901.67
v (t )
Figure. Velocity vs. time data
for the rocket example
http://numericalmethods.eng.usf.edu
Linear Interpolation
t 0 15 ,
v ( t 0 ) 362 . 78
t1 20,
v ( t1 ) 517 . 35
v (t ) v (t 0 )
v (t 1 ) v (t 0 )
t1 t 0
550
517.35
500
(t t 0 )
y s
f ( range )
362 . 78
517 . 35 362 . 78
20 15
( t 15 )
f x desired
362.78
v (16 ) 362 . 78 30 . 913 (16 15 )
3 9 3. 7
10
400
v ( t ) 362 . 78 30 . 913( t 15 )
At t 16 ,
450
350
10
12
x s 10
0
14
16
18
x s range x desired
20
22
24
x s 10
m /s
http://numericalmethods.eng.usf.edu
1
Quadratic Interpolation
G ive n
x 0 , y 0 , x 1 , y 1 ,......, x n 1 , y n 1 , x n , y n , fit q uad ratic sp lines
thro ugh the data. T he sp lines
are give n b y
f ( x ) a 1 x b1 x c 1 ,
2
a 2 x b2 x c2 ,
2
x 0 x x1
x1 x x 2
.
.
.
a n x bn x cn ,
2
x n 1 x x n
F ind a i , bi , c i , i 1, 2, … , n
11
http://numericalmethods.eng.usf.edu
Quadratic Interpolation (contd)
Eac h q uadr atic sp line goes thro ugh tw o co nsec utive data po ints
2
a 1 x 0 b1 x 0 c 1 f ( x 0 )
a 1 x 1 b 1 x 1 c 1 f ( x1 )
2
.
.
.
2
a i x i 1 b i x i 1 c i f ( x i 1 )
2
a i xi bi xi c i f ( xi )
.
.
.
2
a n x n 1 b n x n 1 c n f ( x n 1 )
2
a n x n bn xn cn f ( x n )
12
T his co nd itio n give s 2 n eq uatio ns
http://numericalmethods.eng.usf.edu
Quadratic Splines (contd)
T he firs t der ivatives o f tw o q ua d ratic sp lines a re co ntinuo us a t the inte r ior po ints.
F or exa m p le, the der ivative o f the firs t sp line
a 1 x b1 x c 1
2
is
2 a1 x b1
T he der ivative o f the seco nd sp line
a 2 x b 2 x c 2 is
2
2 a2 x b2
and the tw o are eq ua l at x x 1 giving
2 a 1 x 1 b 1 2 a 2 x1 b 2
2 a1 x 1 b1 2 a 2 x1 b 2 0
13
http://numericalmethods.eng.usf.edu
Quadratic Splines (contd)
S im ilarly at the other interior points,
2 a 2 x 2 b 2 2 a 3 x 2 b3 0
.
.
.
2 a i x i b i 2 a i 1 x i b i 1 0
.
.
.
2 a n 1 x n 1 b n 1 2 a n x n 1 b n 0
W e have (n -1) su ch equ ations. T he total num ber of equations is ( 2 n ) ( n 1) ( 3 n 1) .
W e can assum e that the first spline is linear, that is
14
a1 0
http://numericalmethods.eng.usf.edu
Quadratic Splines (contd)
This gives us ‘3n’ equations and ‘3n’ unknow ns. O nce w e find the ‘3n’ constants,
w e can find the function at an y value of ‘x’ using the splines,
f ( x ) a 1 x b1 x c 1 ,
2
a 2 x b2 x c 2 ,
2
x 0 x x1
x1 x x 2
.
.
.
a n x bn x c n ,
2
15
x n 1 x x n
http://numericalmethods.eng.usf.edu
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
t (s)
0
10
15
20
22.5
30
16
(m/s)
0
227.04
362.78
517.35
602.97
901.67
v (t )
Figure. Velocity vs. time data
for the rocket example
http://numericalmethods.eng.usf.edu
Solution
v ( t ) a 1 t b1 t c1 ,
2
0 t 10
a 2 t b2 t c 2 ,
10 t 15
a 3 t b3 t c 3 ,
15 t 20
a 4 t b4 t c 4 ,
20 t 22 . 5
a 5 t b5 t c 5 ,
22 . 5 t 30
2
2
2
2
Let us set up the equations
17
http://numericalmethods.eng.usf.edu
Each Spline Goes Through
Two Consecutive Data Points
v ( t ) a 1 t b1 t c1 , 0 t 10
2
a 1 ( 0 ) b1 ( 0 ) c 1 0
2
a 1 (10 ) b1 (10 ) c 1 227 . 04
2
18
http://numericalmethods.eng.usf.edu
Each Spline Goes Through
Two Consecutive Data Points
a 2 (10 ) b 2 (10 ) c 2 227 . 04
2
t
s
0
v(t)
m/s
0
a 2 (15 ) b 2 (15 ) c 2 362 . 78
10
15
20
22.5
227.04
362.78
517.35
602.97
a 3 ( 20 ) b 3 ( 20 ) c 3 517 . 35
2
a 3 (15 ) b3 (15 ) c 3 362 . 78
2
2
a 4 ( 20 ) b 4 ( 20 ) c 4 517 . 35
2
a 4 ( 22 . 5 ) b 4 ( 22 . 5 ) c 4 602 . 97
2
a 5 ( 22 . 5 ) b5 ( 22 . 5 ) c 5 602 . 97
2
30
901.67
a 5 ( 30 ) b 5 ( 30 ) c 5 901 . 67
2
19
http://numericalmethods.eng.usf.edu
Derivatives are Continuous at
Interior Data Points
2
v ( t ) a 1 t b1 t c1 , 0 t 10
a 2 t b 2 t c 2 ,10 t 15
2
d
dt
a t
1
2
b1t c1
t 10
2 a1t b1 t 10
d
dt
a
t b2 t c 2
2
2
t 10
2 a 2 t b 2 t 10
2 a 1 10 b1 2 a 2 10 b 2
20 a 1 b1 20 a 2 b 2 0
20
http://numericalmethods.eng.usf.edu
Derivatives are continuous at
Interior Data Points
At t=10
2 a 1 (10 ) b1 2 a 2 (10 ) b 2 0
At t=15
2 a 2 (15 ) b 2 2 a 3 (15 ) b 3 0
At t=20
2 a 3 ( 20 ) b 3 2 a 4 ( 20 ) b 4 0
At t=22.5
2 a 4 ( 22 . 5 ) b 4 2 a 5 ( 22 . 5 ) b 5 0
21
http://numericalmethods.eng.usf.edu
Last Equation
a1 0
22
http://numericalmethods.eng.usf.edu
Final Set of Equations
0
100
0
0
0
0
0
0
0
0
20
0
0
0
1
23
0
1
0
0
0
0
0
0
0
0
0
0
10
1
0
0
0
0
0
0
0
0
0
0
0
0
100
10
1
0
0
0
0
0
0
0
0
0
225
15
1
0
0
0
0
0
0
0
0
0
0
0
0
225
15
1
0
0
0
0
0
0
0
0
0
400
20
1
0
0
0
0
0
0
0
0
0
0
0
0
400
20
1
0
0
0
0
0
0
0
0
0
506 . 25
22 . 5
1
0
0
0
0
0
0
0
0
0
0
0
0
506 . 25
0
0
0
0
0
0
0
0
0
0
0
900
1
0
20
1
0
0
0
0
0
0
0
0
0
0
30
1
0
30
1
0
0
0
0
0
0
0
0
0
0
40
1
0
40
1
0
0
0
0
0
0
0
0
0
0
45
1
0
45
0
0
0
0
0
0
0
0
0
0
0
0
0 a1
0
0
0 b1 227 . 04
0
0 c1
227 . 04
0
0 a 2 362 . 78
0
0 b 2 362 . 78
517 . 35
0
0 c2
0
0 a 3 517 . 35
0
0 b 3 602 . 97
22 . 5 1 c 3 602 . 97
30
1 a 4 901 . 67
0
0 b4 0
0
0 c4 0
0
0 a5
0
1
0 b5 0
0
0 c 5 0
0
http://numericalmethods.eng.usf.edu
Coefficients of Spline
24
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
5
0.20889
−33.956 554.55
28.86
−152.13
http://numericalmethods.eng.usf.edu
Quadratic Spline Interpolation
Part 2 of 2
http://numericalmethods.eng.usf.edu
25
http://numericalmethods.eng.usf.edu
Final Solution
0 t 10
v ( t ) 22 . 704 t ,
0 . 8888 t 4 . 928 t 88 . 88 ,
10 t 15
0 . 1356 t 35 . 66 t 141 . 61 ,
15 t 20
1 . 6048 t 33 . 956 t 554 . 55 ,
20 t 22 . 5
0 . 20889 t 28 . 86 t 152 . 13 ,
22 . 5 t 30
2
2
2
2
26
http://numericalmethods.eng.usf.edu
Velocity at a Particular Point
a) Velocity at t=16
0 t 10
v ( t ) 22 . 704 t ,
0 . 8888 t 4 . 928 t 88 . 88 ,
10 t 15
0 . 1356 t 35 . 66 t 141 . 61 ,
15 t 20
1 . 6048 t 33 . 956 t 554 . 55 ,
20 t 22 . 5
0 . 20889 t 28 . 86 t 152 . 13 ,
22 . 5 t 30
2
2
2
2
v 16 0 . 1356 16 35 . 66 16 141 . 61
2
394 . 24 m/s
27
http://numericalmethods.eng.usf.edu
Acceleration from Velocity Profile
b) The quadratic spline valid at t=16 is
given by
a (16 )
d
dt
v (t )
t 16
2
v t 0 . 1356 t 35 . 66 t 141 . 61 , 15 t 20
a (t )
d
( 0 . 1356 t 35 . 66 t 141 . 61 )
2
dt
0 . 2712 t 35 . 66 , 15 t 20
a (16 ) 0 . 2712 (16 ) 35 . 66 31 . 321 m/s
28
2
http://numericalmethods.eng.usf.edu
Distance from Velocity Profile
c) Find the distance covered by the rocket from t=11s to
t=16s.
S 16 S 11
16
v ( t ) dt
11
v t 0 . 8888 t 4 . 928 t 88 . 88 , 10 t 15
2
0 . 1356 t 35 . 66 t 141 . 61 , 15 t 20
2
S 16 S 11
16
15
16
11
11
15
v t dt v t dt v t dt
15
0 . 8888 t
11
2
4 . 928 t 88 . 88 dt
16
0 . 1356 t
2
35 . 66 t 141 . 61 dt
15
1595 . 9 m
29
http://numericalmethods.eng.usf.edu
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