piecewise - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Mathematics : Mathematical Functions : piecewise

piecewise

piecewise-continuous functions

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

piecewise(cond_1, f_1, cond_2, f_2, ..., cond_n, f_n, f_otherwise)

Parameters

f_i

-

expression

cond_i

-

relation or boolean combination of inequalities

f_otherwise

-

(optional) default expression

Description

• 

With the piecewise function it is possible to express piecewise-continuous functions.  The semantics are as in a case statement: if cond_1 is true then f_1, else if cond_2 is true then f_2, and so on. f_otherwise gives a default case which corresponds to all conditions being false.  The default for f_otherwise is 0.

• 

A condition can be a single equality or inequality, or a boolean combination of inequalities, such as x<3 or 0<xπ. Equalities cannot be used in a boolean expression. The conditions can contain relations with polynomials, abs, signum, or piecewise functions, such as 0<x24and0<x or x<4.  In all cases, x is assumed to be a real variable.

• 

The piecewise function can be differentiated, integrated, simplified, plotted, and used in the following types of differential equations:  constant coefficients and discontinuous perturbation function, general first-order linear, Riccati, and some other classes which are handled by integration or variation of parameter.  See dsolve[piecewise] for more details. series, limit, abs, and signum can handle the piecewise function.

• 

If parameters are involved in the conditions, the system requires useful assumptions in order to perform computations.  For example, piecewise(a*x<1,f(x)) cannot be manipulated unless Maple can determine whether a is positive or negative using the assume system. See "What Assumptions" in the context-sensitive menu.

• 

There exist convert procedures to convert a piecewise function to an expression containing the Heaviside function and vice versa. A piecewise function can also be converted to a list representation, called pwlist. Expressions containing abs or signum can be converted to piecewise functions.

• 

To enter a piecewise function in 2-D Math notation, you can use either the palettes or command completion. To add an additional line to this piecewise function, press Ctrl + Shift + R. See 2-D Math Shortcut Keys and Hints for more information.

Examples

piecewise0<x&comma;x

&lcub;x0<x0otherwise

(1)

eq1piecewise4<x2andx<8&comma;fx

eq1:=&lcub;fx4<x2andx<80otherwise

(2)

simplifyeq1

&lcub;fxx<20x2fxx<808x

(3)

Piecewise functions can have parameters in the conditions.

assumea<b&comma;b<c

eq2piecewisea<xandx<b&comma;1&comma;b<xandx<c&comma;2

eq2:=&lcub;1a~<xandx<b~2b~<xandx<c~

(4)

converteq2&comma;piecewise&comma;x

&lcub;0xa~1x<b~0x&equals;b~2x<c~0c~x

(5)

assumed<0&colon;

eq3piecewise0<xd2&comma;1&comma;2

eq3:=&lcub;10<d~x22otherwise

(6)

converteq3&comma;piecewise&comma;x

&lcub;1x<2d~22d~x

(7)

Note that logical operators, involved in the piecewise conditions, are evaluated according to the same rules as used by the evalb command

piecewisex&equals;0orx&equals;1&comma;a&comma;b

b~

(8)

piecewisex0and0<y&comma;a&comma;b

&lcub;a~0<yb~otherwise

(9)

piecewisen::integerand3<n&comma;n2&comma;n3

n3

(10)

x&equals;0orx&equals;1

false

(11)

x0and0<y

0<y

(12)

n::integerand3<n

false

(13)

As an alternative, use the inert functions And, Or, and Not to construct boolean expressions involving multiple conditions

fpiecewiseOrx&equals;0&comma;x&equals;1&comma;a&comma;b

f:=&lcub;a~Orx&equals;0&comma;x&equals;1b~otherwise

(14)

fassuming0<x

&lcub;a~x&equals;1b~otherwise

(15)

gpiecewiseAndx0&comma;0<y&comma;a&comma;b

g:=&lcub;a~Andx0&comma;0<yb~otherwise

(16)

gassuming0<y

&lcub;a~x0b~otherwise

(17)

hpiecewiseAndn::integer&comma;3<n&comma;n2&comma;n3

h:=&lcub;n2Andn::integer&comma;3<nn3otherwise

(18)

hassuming3<n

&lcub;n2n::integern3otherwise

(19)

Piecewise functions can be simplified

ppiecewisex<0&comma;x&comma;0<x&comma;x

p:=&lcub;xx<0x0<x

(20)

eq4p2&plus;5

eq4:=&lcub;xx<0x0<x2&plus;5

(21)

simplifyeq4

x2&plus;5

(22)

lpiecewisex<0&comma;x2&comma;0<x&comma;x

l:=&lcub;x2x<0x0<x

(23)

eq5l2&plus;5

eq5:=&lcub;x2x<0x0<x2&plus;5

(24)

simplifyeq5

&lcub;x4&plus;5x0x2&plus;50<x

(25)

However, if a piecewise function contains parameters, it cannot be simplified directly.

mpiecewisex<a&comma;x&comma;b<x&comma;x2

m:=&lcub;xx<a~x2b~<x

(26)

eq6simplifym2

eq6:=&lcub;xx<a~x2b~<x2

(27)

converteq6&comma;piecewise&comma;x

&lcub;x2x<a~0xb~x4b~<x

(28)

Other operations involving piecewise functions.

kx&rarr;piecewisex<0&comma;1&comma;x<1&comma;0&comma;1

k:=x&rarr;piecewisex<0&comma;1&comma;x<1&comma;0&comma;1

(29)

k12

0

(30)

jpiecewisex<0&comma;x2&comma;0<x&comma;x2

j:=&lcub;x2x<0x20<x

(31)

xj

&lcub;2xx02x0<x

(32)

&int;j&DifferentialD;x

&lcub;13x3x013x30<x

(33)

jx&equals;2|jx&equals;2

4

(34)

jx&equals;2|jx&equals;2

4

(35)

See Also

combine/piecewise

convert/Heaviside

convert/piecewise

convert/pwlist

dsolve/piecewise

evalb

Heaviside

simplify/piecewise

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam