Skip to content

Piecewise Functions

Explore functions with different rules by interval.

Explore the branches

Inputx=−1x=-1

Active branch

x<0:f(x)=−xx<0:\quad f(x)=-x

Evaluated result

f(−1)=1f(-1)=1
Absolute value graphThe curve shows the selected function. The filled dark point marks the current input and evaluated result. Dashed guides connect it to the axes. Open circles exclude branch endpoints; filled circles include them.−3-3−2-2−1-100112233−3-3−2-2−1-1112233xxf(x)f(x)
The dark point follows the input slider. Open circles exclude endpoints; filled circles include them. The vertical scale adjusts to the function.
Rendered result
f(x)={−xx<0xx≥0f(x)=\begin{cases}-x & x<0 \\ x & x\ge 0\end{cases}
TeX source
f(x)=\begin{cases}-x & x<0 \\ x & x\ge 0\end{cases}

Typeset conditions with cases

The cases environment pairs each expression with its condition under one opening brace. Include equality in the appropriate condition so the definition covers its boundary. Choose from 13 examples, including pulses, step functions, and loss functions. JavaScript evaluates them; KaTeX renders the definition and result. See cases notation for the underlying TeX syntax.