# Possible bug involving square roots simplifications?

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?

• Seems to be an issue of the default 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 makes Simplify return 0 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. – Lukas Lang Apr 27 '19 at 9:57
• Related: Can't simplify Abs[a*Cos[x]]^2 – Lukas Lang Apr 27 '19 at 10:04