 Piecewise Functions - Maple Programming Help

Home : Support : Online Help : Math Apps : Functions and Relations : Basic Functions and Relations : MathApps/PiecewiseFunction

Piecewise Functions

Main Concept

A function whose formula is different on different parts of its domain is called a piecewise function. Such a function is commonly (but not necessarily) written using a case structure:

$f\left(x\right)=\left\{\begin{array}{cc}{f}_{1}\left(x\right)& {\mathrm{condition}}_{1}\\ {f}_{2}\left(x\right)& {\mathrm{condition}}_{2}\\ {f}_{3}\left(x\right)& {\mathrm{condition}}_{3}\\ ...& ...\end{array}\right\$

The conditions should be mutually exclusive. That is, at any given value of $x$ at most one of the conditions can be true. The value of the function is then the value of the subformula corresponding to the true condition.

Examples

 $g\left(x\right)=\left\{\begin{array}{cc}-1-x& x<-2\\ \mathrm{sin}\left(x\right)& -2\le x<1\\ \frac{1}{{x}^{2}}& 1\le x\end{array}\right\$

Splines

A spline was originally a long flexible rod used to draw smooth curves for shipbuilding and woodworking. The rod would be bent and clamped along a series of fixed pegs to give it a particular shape. Eventually this technique was noticed by mathematicians, who gave a more formal definition to a spline. A mathematical spline is a piecewise function which uses polynomials of the same degree to connect a set of points (the "pegs" of old) to create a smooth curve. Splines can be a more effective way of interpolating a curve from a set of fixed points than a polynomial because their extrema tend to have smaller magnitudesthey don't "wobble" very much.

In the plot windows below, create graphs points by clicking or dragging in either plot window. The same points are shown in both graphs. The graph on the left will interpolate a polynomial function in the lowest degree possible, whereas the graph on the right will interpolate a cubic spline (all of the polynomials in the piecewise function will be of degree three).

What do you notice is different about the two? What's the same? 