# Another confusion with simplify

After reading some of the questions concerning Simplify, I still didn't find a solution to my confusion.

I want Mathematica to simplify

Simplify[(-1 + x) Sqrt[(1 - x) (-1 + y^2)] +
Sqrt[(1 - x)^3 (-1 + y^2)], -1 <= x <= 1 && -1 <= y <= 1]


to zero, where $x,y\in [-1,1]$. However I get the same expression.

Nevertheless, Mathematica doesn't seem to have a problem with:

Simplify[(-1 + x) Sqrt[(1 - x)] +
Sqrt[((1 - x)^3) ], -1 <= x <= 1 && -1 <= y <= 1]


0

Or with:

Simplify[Sqrt[(1 - x) (-1 + y^2)] -
Sqrt[(1 - x)] Sqrt[(-1 + y^2)], -1 <= x <= 1 && -1 <= y <= 1]


0

Even more surprisingly if I would just substitute $1-x = a \in [0,2]$ and $1-y^2 = b \in[0,1]$ then also

Simplify[-a Sqrt[a (-b)] + Sqrt[a^3 (-b)], 0 < a < 2 && 0 < b < 1]


0

is OK... What is going on? Is there something I'm implicitly assuming?

• Since Simplify is basically a discrete minimizer of LeafCount under various transformations, probably the LeafCount of intermediate results increases more with 1-x instead of a. The transformations might be rejected before they get to the simpler expressions. – Michael E2 Jan 26 '16 at 12:37
• OK, that seems reasonable. Anyway to get LeafCount over this local maximum? – cherzieandkressy Jan 26 '16 at 12:41
• Not that I know of. Sorry. You can try your own ComplexityFunction or TransformationFunctions. -- See my answer – Michael E2 Jan 26 '16 at 12:53

This answer is similar to the answer by @MichaelE2, but packaged differently:

Simplify[
PowerExpand[
(-1+x) Sqrt[(1-x) (-1+y^2)]+Sqrt[(1-x)^3 (-1+y^2)],
Assumptions->True
],
-1<=x<=1 && -1<=y<=1
]


0

If you translate the variables to be positive, you can use PowerExpand:

ClearSystemCache[]
Simplify[(-1 + x) Sqrt[(1 - x) (-1 + y^2)] +
Sqrt[(1 - x)^3 (-1 + y^2)], -1 <= x <= 1 && -1 <= y <= 1,
TransformationFunctions -> {Automatic,
Simplify[
PowerExpand[# /. {x -> -1 + a, y -> -1 + b}] /.
{a -> x + 1, b -> y + 1}] &}]
(*  0  *)


Another odd approach is to reward expansion in terms of 1 - x to get it past whatever bottleneck is keeping Simplify from working; then follow with a plain Simplify:

ClearSystemCache[]
Simplify@Simplify[(-1 + x) Sqrt[(1 - x) (-1 + y^2)] +
Sqrt[(1 - x)^3 (-1 + y^2)], -1 <= x <= 1 && -1 <= y <= 1,
ComplexityFunction ->
(SimplifySimplifyCount[#] - 100 Count[#, 1 - x, Infinity] &)]
(*  0  *)

• For the first option, it didn't seem to work on more complex inputs but when I made a function SpecSimp[x_]:= Simplify[x, -1 <= y <= 1 && -1 <= z <= 1, TransformationFunctions -> {Automatic, Simplify[ PowerExpand[ x /. {y -> -1 + a, z -> -1 + b] /. {a -> y + 1, b -> z + 1}] &}] where I changed the # sign into the input it did. I don't understand why but OK... Thank you!! – cherzieandkressy Jan 27 '16 at 10:02
• 80k Congratulations :) I hit 50k today. – Kuba Jan 27 '16 at 20:48
• @Kuba Thanks, I saw that. Congratulations to you, too. :) I saw earlier this morning (here) we were the same number of points below the X0000 mark. – Michael E2 Jan 27 '16 at 21:12

Try this:

 (-1 + x) Sqrt[(1 - x) (-1 + y^2)] + Sqrt[(1 - x)^3 (-1 + y^2)] /.
Sqrt[a_^3*b_] -> a*Sqrt[a*b] // Simplify

(*  0  *)


Have fun!

Altough I cannot tell you what goes wrong with Simplify I would suggest implementing the simplification semi-manually. For example, with

te = (-1 + x) Sqrt[(1 - x) (-1 + y^2)] + Sqrt[(1 - x)^3 (-1 + y^2)]


you could use

te /. a_.*Sqrt[b_] :>Simplify[Sign[a], -1 < x < 1 && -1 < y < 1]*Sqrt[Expand[a^2 b]]


This brings the summands in a standard form suitable for the simplifications you need. The boundaries are not quite the same, though, and would need seperate treatment.

Interesting is that a graph

  Plot3D[(-1 + x) Sqrt[(1 - x) (-1 + y^2)] + Sqrt[(1 - x)^3 (-1 + y^2)], {x, -1, 1}, {y, -1, 1}]


is a non-homogenous plain

• Try it with Plot3D..., WorkingPrecision -> 16]. I don't know what you mean by "non-homogenous", because the equation of the plane seems to be $z = 0$, which is about as homogeneous as it gets. Maybe you meant the holes? They're from nonzero imaginary parts arising from rounding error. Using WorkingPrecision` takes care of it. – Michael E2 Jan 26 '16 at 12:21
• Yes, WorkingPrecision is a solution. Thank you. – Vaclav Kotesovec Jan 26 '16 at 12:34