Skip to content

Quadratic Equation Solver

Solve ax² + bx + c = 0: discriminant, real or complex roots, with every step shown.

How it works

Work out the discriminant D = b² − 4ac first. Its sign decides the kind of roots: positive gives two real roots, zero gives one repeated root, negative gives a pair of complex roots. Then put a, b and D into the quadratic formula.

D = b² − 4ac x = (−b ± √D) / 2a Complex roots: x = p ± qi, p = −b / 2a, q = √(−D) / 2|a|

Example

x² − 5x + 6 = 0 has a = 1, b = −5, c = 6. D = (−5)² − 4 × 1 × 6 = 25 − 24 = 1. x = (5 ± √1) / 2, so x = 3 or x = 2.

Common mistakes

  • Dropping the sign of b. In x² − 5x + 6 = 0, b is −5, so −b is +5, not −5.
  • Dividing only the square root by 2a. The whole numerator, −b ± √D, is divided by 2a.
  • Applying the formula when a = 0. Then there is no x² term and the equation is linear: x = −c / b.

About this calculator

Enter the coefficients a, b and c (decimals and negatives are fine). The calculator works out the discriminant D = b² − 4ac, tells you whether the equation has two real roots, one repeated root or two complex roots, and gives the roots with your numbers substituted into the quadratic formula.

Complex roots are written as p ± qi. If a is 0 the equation is no longer quadratic, so the tool solves the linear equation bx + c = 0 instead, and says when every x or no x works. Roots are computed in double precision and shown to up to 6 decimal places, so irrational roots such as √2 are rounded on screen.

Frequently asked questions

What does the discriminant tell me?

The discriminant D = b² − 4ac decides the type of roots. If D is positive there are two different real roots, if D is zero there is one repeated real root, and if D is negative there are two complex roots that are conjugates of each other.

How are complex roots shown?

As p ± qi, where p = −b / 2a is the real part and q = √(−D) / 2|a| is the imaginary part. For x² + 2x + 5 = 0, D = 4 − 20 = −16, so p = −1 and q = 4 / 2 = 2, giving −1 ± 2i.

What happens if a is 0?

The equation becomes bx + c = 0. If b is not 0 the solution is x = −c / b. If b and c are both 0, every x is a solution. If b is 0 and c is not, there is no solution.

Why does it sometimes report a repeated root when D is not exactly 0?

Decimal inputs are not stored exactly by computers, so b² − 4ac can come out as 0.000000000000000007 when it is really 0. The tool treats D as 0 when it is smaller than a few parts in 10¹⁵ of b² and 4ac, which only happens when the difference is rounding error.

Are the roots exact?

They are calculated in double precision (about 15 significant digits) and shown to up to 6 decimal places. Whole-number and simple decimal roots, such as 2 and 3 for x² − 5x + 6, come out clean. Irrational roots are rounded on screen: x² − 2 = 0 shows ±1.414214.