# Solving quadratics by completing the square

For example, solve x²+6x=-2 by manipulating it into (x+3)²=7 and then taking the square root.

#### What you will learn in this lesson

So far, you've either solved quadratic equations by taking the square root or by factoring. These methods are relatively simple and efficient, when applicable. Unfortunately, they are not always applicable.
In this lesson, you will learn a method for solving any kind of quadratic equation.

# Solving quadratic equations by completing the square

Consider the equation $x^2+6x=-2$. The square root and factoring methods are not applicable here.
You can't just take the square root of both sides because the equation includes $x$ raised to the first power.
Furthermore, you simply can't factor $x^2+6x+2$ as the product of two neat linear expressions. Try it yourself, it won't work.
But hope is not lost! We can use a method called completing the square. Let's start with the solution and then review it more closely.
\begin{aligned}(1)&&x^2+6x&=-2\\\\ \blueD{(2)}&&\Large\blueD{x^2+6x+9}&\Large\blueD{=7}&&\blueD{\text{Add 9, completing the square.}}\\\\ (3)&&(x+3)^2&=7&&\text{Factor the expression on the left.}\\\\ (4)&&\sqrt{(x+3)^2}&=\pm \sqrt{7}&&\text{Take the square root.}\\\\ (5)&&x+3&=\pm\sqrt{7}\\\\ (6)&&x&=\pm\sqrt{7}-3&&\text{Subtract 3.}\end{aligned}
In conclusion, the solutions are $x=\sqrt{7}-3$ and $x=-\sqrt{7}-3$.

### What happened here?

Adding $9$ to $x^2+6x$ in row $\blueD{(2)}$ had the fortunate result of making the expression a perfect square that can be factored as $(x+3)^2$. This allowed us to solve the equation by taking the square root.
This was no coincidence, of course. The number $9$ was carefully chosen so the resulting expression would be a perfect square.

### How to complete the square

To understand how $9$ was chosen, we should ask ourselves the following question: If $x^2+6x$ is the beginning of a perfect square expression, what should be the constant term?
Let's assume that the expression can be factored as the perfect square $(x+a)^2$ where the value of constant $a$ is still unknown. This expression is expanded as $x^2+2ax+a^2$, which tells us two things:
1. The coefficient of $x$, which we know to be $6$, should be equal to $2a$. This means that $a=3$.
1. The constant number we need to add is equal to $a^2$, which is $3^2=9$.
Try to complete a few squares on your own.
What is the missing constant term in the perfect square that starts with $x^2+10x$ ?

We want to add a constant number to $x^2+\tealD{10}x$ so it is in the form $x^2+\tealD{2a}x+a^2$. In that form, the coefficient of $x$ is $\tealD{2a}$, and in our expression that coefficient is $\tealD{10}$. Therefore, $\tealD{2a}=\tealD{10}$, which means $a=5$.
The constant number we need to add to get to that form is $a^2$, which is $5^2=25$. This way, the expression will be $x^2+10x+25$ which is factored as $(x+5)^2$.
In conclusion, the constant we should add is $25$.
What is the missing constant term in the perfect square that starts with $x^2-2x$ ?

We want to add a constant number to $x^2\tealD{-2}x$ so it is in the form $x^2+\tealD{2a}x+a^2$. In that form, the coefficient of $x$ is $\tealD{2a}$, and in our expression that coefficient is $\tealD{-2}$. Therefore, $\tealD{2a}=\tealD{-2}$ which means $a=-1$.
The constant number we need to add to get to that form is $a^2$, which is $(-1)^2=1$. This way, the expression will be $x^2-2x+1$, which is factored as $(x-1)^2$.
In conclusion, the constant we should add is $1$.
What is the missing constant term in the perfect square that starts with $x^2+\dfrac{1}{2}x$ ?

We want to add a constant number to $x^2+\tealD{\dfrac{1}{2}}x$ so it is in the form $x^2+\tealD{2a}x+a^2$. In that form, the coefficient of $x$ is $\tealD{2a}$, and in our expression that coefficient is $\tealD{\dfrac{1}{2}}$. Therefore, $\tealD{2a}=\tealD{\dfrac{1}{2}}$, which means $a=\dfrac{1}{4}$.
The constant number we need to add to get to that form is $a^2$, which is $\left(\dfrac{1}{4}\right)^2=\dfrac{1}{16}$. This way, the expression will be $x^2+\dfrac{1}{2}x+\dfrac{1}{16}$, which is factored as $\left(x+\dfrac{1}{4}\right)^2$.
In conclusion, the constant we should add is $\dfrac{1}{16}$.

### Challenge question

What is the missing constant term in the perfect square that starts with $x^2+b\!\cdot\!\!x$?

We want to add a constant number to $x^2+\tealD{b}\cdot x$ so it is in the form $x^2+\tealD{2a}x+a^2$. In that form, the coefficient of $x$ is $\tealD{2a}$, and in our expression that coefficient is $\tealD{b}$. Therefore, $\tealD{2a}=\tealD{b}$, which means $a=\dfrac{b}{2}$.
The constant number we need to add to get to that form is $a^2$, which is $\left(\dfrac{b}{2}\right)^2$. This way, the expression will be $x^2+2\cdot\dfrac{b}{2}\cdot x+\left(\dfrac{b}{2}\right)^2$, which is factored as $\left(x+\dfrac{b}{2}\right)^2$.
In conclusion, the constant we should add is $\left(\dfrac{b}{2}\right)^2$.
This challenge question gives us a shortcut to completing the square, for those that like shortcuts and don't mind memorizing things. It shows us that in order to complete $x^2+bx$ into a perfect square, where $b$ is any number, we need to add $\left(\dfrac{b}{2}\right)^2$ to it.
For example, in order to complete $x^2+\blueD{6}x$ into a perfect square, we added $\left(\dfrac{\blueD{6}}{2}\right)^2=9$ to it.

### Solving equations one more time

All right! Now that you're a certified square-completer, let's go back to the process of solving equations using our method.
Let's look at a new example, the equation $x^2-10x=-12$.
\begin{aligned}(1)&&x^2-10x&=-12\\\\ \blueD{(2)}&&\Large\blueD{x^2-10x+25}&\Large\blueD{=13}&&\blueD{\text{Add 25, completing the square.}}\\\\ (3)&&(x-5)^2&=13&&\text{Factor the expression on the left.}\\\\ (4)&&\sqrt{(x-5)^2}&=\pm \sqrt{13}&&\text{Take the square root.}\\\\ (5)&&x-5&=\pm\sqrt{13}\\\\ (6)&&x&=\pm\sqrt{13}+5&&\text{Add 5.}\end{aligned}
In order to make the original left-hand expression $x^2-10x$ a perfect square, we added $25$ in row $\blueD{(2)}$. As always with equations, we did the same for the right-hand side, which made it increase from $-12$ to $13$.
In general, the choice of the number to add in order to complete the square doesn't depend on the right-hand side, but we should always add the number to both sides.
Now it's your turn to solve some equations.
Solve $x^2-8x=5$.

\begin{aligned}x^2-8x&=5\\\\ x^2-8x+16&=21&&\text{Add 16, completing the square.)}\\\\ (x-4)^2&=21&&\text{Factor}\\\\ \sqrt{(x-4)^2}&=\pm\sqrt{21}&&\text{Take the square root.}\\\\ x-4&=\pm\sqrt{21}\\\\ x&=\pm\sqrt{21}+4&&\text{Add 4.}\end{aligned}
In conclusion, the solutions are $x=\sqrt{21}+4$ and $-\sqrt{21}+4$.
Solve $x^2+3x=-\dfrac{1}{4}$.

\begin{aligned}x^2+3x&=-\dfrac{1}{4}\\\\ x^2+3x+\dfrac{9}{4}&=2&&\text{Add }\dfrac{9}{4}\text{, completing the square.}\\\\\\ \left(x+\dfrac{3}{2}\right)^2&=2&&\text{Factor.}\\\\\\ \sqrt{\left(x+\dfrac{3}{2}\right)^2}&=\pm\sqrt{2}&&\text{Take the square root.}\\\\\\ x+\dfrac{3}{2}&=\pm\sqrt{2}\\\\ x&=\pm\sqrt{2}-\dfrac{3}{2}&&\text{Subtract }\dfrac{3}{2}\text{.}\end{aligned}
In conclusion, the solutions are $x=\sqrt{2}-\dfrac{3}{2}$ and $-\sqrt{2}-\dfrac{3}{2}$.

# Arranging the equation before completing the square

### Rule 1: Separate the variable terms from the constant term

This is how the solution of the equation $x^2+5x-6=x+1$ goes:
\begin{aligned}(1)&&x^2+5x-6&=x+1\\\\ \tealD{(2)}&&\tealD{x^2+4x-6}&\tealD{=1}&&\tealD{\text{Subtract }x.}\\\\ \purpleC{(3)}&&\purpleC{x^2+4x}&\purpleC{=7}&&\purpleC{\text{Add 6.}}\\\\ (4)&&x^2+4x+4&=11&&\text{Add 4, completing the square.}\\\\ (5)&&(x+2)^2&=11&&\text{Factor.}\\\\ (6)&&\sqrt{(x+2)^2}&=\pm\sqrt{11}&&\text{Take the square root.}\\\\ (7)&&x+2&=\pm\sqrt{11}\\\\ (8)&&x&=\pm\sqrt{11}-2&&\text{Subtract 2.}\end{aligned}
Completing the square on one of the equation's sides is not helpful if we have an $x$-term on the other side. This is why we subtracted $x$ in row $\tealD{(2)}$, placing all the variable terms on the left-hand side.
Furthermore, to complete $x^2+4x$ into a perfect square, we need to add $4$ to it. But before we do that, we need to make sure that all the constant terms are on the other side of the equation. This is why we added $6$ in row $\purpleC{(3)}$, leaving $x^2+4x$ on its own.

### Rule 2: Make sure the coefficient of $x^2$ is equal to $1$.

This is how the solution of the equation $3x^2-36x=-42$ goes:
\begin{aligned}(1)&&3x^2-36x&=-42\\\\ \maroonD{(2)}&&\maroonD{x^2-12x}&\maroonD{=-14}&&\maroonD{\text{Divide by 3.}}\\\\ (3)&&x^2-12x+36&=22&&\text{Add 36,completing the square.}\\\\ (4)&&(x-6)^2&=22&&\text{Factor.}\\\\ (5)&&\sqrt{(x-6)^2}&=\pm\sqrt{22}&&\text{Take the square root.}\\\\ (6)&&x-6&=\pm\sqrt{22}\\\\ (7)&&x&=\pm\sqrt{22}+6&&\text{Add 6.}\end{aligned}
The completing the square method only works if the coefficient of $x^2$ is $1$.
In the completing the square method, we compare the given expression to the general perfect square $(x+a)^2$, which is expanded as $x^2+2ax+a^2$. As you see, in this expression, the coefficient of $x^2$ is $1$.
If we look at an expression like $3x^2-36x$ as the beginning of a perfect square, it will not be equal to the general perfect square $(x+a)^2$. Instead, it will be equal to the general perfect square $(\sqrt3\cdot x+a)^2$, which is expanded as $3x^2+2a\sqrt3\cdot x+a^2$. Good luck with that!
This is why in row $\maroonD{(2)}$ we divided by the coefficient of $x^2$, which is $3$.
Sometimes, dividing by the coefficient of $x^2$ will result in other coefficients becoming fractions. This doesn't mean you did something wrong, it just means you will have to work with fractions in order to solve.
\begin{aligned}4x^2-4x&=11\\\\ x^2-x&=\dfrac{11}{4}&&\text{Divide by 4.}\\\\\\ x^2-x+\dfrac{1}{4}&=\dfrac{11}{4}+\dfrac{1}{4}&&\text{Add }\dfrac{1}{4}\text{, completing the square.}\\\\\\ \left(x-\dfrac{1}{2}\right)^2&=3&&\text{Factor.}\\\\\\ \sqrt{\left(x-\dfrac{1}{2}\right)^2}&=\pm\sqrt{3}&&\text{Take the square root.}\\\\\\ x-\dfrac{1}{2}&=\pm\sqrt{3}\\\\ x&=\pm\sqrt{3}+\dfrac{1}{2}&&\text{Add }\dfrac{1}{2}\text{.}\end{aligned}
In conclusion, the solutions are $x=\sqrt{3}+\dfrac{1}{2}$ and $-\sqrt{3}+\dfrac{1}{2}$.
Now it's your turn to solve an equation like this.
Solve $4x^2+20x-3=0$.
\begin{aligned}4x^2+20x-3&=0\\\\ 4x^2+20x&=3&&\text{Add 3}\\\\ x^2+5x&=\dfrac{3}{4}&&\text{Divide by 4.}\\\\\\ x^2+5x+\dfrac{25}{4}&=7&&\text{Add }\dfrac{25}{4}\text{, completing the square.}\\\\\\ \left(x+\dfrac{5}{2}\right)^2&=7&&\text{Factor.}\\\\\\ \sqrt{\left(x+\dfrac{5}{2}\right)^2}&=\pm\sqrt{7}&&\text{Take the square root.}\\\\\\ x+\dfrac{5}{2}&=\pm\sqrt{7}\\\\ x&=\pm\sqrt{7}-\dfrac{5}{2}&&\text{Subtract }\dfrac{5}{2}\text{.}\end{aligned}
In conclusion, the solutions are $x=\sqrt{7}-\dfrac{5}{2}$ and $-\sqrt{7}-\dfrac{5}{2}$.