Cubic Spline Interpolation
Cubic Spline Interpolation
146
High-degree Interpolation
CHAPTER 3
polynomial fitting has strong oscillations.
and Polynomial Approximation
S n"2
S n"1
S1 Sj
S j!1
S0
S j (x j!1) # f (x j!1) # S j!1(x j!1)
S $j (x j!1) # S$j!1(x j!1)
S j%(x j!1) # S j!1
% (x j!1)
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 122
Cubic spline interpolation
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 123
Cubic spline interpolation
Remarks
1. S(x) only agrees with f (x) at xi , not necessarily f 0 (x).
2. Clamped BC is more accurate than natural BC, but needs
f 0 (a), f 0 (b).
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 124
d2 = (c3 − c1 ) = (−4e + 9e − 6e + 1) ≈ −1.94336.
3h2 15
Example
The natural cubic spine is described piecewise by
⎧
3
⎨1 + 1.46600x + 0.25228x ,
⎪ for x ∈ [0, 1],
2
S (x) = 2.71828
Example + 2.22285(x
(Construct a −1) + 0.75685(x
natural cubic +1.69107(x −1)3 , for x ∈ [1, 2],
−1)spline)
⎪
⎩
7.38906 + 8.80977(x −2) + 5.83007(x −2)2 −1.94336(x
x −2)3 , for x ∈ [2, 3].
Construct natural cubic spline forx f (x) = e using xi = i for
The spline and its agreement with f (x) = e are shown in Figure 3.10.
i = 0, 1, 2, 3.
Figure 3.10
y
e3
y = S(x)
y = ex
e2
e
1
1 2 3 x
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 125
Construction of cubic splines
aj , bj , cj , dj , for j = 0, . . . , n − 1
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 126
Construction of cubic splines
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 127
Construction of cubic splines
3 3
hj−1 cj−1 + 2(hj−1 + hj )cj + hj cj+1 = (aj+1 − aj ) − (aj − aj−1 )
hj hj−1
Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 128