I have the following code:
1/2 (Sqrt[(-4 + x1) x1] + Sqrt[-4 + x1] Sqrt[x1]) //Simplify[#, {x1 < 0, (-4 + x1) < 0}] &
Sqrt[x] Sqrt[ y] + Sqrt[x y] // Simplify[#, {x < 0, y < 0}] &
which give respectively
1/2 (Sqrt[-4 + x1] Sqrt[x1] + Sqrt[(-4 + x1) x1])
and
0
Why in one case mathematica recognise a simplification and in the other not?
ComplexityFunction
giving too high complexities for the intermediate expressions in the first case. You can use e.g.ComplexityFunction -> (Count[#, Power[_, 1/2], All] &)
to devalue square roots, which makesSimplify
return0
in both examples. You can also use `ComplexityFunction -> (100 Count[#, Power[_, 1/2], All] + LeafCount[#] &) as a more general complexity function that just gives a high penalty to square roots. $\endgroup$