Quadratic Equation Solver
ax² + bx + c = 0
Try an example
Solutions
x₁ = 3.0000
x₂ = 2.0000
Δ = 1.0000
Step-by-step solution
1. a=1, b=-5, c=6
2. Discriminant Δ = b² − 4ac = -5² − 4(1)(6) = 1.0000
3. x = [−b ± √Δ] / 2a = [−(-5) ± √1.0000] / 2 → x₁=3.0000, x₂=2.0000
About the Quadratic Equation Solver
A quadratic equation is any equation that can be written as ax² + bx + c = 0 with a ≠ 0. Its solutions — the roots — are the values of x that make the expression equal zero. Graphically they are the points where the parabola y = ax² + bx + c crosses the horizontal axis, which is why a quadratic has at most two real solutions: a parabola can cross a line at most twice.
The quadratic formula solves every case, which is unusual and worth appreciating. Factoring is faster when it works but only works on equations with tidy rational roots. Completing the square always works but is laborious. The formula is completing the square done once, in general, so the algebra never has to be repeated.
The most useful part is often not the roots themselves but the discriminant, b² − 4ac. It sits under the square root and its sign alone tells you how many real solutions exist, before you compute anything. In applied work — projectile ranges, break-even points, circuit resonance, collision detection — the question is frequently "does a solution exist at all," and the discriminant answers it in one subtraction.
Formula
x = [ −b ± √(b² − 4ac) ] / 2a
- a
- Coefficient of x². Must be non-zero, or the equation is linear rather than quadratic
- b
- Coefficient of x
- c
- The constant term
- b² − 4ac
- The discriminant, usually written Δ — determines the nature of the roots
The ± sign is what produces two roots. Adding the square root gives one solution, subtracting it gives the other. When the discriminant is zero both branches collapse to the same value, −b / 2a.
That value, −b / 2a, is also the x-coordinate of the parabola's vertex. This follows from symmetry: a parabola is a mirror image about its vertex, so the two roots must be equally spaced either side of it. The square root term is exactly that half-distance.
The formula derives from completing the square on the general form. Divide through by a, move c/a to the right, add (b/2a)² to both sides to form a perfect square, then take the square root. Every step is reversible, which is why the formula finds all solutions and never introduces spurious ones.
Worked Examples
Two distinct real roots: 2x² + 5x − 3 = 0
A positive discriminant, giving two places where the parabola crosses the axis.
Result: x = 0.5 and x = −3
The discriminant was a perfect square (49), which is exactly the condition for rational roots. That means this equation also factors cleanly as (2x − 1)(x + 3) = 0 — a useful shortcut to spot.
One repeated root: x² − 6x + 9 = 0
A zero discriminant. The parabola touches the axis at a single point rather than crossing it.
Result: x = 3, a repeated root with multiplicity two
The vertex sits exactly on the x-axis, so this is the boundary between two real roots and none. In applied problems a zero discriminant usually marks a critical threshold — the launch angle that just reaches a target, or the damping value at which oscillation stops.
No real roots: x² + 2x + 5 = 0
A negative discriminant. The parabola sits entirely above the axis and never crosses it.
Result: x = −1 + 2i and x = −1 − 2i — a complex conjugate pair
Complex roots always arrive in conjugate pairs when the coefficients are real. Whether this counts as "no solution" depends on the problem: for a physical distance it does, but in electrical engineering and signal processing complex roots describe oscillation and are the point of the exercise.
How to Use the Result
Reading the discriminant
Computing Δ = b² − 4ac first tells you what kind of answer to expect, and takes one line:
- —Δ > 0 — two distinct real roots. The parabola crosses the x-axis twice.
- —Δ = 0 — one real root, repeated. The vertex touches the axis.
- —Δ < 0 — no real roots; two complex conjugate roots. The parabola misses the axis entirely.
- —Δ > 0 and a perfect square, with integer coefficients — the roots are rational, so the equation factors without fractions.
Vieta's formulas as a check
For any quadratic, the sum of the roots equals −b/a and their product equals c/a. This gives a fast verification that catches most sign errors without re-running the formula.
Testing the first example: roots 0.5 and −3 sum to −2.5, and −b/a = −5/2 = −2.5 ✓. Their product is −1.5, and c/a = −3/2 = −1.5 ✓.
The same relationships work in reverse. If you need a quadratic with roots 4 and −7, the sum is −3 and the product is −28, so x² + 3x − 28 = 0. This is often quicker than expanding the factored form.
Where quadratics show up in practice
The pattern appears whenever a quantity depends on the square of another — which, because of constant acceleration and area relationships, is extremely often:
- —Projectile motion. Height under gravity is h = −4.9t² + v₀t + h₀, so solving for h = 0 gives the flight time. Two roots appear because the algebra also finds the time before launch when the trajectory would have been at ground level.
- —Break-even analysis. Profit as a function of price is typically quadratic, since revenue is price times quantity and quantity falls with price. The two roots bracket the profitable price range and the vertex is the optimum.
- —Geometry and construction. Any problem fixing an area while varying a dimension produces a quadratic — a rectangular garden of known area with a fixed length of fencing, for instance.
- —Optics and electronics. Lens equations and RLC circuit responses are quadratic; the discriminant distinguishes overdamped, critically damped and underdamped behaviour.
Edge Cases and Common Mistakes
If a = 0 it is not a quadratic
With a = 0 the formula divides by zero. The equation has degenerated into the linear bx + c = 0, whose single solution is x = −c/b. Always check a before applying the formula — this is the most common cause of an unexpected error, and it happens easily when a is computed from other inputs rather than typed in.
Catastrophic cancellation with large b
When b² is much larger than 4ac, √Δ is very close to |b|, and one of the two branches subtracts two nearly equal numbers. In floating-point arithmetic that root loses most of its significant digits.
The numerically stable approach computes the well-conditioned root first, then obtains the other from the product relationship x₁x₂ = c/a. For x² + 10⁸x + 1 = 0, the naive formula returns 0 for the small root while the stable method correctly returns about −10⁻⁸.
Extraneous roots from the original problem
The formula returns every mathematical solution, but the problem may not accept both. A negative time, a negative length, or a price below cost is arithmetically valid and physically meaningless. Always test each root against the constraints of the situation before reporting it.
Roots that look irrational but are not
A discriminant of 48 gives √48 = 4√3, which is irrational. But a discriminant of 2.25 gives 1.5, and one of 0.0625 gives 0.25 — decimal coefficients can still produce clean roots. Do not assume a non-integer discriminant means an untidy answer.
Frequently Asked Questions
When should I factor instead of using the formula?
Factor when the discriminant is a small perfect square and the coefficients are integers — it is faster and less error-prone. Use the formula in every other case. Checking b² − 4ac first tells you which situation you are in before committing to either route.
What does it mean when there are no real roots?
The parabola never reaches the x-axis. If a > 0 the whole curve sits above it, so the expression is always positive; if a < 0 it sits below and the expression is always negative. In an applied problem this normally means the target condition is unreachable — the projectile never gets that high, the price never breaks even.
How do I find the vertex and the maximum or minimum?
The vertex is at x = −b / 2a, and substituting that back gives the y-value. If a > 0 the parabola opens upward and the vertex is the minimum; if a < 0 it opens downward and the vertex is the maximum. This is how quadratics are used for optimisation without calculus.
Can a quadratic have more than two roots?
No. The fundamental theorem of algebra guarantees a degree-two polynomial has exactly two roots counted with multiplicity, over the complex numbers. A repeated root counts as two, and complex roots come in pairs, so the total is always exactly two.
What does completing the square give me that the formula does not?
Vertex form, a(x − h)² + k, which shows the vertex at (h, k) directly and makes graphing and transformations obvious. The formula gives roots efficiently; completing the square gives structure. They are the same algebra stopped at different points.
Why do complex roots always come in pairs?
Because the coefficients are real. The only source of a complex value is √Δ when Δ is negative, and the ± produces one root with +i and one with −i. If the coefficients were themselves complex, the roots would not need to be conjugates.