Wolfram Language & System 10.4 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)


represents a piecewise function with values in the regions defined by the conditions .

uses default value val if none of the apply. The default for val is .


  • The are typically inequalities such as .
  • The are evaluated in turn, until one of them is found to yield True.
  • If all preceding yield False, then the corresponding to the first that yields True is returned as the value of the piecewise function.
  • If any of the preceding do not literally yield False, the Piecewise function is returned in symbolic form.
  • Only those 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[conds] automatically evaluates to Piecewise[conds,0].
  • Piecewise can be used in such functions as Integrate, Minimize, Reduce, DSolve, and Simplify, as well as their numeric analogs.
  • Piecewise[{{v1,c1},{v2,c2},}] can be input in the form . The piecewise operator can be entered as EscpwEsc or \[Piecewise]. The grid of values and conditions can be constructed by first entering Ctrl+Comma, then using Ctrl+Enter and Ctrl+Comma.
  • In StandardForm and TraditionalForm, Piecewise[{{v1,c1},{v2,c2},}] is normally output using a brace, as in .

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

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 EscpwEsc to enter and Ctrl+Comma and then Ctrl+Enter for each additional piecewise case:

Click for copyable input
Introduced in 2004