6 04 Interpolasi Spline SJK
6 04 Interpolasi Spline SJK
6 04 Interpolasi Spline SJK
I t
Interpolation
l ti
Why Splines ?
1
f ( x) =
1 + 25 x 2
Table : Six equidistantly
q
y spaced
p
p
points in [[-1,, 1]]
x
y=
1
1 + 25 x 2
-1.0
10
0 038461
0.038461
-0.6
0.1
-00.22
05
0.5
0.2
0.5
0.6
0.1
1.0
0.038461
Why Splines ?
1.2
0.8
0.4
0
-1
-0.5
0.5
-0.4
-0.8
x
19th Order Polynomial
f (x)
Linear Interpolation
Given ( x0 , y0 ), (x1 , y1 ),......, (x n 1 , y n 1 )( x n , y n ) , 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 ( yi = f ( xi ) )
Figure : Linear splines
f ( x1 ) f ( x 0 )
( x x 0 ),
x1 x 0
x 0 x x1
= f ( x1 ) +
f ( x 2 ) f ( x1 )
( x x1 ),
)
x2 x1
x1 x x 2
.
.
.
= f ( x n 1 ) +
f ( x n ) f ( x n 1 )
( x x n 1 ), x n 1 x x n
x n x n 1
Example
The
h upward
d velocity
l
off a rocket
k is given as a
function of time in Table 1. Find the velocity at
t=16 seconds using linear splines.
splines
Table Velocity as a
function of time
t (s)
v (t ) (m/s)
0
10
15
20
22.5
30
0
227.04
362.78
517.35
602.97
901 67
901.67
Figure. Velocity vs. time data
for the rocket example
Linear Interpolation
t 0 = 15,
v (t 0 ) = 362.78
t1 = 20,
v (t1 ) = 517.35
v(t ) v (t 0 )
v (t ) = v(t 0 ) + 1
(t t 0 )
t1 t 0
517.35
500
ys
f ( range)
= 362.78 +
517.35 362.78
f(x
)
(t 15) desired
20 15
= 393.7
m/s
450
400
362.78
550
350
10
12
x s 10
0
14
16
18
x s , range, x desired
20
22
24
x s + 10
1
Quadratic Interpolation
Given ( x0 , y0 ), ( x1 , y1 ),......, (x n 1 , y n 1 ), ( x n , y n ) , fit quadratic splines through the data. The splines
are given by
f ( x ) = a1 x 2 + b1 x + c1 ,
= a 2 x 2 + b2 x + c2 ,
x 0 x x1
x1 x x 2
.
.
.
= a n x 2 + bn x + cn ,
x n 1 x x n
Find a i , bi , ci , i = 1,
1 22, , n
a1 x1 + b1 x1 + c1 = f ( x1 )
2
.
.
a i xi 1 + bi xi 1 + ci = f ( xi 1 )
2
a i xi + bi xi + c i = f ( xi )
2
.
.
a n x n 1 + bn x n1 + c n = f ( xn 1 )
2
a n x n + bn xn + cn = f ( x n )
2
2 a1 x + b1
2 a2 x + b 2
x0 x x1
x1 x x 2
.
.
.
= a n x 2 + bn x + c n ,
x n 1 x x n
t (s)
v (t ) (m/s)
0
10
15
20
22.5
30
0
227.04
362 78
362.78
517.35
602.97
901 67
901.67
Figure. Velocity
Fi
V l it vs. time
ti
data
d t
for the rocket example
Solution
2
v(t ) = a1t + b1t + c1 , 0 t 10
= a 2 t + b2 t + c 2 , 10 t 15
2
= a3 t + b3t + c3 , 15 t 20
2
= a 4 t + b4 t + c 4 , 20 t 22.5
2
= a5 t + b5 t + c5 ,
2
22.5 t 30
a1 (0) + b1 (0) + c1 = 0
2
a1 (10) + b1 (10) + c1 = 227.04
2
v(t)
m/s
0
227.04
362.78
517.35
602.97
901.67
a 3 ( 20 ) + b3 ( 20 ) + c 3 = 517 .35
2
a 4 ( 20 ) + b4 ( 20 ) + c 4 = 517 .35
a4 (22.5) 2 + b4 (22.5) + c4 = 602.97
2
= a 2 t + b2 t + c 2 ,10 t 15
2
d
2
a1t + b1t + c1
dt
t =10
d
2
=
a2t + b2t + c2
dt
)
t =10
At t=15
At t=20
At t=22.5
Last Equation
a1 = 0
0
0
0
0
0
0
0
20
0
0
0
1
10 1
100
10
225
15 1
225
15 1
400
20 1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
400
20 1
0 506.25 22.5 1
0 20 1 0
30
0 30 1 0
40
40
45
0 a1
0 b1
0
227.04
0
0
227.04
0
0
0 c1
0
0
0 a 2 362.78
0
0
0 b2 362.78
517.35
0
0
0 c2
0
0
0 a3 517.35
0
0
0 b3 = 602.97
506.25 22.5 1 c3 602.97
900
30 1 a 4 901.67
0
0
0 b4 0
0
0
0 c4 0
0
0
0 a5
0
45
1 0 b5 0
0
0
0 c5 0
0
Coefficients of Spline
i
ai
bi
ci
22.704
0 8888
0.8888
4 928
4.928
88 88
88.88
0.1356
35.66
141.61
1.6048
0.20889
33.956 554.55
28.86
152.13
152.13
v (t ) = 22.704t ,
Final Solution
0 t 10
10 t 15
15 t 20
20 t 22.5
22.5 t 30
v (t ) = 22.704t ,
10 t 15
15 t 20
20 t 22.5
22.5 t 30
15
16
11
11
15
16
= 1595.9 m
15