how to flalign multiline

‎I do not know how to align this. could you help me? this is my attempt:

\documentclass{article}‎‎
\usepackage{amsmath} ‎
\begin{document}
‎
\begin{flalign*} ‎‎
\displaystyle \partfunc{e}{‎e‎} && = & q^{-‎\dfrac{1}{24}} ‎‎\bar{q}^{-‎\dfrac{1}{24}}\; \text{tr}\; q^{L_{0}} ‎\bar{q}\;^{\bar{L}_{0}} \\ ‎
&& = ‎&‎ q^{-‎\dfrac{1}{24}} ‎‎\bar{q}^{-‎\dfrac{1}{24}} \; \sum_{\substack{w,n=-‎\infty\\‎N,‎\bar{N}‎}‎}‎^{‎\infty‎} ‎‎\langle ‎N,‎\bar{N}‎,w,n\vert  ‎q^{L_{0}}‎\bar{q}\;^{‎\bar{L_{0}}} \vert ‎N,‎\bar{N},w,n ‎\rangle ‎‎\\‎
&& = & ‎‎‎(q‎\bar{q})‎^{-‎\dfrac{1}{24}‎}\;\;\Big{(} ‎1‎‎+q^{1}+2q^{2}+3q^{3}+...+P(N) q^{N}+...\Big{)}  \times‎ ‎\Big{(}  ‎1‎+\bar{q}^{1}+2\bar{q}^{2}+3\bar{q}^{3}+...+P(\bar{N})\bar{q}^{‎\bar{N}‎}+... \Big{)}‎‎‎‏‎ \times‎ \sum_{w,n=-‎\infty‎‎‎}^{‎\infty‎} ‎q^{‎\dfrac{1}{2}\Big{(}‎\dfrac{w}{2R}+nR\Big{‎)}^{2}‎} ‎‎\bar{q}^{‎\dfrac{1}{2}\Big{(}‎\dfrac{w}{2R}-nR\Big{‎)}^{2}‎}\\
&& = & ‎\dfrac{1‎}{‎\prod‎_{n=1}^{‎\infty‎} (1-q^{n})(1-‎\bar{q}^{n})‎}‎‎\;\sum_{w,n=-‎\infty‎‎‎}^{‎\infty‎} ‎q^{‎\dfrac{1}{2}\Big{(}‎\dfrac{w}{2R}+nR\Big{‎)}^{2}‎} ‎‎\bar{q}^{‎\dfrac{1}{2}\Big{(}‎\dfrac{w}{2R}-nR\Big{‎)}^{2}‎}‎‎‎

\end{flalign*}
\end{document}

• What is this \partfunc, if that is not asking too much? – Bernard Apr 13 '16 at 23:38
• not really relevant to question, but very important: no blank lines in math mode. ever. – barbara beeton Apr 14 '16 at 2:34
• @ Bernard. it is the partition function of a closed string in physics – Farhad Razi Apr 14 '16 at 7:08

The third line must be split, because it will never fit on the page.

Using \dfrac in exponents makes the equations unreadable: just use small fractions or the slashed form, if feasible.

I don't know what \partfunc should do, add your definition. I defined instead a definition for the math operator \tr. You'll notice I removed all \; commands and added instead \, in the exponents next to \bar{q}, because the bar would make them clash.

Finally note \dots between + and \dotsb at the end. Also \mid is better than \vert in those cases.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\partfunc}[2]{#1#2}% ???
\DeclareMathOperator{\tr}{tr}

\begin{document}

\begin{align*}
\partfunc{e}{e}
&= q^{-1/24}\bar{q}^{\,-1/24}\tr q^{L_{0}}\bar{q}^{\,\bar{L}_{0}}\\[2ex]
&= q^{-1/24}\bar{q}^{\,-1/24}
\sum_{\substack{w,n=-\infty\\N,\bar{N}}}^{\infty}
\langle N,\bar{N},w,n\mid q^{L_{0}}\bar{q}^{\,\bar{L_{0}}}\mid N,\bar{N},w,n\rangle\\[2ex]
&=(q\bar{q})^{-1/24}(1+q^{1}+2q^{2}+3q^{3}+\dots+P(N)q^{N}+\dotsb)\\
P(\bar{N})\bar{q}^{\,\bar{N}}+\dotsb)\\

• @FarhadRazi \\[2ex] makes a slightly bigger space between rows, which is useful for distinguishing “continuation lines”, like for those which start with \times, from those that start with = and denote a new step in the computation. – egreg Apr 14 '16 at 8:55