0% found this document useful (0 votes)
6 views

Cubic Spline Interpolation

Regarding Interpolation

Uploaded by

saadashfaq30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Cubic Spline Interpolation

Regarding Interpolation

Uploaded by

saadashfaq30
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Cubic spline interpolation

146
High-degree Interpolation
CHAPTER 3
polynomial fitting has strong oscillations.
and Polynomial Approximation

Can we get a piecewise “low degree” polynomial interpolation


Figure 3.8
instead?
S(x)

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)

x0 x1 x2 ... xj x j!1 x j!2 ... x n"2 x n"1 x n x

Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 122
Cubic spline interpolation

Suppose we are given x0 , . . . , xn and f (xi ), ∀ i, we want to find a


cubic spline interpolation S(x), s.t.
1. S(x) is a cubic polynomial, denoted by Sj (x), on [xj , xj+1 ];
2. Sj (xj ) = f (xj ), Sj (xj+1 ) = f (xj+1 )
3. Sj (xj ) = Sj+1 (xj ) for all j (consequence of Item 2.)
0 (x
4. Sj+1 0
j+1 ) = Sj (xj+1 ) for all j
00 (x
5. Sj+1 ) = S 00 (x
j+1 j j+1 ) for all j
6. One of the following boundary condition is satisfied:
I S 00 (x0 ) = S 00 (xn ) = 0 (natural/free boundary condition)
I S 0 (x0 ) = f 0 (x0 ) and S 0 (xn ) = f 0 (xn ) (clamped boundary
condition)

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

Given {(xi , f (xi )) : i = 0, . . . , n}, we need to construct n cubic


polynomials, each with 4 coefficients

Sj (x) = aj + bj (x − xj ) + cj (x − xj )2 + dj (x − xj )3 on [xj , xj+1 ], ∀j

So we have 4n unknowns to determine:

aj , bj , cj , dj , for j = 0, . . . , n − 1

Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 126
Construction of cubic splines

The cubic spline conditions will determine these 4n coefficients


uniquely (hj := xj+1 − xj ) according to the 6 rules:
1. By definition of Sj .
2. Since Sj (xj ) = aj = f (xj ), we get aj for j = 0, . . . , n − 1.
3. aj+1 = Sj+1 (xj+1 ) = Sj (xj+1 ) = aj + bj hj + cj hj2 + dj hj3 .
4. Sj0 (x) = bj + 2cj (x − xj ) + 3dj (x − xj )2 , therefore Sj0 (xj ) = bj
and bj+1 = Sj+10 (x 0 2
j+1 ) = Sj (xj+1 ) = bj + 2cj hj + 3dj hj .
5. Sj00 (x) = 2cj + 6dj (x − xj ). Then we have Sj00 (xj ) = 2cj . So
2cj+1 = Sj+100 (x 00
j+1 ) = Sj (xj ) = 2cj + 6dj hj .
6. Use the required boundary condition.
I Natural BC: c0 = cn = 0
I Clamped BC: b0 = f 0 (a), bn = f 0 (b).

Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 127
Construction of cubic splines

As we have known the values of aj , we can combine equations


from the last 3 items to solve for cj and obtain

3 3
hj−1 cj−1 + 2(hj−1 + hj )cj + hj cj+1 = (aj+1 − aj ) − (aj − aj−1 )
hj hj−1

for each j = 1, . . . , n − 1. If we assume natural splines with


S000 (x0 ) = Sn−1
00 (x ) = 0, then c = c = 0.
n 0 n

Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 128

You might also like