Sub topic 3
The discriminant and the graph of the parabola
This chapter assumes you can solve linear equations, expand and factor simple polynomials, simplify square roots, and read points on a coordinate graph. It uses the standard form ax² + bx + c = 0 with a ≠ 0.
Reading the discriminant
The discriminant is the quantity d = b² − 4ac. It comes from the quadratic formula, and its sign tells you how many real roots the equation has before you solve it.
- If d > 0, there are two distinct real roots.
- If d = 0, there is one repeated real root.
- If d < 0, there are no real roots, only a pair of complex roots.
On a graph, the roots are the x-intercepts of the parabola y = ax² + bx + c. Positive d means the parabola crosses the x-axis twice. Zero d means it touches the axis at its vertex. Negative d means it never meets the axis.
Complex roots when d is negative
When d < 0, the square root of d is imaginary. Python's cmath module handles this directly:
import cmath
a, b, c = 1, 2, 5
d = b * b - 4 * a * c # -16
r = cmath.sqrt(d) # 4j
print((-b - r) / (2 * a), (-b + r) / (2 * a)) # (-1-2j) (-1+2j)The two roots are p ± qi, here −1 ± 2i. They are conjugates, and they always come in such pairs for real coefficients.
Perfect-square discriminants and rational roots
If a, b and c are integers and d is a perfect square, the roots are rational. For x² − 5x + 6 = 0, d = 25 − 24 = 1, so the roots are (5 ± 1)/2, which are 3 and 2. If d is not a perfect square, the roots are irrational, though still real.
Sum and product of the roots
For any quadratic with roots r₁ and r₂:
- Sum: r₁ + r₂ = −b/a
- Product: r₁ × r₂ = c/a
For 2x² − 4x − 6 = 0, the roots are −1 and 3. The sum is 2, which equals −(−4)/2. The product is −3, which equals −6/2. Use these checks after you solve.
Cancellation error
When b is much larger than 4ac, the formula subtracts two nearly equal numbers and loses precision. Computing the root with the smaller magnitude as c divided by the other root avoids this.
import math
a, b, c = 1, 1e8, 1
d = b * b - 4 * a * c
naive = (-b + math.sqrt(d)) / (2 * a) # loses most digits
stable = (2 * c) / (-b - math.sqrt(d)) # close to the true root -1e-8
print(naive, stable)Common mistakes and how to check
- Forgetting that b is negative in −b when b itself is negative.
- Dropping the minus sign in −4ac when c is negative.
- Dividing only the first term by 2a.
To check an answer, substitute each root into the original equation, then confirm the sum and product match −b/a and c/a.
Exercise
For 2x² + 3x + 5 = 0, what is the discriminant, and what does it say about the graph?
Show answer
d = 3² − 4(2)(5) = 9 − 40 = −31. Because d is negative, there are no real roots, so the parabola has no x-intercepts. The roots are complex conjugates.