Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
Piecewise function
Function which is defined by multiple sub-functions each over its own interval

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 P {\displaystyle P} , for a property P {\displaystyle P} is roughly that the domain of the function can be partitioned into pieces on which the property P {\displaystyle P} holds, but 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.

Related Image Collections Add Image
We don't have any YouTube videos related to Piecewise function yet.
We don't have any PDF documents related to Piecewise function yet.
We don't have any Books related to Piecewise function yet.
We don't have any archived web articles related to Piecewise function yet.

Notation and interpretation

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.6 The if {\displaystyle {\text{if}}} or for {\displaystyle {\text{for}}} is rarely omitted at the start of the right column.7

The subdomains together must cover the whole domain; sometimes it is also required that they are pairwise disjoint, i.e. form a partition of the domain.8 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:9 | x | = { − x , if  x < 0 + x , if  x ≥ 0. {\displaystyle |x|={\begin{cases}-x,&{\text{if }}x<0\\+x,&{\text{if }}x\geq 0.\end{cases}}} For all values of x {\displaystyle x} less than zero, the first sub-function ( − x {\displaystyle -x} ) is used, which negates the sign of the input value, making negative numbers positive. For all values of x {\displaystyle x} greater than or equal to zero, the second sub-function ( x {\displaystyle x} ) is used, which evaluates trivially to the input value itself.

The following table documents the absolute value function at certain values of x {\displaystyle x} :

xf(x)Sub-function used
−33 − x {\displaystyle -x}
−0.10.1 − x {\displaystyle -x}
00 x {\displaystyle x}
1/21/2 x {\displaystyle x}
55 x {\displaystyle x}

In order to evaluate a piecewise-defined function at a given input value, the appropriate subdomain needs to be chosen in order to select the correct sub-function—and produce the correct output value.

Examples

  • A step function or piecewise constant function, composed of constant sub-functions
  • Piecewise linear function, composed of linear sub-functions
  • Broken power law, a function composed of power-law sub-functions
  • Spline, a function composed of polynomial sub-functions, often constrained to be smooth at the joints between pieces
  • PDIFF
  • f ( x ) = { exp ⁡ ( − 1 1 − x 2 ) , x ∈ ( − 1 , 1 ) 0 , otherwise {\displaystyle f(x)={\begin{cases}\exp \left(-{\frac {1}{1-x^{2}}}\right),&x\in (-1,1)\\0,&{\text{otherwise}}\end{cases}}} and some other common Bump functions. These are infinitely differentiable, but analyticity holds only piecewise.

Continuity and differentiability of piecewise-defined functions

A piecewise-defined function is continuous on a given interval in its domain if the following conditions are met:

  • its sub-functions are continuous on the corresponding intervals (subdomains),
  • there is no discontinuity at an endpoint of any subdomain 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 {\displaystyle x_{0}} . The filled circle indicates that the value of the right sub-function is used in this position.

For a piecewise-defined 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 sub-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.101112

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);13 a cartoon-like function is a C2 function, smooth except for the existence of discontinuity curves.14 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

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

References

  1. "Piecewise Functions". www.mathsisfun.com. Retrieved 2020-08-24. https://www.mathsisfun.com/sets/functions-piecewise.html

  2. Weisstein, Eric W. "Piecewise Function". mathworld.wolfram.com. Retrieved 2020-08-24. https://mathworld.wolfram.com/PiecewiseFunction.html

  3. "Piecewise functions". brilliant.org. Retrieved 2020-09-29. https://brilliant.org/wiki/piecewise-functions/

  4. S. M. Nikolsky (1977). A Course Of Mathematical Analysis Vol 1. p. 178. https://archive.org/details/nikolsky-a-course-of-mathematical-analysis-vol-1-mir

  5. Sofronidis, Nikolaos Efstathiou (2005). "The set of continuous piecewise differentiable functions". Real Analysis Exchange. 31 (1): 13–22. doi:10.14321/realanalexch.31.1.0013. ISSN 0147-1937. https://projecteuclid.org/journals/real-analysis-exchange/volume-31/issue-1/The-set-of-continuous-piecewise-differentiable-functions/rae/1149516810.full

  6. Weisstein, Eric W. "Piecewise Function". mathworld.wolfram.com. Retrieved 2024-07-20. https://mathworld.wolfram.com/PiecewiseFunction.html

  7. Weisstein, Eric W. "Piecewise Function". mathworld.wolfram.com. Retrieved 2024-07-20. https://mathworld.wolfram.com/PiecewiseFunction.html

  8. A feasible weaker requirement is that all definitions agree on intersecting subdomains.

  9. Weisstein, Eric W. "Piecewise Function". mathworld.wolfram.com. Retrieved 2020-08-24. https://mathworld.wolfram.com/PiecewiseFunction.html

  10. "One-sided derivative. Encyclopedia of Mathematics". https://encyclopediaofmath.org/. Retrieved 2025-05-04. {{cite web}}: External link in |website= (help) http://encyclopediaofmath.org/index.php?title=One-sided_derivative&oldid=48044

  11. Ilyin, V. A.; Poznyak, E. G. (1982). Fundamentals Of Mathematical Analysis. Vol. 1. Translated from Russian by Irene Aleksanova. Mir Publishers Moscow. pp. 146, 177. ISBN 978-93-859-2386-9. 978-93-859-2386-9

  12. Canuto, Claudio; Tabacco, Anita (2008). Mathematical Analysis I. Translated by: Simon G. Chiossi. Milan: Springer-Verlag Italia. pp. 83, 176. ISBN 978-88-470-0875-5. 978-88-470-0875-5

  13. Kutyniok, Gitta; Labate, Demetrio (2012). "Introduction to shearlets" (PDF). Shearlets. Birkhäuser: 1–38. Here: p.8 /wiki/Gitta_Kutyniok

  14. Kutyniok, Gitta; Lim, Wang-Q (2011). "Compactly supported shearlets are optimally sparse". Journal of Approximation Theory. 163 (11): 1564–1589. arXiv:1002.2661. doi:10.1016/j.jat.2011.06.005. /wiki/ArXiv_(identifier)