Spline Background
Problem: high degree interpolating polynomials often
have extra oscillations.
1
Example: Runge function f (x) = 1+4x
2 , x [1, 1].
1/(1+4x2) and P8(x) and P16(x)
1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
S1(x) = 2 + 34 (x 1) + 41 (x 1)3,
S2(x) = 3 + 32 (x 2) + 43 (x 2)2 14 (x 2)3,
yj
= bj + cj hj + dj h2j ,
hj
where yj = yj+1 yj .
Notice Sj00(x) = 2cj + 6dj (x xj ), so
00
e) Sj+1
(xj+1) = Sj00(xj+1), implies
2cj+1 = 2cj + 6dj hj ; dj hj = (cj+1 cj )/3,
00
with extra unknown cn = Sn1
(xn)/2 added. Then
(cj+1 cj )hj
yj
(cj+1 + 2cj )hj
= bj + cj hj +
= bj +
;
hj
3
3
3yj+1 3yj
h2
h1
3y3 3y2
hn2
hn3
3yn1 3yn2
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
1
0.8
0.6
0.4
0.2
0.2
0.4
0.6
0.8
3y
2c1h1 + c2h1 = 3y
1 , and
h1
n1
cn1hn1 + 2cnhn1 = 3yn0 3y
hn1 .
Linear system equations are a tridiagonal system
2c1h1 + c2h1 =
c1h1 + 2c2(h1+h2) + c3h2 =
..
cn2hn2 + 2cn1(hn2+hn1) + cnhn1 =
cn1hn1 + 2cnhn1 =
3y1
3y10
h1
3y2 3y1
h2
h1
..
3yn1 3yn2
hn1
hn2
3yn1
.
3yn0
hn1
h2
h1
..
..
3yn1 3yn2
cn2hn2 + 2cn1(hn2+hn1) + cnhn1 =
hn1
hn2
cn1 cn = 0.
which can be solved (uniquely) for cj s with O(n) work;
dj = (cj+1 cj )/(3hj ), bj = yj /hj cj hj dj h2j
can be used to find remaining coefficients for Sj (x)s.
hn1
hn2
cn2hn1 cn1(hn2 + hn1) + cnhn2 = 0.
which can be solved (uniquely) for cj s with O(n) work;
dj = (cj+1 cj )/(3hj ), bj = yj /hj cj hj dj h2j
can be used to find remaining coefficients for Sj (x)s.
)(x xj ).
hj
3
hj+1
3
Compare with polynomial interpolation, where setup
time is O(n2) and evauation time is O(n).
Error Theorem :
if f C 4[a, b], with maxx[a,b] |f (4)(x)| = M , and
S(x) is the unique clamped spline for f (x) with
nodes a = x1 < x2 < xn = b, then
|f (x) S(x)|
10
5M
max h4j .
384 1j<n