0% found this document useful (0 votes)
185 views13 pages

Spline

(1) Splines are piecewise polynomials that are smooth at the points where the pieces meet (called knots). This allows for a flexible function that interpolates data points. (2) Linear splines are piecewise linear functions that exactly interpolate given data points. However, the derivative is generally discontinuous at knots. (3) Quadratic splines are piecewise quadratic functions that have continuous first derivatives at knots, providing a smoother interpolation. The smoothness conditions require matching of first derivatives between pieces at knots.
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)
185 views13 pages

Spline

(1) Splines are piecewise polynomials that are smooth at the points where the pieces meet (called knots). This allows for a flexible function that interpolates data points. (2) Linear splines are piecewise linear functions that exactly interpolate given data points. However, the derivative is generally discontinuous at knots. (3) Quadratic splines are piecewise quadratic functions that have continuous first derivatives at knots, providing a smoother interpolation. The smoothness conditions require matching of first derivatives between pieces at knots.
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/ 13

Interpolation by Splines

KEY WORDS. interpolation, polynomial interpolation, spline.


GOAL.
Understand what splines are
Why the spline is introduced
Approximating functions by splines
We have seen in previous lecture that a function f(x) can be interpolated
at n +1 points in an interval [a, b] using a single polynomial p
n
(x) dened over
the entire interval. The error estimate of polynomial interpolation gives
|f(x) p
n
(x)|
|
n+1
(x)|
(n + 1)!
|f
(n+1)
(
x
)|,
where
x
is a point depending on x and the interpolation points {x
i
}
n
i=0
. Since
the term

n+1
(x)

in the bound is the product of n + 1 linear factors |x x


i
|,
each being the distance between two points that both lie in [a, b], we have
|x x
i
| |b a| and so
max
x[a,b]
|f(x) p
n
(x)| |b a|
n+1
max
x[a,b]
|f
(n+1)
(x)|
(n + 1)!
. (1)
This bound suggests that we can make the error as small as we wish by freezing
the value of n and then reducing the size of |b a|. But we still need an
approximation over the original interval [a, b], so we use a piecewise polynomial,
or spline, approximation, in which the original interval is divided into non-
overlapping subintervals and a dierent polynomial fit of the data is used on
each subinterval.
1 Splines
To draw smooth curves through data points, drafters once used thin exible
strips of wood, hard rubber, metal or plastic called mechanical splines. To use
a mechanical spline, pins were placed at a judicious selection of points along a
curve in a design, then the spline was bent so that it touched each of these pins.
Clearly, with this construction, the spline interpolates the curve at these pins
and could be used to reproduce the curve in other drawings. The location of
the pins are called knots. We can change the shape of the curve defined by the
spline by adjusting the location of the knots. For example, to interpolate the
data {(x
i
, f
i
)} we can place knots at each of the nodes x
i
.
Mathematically, a spline function consists of polynomial pieces on subin-
tervals joined together with certain continuity conditions. Formally, suppose
1
that n+1 points x
0
, x
1
, , x
n
have been specied and satisfy x
0
< x
1
< <
x
n
. These points are called knots. Suppose also that an integer k 0 has been
prescribed. A spline function of degree k having knots x
0
, x
1
, , x
n
is a
function S such that:
1. on each interval [x
i1
, x
i
], S is a polynomial of degree k;
2. S has a continuous (k 1)
st
derivative on [x
0
, x
n
].
Hence, S is a piecewise polynomial of degree at most k having continuous
derivatives of all orders up to k 1.
A spline of degree 1 is piecewise linear and has the form
S(x) =
_

_
p
1
(x) = a
1
+ b
1
x, x [x
0
, x
1
),
p
2
(x) = a
2
+ b
2
x, x [x
1
, x
2
),
.
.
.
p
n
(x) = a
n
+ b
n
x, x [x
n1
, x
n
],
In this lecture, we will only consider spline interpolation using linear splines
(splines of degree 1), quadratic splines (splines of degree 2), and cubic splines
(splines of degree 3). Generalization to splines of general order is relatively
straightforward.
2 Linear Interpolating Splines
A simple piecewise polynomial fit is the continuous linear interpolating spline.
For the data set
x x
0
x
1
x
n
y f
0
f
1
f
n
where
a = x
0
< x
1
< . . . < x
n
= b,
the linear spline S
1,n
(x) is a continuous function that interpolates the data
and is constructed from linear functions that are twopoint interpolating poly-
nomials:
S
1,n
(x) =
_

_
p
1
(x) = f
0
xx1
x0x1
+ f
1
xx0
x1x0
, x [x
0
, x
1
],
p
2
(x) = f
1
xx2
x1x2
+ f
2
xx1
x2x1
, x [x
1
, x
2
],
.
.
.
p
n
(x) = f
n1
xxn
xn1xn
+ f
n
xxn1
xnxn1
, x [x
n1
, x
n
].
(2)
Note that
p
1
(x
0
) = f
0
, p
1
(x
1
) = p
2
(x
1
) = f
1
, . . . , p
n1
(x
n1
) = p
n
(x
n1
) = f
n1
, p
n
(x
n
) = f
n
.
2
From the bound on the error for polynomial interpolation in the case of an
interpolating polynomial of degree one, we have
max
x[xi1,xi]
|f( x)S
1,n
( x)|
|x
i
x
i1
|
2
2!
. max
x[xi1,xi]
|f
(2)
(x)|
h
2
2
max
x[a,b]
|f
(2)
(x)|,
where h = max
1in
|x
i
x
i1
|. That is, as the maximum interval length
h 0, the bound on the maximum absolute error behaves like Ch
2
, where C
is a positive constant independent of h.
Suppose that the nodes are chosen to be equally spaced in [a, b], so that
x
i
= a + ih, i = 0, 1, . . . , n, where h (b a)/n. As the number of points n
increases, the error in using S
1,n
( x) as an approximation to f( x) tends to zero
like 1/n
2
.
Example: We construct the linear spline interpolating the data
x 1 0 1
y 0 1 3
from (2), as follows:
S
1,2
(x) =
_

_
0
x0
(1)0
+ 1
x(1)
0(1)
, x [1, 0],
1
x1
01
+ 3
x0
10
, x [0, 1],
(3)
(4)
(5)
=
_
_
_
x + 1, x [1, 0],
2x + 1, x [0, 1].
(6)
An alternative way of representing a linear spline uses a linear spline basis,

i
(x), i = 0, 1, . . . , n, chosen so that

i
(x
j
) =
_
0, j = i
1, j = i.
(7)
Here, each
i
(x) is a roof shaped function with the apex of the roof at the
point (x
i
, 1) and the span on the interval [x
i1
, x
i+1
], and with
i
(x) 0 outside
[x
i1
, x
i+1
]. That is,

i
(x) =
_

_
xxi1
xixi1
, x [x
i1
, x
i
],
xi+1x
xi+1xi
, x [x
i
, x
i+1
],
0, for all other x.
(8)
3
In terms of the linear spline basis, we can write
S
1,n
(x) =
n

i=0
f
i

i
(x). (9)
Then, using (7), we have
S
1,n
(x
j
) =
n

i=0
f
i

i
(x
j
) = f
j
, j = 0, . . . , n.
Example: To construct the linear spline interpolating the data
x 1 0 1
y 0 1 3
using the linear spline basis, we first construct the basis functions as follows:

0
(x) =
_
0x
0(1)
, x [1, 0],
0, x [0, 1],
=
_
_
_
x, x [1, 0],
0, x [0, 1],

1
(x) =
_
x(1)
0(1)
, x [1, 0],
1x
10
, x [0, 1],
=
_
_
_
x + 1, x [1, 0],
1 x, x [0, 1],

2
(x) =
_
_
_
0, x [1, 0],
x0
10
, x [0, 1],
=
_
_
_
0, x [1, 0],
x, x [0, 1].
Then we obtain our linear spline interpolant,
p
2
(x) = 0
0
(x) + 1
1
(x) + 3
2
(x).
Linear splines suer from a major limitation: the derivative of a linear spline
is generally discontinuous at each interior node x
i
. To derive a piecewise polyno-
mial approximation with a continuous derivative requires that we use piecewise
polynomial pieces of higher degree and constrain the pieces to make the curve
smoother.
3 Quadratic Interpolating Splines
To derive a mathematical model of a quadratic spline, suppose the data are
{(x
i
, f
i
)}
n
i=0
, where, as for linear splines,
a = x
0
< x
1
< . . . < x
n
= b, h max
i
|x
i
x
i1
|.
A quadratic spline S
2,n
(x) is a C
1
piecewise quadratic polynomial. This means
that:
4
S
2,n
(x) is piecewise quadratic; that is, between consecutive knots x
i
,
S
2,n
(x) =
_

_
p
1
(x) = a
1
+ b
1
x + c
1
x
2
, x [x
0
, x
1
],
p
2
(x) = a
2
+ b
2
x + c
2
x
2
, x [x
1
, x
2
],
.
.
.
p
n
(x) = a
n
+ b
n
x + c
n
x
2
, x [x
n1
, x
n
];
S
2,n
(x) is C
1
; that is, S
2,n
(x) is continuous and has continuous first
derivative everywhere in the interval [a, b], in particular, at the knots.
For S
2,n
(x) to be an interpolatory quadratic spline, we must also have
S
2,n
(x) interpolates the data, that is,
S
2,n
(x
i
) = f
i
, i = 0, 1, . . . , n.
Within each interval (x
i1
, x
i
), the corresponding quadratic polynomial is
continuous and has continuous derivatives of all orders. Therefore, S
2,n
(x) or
one of its derivatives can be discontinuous only at a knot. Observe that the
function S
2,n
(x) has two quadratic pieces incident at the interior knot x
i
; to
the left of x
i
, it is a quadratic p
i
(x) while to the right it is a quadratic p
i+1
(x).
Thus, a necessary and sufficient condition for S
2,n
(x) to have continuous first
derivative is for these two quadratic polynomials incident at the interior knot
to match in first derivative value. So we have a set of smoothness conditions:
that is, at each interior knot,
p

i
(x
i
) = p

i+1
(x
i
), i = 1, 2, . . . , n 1.
In addition, to interpolate the data, we have a set on interpolation conditions:
that is, on the i-th interval,
p
i
(x
i1
) = f
i1
, p
i
(x
i
) = f
i
, i = 1, 2, . . . , n.
This way of writing the interpolation conditions also forces S
2,n
(x) to be con-
tinuous at the knots.
Since each of the n quadratic pieces has three unknown coecients, our
description of the function S
2,n
(x) involves 3n unknown coecients. Assuring
continuity of the first derivative imposes (n 1) linear constraints on its coe-
cients, and interpolation imposes an additional 2n linear constraints. Therefore,
there are a total of 3n 1 linear constraints on the 3n unknown coecients. In
order that we have the same number of equations as unknowns, we need 1 more
(linear) constraints.
Example 3.1. Construct a quadratic spline interpolating
(1, 0), (0, 1), (1, 3).
5
Solution: Assume that the quadratic spline S
2,2
(x) is of the form
p
1
(x) = a
1
+ b
1
x + c
1
x
2
, on [1, 0]
p
2
(x) = a
2
+ b
2
x + c
2
x
2
, on [0, 1]
Since S
2,2
(x) interpolates the data points, we have
p
1
(1) = a
1
b
1
+ c
1
= 0 (10)
p
1
(0) = a
1
= 1 (11)
p
2
(0) = a
2
= 1 (12)
p
2
(1) = a
2
+ b
2
+ c
2
= 3 (13)
In addition, (p
1
(0))

= (p
2
(0))

gives
b
1
= b
2
. (14)
Above are the ve linear equations about the six unknown coecients a
1
, b
1
, c
1
, a
2
, b
2
, c
2
,
which have innitely many solutions. If we impose one more constrain, for ex-
ample, (S
2,N
(1))

= 0,
b
1
2c
1
= 0.
Then there are six linear equations for six unknown coecients, from which it
can be solved that
a
1
= 1, b
1
= 2, c
1
= 1, a
2
= 1, b
2
= 2, c
2
= 0.
Therefore the quadratic spline function
S
2,2
(x) =
_
1 + 2x + x
2
, on [1, 0]
1 + 2x on [0, 1].
4 An example: the construction of a complete
interpolatory quadratic spline
To construct an interpolatory quadratic spline, we rst define the numbers
z
i
= S

2,n
(x
i
), 0 i n.
Since S
2,n
(x) is a quadratic spline, S

2,n
(x) is a linear spline (by checking the
denitions). Therefore S

2,n
(x) is given by the straight line joining the points
(x
i1
, z
i1
) and (x
i
, z
i
):
p

i
(x) = z
i1
+
z
i
z
i1
h
i
(x x
i1
),
where h
i
x
i
x
i1
. If this expression is integrated once, we obtain
p
i
(x) = z
i1
(x x
i1
) +
z
i
z
i1
2h
i
(x x
i1
)
2
+ C
i
(15)
6
where C
i
is constant of integration. The interpolation conditions p
i
(x
i1
) =
f(x
i1
) and p
i
(x
i
) = f(x
i
) give
C
i
= f(x
i1
), i = 1, 2, n (16)
and
z
i1
h
i
+
z
i
z
i1
2
h
i
+ C
i
= f(x
i
), i = 1, 2, n.
or equivalently
z
i
+ z
i1
2
h
i
= f(x
i
) f(x
i1
), i = 1, 2, n. (17)
The equation (17) is a system of n linear equations for the n + 1 unknowns
z
0
, z
1
, , z
n
. To obtain one additional equation, we apply the endpoint deriva-
tive conditions, e.g. p

1
(x
0
) = 0 which gives
z
0
= 0.
Now we obtain the system of linear equations,
Az = d, (18)
where
z = [z
0
, z
1
, , z
n
]
T
, d = [d
0
, d
1
, , d
n
]
T
,
with
d
i
=
_
_
_
0, i = 0,
2(f(xi)f(xi1))
xixi1
, 1 i n,
and A is the tridiagonal matrix
A =
_

_
1 0
1 1 0
0 1 1
.
.
.
.
.
.
.
.
.
0 1 1
_

_
.
The system can be solved, therefore the quadratic spline function (15).
Example 4.1. Again, we consider to construct a quadratic spline interpolating
(1, 0), (0, 1), (1, 3),
with S

2,2
(x = 1) = 0.
Solution: Let z = (z
0
, z
1
, z
2
)

, where z
i
= S

2,2
(x = x
i
). Then z satises the
linear equations,
Az = d,
7
with the matrix A is
A =
_
_
1 0 0
1 1 0
0 1 1
_
_
.
and
d = (0, 2, 4)

.
Therefore, z = (0, 2, 2)

. Pluging in z and C
1
= 0, C
2
= 1 (see equation (16))
into equation (15), gives
S
2,2
(x) =
_
1 + 2x + x
2
, on [1, 0]
1 + 2x on [0, 1].
It is observed that both approaches in this and previous example give the same
quadratic spline interpolation.
5 Cubic Interpolating Splines
To derive a mathematical model of a cubic spline, suppose the data are {(x
i
, f
i
)}
n
i=0
,
where, as for linear splines,
a = x
0
< x
1
< . . . < x
n
= b, h max
i
|x
i
x
i1
|.
A cubic spline S
3,n
(x) is a C
2
piecewise cubic polynomial. This means that:
S
3,n
(x) is piecewise cubic; that is, between consecutive knots x
i
,
S
3,n
(x) =
_

_
p
1
(x) = a
1
+ b
1
x + c
1
x
2
+ d
1
x
3
, x [x
0
, x
1
],
p
2
(x) = a
2
+ b
2
x + c
2
x
2
+ d
2
x
3
, x [x
1
, x
2
],
.
.
.
p
n
(x) = a
n
+ b
n
x + c
n
x
2
+ d
n
x
3
, x [x
n1
, x
n
];
S
3,n
(x) is C
2
; that is, S
3,n
(x) is continuous and has continuous first and
second derivatives everywhere in the interval [a, b], in particular, at the
knots.
For S
3,n
(x) to be an interpolatory cubic spline, we must also have
S
3,n
(x) interpolates the data, that is,
S
3,n
(x
i
) = f
i
, i = 0, 1, . . . , n.
Within each interval (x
i1
, x
i
), the corresponding cubic polynomial is con-
tinuous and has continuous derivatives of all orders. Therefore, S
3,n
(x) or one
of its derivatives can be discontinuous only at a knot. Observe that the function
S
3,n
(x) has two cubic pieces incident at the interior knot x
i
; to the left of x
i
,
8
it is a cubic p
i
(x) while to the right it is a cubic p
i+1
(x). Thus, a necessary
and sucient condition for S
3,n
(x) to be continuous and have continuous first
and second derivatives is for these two cubic polynomials incident at the interior
knot to match in value, and in first and second derivative values. So we have a
set of smoothness conditions: that is, at each interior knot,
p

i
(x
i
) = p

i+1
(x
i
), p

i
(x
i
) = p

i+1
(x
i
), i = 1, 2, . . . , n 1.
In addition, to interpolate the data, we have a set on interpolation conditions:
that is, on the i-th interval,
p
i
(x
i1
) = f
i1
, p
i
(x
i
) = f
i
, i = 1, 2, . . . , n.
This way of writing the interpolation conditions also forces S
3,n
(x) to be con-
tinuous at the knots.
Since each of the n cubic pieces has four unknown coefficients, our description
of the function S
3,n
(x) involves 4n unknown coefficients. Assuring continuity
of this function and its first and second derivatives imposes 3(n 1) linear
constraints on its coefficients, and interpolation imposes an additional n + 1
linear constraints. Therefore, there are a total of 4n 2n = 3(n 1) + (n + 1)
linear constraints on the 4n unknown coefficients. In order that we have the
same number of equations as unknowns, we need 2 more (linear) constraints.
There are various ways of specifying two additional constraints such as the
following.
1. The socalled natural cubic spline results when we impose the condi-
tions
p

1
(x
0
) = 0, p

n
(x
n
) = 0.
The natural cubic spline is seldom used since it does not provide a su-
ciently accurate approximation S
3,n
(x) near the ends of the interval [a, b].
This may be anticipated from the fact that we are forcing zero values on
the second derivatives when these are not necessarily the values of the sec-
ond derivative of the function which the data measures. A natural cubic
spline is built up from cubic polynomials, so it is reasonable to expect that
if the data come from a cubic polynomial, then the natural cubic spline
S
3,n
(x) will reproduce the cubic polynomial. However, for example, if the
data are measured from the function f(x) = x
2
then the natural spline
S
3,n
(x) = f(x); the function f(x) = x
2
has nonzero second derivatives
at the nodes x
0
and x
n
where the value of the second derivative of the
natural cubic spline S
3,n
(x) is zero by denition.
2. Instead of imposing the natural cubic spline conditions, we could use the
correct second derivative values:
p

1
(x
0
) = f

(x
0
), p

n
(x
n
) = f

(x
n
).
These second derivative values of the data are not usually available but
they can be replaced by accurate approximations.
9
3. A simpler, suciently accurate spline is determined using the socalled
notaknot conditions. Recall that at each knot the spline S
3,n
(x)
changes from one cubic to the next. The idea of the notaknot conditions
is not to change cubic polynomials as one crosses both the first and last
interior nodes, x
1
and x
n1
. [Then x
1
and x
N1
are not knots.] These
conditions are expressed mathematically as the notaknot conditions
p

1
(x
1
) = p

2
(x
1
), p

n1
(x
n1
) = p

n
(x
n1
).
By construction, the first two pieces, p
1
(x) and p
2
(x), of the cubic spline
S
3,n
(x) agree in value, first, and second derivative at x
1
. If p
1
(x) and p
2
(x)
also satisfy the notaknot condition at x
1
, it follows that p
1
(x) p
2
(x);
that is, x
1
is no longer a knot.
4. In the complete cubic spline, the slope conditions
p

1
(x
0
) = f

(x
0
), p

n
(x
n
) = f

(x
n
) (19)
are imposed. These first derivative values of the data may not be readily
available but they can be replaced by accurate approximations.
6 An example: the construction of a complete
interpolatory cubic spline
(Note: the notations below is a little bit dierent from what we adopt in the
class. However, the ideas behind are the same.)
As an example of the construction of an interpolatory cubic spline, we con-
sider case 4 of section 4.5, that of the complete cubic spline. First, we dene
the numbers z
i
= S

3,n
(x
i
), 0 i n. (The complete interpolatory cubic spline
will be dened in terms of z
i
, 0 i n.) Since S

3,n
is continuous at x
i
,
1 i n 1, the z
i
exist and, at each interior knot, satisfy
p

i
(x
i
) = z
i
= p

i+1
(x
i
), 1 i n 1.
Since p
i+1
(x) is a cubic polynomial on [x
i
, x
i+1
], p

i+1
is a linear function satis-
fying p

i+1
(x
i
) = z
i
and p

i
(x
i+1
) = z
i+1
and therefore is given by the straight
line joining the points (x
i
, z
i
) and (x
i+1
, z
i+1
):
p

i+1
(x) =
z
i
h
i+1
(x
i+1
x) +
z
i+1
h
i+1
(x x
i
),
where h
i+1
x
i+1
x
i
. If this expression is integrated twice, we obtain
p
i+1
(x) =
z
i
6h
i+1
(x
i+1
x)
3
+
z
i+1
6h
i+1
(x x
i
)
3
+ C(x x
i
) + D(x
i+1
x),
where C and D are constants of integration. The interpolation conditions
p
i+1
(x
i
) = f
i
and p
i+1
(x
i+1
) = f
i+1
give
z
i
6h
i+1
(x
i+1
x
i
)
3
+ D(x
i+1
x
i
) = f
i
10
and
z
i+1
6h
i+1
(x
i+1
x
i
)
3
+ C(x
i+1
x
i
) = f
i+1
,
respectively, from which it follows that
C =
_
f
i+1
h
i+1

z
i+1
h
i+1
6
_
, D =
_
f
i
h
i+1

z
i
h
i+1
6
_
.
Thus,
p
i+1
(x) =
z
i
6h
i+1
(x
i+1
x)
3
+
z
i+1
6h
i+1
(x x
i
)
3
+
_
f
i+1
h
i+1

z
i+1
h
i+1
6
_
(x x
i
)
+
_
f
i
h
i+1

z
i
h
i+1
6
_
(x
i+1
x).
Once the values of z
0
, z
1
, , z
n
have been found, S
3,n
(x) can be evaluated for
any x in the interval [x
0
, x
n
].
To determine z
1
, z
2
, , z
n1
, we use the continuity equations for S

3,n
. At
an interior knot x
i
, we must have p

i
(x
i
) = p

i+1
(x
i
). Since
p

i+1
(x) =
z
i
2h
i+1
(x
i+1
x)
2
+
z
i+1
2h
i+1
(x x
i
)
2
+
_
f
i+1
h
i+1

z
i+1
h
i+1
6
_

_
f
i
h
i+1

z
i
h
i+1
6
_
,
it follows that, after simplification,
p

i+1
(x
i
) =
h
i+1
3
z
i

h
i+1
6
z
i+1

f
i
h
i+1
+
f
i+1
h
i+1
, (20)
and analogously
p

i
(x
i
) =
h
i
6
z
i1
+
h
i
3
z
i

f
i1
h
i
+
f
i
h
i
. (21)
When the right hand sides of (20) and (21) are set equal to each other, the
result can be written as
h
i
z
i1
+2(h
i
+h
i+1
)z
i
+h
i+1
z
i+1
=
6
h
i+1
(f
i+1
f
i
)
6
h
i
(f
i
f
i1
), 1 i n1,
(22)
which is a system of n1 linear equations for the n+1 unknowns z
0
, z
1
, , z
n
.
To obtain two additional equations, we apply the endpoint derivative con-
ditions p

1
(x
0
) = f

0
f

(x
0
) and p

n
(x
n
) = f

n
f

(x
n
) of (19) to obtain,
respectively,
2h
1
z
0
+ h
1
z
1
=
6
h
1
(f
1
f
0
) 6f

0
, (23)
on using (20) with i = 0, and
h
n
z
n1
+ 2h
n
z
n
= 6f

n

6
h
n
(f
n
f
n1
), (24)
11
on using (21) with i = n. Combining equations (23), (22), and (24), we obtain
the system of linear equations,
Az = d, (25)
where
z = [z
0
, z
1
, , z
n
]
T
, d = [d
0
, d
1
, , d
n
]
T
,
with
d
i
=
_

_
6
h1
(f
1
f
0
) 6f

0
, i = 0,
6
hi+1
(f
i+1
f
i
)
6
hi
(f
i
f
i1
), 1 i n 1,
6f

n

6
hn
(f
n
f
n1
), i = n,
and A is the tridiagonal matrix
A =
_

_
2h
1
h
1
h
1
2(h
1
+ h
2
) h
2
h
2
2(h
2
+ h
3
) h
3
.
.
.
.
.
.
.
.
.
h
n1
2(h
n1
+ h
n
) h
n
h
n
2h
n
_

_
.
This system can be solved using the MATLAB function tridisolve available from
www.mathworks.com/Moler
7 The Error in Cubic Spline Interpolation
For each way of supplying the additional linear constraints discussed in the
preceding, the system of 4n linear constraints has a unique solution as long as
the knots are distinct. So, the cubic spline interpolant constructed using any one
of the natural, the correct endpoint second derivative value, an approximated
endpoint second derivative value, the notaknot conditions or the complete
spline conditions is unique. This uniqueness result permits an estimate of the
error associated with approximations by cubic splines from the error bound for
polynomial interpolation,
max
x[xi1,xi]
|f(x) p
3
(x)|
h
4
4!
max
x[a,b]
|f
(4)
(x)|,
where h = max
i
|x
i
x
i1
|. We might anticipate that the error associated with
approximation by a cubic spline would be O(h
4
) for h small, as for the interpo-
lating cubic polynomial. However, the maximum absolute error associated with
the natural cubic spline approximation behaves like O(h
2
) as h 0. In con-
trast, the maximum absolute error for a cubic spline based on correct endpoint
12
second derivative values, or on the notaknot conditions or the complete spline
conditions behaves like O(h
4
). Unlike the natural cubic spline, the correct sec-
ond derivative value, notaknot cubic splines and complete splines reproduce
cubic polynomials. That is, in all of these cases, S
3,n
(x) f(x) on the inter-
val [a, b] whenever the data are measured from a cubic polynomial f(x). This
reproducibility property is a necessary condition for the cubic spline S
3,n
(x) to
be an O(h
4
) approximation to a general function f(x).
13

You might also like