How to Complete the Square: Method and Applications

Completing the square isn't a memorized trick, it's filling in a missing corner. Here's the geometry behind it, the exact steps to solve any quadratic with it, and how it finds a maximum without any calculus.

By Petrus Sheya

August 11, 2026 · 5 min read

Take x2+6xx^2 + 6x. It's close to being a perfect square, but not quite. Add exactly one number to it and it becomes one. That number isn't a magic constant someone made up, it's built right into the 6. Once you know how to find it, you can turn any quadratic into a perfect square plus a leftover. That's the whole trick, and it's called completing the square.


Why does x2+6xx^2 + 6x need anything added at all?

Picture x2x^2 as a literal square, side length xx. Now attach a rectangle of area 6x6x to one side. Together they form an L-shape, not a square, because a real square needs four matching sides and right now you've got a big square with an extra strip hanging off one edge.

Here's the move that makes it work: cut that 6x6x rectangle in half, and wrap one half around the right side of the square and the other half around the bottom. Now you've got a bigger square-ish shape with one small piece missing, right in the corner.

x² + bx is an almost-square: a big square plus two thin strips, missing one corner. Slide b, then reveal the exact piece needed to close the gap.

3x3x?xb/2 = 3x
x² + 6x  + ?
half of b3
(b/2)²9

Slide bb and look at that corner gap. Its side length is always half of bb, because you split bb down the middle to wrap it around two sides. So its area is always (b/2)2(b/2)^2. Fill that piece in and you've genuinely built a square, with side x+b/2x + b/2.

That's the entire idea. In symbols, we write it as:

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

Notice the minus sign at the end. We added (b/2)2(b/2)^2 to make the square work, so we have to subtract it right back out, otherwise we've changed the value of the expression. Add it, then take it away. That's completing the square in one sentence.


Turning the picture into an algorithm

Geometry is great for seeing why the trick works, but you don't want to draw a square every time you solve an equation. Here's the algebra version, applied to x2+6x+5=0x^2 + 6x + 5 = 0.

Watch x² + 6x + 5 = 0 turn into a perfect square, one legal move at a time. Nothing here changes the equation, it only changes how it's written.

+ 6x + 5 = 0Start with the equationcheck: (-1)² + 6(-1) + 5 = 0, and (-5)² + 6(-5) + 5 = 0
roots-1, -5
number added9

Every step is a legal move: adding the same number to both sides, or just rewriting one side in a different form. Nothing here secretly changes the equation. Once the left side is (x+3)2(x+3)^2, solving is just a square root away.

The general pattern for any x2+bx+c=0x^2 + bx + c = 0:

x2+bx=c        (x+b2)2=(b2)2cx^2 + bx = -c \;\;\Rightarrow\;\; \left(x+\frac{b}{2}\right)^2 = \left(\frac{b}{2}\right)^2 - c

And if you push this through with letters instead of numbers, all the way to the end, you get the quadratic formula. It's not a separate method you have to learn from scratch, it's completing the square done once in general so you never have to redo the algebra by hand. If the leading coefficient isn't 1, you factor it out first: ax2+bx+c=a(x+b2a)2+cb24aax^2+bx+c = a\left(x+\frac{b}{2a}\right)^2 + c - \frac{b^2}{4a}, same idea, just with an extra factor to track.


A quadratic already knows where its own minimum is

Here's something you don't get for free from factoring. Once you write a quadratic as (xh)2+k(x-h)^2 + k, called vertex form, the lowest point of the parabola is sitting right there in the equation: it's (h,k)(h, k).

Why? Because (xh)2(x-h)^2 can never be negative, its smallest possible value is 0, and that happens exactly when x=hx = h. At that instant, y=0+k=ky = 0 + k = k. Everywhere else, you're adding something positive to kk, so kk is the floor.

y = (x - h)² + k is a quadratic that already tells you its own vertex. Drag h and k and watch the parabola slide, no calculus required to find the bottom.

(2, -3)
Vertex form: y = (x - 2- 3 =  Expanded: y = x² - 4x + 1
vertex(2, -3)
min or maxminimum

Drag hh and kk and watch the parabola slide around, always keeping its lowest point exactly at (h,k)(h,k). This is why completing the square matters beyond solving equations. It's how you find a maximum or minimum without touching calculus, just by rewriting the expression.


Where this actually gets used: finding a maximum

Suppose you've got 40 meters of fence and want to build the biggest possible rectangular pen against a wall... how long should each side be?

Let one side be xx. Since the two sides you're fencing (not counting the wall) must add up to 20, the other side is 20x20 - x. The area is:

A(x)=x(20x)=x2+20xA(x) = x(20-x) = -x^2 + 20x

That's a downward parabola, so it has a maximum, and completing the square finds it directly:

A(x)=(x10)2+100A(x) = -(x-10)^2 + 100

The vertex is (10,100)(10, 100), so the biggest possible pen is a 10×1010 \times 10 square, with area 100 m2100\text{ m}^2. No derivatives, no guessing, just the same "fill the missing corner" idea from before, applied to a real shape.

40 meters of fence, one rectangular pen. Slide the side length x and watch the area curve, completing the square finds the peak without ever touching calculus.

x = 4 my = 16 mmax: 100 m² at x=10
Area(x) = x(20 - x) = -(x - 10)² + 100  →  keep sliding toward x = 10...
side y16 m
area64
max possible100

Slide xx toward 10 and watch the area climb toward exactly 100, then fall away on the other side. That symmetry isn't a coincidence, it's the same (xh)2(x-h)^2 shape doing the same thing it always does.

This kind of problem shows up everywhere real quadratics do: projectile motion asks for the peak height the same way, and any time you're optimizing something that follows a parabola, completing the square gets you the answer directly.


The short version

Completing the square works because x2+bxx^2 + bx is a square shape with one corner missing, and that missing piece always has area (b/2)2(b/2)^2. Add it in, subtract it back out, and any quadratic becomes "something squared plus a constant." That single move solves equations by taking a square root instead of guessing factors, and it reveals a parabola's vertex directly, which means it finds a maximum or minimum without any calculus at all. If you've also seen factoring or the three ways to solve a quadratic, this is the method sitting underneath both of them.

All visualizations are interactive React components running entirely in your browser. No libraries beyond React.