# What's wrong with a simple equation-solving task?

Here is my equation to solve for unknown, $$c$$:

Solve[w - 1/(w (1 - e)) == (c - 1/c), c]

which yields

{{c -> (-1 + w^2 - e w^2 - Sqrt[-4 (w - e w) (-w + e w) + (1 - w^2 + e w^2)^2])/(2 (w - e w))},
{c -> (-1 + w^2 - e w^2 + Sqrt[-4 (w - e w) (-w + e w) + (1 - w^2 + e w^2)^2])/(2 (w - e w))}}

I tried a slightly different approach to solve it by replacing the left hand side by $$z$$ as follows:

Solve[z == (c - 1/c), c]

which yields

{{c -> 1/2 (z - Sqrt[4 + z^2])}, {c -> 1/2 (z + Sqrt[4 + z^2])}}

And I replaced w - 1/(w (1 - e)) back to z and the above solution is expressed as:

{{c -> 1/2 ((w - 1/(w (1 - e))) - Sqrt[4 + (w - 1/(w (1 - e)))^2])}, {c -> 1/2 ((w - 1/(w (1 - e))) + Sqrt[4 + (w - 1/(w (1 - e)))^2])}}

To confirm that the two approaches yield the same solution, which should be a must, I subtracted one from the other, expecting to get zero, but I didn't!

Here is what I did:

FullSimplify[(-1 + w^2 - e w^2 - Sqrt[-4 (w - e w) (-w + e w) + (1 - w^2 + e w^2)^2])/(2 (w - e w)) - 1/2 (w - 1/(w (1 - e)) - Sqrt[4 + (w - 1/(w (1 - e)))^2])]

which doesn't give me zero but

1/2 (Sqrt[4 + 2/(-1 + e) + 1/((-1 + e)^2 w^2) + w^2] + Sqrt[1 + (-1 + e) w^2 (-2 - w^2 + e (4 + w^2))]/((-1 + e) w))

Did I miss anything?

• Getting answers to questions one should explain whether they are helpful or not, if not one should explain why. Commented Jan 19 at 21:59
• @Artes, I entirely missed to do that. Thanks for the reminder.
– ppp
Commented Jan 19 at 22:03

First of all the system works corectly while you make unjustified reductions. Expressions w - 1/(w (1 - e)) and z can be equivalent only under certain conditions which you simply ignore and so you shouldn't expect that the result would be 0, since there are square roots involved.

FullSimplify as well as Simplify yield results which are generically true, i.e. there are exceptional cases which are not true. Instead of FullSimplify you should rather use Reduce to get always correct results and the warning below explains why the expression couldn't be simplified further.

expr[e_, w_] :=
1/2 (Sqrt[4 + 2/(-1 + e) + 1/((-1 + e)^2 w^2) + w^2] +
Sqrt[1 + (-1 + e) w^2 (-2 - w^2 + e (4 + w^2))]/((-1 + e) w))

Reduce[ expr[e, w] == 0, {e, w}];

If we restrict only to the real domain we get a simple condition when the expression vanishes

cond = Reduce[ expr[e, w] == 0, {e, w}, Reals]
(e < 1 && w > 0) || (e > 1 && w < 0)

and now we can exploit it as a condition in FullSimplify

FullSimplify[ expr[e, w], cond]
0

consequently we can demonstrate examples when the expression vanishes or not

With[{e = 2, w = 1}, Simplify[expr[e, w]]]
2 Sqrt[2]
With[{e = 2, w = -1}, Simplify[expr[e, w]]]
0