Completing the square
Before reading this guide, it is recommended that you read Guide: Introduction to quadratic equations. Optionally, you may also find it useful to read [Guide: Expanding brackets] for the purposes of checking your answers, Guide: Laws of indices for algebraic manipulation, Guide: Introduction to rearranging equations for rearranging completed squares to solve quadratics and Guide: Introduction to complex numbers for dealing with square roots of negative numbers.
What is completing the square?
As you have seen in Guide: Introduction to quadratic equations, quadratic expressions are incredibly important in mathematics, and having a variety of techniques of dealing with them will be important tools in your future work.
One of these techniques is called completing the square, which takes a quadratic expression like \(ax^2 + bx + c\) and expresses it in the form \(a(x+p)^2 + q\); essentially, completing the square is like ‘factorization with a remainder’. Completing the square is a useful tool in many areas of mathematics, such as geometry (particularly in the theory of conic sections), integral calculus, and solving quadratic equations. Not only is it useful in these areas, it also gives you an opportunity to practise your skills involving algebraic manipulation and factorization.
This guide will focus on completing the square for quadratic expressions of the form \(ax^2 + bx + c\), both where \(a = 1\) and where \(a \neq 1\).
Expressions of the form \(x^2 + bx + c\)
The idea is to turn a quadratic expression like \[x^2 + bx + c\] into one that looks like \[(x+p)^2 + q\] where \(b,c,p,q\) are numbers. The best way to see how this works is via an example, which relies on expanding brackets (see [Guide: Expanding brackets] for more).
Suppose you want to complete the square of a quadratic expression like \(x^2 + 4x + 9\). The aim of completing the square is to find numbers \(p,q\) such that \[(x+p)^2 + q = x^2 + 4x + 9.\] Expanding the brackets on the left-hand side of this equation gives \[x^2 + 2px + p^2 + q = x^2 + 4x + 9.\] These two expressions are equal if and only if the coefficients match. Comparing the coefficients for the \(x\) terms on both sides gives \(2p = 4\) and so \(p = 2\). With this knowledge, you can then compare the \(9\) with the \(p^2 + q\) term to get \[4 + q = 9\] and so \(q = 5\). You can then write that \(x^2 + 4x + 9 = (x+2)^2 + 5\) and you have completed the square.
To check your answer, you can expand the brackets of the completed square: \[\begin{align*} (x+2)^2 + 5 &= x^2 + 4x + 4 + 5\\[0.5em] &= x^2 + 4x + 9 \end{align*}\] which is the original expression.
A pictorial representation of this process is given in Figure 1. Notice that breaking down the top and rearranging gives the bottom figure. This is the source of the phrase ‘completing the square’!
You can notice three things about Example 1:
If you are trying to write \(x^2 + bx + c\) in the form \((x+p)^2 + q\), then the value of \(p\) is going to be half that of \(b\), so \(p = b/2\).
Whether or not \(q\) is positive or negative depends on the value of \(c\). If \(c > p^2\), then \(q\) is positive; if \(c < p^2\), then \(q\) is negative.
This gives a method for working out the completed square of any expression of the form \(x^2 + bx + c\). See below for such a method.
Suppose you’re given an expression like \(x^2 + bx + c\) and you want to write it in the form \((x+p)^2 + q\). Here’s how to complete the square:
First, write \(p = b/2\). This gives you \(p\).
Work out \(p^2\), and solve the equation \(p^2 + q = c\) for \(q\). This gives you \(q\).
Then the expression \((x+p)^2 + q\) is equal to \(x^2 + bx + c\), and you have completed the square.
You can use this method to complete the square in the examples that follow.
Suppose you would like to complete the square of the expression \(x^2 + 12x + 20\). Here, you can identify the expression as in the form \(x^2 + bx + c\) with \(b = 12\) and \(c = 20\). Now, you can follow the steps in Method 1.
Here, \(p = b/2 = 12/2 = 6\).
Working out \(p^2\) gives \(6^2 = 36\). Solving \(p^2 + q = c\) gives \(q\), and so here \(36 + q = 20\). It follows that \(q = -16\).
You can then say that \((x + 6)^2 - 16 = x^2 + 12x + 20\). Expanding the brackets to check your answer gives \[\begin{align*} (x+6)^2 - 16 &= x^2 + 12x + 36 - 16 = x^2 + 12x + 20. \end{align*}\]
You can see in this example that \(q\) may be negative. The next example demonstrates a case where \(p\) is negative.
Suppose you would like to complete the square of the expression \(y^2 - 10y + 41\). Once again, you can identify the expression as in the form \(y^2 + by + c\) with \(b = -10\) and \(c = 41\). Now, you can follow the steps in Method 1.
Here, \(p = b/2 = -10/2 = -5\).
Working out \(p^2\) gives \((-5)^2 = 25\). Solving \(p^2 + q = c\) gives \(q\), and so here \(25 + q = 41\). It follows that \(q = 16\).
You can then say that \((y - 5)^2 + 16 = y^2 - 10y + 41\). Expanding the brackets to check your answer gives \[\begin{align*} (y-5)^2 + 16 &= y^2 - 10y + 25 + 16 = y^2 - 10y + 41. \end{align*}\]
The next example contains a case where \(b\) is odd, and so \(p\) will not be a whole number.
You are given the quadratic expression \(x^2 + 3x - 1\), and you would like to complete the square. Identifying the expression as in the form \(x^2 + bx + c\) with \(b = 3\) and \(c = -1\), you can follow the steps in Method 1.
Here, \(p = b/2 = 3/2\).
Working out \(p^2\) gives \((3/2)^2 = 9/4\). Solving \(p^2 + q = c\) gives \(q\), and so here \[\frac{9}{4} + q = -1.\] Since \(-1 = -4/4\), you can work out that \(q = -13/4\).
You can then say that \(\displaystyle \left(x + \frac{3}{2}\right)^2 - \frac{13}{4}\) is the completed square of \(x^2 + 3x - 1\).
Expanding the brackets to check your answer gives \[\begin{align*} \left(x + \frac{3}{2}\right)^2 - \frac{13}{4} &= x^2 + 3x + \frac{9}{4} - \frac{13}{4}\\[0.5em] &= x^2 + 3x - \frac{4}{4} = x^2 + 3x - 1. \end{align*}\]
Here’s a final example of an important quadratic expression previously seen in Guide: Using the quadratic formula.
You are given the quadratic expression \(m^2 - m - 1\), and you would like to complete the square. Identifying the expression as in the form \(m^2 + bm + c\) with \(b = -1\) and \(c = -1\), you can follow the steps in Method 1.
Here, \(p = -1/2\).
Working out \(p^2\) gives \((-1/2)^2 = 1/4\). Solving \(p^2 + q = c\) gives \(q\), and so here \[\frac{1}{4} + q = -1.\] Since \(-1 = -4/4\), you can work out that \(q = -5/4\).
You can then say that \(\displaystyle\left(m - \frac{1}{2}\right)^2 - \frac{5}{4}\) is the completed square of \(m^2 - m - 1\).
Expanding the brackets to check your answer gives \[\begin{align*} \left(m - \frac{1}{2}\right)^2 - \frac{5}{4} &= m^2 - m + \frac{1}{4} - \frac{5}{4}\\[0.5em] &= m^2 - m - \frac{4}{4} = m^2 - m - 1. \end{align*}\]
Expressions of the form \(ax^2 + bx + c\)
Unfortunately, not every quadratic expression has the coefficient of the \(x^2\) term equal to \(1\). It is often the case that that \(a\neq 1\) in the quadratic expression \(ax^2 + bx + c\). So how do you deal with this?
The idea is to factorize the quadratic expression, taking out the constant \(a\) (which is necessarily non-zero in a quadratic expression). Doing this gives \[ax^2 + bx + c = a\left(x^2 + \frac{b}{a}x + \frac{c}{a}\right)\] You can then notice that the term inside the brackets is of the form \(x^2 + rx + s\), where \(r,s\) are numbers; but you can complete the square of these kinds of expressions already!
So, to complete the square of \(ax^2 + bx + c\) into a form of \(a(x+p)^2 + t\), you can follow this method:
Suppose you’re given an expression like \(ax^2 + bx + c\) and you want to write it in the form \(a(x+p)^2 + t\). Here’s how to complete the square:
First of all, take out a factor of \(a\) to get \(a(x^2 + rx + s)\), where \(r = b/a\) and \(s = c/a\).
Complete the square on \(x^2 + rx + s\) to get \((x+p)^2 + q\).
The expression \(a((x+p)^2 + q)\) is equal to \(ax^2 + bx + c\). Multiplying out the brackets shows that \(a(x+p)^2 + aq = ax^2 + bx + c\).
There is a way of completing the square for \(ax^2 + bx + c\) in the form \((dx + e)^2 + f\). The formula is given here: \[ax^2 + bx + c = \left(x\sqrt{a} + \frac{b}{2\sqrt{a}}\right)^2 + \left(c - \frac{b^2}{4a}\right)\] This works well if \(a\) is a perfect square; see Example 8 for more.
Do not try and remember this formula! It is much better to reinforce the methods given in this guide rather than input numbers into this formula.
Suppose you would like to complete the square of the expression \(2x^2 + 12x + 24\). Here, you can identify the expression as in the form \(ax^2 + bx + c\) with \(a = 2\), \(b = 12\) and \(c = 24\). Now, you can follow the steps in Method 1.
Taking out a factor of \(a = 2\) gives the expression as \[2x^2 + 12x + 24 = 2(x^2 + 6x + 12)\] You can now notice the part inside the brackets is of the form \(x^2 + rx + s\) with \(r = 6\) and \(s = 12\).
Now, complete the square on \(x^2 + 6x + 12\). Here \(p = 6/2 = 3\). Working out \(p^2\) gives \(3^2 = 9\). Solving \(p^2 + q = s\) gives \(q\), and so here \(9 + q = 12\). It follows that \(q = 3\).
This means that \(2x^2 + 12x + 24 = 2((x+3)^2 + 3)\) and so taking out the last term in brackets gives \[2x^2 + 12x + 24 = 2(x+3)^2 + 6\] This is your final answer.
Once again, you can expand the brackets to check your answer: \[\begin{align*} 2(x+3)^2 + 6 &= 2(x^2 + 6x + 9) + 6\\[0.5em] &= 2x^2 + 12x + 18 + 6 = 2x^2 + 12x + 24 \end{align*}\]
Suppose you would like to complete the square of the expression \(4y^2 + 12y - 4\). You can identify the expression as in the form \(ay^2 + by + c\) with \(a = 4\), \(b = 12\) and \(c = -4\).
Taking out a factor of \(a = 4\) gives the expression as \[4y^2 + 12y - 4 = 4(y^2 + 3y - 1)\] You can now notice the part inside the brackets is of the form \(y^2 + ry + s\) with \(r = 3\) and \(s = -1\).
Now, complete the square on \(y^2 + 3y -1\). You can notice that you have already done this in Example 4 with \(x\) as the variable. So here \[y^2 + 3y - 1 = \left(y + \frac{3}{2}\right)^2 - \frac{13}{4}.\]
This means that \(\displaystyle 4y^2 + 12y - 4 = 4\left(\left(y + \frac{3}{2}\right)^2 - \frac{13}{4}\right)\) and so taking out the last term in brackets gives \[4y^2 + 12y - 4 = 4\left(y + \frac{3}{2}\right)^2 - 4\cdot \frac{13}{4} = 4\left(y + \frac{3}{2}\right)^2 - 13.\]
Once again, you can expand the brackets to check your answer: \[\begin{align*} 4\left(y + \frac{3}{2}\right)^2 - 13 &= 4\left(y^2 + 3y + \frac{9}{4}\right) - 13\\[0.5em] &= 4y^2 + 12y + 9 - 13 = 4y^2 + 12y - 4 \end{align*}\]
You can simplify this example even further. You could notice here that \(a=4\) is a square number; specifically, \(2\cdot 2\). By writing \(4 = 2\cdot 2\), you can use the laws of indices (see Guide: Laws of indices) to say that \[\begin{align*} 4\left(y + \frac{3}{2}\right)^2 &= 2^2\left(y + \frac{3}{2}\right)^2 = \left(2\left(y + \frac{3}{2}\right)\right)^2 = (2y + 3)^2 \end{align*}\] and so \(4y^2 + 12y - 4 = (2y+3)^2 - 13\). This technique is particularly useful if \(a\) is the square of an integer; less useful if it is not!
The final example in this section deals with some slightly odder looking numbers. Although the numbers will not be as nice as the previous examples, if you follow the process carefully then uglier numbers will not matter!
Suppose you would like to complete the square of the expression \(3m^2 - 2m - 1\). You can identify the expression as in the form \(am^2 + bm + c\) with \(a = 3\), \(b = -2\) and \(c = -1\).
Taking out a factor of \(a = 3\) gives the expression as \[3m^2 - 2m - 1 = 3\left(m^2 - \frac{2}{3}m - \frac{1}{3}\right)\] You can now notice the part inside the brackets is of the form \(m^2 + rm + s\) with \(r = -2/3\) and \(s = -1/3\).
Now, complete the square on \(m^2 - \frac{2}{3}m - \frac{1}{3}\). Here \(p = (-2/3)/2 = -1/3\). Working out \(p^2\) gives \((-1/3)^2 = 1/9\). Solving \(p^2 + q = s\) gives \(q\), and so here \[\frac{1}{9} + q = -\frac{1}{3}\] It follows that \(q = -4/9\).
This means that \(\displaystyle 3m^2 - 2m - 1 = 3\left(\left(m - \frac{1}{3}\right)^2 - \frac{4}{9}\right)\) and so taking out the last term in brackets gives \[3m^2 - 2m - 1 = 3\left(m - \frac{1}{3}\right)^2 - 3\cdot \frac{4}{9} = 3\left(m - \frac{1}{3}\right)^2 - \frac{4}{3}\] and this is your final answer.
Once again, you can expand the brackets to check your answer: \[\begin{align*} 3\left(m - \frac{1}{3}\right)^2 - \frac{4}{3} &= 3\left(m^2 - \frac{2}{3}m + \frac{1}{9}\right) - \frac{4}{3}\\[0.5em] &= 3m^2 - 2m + \frac{1}{3} - \frac{4}{3} = 3m^2 - 2m - 1 \end{align*}\]
Solving quadratic equations
You can use what you have learned in this guide to solve quadratic equations of the form \(ax^2 + bx^2 + c = 0\). To do this, write the expression \(ax^2 + bx + c\) as a completed square \(a(x+p)^2 + t\), which is equal to \(0\). You can then rearrange the equation (see Guide: Introduction to rearranging equations for more) for \(x\) to work out the roots of the quadratic equation.
You may find that \((x+p)^2\) is equal to a negative number. You can use imaginary numbers to then solve the quadratic. See Guide: Introduction to complex numbers for more.
Suppose that you want to solve the quadratic equation \(x^2 + 12x + 20 = 0\). You completed the square of \(x^2 + 12x + 20\) in Example 2, getting \((x+6)^2 - 16\). So \((x+6)^2 - 16 = 0\); taking the \(16\) over and removing the square - taking care to include both the positive and negative roots of \(16\) - gives \[x + 6 = \pm 4\] Therefore \(x = -6 + 4= -2\) and \(x = -6 - 4 = -10\) are the two solutions of \(x^2 + 12x + 20 = 0\).
Suppose that you want to solve the quadratic equation \(y^2 - 10y + 41 = 0\). You completed the square of \(y^2 - 10y + 41\) in Example 3, getting \((y - 5)^2 + 16\). So \((y - 5)^2 + 16 = 0\); taking the \(16\) over gives \((y-5)^2 = -16\). Using imaginary numbers (see Guide: Introduction to complex numbers) gives \[y-5 = \pm 4i\] Therefore \(y = 5 + 4i\) and \(y = 5 - 4i\) are the two complex solutions of \(y^2 - 10y + 41 = 0\).
You can complete the square on the general quadratic equation \(ax^2 + bx + c = 0\) to get the quadratic formula, which gives solutions to any quadratic equation: see Guide: Using the quadratic formula for more, and Proof: The quadratic formula for how it is done.
Quick check problems
You are given four quadratic expressions below. Complete the square on each of them, by giving the constants. If your answer contains rational numbers, they should be written as fractions in their simplest form.
\(x^2 - 6x = (x+p)^2 + q\), where \(p=\) and \(q=\) .
\(x^2 + 8x + 1 = (x+p)^2 + q\), where \(p=\) and \(q=\) .
\(x^2 - 5x + 8 = (x+p)^2 + q\), where \(p=\) and \(q=\) .
\(2x^2 + 8x + 15 = a(x+p)^2 + q\), where \(a=\) , \(p=\) and \(q=\) .
Further reading
For more questions on the subject, please go to Questions: Completing the square.
Version history
v1.0: initial version created 09/24 by tdhc.