# Why doesn't Mathematica pull out common factor when simplifing sums of square roots?

Why can't Mathematica pull out the common factor in the following expression when FullSimplifying, to see that it is zero?

FullSimplify[
(-3 + x^2) Sqrt[α (-2 + x^2)/(-3 + x^2)] + Sqrt[α (6 - 5 x^2 + x^4)]
, {0 < α < 1, 0 < x < 1}
]


(-3 + x^2) Sqrt[((-2 + x^2) α)/(-3 + x^2)] + Sqrt[(6 - 5 x^2 + x^4) α]

while it has no problem seeing this without the extra factor of α

FullSimplify[
(-3 + x^2) Sqrt[(-2 + x^2)/(-3 + x^2)] + Sqrt[(6 - 5 x^2 + x^4)]
, {0 < x < 1}
]


0

Although squaring and expanding the expression before applying FullSimplify works in this simple case, I have a matrix where expressions of this sort, with different arguments, form some sub-clause of each entry (where the other parts are complicated functions of different variables) and squaring unfortunately doesn't work.

========

Further strange behaviour simplifying expressions with roots:

No problems simplifying this expression:

FullSimplify[Sqrt[-x^2 + 2/(1 + x^2)] + x^2 Sqrt[-x^2 + 2/(1 + x^2)],
0 < x < 1]


Sqrt[2 + x^2 - 2 x^4 - x^6]

but when combined with an additional term identical to the sum, but opposite in sign, cannot combine the latter two any more

FullSimplify[-Sqrt[2 + x^2 - 2 x^4 - x^6] + Sqrt[-x^2 + 2/(1 + x^2)]
+ x^2 Sqrt[-x^2 + 2/(1 + x^2)], 0 < x < 1]


-Sqrt[2 + x^2 - 2 x^4 - x^6] + Sqrt[-x^2 + 2/(1 + x^2)] + x^2 Sqrt[-x^2 + 2/(1 + x^2)]

When the sum of the last two terms is done manually, all goes as expected:

FullSimplify[-Sqrt[ 2 + x^2 - 2 x^4 - x^6] + (1 + x^2) Sqrt[-x^2 + 2/(1 + x^2)]
, 0 < x < 1]


0

Why is this happening? How can I make FullSimplify combine Sqrt[-x^2 + 2/(1 + x^2)] + x^2 Sqrt[-x^2 + 2/(1 + x^2)] to obtain (1 + x^2) Sqrt[-x^2 + 2/(1 + x^2)] when there are other clauses in the expression?

• FullSimplify[ PowerExpand[(-3 + x^2) Sqrt[\[Alpha] (-2 + x^2)/(-3 + x^2)] + Sqrt[\[Alpha] (6 - 5 x^2 + x^4)]], {0 < \[Alpha] < 1, 0 < x < 1}] returns 0... perhaps applying PowerExpand on your unspecified cases might help? – ciao Oct 1 '15 at 10:12
• @ciao, it works, but is dangerous to apply blindly to my expressions, without verifying positivity of each individual component manually. Does FullSimplify not contain a similar transformation, even when the assumptions imply that the components are always positive? – Rakhi Mahbubani Oct 1 '15 at 11:58

expr = (-3 + x^2) Sqrt[\[Alpha] (-2 + x^2)/(-3 + x^2)] +
Sqrt[\[Alpha] (6 - 5 x^2 + x^4)];


If identifying the zeroes is important enough to warrant the overhead,

Assuming[{0 < \[Alpha] < 1, 0 < x < 1},
If[expr == 0, 0, expr] // FullSimplify]

(*  0  *)

• Thanks, this works perfectly. I still don't understand why FullSimplify can't see that the roots of expr are outside the range of x given in the assumptions. It can do this in the absence of the extra parameter \[Alpha], and the roots are \[Alpha]-independent. Very strange behaviour indeed... – Rakhi Mahbubani Oct 2 '15 at 8:55
• Unfortunately this doesn't work in context, because my expressions to be simplified have too many independent variables, so identifying the zeros takes too long...Question updated with more strange behaviour... – Rakhi Mahbubani Oct 2 '15 at 10:26

Try this:

expr = (-3 + x^2) Sqrt[\[Alpha] (-2 + x^2)/(-3 + x^2)] +
Sqrt[\[Alpha] (6 - 5 x^2 + x^4)]


then

 Simplify[expr /. a_*Sqrt[b_] -> Sqrt[a^2*b] //
PowerExpand, {x > Sqrt[2], \[Alpha] > 0}]

(*  2 Sqrt[(6 - 5 x^2 + x^4) \[Alpha]]  *)


Have fun!

• thanks, but this gives the incorrect answer for the range of x specified above, 0<x<1, where a_ as used by you above is negative – Rakhi Mahbubani Oct 2 '15 at 8:43
• @Rakhi Mahbubani Well, but you should look, what you are doing. In this domain (-3 + x^2)<0 and, therefore, the rule should be written down differently: a_*Sqrt[b_] -> -Sqrt[a^2*b] . – Alexei Boulbitch Oct 2 '15 at 12:41
• @alexey boulbitch, you're right of course. However I'm looking for a solution where Mathematica will give me the correct answer given a consistent set of assumptions, without my having to make substitutions on a case-by-case basis c.f. Example 2 above. I'm wondering whether I'm missing a subtlety that prevents the combination of the two obviously similar parts, or whether I can make a simple tweak of the complexity function to fix these issues. – Rakhi Mahbubani Oct 4 '15 at 19:12