Completing the square · Mathematics Class 9–10 | StemPy Lab
Course 4.2·Lesson 1 of 3
Completing the square
Some quadratic equations do not factorise neatly. Completing the square solves them all. We add the number that turns x2+bx into a perfect square, (2b)2
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
When factorising is not enough
Try to factorise x2−4x+1. We need two numbers whose product is 1 and whose sum is −4. No whole numbers work, and no simple fractions either. Yet the equation x2−4x+1=0 does have roots. We need a method that works every time.
The idea comes from equations like
(x−2)2=3.
This one is easy. A number whose square is 3 is 3 or −3, so x−2=±3 and x=2±3. If we can turn any quadratic equation into the form (x+p)2=k, we can solve it. Turning it into that form is called completing the square.
A picture of the method
Completing the square as a picture. On the left, x squared plus 6x is drawn as a blue square of side x with two green strips, each 3 by x, along two of its sides. The corner between the strips, 3 by 3, is empty and marked with a question mark. An arrow labelled add 9 leads to the right-hand drawing, where the corner is filled with a small square of area 9. The whole shape is now one square of side x plus 3, so x squared plus 6x plus 9 equals x plus 3, all squared.
Draw x2+6x as an area. The x2 is a square of side x. Split the 6x into two strips, each 3 by x, and put one along each side of the square.
The shape is almost a square of side x+3. Only the corner is missing, a small square of side 3 and area 9. Add 9 and the square is complete:
x2+6x+9=(x+3)2.
The missing piece is always the square of half the coefficient of x.
The method, step by step
Solve x2+6x−7=0.
Move the number term.x2+6x=7.
Add the square of half of b to both sides. Half of 6 is 3, and 32=9. So x2+6x+9=16.
Write the left side as a square.(x+3)2=16.
Take the square root, with both signs.x+3=4 or x+3=−4.
Solve.x=1 or x=−7.
Check.12+6×1−7=0, and (−7)2+6×(−7)−7=49−42−7=0.
Now the equation that would not factorise: x2−4x+1=0. Half of −4 is −2, and (−2)2=4.
x2−4x+4=−1+4,(x−2)2=3,x=2±3.
So x≈3.732 or x≈0.268.
When the square term has a number in front
Solve 2x2−8x+3=0. First divide every term by 2, so that x2 stands alone:
x2−4x+23=0.
Then complete the square as before: (x−2)2=4−23=25. So x=2±25, which is about 3.58 or 0.42.
When there is no answer
Try x2+2x+5=0. Completing the square gives (x+1)2=−4. But the square of a real number is never negative. So this equation has no real roots. The method tells us so, without any guessing.
Practise with new numbers
Try it in Python
The program completes the square for three equations and prints the roots, or says that there are none.
Common mistakes
Adding b2 instead of (2b)2. For x2+6x we add 9, not 36.
Adding to one side only. Whatever is added to the left must be added to the right too.
Forgetting the negative root.(x+3)2=16 gives x+3=4orx+3=−4.
Not dividing first. With 2x2, divide every term by 2 before you halve the coefficient of x.
Remember these
x2+bx+(2b)2=(x+2b)2.
Move the number term, add (2b)2 to both sides, take the square root with ±, and solve.
If the right side comes out negative, there are no real roots.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Which number completes the square for x2−12x?
Solve (x−4)2=9.
Write x2+2x+7 in the form (x+p)2+q.
Why does x2+4x+9=0 have no real roots?
To solve 3x2+6x−2=0 by completing the square, what is the first step?
Enroll free in The Quadratic Formula and the Nature of Roots
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.