Skip to content
  • Open the math solver
  • Ask the AI tutor
  • Find an AP course
  • Create a quiz
  • Open the calculator
  • Graphing Calculator
  • Browse all calculators
  • Read math guides
↑ ↓Enter to open · Esc to close
Solve a problem

Algebra

Completing the Square: A Step-by-Step Guide

By MathSolver Pro Editorial Team · Published

Completing the square rewrites x2+bxx^2 + bx as a perfect square minus a constant. It solves any quadratic, gives the vertex of a parabola, produces the quadratic formula, and reappears in circles and calculus.

The idea behind the method

A perfect square trinomial is the expansion of a squared binomial. Expanding (x+h)2(x + h)^2 gives x2+2hx+h2x^2 + 2hx + h^2: the constant term is the square of half the coefficient of xx. Completing the square means adding exactly that constant so an expression becomes a perfect square.

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

For example, half of 6 is 3 and 32=93^2 = 9, so x2+6x=(x+3)2−9x^2 + 6x = (x + 3)^2 - 9. Expanding the right side gives x2+6x+9−9x^2 + 6x + 9 - 9, which confirms it. Geometrically, x2+6xx^2 + 6x is an xx by xx square plus two 33 by xx strips, and the missing corner is a 33 by 33 square of area 9.

The same pattern works with a minus sign. Half of −10-10 is −5-5 and (−5)2=25(-5)^2 = 25, so x2−10x=(x−5)2−25x^2 - 10x = (x - 5)^2 - 25. The constant you add is always positive, because it is a square, while the sign inside the bracket matches the sign of bb. Keeping these two facts separate prevents most errors in the steps that follow.

Solving a quadratic equation by completing the square

  1. If the coefficient of x2x^2 is not 1, divide every term by it.
  2. Move the constant term to the right side.
  3. Add (b/2)2(b/2)^2 to both sides.
  4. Write the left side as (x+b/2)2(x + b/2)^2 and simplify the right side.
  5. Take the square root of both sides, remembering ±\pm, and solve for xx.

Example 1: x2+6x+5=0x^2 + 6x + 5 = 0

  1. Move the constant: x2+6x=−5x^2 + 6x = -5.
  2. Half of 6 is 3, and 32=93^2 = 9. Add 9 to both sides: x2+6x+9=4x^2 + 6x + 9 = 4.
  3. Factor: (x+3)2=4(x + 3)^2 = 4.
  4. Square root: x+3=±2x + 3 = \pm 2, so x=−1x = -1 or x=−5x = -5.
  5. Check x=−1x = -1: 1−6+5=01 - 6 + 5 = 0. Check x=−5x = -5: 25−30+5=025 - 30 + 5 = 0.

When the leading coefficient is not 1

Example 2: 2x2−8x+3=02x^2 - 8x + 3 = 0

  1. Divide by 2: x2−4x+32=0x^2 - 4x + \frac{3}{2} = 0.
  2. Move the constant: x2−4x=−32x^2 - 4x = -\frac{3}{2}.
  3. Half of −4-4 is −2-2, and (−2)2=4(-2)^2 = 4. Add 4: (x−2)2=4−32=52(x - 2)^2 = 4 - \frac{3}{2} = \frac{5}{2}.
  4. Square root: x−2=±52=±102x - 2 = \pm\sqrt{\frac{5}{2}} = \pm\frac{\sqrt{10}}{2}.
  5. So x=2±102x = 2 \pm \frac{\sqrt{10}}{2}, approximately 3.5813.581 and 0.4190.419.

The quadratic formula agrees: x=8±64−244=8±2104=2±102x = \frac{8 \pm \sqrt{64 - 24}}{4} = \frac{8 \pm 2\sqrt{10}}{4} = 2 \pm \frac{\sqrt{10}}{2}. With an odd middle coefficient the fractions are unavoidable but manageable. For x2+5x−1=0x^2 + 5x - 1 = 0, half of 5 is 52\frac{5}{2}, so (x+52)2=1+254=294\left(x + \frac{5}{2}\right)^2 = 1 + \frac{25}{4} = \frac{29}{4} and x=−5±292x = \frac{-5 \pm \sqrt{29}}{2}.

Complex solutions

If the right side ends up negative, there are no real solutions, but the method still gives the complex ones.

x2+4x+13=0  ⇒  (x+2)2=−9  ⇒  x+2=±3i  ⇒  x=−2±3ix^2 + 4x + 13 = 0 \;\Rightarrow\; (x + 2)^2 = -9 \;\Rightarrow\; x + 2 = \pm 3i \;\Rightarrow\; x = -2 \pm 3i

Check: (−2+3i)2=4−12i+9i2=−5−12i(-2 + 3i)^2 = 4 - 12i + 9i^2 = -5 - 12i, and −5−12i+4(−2+3i)+13=−5−12i−8+12i+13=0-5 - 12i + 4(-2 + 3i) + 13 = -5 - 12i - 8 + 12i + 13 = 0.

Vertex form of a parabola

The most common use of completing the square in graphing is converting y=ax2+bx+cy = ax^2 + bx + c into vertex form y=a(x−h)2+ky = a(x - h)^2 + k, where (h,k)(h, k) is the vertex. Since a square is never negative, the vertex is the minimum point when a>0a > 0 and the maximum point when a<0a < 0.

Example 3: y=x2−4x+7y = x^2 - 4x + 7

  1. Complete the square on x2−4xx^2 - 4x: (x−2)2−4(x - 2)^2 - 4.
  2. Substitute: y=(x−2)2−4+7=(x−2)2+3y = (x - 2)^2 - 4 + 7 = (x - 2)^2 + 3.
  3. Vertex (2,3)(2, 3), a minimum; the parabola never goes below y=3y = 3, so it has no x-intercepts.

Example 4: y=−2x2+12x−10y = -2x^2 + 12x - 10

  1. Factor −2-2 out of the xx terms only: y=−2(x2−6x)−10y = -2(x^2 - 6x) - 10.
  2. Complete the square inside: x2−6x=(x−3)2−9x^2 - 6x = (x - 3)^2 - 9.
  3. Distribute carefully: y=−2(x−3)2+18−10=−2(x−3)2+8y = -2(x - 3)^2 + 18 - 10 = -2(x - 3)^2 + 8.
  4. Vertex (3,8)(3, 8), a maximum. Check: at x=3x = 3, −18+36−10=8-18 + 36 - 10 = 8.

The most frequent error in Example 4 is forgetting to multiply the subtracted 9 by the factored-out −2-2. Expanding your vertex form back out is a quick check.

The shortcut h=−b2ah = -\frac{b}{2a} gives the same vertex x-coordinate; completing the square shows where that formula comes from. The quadratic calculator reports the vertex alongside the roots.

Deriving the quadratic formula

Completing the square on the general equation ax2+bx+c=0ax^2 + bx + c = 0 with a≠0a \neq 0 produces the quadratic formula, which is why the formula always works.

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

The middle step comes from adding b24a2\frac{b^2}{4a^2} to both sides and writing −ca-\frac{c}{a} as −4ac4a2-\frac{4ac}{4a^2}. The guide on how to solve quadratic equations explains when to use the formula, factoring or this method.

Circles and other applications

Completing the square in both xx and yy turns a general circle equation into centre-radius form.

Example 5: x2+y2−6x+4y−12=0x^2 + y^2 - 6x + 4y - 12 = 0

  1. Group and move the constant: (x2−6x)+(y2+4y)=12(x^2 - 6x) + (y^2 + 4y) = 12.
  2. Add 9 for xx and 4 for yy to both sides: (x−3)2+(y+2)2=25(x - 3)^2 + (y + 2)^2 = 25.
  3. Centre (3,−2)(3, -2), radius 5.

In calculus, the same step prepares integrals such as ∫dxx2+2x+5\int \frac{dx}{x^2 + 2x + 5}: writing the denominator as (x+1)2+4(x + 1)^2 + 4 gives 12arctan⁡x+12+C\frac{1}{2}\arctan\frac{x + 1}{2} + C. The integral calculator uses this substitution when it applies.

Common mistakes

  • Adding (b/2)2(b/2)^2 to one side only.
  • Completing the square before dividing by a leading coefficient other than 1.
  • Forgetting ±\pm when taking the square root, which loses a solution.
  • Using b2b^2 or b/2b/2 instead of (b/2)2(b/2)^2.
  • Reading the vertex sign wrong: (x−3)2(x - 3)^2 has h=3h = 3, and (x+3)2(x + 3)^2 has h=−3h = -3.

Try your own example in the completing the square calculator, which shows each of the steps above.

Reading information from the completed square

Once a quadratic is written as a(x−h)2+ka(x - h)^2 + k, a lot of information can be read off without further calculation. The vertex is (h,k)(h, k) and the axis of symmetry is the vertical line x=hx = h. The range follows directly: if a>0a > 0, the smallest value is kk and the range is [k,∞)[k, \infty); if a<0a < 0, the largest value is kk and the range is (−∞,k](-\infty, k].

The number of x-intercepts also follows. Setting a(x−h)2+k=0a(x - h)^2 + k = 0 gives (x−h)2=−ka(x - h)^2 = -\frac{k}{a}. If −ka-\frac{k}{a} is positive there are two intercepts, if it is zero the vertex touches the axis, and if it is negative the parabola never crosses the axis. In Example 3, (x−2)2=−3(x - 2)^2 = -3 has no real solution, which matches the vertex at height 3 on an upward parabola. In Example 4, −2(x−3)2+8=0-2(x - 3)^2 + 8 = 0 gives (x−3)2=4(x - 3)^2 = 4, so the intercepts are x=1x = 1 and x=5x = 5.

Optimisation problems use the same idea. If the profit from selling at price pp is P=−2p2+12p−10P = -2p^2 + 12p - 10 in hundreds of dollars, Example 4 shows the maximum profit is 8 hundred dollars at p=3p = 3. No calculus is needed, because the square term can only reduce the value below the vertex height.

Practice problems with answers

Try these before looking at the answers. Each one uses a step from the examples above.

  1. Solve x2−10x+21=0x^2 - 10x + 21 = 0. Answer: (x−5)2=4(x - 5)^2 = 4, so x=3x = 3 or x=7x = 7.
  2. Solve x2+2x−4=0x^2 + 2x - 4 = 0. Answer: (x+1)2=5(x + 1)^2 = 5, so x=−1±5x = -1 \pm \sqrt{5}.
  3. Write y=x2+8x+10y = x^2 + 8x + 10 in vertex form. Answer: y=(x+4)2−6y = (x + 4)^2 - 6, vertex (−4,−6)(-4, -6).
  4. Write y=3x2−6x+1y = 3x^2 - 6x + 1 in vertex form. Answer: y=3(x−1)2−2y = 3(x - 1)^2 - 2, vertex (1,−2)(1, -2).
  5. Find the centre and radius of x2+y2+2x−8y+8=0x^2 + y^2 + 2x - 8y + 8 = 0. Answer: (x+1)2+(y−4)2=9(x + 1)^2 + (y - 4)^2 = 9, centre (−1,4)(-1, 4), radius 3.

If an answer does not match, expand your completed square and compare it with the original line by line; the difference usually shows exactly which constant was added or subtracted incorrectly.

Why the method is worth learning

With the quadratic formula available, it is fair to ask why completing the square is still taught. The answer is that it is a transformation, not just a solving trick. It rewrites an expression so that the variable appears in only one place, inside a square. Once that happens, the expression is easy to analyse: its smallest or largest value, its symmetry and its zeros are all visible at once.

This idea recurs across mathematics. Conic sections such as circles, ellipses and hyperbolas are identified by completing the square in two variables. In statistics, the normal distribution's density involves a completed square in its exponent, and deriving many of its properties relies on the same algebra. In calculus, integrals with a quadratic under a square root or in a denominator become standard forms after this step. Physics uses it to find equilibrium points of energy functions.

Practising it on simple quadratics therefore builds a skill that later topics assume you have. If you can do Examples 1 to 5 without notes, you are well prepared for those uses, and for exam questions that ask you to show the method rather than just state roots.

Frequently asked questions

Why add (b/2) squared?

Because (x+h)2=x2+2hx+h2(x + h)^2 = x^2 + 2hx + h^2. Matching 2h2h with bb gives h=b/2h = b/2, so the constant that makes a perfect square is (b/2)2(b/2)^2.

Should I complete the square or just use the formula?

For solving, the formula is usually faster. Completing the square is the better tool for vertex form, circle equations and some integrals, and it explains where the formula comes from.

Does completing the square work for every quadratic?

Yes. Every quadratic with a≠0a \neq 0 can be rewritten this way, including those with irrational or complex solutions.

How do I complete the square when b is odd?

Use fractions rather than decimals. Half of bb is b2\frac{b}{2}, and you add b24\frac{b^2}{4}. For x2+3xx^2 + 3x, add 94\frac{9}{4} to get (x+32)2−94\left(x + \frac{3}{2}\right)^2 - \frac{9}{4}.

What do I do if the coefficient of x squared is negative?

Factor the negative coefficient out of the x2x^2 and xx terms, complete the square inside the bracket, and then multiply the subtracted constant by that coefficient when you remove the bracket, as in Example 4.

MathSolver Pro Editorial Team

Math content and review

Our editorial team writes every guide to explain the reasoning behind each method, not just the answer. Each worked example is checked against the site's own solver engines and automated tests before it is published, and articles are revised whenever a method or an exam format changes.