Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

INTERPOLATION

BISHNU P. LAMICHHANE

1. P IECEWISE P OLYNOMIAL I NTERPOLATION


So far we have considered the approximation of a function by a global polynomial. This
implies that if the definition of the function is to be modified at a point, the polynomial
interpolant changes globally. On the contrary, the piecewise polynomial interpolant does
not change globally if the definition of the function changes locally. Moreover, high-degree
polynomials can oscillate erratically manifesting Runge’s phenomenon.
Assume that the interpolation problem is posed on an interval I ⊂ R. The central idea
of piecewise interpolation is to decompose the interval I into non-overlapping subinter-
vals and construct different polynomials in each subinterval. This is then called piecewise-
polynomial approximation. The simplest piecewise-polynomial approximation is piecewise-
linear interpolation. The piecewise-linear interpolant is often called linear spline inter-
polant.

1.1. Piecewise-linear Interpolant or Linear Spline Interpolant. Let ∆ = {a = x0 < x1 <


· · · < xn = b} be a set of points in [a, b], and T = {Ii }n−1
i=0 , where Ii = [xi , xi+1 ).

The piecewise-linear interpolant is obtained


by joining the set of data points
{(x0 , f (x0 )), (x1 , f (x1 )), · · · , (xn , f (xn ))}
by a series of straight lines, as shown in the
adjacent figure.

Let Sl (∆) be the space of all pieceise-linear functions with respect to ∆. One can show that

University of Newcastle, School of Mathematical & Physical Sciences, Mathematics Building V, University
Drive, Callaghan, NSW 2308, Australia, Bishnu.Lamichhane@newcastle.edu.au.
1
2 BISHNU P. LAMICHHANE

Sl (∆) is a linear space of dimension n + 1. Then if we define


 x − x1 if x ∈ I  x − xn−1 if x ∈ I
 
0 n−1
φ0 (x) = x0 − x 1 , φn (x) = xn − xn−1 and
 0 otherwise  0 otherwise
 x−x
i−1
 if x ∈ Ii−1
 xi − xi−1


x − xi+1
φi (x) = if x ∈ Ii , for i = 1, . . . , n − 1,
 x − x
 i i+1


0 otherwise
{φi }ni=0 forms a basis for the space the set Sl (∆). Thus, a function sl ∈ Sl can be written as
n
sl (x) = ∑ ci φi (x),
i=0
where c0 , . . . , cn are arbitrary constants. As φi (x j ) = δi j , the basis {φi }ni=0 is a nodal basis of
S1,0 (T ) with respect to the set of points ∆. Therefore, the piecewise linear interpolation of
a continuous function f : [a, b] → R is obtained by setting ci = f (xi ), i = 0, . . . , n. The basis
functions are continuous but not differentiable and thus the piecewise linear interpolant sl (x)
is also continuous.
1.2. Hermite Cubic Spline Interpolation: Given a set of points ∆ = {a = x0 < x1 < · · · <
xn = b} of the interval [a, b] having n + 1 number of points, we want to find a piecewise
polynomial p with p(xi ) = yi , and p0 (xi ) = zi for i = 0, . . . , n. Using the construction of basis
functions for Hermite interpolation, we define a piecewise polynomial p for i = 0, . . . , n − 1
as
p(x) = Hi (x)yi + Hi+1 (x)yi+1 + Ki (x)zi + Ki+1 (x)zi+1 , x ∈ [xi , xi+1 )
with Hi , Hi+1 , Ki , and Ki+1 defined as
H j (xi ) = δi j , H 0j (xi ) = 0, K j (xi ) = 0, K 0j (xi ) = δi j , i, j = 0, . . . , n.
Let li and li+1 be piecewise linear polynomials given by
x − xi+1 x − xi
li (x) = , li+1 (x) = .
xi − xi+1 xi+1 − xi
Then
Hi (x) = [li (x)]2 (1 − 2li0 (xi )(x − xi )), Ki (x) = [li (x)]2 (x − xi )
for i = 0, . . . , n.
1.3. Cubic Spline Interpolant. We follow the construction as in [1]. The cubic spline in-
terpolation problem is posed as follows:
Definition 1. (Cubic Spline Interpolant) Given n + 1 pairs of numbers (x0 , y0 ), · · · , (xn , yn )
with a = x0 < · · · < xn = b, a cubic spline interpolant S is a piecewise cubic function that
satisfies the following conditions:
(1) S(x) is a cubic polynomial in [x j , x j+1 ], denoted by S j (x), for each j = 0, 1, · · · , n − 1.
(2) S j (x j ) = y j and S j (x j+1 ) = y j+1 for each j = 0, 1, · · · , n − 1.
(3) S j+1 (x j+1 ) = S j (x j+1 ) for each j = 0, 1, · · · , n − 2.
(4) S0j+1 (x j+1 ) = S0j (x j+1 ) for each j = 0, 1, · · · , n − 2.
(5) S00j+1 (x j+1 ) = S00j (x j+1 ) for each j = 0, 1, · · · , n − 2.
INTERPOLATION 3

The function S(x) is called a cubic spline interpolant. We first count the number of un-
known coefficients and number of conditions in the interpolation problem:
(1) A cubic polynomial has 4 coefficients, and thus there are 4n coefficients of the cubic
polynomial (4 on each interval [xi , xi+1 ], i = 0, 1, 2, · · · , n.)
(2) There are n + 1 interpolating conditions and n − 1 continuity conditions for S, S0 and
S00 . Thus there are 3(n − 1) continuity conditions. Hence, we have a total of 4n − 2
conditions for 4n unknown coefficients.

Depending on the choice of remaining two conditions, we can construct various interpolating
cubic splines. The most popular cubic spline is the natural cubic spline, which is defined as
follows.
Definition 2. The natural cubic spline is the cubic spline interpolant satisfying the end
conditions
S00 (x0 ) = S00 (xn ) = 0.
Now we prove that the two additional conditions uniquely determine S2 .
Example 1. Construct a natural cubic spline that passess through the points (1, 2), (2, 3), and
(3, 5).
Solution: This spline consists of two cubics. The first for the interval [1, 2], denoted by
S0 (x) = a0 + b0 (x − 1) + c0 (x − 1)2 + d0 (x − 1)3 ,
and the other for [2, 3], denoted by
S1 (x) = a1 + b1 (x − 2) + c1 (x − 2)2 + d1 (x − 2)3 .
There are 8 constants to be determined, which requires 8 conditions. We have four conditions
from the fact that the splines must agree with the data at nodes. Hence
2 = f (1) = a0 , 3 = f (2) = a0 + b0 + c0 + d0 , 3 = f (2) = a1 , and
5 = f (3) = a1 + b1 + c1 + d1 .
We have two conditions from the fact that S00 (2) = S10 (2), and S000 (2) = S100 (2). They give
S00 (2) = S10 (2) : b0 + 2c0 + 3d0 = b1 , and S000 (2) = S100 (2) : 2c0 + 6d0 = 2c1 .
4 BISHNU P. LAMICHHANE

The final two conditions come from the natural boundary conditions :
S000 (1) = 0 : 2c0 = 0, and S100 (3) = 0 : 2c1 + 6d1 = 0.
Eliminating c0 , a1 and a0 , we have a linear system for {b0 , b1 , c1 , d0 , d1 }:
b0 + d0 = 3 − 2 = 1
b1 + c1 + d1 = 5 − 3 = 2
b0 + 3d0 − b1 = 0
6d0 − 2c1 = 0
2c1 + 6d1 = 0.
Solving this system of equations gives the spline
(
2 + 43 (x − 1) + 41 (x − 1)3 , for x ∈ [1, 2]
S(x) =
3 + 23 (x − 2) + 43 (x − 2)2 − 14 (x − 2)3 , for x ∈ [2, 3].

Construction of the Natural Cubic Spline. We know that we have to determine 4n coeffi-
cients to define the cubic spline interpolant. We now apply the conditions in the definition to
compute the cubic polynomial S j (x) for each j = 0, 1, · · · , n − 1:
S j (x) = y j + b j (x − x j ) + c j (x − x j )2 + d j (x − x j )3
so that condition (1) and (2) are applied once. We now apply condition (3) to obtain
y j+1 = S j+1 (x j+1 ) = y j + b j (x j+1 − x j ) + c j (x j+1 − x j )2 + d j (x j+1 − x j )3
for each j = 0, 1, · · · , n − 2. Let h j = x j+1 − x j for j = 0, 1, · · · , n − 1. Then
y j+1 = y j + b j h j + c j h2j + d j h3j
for each j = 0, 1, · · · , n − 1. The case j = n − 1 is included as yn = Sn−1 (xn ) = yn−1 +
bn−1 hn−1 + cn−1 h2n−1 + dn−1 h3n−1 .
Similarly, differentiating S j (x) with respect to x, we have
S0j (x) = b j + 2c j (x − x j ) + 3d j (x − x j )2
which implies that S0j (x j ) = b j for each j = 0, 1, · · · , n − 1. Now defining bn = S0 (xn ) =
 
Sn−1 (xn ), we apply condition (4) S0j+1 (x j+1 ) = S0j (x j+1 ) to get

b j+1 = b j + 2c j h j + 3d j h2j
for each j = 0, 1, · · · , n − 1.
We want to find another relationship between  the coefficients of S j by defining cn =
S (xn )/2 and applying the condition (5) S j+1 (x j+1 ) = S00j (x j+1 ) . Then, for each j =
00 00

0, 1, · · · , n − 1
c j+1 − c j
c j+1 = c j + 3d j h j or d j = .
3h j
Using the value of d j in the expression for y j+1 and b j+1 yields
h2j
(1) y j+1 = y j + b j h j + (2c j + c j+1 ) and b j+1 = b j + h j (c j + c j+1 ).
3
INTERPOLATION 5

Here the first equation of (1) can be solved for b j to get


y j+1 − y j h j y j − y j−1 h j−1
bj = − (2c j + c j+1 ) and b j−1 = − (2c j−1 + c j ).
hj 3 h j−1 3
Reducing the index of the second equation of (1) by 1, we get

b j = b j−1 + h j−1 (c j−1 + c j ).

Using these values of b j and b j−1 in this equation, we obtain


y j+1 − y j h j y j − y j−1 h j−1
− (2c j + c j+1 ) = − (2c j−1 + c j ) + h j−1 (c j−1 + c j ).
hj 3 h j−1 3
Rearranging and multiplying by 3, we have
y j+1 − y j y j − y j−1
h j (2c j + c j+1 ) − h j−1 (2c j−1 + c j ) + 3h j−1 (c j−1 + c j ) = 3 −3 .
hj h j−1
We can simplify this to get
y j+1 − y j y j − y j−1
(2) h j−1 c j−1 + 2(h j−1 + h j )c j + h j c j+1 = 3 −3 ,
hj h j−1

for each j = 0, 1, · · · , n − 1 This system has {c j }nj=0 unknowns. Since the values {x j }nj=0 and
{y j }nj=0 are given, once we find the coefficients {c j }nj=0 , we can obtain {b j }nj=0 and {d j }nj=0
from the equations
y j+1 − y j h j c j+1 − c j
bj = − (2c j + c j+1 ) and dj = .
hj 3 3h j

Thus we can construct the cubic polynomials {S j (x)}nj=0 . To show that the piecewise cubic
polynomial is unique, we need the following definition.

Definition 3. A matrix A ∈ Rn×n is said to be diagonally dominant if

|aii | ≥ ∑ |ai j |, i = 1, 2, · · · , n.
j=1
j6=i

A is said to be strictly diagonally dominant if strict inequality holds for each i.

Theorem 1. A strictly diagonally dominant matrix A is non-singular.

Theorem 2. Let f be defined at each point of the set ∆ = {a = x0 < x1 < · · · < xn = b} of
[a, b] with yi = f (xi ), 0 ≤ i ≤ n. Then f has a unique natural cubic spline interpolant on the
set ∆; that is, a spline interpolant that satisfies the natural boundary conditions S00 (x0 ) = 0
and S00 (xn ) = 0.

Proof. The boundary conditions imply that

cn = S00 (xn )/2 = 0 and S00 (x0 ) = 2c0 + 6d0 (x0 − x0 ) = 0.


6 BISHNU P. LAMICHHANE

Thus c0 = cn = 0. The two equations c0 = cn = 0 together with the equations in (2) can be
written as a linear system Ac = f, where A is n + 1 × n + 1 matrix
 
1 0 0 0 ··· 0 0 0
h0 2(h0 + h1 )
 h1 0 ··· 0 0 0 
0 h1 2(h1 + h2 ) h2 · · · 0 0 0 
A =  .. ,
 
.. .. .. . .
.
 . . . . 0 0 0 
0 0 0 0 · · · hn−2 2(hn−2 + hn−1 ) hn−1 
0 0 0 0 ··· 0 0 1
and f and c are two vectors with
   
0 c0
3 3

 (y
h1 2 − y 1 ) − h0 (y1 − y0 )



 c1


f= .. c= ..
and .
   
.  .
3 3
   
hn−1 (yn − yn−1 ) − hn−2 (yn−1 − yn−2 )
  cn−1 
0 cn
Since the matrix A is strictly diagonal dominant, the matrix A is non-singular and hence the
linear system Ac = f has a unique solution. 
Example 2. Piecewise Cubic Hermite Interpolating Polynomial: Assume that no derivatives
are provided at the nodes, but only function values. A piecewise cubic polynomial can be
constructed also in this case assigning some suitable derivatives of the function at the nodes.
The derivatives are assigned in such a way that the resulting piecewise curve is continu-
ously differentiable. One such example can be found in [2] and is used in piecewise cubic
interpolation of M ATLAB. The derivatives zi are assigned in such a way that the function
is continuously differentiable and function values do not locally overshoot the data values
resulting in a shape-preserving, “visually pleasing” interpolant. Let di be defined as
yi+1 − yi
di = , i = 0, . . . , n − 1.
xi+1 − xi
For an inner point xi , if di and di−1 are of opposite signs or if either of them is zero, xi is
the local extremum. Thus zi is set to be zero. If di and di−1 have the same sign and the two
intervals (xi−1 , xi ) and (xi , xi+1 ) have the same length, then zi is taken to be the harmonic
mean of the two discrete slopes:
 
1 1 1 1
= + .
zi 2 di−1 di
That means at the support node xi , the reciprocal slope of the Hermite interpolant is the
average of the reciprocal slopes of the piecewise linear interpolant on either side.
If di and di−1 have the same sign, but the two intervals have different lengths, then zi is set
to be a weighted harmonic mean of the two discrete slopes
 
1 1 w1 w2
= +
zi w1 + w2 di−1 di
with w1 = 2hi + hi−1 and w2 = hi + 2hi−1 , hi = xi+1 − xi . Further modification is necessary at
the end points, see [2] for more detail.
INTERPOLATION 7

R EFERENCES
[1] R.L. Burden and J.D. Faires. Numerical Analysis. Brooks and Cole, eighth edition, 2005.
[2] F.N. Fritsch and R.E. Carlson. Monotone piecewise cubic interpolation. SIAM Journal on Numerical Analy-
sis, 17:238–246, 1980.

You might also like