# Completing the square

Suppose we have $ax^2 + bx + c = 0$.

It’d be easier to complete the square if the $x$ term were even, so let’s double:

$2ax^2 + 2bx + 2c = 0$

It’s also be nicer if the $x^2$ term were a square, so let’s multiply by $2a$:

$4a^2x^2 + 4abx + 4ac = 0$

The first two terms are $(2ax)(2ax + 2b)$, which by difference of two squares, is $(2ax + b)^2 - b^2$:

$(2ax + b)^2 - b^2 + 4ac = 0$

Or better:

$(2ax + b)^2 = b^2 - 4ac$

Unsquare everything:

$2ax + b = \pm \sqrt{b^2 - 4ac}$

Rearrange:

$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$

Now, I know that won’t come as a surprise. However, there are two nuggets in doing it this way that I especially like:

- Making the first term a square and the second term even hugely simplifies the process of completing the square (who among us has not got confused by the “uh… it’s $a\left(x - \frac{b}{2a}\right)^2 - \frac{b^2}{4a^2}$, I think…?” process?).
- Dealing with the first two terms as a difference of two squares is probably unnecessary, but a link I hadn’t drawn before.