2
$\begingroup$

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?

$\endgroup$
  • 2
    $\begingroup$ 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? $\endgroup$ – ciao Oct 1 '15 at 10:12
  • 2
    $\begingroup$ @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? $\endgroup$ – Rakhi Mahbubani Oct 1 '15 at 11:58
1
$\begingroup$
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  *)
$\endgroup$
  • $\begingroup$ 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... $\endgroup$ – Rakhi Mahbubani Oct 2 '15 at 8:55
  • $\begingroup$ 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... $\endgroup$ – Rakhi Mahbubani Oct 2 '15 at 10:26
1
$\begingroup$

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!

$\endgroup$
  • $\begingroup$ 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 $\endgroup$ – Rakhi Mahbubani Oct 2 '15 at 8:43
  • $\begingroup$ @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] . $\endgroup$ – Alexei Boulbitch Oct 2 '15 at 12:41
  • $\begingroup$ @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. $\endgroup$ – Rakhi Mahbubani Oct 4 '15 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.