Completing the square

Main Article
Discussion
Related Articles  [?]
Bibliography  [?]
Citable Version  [?]

This editable Main Article is under development and subject to a disclaimer.

In algebra, completing the square is a way of rewriting a quadratic polynomial as the sum of a constant and a constant multiple of the square of a first-degree polynomial. Thus one has

${\displaystyle ax^{2}+bx+c=a(\cdots )^{2}+{\text{constant}}}$

and completing the square is the way of filling in the blank between the brackets. Completing the square is used for solving quadratic equations (the proof of the well-known formula for the general solution consists of completing the square). The technique is also used to find the maximum or minimum value of a quadratic function, or in other words, the vertex of a parabola.

The technique relies on the elementary algebraic identity

${\displaystyle (u+v)^{2}=u^{2}+2uv+v^{2}.\qquad \qquad (*)}$

Concrete examples

We want to fill in this blank:

${\displaystyle 3x^{2}+42x-5.\,}$

We write

{\displaystyle {\begin{aligned}3x^{2}+42x-5&{}=3(x^{2}+14x)-5\\&{}=3(x^{2}+2x\cdot 7)-5.\end{aligned}}}

Now the expression (${\displaystyle \scriptstyle x^{2}+2x\cdot 7}$) corresponds to ${\displaystyle \scriptstyle u^{2}+2uv}$ in the elementary identity labeled (*) above. If ${\displaystyle \scriptstyle x^{2}}$ is ${\displaystyle \scriptstyle u^{2}}$ and ${\displaystyle \scriptstyle 2x\cdot 7}$ is ${\displaystyle \scriptstyle 2uv}$, then ${\displaystyle \scriptstyle v}$ must be 7. Therefore ${\displaystyle \scriptstyle (u+v)^{2}}$ must be ${\displaystyle \scriptstyle (x+7)^{2}}$. So we continue:

{\displaystyle {\begin{aligned}&{}3(x^{2}+2x\cdot 7)-5\\&{}=3\left(x^{2}+2x\cdot 7+7^{2}\right)-5-3(7^{2}),\end{aligned}}}

Now we have added ${\displaystyle \scriptstyle 7^{2}}$ inside the parentheses, and compensated (thus justifying the "=") by subtracting ${\displaystyle \scriptstyle 3(7^{2})}$ outside the parentheses. The expression inside the parentheses is now ${\displaystyle \scriptstyle u^{2}+2uv+v^{2}}$, and by the elementary identity labeled (*) above, it is therefore equal to ${\displaystyle \scriptstyle (u+v)^{2}}$, i.e. to ${\displaystyle \scriptstyle (x+7)^{2}}$. So now we have

${\displaystyle 3(x+7)^{2}-5-3(7^{2})=3(x+7)^{2}-152.\,}$

Thus we have the equality

${\displaystyle 3x^{2}+42x-5=3(x+7)^{2}-152.\,}$

More abstractly

It is possible to give a closed formula for the completion in terms of the coefficients a, b and c. Namely,

${\displaystyle ax^{2}+bx+c=a\left(x+{\frac {b}{2a}}\right)^{2}-{\frac {\Delta }{4a}},}$

where ${\displaystyle \scriptstyle \Delta }$ stands for the well-known discriminant of the polynomial, that is ${\displaystyle \scriptstyle \Delta =b^{2}-4ac}$.

Indeed, we have

{\displaystyle {\begin{aligned}ax^{2}+bx+c&{}=a\left(x^{2}+{\frac {b}{a}}x\right)+c\\&{}=a\left(x^{2}+2{\frac {b}{2a}}x\right)+c.\end{aligned}}}

The last expression inside parentheses above corresponds to ${\displaystyle \scriptstyle u^{2}+2uv}$ in the identity labelled (*) above. We need to add the third term, ${\displaystyle \scriptstyle v^{2}}$:

{\displaystyle {\begin{aligned}ax^{2}+bx+c&{}=a\left(x^{2}+{\frac {b}{a}}x\right)+c\\&{}=a\left(x^{2}+2{\frac {b}{2a}}x+\left({\frac {b}{2a}}\right)^{2}\right)+c-a\left({\frac {b}{2a}}\right)^{2}\\&{}=a\left(x+{\frac {b}{2a}}\right)^{2}+c-{\frac {b^{2}}{4a}}\\&{}=a\left(x+{\frac {b}{2a}}\right)^{2}+{\frac {4ac-b^{2}}{4a}}.\end{aligned}}}