


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Given N + 1 data points in the interval [a, b],
x t 0 t 1 · · · tN
y y 0 y 1 · · · yN
t 0 t 1 t 2 t N− t N− t N
S 0
(x)
S 1 (x)
S N− (x)
S N− (x) S(x)
x
Cubic Spline
we want to construct a cubic spline S(x) to interpolate the table presumable of a function f (x).
We assume that the points are ordered so that
a = t 0 < t 1 < · · · < tN = b.
S(x) is given by a different cubic polynomial in each interval [t 0 , t 1 ], [t 1 , t 2 ], · · · , [tN − 1 , tN ]. Let
S(x) be given by Si(x) if x ∈ [ti, ti+1]. Each cubic polynomial is defined by 4 coefficients and so
we have a total of 4N parameters. These are determined by the following conditions:
have Si(ti) = yi and Si(ti+1) = yi+1.
′ (x) must be continuous at each of the internal knots. Therefore for i = 1, 2 , · · · , N − 1
we must have S ′ i− 1 (ti) = S ′ i (ti).
′′ (x) must be continuous at each of the internal knots. Therefore for i = 1, 2 , · · · , N − 1
we must have S
′′ i− 1 (ti) =^ S
′′ i (ti).
(a) The natural spline: S ′ (a) = 0 = S ′ N − 1 (b),
(b) The clamped cubic spline: S ′ 0 (a) = f ′ (a) and S ′ N − 1 (b) = f ′ (b).
The clamped cubic spline gives more accurate approximation to the function f (x), but requires
knowledge of the derivative at the endpoints. Condition 1 gives 2N relations. Conditions 2, 3
and 4 each gives N − 1 relations. Together with the 2 relations from condition 4, we have a
total of 2N + 2(N − 1) + 2 = 4N conditions. Thus we have just the right number of relations to
determined all the parameters uniquely.
The best way to express the cubic polynomial within each subinterval is to note that since
Si(x) is a cubic polynomial, then S
′′ i (x) must be a linear function of the form
′′ i (x) =^ αx^ +^ β.
Next we denote S ′′ i (ti) = zi and S ′′ i (ti+1) = zi+1, so that replacing i by i − 1 in the second
expression gives S ′′ i− 1 (ti) = zi, and therefore condition 3 is automatically satisfied. We then
evaluate S ′′ i (x) at the endpoint of the subinterval to get
′′ i (ti) = zi = αti + β
′′ i (ti+1) = zi+1 = αti+1 + β.
We can then solve for α and β to obtain
α =
zi+1 − zi
hi
β =
ziti+1 − zi+1ti
hi
where we define hi = ti+1 − ti for i = 0, · · · , N − 1. Inserting these back to the expression for
S
′′ i (x) gives
′′ i (x) =^
zi
hi
(ti+1 − x) +
zi+
hi
(x − ti).
Integrating this expression, we have
′ i(x) =^ −^
zi
2 hi
(ti+1 − x)
2
zi+
2 hi
(x − ti)
2
where p is a constant. Integrating one more time, we have
Si(x) = −
zi
6 hi
(ti+1 − x)
3
zi+
6 hi
(x − ti)
3
where q is another constant. Instead of using constants p and q, it is better to use constants C
and D so that
Si(x) = −
zi
6 hi
(ti+1 − x)
3
zi+
6 hi
(x − ti)
3
Evaluating this at ti gives
Si(ti) = yi =
zi
h
2 i
from which we get D =
yi hi
zihi 6
. Similarly, evaluating Si(x) at ti+1 gives
Si(ti+1) = yi+1 =
zi+
h
2 i
from which we get C =
yi+ hi
zi+1hi 6
. Using these results for C and D, we finally have the
expression for Si(x):
Si(x) = −
zi
6 hi
(ti+1 −x)
3
zi+
6 hi
(x−ti)
3
yi+
hi
zi+1hi
(x−ti)+
yi
hi
zihi
(ti+1 −x). (1)
One can easily see that
Ai =
zi+1 − zi
6 hi
Bi =
zi
Ci = −
hizi+
hizi
yi+1 − yi
hi