Piecewise Functions
rating: 0+x

« All Snippets

Basic Commands

The array command in combination with the \left and \right commands provides an easy way to typeset piecewise-defined functions. Here is some sample code followed by the output:

$$
f(x) = \left\{
        \begin{array}{ll}
            -x & \quad x \leq 0 \\
            x & \quad x > 0
        \end{array}
    \right.
$$

The result is:(1)
\begin{align} f(x) = \left\{ \begin{array}{ll} -x & \quad x \leq 0 \\ x & \quad x > 0 \end{array} \right. \end{align}

The arguments to the array command are ll, indicating two cells that are left-aligned. Other options here include c, for center-aligned, and r for right-aligned. The \quad command adds in some additional spacing between the definition and the inequalities.

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License