Sub topic 2
Using the Quadratic Formula
This chapter assumes you can solve linear equations, expand brackets, simplify square roots, and read points on a coordinate graph.
Applying the formula
A quadratic equation in standard form is ax² + bx + c = 0, where a ≠ 0. Its roots are:
x = (−b ± √(b² − 4ac)) / (2a)
Identify a, b and c first, keeping their signs. Then substitute them into the formula.
For example, take 2x² − 4x − 6 = 0. Here a = 2, b = −4 and c = −6.
import math
def solve_quadratic(a, b, c):
if a == 0:
raise ValueError("a must be nonzero")
d = b * b - 4 * a * c
if d > 0:
r = math.sqrt(d)
return [(-b - r) / (2 * a), (-b + r) / (2 * a)]
if d == 0:
return [-b / (2 * a)]
return []
print(solve_quadratic(2, -4, -6)) # [-1.0, 3.0]The discriminant: b² − 4ac
The expression under the square root, b² − 4ac, is the discriminant. Compute it before the rest of the formula. It decides how many real roots the equation has.
For the example above, the discriminant is (−4)² − 4(2)(−6) = 16 + 48 = 64.
Reading the discriminant: two, one or no real roots
- Positive: two distinct real roots.
- Zero: one repeated real root, x = −b / (2a).
- Negative: no real roots. The square root is then imaginary, so the roots are complex.
Exercise
How many real roots does x² + 4x + 5 = 0 have?
Show answer
Here a = 1, b = 4, c = 5, so the discriminant is 16 − 20 = −4. Because it is negative, there are no real roots. The roots are the complex pair −2 ± i.