Skip to main content

Exploring Calculus with Maple Introductory Calculus

Section 9.5 Assigning Piecewise Functions

A piecewise-defined function is a function defined by multiple sub-functions. Each sub-function applies to a certain interval of the domain, called a sub-domain. We can define piecewise functions in Maple by using the piecewise() command. The sub-domain of each sub-function is specified before its expression.
> P(x) := piecewise(x <= -1, x^2, -1 < x <= 1, -x, 1 < x, x-4);
\begin{equation*} \displaystyle P\, := \,x\mapsto \begin{cases}{x}^{2}\amp x\leq -1 \\ -x\amp -1\lt x\leq 1 \\ x-4\amp 1\lt x \end{cases} \end{equation*}
> P(x);
\begin{equation*} \displaystyle \begin{cases}{x}^{2}\amp x\leq -1 \\ -x\amp -1 \lt x\leq 1 \\ x-4\amp 1\lt x \end{cases} \end{equation*}