3

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)}
2
  • 2
    Welcome to TeX.SE!
    – Mensch
    Dec 18, 2021 at 15:00
  • 1
    Although it's probably not useful here, what document class are you using? Inspection shows that this is a single fraction, with many nested \sqrt elements. There are matching numbers of left and right braces, and \left-\right` pairs. Disassembling it and deciding where sub-elements might be broken will almost certainly have to be done manually. I don't know of any existing software or code that can do it. Dec 18, 2021 at 15:33

2 Answers 2

11

Rather than trying to find suitable line breaks in the long and, dare I say it, rather unwieldy formula at hand, I'd restate the formula in terms of its four major components -- named A, B, C, and D below; you're obviously free to choose different labels -- and then provide separate expressions for each of these four major components. I think your readers may find this approach illuminating because of some interesting parallels in the expressions for A and B on the one hand and C and D on the other`.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for '\shortintertext' macro

\begin{document}
The formula of interest is a function of the parameters $a$ and $b$:
\[
\frac{\sqrt{A}-\sqrt{B}}{\sqrt{C}-\sqrt{D}}\qquad \text{with $C\ne D$}\,,
\]
where
\begin{align*}
A &= abxy \\
B &= (1-a)(1-b)(1-x)(1-y) \\
C &= abwz  \\
D &= (1-a)(1-b)(1-w)(1-z) \\
\shortintertext{and}
x &= au\big/\bigl(au+(1-b)(1-u)\bigr) \\
y &= (1-u)\big/\bigl((1-a)u+b(1-u)\bigr) \\
u &= \sqrt{b}\big/\bigl(\sqrt{1-a}+\sqrt{b}\,\bigr) \\[1ex]
w &= b(1-v)\big/\bigl(b(1-v)+(1-a)v\bigr) \\
z &= \sqrt{a/(1-b)}\,v \\
v &= \sqrt{1-b}\big/\bigl(\sqrt{a}+\sqrt{1-b}\,\bigr) \,.
\end{align*}
\end{document}
7

Indeed, it seems hard to find a right place to split this formula and to actually do it. But this formula is so long that it is hardly readable, and in my opinion, splitting it in more lines would not help.

I would recommend to define new variables instead of trying to split this formula. For example, \frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}} and \frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}} both appear several times in your formula, so I would do something like the following.

\documentclass{article}
\usepackage{amsmath}
\usepackage[margin=30mm]{geometry}
\begin{document}
\[
\frac{%
    \sqrt{\frac{ax}{ax + (1-b)(1-x)} ab \frac{b(1-x)}{b(1-x)+(1-a)x}} - \sqrt{\left(1 - \frac{ax}{ax + (1-b)(1-x)}\right) (1-a)(1-b)\left(1-\frac{b(1-x)}{b(1-x) + (1-a)x}\right)}%
}{%
    \sqrt{\sqrt{\frac{a}{1-b}} yab \frac{b(1-y)}{b(1-y) + (1-a)y}}-\sqrt{\left(1-\sqrt{\frac{a}{1-b}}y\right) (1-a)(1-b)\left(1 - \frac{b(1-y)}{b(1-y) + (1-a)y} \right)}%
}
\]
where
\[
x = \frac{\sqrt{b}}{\sqrt{1-a}+\sqrt{b}}
\qquad\text{and}\qquad
y = \frac{\sqrt{1-b}}{\sqrt{a}+\sqrt{1-b}}
\]
\end{document}

On a side note, your code is also very hard to read. Don't be afraid to add some spaces in math mode, it should not affect the output.

You must log in to answer this question.

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