Quadratic Equation Solver

Solve quadratic equations accurately, including the cases where the textbook formula silently loses precision and returns a badly wrong root.

Solve ax² + bx + c = 0

The textbook formula, side by side

Both answers substituted back into ax² + bx + c. A root gives zero; anything else does not.

Other forms

Why the answers can differ

  • The quadratic formula is not wrong — as algebra it is exact. As arithmetic on a computer it throws away accuracy whenever b squared is much bigger than 4ac, and it does so silently, reporting a confident answer that is badly out.
  • The reason is catastrophic cancellation. For x² + 10⁹x + 1 the discriminant is 10¹⁸ - 4, which a computer cannot tell apart from 10¹⁸, so its square root is exactly 10⁹ and the small root becomes (-10⁹ + 10⁹)/2 = 0. Substitute that back and you get 1. It is not nearly right; it is the wrong answer with a clean face.
  • The fix has been known for decades. Compute the root that adds two same-signed numbers instead of subtracting two nearly equal ones, then get the other from the fact that the roots multiply to c/a. No cancellation anywhere, and this page shows both answers side by side so you can see the difference rather than take it on trust.
  • Every root here is checked by substitution — put it back into ax² + bx + c and see what comes out. That number is shown. A root that does not give nearly zero is not a root, whatever formula produced it.
  • Most quadratics do not factor over the integers. Factoring works exactly when the discriminant is a perfect square, which is rare among coefficients picked at random, so this reports "does not factor" honestly rather than rounding something into a shape that looks tidy.
  • With a = 0 there is no quadratic to solve. It is a straight line, and dividing by 2a would be dividing by zero — so that case is named rather than computed.

How to use

  1. Enter the coefficients a, b and c.
  2. Read both roots, real or complex.
  3. Check the discriminant to see which case you are in.
  4. Compare the residual to confirm the roots are genuine.

Frequently asked questions

What does the discriminant tell you?

Which kind of roots to expect. Positive gives two distinct real roots, zero gives one repeated root, and negative gives a complex conjugate pair. It is the part under the square root in the standard formula, and its sign settles the shape of the answer before any arithmetic is done.

Why can the standard formula give a wrong answer?

Because of catastrophic cancellation. When b is large relative to a and c, one of the two roots is computed by subtracting two nearly equal numbers, and almost all the significant digits cancel. The surviving digits are rounding error, so the root can be wildly wrong or come back as exactly zero.

How is that avoided?

By computing the root that does not suffer cancellation, then obtaining the other from the fact that the two roots multiply to c divided by a. This calculator does that, which is why it returns a correct small root for an equation where the textbook formula returns zero.

Can I check a root myself?

Yes, and it is worth doing: substitute it back into the original equation and see how close the result is to zero. That leftover value is the residual, and a large one means the root is not really a root — which is precisely how the precision problem is detected.

What if a is zero?

Then it is not a quadratic but a linear equation, with a single root at minus c over b. Dividing by a in the standard formula would fail, so this case has to be handled separately rather than assumed away.

What are complex roots actually telling me?

That the parabola never crosses the horizontal axis. They are perfectly real answers in the sense of being correct and useful — in electrical engineering and control theory, complex roots describe oscillation, and their imaginary part gives its frequency.

🔒 This tool runs entirely in your browser. Nothing you enter is uploaded, logged, or stored.