Splines 2014
Splines 2014
Francis J. Narcowich
October 2014∗
1 Splines
Splines are piecewise polynomial functions that have certain “regularity”
properties. These can be defined on all finite intervals, and intervals of the
form (−∞, a], [b, ∞) or (−∞, ∞).
We have already encountered linear splines, which are simply continuous,
piecewise-linear functions. More general splines are defined similarly to the
linear ones. They are labeled by three things: (1) a knot sequence, ∆; (2) the
degree k of the polynomial; and, (3) the space C r , the level of differentiability
of the whole spline. The knot sequence is where the polynomial may change.
For a linear spline defined on [0, 1], the knot sequence ∆ = {x0 = 0 < x1 <
x2 < · · · < xn = 1} is where one linear polynomial meets another. Since the
polynomials are linear, k = 1. Finally, since the linear splines are continuous,
they are in C 0 [0, 1], so r = 0.
Definition 1.1. We denote the set of splines having knot sequence ∆, degree
of polynomial k, and smoothness C r by S ∆ (k, r).
There is a special case in which k = 0 and r = −1. These are just step
functions. Since the polynomials are taken to be constants, k = 0. Letting
r = −1 simply means that the step function is discontinuous at the knots.
With ∆, k, and r fixed, S ∆ (k, r) is a vector space, which may be finite
dimensional or infinitely dimensional. This raises the issue of bases for the
spaces.
1
(
x x≥0
(x)+ =
0 x < 0.
The knot sequence for N2 is the the set of all integers, Z, although changes
in the function only occur at {0, 1, 2}, and N2 is a linear spline. As the
graph below shows, N2 is a “tent” function.
N2(x)
0.5
Proof. Exercise.
1
The order of a B-spline is m = k + 1.
2
Example 1.3. Consider n = 4. Recall that the values at the corners and
endpoints determine the linear spline. So, let yj be given at j = 0, 1, 2, 3, 4.
Then, the interpolating spline is
4
X
s(x) = yj N2 (4x − j + 1), 0 ≤ x ≤ 1.
j=0
(
1 x ∈ [0, 1)
The order 1 B-spline is just a “box” of the form N1 (x) = .
0 x 6∈ [0, 1)
It can be used to start an iteration to obtain cardinal B-splines of order
m ≥ 2 and higher. The recurrence formula to be iterated is
x m−x
Nm (x) = Nm−1 (x) + Nm−1 (x − 1).
m−1 m−1
From the formula above, one can show that the order m B-splines, Nm , are
in S Z (m − 1, m − 2), and that the support of Nm is precisely [0, m]. This
feature is important enough that is used to label them.
3
join, so there are r + 1 equations that must match (the polynomials across
a knot must match and their r derivatives must match). This yields (n −
1)(r + 1) constraints. Therefore, we have at least n(k + 1) − (n − 1)(r + 1) =
1
n(k − r) + r + 1 parameters. It follows that the dimension of S n (k, r) =
n(k − r) + r + 1 provided that the equations at the knots are independent
(which can be shown). We summarize this below3
1
Proposition 2.1. dim S n (k, r) = n(k − r) + r + 1.
1
For an example, consider k = 1, r = 0. This is the space S n (1, 0) which
has dimension n(1 − 0) + 0 + 1 = n + 1. If we consider k = m − 1, r = m − 2,
1
then the dimension S n (m−1, m−2) is n(m−1−m+2)+m−2+1 = n+m−1.
satisfies φ(1) = φ0 (1) = 0. Substituting the values for φ(0) = 1 and φ0 (0) = 0
yields −A + B = 1 and 3A − 2B = 0, which has the solution A = 2 and
B = 3. Then, after re-arranging, we see that
4
By construction, φ(0) = 1 and φ0 (±1) = φ0 (0) = 0. Of course, outside of
[−1, 1], it is identically 0. It is easy to show that φ ∈ C (1) , so φ ∈ S Z (3, 1).
The function φ will be used to interpolate the values of a function, while
yielding zero derivative data on each of the knots.
We next construct a function ψ that takes zero value at the endpoints,
but assumes a derivative value of one at 0. We let ψ be the cubic function
ψ(x) = A(x − 1)3 + B(x − 1)2 ,
which already satisfies ψ(1) = ψ 0 (1) = 0. The condition ψ(0) = 0 implies
A = B and the condition ψ 0 (0) = 1 implies 3A − 2B = 1. Combining these
conditions yields the function
ψ(x) = x(x − 1)2 .
We then extend it to all of R:
(
x(|x| − 1)2 |x| ≤ 1
ψ(x) = (3.2)
0 |x| > 1
As in the case of φ, we have ψ ∈ S Z (3, 1), but this time ψ(0) = 0 and
ψ 0 (0) = 1.
1
We now construct a set of functions that will form a basis for S n (3, 1).
We begin by changing scale in φ and ψ, which are defined in (3.1) and (3.2),
and then translating the resulting functions. For φ, we define
φj (x) := φ(nx − j). (3.3)
Notice that φ0 (x) = φ(nx) and φj (x) = φ(n(x − nj )) = φ0 (x − nj ). That
is, φj (x) is φ0 (x) translated by nj , that φj (x) is supported on the interval
[ j−1 j+1 0
n , n ], and that the conditions used to define φ – i.e., φ(0) = 1, φ (0) = 0
0
and so on – imply that φj (k/n) = δj,k and that φj (k/n) = 0.
To construct ψj basis functions from ψ, we first consider the derivative
of ψ(nx − j). We note that
d 0 0
dx (ψ(nx − j)) x= j = nψ (nx − j) x= j = nψ (0) = n.
n n
5
4 Interpolation with Cubic Splines
We consider the problem of interpolating a function f and its derivative at
a set of n + 1 equally spaced knots, using the cubic splines constructed in
the previous section. We begin by showing that {φj , ψj }nj=0 is a basis for
1
S n (3, 1).
We note that there are n + 1 of each type, which gives a total of 2n + 2
1
functions in the set. Since this is the dimension of S n (3, 1), it suffices to
show that the set {φj , ψj }nj=0 is linearly independent.
Consider a linear combination of the cubic splines, s(x) = nj=0 αj φj (x)+
P
βj ψj (x). Using φj (k/n) = δj,k , φj (k/n) = 0 and ψj (k/n) = 0, ψj0 (k/n) = δk,j ,
we see that
Xn
s(k/n) = αj φj (k/n) +βj ψj (k/n) = αk (4.1)
| {z } | {z }
j=0
δj,k 0
n
X
s0 (k/n) = αj φ0j (k/n) +βj ψj0 (k/n) = βk , (4.2)
j=0
| {z } | {z }
0 δj,k
6
1
over all s ∈ S n (3, 1) for which s(xj ) = fj for j = 0, . . . , n.
Since s is a piecewise cubic function, s00 exists and is piecewise continu-
1
ous. Therefore, the equation (5.1) is well defined for all of s ∈ S n (3, 1). In
fact, it can be shown that (5.1) is an inner product on the set of functions
1
in S n (3, 1) that are zero at the endpoints.
1
Any function s ∈ S n (3, 1) such that s(xj ) = fj can be written in the
form
Xn Xn
s(x) = fj φj (x) − αj ψj (x).
j=0 j=0
Pn
Let f = j=0 fj φj (x). We seek to find coefficients α that minimize the
norm of s. That is, we want to solve the problem
hf − g, ψk i = 0 (5.3)
The matrix G is a Gram matrix for the linearly independent ψj ’s. Conse-
quently, it’s invertible. Due to the compact support of ψk , we see that
Z 1 Z
00 00
hψj , ψk i = ψj (x)ψk (x) dx = ψj00 (x)ψk00 (x) dx. (5.5)
0 [ j−1
n
, j+1
n
]∩[ k−1
n
, k+1
n
]