About this calculator
A quadratic equation ax² + bx + c = 0 has two roots, which may be real and different, one repeated real root, or a pair of complex roots. The discriminant D = b² − 4ac tells which. The graph of y = ax² + bx + c is a parabola: the real roots are where it crosses the x-axis and the vertex is its lowest (a > 0) or highest (a < 0) point.
Formula
x = (−b ± √D) ÷ 2a, D = b² − 4ac
To avoid losing digits when b² is much larger than 4ac, the calculator uses the equivalent stable form q = −(b + sign(b)√D) ÷ 2, x₁ = q ÷ a, x₂ = c ÷ q.
D < 0: x = −b/2a ± i √(−D)/2|a| Vertex: (−b/2a, c − b²/4a)
Worked example
x² − 3x − 10 = 0 (a = 1, b = −3, c = −10):
- D = 9 + 40 = 49, √D = 7
- x = (3 ± 7) ÷ 2 → x₁ = −2, x₂ = 5; factored: (x + 2)(x − 5)
- Vertex (1.5, −12.25)
x² + 2x + 5 = 0 gives D = −16 → x = −1 ± 2i.
Assumptions and limitations
- Real coefficients a, b and c; a must not be zero.
- A discriminant within 10⁻¹⁴ of zero, relative to the size of b² and 4ac, is treated as zero (a double root), because rounding cannot tell such values apart.
- D itself is computed as b² − 4ac in double precision; for nearly equal roots of very large coefficients the last digits can be uncertain.
References
- Press, W. H. et al. Numerical Recipes, 3rd ed., §5.6 — quadratic and cubic equations (stable formula).
- Higham, N. J. Accuracy and Stability of Numerical Algorithms — cancellation in the quadratic formula.
