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

Logical and Piecewise Functions

Nested logical and piecewise functions can be expanded out much like nested arithmetic functions. You can do this using LogicalExpand and PiecewiseExpand.
LogicalExpand[expr]expand out logical functions in expr
PiecewiseExpand[expr]expand out piecewise functions in expr
PiecewiseExpand[expr,assum]expand out with the specified assumptions

Expanding out logical and piecewise functions.

LogicalExpand puts logical expressions into a standard disjunctive normal form (DNF), consisting of an OR of ANDs.
By default, Mathematica leaves this expression unchanged.
Click for copyable input
LogicalExpand expands this into an OR of ANDs.
Click for copyable input
LogicalExpand works on all logical functions, always converting them into a standard OR of ANDs form. Sometimes the results are inevitably quite large.
Xor can be expressed as an OR of ANDs.
Click for copyable input
Any collection of nested conditionals can always in effect be flattened into a piecewise normal form consisting of a single Piecewise object. You can do this in Mathematica using PiecewiseExpand.
By default, Mathematica leaves this expression unchanged.
Click for copyable input
PiecewiseExpand flattens it into a single Piecewise object.
Click for copyable input
Functions like Max and Abs, as well as Clip and UnitStep, implicitly involve conditionals, and combinations of them can again be reduced to a single Piecewise object using PiecewiseExpand.
This gives a result as a single Piecewise object.
Click for copyable input
With x assumed real, this can also be written as a Piecewise object.
Click for copyable input
Functions like Floor, Mod and FractionalPart can also be expressed in terms of Piecewise objects, though in principle they can involve an infinite number of cases.
Without a bound on x, this would yield an infinite number of cases.
Click for copyable input
Mathematica by default limits the number of cases that Mathematica will explicitly generate in the expansion of any single piecewise function such as Floor at any stage in a computation. You can change this limit by resetting the value of $MaxPiecewiseCases.