Quadratic equation solver
The b² − 4ac term under the square root decides everything. Positive gives two distinct real roots, zero gives one repeated root where the parabola just touches the axis, and negative gives a complex pair. Checking it first tells you what kind of answer to expect, and it is the fastest way to spot an arithmetic slip; a negative discriminant on a problem that should have real roots means a sign is wrong.
The quadratic formula gives x = (−b ± √(b² − 4ac)) ÷ 2a. For x² − 3x + 2, the discriminant is 1 and the roots are 2 and 1. A negative discriminant means the roots are a complex conjugate pair.
How to solve a quadratic
Completing the square is where the formula comes from, and it also gives the vertex directly. Writing ax² + bx + c as a(x + b∕2a)² + (c − b²∕4a) shows the turning point at x = −b∕2a immediately. That form is often more useful than the roots: for a projectile it gives the maximum height, and for an optimisation problem it gives the answer without needing calculus. The formula has one real failure mode and it is arithmetic rather than algebra. When b² dwarfs 4ac, −b and √(b² − 4ac) are almost equal, and subtracting two nearly equal numbers throws away most of the digits you had. Solve x² − 200,000x + 1 = 0 in ordinary double-precision and the small root comes back as 0.0000049999944 where it should be 0.0000050000000. Correct to about six significant figures where a double normally carries sixteen. This page uses the standard formula, so on coefficients that lopsided, take the larger root as reliable and recover the smaller one from the fact that the two must multiply to c∕a.
Questions
x = (−b ± √(b² − 4ac)) ÷ 2a.
Positive means two real roots, zero means one repeated root where the parabola touches the axis, negative means a complex pair.
It is not a quadratic: it is linear, and the single root is −c/b.
At x = −b∕2a, with y = c − b²∕4a. It is the turning point of the parabola.
They must add to −b∕a and multiply to c∕a. For 2x² − 7x + 3 the roots 3 and 0.5 sum to 3.5 and multiply to 1.5, which is exactly what the coefficients demand.
Almost always cancellation on the smaller root when b² is huge next to 4ac. It is a floating-point limit, not a disagreement about the maths.
Only when the roots are rational. The formula works for every quadratic.