Lecture 16: Piecewise Interpolation

1.Splines

Instead of adopting basis functions defined over the entire sampling interval [x0,xn] as exemplified by the monomial or Lagrange bases, approximations of f: can be constructed with different branches over each subinterval, by introducing Si:[xi-1,xi], and the approximation

p(t)={ S1(t) x0t<x1 S2(t) x1t<x2 Sn(t) xn-1t<xn Sn+1(t) t=xn ..

The interpolation conditions p(xi)=yi lead to constraints

Si(xi-1)=yi-1.

The form of S(t) can be freely chosen, and though most often S(t) is a low-degree polynomial, the spline functions may have any convenient form, e.g., trigonometric or arcs of circle. The accuracy of the p(t) approximant is determined by the choice of form of S(t), and by the sample points. It is useful to introduce a quantitative measure of the sampling through the following definitions.

Definition. {x0,x1,,xn} is a partition of the interval [a,b] if xi, i=0,1,,n, satisfy

a=x0<x1<<xn-1<xn=b.

Definition. The norm of partition X={x0,x1,,xn} of the interval [a,b] is

||X||=max1in|xi-xi-1|.

Constant splines (degree 0).
A simple example is given by the constant functions Si(t)=yi-1. Arbitrary accuracy of the approximation can be achieved in the limit of n, ||X||0. Over each subinterval the polynomial error formula gives

f(t)-Si(t)=f'(ξt)(t-xi-1),

so overall

|f(t)-p(t)|||f'||||X||,

which becomes

|f(t)-p(t)|||f'||h,

for equidistant partitions xi=x0+ih, h=(xn-x0)/n. The interpolant p(t) converges to f(t) linearly (order of convergence is 1)

Linear splines (degree 1).
A piecewise linear interpolant is obtained by

Si(t)=t-xi-1xi-xi-1(yi-yi-1)+yi-1.

The interpolation error is bounded by

|f(t)-p(t)|12||f'||h2,

for an equidistant partition, exhibiting quadratic convergence.

Quadratic splines (degree 2).
A piecewise quadratic interpolant is formulated as

Si(t)=bi(t-xi-1)2+ci(t-xi-1)+yi-1.

The interpolation conditions are met since Si(xi-1)=yi-1. 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

Si(xi)=bihi2+cihi=yi, i=1,2,,n Si'(xi)=2bihi+ci=2bi+1hi+1+ci+1=Si+1'(xi) i=1,2,,n-1 .

An additional condition is required to close the system, for example Sn'(xi)=yn' (known end slope), or Sn'(xi)=0 (zero end slope), or Sn'(xi)=Sn'(xi-1) (constant end-slope). The coefficients bi,ci are conveniently determined by observing that Si'(t) is linear over interval [xi-1,xi] of length hi=xi-xi-1, and is given by

Si'(t)=t-xi-1hi(si-si-1)+si-1=si-1hi(xi-t)+sihi(t-xi-1),

with si=yi', the slope of the interpolant at xi. The continuity of first derivative conditions Si'(xi)=Si+1'(xi) are satisfied, and integration gives

Si(t)=si2hi(t-xi-1)2-si-12hi(xi-t)2+Ai.

The interpolation condition Si(xi-1)=yi-1, determines the constant of integration Ai

Ai-si-1hi2=yi-1Ai=yi-1+si-1hi2,

Imposing the continuity of function condition Si(xi)=Si+1(xi) gives

sihi2+yi-1+si-1hi2=-sihi+12+yi+sihi+12,

or

si-1+si=2hi(yi-yi-1),i=1,2,,n,

a bidiagonal system for the slopes that is solved by backward substituion in 𝒪(2n) operations. For i=1, the s0 value arising in the system has to be given by an end condition, and the overall system 𝑩𝒔=𝒅 is defined by

𝑩=[ 1 1 1 1 1 1 1 ],𝒅=[ 2h1(y1-y0)-s0 2h2(y2-y1) 2hn(yn-yn-1) ],𝒔n,𝑩n×n.

The interpolation error is bounded by

|f(t)-p(t)|12||f'||h2,

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

Si''(t)=zi-1hi(xi-t)+zihi(t-xi-1),

with zi-1=Si''(xi-1), zi=Si''(xi) the curvature at the endpoints of the [xi-1,xi] subinterval. Double integration gives

Si(t)=zi-16hi(xi-t)3+zi6hi(t-xi-1)3+Ai(t-xi-1)+Bi(xi-t).

The interpolation conditions Si(xi-1)=yi-1, Si-1(xi)=yi, gives the integration constants

Ai=yihi-zihi6,Bi=yi-1hi-zi-1hi6

and continuity of first derivative, Si'(xi)=Si+1'(xi), subsequently leads to a tridiagonal system for the curvatures

hizi-1+2(hi+hi-1)zi+hi+1zi+1=6(yi+1-yi)hi+1-6(yi-yi-1)hi,i=1,2,,n-1.

End conditions are required to close the system. Common choices include:

  1. Zero end-curvature, also known as the natural end conditions: z0=zn=0.

  2. Curvature extrapolation: z0=z1, zn=zn-1

  3. Analytical end conditions given by the function curvature: z0=f''(x0), zn=f''(xn).

2.B-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 (B-spline) approach is the piecewise constant functions

Bj,0(t)={ 1 xjt<xj+1 0 otherwise .,

leading to the interpolant

f(t)p(t)=j=0nyjBj,0(t), (1)

of f:, as sampled by data set 𝒟={(xi,yi=f(xi)),i=0,1,,n}, a=x0<x1<<xn=b. The set

0(t;𝒙)={B0,0(t),B1,0(t),,Bn,0(t)}

constitutes a basis for all piecewise constant approximants of real functions on the interval [x0,xn]. Higher degree basis sets k(t;𝒙), k>0, are defined recursively through

Bj,k(t)=wj,k(t)Bj,k-1(t)+(1-wj+1,k(t))Bj+1,k-1(t),

with the weight function

wj,k(t)=t-xjxj+k-xj.

Figure 1. B-spline sets 0,1,2,3,4 with 𝒙=[ 0 1 2 3 4 5 ]

As the degree k increases, the support of Bj,k(t) increases to the interval [xj,xj+k+1]. This is the B-spline analog of the additional end conditions in traditional spline formulations, and leads to the set

k(t;𝒙)={B0,k(t),B1,k(t),,Bn,k(t)}

defining a basis for splines of degree k only on a subinterval within [x0,xn]. Consider the piecewise linear case k=1, (Fig. 2). The set 1 forms a basis for piecewise linear functions if over each subinterval [xj,xj+1] an arbitrary linear function S1(t) can be expressed as a linear combination

S1(t)=a+bt=i=0nciBi,1(t).

Over [xj,xj+1] only Bj-1,1(t),Bj(t) are not identically zero, hence

S1(t)=cj-1Bj-1,1(t)+cjBj,1(t).

For the end interval [x0,x1], a definition of B-1,1(t) would be required,

S1(t)=c-1B-1,1(t)+c0B0,1(t),

not available within the chosen 𝒙 data set. At the other end interval [xn-1,xn],

S1(t)=cn-1Bn-1,1(t)+cnBn,1(t),

invokes Bn,1 which requires Bn+1,0(t), again not available within the chosen data set. One can either include samples outside the [a,b] interval or restrict the spline domain of definition. Again, this is analogous with the treatment of end conditions in traditional splines:

  1. Sampling outside of the [a,b] range seeks additional information on the function being interpolated f, as for instance imposed by the condition S'(a)=f(a) in traditional splines;

  2. Restricting the definition domain corresponds to inferring information on the behavior of f in the end intervals as in the condition S'(x0)=S'(x1) in traditional splines.

Denote by 𝒮k(t;𝒙) the set of splines S:[x0,xn], that are piecewise polynomials of degree k on the partition 𝒙 of [x0,xn]. The k=0, piecewise constant interpolant (1) is specified by n+1 coefficients, the components of 𝒚n+1, hence

dim𝒮0(t;𝒙)=n+1,

i.e., the dimension of the space of piecewise-constant splines is equal to the number of sample points. As the degree k increases, additional end conditions are required to specify a spline interpolation and

dim𝒮k(t;𝒙)=n+1+k,

requiring a basis set

.(t;𝒙)={B-k,k(t),,B0,k(t),B1,k(t),,Bn,k(t)}.

Figure 2. B-spline set 1 for 𝒙=[ 0 1 2 3 4 5 ]

Algorithm B-spline evaluation (inefficient, does not account for known zero values of B)

Input: K,𝒕m, 𝒙k+n+1

𝑩=𝟎m×(k+n+1)

for i=1:m

for j=1:k+n

if xjti<xj+1 then B[i,j]=1 end

end

if tixk+n+1 then B[i,k+n+1]=1 end

end

for k=1:K

for j=1:k+n

w=(t-xj)/(xj+k-xj)

B[:,j]=wB[:,j]+(1-w)B[:,j+1]

end

end

return 𝑩

A B-spline interpolant of degree k is given by a linear combination of the basis set k(t;𝒙)

f(t)pk(t)=j=-knciBj,k(t).

The interpolation conditions yi=p(xi) lead to an underdetermined linear system for k>0

𝑩𝒄=𝒚,𝑩=[ B-k,k(𝒙) B0,k(𝒙) Bn,k(𝒙) ](n+1)×(k+n+1),

analogous to the k degrees of freedom in specification of end conditions for 𝒮k(𝒙).