Completing the square

Using the method of addition squared, we can express the quadratic function ax2 + bx + c in the form (x + m)2 + n.

The squaring algorithm

The algorithm uses the classical formula for bracket augmentation:

$$(a+b)^2=a^2+2ab+b^2$$

The procedure is as follows. For now, suppose a = 1. Suppose we have a quadratic function f(x) = x2 + 6x + 1 and want to convert it to the form (x + m)2 + n. The first thing we do is to determine the values from the first parenthesis: (x + m)2. What number do we need to put after m? According to the formula, the equality (x + m)2 = x2 + 2mx + m2 must hold . In the function f we have x2, that's fine. But in place of the linear term we have 6x. What value must we choose after m for 6x = 2mx to be valid ? Obviously m = b/2 = 6/2 = 3 must be valid . So we always put half the value of b from the quadratic function after m.

This gives us the form (x + 3)2 − n. It remains to determine the number n. We now know that (x + m)2 = x2 + 2mx + m2 is valid. The x2 + 2mx part is wanted, but the expression m2 is left over, there is no equivalent in the function f. Therefore, we subtract m2 from the current result to get the form (x + m)2 − m2, which when multiplied equals x2 + 2mx + m2 − m2. After subtraction, we only have x2 + 2mx.

But in the function f we still have the absolute term c. We simply add it. We get the form (x + m)2 − m2 + c, after multiplying x2 + 2mx + m2 − m2 + c and after simplifying x2 + 2mx + c. Because m = b/2, this expression is equal to x2 + bx + c, so after multiplying the expression (x + m)2 − m2 + c we get back the original function, we have calculated correctly. (I repeat that a = 1, nowhere is it missing.)

So for the sample function f, we get an expression in the form of a square (x + 3)2 − 9 + 1 = (x + 3)2 − 8. We can try to multiply it back:

$$\begin{eqnarray} (x+3)^2-8&=&x^2+6x+9-8\\ &=&x^2+6x+1 \end{eqnarray}$$

The square addition method is used, for example, when you want to draw the graph of a quadratic function.

When a≠1

In the case where we have a function for which it is not true that a = 1, we proceed by plotting the whole function with the number a and proceed as we already know how. Example:

$$2x^2+16x-12=0$$

We output a two from the whole function:

$$2\cdot(x^2+8x-6)=0$$

We can already convert the function inside the parentheses to a square.

$$x^2+8x-6=(x+4)^2-16-6=(x+4)^2-22$$

We plug this result into the previous equation to get:

$$2\cdot(x^2+8x-6)=2\left((x+4)^2-22\right)=2(x+4)^2-44$$