I want to write a clean-looking piecewise defined function.
There's a similar post here: How to write a function (piecewise) with bracket outside?, but I have follow-up questions.
The two options I have now are:
\[ f(n) = \begin{cases}
\frac{n}{2} & \textrm{ if $n$ is even} \\
-\frac{n-1}{2} & \textrm{ if $n$ is odd} \\
\end{cases} \]
(using the amsmath package), and
For every $n \in \mathbb{N}$, let
\[ f(n) = \left\{
\begin{array}{l l}
\frac{n}{2} & \quad \mbox{if $n$ is even}\\
-\frac{n-1}{2} & \quad \mbox{if $n$ is odd}\\
\end{array} \right. \]
Both seem pretty complicated for something so simple...
Also, is there a way to "center" the $\frac{n}{2}$, so it looks aligned with $-\frac{n-1}{2}$ (instead of off to the left)?

c lfor your column specification in thearrayexample? Also, if you're usingamsmath, you should use\text{..}instead of\textrm{..}or\mbox{..}, since it preserves the correct font size. – Werner Dec 07 '11 at 18:10