7
$\begingroup$

There seems to be some sort of bug in mathematica, where sometimes it will treat a quadratic equation as a quartic equation. For example:

Solve[c + b x + x^2 == 0, x, Assumptions -> b >= 0]

will output


{{x -> ConditionalExpression[
    Root[-Im[c]^2 + 
        b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 4 Re[c]) #1^2 + 
        8 b #1^3 + 4 #1^4 &, 1] - 
     I \[Sqrt](Re[c] + 
         b Root[-Im[c]^2 + 
             b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 
                4 Re[c]) #1^2 + 8 b #1^3 + 4 #1^4 &, 1] + 
         Root[-Im[c]^2 + 
            b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 
               4 Re[c]) #1^2 + 8 b #1^3 + 4 #1^4 &, 1]^2), 
    Im[c] < 0]}, {x -> 
   ConditionalExpression[
    Root[-Im[c]^2 + 
        b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 4 Re[c]) #1^2 + 
        8 b #1^3 + 4 #1^4 &, 1] + 
     I \[Sqrt](Re[c] + 
         b Root[-Im[c]^2 + 
             b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 
                4 Re[c]) #1^2 + 8 b #1^3 + 4 #1^4 &, 1] + 
         Root[-Im[c]^2 + 
            b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 
               4 Re[c]) #1^2 + 8 b #1^3 + 4 #1^4 &, 1]^2), 
    Im[c] > 0]}, {x -> 
   ConditionalExpression[
    Root[-Im[c]^2 + 
        b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 4 Re[c]) #1^2 + 
        8 b #1^3 + 4 #1^4 &, 2] - 
     I \[Sqrt](Re[c] + 
         b Root[-Im[c]^2 + 
             b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 
                4 Re[c]) #1^2 + 8 b #1^3 + 4 #1^4 &, 2] + 
         Root[-Im[c]^2 + 
            b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 
               4 Re[c]) #1^2 + 8 b #1^3 + 4 #1^4 &, 2]^2), 
    Im[c] > 0]}, {x -> 
   ConditionalExpression[
    Root[-Im[c]^2 + 
        b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 4 Re[c]) #1^2 + 
        8 b #1^3 + 4 #1^4 &, 2] + 
     I \[Sqrt](Re[c] + 
         b Root[-Im[c]^2 + 
             b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 
                4 Re[c]) #1^2 + 8 b #1^3 + 4 #1^4 &, 2] + 
         Root[-Im[c]^2 + 
            b^2 Re[c] + (b^3 + 4 b Re[c]) #1 + (5 b^2 + 
               4 Re[c]) #1^2 + 8 b #1^3 + 4 #1^4 &, 2]^2), 
    Im[c] < 0]}}

Any idea of what is going on here?

$\endgroup$
5
  • 2
    $\begingroup$ Mathematica assumes that all variables other than b are complex. If you are only looking for solutions associated with real variables, use Assuming[b >= 0, Solve[c + b x + x^2 == 0, x, Reals] // Simplify] $\endgroup$
    – Bob Hanlon
    Commented Oct 29, 2021 at 14:22
  • $\begingroup$ Well, c is complex, but this should still be solved by the quadratic formula $\endgroup$ Commented Oct 29, 2021 at 14:24
  • 4
    $\begingroup$ Please do not use the bugs tag for your own questions. Please see the tag description for an explanation. Please do assist in adding the tag to others' posts (once you have sufficient reputation score to do so). $\endgroup$
    – Szabolcs
    Commented Oct 29, 2021 at 14:26
  • 1
    $\begingroup$ This looks like an error to me. It implies that there is only a solution for Im[c] < 0 what is definitely wrong. Please report this to [email protected] and post their answer here. $\endgroup$ Commented Oct 29, 2021 at 16:21
  • $\begingroup$ @DanielHuber if you look closely they have both cases, they separate Im[c] < 0 from Im[c]> 0. It still looks like a mistake. I have emailed [email protected]. Will keep you posted. $\endgroup$ Commented Oct 29, 2021 at 16:50

1 Answer 1

7
$\begingroup$

This is effectively solving the system c + b x + x^2 == 0 && b >= 0, where x and c are complex and b is real. This gets converted to a system in 5 real variables {b, Re[c], Im[c], Re[x], Im[x]}. The system is solved using the cylindrical algebraic decomposition algorithm, which yields solutions for Re[x] and Im[x] with inequality conditions on b, Re[c], and Im[c].

Of course a human can easily see that the assumption makes no difference for the solutions of this specific equation. Solve has to add the assumption to the system, because it might make a difference, e.g.

In[4]:= Solve[(b-Abs[b]) x^2 + x == 1, x, Assumptions -> b >= 0]                
Out[4]= {{x -> 1}}
$\endgroup$
2
  • $\begingroup$ Should it not still be considered as bug given it is such an innefficient way to present the result? $\endgroup$ Commented Nov 12, 2021 at 14:15
  • $\begingroup$ @Filipe Miguel have you reported it to Wolfram Support & have they confirmed it as a bug? If not, then no, do not use the bugs tag. $\endgroup$ Commented Dec 20, 2021 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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