A piecewise function (or piecewise-defined function) is a function that changes “formula” depending on which interval xx falls into. We have already met them in the study of the absolute value: now we treat them as an object in their own right.

Definition — Piecewise function

A function f ⁣:DRf\colon D\to\mathbb{R} is piecewise defined if DD is split into nn intervals I1,,InI_1,\ldots,I_n with D=I1InD=I_1\cup\cdots\cup I_n and on each IkI_k a formula fk(x)f_k(x) is assigned: f(x)={f1(x)xI1,f2(x)xI2,fn(x)xIn.f(x) = \begin{cases} f_1(x) & x\in I_1, \\ f_2(x) & x\in I_2, \\ \vdots & \\ f_n(x) & x\in I_n. \end{cases}

Example — Sign function

sgn(x)={+1x>0,0x=0,1x<0.\operatorname{sgn}(x) = \begin{cases} +1 & x>0, \\ 0 & x=0, \\ -1 & x<0. \end{cases} Three constant pieces. It is not continuous at x=0x=0: a jump of height 22.

Example — Absolute value as a piecewise function

x={xx0xx<0|x|=\begin{cases} x & x\ge 0 \\ -x & x<0\end{cases}. Two linear pieces meeting at (0,0)(0,0) at the same height: continuous but not differentiable at 00 (a corner point, which we shall see in Year Five).

Topics: Functions and properties
Concepts: Piecewise function · Sign function · Absolute value
Functions: Sign function · Absolute value