# Solving quadratic equations bug in Mathematica 12.3

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?

• 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] Commented Oct 29, 2021 at 14:22
• Well, c is complex, but this should still be solved by the quadratic formula Commented Oct 29, 2021 at 14:24
• 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). Commented Oct 29, 2021 at 14:26
• 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. Commented Oct 29, 2021 at 16:21
• @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. Commented Oct 29, 2021 at 16:50

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}}
• Should it not still be considered as bug given it is such an innefficient way to present the result? Commented Nov 12, 2021 at 14:15
• @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. Commented Dec 20, 2021 at 7:52