Piecewise linear function (source code)

= Piecewise linear function
{wiki}

= Piecewise-linear
{synonym}

A <piecewise linear function> agrees with an <affine function> on each member of a finite or <locally finite family of subsets> partitioning its <domain of a function>. On the <real line> the pieces are <intervals>; in higher dimensions each piece can be a <polyhedron>. Here the conventional word “linear” permits a constant offset within each piece.

For example, the <absolute value> function satisfies $|x|=-x$ for $x\leq0$ and $|x|=x$ for $x\geq0$. Both branches agree at zero, so the resulting <function> is <continuous>, although its <derivative> changes there. Joining sampled values by <linear interpolation> gives another common construction. If the partition pieces meet, their formulas must agree on overlaps to define a single <function>; allowing separate pieces across a jump is a convention that should be stated.