TheInfoList In
mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and their changes (cal ...
, a piecewise-defined function (also called a piecewise function, a hybrid function, or definition by cases) is a
function Function or functionality may refer to: Computing * Function key A function key is a key on a computer A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern comp ...
defined by multiple sub-functions, where each sub-function applies to a different interval in the domain. Piecewise definition is actually a way of expressing the function, rather than a characteristic of the function itself. A distinct, but related notion is that of a property holding piecewise for a function, used when the domain can be divided into intervals on which the property holds. Unlike for the notion above, this is actually a property of the function itself. A piecewise linear function (which happens to be also continuous) is depicted as an example.

# Notation and interpretation

Piecewise functions can be defined using the common
functional notation In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and ...
, where the body of the function is an array of functions and associated subdomains. These subdomains together must cover the whole
domain Domain may refer to: Mathematics *Domain of a function In mathematics, the domain of a Function (mathematics), function is the Set (mathematics), set of inputs accepted by the function. It is sometimes denoted by \operatorname(f), where is th ...
; often it is also required that they are pairwise disjoint, i.e. form a partition of the domain. In order for the overall function to be called "piecewise", the subdomains are usually required to be intervals (some may be degenerated intervals, i.e. single points or unbounded intervals). For bounded intervals, the number of subdomains is required to be finite, for unbounded intervals it is often only required to be locally finite. For example, consider the piecewise definition of the
absolute value In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities an ... function: :$, x, = \begin{cases} -x, & \text{if } x < 0 \\ +x, & \text{if } x \ge 0 . \end{cases}$ For all values of $x$ less than zero, the first function ($-x$) is used, which negates the sign of the input value, making negative numbers positive. For all values of $x$ greater than or equal to zero, the second function ($x$) is used, which evaluates trivially to the input value itself. The following table documents the absolute value function at certain values of $x$: {, class="wikitable" !style="width: 3em" , ''x'' !style="width: 3em" , ''f''(''x'') !Function used , - , −3 , , 3 , , $-x$ , - , −0.1, , 0.1, , $-x$ , - , 0 , , 0 , , $x$ , - , 1/2 , , 1/2, , $x$ , - , 5 , , 5 , , $x$ , - Here, notice that in order to evaluate a piecewise function at a given input value, the appropriate subdomain needs to be chosen in order to select the correct function—and produce the correct output value.

# Continuity and differentiability of piecewise functions

A piecewise function is
continuous Continuity or continuous may refer to: Mathematics * Continuity (mathematics), the opposing concept to discreteness; common examples include ** Continuous probability distribution or random variable in probability and statistics ** Continuous ga ...
on a given interval in its domain if the following conditions are met: * its constituent functions are continuous on the corresponding intervals (subdomains), * there is no discontinuity at each endpoint of the subdomains within that interval. The pictured function, for example, is piecewise-continuous throughout its subdomains, but is not continuous on the entire domain, as it contains a jump discontinuity at $x_0$. The filled circle indicates that the value of the right function piece is used in this position. For a piecewise function to be differentiable on a given interval in its domain, the following conditions have to fulfilled in addition to those for continuity above: * its constituent functions are differentiable on the corresponding ''open'' intervals, * the one-sided derivatives exist at all intervals endpoints, * at the points where two subintervals touch, the corresponding one-sided derivatives of the two neighboring subintervals coincide.

# Applications

In applied mathematical analysis, piecewise 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. In particular, shearlets have been used as a representation system to provide sparse approximations of this model class in 2D and 3D.

# Common examples

*
Piecewise linear function In mathematics and statistics, a piecewise linear, PL or segmented function is a real-valued function of a real variable, whose graph of a function, graph is composed of straight-line segments. Definition A piecewise linear function is a function ... , a piecewise function composed of line segments **
Step function In mathematics, a function on the real number Real may refer to: * Reality, the state of things as they exist, rather than as they may appear or may be thought to be Currencies * Brazilian real (R\$) * Central American Republic real * Mexican ... , a piecewise function composed of constant functions ***
Boxcar function 250px, A graphical representation of a boxcar function In mathematics Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and c ... , ***
Heaviside step function 325px, The Heaviside step function, using the half-maximum convention The Heaviside step function, or the unit step function, usually denoted by or (but sometimes , or ), is a step function, named after Oliver Heaviside (1850–1925), the valu ...
***
Sign function In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities a ...
**
Absolute value In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities an ... **
Triangular function *
Broken power law Image:Long tail.svg, 300px, An example power-law graph that demonstrates ranking of popularity. To the right is the long tail, and to the left are the few that dominate (also known as the Pareto principle, 80–20 rule). In statistics, a power law ...
, a piecewise function composed of power laws * Spline, a piecewise function composed of polynomial functions, possessing a high degree of smoothness at the places where the polynomial pieces connect **
B-spline In the mathematical Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantitie ...
*
PDIFF * $f\left(x\right)= \begin\left\{cases\right\} \exp\left\left( -\frac\left\{1\right\}\left\{1 - x^2\right\}\right\right), & x \in \left(-1,1\right) \\ 0, & \text\left\{otherwise\right\} \end\left\{cases\right\}$ and some other common
Bump function In mathematics Mathematics (from Greek: ) includes the study of such topics as numbers (arithmetic and number theory), formulas and related structures (algebra), shapes and spaces in which they are contained (geometry), and quantities and t ... s. These are infinitely differentiable, but analyticity holds only piecewise. * Continuous functions in the reals need not be bounded or uniformly continuous, but are always piecewise bounded and piecewise uniformly continuous.