Lecture 16: Piecewise Interpolation
1.Splines
Instead of adopting basis functions defined over the entire sampling
interval as exemplified by the monomial or Lagrange
bases, approximations of
can be constructed with different branches over each subinterval, by
introducing , and the
approximation
The interpolation conditions
lead to constraints
The form of can be freely chosen, and though most
often is a low-degree polynomial, the spline
functions may have any convenient form, e.g., trigonometric or arcs of
circle. The accuracy of the approximant is determined by the
choice of form of , and by the sample points. It is
useful to introduce a quantitative measure of the sampling through the
following definitions.
Definition. is a partition of the
interval if ,
,
satisfy
Definition. The norm of partition of the interval
is
Constant splines (degree 0).
A simple example is given by the constant functions .
Arbitrary accuracy of the approximation can be achieved in the limit
of ,
.
Over each subinterval the polynomial error formula gives
so overall
which becomes
for equidistant partitions ,
. The interpolant
converges to linearly (order of convergence is 1)
Linear splines (degree 1).
A piecewise linear interpolant is obtained by
The interpolation error is bounded by
for an equidistant partition, exhibiting quadratic convergence.
Quadratic splines (degree 2).
A piecewise quadratic interpolant is formulated as
The interpolation conditions are met since .
The additional parameters of this higher order spline interpolant can be
determined by enforcing additional conditions, typically continuity of
function and derivative at the boundary between two subintervals
An additional condition is required to close the system, for example
(known end slope), or
(zero end slope), or (constant end-slope). The coefficients
are conveniently determined by observing that is linear
over interval of length ,
and is given by
with ,
the slope of the interpolant at
The continuity of first derivative conditions
are satisfied, and integration gives
The interpolation condition ,
determines the constant of integration
Imposing the continuity of function condition
gives
or
a bidiagonal system for the slopes that is solved by backward
substituion in operations. For ,
the value arising
in the system has to be given by an end condition, and the overall
system
is defined by
The interpolation error is bounded by
for an equidistant partition, exhibiting quadratic convergence.
Cubic splines (degree 3).
The approach outlined above can be extended to cubic splines, of
special interest since continuity of curvature is achieved at the
nodes, a desirable feature in many applications. The second derivative
is linear
with ,
the curvature at the endpoints of the subinterval. Double integration gives
The interpolation conditions ,
,
gives the integration constants
and continuity of first derivative, ,
subsequently leads to a tridiagonal system for the curvatures
End conditions are required to close the system. Common choices include:
-
Zero end-curvature, also known as the natural end conditions: .
-
Curvature extrapolation: ,
-
Analytical end conditions given by the function curvature: ,
.
2.-splines
The above analytical approach becomes increasingly unwieldy for higher
degree piecewise polynomials. An alternative approach is to
systematically generate basis sets of desired polynomial degree over
each subinterval. The starting point in this basis-spline ()
approach is the piecewise constant functions
leading to the interpolant
|
(1) |
of ,
as sampled by data set , .
The set
constitutes a basis for all piecewise constant approximants of real
functions on the interval . Higher degree basis sets ,
, are
defined recursively through
with the weight function
 |
|
Figure 1. -spline
sets
with
|
In[3]:= |
B[j_, 0, t_] := If[j <= t < j + 1, 1, 0];
B[j_, k_, t_] := B[j, k, t] =
(t-j)/k B[j,k-1,t] + (1-(t-j-1)/k) B[j+1,k-1,t];
bases=Table[B[j,k,t],{j,0,5},{k,0,4}]; bases[[3,1]] |
In[5]:= |
plots=Plot[bases,{t,0,10},PlotRange->All];
Export[HomeDirectory[] <> "/courses/MATH661/images/Bsplines.eps", plots] |
As the degree increases, the support of
increases to
the interval . This is the -spline
analog of the additional end conditions in traditional spline
formulations, and leads to the set
defining a basis for splines of degree
only on a subinterval within . Consider the piecewise linear case , (Fig. 2). The set
forms a basis for piecewise linear functions if over each subinterval
an arbitrary linear function can be
expressed as a linear combination
Over only are not
identically zero, hence
For the end interval , a definition of would be
required,
not available within the chosen data
set. At the other end interval ,
invokes
which requires , again not
available within the chosen data set. One can either include samples
outside the interval or restrict the spline domain of
definition. Again, this is analogous with the treatment of end
conditions in traditional splines:
-
Sampling outside of the range seeks additional information on the
function being interpolated , as for
instance imposed by the condition in
traditional splines;
-
Restricting the definition domain corresponds to inferring
information on the behavior of in the
end intervals as in the condition
in traditional splines.
Denote by
the set of splines , that are
piecewise polynomials of degree on the
partition of . The ,
piecewise constant interpolant (1) is specified by coefficients,
the components of ,
hence
i.e., the dimension of the space of piecewise-constant splines is equal
to the number of sample points. As the degree
increases, additional end conditions are required to specify a spline
interpolation and
requiring a basis set
 |
|
Figure 2. -spline
set
for
|
In[8]:= |
plots=Plot[bases[[;;,2]],{t,0,10},PlotRange->All,GridLines->Automatic];
Export[HomeDirectory[] <> "/courses/MATH661/images/B1splines.eps", plots] |
Algorithm B-spline evaluation (inefficient, does not
account for known zero values of )
Input: ,
if
then end
if
then end
∴ |
function Bspline(t,x,K)
np1=length(x); n=np1-1; m=length(t);B=zeros(m,np1)
for i=1:m
for j=1:n
if (x[j]<=t[i]<x[j+1]) B[i,j]=1.0; end
end
if (t[i]≈x[np1]) B[i,np1]=1.0; end
end
for k=1:K
for j=1:n-k
w0 = (t .- x[j])/(x[j+k]-x[j])
w1 = 1 .- (t .- x[j+1])/(x[j+1+k]-x[j+1])
B[:,j] = w0 .* B[:,j] + w1 .* B[:,j+1]
end
end
return B
end; |
∴ |
n=10; k=0; x=collect(0:n); h=0.1; t=collect(0:h:n); B=Bspline(t,x,k); clf(); for j=1:n-k plot(t,B[:,j],"o"); end; grid("on") |
∴ |
n=10; k=1; x=collect(-k:n+k); t=collect(0:h:n); B=Bspline(t,x,k); clf(); for j=1:n+k plot(t,B[:,j]); end; grid("on") |
∴ |
n=10; k=2; x=collect(-k:n+k); t=collect(0:h:n); B=Bspline(t,x,k); clf(); for j=1:n+k plot(t,B[:,j]); end; grid("on") |
∴ |
n=10; k=3; x=collect(-k:n+k); t=collect(0:h:n); B=Bspline(t,x,k); clf(); for j=1:n+k plot(t,B[:,j]); end; grid("on") |
∴ |
n=10; k=3; x=collect(-k:n+k); t=collect(-k:h:n+k); B=Bspline(t,x,k); clf(); for j=1:n+k plot(t,B[:,j]); end; grid("on") |
∴ |
n=10; k=2; x=collect(-k:n+k); t=collect(-k:h:n+k); B=Bspline(t,x,k); clf(); for j=1:n+k plot(t,B[:,j]); end; grid("on") |
∴ |
n=10; k=4; x=collect(-k:n+k); t=collect(0:h:n); B=Bspline(t,x,k); clf(); for j=1:n+k plot(t,B[:,j]); end; grid("on") |
∴ |
n=10; k=5; x=collect(-k:n+k); t=collect(0:h:n); B=Bspline(t,x,k); clf(); for j=1:n+k plot(t,B[:,j]); end; grid("on") |
∴ |
n=10; k=6; x=collect(-k:n+k); t=collect(0:h:n); B=Bspline(t,x,k); clf(); for j=1:n+k plot(t,B[:,j]); end; grid("on") |
∴ |
n=10; k=7; x=collect(-k:n+k); t=collect(0:h:n); B=Bspline(t,x,k); clf(); for j=1:n+k plot(t,B[:,j]); end; grid("on") |
A -spline interpolant of degree is given by a linear combination of the basis
set
The interpolation conditions
lead to an underdetermined linear system for
analogous to the degrees of freedom in
specification of end conditions for .
∴ |
n=5; k=0; x=-k:n; t=0:n; B=Bspline(t,x,k) |
|
(2) |
∴ |
n=5; k=1; x=-k:n; t=0:n; B=Bspline(t,x,k) |
|
(3) |
∴ |
n=5; k=2; x=-k:n; t=0:n; B=Bspline(t,x,k) |
|
(4) |
∴ |
n=5; k=3; x=-k:n; t=0:n; B=round.(10000*Bspline(t,x,k))/10000 |
|
(5) |