Sub topic 5
Using the quadratic formula
This chapter assumes you can solve linear equations, expand and factor simple polynomials, simplify square roots, and read a coordinate graph. Earlier chapters put the equation in standard form and derived the formula by completing the square. This chapter is about using the formula reliably. You will practice a fixed procedure, work through several kinds of equation, and learn to check each answer.
The formula
For an equation in standard form ax² + bx + c = 0 with a ≠ 0, the solutions are
x = (−b ± √(b² − 4ac)) / (2a)
The ± symbol means "plus or minus". It stands for two calculations, one with + and one with −. Each gives one root. If the two results are equal, the equation has one repeated root.
The whole expression −b ± √(b² − 4ac) is divided by 2a. The division bar covers both terms of the numerator, so you cannot cancel a single term against 2a.
A procedure that avoids most errors
Follow the same steps every time.
- Move every term to one side so the other side is 0.
- Order the terms by degree and read off a, b and c, including their signs.
- Compute b² − 4ac.
- Take the square root and simplify it if you can.
- Compute both values of x.
- Check the roots by substituting them back into the original equation.
Reading a, b and c
The signs belong to the coefficients. In 2x² − 4x − 6 = 0, the coefficient b is −4, not 4, and c is −6. A term that is missing has coefficient 0.
| Equation as given | Standard form | a | b | c |
|---|---|---|---|---|
| 2x² − 4x − 6 = 0 | unchanged | 2 | −4 | −6 |
| 3x² + 5x = 2 | 3x² + 5x − 2 = 0 | 3 | 5 | −2 |
| x² − 9 = 0 | x² + 0x − 9 = 0 | 1 | 0 | −9 |
| −x² + 2x + 3 = 0 | unchanged | −1 | 2 | 3 |
| 4x² = 12x − 9 | 4x² − 12x + 9 = 0 | 4 | −12 | 9 |
Worked examples
Two distinct rational roots
Solve 2x² − 4x − 6 = 0. Here a = 2, b = −4 and c = −6.
b² − 4ac = (−4)² − 4(2)(−6) = 16 + 48 = 64
The square root is 8. Then
x = (−(−4) ± 8) / (2·2) = (4 ± 8) / 4
so x = 12/4 = 3 or x = −4/4 = −1.
Check x = 3: 2(9) − 12 − 6 = 0. Check x = −1: 2(1) + 4 − 6 = 0. Both work.
An equation that needs rearranging
Solve 3x² + 5x = 2. Subtract 2 from both sides to get 3x² + 5x − 2 = 0, so a = 3, b = 5 and c = −2.
b² − 4ac = 25 − 4(3)(−2) = 25 + 24 = 49
x = (−5 ± 7) / 6
so x = 2/6 = 1/3 or x = −12/6 = −2.
Check x = 1/3: 3(1/9) + 5/3 − 2 = 1/3 + 5/3 − 2 = 0. Check x = −2: 12 − 10 − 2 = 0.
Rewriting the equation to have 0 on one side is the step most often skipped. Reading a, b and c from 3x² + 5x = 2 directly would give c = 2, which is wrong.
Irrational roots
Solve x² − 4x + 1 = 0. Here a = 1, b = −4 and c = 1.
b² − 4ac = 16 − 4 = 12
Simplify the radical: √12 = √(4·3) = 2√3. Then
x = (4 ± 2√3) / 2 = 2 ± √3
Divide each term of the numerator by 2. The roots are about 0.268 and 3.732. Leaving an exact answer such as 2 ± √3 is usually better than rounding, because rounded values only satisfy the equation approximately.
A negative leading coefficient
Solve −x² + 2x + 3 = 0. Here a = −1, b = 2 and c = 3.
b² − 4ac = 4 − 4(−1)(3) = 4 + 12 = 16
x = (−2 ± 4) / (−2)
so x = 2/(−2) = −1 or x = −6/(−2) = 3.
Check x = 3: −9 + 6 + 3 = 0. Check x = −1: −1 − 2 + 3 = 0.
You could instead multiply the whole equation by −1 to get x² − 2x − 3 = 0. The roots are the same. Doing this often reduces sign mistakes, since a becomes positive.
One repeated root
Solve 4x² = 12x − 9. Move the terms to get 4x² − 12x + 9 = 0, so a = 4, b = −12 and c = 9.
b² − 4ac = 144 − 144 = 0
x = (12 ± 0) / 8 = 3/2
The ± produces the same value twice, so there is one repeated root. The left side factors as (2x − 3)², which confirms it.
A missing term
Solve x² − 9 = 0. Here a = 1, b = 0 and c = −9.
b² − 4ac = 0 + 36 = 36
x = (0 ± 6) / 2 = ±3
The formula works here, but isolating x² and taking square roots is shorter. When b = 0, that shortcut is usually the better choice. When c = 0, as in x² − 5x = 0, factoring out x is faster. The formula is the general tool. Use it when no shortcut is obvious, or when you want one method that always works.
Doing it in code
The function below follows the same steps. It computes the discriminant first and uses its sign to decide how many real roots to return. Chapter content on the discriminant's meaning comes later in this tutorial. Here the code is only a way to automate the procedure and the check.
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 []
def residual(a, b, c, x):
return a * x * x + b * x + c
for coeffs in [(2, -4, -6), (3, 5, -2), (1, -4, 1), (-1, 2, 3), (4, -12, 9)]:
roots = solve_quadratic(*coeffs)
print(coeffs, [round(x, 4) for x in roots],
[round(residual(*coeffs, x), 9) for x in roots])The first list shows the roots rounded to four places. The second list holds the residuals, the value of ax² + bx + c at each root. A correct root gives a residual of zero, or very nearly zero because floating-point arithmetic is not exact. For example, solve_quadratic(2, -4, -6) returns [-1.0, 3.0].
The function returns an empty list when the discriminant is negative, because there are no real roots. Complex roots get their own chapter.
Why a cannot be zero
The formula divides by 2a. If a = 0, the equation bx + c = 0 is linear and has a single solution x = −c/b (when b ≠ 0). A genuine quadratic needs a ≠ 0. If a problem gives you a parameter in the leading coefficient, such as kx² + 3x + 1 = 0, treat k = 0 as a separate case.
Common mistakes
These errors account for most wrong answers.
- Dropping the sign of b. Writing −b as −(−4) = 4 is required. A common slip is to write −4. Put parentheses around negative values whenever you substitute.
- Squaring b incorrectly. (−4)² is 16, not −16. A calculator entry of −4² gives −16, so enter (−4)².
- Mishandling −4ac. If a or c is negative, then −4ac is positive. In the example with c = −6, the term 4ac was −48 and subtracting it added 48.
- Dividing only part of the numerator. In (4 ± 2√3)/2, both 4 and 2√3 are divided by 2. Writing 4 ± √3 is wrong.
- Forgetting that 2a is the whole denominator. Writing x = −b ± √d / 2a without grouping changes the meaning. In writing, use a long fraction bar. In code, use parentheses:
(-b + r) / (2 * a). - Putting 2a inside the root or applying the root to −b. Only b² − 4ac sits under the radical.
- Skipping the rearrangement. The equation must equal 0 before you read off the coefficients.
Checking your answer
Substitution is the most reliable check. Plug each root into the original equation, not your rearranged version. That way a mistake in rearranging also gets caught.
A second check uses the structure of the roots. For ax² + bx + c = 0, the two roots add up to −b/a and multiply to c/a. In the first example, 3 + (−1) = 2 = −(−4)/2, and 3 · (−1) = −3 = −6/2. A later chapter develops this idea. For now, use it as a quick test: if your sum or product does not match, recheck your arithmetic.
Exercise
Solve 5x² − 3x = 2 with the quadratic formula. State a, b and c, the value of b² − 4ac, both roots, and check each root by substitution.
Show answer
Rearrange to 5x² − 3x − 2 = 0, so a = 5, b = −3 and c = −2. Then b² − 4ac = 9 − 4(5)(−2) = 9 + 40 = 49, and the square root is 7. So x = (3 ± 7) / 10, which gives x = 10/10 = 1 or x = −4/10 = −2/5. Check x = 1: 5 − 3 − 2 = 0. Check x = −2/5: 5(4/25) + 6/5 − 2 = 4/5 + 6/5 − 2 = 0. The sum of the roots is 3/5 = −b/a and the product is −2/5 = c/a, which also match.
Exercise
A student solves x² + 6x + 5 = 0 and writes x = (6 ± √(36 − 20)) / 2 = (6 ± 4) / 2, so x = 5 or x = 1. Find the error and give the correct roots.
Show answer
The student used b = 6 in the −b term. It should be −b = −6. The correct calculation is x = (−6 ± √16) / 2 = (−6 ± 4) / 2, so x = −1 or x = −5. Substituting the student's x = 1 gives 1 + 6 + 5 = 12, not 0, which shows it is wrong.
Exercise
Solve 9x² − 12x + 4 = 0. How many distinct roots does it have?
Show answer
Here a = 9, b = −12 and c = 4. Then b² − 4ac = 144 − 144 = 0, so x = 12/18 = 2/3. There is one distinct root, a repeated root at x = 2/3. The left side equals (3x − 2)².