How to Complete the Square

Updated · MathSolver

In 30 seconds

  • Completing the square rewrites x² + bx + c as (x + b/2)² plus a constant, by adding and subtracting (b/2)².
  • Use it to solve any quadratic equation, to find the vertex of a parabola, and to derive the quadratic formula.
  • If the leading coefficient is not 1, divide by it (or factor it out) first.

What is completing the square?

Completing the square is a method for rewriting a quadratic expression as a perfect square plus a constant. The expression x² + 6x is not a perfect square, but adding 9 turns it into x² + 6x + 9 = (x + 3)². The number you add is always half the coefficient of x, squared.

The method has three common uses. It solves quadratic equations, including ones that do not factor over the integers. It puts a quadratic function into vertex form, so you can read off the vertex of its graph. And it is how the quadratic formula is derived, so understanding it explains where that formula comes from.

x2+bx=(x+b2)2−(b2)2x^2 + bx = \left(x + \tfrac{b}{2}\right)^2 - \left(\tfrac{b}{2}\right)^2

The completing the square formula

Start from (x + b/2)² = x² + bx + (b/2)². The first two terms are exactly x² + bx, so x² + bx equals (x + b/2)² minus the extra (b/2)². That identity is the whole method: to complete the square, add (b/2)² to make a perfect square, and subtract it again (or add it to the other side of an equation) so the value does not change.

For example, with b = −4: half of −4 is −2, and (−2)² = 4. So x² − 4x = (x − 2)² − 4. The sign inside the bracket always matches the sign of b, while the number you add, (b/2)², is always positive.

The number to add for common values of b
ExpressionHalf of bAdd (b/2)²Perfect square
x² + 6x39(x + 3)²
x² − 4x−24(x − 2)²
x² + 10x525(x + 5)²
x² + 3x3/29/4(x + 3/2)²
x² − x−1/21/4(x − 1/2)²

How to complete the square step by step

To solve x² + 6x + 5 = 0 by completing the square, follow the same five steps every time. The method works whether or not the quadratic factors, which is its main advantage over factoring.

x2+6x+5=0;⇒;(x+3)2=4;⇒;x=−1 or x=−5x^2 + 6x + 5 = 0 ;\Rightarrow; (x + 3)^2 = 4 ;\Rightarrow; x = -1 \text{ or } x = -5
  • Move the constant to the right side: x² + 6x = −5.
  • Take half the coefficient of x and square it: (6/2)² = 9.
  • Add that number to both sides: x² + 6x + 9 = −5 + 9 = 4.
  • Write the left side as a perfect square: (x + 3)² = 4.
  • Take the square root of both sides, remembering ±, and solve: x + 3 = ±2, so x = −1 or x = −5.

When the leading coefficient is not 1

The method needs the x² coefficient to be 1. If it is not, divide every term of the equation by it first. For 2x² + 8x + 3 = 0, divide by 2 to get x² + 4x + 3/2 = 0, move the constant, x² + 4x = −3/2, and add (4/2)² = 4 to both sides: (x + 2)² = 5/2.

Taking square roots gives x + 2 = ±√(5/2), so x = −2 ± √10/2 (because √(5/2) = √10/2). When you are rewriting an expression rather than solving an equation, factor the coefficient out of the x terms instead of dividing: 2x² + 8x + 3 = 2(x² + 4x) + 3 = 2(x + 2)² − 8 + 3 = 2(x + 2)² − 5.

2x2+8x+3=2(x+2)2−52x^2 + 8x + 3 = 2(x + 2)^2 - 5

Completing the square with fractions

When the coefficient of x is odd, half of it is a fraction, and that is fine. For x² + 5x − 3 = 0, move the constant to get x² + 5x = 3. Half of 5 is 5/2, and (5/2)² = 25/4. Adding 25/4 to both sides gives (x + 5/2)² = 3 + 25/4 = 12/4 + 25/4 = 37/4.

Taking square roots gives x + 5/2 = ±√37/2, because √(37/4) = √37/√4 = √37/2. So x = (−5 ± √37)/2. Keeping the numbers as fractions instead of decimals avoids rounding errors, and the final answer is exact. To check, use decimals: √37 ≈ 6.083, so x ≈ 0.541 or x ≈ −5.541, and 0.541² + 5(0.541) − 3 ≈ 0.293 + 2.705 − 3 ≈ 0.

Fractions also appear when you divide by the leading coefficient. The steps stay the same; only the arithmetic changes. Writing every constant over the same denominator before adding, as in 12/4 + 25/4, is the easiest way to keep the right side correct.

x2+5x=3;⇒;(x+52)2=374;⇒;x=−5±372x^2 + 5x = 3 ;\Rightarrow; \left(x + \tfrac{5}{2}\right)^2 = \tfrac{37}{4} ;\Rightarrow; x = \frac{-5 \pm \sqrt{37}}{2}

Why it is called completing the square

The name comes from a picture. Draw x² as a square with side x. The term bx can be split into two rectangles, each x long and b/2 wide, placed along two sides of the square. Together the three pieces almost form a larger square with side x + b/2, but one small corner is missing.

That missing corner is a square with side b/2, so its area is (b/2)². Adding it completes the large square: x² + bx + (b/2)² = (x + b/2)². For x² + 6x, the two rectangles are x by 3, and the missing corner is 3 by 3, which is why you add 9. Remembering this picture makes it easy to recall which number to add, without memorising a formula.

Using completing the square to solve quadratic equations

Completing the square gives exact answers even when the roots are irrational. For x² − 4x − 2 = 0, move the constant to get x² − 4x = 2, add 4 to both sides to get (x − 2)² = 6, and take square roots: x = 2 ± √6. Factoring would not find these roots, because no pair of integers multiplies to −2 and adds to −4.

If the right side turns out negative, the equation has no real solutions. For x² + 2x + 5 = 0 you get (x + 1)² = −4, and no real number squared is negative. In a course that uses complex numbers, the solutions are x = −1 ± 2i.

x2−4x−2=0;⇒;(x−2)2=6;⇒;x=2±6x^2 - 4x - 2 = 0 ;\Rightarrow; (x - 2)^2 = 6 ;\Rightarrow; x = 2 \pm \sqrt{6}

Using completing the square to find the vertex

Any quadratic function can be written in vertex form, y = a(x − h)² + k, where (h, k) is the vertex of the parabola. Completing the square is how you get there. For y = x² − 6x + 5, add and subtract 9: y = (x² − 6x + 9) − 9 + 5 = (x − 3)² − 4. The vertex is (3, −4).

Reading the vertex form also tells you the minimum or maximum value. Because (x − 3)² is never negative, the smallest value of y is −4, reached at x = 3. If a is negative, the parabola opens downward and k is the maximum instead. The x-coordinate of the vertex always equals −b/(2a), which is a quick way to check your result: here −(−6)/(2 · 1) = 3.

y=x2−6x+5=(x−3)2−4;⇒;vertex (3,−4)y = x^2 - 6x + 5 = (x - 3)^2 - 4 ;\Rightarrow; \text{vertex } (3, -4)

How completing the square gives the quadratic formula

Apply the same steps to the general equation ax² + bx + c = 0 with a ≠ 0. Divide by a: x² + (b/a)x + c/a = 0. Move the constant: x² + (b/a)x = −c/a. Half the coefficient of x is b/(2a), so add b²/(4a²) to both sides.

The left side becomes (x + b/(2a))², and the right side simplifies to (b² − 4ac)/(4a²). Taking square roots gives x + b/(2a) = ±√(b² − 4ac)/(2a), and subtracting b/(2a) leaves the quadratic formula. The expression under the root, b² − 4ac, is the discriminant: it is the same number that decides whether completing the square leaves a positive, zero or negative right side.

(x+b2a)2=b2−4ac4a2;⇒;x=−b±b2−4ac2a\left(x + \frac{b}{2a}\right)^2 = \frac{b^2 - 4ac}{4a^2} ;\Rightarrow; x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}

Which method should you use?

Completing the square, factoring and the quadratic formula all solve the same equations. Choose the one that fits the question and the numbers.

If a question asks for the vertex, the maximum or minimum value, or vertex form, completing the square is the method to use, because the other two only give the roots. If it only asks for solutions, try factoring first, since it is fastest when it works, and fall back on the quadratic formula when the coefficients are large or awkward.

Comparing methods for quadratic equations
MethodBest whenExample
FactoringThe quadratic factors over the integersx² − 5x + 6 = (x − 2)(x − 3)
Completing the squareb is even and a = 1, or you need the vertexx² − 4x − 2 = 0 → x = 2 ± √6
Quadratic formulaAny quadratic, especially with awkward coefficients3x² + 7x − 2 = 0

Worked examples

Each example follows the five steps. Substitute the answers back into the original equation to check them.

  1. 1. Solve x² + 6x + 5 = 0.

    • x² + 6x = −5; add (6/2)² = 9 to both sides.
    • (x + 3)² = 4, so x + 3 = ±2.

    Answer: x = −1 or x = −5

  2. 2. Solve x² − 4x − 2 = 0.

    • x² − 4x = 2; add 4.
    • (x − 2)² = 6, so x − 2 = ±√6.

    Answer: x = 2 ± √6

  3. 3. Solve 2x² + 8x + 3 = 0.

    • Divide by 2: x² + 4x = −3/2; add 4.
    • (x + 2)² = 5/2, so x + 2 = ±√10/2.

    Answer: x = −2 ± √10/2

  4. 4. Solve x² + 3x − 1 = 0.

    • x² + 3x = 1; add (3/2)² = 9/4.
    • (x + 3/2)² = 13/4, so x + 3/2 = ±√13/2.

    Answer: x = (−3 ± √13)/2

  5. 5. Find the vertex of y = x² − 6x + 5.

    • Add and subtract 9: y = (x² − 6x + 9) − 9 + 5.
    • y = (x − 3)² − 4.

    Answer: Vertex (3, −4); minimum value −4

Common mistakes

Most errors happen in the step where the number is added. A quick substitution check catches them.

  • Adding (b/2)² to one side only. In an equation it must be added to both sides; in an expression it must also be subtracted.
  • Forgetting to divide by the leading coefficient first, which gives the wrong number to add.
  • Using b instead of b/2: for x² + 6x the number to add is 9, not 36.
  • Dropping the ± when taking the square root, which loses one of the two solutions.
  • Getting the sign inside the bracket wrong: x² − 4x becomes (x − 2)², not (x + 2)².

Practice problems with answers

Try each problem, then reveal the answer and check it by substitution.

  1. 1. Solve x² + 8x + 7 = 0

    Show answer

    x = −1 or x = −7

  2. 2. Solve x² − 10x + 18 = 0

    Show answer

    x = 5 ± √7

  3. 3. Solve 3x² − 12x + 5 = 0

    Show answer

    x = 2 ± √21/3

  4. 4. Write y = 2x² + 12x + 7 in vertex form

    Show answer

    y = 2(x + 3)² − 11; vertex (−3, −11)

  5. 5. Solve x² + 2x + 5 = 0

    Show answer

    No real solutions; x = −1 ± 2i

Frequently asked questions

What number do you add to complete the square?

Half the coefficient of x, squared: (b/2)². For x² + 10x that is (10/2)² = 25, giving x² + 10x + 25 = (x + 5)².

Does completing the square work for every quadratic?

Yes. Unlike factoring, it works for any quadratic equation. If the leading coefficient is not 1, divide by it first. If the right side ends up negative, the equation has no real solutions.

How do you complete the square when b is odd?

Use fractions. Half of an odd b is a fraction such as 5/2, and you add its square, 25/4. Write the constants over a common denominator before adding them, and keep the answer exact, for example x = (−5 ± √37)/2.

Is completing the square better than the quadratic formula?

Neither is always better. Completing the square is quicker when b is even and the leading coefficient is 1, and it is the method for finding the vertex. The quadratic formula is more direct for awkward coefficients, and it comes from completing the square anyway.

  • How to Factor Polynomials — Learn how to factor polynomials step by step: GCF, difference of squares, trinomials, grouping and cubics, with worked examples and common mistakes.

Stuck on a different problem? Try the AI math solver with steps or browse more math guides.