# Piecewise linear function: Wikis

Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

# Encyclopedia

A piecewise linear function
A function (blue) and a piecewise linear approximation to it (red).
A piecewise linear function in two dimensions (top) and the convex polytopes on which it is linear (bottom).

In mathematics, a piecewise linear function is a piecewise-defined function whose pieces are linear.

## Examples

The function defined by:

$f(x) = \begin{cases} -x-3 & \text{if }x \leq -3 \ x+3 & \text{if }-3 < x < 0 \ -2x+3 & \text{if }0 \leq x < 3 \ x-3 & \text{if }x \geq 3 \end{cases}$

is piecewise linear with four pieces. (The graph of this function is shown to the right.) Since the graph of a linear function is a line, the graph of a piecewise linear function consists of line segments and rays. If the function is continuous, the graph will be a polygonal curve.

Other examples of piecewise linear functions include the absolute value function, the square wave, the sawtooth function, and the floor function.

## Notation

The notion of a piece wise linear function makes sense in several different contexts. Piecewise linear functions may be defined on n-dimensional Euclidean space, or more generally any vector space or affine space, as well as on piecewise linear manifolds, simplicial complexes, and so forth. In each case, the function may be real-valued, or it may take values from a vector space, an affine space, a piecewise-linear manifold, or a simplicial complex. (In these contexts, the term “linear” does not refer solely to linear transformations, but to more general affine linear functions.)

In dimensions higher than one, it is common to require the domain of each piece to be a polygon or polytope. This guarantees that the graph of the function will be composed of polygonal or polytopal pieces.

Important sub-classes of piecewise linear functions include the continuous piecewise linear functions and the convex piecewise linear functions. Splines generalize piecewise linear functions to higher-order polynomials, and more one can speak of piecewise-differentiable functions, as in PDIFF.