How can I split up a long and complicated equation in LaTeX?

  • Context: LaTeX 
  • Thread starter Thread starter SeM
  • Start date Start date
  • Tags Tags
    Latex Lines Split
SeM
Hi, how do I split up this horrible equation into several lines?

given in latex code:

\Psi_2= -2.018\,{10}^{-122}\,C_{2}\,{\mathrm{e}}^{-x\,1.014{}{10}^7{}\mathrm{i}}\,\left(1.398\,{10}^{121}\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}-1.398\,{10}^{121}\,x^2\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}+1.398\,{10}^{121}\,x^2-1.436\,{10}^{135}+x^3\,1.396{}{10}^{60}{}\mathrm{i}+x\,2.833{}{10}^{128}{}\mathrm{i}\right)

and shown in latex form:

\begin{equation}
\Psi_2= -2.018\,{10}^{-122}\,C_{2}\,{\mathrm{e}}^{-x\,1.014{}{10}^7{}\mathrm{i}}\,\left(1.398\,{10}^{121}\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}-1.398\,{10}^{121}\,x^2\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}+1.398\,{10}^{121}\,x^2-1.436\,{10}^{135}+x^3\,1.396{}{10}^{60}{}\mathrm{i}+x\,2.833{}{10}^{128}{}\mathrm{i}\right)
\end{equation}

it shows beautifully here, but in my latex document it stretches beyond the right margin of the page, and does not split up no matter what I have tried.
 
SeM said:
no matter what I have tried.
What have you tried?
 
DrClaude said:
What have you tried?

I managed, I used

\begin{equation*}
\begin{split*}
\begin{align*}
& Text to split //
& second part to split //
& and so on //

\end{equation*}
\end{split*}
\end{align*}
 
It is strange to see an align within a split. Normally, it should be inside the align. From the AMS math documentation:
Like multiline, the split environment is for single equations that are too long to fit on one line and hence must be split into multiple lines. Unlike multline, however, the split environment provides for alignment among the split lines, using & to mark alignment points. Unlike the other amsmath equation structures, the split environment provides no numbering, because it is intended to be used only inside some other displayed equation structure, usually an equation, align, or gather environment, which provides the numbering.
 
DrClaude said:
It is strange to see an align within a split. Normally, it should be inside the align. From the AMS math documentation:
It worked well as given.

Thanks!
 
SeM said:
Hi, how do I split up this horrible equation into several lines?

given in latex code:

\Psi_2= -2.018\,{10}^{-122}\,C_{2}\,{\mathrm{e}}^{-x\,1.014{}{10}^7{}\mathrm{i}}\,\left(1.398\,{10}^{121}\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}-1.398\,{10}^{121}\,x^2\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}+1.398\,{10}^{121}\,x^2-1.436\,{10}^{135}+x^3\,1.396{}{10}^{60}{}\mathrm{i}+x\,2.833{}{10}^{128}{}\mathrm{i}\right)

and shown in latex form:

\begin{equation}
\Psi_2= -2.018\,{10}^{-122}\,C_{2}\,{\mathrm{e}}^{-x\,1.014{}{10}^7{}\mathrm{i}}\,\left(1.398\,{10}^{121}\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}-1.398\,{10}^{121}\,x^2\,{\mathrm{e}}^{x\,1.014{}{10}^7{}\mathrm{i}}+1.398\,{10}^{121}\,x^2-1.436\,{10}^{135}+x^3\,1.396{}{10}^{60}{}\mathrm{i}+x\,2.833{}{10}^{128}{}\mathrm{i}\right)
\end{equation}

it shows beautifully here, but in my latex document it stretches beyond the right margin of the page, and does not split up no matter what I have tried.

Well there are various environments like align and IEEEeqnarray that you could use to produce output like this: $$\begin{align}
\Psi_2 = -2.018 \, {10}^{-122} \, C_{2} \,
{\mathrm{e}}^{-x\,1.014 \cdot {10}^7{}\mathrm{i}}\, \Bigl(
& 1.398 \, {10}^{121} \,
{\mathrm{e}}^{x\,1.014 \cdot {10}^7{}\mathrm{i}} \nonumber \\
&-\> 1.398 \, {10}^{121} \, x^2 \,
{\mathrm{e}}^{x \, 1.014 \cdot {10}^7{}\mathrm{i}} \nonumber \\
&+\> 1.398\,{10}^{121}\,x^2 - 1.436\,{10}^{135} \nonumber \\
&+\> x^3\,1.396{}{10}^{60}{}\mathrm{i}
+ x\,2.833{}{10}^{128}{}\mathrm{i} \Bigr) \,.
\end{align}$$

But why not just use a few variables: $$\Psi_{2} = - \lambda \, C_{2} \,
\mathrm{e}^{-\mathrm{i} \phi x} \, \Bigl(
\alpha \mathrm{e}^{\mathrm{i} \phi x}
- \alpha x^{2} \mathrm{e}^{\mathrm{i} \phi x}
+ \alpha x^{2} - \beta
+ \mathrm{i} \gamma x^{3}
+ \mathrm{i} \delta x \Bigr) \,,$$ where $$\begin{eqnarray}
\lambda &=& 2.018 \cdot 10^{-122} \,, &\qquad&
\phi &=& 1.014 \cdot 10^{7} \,, \\
\alpha &=& 1.398 \cdot 10^{121} \,, &&
\beta &=& 1.436 \cdot 10^{135} \,, \\
\gamma &=& 1.396 \cdot 10^{60} \,, &&
\delta &=& 2.833 \cdot 10^{128} \,.
\end{eqnarray}$$ This makes the structure of the equation so much clearer.

You can produce the second set of equations in a paper with, e.g.,
Code:
\begin{IEEEeqnarray}{rCl+rCl}
  \lambda &=& 2.018 \cdot 10^{-122} \,, &
  \phi &=& 1.014 \cdot 10^{7} \,, \\
  \alpha &=& 1.398 \cdot 10^{121} \,, &
  \beta &=& 1.436 \cdot 10^{135} \,, \\
  \gamma &=& 1.396 \cdot 10^{60} \,, &
  \delta &=& 2.833 \cdot 10^{128} \,.
\end{IEEEeqnarray}
(If you want to use the IEEEeqnarray environment like here then install IEEEtrantools and put \usepackage[retainorgcmds]{IEEEtrantools} in the document preamble.)
 
  • Like
Likes   Reactions: FactChecker
wle said:
(If you want to use the IEEEeqnarray environment like here then install IEEEtrantools and put \usepackage[retainorgcmds]{IEEEtrantools} in the document preamble.)
Thanks WLE! I ended up using texlabel because these expressions become too long.
 
Last edited by a moderator:

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 11 ·
Replies
11
Views
9K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 15 ·
Replies
15
Views
26K