Skip to content

How to Input Piecewise Functions

Written Tutorial

Enter Math Mode

  • If you want to type a math formula, enter Math Mode first.
  • For inline math, type $.
  • For a display equation on its own line, use Alt/Option + $.

Insert a Piecewise Function

  • In Math Mode, use the Toolbar: Insert -> Table -> Choice.
  • Or press \ to enter command mode, type choice, and press Enter.

Expand the Piecewise Structure

  • Place the cursor inside the piecewise function.
  • Use Alt/Option + the arrow keys to expand it.

Enter Each Case

  • A common layout is to type the expression on the left and the condition on the right.
  • For example, type x^2 on the left and x >= 0 on the right.
  • You can also keep using LEGO symbols, Tab cycling, or command mode for additional math symbols.

Numbering and Referencing

  • Piecewise functions can be numbered as a whole formula or line by line.
  • If you select the whole piecewise function and click 123 on the focus toolbar, the whole multi-line formula is typically numbered.
  • For more about the 123 button, the \eq-number command, and references, see Quick Formula Editing.

Optional Reading: How to Write a Piecewise Function in LaTeX

In LaTeX\LaTeX, the most common way to typeset a piecewise function is the cases environment. For example:

latex
f(x) =
\begin{cases}
x^2, & x \ge 0 \\
-x, & x < 0
\end{cases}

This renders as:

f(x)={x2,x0x,x<0f(x) = \begin{cases} x^2, & x \ge 0 \\ -x, & x < 0 \end{cases}

If you already have existing LaTeX\LaTeX code, you can also convert it directly in Liii STEM with Magic Paste.