Sub topic 13
From Standard Form to Vertex Form by Completing the Square
What this chapter assumes
You should already be able to do the following:
- Read the vertex, axis of symmetry, and intercepts from y = a(x - h)^2 + k.
- Expand a binomial such as (x - 3)^2 into x^2 - 6x + 9.
- Solve simple linear equations.
This chapter goes the other way. A quadratic often arrives in standard form, y = ax^2 + bx + c. In that form the vertex is not visible. Completing the square rewrites it as vertex form, where the vertex can be read directly.
Why convert at all
Standard form shows the y-intercept right away, because y(0) = c. It hides the vertex, the axis, and the maximum or minimum value. Vertex form shows those at once. After converting, you can use the same graphing procedure as in the earlier chapters.
| Feature | Visible in standard form? | Visible in vertex form? |
|---|---|---|
| Opening direction (sign of a) | Yes | Yes |
| y-intercept | Yes, it is c | After computing a*h^2 + k |
| Vertex and axis | No | Yes, (h, k) and x = h |
| Maximum or minimum value | No | Yes, it is k |
| x-intercepts | Needs factoring or the quadratic formula | Square roots: x = h ± sqrt(-k/a) |
The idea behind completing the square
A perfect square trinomial has the form x^2 + 2px + p^2 = (x + p)^2. The constant is the square of half the x-coefficient. Completing the square means adding the missing constant so that the x-terms become a perfect square. You also subtract the same amount so the value of the expression does not change.
Take y = x^2 - 6x + 5.
- The x-coefficient is -6. Half of it is -3, and its square is 9.
- Add and subtract 9: y = (x^2 - 6x + 9) - 9 + 5.
- Factor the bracket and combine constants: y = (x - 3)^2 - 4.
The vertex is (3, -4). Expanding confirms it: (x - 3)^2 - 4 = x^2 - 6x + 9 - 4 = x^2 - 6x + 5.
The general derivation
Start with y = ax^2 + bx + c, where a is not 0.
- Factor a out of the two x-terms: y = a(x^2 + (b/a)x) + c.
- Half of b/a is b/(2a). Its square is b^2/(4a^2). Add and subtract it inside the bracket: y = a(x^2 + (b/a)x + b^2/(4a^2) - b^2/(4a^2)) + c.
- Group the perfect square: y = a(x + b/(2a))^2 - a * b^2/(4a^2) + c.
- Simplify the leftover term: y = a(x + b/(2a))^2 + c - b^2/(4a).
Matching this to a(x - h)^2 + k gives two formulas:
- h = -b/(2a)
- k = c - b^2/(4a)
The a stays the same in both forms. Only h and k are new.
Worked examples
Example 1: a equals 1
For y = x^2 + 3x + 1, b = 3 and c = 1.
- h = -3/2
- k = 1 - 9/4 = -5/4
So y = (x + 3/2)^2 - 5/4. The vertex is (-3/2, -5/4). Odd values of b give fractions, and that is normal.
Example 2: a is not 1
For y = 2x^2 + 8x + 3, a = 2, b = 8, and c = 3.
- h = -8/(2 * 2) = -2
- k = 3 - 64/(4 * 2) = 3 - 8 = -5
So y = 2(x + 2)^2 - 5. Check by expanding: 2(x^2 + 4x + 4) - 5 = 2x^2 + 8x + 8 - 5 = 2x^2 + 8x + 3.
The shape and the opening direction are unchanged, so the parabola still opens upward with a = 2. The vertex is (-2, -5), and the minimum value is -5.
Example 3: a is negative
For y = -x^2 + 4x - 1, a = -1, b = 4, and c = -1.
- h = -4/(2 * -1) = 2
- k = -1 - 16/(4 * -1) = -1 + 4 = 3
So y = -(x - 2)^2 + 3. The vertex is (2, 3), and it is a maximum because the parabola opens downward.
A shortcut for k
Once you have h, you can find k by evaluating the original function at x = h. The vertex lies on the curve, so k = y(h). For y = 2x^2 + 8x + 3 and h = -2:
y(-2) = 2(4) + 8(-2) + 3 = 8 - 16 + 3 = -5
This agrees with the formula. Doing both gives you a built-in check on your arithmetic.
Doing it in code
The function below applies the two formulas. It is the same computation you do by hand.
def standard_to_vertex(a, b, c):
"""Convert y = ax^2 + bx + c to (a, h, k) for y = a(x - h)^2 + k."""
h = -b / (2 * a)
k = c - b**2 / (4 * a)
return a, h, k
print(standard_to_vertex(1, -6, 5))
# (1, 3.0, -4.0) -> y = (x - 3)^2 - 4
print(standard_to_vertex(2, 8, 3))
# (2, -2.0, -5.0) -> y = 2(x + 2)^2 - 5A conversion can be tested by comparing the two forms at many x-values. If they agree everywhere you test, the conversion is almost certainly right. Two different quadratics can agree at no more than two points, so testing eleven points is decisive.
def standard_to_vertex(a, b, c):
h = -b / (2 * a)
k = c - b**2 / (4 * a)
return a, h, k
def forms_agree(a, b, c):
"""True if a(x - h)^2 + k matches ax^2 + bx + c at x = -5..5."""
a, h, k = standard_to_vertex(a, b, c)
return all(
abs(a * (x - h) ** 2 + k - (a * x**2 + b * x + c)) < 1e-9
for x in range(-5, 6)
)
print(forms_agree(1, -6, 5), forms_agree(2, 8, 3), forms_agree(-1, 4, -1), forms_agree(1, 3, 1))
# True True True TrueThe small tolerance 1e-9 is needed because floating-point division can leave tiny rounding errors.
Common errors
| Error | What goes wrong | Fix |
|---|---|---|
| Using h = b/(2a) | The sign of h is flipped | h = -b/(2a). The bracket is (x - h), so a positive b gives a bracket like (x + something). |
| Forgetting a when balancing | You add 9 inside a bracket that has a factor of 2 in front, but you subtract only 9 outside | The added amount is multiplied by a, so subtract a times that amount. The formula k = c - b^2/(4a) already handles this. |
| Writing k = c + b^2/(4a) | The sign of the correction is wrong | You subtract the square you added. Confirm with k = y(h). |
| Factoring a out of c as well | Constants get divided by a by mistake | Factor a only from the x^2 and x terms. |
| Writing (x + h) when h is negative | A double sign change | Write (x - h) and substitute h. If h = -2, you get (x - (-2)) = (x + 2). |
Connecting back to graphing
After converting, apply the graphing procedure from the earlier chapters.
- Read the vertex (h, k) and the axis x = h.
- Use the sign of a to decide whether the vertex is a minimum or a maximum.
- Find the y-intercept. It is c from the original standard form, so you do not need to compute a*h^2 + k.
- Find x-intercepts with x = h ± sqrt(-k/a), if -k/a is not negative.
- Reflect points across the axis and sketch the curve.
For y = x^2 - 6x + 5, the vertex form is (x - 3)^2 - 4, so the vertex is (3, -4) and the axis is x = 3. The y-intercept is 5. Because -k/a = 4, the x-intercepts are 3 ± 2, which gives 1 and 5. The point (0, 5) reflects across x = 3 to (6, 5).
When not to convert
Completing the square is not always the most efficient route. If you only need the x-intercepts and the quadratic factors easily, factoring is quicker. If you only need the vertex, the formulas h = -b/(2a) and k = y(h) are enough. Convert to full vertex form when you need the transformation description, an exact equation to hand to someone else, or a clean starting point for graphing.
Exercise
Convert y = x^2 + 4x + 7 to vertex form. State the vertex and the minimum value.
Show answer
Here a = 1, b = 4, c = 7. Then h = -4/2 = -2 and k = 7 - 16/4 = 3. So y = (x + 2)^2 + 3. The vertex is (-2, 3), and the minimum value is 3. Check: (x + 2)^2 + 3 = x^2 + 4x + 4 + 3 = x^2 + 4x + 7.
Exercise
Convert y = -2x^2 + 12x - 13 to vertex form. Does the vertex give a maximum or a minimum, and what is its value?
Show answer
Here a = -2, b = 12, c = -13. Then h = -12/(2 -2) = 3 and k = -13 - 144/(4 -2) = -13 + 18 = 5. So y = -2(x - 3)^2 + 5. Because a is negative, the parabola opens downward, so the vertex (3, 5) is a maximum and its value is 5. Check: -2(x^2 - 6x + 9) + 5 = -2x^2 + 12x - 18 + 5 = -2x^2 + 12x - 13.
Exercise
A student converts y = 3x^2 + 12x + 5 and writes y = 3(x + 2)^2 + 5 - 4 = 3(x + 2)^2 + 1. Find the error and give the correct vertex form.
Show answer
The student added 4 inside the bracket, but the bracket is multiplied by 3, so the amount added is 12. The correct correction is 5 - 12 = -7. Using the formulas: h = -12/6 = -2 and k = 5 - 144/12 = -7. The correct form is y = 3(x + 2)^2 - 7. Check: 3(x^2 + 4x + 4) - 7 = 3x^2 + 12x + 12 - 7 = 3x^2 + 12x + 5.