Spline Toolbox | ![]() ![]() |
The ppform
A univariate piecewise polynomial f is specified by its break sequence breaks
and the coefficient array coefs
of the local power form (see (*) below) of its polynomial pieces; -- see the section on Tensor Product Splines for a discussion of multivariate piecewise-polynomials. The coefficients may be d
-vectors, usually 2-vectors or 3-vectors, in which case f is a curve in 2-space or 3-space. To comply with the standard treatment of vectors in this toolbox, any coefficient and any value of a spline curve is always written as a 1-column matrix. For simplicity, the present discussion deals only with the case when the coefficients are scalars.
The break sequence is assumed to be strictly increasing,
breaks(1) < breaks(2) < ... < breaks(l+1)
with 1
the number of polynomial pieces that make up f.
While these polynomials may be of varying degrees, they are all recorded as polynomials of the same order k
, i.e., the coefficient array coefs
is of size [l,k]
, with coefs(j,:)
containing the k
coefficients in the local power form for the j-
th polynomial piece, from the highest to the lowest power; see (*) below.
The items breaks
, coefs
, 1
, and k
, make up the ppform of f, along with the dimension d
of its coefficients; usually d
equals 1. The basic interval of this form is the interval [breaks(1)
.. breaks(l
+1)
]. It is the default interval over which a function in ppform is plotted by the plot command fnplt
.
In these terms, the precise description of the piecewise-polynomial f is
(*
) f(t)= polyval(coefs(j,:),
t- breaks(j))
Here, polyval
(a
,x
) is the MATLAB function; it returns the number
This defines f(t) only for t in the half-open interval [breaks(1)
..breaks(l+1))
. For any other t, f(t) is defined by
i.e., by extending the first, respectively last, polynomial piece.
A piecewise-polynomial is usually constructed by some command, through a process of interpolation or approximation, or conversion from some other form e.g., from the B-form, and is output as a variable. But it is also possible to make one up from scratch, using the statement
pp=ppmak(breaks,coefs)
For example, we might say pp=ppmak(
-5:
-1,
-22:
-11)
, or, more explicitly,
breaks = -5:-1; coefs = -22:-11; pp = ppmak(breaks,coefs);
thus supplying the uniform break sequence -5:
-1
and the coefficient sequence -22:
-11
. Since this break sequence has 5 entries, hence 4 break intervals, while the coefficient sequence has 12 entries, we have, in effect, specified a piecewise-polynomial of order
3 (= 12/4). The command
fnbrk(pp)
prints out all the constituent parts of this piecewise-polynomial, as follows:
breaks(1:l+1) -5 -4 -3 -2 -1 coefficients(d*l,k) -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 pieces number l 4 order k 3 dimension d of target 1
Further, fnbrk
can be used to supply each of these parts separately. But the point of the Spline Toolbox is that you usually need not concern yourself with these details. You simply use pp
as an argument to commands that evaluate, differentiate, integrate, convert or plot the piecewise-polynomial whose description is contained in pp
.
Here are some operations you can perform on a piecewise-polynomial.
Inserting additional breaks comes in handy when one wants to add two piecewise-polynomials with different breaks, as is done in the command fncmb
.
To illustrate the use of some of these commands, here is a plot of the particular piecewise-polynomial we just made up. First, the basic plot:
x = linspace(-5.5,-.5,101); plot(x, fnval(pp,x),'x')
Then add to the plot the breaklines:
breaks=fnbrk(pp,'
b'
); yy=axis; hold on for j=1:fnbrk(pp,'
l'
)+1 plot(breaks([j j]),yy(3:4)) end
Finally, superimpose on that plot the plot of the polynomial that supplies the third polynomial piece:
plot(x,fnval(fnbrk(pp,3),x),'linew',1.3) set(gca,'
ylim'
,[-60 -10]), hold off
Figure 1-8: A Piecewise-Polynomial Function, Its Breaks, and the Polynomial Giving Its Third Piece
Figure 1-8 is the final picture. It shows the piecewise-polynomial as a sequence of points and, solidly on top of it, the polynomial from which its third polynomial piece is taken. It is quite noticeable that the value of a piecewise-polynomial at a break is its limit from the right, and that the value of the piecewise-polynomial outside its basic interval is obtained by extending its leftmost, respectively its rightmost, polynomial piece.
While the ppform of a piecewise-polynomial is efficient for evaluation, the construction of a piecewise-polynomial from some data is usually more efficiently handled by determining first its B-form, i.e., its representation as a linear combination of B-splines.
![]() | Splines: An Overview | The B-form | ![]() |