To define a function defined by different expressions in different
parts of its domain, Maple supplies what is known as an if ...
then ...else control structure. The syntax for this structure is
if condition then
action if condition is true
action if condition is false
This structure can be all on one line or on several lines; it doesn't matter. We can use this structure to define the function
with the following command.
> f:= x -> if x>=0 then x+3 else 3-x fi ;
For defining compound functions involving more than two expressions, Maple has a more complicated control structure, if ...then ...else if ... . For more information, see the section on Maple and Compound Functions.