Quadratic Equation Calculator
Solve ax²+bx+c=0.
Formula
x = [-b±√(b²-4ac)]/2a
Example
x²-5x+6=0 → x=3, x=2.
Embed this calculator on your site
Add this free calculator to your own website with one line of code. The embedded version is responsive, ad-free, and includes a small attribution link back to CalcNest AI.
<iframe src="https://calcnestai.com/embed/quadratic-equation-calculator.html" width="100%" height="700" frameborder="0" style="border: 1px solid #e5e5e5; border-radius: 12px; max-width: 720px;" loading="lazy" title="Quadratic Equation Calculator — Free Tool by CalcNest AI"></iframe>
Understanding the Quadratic Equation Calculator
A quadratic solver applies the formula to find roots and reports the discriminant. The discriminant is the informative part, because its sign tells you how many real roots exist before any square root is taken.
How it actually works
Enter coefficients a, b, and c. The calculator computes the discriminant, then applies the quadratic formula when it is non-negative. Coefficients 1, −5, and 6 give roots of 3 and 2.
| b² − 4ac | Roots |
|---|---|
| Positive | Two distinct real roots |
| Zero | One repeated real root |
| Negative | Two complex conjugate roots |
| a = 0 | Not quadratic, solve as linear |
The deeper context most people miss
A negative discriminant does not mean there are no solutions, only no real ones. The two complex roots are conjugates, mirror images across the real axis, which is always true for polynomials with real coefficients and is why complex roots always arrive in pairs.
Why the formula is numerically dangerous
The quadratic formula is algebraically exact and can lose almost all precision in floating point. The problem arises when b squared is much larger than 4ac, making the square root of the discriminant very close to the absolute value of b. One of the two roots then involves subtracting nearly equal quantities, which is catastrophic cancellation: the leading digits agree and cancel, leaving a result determined by the least significant and least reliable bits. A concrete case makes it stark: for coefficients 1, 200, and minus 0.000015, the root computed by the naive formula can be wrong in most of its significant digits while the other root is computed accurately. The standard remedy uses the relationship that the product of the roots equals c over a. Compute the root that involves addition rather than subtraction, which is numerically safe, then obtain the second root by division rather than by the formula. Choosing which form to use based on the sign of b is what robust implementations do, and it costs nothing. This is one of the clearest examples of a formula being correct as mathematics and wrong as an algorithm, and it appears in numerical analysis courses precisely because the failure is so complete and so easy to miss: the code produces a plausible number rather than an error.
A worked example: what the roots mean geometrically
Roots of 2 and 3 for the coefficients 1, −5, 6 are where the parabola crosses the horizontal axis, and the vertex sits midway between them at 2.5, since a parabola is symmetric about its axis. That relationship holds generally: the sum of the roots is minus b over a and their product is c over a, results known as Vieta's formulas, and they provide a quick check on any solution since the sum and product of computed roots should match. They also allow constructing a quadratic with specified roots without expanding, which is convenient. Factoring is the alternative route to the same answer and works when the roots are rational, and completing the square is the method the formula itself derives from, which is worth doing once since it explains why the formula has the shape it does: the vertex plus or minus the distance to the roots. When the discriminant is negative the parabola never reaches the axis, sitting entirely above or below depending on the sign of a, and the complex roots still carry meaning in applications, describing oscillation rather than crossing. In a damped oscillator, real roots mean the system returns to equilibrium without overshooting while complex roots mean it oscillates, so the discriminant's sign determines the qualitative physical behaviour.
Deciding how to solve in practice
Method choice depends on context. Factoring is fastest when it works and is worth attempting first for small integer coefficients, since spotting that a quadratic factors saves the arithmetic entirely. Completing the square gives the vertex directly and is preferable when the extremum matters more than the roots. The formula always works and should be implemented carefully as described. Numerical root finding including Newton's method generalises to higher degrees where no formula exists. For higher polynomials, cubic and quartic equations have closed-form solutions that are considerably more complicated and rarely used in practice, and degree five and above have no general algebraic solution, which Abel proved and Galois explained through the structure of permutation groups, founding a whole field in the process. That result is worth knowing because it is a rare case of mathematics proving something cannot be done rather than failing to do it. In applications, quadratics appear in projectile motion, optimisation with a single variable, circuit resonance, and anywhere a second-order relationship arises, and the discriminant frequently answers the practical question directly: whether a projectile reaches a target, whether a system oscillates, or whether two objects collide.
Where the formula came from
Methods for solving quadratics predate the algebraic notation used to express them by millennia. Babylonian tablets from around 2000 BC contain procedures equivalent to completing the square, stated as recipes for specific numerical problems since symbolic algebra did not exist. Greek mathematicians treated the problem geometrically, with Euclid's approach constructing lengths rather than manipulating symbols. Brahmagupta in seventh-century India gave an explicit rule covering negative numbers, which Greek treatments avoided since negative lengths were meaningless. Al-Khwarizmi's ninth-century work systematised solution methods and gave algebra its name, from the term for the operation of restoring balance to an equation, and his classification into cases was necessary because negative coefficients were still not accepted. The modern single formula covering all cases required accepting negative and complex numbers, which took until the sixteenth and seventeenth centuries, with complex roots being regarded as fictitious long after they proved useful. The lesson embedded in that history is that mathematical progress frequently consists of accepting objects that seem illegitimate: negative numbers, irrationals, and complex numbers each faced resistance, and each turned out to simplify rather than complicate the subject once accepted.
Variations: higher degrees, systems, and special cases
Cubic equations have a closed-form solution discovered in sixteenth-century Italy amid a well-documented priority dispute involving Tartaglia and Cardano, and it requires complex numbers even when all roots are real, which was the historical motivation for taking them seriously. Quartics have a solution reducing to a cubic. Degree five and above have no general radical solution. Systems of quadratics arise in geometry, including finding intersections of circles and lines, which is what ray tracing and collision detection compute. Quadratic forms in several variables are represented by matrices and classified by eigenvalue signs. Quadratic programming optimises quadratic objectives under linear constraints and has efficient algorithms. Diophantine quadratics seek integer solutions and connect to number theory, with Pell's equation being a classical case. In modular arithmetic, quadratic residues determine which numbers have square roots modulo a prime and underlie several cryptographic constructions. For computation, library routines handle the numerical issues and should be preferred, particularly since the naive formula's failure mode produces plausible wrong answers rather than obvious errors.
Solving quadratics reliably
Check the discriminant first, since its sign tells you how many real roots exist before any square root is attempted. Confirm that a is non-zero, since a zero leading coefficient makes the equation linear and the formula divides by zero. Use the numerically stable form in code, computing the root involving addition and obtaining the other from the product relationship c over a, which avoids catastrophic cancellation when b squared far exceeds 4ac. Verify solutions against Vieta's formulas, checking that the roots sum to minus b over a and multiply to c over a. Try factoring first for small integer coefficients, which is faster when it works. Complete the square when the vertex matters more than the roots. Remember that a negative discriminant gives complex conjugate roots rather than no solution, and that those roots describe oscillation in physical applications. Use library routines rather than a hand-coded formula, since the naive implementation fails silently with plausible wrong answers. And note that no general algebraic solution exists for degree five and above, so numerical methods are necessary there.
What people get wrong
- Implementing the quadratic formula naively, which suffers catastrophic cancellation when b² far exceeds 4ac and returns a plausible but badly wrong root.
- Reading a negative discriminant as no solution, when it gives two complex conjugate roots that carry real meaning in oscillation and circuit problems.
- Applying the formula without checking that a is non-zero, when a zero leading coefficient makes the equation linear and the formula divides by zero.
- Expecting a general formula for higher degree polynomials, when Abel and Galois proved none exists in radicals for degree five and above.
Where the math comes from
For ax² + bx + c = 0 with a ≠ 0, the roots are (−b ± √(b² − 4ac)) / 2a. The discriminant b² − 4ac determines the nature of the roots: positive gives two real, zero gives one repeated, and negative gives two complex conjugates. Vieta's formulas give the sum of roots as −b/a and their product as c/a.
Questions and answers
How do I check my answer?
Plug the answer back into the original equation. If both sides match, the answer is correct. This works for any algebraic problem.
Can the calculator handle complex roots?
Most basic calculators handle real roots only. Complex roots (when discriminant is negative for quadratics) require a complex-number-aware calculator.
What if the equation has no solution?
Some equations have no real solutions. The calculator should indicate this rather than returning nonsense. If it does not, try simplifying the equation first.
How do I solve systems of equations?
Substitution, elimination, or matrix methods. Two-equation, two-unknown systems are simplest; larger systems need matrix calculators.
Is there one method that always works?
For polynomials up to degree 4, yes - the quadratic, cubic, and quartic formulas. Degree 5+ generally requires numerical methods. For most real-world problems, factoring, formula, or graphing handles everything.
What does the discriminant tell me?
How many real roots exist, before any square root is taken. Positive gives two distinct real roots, zero gives one repeated root where the parabola touches the axis, and negative gives two complex conjugates where the parabola never reaches it.
Is a negative discriminant a problem?
Not mathematically. It means the roots are complex conjugates rather than real, and they carry meaning in applications: in a damped oscillator, complex roots mean the system oscillates while real roots mean it returns to equilibrium without overshooting.
Why is the quadratic formula dangerous in code?
Because when b² far exceeds 4ac, the square root of the discriminant nearly equals the absolute value of b, so one root involves subtracting nearly equal numbers. That cancellation destroys precision and returns a plausible but badly wrong value.
How do I compute roots stably?
Compute the root whose formula involves addition rather than subtraction, which is numerically safe, then get the other from the product relationship: the roots multiply to c over a. Choosing the form by the sign of b is what robust implementations do.
How can I check my answers?
With Vieta's formulas: the roots should sum to minus b over a and multiply to c over a. It's a quick verification that catches sign errors and arithmetic slips without redoing the calculation.
What if a is zero?
The equation is linear rather than quadratic, and the formula divides by zero. Solve it as bx + c = 0 instead. Checking for this case is necessary in any implementation since the coefficient may come from a calculation.
Do higher degree equations have formulas?
Cubics and quartics do, discovered in sixteenth-century Italy and considerably more complicated. Degree five and above have no general solution in radicals, which Abel proved and Galois explained through the structure of permutation groups.
Related calculators
Absolute Value Equation · Polynomial Evaluation · Matrix 3x3 Determinant · Linear Regression · Matrix Addition