Completing the Square

x^2 + bx = (x + b/2)^2 - (b/2)^2 — make a perfect square.

The idea

Completing the square rewrites a quadratic $x^2 + bx + c$ in vertex form, $(x + h)^2 + k,$ in which $x$ appears exactly once. Once $x$ sits inside a single square, taking a square root undoes that square and the solutions follow directly — whether or not the quadratic factors.

Expanding $(x + h)^2 = x^2 + 2hx + h^2$ shows how to choose $h$: the middle term $2hx$ must match the given $bx$.

Algorithm.

Algorithm: Completing the Square Input: a quadratic x² + bx + c Output: the same expression written as (x + h)² + k 1. h = b/2, half the coefficient of x // (x + h)² then matches x² + bx 2. k = c − h² // takes back the h² the square supplies on its own 3. return (x + h)² + k // equals the original at every x

The name records a picture: a square of side $x$ and two strips of width $b/2$ assemble into a larger square once its missing corner is filled in.

Ways to work on it

Not sure where to start? Take the ten-question placement test.