Quadratic Equation Solver: How It Works
A quadratic equation has the form ax² + bx + c = 0, and every one of them can be solved by the same formula. What varies is how many real solutions exist — and the discriminant tells you that before you finish the calculation.
The formula
x = [ −b ± √(b² − 4ac) ] ÷ 2a
The expression under the root, b² − 4ac, is the discriminant. It determines the nature of the solutions before you compute them:
| Discriminant | Solutions | Graph |
|---|---|---|
| Positive | Two distinct real roots | Crosses the x-axis twice |
| Zero | One repeated real root | Touches the x-axis once |
| Negative | Two complex conjugate roots | Never touches the x-axis |
Worked example
Solve 2x² − 7x + 3 = 0. Here a = 2, b = −7, c = 3.
- Discriminant = (−7)² − 4(2)(3) = 49 − 24 = 25 — positive, so two real roots.
- √25 = 5
- x = (7 + 5) ÷ 4 = 3 and x = (7 − 5) ÷ 4 = 0.5
Check by substitution: 2(9) − 7(3) + 3 = 18 − 21 + 3 = 0. ✓
Other methods, and when they are faster
- Factoring. If you can spot two numbers multiplying to ac and summing to b, factoring is quicker. It only works cleanly for rational roots.
- Completing the square. Slower, but it converts the equation to vertex form, which directly gives the parabola's turning point.
- Difference of squares. For x² − k = 0, the roots are simply ±√k.
The formula always works, which makes it the reliable default. Factoring is worth trying first only when the coefficients are small integers.
Reading the parabola
The graph of y = ax² + bx + c is a parabola. Its vertex sits at x = −b ÷ 2a, and substituting that back gives the vertex's y value. If a is positive the parabola opens upward and the vertex is a minimum; if negative it opens downward and the vertex is a maximum.
This is why quadratics appear in optimisation problems: maximum area for a given perimeter, maximum profit at a given price, maximum height of a projectile. The vertex is the answer.
Complex roots
A negative discriminant means the parabola never crosses the x-axis, so there is no real solution. The roots are complex: for x² + 2x + 5 = 0, the discriminant is 4 − 20 = −16, and the roots are −1 ± 2i.
These are not a mathematical curiosity — complex roots describe oscillating systems, and they are fundamental to electrical engineering, signal processing and control theory. A negative discriminant in a physical problem usually means the system oscillates rather than settling.
A numerical caution
When b² is much larger than 4ac, one root computed by the standard formula suffers from subtracting two nearly equal numbers, which loses precision badly in floating-point arithmetic. The stable approach computes the larger-magnitude root first, then obtains the other from the fact that the product of the roots equals c ÷ a. This matters in scientific computing and is the sort of detail that separates a working implementation from a correct one.