# Piecewise

In mathematics, a **piecewise-defined function** (also called a **piecewise function** or a **hybrid function**) is a function defined by multiple sub-functions, each sub-function applying to a certain interval of the main function's domain, a sub-domain. Piecewise is actually a way of expressing the function, rather than a characteristic of the function itself, but with additional qualification, it can describe the nature of the function. For example, a **piecewise polynomial** function is a function that is a polynomial on each of its sub-domains, but possibly a different one on each.

The word *piecewise* is also used to describe any property of a piecewise-defined function that holds for each piece but not necessarily hold for the whole domain of the function. A function is **piecewise differentiable** or **piecewise continuously differentiable** if each piece is differentiable throughout its subdomain, even though the whole function may not be differentiable at the points between the pieces. In convex analysis, the notion of a derivative may be replaced by that of the subderivative for piecewise functions. Although the "pieces" in a piecewise definition need not be intervals, a function is not called "piecewise linear" or "piecewise continuous" or "piecewise differentiable" unless the pieces are intervals.

## Notation and interpretation

Piecewise functions are defined using the common functional notation, where the body of the function is an array of functions and associated subdomains. Crucially, in most settings, there must only be a *finite* number of subdomains, each of which must be an interval, in order for the overall function to be called "piecewise". For example, consider the piecewise definition of the absolute value function:

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.

Consider the piecewise function *f*(*x*) evaluated at certain values of *x*:

x |
f(x) |
Function used |
---|---|---|

−3 | 3 | −x |

−0.1 | 0.1 | −x |

0 | 0 | x |

1/2 | 1/2 | x |

5 | 5 | x |

Thus, 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

A piecewise function is continuous on a given interval if the following conditions are met:

- it is defined throughout that interval,
- 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 . The filled circle indicates that the value of the right function piece is used in this position.

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

## Common examples

Specific instances of piecewise functions include:

- Step function, a piecewise function composed of constant functions
- Piecewise linear function, a piecewise function composed of line segments
- Broken 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
- PDIFF

## See also

Wikibooks has a book on the topic of: Gnuplot#Piecewise-defined functions |

## References

- Kutyniok, Gitta; Labate, Demetrio (2012). "Introduction to shearlets" (PDF).
*Shearlets*. Birkhäuser: 1–38.