Quadratic Formula Calculator
Both roots of ax² + bx + c = 0 — real and distinct, one repeated, or a complex conjugate pair — with the discriminant that decides which, the vertex, the axis of symmetry, and the factored form. Solved with the numerically stable version of the formula, so the small root is as accurate as the large one.
Solve ax² + bx + c = 0
What multiplies x². It sets which way the parabola opens — upwards when positive, downwards when negative — and it cannot be zero.
What multiplies x. Together with a it fixes the axis of symmetry at x = −b ÷ 2a. Enter 0 if the equation has no x term.
The term with no x. It is also the y-intercept: put x = 0 into the equation and c is all that is left.
For x² - 3x + 2 = 0 the discriminant b² − 4ac is 1 — positive, so the parabola crosses the x-axis at two separate points. The vertex sits at (1.5, -0.25).
- Discriminant (b² − 4ac)
- 1
- Nature of the roots
- Two distinct real roots
- Root x₁
- 2
- Root x₂
- 1
- Vertex
- (1.5, -0.25)
- Axis of symmetry
- x = 1.5
- y-intercept
- (0, 2)
- Factored form
- (x - 2)(x - 1)
The formula, where it comes from, and why the textbook version is not the one to compute with
A quadratic has at most two roots, and one expression finds both. What that expression does not tell you is that only one of the two signs is safe to evaluate directly.
x = (−b ± √(b² − 4ac)) ÷ 2a • D = b² − 4ac • vertex = (−b ÷ 2a, −D ÷ 4a)- a, b, c
- The coefficients of x², x and the constant term. a cannot be zero
- D
- The discriminant — positive, zero or negative gives two roots, one, or a complex pair
- −b ÷ 2a
- The axis of symmetry, and the x-coordinate of the vertex
Completing the square, once, in general
The formula is not a rule handed down; it is one worked example done with letters. Take ax² + bx + c = 0, divide through by a, and move the constant to the right: x² + (b/a)x = −c/a. The left-hand side is one term short of a perfect square, and the missing term is (b/2a)², so add it to both sides. The left becomes (x + b/2a)² and the right becomes (b² − 4ac) ÷ 4a².
Take the square root of both sides — remembering that a square has two roots, which is where the ± comes from — and subtract b/2a. That is the quadratic formula, and the derivation hands you the vertex on the way past: written as a(x + b/2a)² − D/4a, the expression is smallest when the bracket is zero, at x = −b/2a, where its value is −D/4a.
What the discriminant tells you before you solve
D = b² − 4ac is worth computing first, because it settles the shape of the answer on its own. Positive: two distinct real roots, a parabola crossing the axis twice. Zero: one repeated root, sitting exactly at the vertex. Negative: no real roots, and a complex conjugate pair either side of the axis of symmetry. And if a, b and c are integers and D is a perfect square, the roots are rational and the quadratic factors over the integers — 25 for x² − 3x − 4 means you could have spotted (x − 4)(x + 1) without the formula.
Why the textbook formula gets one of the two roots badly wrong
This is the part almost no quadratic calculator mentions, and it is the reason this one computes the roots the way it does.
When b² is much larger than 4ac, √(b² − 4ac) is very nearly |b|. One of the two roots is then found by subtracting two numbers that agree in almost every digit. The digits they share cancel to nothing, and the answer is rebuilt out of whatever was left in the last few bits — which is rounding error, not arithmetic. The name for this is catastrophic cancellation, and it does not announce itself: every individual step looks fine.
The fix is to never do that subtraction. Compute instead
q = −(b + sign(b)·√(b² − 4ac)) ÷ 2 • x₁ = q ÷ a • x₂ = c ÷ q- sign(b)
- +1 when b is positive, −1 when negative — so the two terms always add
- x₂ = c ÷ q
- From Vieta's relation x₁x₂ = c/a: a division, where the textbook has a subtraction
Because sign(b) matches the sign of b, the bracket adds two same-signed quantities and nothing can cancel. The second root then comes from the product of the roots rather than the formula, turning the dangerous step into a division that is accurate to within one rounding. The extra cost is a single sign test.
x² − 3x + 2 = 0, and then a nastier one
Start with the default above. Here a = 1, b = −3 and c = 2, so the discriminant is (−3)² − 4 × 1 × 2 = 9 − 8 = 1. Positive, so expect two distinct real roots — and a perfect square, so expect them to be rational.
The square root of 1 is 1. The stable route gives q = −(−3 + (−1) × 1) ÷ 2 = 2, so x₁ = q ÷ a = 2 and x₂ = c ÷ q = 2 ÷ 2 = 1. The vertex sits at x = −b ÷ 2a = 1.5, where y = −D ÷ 4a = −0.25, and the y-intercept is c = 2. In factored form: (x − 2)(x − 1). Everything checks: the roots multiply to 2, which is c/a, and add to 3, which is −b/a.
Where the textbook formula visibly fails
Now try a = 1, b = 100000000, c = 1 in the calculator above — the equation x² + 10⁸x + 1 = 0. The discriminant is 10¹⁶ − 4 = 9,999,999,999,999,996, and its square root is 99,999,999.99999999. Notice how close that is to b.
The textbook formula computes the small root as (−10⁸ + 99,999,999.99999999) ÷ 2. Those two numbers agree to fifteen digits. In double precision their difference comes out as 1.4901161193847656e−8 — which is exactly 2⁻²⁶, and a result that lands on a clean power of two is a result assembled from a handful of surviving bits. Halved, the root is −7.450580596923828e−9.
The true small root is −1e−8. The textbook answer is 25.5% too small. And you can see it is wrong without knowing the right answer: substitute it back into x² + 10⁸x + 1 and you get 0.2549, when a root should give zero. Substitute −1e−8 and you get 1.1e−16, which is zero to the limit of the format.
The stable route never subtracts. Since b is positive, q = −(10⁸ + 99,999,999.99999999) ÷ 2 = −100,000,000, so the large root is q ÷ a = −100,000,000 and the small one is c ÷ q = 1 ÷ −100,000,000 = −1e−8. Same formula, same inputs, one root that is right and one that is not — and the difference is which order you do the arithmetic in.
What this calculator assumes
- a is not zero. With no x² term the equation is linear, and the formula would divide by zero — so it is refused, with the linear root named in the message.
- Coefficients run from −1,000,000,000 to 1,000,000,000. That is a display and precision limit rather than a mathematical one.
- Results are rounded to twelve significant figures, not to a fixed number of decimal places. The roots of one equation can span many orders of magnitude — 1e−8 and 1e8 in the example above — and two decimal places would print the interesting one as zero.
- The discriminant is computed as b² − 4ac in double precision. It has a cancellation problem of its own when b² and 4ac are nearly equal, which a fused multiply-add or extended precision would fix; this tool does not. In practice it shows up as a root that is very nearly repeated being reported as two distinct roots that agree to eleven digits.
- Roots are listed largest first. That is a display choice, not mathematics: the ± ordering in the textbook formula flips with the sign of b, and a result that reorders itself as you type would be worse.
- Complex roots are reported as a shared real part and one imaginary magnitude, because a conjugate pair carries no more information than that.
Quadratic formula FAQ
What does the discriminant tell you before you solve?
Everything about the shape of the answer, from one subtraction. The discriminant is b² − 4ac, and it is the quantity under the square root in the formula. Positive means two distinct real roots and a parabola that crosses the x-axis twice. Exactly zero means one repeated root, and a parabola that touches the axis at its vertex and turns away. Negative means no real roots at all — the parabola misses the axis entirely — and the two solutions are a complex conjugate pair. If the coefficients are whole numbers and the discriminant is a perfect square, you also know the roots are rational and the quadratic factors neatly over the integers, which is worth checking before reaching for the formula at all.
Where does the quadratic formula actually come from?
Completing the square, done once in general instead of once per problem. Start with ax² + bx + c = 0, divide through by a, and move the constant across: x² + (b/a)x = −c/a. The left side is almost a perfect square — it needs (b/2a)², so add that to both sides. Now the left is (x + b/2a)² and the right is (b² − 4ac)/4a². Take the square root of both sides, remembering it can be positive or negative, and subtract b/2a. What is left is x = (−b ± √(b² − 4ac)) ÷ 2a. Every quadratic you have ever solved by completing the square was re-deriving this.
What do complex roots mean if the parabola never crosses the axis?
They mean the equation has no solution among the real numbers, but two among the complex ones — and they always arrive as a conjugate pair, a + bi and a − bi, because the only thing separating them is the sign in front of the square root. Geometrically the real part is still the axis of symmetry: the pair sits symmetrically either side of the vertex, just off the real line. They are not a failure state. For a spring or a circuit, a complex pair is the algebra reporting oscillation rather than decay, and the imaginary part is the frequency of it.
Why does this calculator use a different formula for the second root?
Because the textbook formula computes one of the two roots by subtracting numbers that are nearly equal, and when b² is much larger than 4ac they are equal to within a rounding error. All the leading digits cancel and the answer is assembled from the few bits that were left underneath. For x² + 100000000x + 1 = 0 the textbook route returns −7.450580596923828e−9 for the small root when the true value is −1e−8: a 25% error, and the wrong answer is exactly 2⁻²⁷, which is the fingerprint of a result built from a handful of surviving bits. This page computes q = −(b + sign(b)·√(b² − 4ac)) ÷ 2, which only ever adds same-signed numbers, and takes the roots as q/a and c/q. Both come out accurate to full precision.
What happens if a is zero?
Then it is not a quadratic. With no x² term the equation collapses to bx + c = 0, a straight line with exactly one root at x = −c/b, and the formula does not apply — it would divide by 2a, which is zero. This calculator refuses a = 0 rather than returning something, but the error message works out the linear root for you, because someone who typed zero for a almost certainly wants that number rather than a lecture. If b is also zero, there is no x anywhere in the equation and it is either always true or never true, depending on c.
Why is the vertex at x = −b ÷ 2a?
It falls out of completing the square, which is why the derivation is worth doing once. Rewriting ax² + bx + c as a(x + b/2a)² − (b² − 4ac)/4a puts the whole expression in terms of a single squared bracket. A square is never negative, so the smallest that term can be is zero, which happens when x = −b/2a — and at that point the expression equals −(b² − 4ac)/4a. That is the vertex, and it is a minimum when a is positive and a maximum when a is negative. It is also the midpoint of the two roots, which is why the same number is the axis of symmetry.
Sources and review notes
- NIST Digital Library of Mathematical Functions §1.11 — algebraic equations, including the quadratic and its discriminant
- David Goldberg, “What Every Computer Scientist Should Know About Floating-Point Arithmetic”, ACM Computing Surveys 23(1), 1991 — the standard reference on catastrophic cancellation, which uses the quadratic formula as its example
- IEEE 754-2019 — the binary floating-point arithmetic every figure on this page is computed in
The algebra here is definitional and cannot go stale; the arithmetic can. The engine behind this page is a pure function under unit test, and one of those tests exists specifically to fail if the naive form of the formula is ever substituted back in — it pins the small root of x² + 10⁸x + 1 to −1e−8 and checks that the value satisfies the equation.