thumb|280px|Plot of the [[piecewise linear function <math>f(x) = \left\{ \begin{array}{lll} -3-x & \text{if} & x \leq -3 \\ x+3 & \text{if} & -3 \leq x \leq 0 \\ 3-2x & \text{if} & 0 \leq x \leq 3 \\ 0.5x - 4.5 & \text{if} & 3 \leq x \\ \end{array} \right.</math>]]
In mathematics, a piecewise function (also called a piecewise-defined function, a hybrid function, or a function defined by cases) is a function whose domain is partitioned into several intervals ("subdomains") on which the function may be defined differently. Piecewise definition is actually a way of specifying the function, rather than a characteristic of the resulting function itself, as every function whose domain contains at least two points can be rewritten as a piecewise function. The first three paragraphs of this article only deal with this first meaning of "piecewise".
Terms like piecewise linear, piecewise smooth, piecewise continuous, and others are also very common. The meaning of a function being piecewise <math>P</math>, for a property <math>P</math>, is roughly that the domain of the function can be partitioned into pieces on which the property <math>P</math> holds, but this term is used slightly differently by different authors. Unlike the first meaning, this is a property of the function itself and not only a way to specify it. Sometimes the term is used in a more global sense involving triangulations; see Piecewise linear manifold.
Notation and interpretation
thumb|280px|right|Graph of the absolute value function,
thumb|280px|The function is piecewise [[Monotonic function|monotonic (subdomains <math>(-\infty,0]</math>, ) and piecewise differentiable (subdomains , , and ).]]
Piecewise functions can be defined using the common functional notation, where the body of the function is an array of functions and associated subdomains. A semicolon or comma may follow the subfunction or subdomain columns. This is enough for a function to be "defined by cases", but in order for the overall function to be "piecewise", the subdomains are typically required to be nonempty intervals (some may be degenerate intervals, i.e. single points or unbounded intervals) and they are often not allowed to have infinitely many subdomains in any bounded interval. This means that functions with bounded domains will only have finitely many subdomains, while functions with unbounded domains can have infinitely many subdomains, as long as they are appropriately spread out.
As an example, consider the piecewise definition of the absolute value function:
Applications
In applied mathematical analysis, "piecewise-regular" functions have been found to be consistent with many models of the human visual system, where images are perceived at a first stage as consisting of smooth regions separated by edges (as in a cartoon);
a cartoon-like function is a C<sup>2</sup> function, smooth except for the existence of discontinuity curves.
In particular, shearlets have been used as a representation system to provide sparse approximations of this model class in 2D and 3D.
Piecewise defined functions are also commonly used for interpolation, such as in nearest-neighbor interpolation.
See also
- Piecewise linear continuation
