How to show a formula too long to fit in a line?

For example: $$ P(Y-X=m | Y > X) = \sum_{k} P(Y-X=m, X=k | Y > X) = \sum_{k} P(Y-X=m | X=k, Y > X) P(X=k | Y > X) = \sum_{k} P(Y-k=m | Y > k) P(X=k | Y > X).$$

Thanks!

share
Why downvote this? – Aryabhata Mar 19 '11 at 20:01
1  
@Moron: Some people are just pathetic... – Ethan Mar 20 '11 at 0:43
2  
Let us not jump to conclusions. Perhaps they think they have a valid reason? I am guessing one possible reason could be that it is already in the FAQ (although my brief search didn't bring up any). The downvote could be to encourage searching the FAQ first. Of course, downvoting without commenting is pointless in that case. – Aryabhata Mar 20 '11 at 2:25

3 Answers

up vote 14 down vote accepted

Use double dollars and the \begin{align*} environment (within TeX-mode) to solve the problem.

$$\begin{align*} P(Y-X=m | Y > X) &= \sum_{k} P(Y-X=m, X=k | Y > X) \\ &= \sum_{k} P(Y-X=m | X=k, Y > X) P(X=k | Y > X) \\ &= \sum_{k} P(Y-k=m | Y > k) P(X=k | Y > X).\end{align*}$$

$$\begin{align*}
P(Y-X=m | Y > X) &= \sum_{k} P(Y-X=m, X=k | Y > X) \ &= \sum_{k} P(Y-X=m | X=k, Y > X) P(X=k | Y > X) \ &= \sum_{k} P(Y-k=m | Y > k) P(X=k | Y > X).\end{align*}$$

share
What about a case where one has a single long formula which begins with a \left(and ends with a \right)? The align environment seems to fail (in MathJax) for that case. – Eric Nitardy Mar 19 '11 at 17:47
4  
@Eric: You can use the invisible \right. to close the left( on the first line and the invisible \left. to open the closing \right) on the last line and make \begin{align}...\end{align} happy. – Isaac Mar 19 '11 at 19:26
1  
Actually, the \begin{align*} environment can be used without first going into TeX mode (without the double dollar signs), though it sometimes requires you to escape with extra backslashes to get the interpreter to understand. – Arturo Magidin Mar 19 '11 at 21:13
1  
@Eric: the specific problem with \left and \right pairs not working across line breaks is also inherent already in standard TeX, so not a problem with MathJax per se. The usual way to solve the problem is to manually insert \big and similar versions. See en.wikipedia.org/wiki/Help:Displaying_a_formula – Willie Wong Mar 23 '11 at 16:11
@Isaac: But that can give problems because the left bracket and the right bracket don't have to be of the same size! – Jonas Teuwen Aug 7 '11 at 11:40
1  
One way to get them to be the same size is using the vphantom command. – David Speyer Aug 7 '11 at 14:30
Oh, I didn't know Isaac's trick. How cool. – mixedmath Aug 7 '11 at 20:59

Alternatively, since MathJax supports the amsmath extensions, the split environment is also supported:

$$\begin{split}P(Y-X=m | Y > X) &= \sum_{k} P(Y-X=m, X=k | Y > X) \\ &= \sum_{k} P(Y-X=m | X=k, Y > X) P(X=k | Y > X) \\ &= \sum_{k} P(Y-k=m | Y > k) P(X=k | Y > X).\end{split}$$

which is generated by

$$\begin{split} P(Y-X=m | Y > X) &= \sum_{k} P(Y-X=m, X=k | Y > X) \\ &= \sum_{k} P(Y-X=m | X=k, Y > X) P(X=k | Y > X) \\ &= \sum_{k} P(Y-k=m | Y > k) P(X=k | Y > X).\end{split}$$

share
1  
And nobody pointed out that it would be much nicer to use \mid instead of |... :) – t.b. Aug 7 '11 at 9:56
1  
@Theo: ROFL, yes. :D It sucks MathJax doesn't support the \middle to go along with \left and \right though. – J. M. Aug 7 '11 at 10:14
Oh, I wasn't aware of that... Hmm. That's probably because I normally use colons for that purpose. – t.b. Aug 7 '11 at 10:24

As the last mathematician in the world still using Plain TeX, I'd do it with eqalign.

$$\eqalign{P(Y-X=m\mid Y\gt X)&=\sum_kP(Y-X=m,X=k\mid Y\gt X)\cr&=\sum_kP(Y-X=m\mid X=k,Y\gt X)\,P(X=k\mid Y>X)\cr&=\sum_kP(Y-k=m\mid Y\gt k)\,P(X=k\mid Y\gt X)\cr}$$

\eqalign{
  P(Y-X=m\mid Y\gt X)
    &=\sum_kP(Y-X=m,X=k\mid Y\gt X)\cr
    &=\sum_kP(Y-X=m\mid X=k,Y\gt X)\,P(X=k\mid Y>X)\cr
    &=\sum_kP(Y-k=m\mid Y\gt k)\,P(X=k\mid Y\gt X)\cr
}
share
"last mathematician in the world still using Plain $\TeX$" - IIRC, Arturo's another one, so I'm not sure about that claim... :) – J. M. Aug 7 '11 at 12:52
Thanks, Theo; thanks, J. M., I'm in good company then. – Gerry Myerson Aug 7 '11 at 22:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged