piecewise - Maple Help

convert/piecewise

convert to a piecewise function

 Calling Sequence convert( expr, piecewise ) convert( expr, piecewise, var)

Parameters

 expr - expression piecewise - literal name var - name representing the main variable

Description

 • Converts an expression containing Heaviside, abs, signum, or if to a piecewise function. If the expression has the form $\mathrm{if}\left(...\right)$, the $\mathrm{if}$ must be replaced by If to avoid evaluation. If the expression contains more than one name, the argument var specifies the variable with respect to which the function is piecewise.
 • convert/piecewise can be used to compute the normal form of an expression involving piecewise, Heaviside, abs, signum, min, or max with respect to the variable var.
 • When converting Heaviside to piecewise you can perform the conversion taking Heaviside(0) = 1. For that purpose set the Environment Variable _EnvUseHeavisideAsUnitStep to true; see the last example.

Examples

 > $\mathrm{convert}\left(x\mathrm{Heaviside}\left(x\right),\mathrm{piecewise},x\right)$
 $\left\{\begin{array}{cc}{0}& {x}{<}{0}\\ {\mathrm{undefined}}& {x}{=}{0}\\ {x}& {0}{<}{x}\end{array}\right\$ (1)
 > $\mathrm{convert}\left(x\mathrm{Heaviside}\left(x\right),\mathrm{piecewise},x\right)$
 $\left\{\begin{array}{cc}{0}& {x}{<}{0}\\ {\mathrm{undefined}}& {x}{=}{0}\\ {x}& {0}{<}{x}\end{array}\right\$ (2)
 > $\mathrm{convert}\left(\mathrm{Heaviside}\left(x\right)+x\mathrm{Heaviside}\left(x-1\right),\mathrm{piecewise},x\right)$
 $\left\{\begin{array}{cc}{0}& {x}{<}{0}\\ {\mathrm{undefined}}& {x}{=}{0}\\ {1}& {x}{<}{1}\\ {\mathrm{undefined}}& {x}{=}{1}\\ {1}{+}{x}& {1}{<}{x}\end{array}\right\$ (3)
 > $\mathrm{convert}\left(\mathrm{abs}\left(1-\mathrm{abs}\left(x\right)\right),\mathrm{piecewise}\right)$
 $\left\{\begin{array}{cc}{-}{1}{-}{x}& {x}{\le }{-1}\\ {1}{+}{x}& {x}{<}{0}\\ {1}{-}{x}& {x}{<}{1}\\ {x}{-}{1}& {1}{\le }{x}\end{array}\right\$ (4)
 > $\mathrm{convert}\left(\mathrm{signum}\left(x\right),\mathrm{piecewise}\right)$
 $\left\{\begin{array}{cc}{-1}& {x}{<}{0}\\ {0}& {x}{=}{0}\\ {1}& {0}{<}{x}\end{array}\right\$ (5)

Converting signum taking its value at zero from its _Environment variable

 > $\mathrm{_Envsignum0}≔12$
 ${\mathrm{_Envsignum0}}{≔}{12}$ (6)
 > $\mathrm{convert}\left(\mathrm{signum}\left(x\right),\mathrm{piecewise}\right)$
 $\left\{\begin{array}{cc}{-1}& {x}{<}{0}\\ {12}& {x}{=}{0}\\ {1}& {0}{<}{x}\end{array}\right\$ (7)
 > $\mathrm{convert}\left(\mathrm{If}\left(x<1,xx,x<2,2x+2,x<3,3+x\right),\mathrm{piecewise}\right)$
 $\left\{\begin{array}{cc}{{x}}^{{2}}& {x}{<}{1}\\ {2}{}{x}{+}{2}& {x}{<}{2}\\ {3}{+}{x}& {x}{<}{3}\\ {0}& {3}{\le }{x}\end{array}\right\$ (8)

Converting Heaviside(x) taking Heaviside(0) = 1

 > $\mathrm{_EnvUseHeavisideAsUnitStep}≔\mathrm{true}$
 ${\mathrm{_EnvUseHeavisideAsUnitStep}}{≔}{\mathrm{true}}$ (9)
 > $\mathrm{convert}\left(\mathrm{Heaviside}\left(x\right),\mathrm{piecewise}\right)$
 $\left\{\begin{array}{cc}{0}& {x}{<}{0}\\ {1}& {0}{\le }{x}\end{array}\right\$ (10)