Sub topic 6
The discriminant: b² − 4ac
This chapter assumes you can rewrite an equation in standard form, ax² + bx + c = 0, and read off a, b and c. It also assumes you can simplify square roots and have seen the quadratic formula. The goal is to treat the expression under the square root as an object of its own. You will compute it reliably and see what it measures.
What the discriminant is
The quadratic formula for ax² + bx + c = 0 with a ≠ 0 is:
x = (−b ± √(b² − 4ac)) / (2a)
The discriminant is the expression under the square root. It is usually written D or Δ:
D = b² − 4ac
It is called a discriminant because it discriminates, or tells apart, the kinds of solutions the equation has. You can compute it without solving anything, and it fixes the character of the roots before you finish the formula.
Where it comes from
Completing the square on ax² + bx + c = 0 gives:
(x + b/(2a))² = (b² − 4ac) / (4a²)
The left side is a square, so it cannot be negative for real x. Everything depends on the right side, whose numerator is D. The denominator 4a² is always positive, so the sign of D alone decides whether the right side is positive, zero or negative. The formula follows by taking square roots of both sides, which is why D sits inside the radical.
Computing D step by step
Follow the same procedure every time:
- Rewrite the equation so that one side is 0 and the terms are in the order x², x, constant.
- Read off a, b and c, including their signs.
- Square b. The result is never negative.
- Compute 4ac, keeping its sign.
- Subtract: D = b² − 4ac.
Worked examples
Example 1. Take 2x² − 4x − 6 = 0. Here a = 2, b = −4 and c = −6.
- b² = (−4)² = 16
- 4ac = 4 · 2 · (−6) = −48
- D = 16 − (−48) = 16 + 48 = 64
Example 2. Take x² + 2x + 5 = 0. Here a = 1, b = 2 and c = 5.
- b² = 4
- 4ac = 20
- D = 4 − 20 = −16
Example 3. Take 4x² − 12x + 9 = 0. Here a = 4, b = −12 and c = 9.
- b² = 144
- 4ac = 144
- D = 144 − 144 = 0
Example 4: an equation not yet in standard form. Take 3x = x² − 4. Move every term to one side to get x² − 3x − 4 = 0. Now a = 1, b = −3 and c = −4.
- b² = (−3)² = 9
- 4ac = 4 · 1 · (−4) = −16
- D = 9 − (−16) = 25
Reading a, b and c from the original form would have been wrong here. The coefficient of x is −3 only after the rearrangement.
What the sign of D tells you
The cases are developed fully in the next chapter. This table is a first look.
| Value of D | Square root of D | Roots of the quadratic |
|---|---|---|
| D > 0 | a positive real number | two distinct real roots |
| D = 0 | 0 | one real root, repeated |
| D < 0 | not a real number | no real roots (two complex roots) |
Applying the table to the examples:
- Example 1 has D = 64 > 0, so there are two real roots. They are x = (4 ± 8)/4, which gives −1 and 3.
- Example 2 has D = −16 < 0, so there are no real roots.
- Example 3 has D = 0, so there is one repeated root, x = 12/8 = 3/2.
- Example 4 has D = 25 > 0, so there are two real roots. They are x = (3 ± 5)/2, which gives 4 and −1.
What the size of D tells you
The sign is not the only information. The two roots differ by:
x₂ − x₁ = √D / |a|
You can see this from the formula, because the two roots are (−b − √D)/(2a) and (−b + √D)/(2a). Their difference is 2√D/(2a), taken as a positive distance. Check it on Example 1. The roots are −1 and 3, so the distance is 4. The formula gives √64 / 2 = 4. ✓
So a larger D means the roots are farther apart, and D = 0 means the distance is zero, which is why the root is repeated.
How D changes when you transform the equation
Two facts help you check your work.
Shifting x does not change D. Substitute x → x + 1 into x² − 2x − 3, whose discriminant is 4 + 12 = 16:
(x + 1)² − 2(x + 1) − 3 = x² + 2x + 1 − 2x − 2 − 3 = x² − 4
This new equation has a = 1, b = 0 and c = −4, so D = 0 − 4 · 1 · (−4) = 16. A horizontal shift moves both roots by the same amount, so the distance between them stays the same, and so does D.
Scaling the whole equation by k multiplies D by k². Multiply Example 1 by 1/2 to get x² − 2x − 3 = 0. Its discriminant is 16, and the original was 64 = 4 · 16, where 4 = (1/(1/2))². Because k² is positive, the sign of D never changes when you scale. This is why you can divide an equation by a common factor before computing D without changing the type of roots.
Computing D in code
A short helper makes the formula concrete. Use exact arithmetic when the coefficients are fractions, because the test D == 0 matters.
from fractions import Fraction
def discriminant(a, b, c):
return b * b - 4 * a * c
def describe(a, b, c):
d = discriminant(a, b, c)
if d > 0:
return d, "two distinct real roots"
if d == 0:
return d, "one repeated real root"
return d, "no real roots"
for coeffs in [(2, -4, -6), (1, 2, 5), (4, -12, 9)]:
print(coeffs, describe(*coeffs))
# Exact arithmetic: x² + x/5 + 1/100 = 0 has a repeated root.
print(describe(Fraction(1), Fraction(1, 5), Fraction(1, 100)))The output is:
(2, -4, -6) (64, 'two distinct real roots')
(1, 2, 5) (-16, 'no real roots')
(4, -12, 9) (0, 'one repeated real root')
(Fraction(0, 1), 'one repeated real root')Common errors when computing D
- Dropping the sign of b. If b = −3, then b² = (−3)² = 9, not −9. Put parentheses around negative values.
- Mishandling 4ac when c is negative. If a and c have opposite signs, then ac is negative and −4ac is positive. The two terms add, so D > 0 is guaranteed. This is a quick check: if a and c have opposite signs, the roots are real and distinct.
- Forgetting the 4. Writing b² − ac is a frequent slip. Check against Example 3, where 144 − 144 = 0 only works with the factor of 4.
- Reading a, b, c before rearranging. Example 4 shows this. Always move everything to one side first.
- Missing zero coefficients. In x² − 9 = 0, b = 0, so D = 0 − 4 · 1 · (−9) = 36. The missing x term does not make b disappear from the formula. It just makes it 0.
- Using 2a or a single factor of 2 in the wrong place. The discriminant has no division. Only the final formula divides by 2a.
Summary of the key points
- D = b² − 4ac is the expression under the square root in the quadratic formula.
- It comes from the right side of the completed-square form, (x + b/(2a))² = D/(4a²).
- Its sign decides how many real roots exist. Its size sets the distance √D / |a| between them.
- Shifting x leaves D unchanged. Scaling the equation by k multiplies D by k².
- Most errors come from signs, a missing factor of 4, or reading coefficients before putting the equation in standard form.
Exercise
For the equation 5x = 2x² + 1, first write it in standard form and identify a, b and c. Then compute the discriminant, state how many real roots there are, and use √D / |a| to find the distance between the roots.
Show answer
Move all terms to one side: 2x² − 5x + 1 = 0, so a = 2, b = −5 and c = 1. Then D = (−5)² − 4 · 2 · 1 = 25 − 8 = 17. Since D > 0, there are two distinct real roots. The distance between them is √17 / 2, which is about 2.06. As a check, the roots are (5 ± √17)/4, and their difference is 2√17/4 = √17/2.
Exercise
The equation x² + kx + 9 = 0 has exactly one repeated real root. Find every value of k, and give the root for each.
Show answer
Set D = 0: k² − 4 · 1 · 9 = 0, so k² = 36 and k = 6 or k = −6. For k = 6 the root is x = −k/2 = −3, since x² + 6x + 9 = (x + 3)². For k = −6 the root is x = 3, since x² − 6x + 9 = (x − 3)².