Sub topic 10
Completing the square when a is not 1
Completing the square on x^2 + bx + c works because x^2 + bx + (b/2)^2 equals (x + b/2)^2. That identity needs the coefficient of x^2 to be 1. When a is not 1, the fix is to make it 1 first. This chapter covers two ways to do that, the checks that catch the usual mistakes, and the three kinds of outcome.
Strategy 1: divide by a first
Divide every term of ax^2 + bx + c = 0 by a. This gives x^2 + (b/a)x + c/a = 0, which you can solve with the method you already know. Dividing both sides of an equation by a nonzero number gives an equivalent equation, so the solutions do not change.
Example with whole-number steps
Solve 2x^2 + 12x - 14 = 0.
- Divide by 2: x^2 + 6x - 7 = 0.
- Move the constant: x^2 + 6x = 7.
- Add (6/2)^2 = 9 to both sides: x^2 + 6x + 9 = 16.
- Factor the left side: (x + 3)^2 = 16.
- Take square roots: x + 3 = 4 or x + 3 = -4.
- Solve: x = 1 or x = -7.
Check x = -7: 2(49) + 12(-7) - 14 = 98 - 84 - 14 = 0. Check x = 1: 2 + 12 - 14 = 0.
Example with fractions
Solve 3x^2 - 4x - 4 = 0.
- Divide by 3: x^2 - (4/3)x - 4/3 = 0.
- Move the constant: x^2 - (4/3)x = 4/3.
- Half of -4/3 is -2/3, and its square is 4/9. Add 4/9 to both sides: x^2 - (4/3)x + 4/9 = 4/3 + 4/9 = 16/9.
- Factor: (x - 2/3)^2 = 16/9.
- Take roots: x - 2/3 = 4/3 or x - 2/3 = -4/3.
- Solve: x = 2 or x = -2/3.
Fractions are the main cost of this strategy. Work with the fractions exactly. Converting to decimals early causes rounding drift.
Strategy 2: factor a out of the variable terms
You can avoid dividing the whole equation by pulling a out of only the x^2 and x terms. Keep the constant where it is.
Solve 2x^2 + 8x + 3 = 0.
- Group and factor: 2(x^2 + 4x) + 3 = 0.
- Move the constant: 2(x^2 + 4x) = -3.
- Complete the square inside the parentheses by adding 4. The 4 sits inside a group multiplied by 2, so you have added 2 · 4 = 8 to the left side. Add 8 to the right side too: 2(x^2 + 4x + 4) = -3 + 8.
- Simplify: 2(x + 2)^2 = 5.
- Divide by 2: (x + 2)^2 = 5/2.
- Take roots: x + 2 = ±sqrt(5/2).
- Solve: x = -2 ± sqrt(5/2).
You can rationalize the radical: sqrt(5/2) = sqrt(10)/2, so x = -2 ± sqrt(10)/2. Numerically, x is about -0.419 or -3.581.
Which strategy to use
| Situation | Better choice |
|---|---|
| a divides b and c evenly, as in 2x^2 + 12x - 14 | Strategy 1 |
| a does not divide b, as in 3x^2 - 4x - 4 | Either; Strategy 2 delays the fractions |
| You want to show that a standard form is equivalent to (x + h)^2 = k | Strategy 1 |
| You are working by hand and want fewer fractions | Strategy 2 |
Both strategies reach the same equation, (x + h)^2 = k, where h = b/(2a) and k = h^2 - c/a. Chapter 14 uses this fact to derive the quadratic formula.
The procedure as a flow
The three outcomes
After you reach (x + h)^2 = k, the sign of k decides everything. A square of a real number is never negative.
- If k > 0, there are two real roots, -h + sqrt(k) and -h - sqrt(k).
- If k = 0, there is one repeated root, x = -h. The graph touches the x-axis at one point.
- If k < 0, there are no real roots. Stop and say so. Do not write a square root of a negative number as a real answer.
Repeated root example
Solve 4x^2 - 12x + 9 = 0.
- Divide by 4: x^2 - 3x + 9/4 = 0.
- Half of -3 is -3/2, and its square is 9/4. The constant term already equals that, so the left side is a perfect square: (x - 3/2)^2 = 0.
- Therefore x = 3/2, a repeated root.
Because 4x^2 - 12x + 9 = (2x - 3)^2, this equation also yields to the perfect-square pattern from the factoring chapters.
No-real-roots example
Solve 2x^2 + 4x + 5 = 0.
- Divide by 2: x^2 + 2x + 5/2 = 0.
- Move the constant: x^2 + 2x = -5/2.
- Add 1 to both sides: (x + 1)^2 = -5/2 + 1 = -3/2.
- A real square cannot equal -3/2, so there are no real solutions.
Checking your work by substitution
Substitute each solution into the original equation, not into a later step. A mistake in step 2 would still look consistent with step 5, but it will fail in the original.
For irrational roots, substitution by hand is awkward. Use one of these checks instead:
- Expand the final square back out and compare it with the equation you started from, after dividing by a.
- Use a decimal approximation. For x = -2 + sqrt(5/2) ≈ -0.4189, compute 2x^2 + 8x + 3 ≈ 2(0.17546) - 3.35109 + 3 ≈ 0.0000.
- Check the sum of the roots. The two roots of ax^2 + bx + c = 0 add up to -b/a. For 2x^2 + 8x + 3, the roots -2 ± sqrt(5/2) add up to -4, which equals -8/2.
Common errors
| Error | What goes wrong | Fix |
|---|---|---|
| Dividing only the first term by a | The equation changes, so the roots change | Divide every term on both sides |
| Adding (b/2)^2 instead of (b/(2a))^2 | The left side is not a perfect square | After dividing by a, the new middle coefficient is b/a, so use half of that |
| Forgetting to multiply by a in Strategy 2 | The two sides are no longer balanced | Add a times the inside number to the right |
| Dropping the minus sign in x + h | The roots have the wrong sign | Write x + h = ±sqrt(k), then subtract h |
| Writing ±sqrt(k) when k is negative | Reports solutions that are not real | State that there are no real roots |
Doing it in code
This program computes h and k with exact fractions, then reads off the outcome. Exact arithmetic keeps the test k == 0 reliable, because a floating-point k might come out as 1e-17 instead of 0.
from fractions import Fraction
import math
def complete_square(a, b, c):
"""Return (h, k) so that a*x^2 + b*x + c = 0 is equivalent to (x + h)^2 = k."""
a, b, c = Fraction(a), Fraction(b), Fraction(c)
if a == 0:
raise ValueError("a must not be 0")
h = b / (2 * a) # half of the x coefficient after dividing by a
k = h * h - c / a # (b/(2a))^2 - c/a
return h, k
def solve(a, b, c):
"""Return the real solutions as a sorted tuple, rounded to 6 places."""
h, k = complete_square(a, b, c)
if k < 0:
return ()
root = math.sqrt(k)
center = float(-h)
return tuple(sorted({round(center - root, 6), round(center + root, 6)}))
print(solve(2, 12, -14)) # (-7.0, 1.0)
print(solve(3, -4, -4)) # (-0.666667, 2.0)
print(solve(2, 8, 3)) # (-3.581139, -0.418861)
print(solve(2, 4, 5)) # ()
print(solve(4, -12, 9)) # (1.5,)Each call matches an example above. The five results show two rational roots, a pair with a fraction, a pair with an irrational part, no real roots, and a repeated root.
Choosing a strategy under time pressure
On a test, first try factoring when the numbers are small. Complete the square when the quadratic does not factor over the integers, or when the question asks you to rewrite the equation in the form a(x - h)^2 + k, which is vertex form. For vertex form, Strategy 2 is the natural tool, since it keeps a outside the square.
Exercise
Solve 2x^2 - 12x + 7 = 0 by completing the square. Give the exact roots, then check that they add up to -b/a.
Show answer
Divide by 2: x^2 - 6x + 7/2 = 0. Move the constant: x^2 - 6x = -7/2. Add (6/2)^2 = 9: (x - 3)^2 = -7/2 + 9 = 11/2. Take roots: x - 3 = ±sqrt(11/2) = ±sqrt(22)/2. So x = 3 ± sqrt(22)/2, which is about 5.345 or 0.655. The sum is 3 + 3 = 6, and -b/a = -(-12)/2 = 6, so the check passes.
Exercise
In 5x^2 + 10x + 8 = 0, a student writes 5(x^2 + 2x + 1) = -8 + 1 after adding 1 inside the parentheses. What is wrong, and what is the outcome of the equation?
Show answer
The student added 1 inside a group multiplied by 5, so the equation changed by 5, not 1. The correct step is 5(x^2 + 2x + 1) = -8 + 5, which gives 5(x + 1)^2 = -3, so (x + 1)^2 = -3/5. This is negative, so the equation has no real roots.