The piecewise function has a straightforward syntax. Every piece is specified by a Boolean condition followed by an expression. The next several Maple command lines make use of the following piecewise function:
>
|
|
| (1.1) |
This can be evaluated at arbitrary points. For example,
>
|
|
| (1.2) |
>
|
|
| (1.3) |
Because of the division by zero, points such as x = 1 cannot be substituted. However, can be determined.
>
|
|
| (1.4) |
Such functions can be plotted to determine their behavior.
>
|
|
Besides evaluating limits, you can do operations such as computing derivatives, integrating, and solving differential equations with piecewise functions. Examples of solving DEs will be illustrated later. Using the same function, f(x), find its piecewise derivative.
>
|
|
| (1.5) |
Integrating this function gives:
>
|
|
| (1.6) |
Evaluate the integral with values for the lower and upper bounds.
>
|
|
| (1.7) |
where Si(x) is the Sine integral function.
Note: This works because discont is able to determine the potential discontinuities of piecewise functions. For example,
>
|
|
| (1.8) |
Consider a new function, g(x).
>
|
|
| (1.9) |
The piecewise function allows for common manipulations, such as simplifications. The addition of the selector 'piecewise' indicates to simplify that it should only do simplifications as they apply to piecewise functions. This is more efficient, in general.
>
|
|
| (1.10) |
Piecewise functions can be converted to a number of other functions and distributions.
>
|
|
| (1.11) |
Distributions can be converted back to piecewise functions.
>
|
|
| (1.12) |
The function piecewise lets us work with the CurveFitting[Spline] command. For example,
>
|
|
| (1.13) |
This spline can be graphed.
>
|
|
But now we can also integrate it.
>
|
|
>
|
|
| (1.14) |
Other piecewise functions can also be converted to piecewise and be properly manipulated. For example,
>
|
|
| (1.15) |
Another example of conversion, in this case with signum and abs.
>
|
|
| (1.16) |
Note: The discontinuity at 0 in the above function.
Another simple example:
>
|
|
| (1.17) |
It turns out to be a well-behaved, non-piecewise function.
We can also determine the differentiability class of a piecewise continuous function. For example, in the case of our previous spline function, newcubic, we have
>
|
|
>
|
|
| (1.18) |
This must be true for splines! However, when we check to see if it is , we obtain
>
|
|
| (1.19) |
To determine the highest order of continuity and the problem points, enter:
>
|
|
| (1.20) |