Lably
Skip to content

Piecewise function

Function defined by multiple sub-functions

  • 3 min read
  • 4 chapters

Related on Lably

Through Mathematics, Function (mathematics) and Domain of a function

Terms like piecewise linear, piecewise smooth, piecewise continuous, and others are also very common. The meaning of a function being piecewise P, for a property P, is roughly that the domain of the function can be partitioned into pieces on which the property P 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

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 if or for 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: |x|={−x,if x<0+x,if x≥0. For all values of x less than zero, the first sub-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 sub-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:

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.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Functions