The idea: a square with a missing corner
A quadratic equation is ax² + bx + c = 0 with a ≠ 0. A square is easy to solve: if (x + 3)² = 4, then x + 3 is 2 or −2. Completing the square turns any quadratic into that shape. Draw x² as an x-by-x square and 6x as a strip 6 wide and x tall. Cut the strip into two 3-by-x halves, put one along the right side and one along the bottom. The picture is a big square with one 3×3 corner missing. Add that corner, area 9, and x² + 6x + 9 = (x + 3)².
Vertex form and the parabola
Add the corner and take it away again, so nothing changes: x² + 6x + 5 = (x² + 6x + 9) − 9 + 5 = (x + 3)² − 4. This is the vertex form a(x − h)² + k with h = −3 and k = −4. The squared part is never negative and is 0 only at x = −3, so the graph y = x² + 6x + 5, a parabola, has its lowest point, the vertex, at (−3, −4). It is mirror-symmetric about the vertical line x = −3, the axis of symmetry. Vertex form is the graph of y = x² shifted left 3 and down 4; see function transformations.
Solving is now one square root: (x + 3)² = 4, so x + 3 = ±2 and x = −1 or x = −5. Those are the roots, where the parabola crosses the x-axis. In general h = −b/2a and k = c − b²/4a. (Demo: complete the square, x² + 6x + 5) To see how each of a, b and c moves the graph, see What a, b and c Do to a Parabola.
When b is negative the strips are taken away instead of added (red on the canvas): x² − 4x + 4 = (x − 2)². The corner is still +(b/2)².
Deriving the quadratic formula
Do the same steps with letters:
- Divide by a: x² + (b/a)x + c/a = 0.
- Move c/a over and add the corner (b/2a)² to both sides: (x + b/2a)² = (b² − 4ac) / 4a².
- Take the square root: x + b/2a = ±√(b² − 4ac) / 2a.
x = (−b ± √(b² − 4ac)) / 2a
The two roots sit at equal distances √(b² − 4ac)/2a on either side of the axis x = −b/2a. For x² − 2x − 3: x = (2 ± √16)/2 = (2 ± 4)/2, so x = 3 or x = −1, both 2 away from the axis x = 1. (Demo: two roots)
The discriminant: two, one or zero real roots
The number under the root, D = b² − 4ac, is the discriminant. Its sign tells how many real roots there are before you finish the calculation. With a > 0 the parabola opens upward, and D > 0 exactly when the vertex is below the x-axis (k = −D/4a).
| D | real roots | the parabola | example |
|---|---|---|---|
| D > 0 | two, (−b ± √D)/2a | crosses the x-axis twice | x² − 2x − 3: D = 16, x = −1, 3 |
| D = 0 | one double root, −b/2a | touches the axis at its vertex | x² − 4x + 4: D = 0, x = 2 |
| D < 0 | none (a complex pair) | misses the axis | x² + 2x + 5: D = −16, x = −1 ± 2i |
(Demo: one double root, Demo: no real roots)
Complex roots
When D < 0 there is no real number whose square is D. With the imaginary unit i, where i² = −1, √D = i√(−D) and the formula still works: x² + 2x + 5 gives x = (−2 ± 4i)/2 = −1 ± 2i. Complex roots of a real quadratic always come as a conjugate pair a ± bi: their real part is the axis of symmetry, −b/2a. See complex numbers for how to add and multiply them.
Factoring vs the formula
If x² + bx + c = (x − r₁)(x − r₂), the product is 0 exactly when one factor is 0, so the roots are r₁ and r₂. Multiplying out gives r₁ + r₂ = −b and r₁·r₂ = c. Factoring by guessing means finding two whole numbers p, q with p·q = c and p + q = b; then x² + bx + c = (x + p)(x + q).
| factoring | formula | |
|---|---|---|
| x² − 5x + 6 | (−2)(−3) = 6, sum −5: (x − 2)(x − 3), x = 2, 3 | (5 ± 1)/2 = 2, 3 |
| x² − 2x − 1 | no whole-number pair works | (2 ± √8)/2 = 1 ± √2 |
| when it works | whole-number (rational) roots only | always |
(Demo: factoring vs the formula)
In practice
On a computer, (−b ± √D)/2a can lose digits: when b² is much bigger than 4ac, one of −b + √D or −b − √D subtracts two nearly equal numbers. Numerical code computes q = −(b + sign(b)·√D)/2 first, then the two roots as q/a and c/q. For higher degrees there is no such simple formula past degree 4, and root finders such as Newton's method follow tangent lines instead; Newton's method on x² − 2 is the old Babylonian square-root rule.
One degree up, the cubic ax³ + bx² + cx + d has an inflection point instead of a vertex, and its turning points come from the discriminant of f′; see Cubic Functions: What a, b, c, d Do.
A ray tracer solves one quadratic per ray and sphere, and the discriminant says hit or miss: see Ray Tracing.
What the page leaves out
Only integer coefficients from a short preset list are shown, all with a > 0 (opening upward); with a < 0 everything flips and the vertex is a maximum. The area model draws only the x² + (b/a)x part, so a negative c or a negative strip is shown by colour, not as a real area. Factoring with a ≠ 1 (the "ac method"), the cubic and quartic formulas, and the numerically stable formula are only described.