# Unexpected behaviour of Solve applied to two equations in two variables

I have a simple Mathematica expression

Solve[{a(a-1)Sqrt[1+a^2+b^2] == b(a^3-1), b(b-1)Sqrt[1+a^2+b^2] == a(b^3-1)}]


which returns (on version 8.0, and also version 9.0)

{{b -> -(a/(1 + a))}, {a -> 1, b -> -I}, {a -> 1, b -> I}, {a -> 1, b -> 1},
{b -> 0, a -> 0}, {b -> I, a -> I}, {b -> 1, a -> -I}, {b -> 1, a -> I}}


The first of these solutions does not seem correct. For example, putting a=2, b=-2/3 does not satisfy either of the equations. On the other hand, if I add the "VerifySolutions" option to Solve I get the right answer:

Solve[{a(a-1)Sqrt[1+a^2+b^2] == b(a^3-1), b(b-1)Sqrt[1+a^2+b^2] == a(b^3-1)}
, VerifySolutions -> True]


returns

{{a -> 1, b -> -I}, {a -> 1, b -> I}, {a -> 1, b -> 1}, {b -> 0, a -> 0},
{b -> I, a -> I}, {b -> 1, a -> -I}, {b -> 1, a -> I}}


Is this the expected behaviour? It seems a bit odd to have to add an option to Solve to make it check that the solution returned actually satisfies the original equations.

-
Actually, Mathematica returns the correct solution and some hint towards the infinite parameter family of solutions your system has in the reals. Try Reduce and you'll see what I mean. So your equations are identically satisfied for ANY $b < -1, a = \frac{-b}{b+1}.$ You can check that by running Simplify[a (a - 1) Sqrt[1 + a^2 + b^2] == b (a^3 - 1) /. a -> -b/(b + 1), b < -1] and Simplify[b (b - 1) Sqrt[1 + a^2 + b^2] == a (b^3 - 1) /. a -> -b/(b + 1), b < -1] – gpap Sep 13 '13 at 11:29
Sorry, I'm not sure I understand this -- if I set (say) $b=-2$, $a=2$, then neither of the equations is satisfied, right? – Ashley Montanaro Sep 13 '13 at 11:55
@AshleyMontanaro May be you want to say $b=-2,a=-2$ ? – ybeltukov Sep 13 '13 at 12:40
Thanks -- yes, this does satisfy both of the equations. However, it doesn't correspond to any of the solutions returned by Mathematica. So it seems that the set returned by Solve doesn't contain all the solutions, and that not all the solutions it does return are correct. – Ashley Montanaro Sep 13 '13 at 12:47
If you set $b=-2,$ then $a=\frac{-b}{(b+1)} = \frac{2}{-1}=-2$ and not $+2.$ This holds for any pair of real numbers given $b<-1.$ Use Reduce in place of Solve and the $a=\frac{-b}{(b+1)}$ solution will come with a constraint that, in the real domain, translates to $b<-1.$ – gpap Sep 13 '13 at 13:10

Actually, Mathematica returns the correct solution, but there is quite a high degree of symmetry (i.e. $a \leftrightarrow b$) between your equations and not much extra information in solving them as a system. Solve uses generic parameters so Solve[a x + b == 0, x] gives you {{x -> -(b/a)}} without accounting for the case a=0.

So it's a good idea to use reduce:

Reduce[{a(a-1)Sqrt[1+a^2+b^2] == b(a^3-1), b(b-1)Sqrt[1+a^2+b^2] == a(b^3-1)}]

(*out*)
(b == 0 && a == 0) || (b == -I && a == 1) || (b == I &&
a == I) || (b == I && a == 1) || (b == 1 && a == -I) || (b == 1 &&
a == I) || (b == 1 && a == 1) || (b (1 + b) (1 + b^2) != 0 && -b != 0 &&
0 == (-1 - b - b^2 - Sqrt[(1 + b + b^2)^2/(1 + b)^2] -
b Sqrt[(1 + b + b^2)^2/(1 + b)^2])/(1 + b) && a == -(b/(1 + b)))


which gives you the seven solutions you got from Solve, a warning message, and an eighth solution which translates to

"for $b\ne 0, \pm1$ and if $b$ satisfies $$\frac{-b^2-\sqrt{\frac{\left(b^2+b+1\right)^2}{(b+1)^2}} b-\sqrt{\frac{\left(b^2+b+1\right)^2}{(b+1)^2}}-b-1}{b+1}=0$$ then $a=-\frac{b}{b+1}.$"

The equation for $b$ is, essentially, just $-z = \sqrt{z^2}$ with $z = \frac{b^2+b+1}{b+1}$ and mathematica is having trouble picking a branch for the square root hence the warning. In the real domain the above is satisfied for $z\le 0$ or $b<-1.$

You can see this using Reduce again:

Reduce[(1 + b + b^2)/(1 + b) <= 0, Reals]

(*out*) b < -1


or you can use Reduce on the equation spat out by Reduce the first time and you will get the same answer:

Reduce[0 == (-1 - b - b^2 - Sqrt[(1 + b + b^2)^2/(1 + b)^2] -
b Sqrt[(1 + b + b^2)^2/(1 + b)^2])/(1 + b), Reals]

(*out*) b < -1


so, on top of the seven solutions above, any pair $b<-1, a=-\frac{b}{b+1}$ is a solution which Solve correctly picked but for generic $b.$

-