The formula
This solves for any .
Where it comes from
The method is called completing the square. Start with the equation and divide through by :
The left side is almost a perfect square. expands to , so add to both sides:
Take the square root of both sides, remembering it can be positive or negative, then subtract . That gives the quadratic formula.
The discriminant is the part under the root, and it decides what kind of answer you get:
- : two real roots. The parabola crosses the x-axis twice.
- : one repeated root. The parabola just touches the axis.
- : two complex roots. The parabola never reaches the axis.
The vertex, the parabola’s turning point, sits halfway between the roots, at .
Worked example
, so , , :
Watch out for
- Signs. means flip the sign of . With , .
- Rounding errors on computers. When is much larger than , subtracting nearly equal numbers loses precision. This calculator uses the rearranged form from Numerical Recipes to avoid it.
Sources
- Press, W. H. et al. Numerical Recipes, 3rd edition (2007), section 5.6 "Quadratic and Cubic Equations"
Last checked