# Syntax for writing a function defined by cases [duplicate]

Suppose we want to write about a function in a question that is defined by cases. In our note books we generally write "$f(x) =$" and then we give a big curly left bracket, and then define various values the function is to take in different domains. How to write this here? I mean can someone give me the syntax?

• Specifically, this answer in the MathJax tutorial thread. Dec 8 '15 at 20:41

## 1 Answer

The environment for that is cases, you use it as

$$f(x) = \begin{cases} 0 &, x < 0 \\ 1 & 0 \leqslant x \leqslant 2 \\ -\pi &, x > 2.\end{cases}$$


(line breaks and indentation to be adjusted by personal preference, I chose an odd layout here to avoid scroll bars for the code sample) to produce

$$f(x) = \begin{cases} 0 &, x < 0 \\ 1 & 0 \leqslant x \leqslant 2 \\ -\pi &, x > 2.\end{cases}$$

• Extremely useful. Thank you very much @Daniel Fisher Dec 8 '15 at 20:45