A piecewise function is one that is defined by two or more different formulas, each applying to a specific subset of the function's domain. Instead of a single rule valid everywhere, the definition lists alternative rules together with the part of the domain where each rule applies. Such definitions are common in elementary and applied mathematics because many practical relationships change behavior across thresholds or intervals.
Definition and notation
To specify a piecewise function mathematicians typically use a brace with separate lines, each giving an expression and its condition. For example, one might write f(x) = { 2x if x > 0; x - 1 if x ≤ 0 } to indicate that f equals 2x for positive x and x−1 otherwise. Conditions are usually written with inequalities, interval notation, or logical connectors; equivalent descriptions use indicator functions or step functions to combine formulas into a single expression.
Properties at boundaries and classifications
Behavior at the points where the defining pieces meet is important. A piecewise function may be continuous or discontinuous at a boundary depending on whether the one-sided limits agree with the assigned value. Differentiability is more restrictive: even if a piecewise function is continuous, corners or cusps can make it non-differentiable at junctions. When each piece is a polynomial it is often called piecewise-polynomial; if each piece is linear it is piecewise-linear. The terms piecewise-continuous and piecewise-smooth classify functions by regularity on each piece.
Common examples and uses
Many familiar functions are naturally defined piecewise. Typical examples include the absolute value function, the floor (greatest-integer) function, the sign function and step functions used in modelling switches. Piecewise definitions appear across calculus, numerical methods, signal processing, computer graphics (splines), and engineering models where different regimes follow different laws.
Practical notes and distinctions
When working with piecewise functions, state the domains of the pieces clearly and decide how boundary points are assigned. In computation, piecewise definitions are implemented with conditional statements; in analysis they are used to construct examples or counterexamples about limits, continuity and differentiability. Understanding the local behavior near boundaries is often the key to integrating, differentiating, or approximating a piecewise-defined function.