How to typeset piecewise-defined functions?
Option 1 (recommended)
\documentclass[preview,border=12pt,varwidth]{standalone}
\usepackage{mathtools}
\begin{document}
\abovedisplayskip=0pt\relax
\[
\lvert x \rvert =
\begin{cases}
x & \text{if } x>0\\
0 & \text{if } x=0\\
-x& \text{if } x<0
\end{cases}
\]
\end{document}
Option 2 (just for fun)
right aligned
\documentclass[preview,border=12pt,varwidth]{standalone}
\usepackage{mathtools}
\begin{document}
\abovedisplayskip=0pt\relax
\[
\lvert x \rvert =
\left\{
\!
\begin{aligned}
x & \text{ if } x>0\\
0 & \text{ if } x=0\\
-x& \text{ if } x<0
\end{aligned}
\right.
\]
\end{document}
Important Notes
standalone
class and \abovedisplayskip=0pt
are settings for my own purpose to create a standalone and tight output. You should not use it for your production unless your objective is the same as mine.