Spline Toolbox    

Use

Here are some operations you can perform on a piecewise-polynomial.

v=fnval(pp,x)
Evaluates
dpp=fnder(pp)
Differentiates
dirpp=fndir(pp,dir)
Differentiates in the direction dir
ipp=fnint(pp)
Integrates
pj=fnbrk(pp,j)
Pulls out the jth polynomial piece
pc=fnbrk(pp,[a b])
Restricts/extends to the interval [a..b]
fnplt(pp)
Plots piecewise-polynomial on its basic interval
sp = fn2fm(pp,'B-')
Converts to B-form
pr = fnrfn(pp,morebreaks)
Inserts additional breaks

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:

Then add to the plot the breaklines:

Finally, superimpose on that plot the plot of the polynomial that supplies the third polynomial piece:

Figure 2-9: A Piecewise-Polynomial Function, Its Breaks, and the Polynomial Giving Its Third Piece

Figure 2-9 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.


  Construction The B-form