4
$\begingroup$

I got a solution for the equation

Simplify[Solve[
  1/(2 q r (-1 + c1 M s1)) (-a q + M q + b c1 q s0 + a c1 M q s1 - 
  c1 M^2 q s1 - 
  c2 M r s1 + \[Sqrt](4 q r (-1 + c1 M s1) (b (cp + c2 s0) + 
        c2 (a - M) M s1) + (b c1 q s0 - c1 M^2 q s1 + 
       a q (-1 + c1 M s1) + M (q - c2 r s1))^2)) == 0 , M ]]

which is $\left\{\left\{M\to \frac{1}{2} \left(a-\frac{\sqrt{a^2 \text{c2} \text{s1}+4 b (\text{c2} \text{s0}+\text{cp})}}{\sqrt{\text{c2}} \sqrt{\text{s1}}}\right)\right\},\left\{M\to \frac{1}{2} \left(\frac{\sqrt{a^2 \text{c2} \text{s1}+4 b (\text{c2} \text{s0}+\text{cp})}}{\sqrt{\text{c2}} \sqrt{\text{s1}}}+a\right)\right\}\right\}$

But then when I plug that expression into the original lefthand side of the equation I do not get zero

Simplify[
     1/(2 q r (-1 + c1 M s1)) (-a q + M q + b c1 q s0 + a c1 M q s1 - 
     c1 M^2 q s1 - 
     c2 M r s1 + \[Sqrt](4 q r (-1 + c1 M s1) (b (cp + c2 s0) + 
           c2 (a - M) M s1) + (b c1 q s0 - c1 M^2 q s1 + 
          a q (-1 + c1 M s1) + M (q - c2 r s1))^2)) /. 
     M -> 1/2 (a + Sqrt[4 b (cp + c2 s0) + a^2 c2 s1]/(
      Sqrt[c2] Sqrt[s1]))]

Not sure what is going on here. I've tried expanding the expression in the second piece of code before simplifying, but that unfortunately didn't help.

$\endgroup$
  • $\begingroup$ Related/duplicate: mathematica.stackexchange.com/questions/38363/… $\endgroup$ – Michael E2 Apr 25 '16 at 10:49
  • $\begingroup$ @MichaelE2 Thanks for pointing that out, it is probably a duplicate, but Szabolcs answer here is more thorough/complete than the one in the question you point to. $\endgroup$ – WetlabStudent Apr 25 '16 at 12:07
6
$\begingroup$

Solve provides generic solutions, as stated in the documentation under "Details". This means that when we have symbolic parameters, the solutions may not be valid for all values of those parameters. This must be the case for your equation too. But since your equation has so many parameters, it is very hard to see what is going on. Let us take a simpler example.

eq = Sqrt[1 - x^2] == b

How would you solve this by hand? You might decide to square both sides to obtain

1 - x^2 == b^2

then proceed to solve this second order equation as usual. And this is what Mathematica does.

sol = Solve[eq, x]
(* {{x -> -Sqrt[1 - b^2]}, {x -> Sqrt[1 - b^2]}} *)

Substituting back, we get

eq /. sol
(* {Sqrt[b^2] == b, Sqrt[b^2] == b} *)

which does not Simplify or FullSimplify to True. Why not? Because it is not valid for general complex b. For example it is not valid if b == -1. Indeed, in this case eq would have no solutions at all!

When we squared both sides of the equation, we lost equivalence. The squared equation may have more solutions than the original. For example the trivial x == 1 has one solution while its square x^2 == 1^2 has two, one of which is not valid for the original equation.

We can ask Mathematica to try to tell us under what conditions the solutions are valid, either by using Reduce or MaxExtraConditions.

Solve[eq, x, MaxExtraConditions -> All]

During evaluation of In[175]:= Solve::useq: The answer found by Solve contains equational condition(s) {0==b-Sqrt[b^2],0==b-Sqrt[b^2]}. A likely reason for this is that the solution set depends on branch cuts of Wolfram Language functions. >>

(* {{x -> 
   ConditionalExpression[-Sqrt[1 - b^2], -b + Sqrt[b^2] == 0]}, {x -> 
   ConditionalExpression[Sqrt[1 - b^2], -b + Sqrt[b^2] == 0]}} *)

But the result is not always practically useful. What you should do is first try to reduce the number of parameters in your equation manually, then think about what assumptions are reasonable for them. Are they all real? Are they all positive? Etc. Then use these assumptions when Simplifying after backsubstituion. In this simple case it would be

Simplify[eq /. sol, b > 0]
(* {True, True} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.