# I got wrong answers when solving an equation

I have this expression:

 eqn= -(P (d4^6 + d4^4 (-2 d5^2 +          3 (l - z)^2) +
d4^2 (d5^4 - 2 d5^2 (l - z)^2 + 3 (l - z)^4) +
2 d4 d5^2 Sqrt[-(-d4^2+ (d3-d5)^2 -(l-z)^2) (-d4^2 + (d3 + d5)^2 - (l - z)^2)] (-l + z) +
d3^4 (d4 + l - z) (d4 - l + z) -
(d5^2 + (l - z)^2) (l - z)^2 (d5 + l - z) (d5 - l + z) -
2 d3^2 (d4^4 + d4^2 (d5^2 + (l - z)^2) - d5^2 (l - z)^2 +
d4 Sqrt[-(-d4^2 + (d3 - d5)^2 - (l - z)^2) (-d4^2 + (d3 + d5)^2 - (l - z)^2)] (-l + z))));


when I tried to solve:

   Solve[eqn == 0, z];


I got the following results:

{{z -> I (d4 - I l)},
{z -> -I (d4 + I l)},
{z -> -Sqrt[d3^2 - d4^2 - 2 d4 d5 - d5^2] + l},
{z ->  Sqrt[d3^2 - d4^2 - 2 d4 d5 - d5^2] + l},
{z -> -Sqrt[d3^2 - d4^2 + 2 d4 d5 - d5^2] + l},
{z ->  Sqrt[d3^2 - d4^2 + 2 d4 d5 - d5^2] + l},
{z -> -Sqrt[-d3^2 - 2 d3 d4 - d4^2 + d5^2] + l},
{z ->  Sqrt[-d3^2 - 2 d3 d4 - d4^2 + d5^2] + l},
{z -> -Sqrt[-d3^2 + 2 d3 d4 - d4^2 + d5^2] + l},
{z ->  Sqrt[-d3^2 + 2 d3 d4 - d4^2 + d5^2] + l}}


But when I wanted to check the previous results, some of them wasn't correct, like this one:

FullSimplify[ eqn /. {z -> Sqrt[d3^2 - d4^2 - 2 d4 d5 - d5^2] + l},
Assumptions -> d3 > 0 && d5 > 0]
(*
-8 d4 (d3 - d5) d5 (d3 + d5) (-d3^2 + (d4 + d5)^2) P
*)


Any help with this ?

-
I can see two types of answers to your question. First is how to get it right in this particular case. Second, that I suspect would be of interest to many, is an explanation of what is going on and whether one should be wary of Solve in certain (which?) situations. – A.G. Dec 24 '13 at 20:19
If you can explain the Second case, that would be appreciated> – M7ammad Dec 28 '13 at 18:43

This may be useful, first notice z always appears with l ( el not one right? ) and do this sub:

eqn = eqn /. z-> zprime + l


soln = Solve[ eqn == 0, zprime]


Which as you notice does not make eqn identically zero when each solution is back substituted.

We can see the additional restrictions required using Reduce:

Off[Reduce::useq]
{#, Simplify[ Reduce[Simplify[eqn  /. #] == 0],
Assumptions -> {Element[{d1, d2, d3, d4, d5}, Reals]} ]} & /@
soln  // MatrixForm

(*    {zprime -> -I d4}   d3 + d5 == 0 || d3 == d5 ||
d3 >= Abs[d5] || d3 + Abs[d5] <= 0 ||
d4 == 0   *)
...etc..


Using Reduce on each Solve result is for some reason way faster than using Reduce directly on the original equaiton.

-