Completing the square
Using the method of completing the square, we can write a quadratic function ax2 + bx + c in the form (x + m)2 + n.
The algorithm for completing the square
The algorithm uses the standard formula for squaring a bracket:
The procedure goes like this. For now, let’s assume that a = 1. Imagine we have the quadratic function f(x) = x2 + 6x + 1 and want to convert it to the form (x + m)2 + n. First we work out the values in the first bracket: (x + m)2. What number do we need to substitute for m? By the formula, we must have (x + m)2 = x2 + 2mx + m2. In the function f we have x2, which is fine. But in place of the linear term we have 6x. What value must we choose for m so that 6x = 2mx? Clearly we need m = b/2 = 6/2 = 3. So for m we always substitute half of the value of b from the quadratic function.
This gives us the form (x + 3)2 + n. It remains to find the number n. We already know that (x + m)2 = x2 + 2mx + m2. The part x2 + 2mx is what we want, but the term m2 is surplus – there is nothing like it in the function f. So we subtract m2 from our current result. This gives (x + m)2 − m2, which after expanding the brackets equals x2 + 2mx + m2 − m2. After the subtraction we are left with just x2 + 2mx.
In the function f, however, we still have the constant term c. We simply add it. This gives the form (x + m)2 − m2 + c, which after expanding the brackets is x2 + 2mx + m2 − m2 + c and after simplifying x2 + 2mx + c. Since m = b/2, this expression is equal to x2 + bx + c. So when we expand the brackets in (x + m)2 − m2 + c, we get the original function back, and we know our working was correct. (Remember that a = 1, so nothing is missing there.)
For our sample function f we therefore get the expression in completed-square form (x + 3)2 − 9 + 1 = (x + 3)2 − 8. We can check it by expanding the brackets again:
Completing the square is used, for example, when you want to sketch the graph of a quadratic function.
When a ≠ 1
If the function does not have a = 1, we take out the leading coefficient a as a common factor from the whole function and carry on as we already know how. Example:
Take out the factor 2 from the whole expression:
We already know how to complete the square for the expression inside the bracket.
We substitute this result into the previous equation, which gives: