This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)


Piecewise[{{val1, cond1}, {val2, cond2}, ...}]
represents a piecewise function with values vali in the regions defined by the conditions condi.
Piecewise[{{val1, cond1}, ...}, val]
uses default value val if none of the condi apply. The default for val is 0.
  • The condi are typically inequalities such as a≤x<b.
  • The condi are evaluated in turn, until one of them is found to yield True.
  • If all preceding condi yield False, then the vali corresponding to the first condi that yields True is returned as the value of the piecewise function.
  • If any of the preceding condi do not literally yield False, the Piecewise function is returned in symbolic form.
  • Only those vali explicitly included in the returned form are evaluated.
  • Elements of the form {vali, False} are dropped, as are all elements after the first {vali, True}.
  • Piecewise[{{v1, c1}, {v2, c2}, ...}] can be input in the form . The piecewise operator can be entered as Esc pw Esc or \[Piecewise]. The grid of values and conditions can be constructed by first entering Ctrl+Comma, then using Ctrl+Enter and Ctrl+Comma.
Set up a piecewise function with different pieces below and above zero:
Click for copyable input
Find the derivative of a piecewise function:
Click for copyable input
Use Esc pw Esc to enter and Control+Comma and then
Control+DynamicBox[ToBoxes[If[$OperatingSystem === MacOSX, Return, Enter], StandardForm], ImageSizeCache -> {38., {1., 8.}}]
for each additional piecewise case:
Click for copyable input
New in 5.1