Dividing an equation into two lines

I am trying to divide this equation into two different lines but I am not able to. I tried to use package breqn but that started giving me some compilation errors on the style file itself.

\frac{ \sum_{n_i\in S_{c_k}} P_{ij} ( x_{i} P(y_i = 1\ |\ x_i = 1) + (1- x_{i}) P (y_i = 1\ |\ x_i=0))}{\sum_{n_i\in S_{c_k}} P_{ij}}


The problem here is \frac{} which prevents me from using align to break the equation.

-

migrated from stackoverflow.comJun 5 '12 at 3:34

This question came from our site for professional and enthusiast programmers.

The equation itself fits on a single line. Where do you want to break it? –  Werner Jun 4 '12 at 23:52
There seem to be more } right braces than { left braces in that equation. Are there? –  thb Jun 4 '12 at 23:58
The start of that equation looks a little ... odd. Do you really want the P on the denominator of the fraction with the subscript i removed from it? Or did you want P_i there? It's unusual notation to have an empty summation divided by something. –  Loop Space Jun 5 '12 at 9:51
Well, the original equation was somewhat longer. I removed some useless parts from it to simplify it. Now it does fit in a line and looks odd. –  user1436235 Jun 5 '12 at 16:31
The input and the output don't agree. Anyway, it's impossible to break a fraction across lines. –  egreg Jun 5 '12 at 16:40

You can use multline

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{multline}
a+b+c+d+e+f\\
+i+j+k+l+m+n
\end{multline}

\end{document}

-
In the sake of minimality, you can omit amssymb ;) As well, some additional relevant information: (1) multline* supresses equation numbering; (2) it goes like this: first line is left-aligned, all middle lines are centered, last line is right-aligned. –  yo' Jun 5 '12 at 7:25
amssymb removed –  sandu Jun 5 '12 at 9:29
multiline does not seem to work with \frac. Latex complains about missing } –  user1436235 Jun 5 '12 at 16:33

Since you mention that this is a simplified version of your actual formula, I am assuming that it won't fit on one line. If so, here is one way you can display a similar equation over multiple lines:

Code:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
\frac{1}{\sum_{n_i\in S_{c_k}} P_{ij}}
\Biggl[
\sum_{n_i\in S_{c_k}} &\phantom{+}P_{ij} \bigl( x_{i} P(y_i = 1\ |\  x_i = 1 ) \\
&+ (1- x_{i}) P(y_i = 1\ |\ x_i=0)\bigr) \Biggr]
\end{align*}
\end{document}

-
I've fixed \bigl and similar ones. Probably multline is better, as it doesn't require finding alignment points. –  egreg Jun 5 '12 at 16:53