[Tex/LaTex] Function with cases or array

arrayscases

I want to get this function:

enter image description here

I wrote two options, but I can't match the picture. Here is the first one:

\begin{displaymath}
        P[\chi_{n+1}=j|\chi_{n}=i]=
        \begin{dcases}
                \frac{N-i}{N}&\text{si }j=i+1\\
                \frac{i}{N}&\text{si }j=i-1\\
                0&\text{otro caso}
        \end{dcases}
\end{displaymath}

Case 1

And here is the second one: (This one is kind of compressed)

\begin{displaymath}
        P[\chi_{n+1}=j|\chi_{n}=i]=
        \left\{\begin{array}{cc}
                \dfrac{N-i}{N} & \text{si }j=i+1\\
                \dfrac{i}{N} & \text{si }j=i-1\\
                0 & \text{en otro caso}
        \end{array}\right
\end{displaymath}

How can improve the code?. Thanks for the support.

Best Answer

The issue seems to be that you want the "column" to the right of the brace to be centered rather than left justified, which is what happens in all of the cases environments (at least, in all of the ones that I know about). To fix this this the OP's idea of using an array seems to be the way to go, but a few tweaks are needed.

  • First, if you use \left\{ then there has to be a matching \right<delimiter>. As there isn't a matching right delimiter, in this case, you can use \right.. Personally, I don't like the sizes that \left....\right produces so, instead, I have defined a macro \Bigger that will scale the following delimiter to the specified height in millimeters, which defaults to 7mm. Except for the optional argument, this is similar to the \bigl, \biggl, \Big ... amsmath macros.
  • Next, as the OP says, the rows of the array are too close together. You can adjust the spacing between rows using the optional argument to the \\ command. So \\[3mm] will add an extra 3mm between the rows, which seems about right.
  • The array environment comes with padding, so there is too much space between the brace and the equations. You can remove the left-padding by adding @{} to the array specifications.
  • I have added some punctuation.
  • Finally, as suggested in the comments, \mid is better than |.

With these changes the MWE produces:

enter image description here

This is pretty close to the "ideal" image given at the top of the question. Here is the full code:

\documentclass{article}
\usepackage{amsmath}

% an ams-style operator for resizing delimiters
% Usage: \Bigger[, \Bigger[8][, \Bigger[10](, ...
\newcommand\Bigger[2][7]{\left#2\rule{0mm}{#1truemm}\right.}

\begin{document}

\begin{displaymath}
        P[\chi_{n+1}=j\mid\chi_{n}=i]=
        \Bigger[14]\{\begin{array}{@{}cl}
                \dfrac{N-i}{N}, & \text{si }j=i+1,\\[3mm]
                \dfrac{i}{N},   & \text{si }j=i-1,\\[3mm]
                0,              & \text{en otro caso}.
        \end{array}
\end{displaymath}

\end{document}
Related Question