Sometimes I observe Mathematica produce expressions exactly like the following after a simplification step:
$$\frac{a+\sqrt{-(1-b)}\sqrt{\frac{1}{b-1}}}{\sqrt{c}\sqrt{\frac{1}{c}}}$$
Now, any further generic Simplify
or FullSimplify
would not do any good any more. One is tempted to use PowerExpand
, but this would just introduce an annoying i
term in the numerator, instead of simplifying correctly. Therefore, what I have been doing is typing in simplifications like:
/.Sqrt[x_]Sqrt[y_]/(Sqrt[z_]Sqrt[m_])->Sqrt[x y]/Sqrt[z m]//Simplify
by hand. This is very annoying. Maybe there is a Mathematica function which joins all the square roots in all possible places of an expression together?
EDIT Example code to be simplified:
Sqrt[-(1 - b)] Sqrt[1/(b - 1)]
Generally, any simplification involving explicitly specifying properties of terms involved does not help really, since the amount of actions is the same as manually correcting the expression. What I am looking for is a function which merges all possible square roots together, regardless of content.
EDIT2
Please note the following triviality: a search for a function performing the merging of all square roots in an expression only makes sense if an appropriate branch for the square root functions is chosen so that $\sqrt{x}\sqrt{y}=\sqrt{x y}$ is actually true for the expressions in question. Thank you.
Sqrt[-2] Sqrt[-2] != Sqrt[4]
andSqrt[-3] Sqrt[-1/3] != 1
. $\endgroup$expr //. Sqrt[x_] Sqrt[y_] -> Sqrt[x y]
. $\endgroup$