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. The or is rarely omitted at the start of the right column. 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. 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: For all values of less than zero, the first sub-function () is used, which negates the sign of the input value, making negative numbers positive. For all values of greater than or equal to zero, the second sub-function is used, which evaluates trivially to the input value itself. The following table documents the absolute value function at certain values of : {, class="wikitable" ! style="width: 3em" , ''x'' ! style="width: 3em" , ''f''(''x'') !Sub-function used , - , −3 , , 3 , , , - , −0.1, , 0.1, , , - , 0 , , 0 , , , - , 1/2 , , 1/2, , , - , 5 , , 5 , , , - 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 ** B-spline * PDIFF *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 . 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.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 aSee also
* Piecewise linear continuation *References
{{Reflist Functions and mappings