Text FormattingHow can I split this long equation into multiple lines?

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
jackdaniel87
Posts: 1
Joined: Sat Dec 18, 2021 5:03 pm

How can I split this long equation into multiple lines?

Post by jackdaniel87 »

I've looked at many different methods to split this VERY long formula into several lines but I always get an error but I can't even see where, the formula works - i think the issue is with the splitting method. Can somebody provide a code that works? Many thanks!

\frac{\left(\sqrt{\frac{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\ +\left(1-b\right)\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}ab\frac{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)+\left(1-a\right)\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}}-\sqrt{\left(1-\frac{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\ +\left(1-b\right)\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}\right)\left(1-a\right)\left(1-b\right)\left(1-\frac{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)+\left(1-a\right)\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}\right)}\right)}{\left(\sqrt{\sqrt{\frac{a}{1-b}}\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}ab\frac{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)}{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)+\left(1-a\right)\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}}}-\sqrt{\left(1-\sqrt{\frac{a}{1-b}}\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)\left(1-a\right)\left(1-b\right)\left(1-\frac{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)}{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)+\left(1-a\right)\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}}\right)}\right)}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

How can I split this long equation into multiple lines?

Post by Bartman »

Please try to publish a Infominimal working example marked as code.

You could write the quotient as a product:

Code: Select all

\documentclass{article}
\usepackage{mathtools}% loads amsmath
\usepackage[hmargin=1.5cm, showframe]{geometry}

\begin{document}
\begin{equation}
\begin{split}
&\left(\sqrt{\frac{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}
{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}+\left(1-b\right)
\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}ab
\frac{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}
{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)+\left(1-a\right)
\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}}\right.\\
&\left.-\sqrt{\left(1-\frac{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}
{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}+\left(1-b\right)
\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}\right)\left(1-a\right)
\left(1-b\right)\left(1-\frac{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}
{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)+\left(1-a\right)
\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}\right)}\right)\\
&\left(\sqrt{\sqrt{\frac{a}{1-b}}\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}ab
\frac{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)}
{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)+\left(1-a\right)
\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}}}\right.\\
&\left.-\sqrt{\left(1-\sqrt{\frac{a}{1-b}}\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)
\left(1-a\right)\left(1-b\right)
\left(1-\frac{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)}
{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)+\left(1-a\right)
\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}}\right)}\right)^{-1}
\end{split}
\end{equation}
\end{document}
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

How can I split this long equation into multiple lines?

Post by Ijon Tichy »

Or you can use \Bigg/, either at the end of line:

Code: Select all

\documentclass{article}
\usepackage{mathtools}% loads amsmath
\usepackage[hmargin=1.5cm, showframe]{geometry}

\begin{document}
\begin{equation}
\begin{split}
&\left(\sqrt{\frac{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}
{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}+\left(1-b\right)
\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}ab
\frac{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}
{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)+\left(1-a\right)
\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}}\right.\\
&\left.-\sqrt{\left(1-\frac{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}
{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}+\left(1-b\right)
\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}\right)\left(1-a\right)
\left(1-b\right)\left(1-\frac{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}
{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)+\left(1-a\right)
\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}\right)}\right)\Bigg/\\
&\left(\sqrt{\sqrt{\frac{a}{1-b}}\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}ab
\frac{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)}
{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)+\left(1-a\right)
\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}}}\right.\\
&\left.-\sqrt{\left(1-\sqrt{\frac{a}{1-b}}\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)
\left(1-a\right)\left(1-b\right)
\left(1-\frac{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)}
{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)+\left(1-a\right)
\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}}\right)}\right)
\end{split}
\end{equation}
\end{document}
or at the begin of a line:

Code: Select all

\documentclass{article}
\usepackage{mathtools}% loads amsmath
\usepackage[hmargin=1.5cm, showframe]{geometry}

\begin{document}
\begin{equation}
\begin{split}
&\left(\sqrt{\frac{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}
{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}+\left(1-b\right)
\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}ab
\frac{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}
{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)+\left(1-a\right)
\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}}\right.\\
&\left.-\sqrt{\left(1-\frac{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}
{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}+\left(1-b\right)
\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}\right)\left(1-a\right)
\left(1-b\right)\left(1-\frac{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}
{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)+\left(1-a\right)
\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}\right)}\right)\\
\Bigg/&\left(\sqrt{\sqrt{\frac{a}{1-b}}\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}ab
\frac{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)}
{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)+\left(1-a\right)
\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}}}\right.\\
&\left.-\sqrt{\left(1-\sqrt{\frac{a}{1-b}}\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)
\left(1-a\right)\left(1-b\right)
\left(1-\frac{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)}
{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)+\left(1-a\right)
\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}}\right)}\right)
\end{split}
\end{equation}
\end{document}
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

How can I split this long equation into multiple lines?

Post by Ijon Tichy »

You could also use \splitdfrac:

Code: Select all

\documentclass{article}
\usepackage{mathtools}% loads amsmath
\usepackage[hmargin=1.5cm, showframe]{geometry}

\begin{document}
\begin{equation}
\frac{\left(\splitdfrac{\sqrt{\frac{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}
{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}+\left(1-b\right)
\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}ab
\frac{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}
{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)+\left(1-a\right)
\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}}}
{-\sqrt{\left(1-\frac{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}
{a\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}+\left(1-b\right)
\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}\right)\left(1-a\right)
\left(1-b\right)\left(1-\frac{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)}
{b\left(1-\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}\right)+\left(1-a\right)
\frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}}\right)}}\right)}
{\left(\splitdfrac{\sqrt{\sqrt{\frac{a}{1-b}}\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}ab
\frac{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)}
{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)+\left(1-a\right)
\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}}}}
{-\sqrt{\left(1-\sqrt{\frac{a}{1-b}}\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)
\left(1-a\right)\left(1-b\right)
\left(1-\frac{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)}
{b\left(1-\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}\right)+\left(1-a\right)
\frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}}\right)}}\right)}
\end{equation}
\end{document}
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply