Sub topic 7
Reading the discriminant: two, one or no real roots
This chapter assumes you can rewrite a quadratic in standard form, ax² + bx + c = 0 with a ≠ 0. It also assumes you know the quadratic formula, and you can simplify square roots. The aim here is to read the expression b² − 4ac and know how many real roots an equation has before you solve it.
Where the discriminant comes from
The quadratic formula is
x = (−b ± √(b² − 4ac)) / (2a)
The expression under the square root is the discriminant. It is usually written D or Δ:
D = b² − 4ac
It is called a discriminant because it discriminates, or tells apart, the kinds of roots an equation can have. To see why it has this power, look at the step in the derivation just before the square root is taken. Completing the square on ax² + bx + c = 0 gives
(x + b/(2a))² = (b² − 4ac) / (4a²)
The left side is a real number squared, so it cannot be negative. The denominator 4a² is always positive, because a ≠ 0. That means the sign of the right side is the sign of D, and the sign of D decides whether a real x can satisfy the equation.
The three cases
| Sign of D | Square root of D | Real roots | Description |
|---|---|---|---|
| D > 0 | a positive real number | 2 | two distinct real roots |
| D = 0 | 0 | 1 | one repeated real root, x = −b/(2a) |
| D < 0 | not a real number | 0 | no real roots |
The next sections go through each case.
D > 0: two distinct real roots
The square root is a positive number, so the ± gives two different values. Take 2x² − 4x − 6 = 0. Here a = 2, b = −4, c = −6.
D = (−4)² − 4(2)(−6) = 16 + 48 = 64
D is positive, so there are two real roots. Since √64 = 8:
x = (4 ± 8) / 4, which gives x = 3 and x = −1.
D = 0: one repeated root
The square root is 0, so the ± has no effect and both formula values coincide: x = −b/(2a). Take x² − 6x + 9 = 0. Here a = 1, b = −6, c = 9.
D = 36 − 36 = 0, so x = 6/2 = 3.
This quadratic is a perfect square: x² − 6x + 9 = (x − 3)². The equation (x − 3)(x − 3) = 0 has the factor x − 3 twice. For that reason 3 is called a double root, or a root of multiplicity 2. The equation has one solution, but it counts twice when you count roots with multiplicity.
This is the case where a quadratic can be written as a(x − r)². If you find D = 0, you can factor immediately: a(x + b/(2a))².
D < 0: no real roots
The square root of a negative number is not a real number. The right side of (x + b/(2a))² = D/(4a²) is negative, but a real square cannot be negative. So no real x works.
Take x² + 2x + 5 = 0. Here D = 4 − 20 = −16. No real number satisfies this equation. The equation does have two solutions in the complex numbers, which a later chapter covers. For now, the correct statement is "no real roots", not "no solutions".
A decision procedure
The discriminant lets you decide before doing any square-root arithmetic.
Always compute D from the standard form. If the equation arrives as 2x² = 4x − 2, move everything to one side first: 2x² − 4x + 2 = 0. Then a = 2, b = −4, c = 2, and D = 16 − 16 = 0. One repeated root, x = 1.
Classifying equations in code
This function computes D and classifies the equation. It works with integers and with exact fractions.
from fractions import Fraction
def classify(a, b, c):
if a == 0:
raise ValueError("a must be nonzero")
d = b * b - 4 * a * c
if d > 0:
return d, "two distinct real roots"
if d == 0:
return d, "one repeated real root"
return d, "no real roots"
print(classify(1, -3, 2)) # (1, 'two distinct real roots')
print(classify(1, -6, 9)) # (0, 'one repeated real root')
print(classify(1, 2, 5)) # (-16, 'no real roots')
print(classify(2, -4, -6)) # (64, 'two distinct real roots')
# Exact arithmetic: x² + 0.3x + 0.0225 = 0 written with fractions
print(classify(Fraction(1), Fraction(3, 10), Fraction(9, 400)))
# (Fraction(0, 1), 'one repeated real root')The last line uses fractions on purpose. Comparing a floating-point D with == 0 is fragile.
Equations with a parameter
A common task is to find which values of a parameter give each case. Treat D as an expression in the parameter and study its sign.
Consider x² + 6x + k = 0. Here a = 1, b = 6, c = k, so
D = 36 − 4k
- D > 0 when 36 − 4k > 0, so k < 9. There are two real roots.
- D = 0 when k = 9. There is one repeated root, x = −3.
- D < 0 when k > 9. There are no real roots.
You can confirm this by scanning values of k:
for k in range(7, 12):
d = 6 * 6 - 4 * 1 * k
label = "two" if d > 0 else "one" if d == 0 else "none"
print(f"k={k}: D={d} -> {label}")
# k=7: D=8 -> two
# k=8: D=4 -> two
# k=9: D=0 -> one
# k=10: D=-4 -> none
# k=11: D=-8 -> noneWhen the parameter appears in a, remember that a ≠ 0 is required for the equation to be quadratic at all. For kx² − 4x + 1 = 0, D = 16 − 4k. D > 0 gives k < 4, but k = 0 must be excluded because the equation is then linear (−4x + 1 = 0, with one root). So the equation has two real roots when k < 4 and k ≠ 0.
When D itself is quadratic in the parameter, you must solve an inequality. For x² + mx + 16 = 0, D = m² − 64. D = 0 when m = 8 or m = −8. D > 0 when m < −8 or m > 8, and D < 0 when −8 < m < 8.
Edge cases and gotchas
- The equation must be in standard form first. If you read b and c from an unsimplified equation, D will be wrong. Expand brackets and collect terms before reading a, b and c.
- Sign of b. In D = b² − 4ac, b is squared, so its sign does not matter for D. The sign of c and a does matter: if a and c have opposite signs, then −4ac is positive and D is guaranteed to be positive. A quadratic such as 3x² + 5x − 2 = 0 therefore always has two real roots, with no calculation needed.
- Writing −b² when b is negative. If b = −4, then b² = 16, not −16. In code,
b * bavoids this slip. By hand, put the negative number in brackets. - D = 0 is a boundary. It separates the case with two real roots from the case with none. Changing one coefficient slightly moves D across zero, and the root count jumps from two to none. That is why parameter questions focus on D = 0 to find the cut-off values.
- Real versus complex. "No real roots" is a statement about the real number line. The answer to "how many roots?" depends on the number system. Counting multiplicity, every quadratic has exactly two roots over the complex numbers.
- The discriminant does not give the roots. It only says how many real ones there are. You still need the formula, or a factorization, to find them.
Summary of the working model
- Rewrite the equation as ax² + bx + c = 0.
- Compute D = b² − 4ac, taking care with signs.
- If D > 0, expect two distinct real roots. If D = 0, expect one repeated root, −b/(2a). If D < 0, expect no real roots.
- For parameter problems, find where D changes sign by solving D = 0.
- In code, use exact arithmetic or a tolerance for the D = 0 test.
Exercise
Without solving, state how many real roots each equation has: (a) 3x² − 5x + 4 = 0, (b) 4x² + 12x + 9 = 0, (c) 3x² + 5x − 2 = 0.
Show answer
(a) D = 25 − 48 = −23, which is negative, so there are no real roots. (b) D = 144 − 144 = 0, so there is one repeated real root, x = −12/8 = −3/2. (c) D = 25 + 24 = 49, which is positive, so there are two distinct real roots. (The roots are x = 1/3 and x = −2.)
Exercise
For which values of m does x² + mx + 16 = 0 have exactly one real root? Give the root in each case.
Show answer
Here D = m² − 64. Setting D = 0 gives m = 8 or m = −8. For m = 8 the root is x = −8/2 = −4, since x² + 8x + 16 = (x + 4)². For m = −8 the root is x = 8/2 = 4, since x² − 8x + 16 = (x − 4)².
Exercise
Find all values of k for which kx² − 4x + 1 = 0 has two distinct real roots.
Show answer
The equation is quadratic only if k ≠ 0. Then D = 16 − 4k. Two distinct real roots need D > 0, so 16 − 4k > 0, which gives k < 4. Excluding k = 0, the answer is k < 4 with k ≠ 0.