Completing the square is an algebraic technique that rewrites a quadratic polynomial as a multiple of the square of a linear expression plus a constant. Its basic identity is
The technique is used to solve quadratic equations, locate maxima and minima, identify geometric curves, evaluate integrals, and simplify quadratic expressions in several variables.
Basic identity and procedure
The method follows from the expansion
To make part of a perfect square, choose . Adding and subtracting gives
The added term supplies the constant needed for the square, while the subtracted term preserves the original expression.
For a general quadratic , the steps are:
Factor out of the quadratic and linear terms:
Complete the square inside the parentheses:
Collect the remaining constant terms:
For example,
This is an identity: both expressions have the same value for every . Completing the square does not require setting the expression equal to zero.
Solving quadratic equations
For an equation such as
completing the square gives
and therefore
The solutions are and . Both signs are necessary because either or has square .
Applied to the general equation , the method yields
Taking square roots and rearranging gives the quadratic formula:
The quantity
is the discriminant. For real coefficients:
- If , there are two distinct real roots.
- If , there is one repeated real root.
- If , there are no real roots, but there are two nonreal complex roots.
For instance,
so its zeros satisfy , giving .
Geometry and extrema
Vertex form of a parabola
The graph of a real quadratic function
is a parabola. Completing the square puts it into vertex form:
where
Its vertex is , and its axis of symmetry is . Since for real :
- If , the function has a global minimum .
- If , it has a global maximum .
Thus completing the square solves a basic optimization problem without using differentiation. For example,
has minimum value , attained at .
Area interpretation
For positive and , the expression can be represented by a square of side together with two rectangles, each of dimensions by . Arranging the rectangles along adjacent sides leaves a missing corner of area . Adding that corner produces a square of side .
This construction explains the phrase “completing the square.” The algebraic identity remains valid for negative values as well, even when the simple picture using positive lengths no longer applies directly.
Circles and other conics
In analytic geometry, completing the square identifies the centers and standard forms of many conic sections. For example,
becomes
It therefore represents a circle with center and radius .
Completing separate squares removes linear terms, but a translation alone does not remove a mixed term such as . For general conics, a rotation of coordinates may also be needed.
Applications in calculus and probability
Integration
Completing the square can convert a quadratic denominator into a standard form. For example,
so
The method is especially useful in calculus when a quadratic expression appears in a denominator, under a square root, or in an exponent. The resulting form determines the substitution or standard integral that applies.
Gaussian expressions
For ,
Consequently,
The same rewriting identifies expressions proportional to the density of a normal distribution. The exponent
corresponds, after normalization, to mean and variance .
In Bayesian inference, multiplying a normal likelihood by a normal prior produces an exponent that is quadratic in the unknown parameter. Completing the square reveals the mean and variance of the resulting normal posterior.
Several variables
The method extends to quadratic forms. Let and be real column vectors and let be an invertible symmetric matrix. Then
Here denotes transpose.
If is positive definite, the first term on the right is nonnegative and vanishes only when
The expression therefore has a unique global minimum
This is the multivariable counterpart of locating a parabola’s vertex. It is used in quadratic optimization and in calculations involving the multivariate normal distribution.
Positive definiteness is essential for this minimum conclusion. An invertible indefinite matrix still permits the identity, but its quadratic form can take both positive and negative values.
If is singular, its inverse does not exist. A suitable translation can remove the linear term only when the equation
has a solution. For symmetric , this requires to lie in the image of .
Historical development
Problems now described as completing the square occur in ancient Babylonian mathematics. Surviving procedures solve problems equivalent to quadratic equations by operations such as halving a coefficient, squaring it, and taking a square root. These procedures predate modern symbolic notation.
In the ninth century, al-Khwarizmi presented systematic treatments of quadratic equations together with geometric justifications. Because his presentation treated quantities as positive, it separated cases that modern notation combines into a single general equation. Modern symbolic algebra expresses the underlying square-completion procedure as one identity.
Scope and limitations
The usual formula requires ; when , the expression is not quadratic. It also requires division by . Consequently, over a field of characteristic , the ordinary procedure does not apply: the expansion of has no term with which to match an arbitrary linear coefficient.
Completing the square gives exact algebraic identities, but it does not automatically provide a numerically stable computational procedure. In floating-point arithmetic, evaluating differences such as can lose relative accuracy when the terms are nearly equal. Similarly, the standard quadratic formula can suffer cancellation for some coefficients; implementations concerned with numerical stability may use algebraically equivalent formulas instead.