Google Play badge

Use the method of completing the square to transform any quadratic equation in x into an equation of the form (x - p)² = q that has the same solutions. Derive the quadratic formula from this form.


Completing the Square and Deriving the Quadratic Formula

A surprising fact about quadratic equations is that one elegant idea can be used to solve any equation of the form \(ax^2+bx+c=0\), as long as \(a\neq 0\). That idea is completing the square. It does more than produce answers: it reveals the structure hidden inside a quadratic expression and leads directly to one of the most famous formulas in algebra.

Quadratic equations appear whenever a relationship is nonlinear rather than linear. The height of a basketball shot, the area of a rectangular garden, and the shape of a satellite dish can all involve quadratics. To solve these problems, we often need to find the values of \(x\) that make a quadratic expression equal to zero or to some other number.

Why this method matters

Factoring is fast when it works, but not every quadratic factors nicely. Graphing can show approximate answers, but not always exact ones. Completing the square gives a systematic method that works even when the solutions are irrational, and it also explains the shape and position of the parabola associated with the equation.

When we rewrite a quadratic equation in the form \((x-p)^2=q\), we are putting it into a form that is easy to solve. Once a square is isolated, we can take square roots and solve for \(x\). The challenge is learning how to create that square correctly.

Prerequisite ideas to recall

A quadratic equation in one variable is usually written in standard form as \(ax^2+bx+c=0\), where \(a\neq 0\).

A perfect-square trinomial has a form such as \(x^2+2rx+r^2=(x+r)^2\) or \(x^2-2rx+r^2=(x-r)^2\).

If \(u^2=q\), then solving for \(u\) gives \(u=\pm\sqrt{q}\), provided we are working in the real numbers and \(q\ge 0\).

One pattern is especially important: if you know the coefficient of \(x\), then half of it determines the constant needed to form a perfect square. For example, \(x^2+10x+25=(x+5)^2\) because half of \(10\) is \(5\), and \(5^2=25\).

What completing the square means

At its heart, completing the square means rewriting a quadratic expression so that it becomes a squared binomial plus or minus a constant. The geometric idea in [Figure 1] shows why this works: when the terms \(x^2\) and \(6x\) are arranged as a nearly complete square, adding \(9\) fills in the missing corner and creates \((x+3)^2\).

In symbols, if you have \(x^2+bx\), then adding \(\left(\dfrac{b}{2}\right)^2\) produces a perfect square:

\[x^2+bx+\left(\frac{b}{2}\right)^2=\left(x+\frac{b}{2}\right)^2\]

This is the key pattern you use again and again. If the coefficient of \(x^2\) is not \(1\), you first divide the entire equation by that coefficient so that the square-completion step works cleanly.

Algebra tile style diagram showing a large square partitioned into x^2 region, two 3x rectangles, and a small 9 square to illustrate x^2 + 6x + 9 as a completed square
Figure 1: Algebra tile style diagram showing a large square partitioned into x^2 region, two 3x rectangles, and a small 9 square to illustrate x^2 + 6x + 9 as a completed square

The method may seem artificial at first, but it is actually very precise. You are not "adding a random number." You are adding exactly the number that turns the quadratic part into a perfect square. To keep the equation balanced, anything added to one side must also be added to the other side, unless you first moved the constant term away.

A perfect-square trinomial is a trinomial that can be written as the square of a binomial, such as \(x^2+8x+16=(x+4)^2\).

The quadratic formula is a general formula that gives the solutions of \(ax^2+bx+c=0\): \(x=\dfrac{-b\pm\sqrt{b^2-4ac}}{2a}\).

The visual model from [Figure 1] also explains why the number added is related to half the linear coefficient. A binomial square such as \((x+r)^2\) expands to \(x^2+2rx+r^2\), so the coefficient of \(x\) is always twice the added number inside the binomial.

Transforming any quadratic equation into \((x-p)^2=q\)

There is a reliable sequence of algebraic steps, and [Figure 2] organizes them into a clear flow. Start with the general equation \(ax^2+bx+c=0\), where \(a\neq 0\), and aim to isolate a squared expression.

Here is the general method:

Step 1: Move the constant term to the other side: \(ax^2+bx=-c\).

Step 2: If \(a\neq 1\), divide every term by \(a\): \(x^2+\dfrac{b}{a}x=-\dfrac{c}{a}\).

Step 3: Add the square of half the coefficient of \(x\) to both sides. Half of \(\dfrac{b}{a}\) is \(\dfrac{b}{2a}\), so add \(\left(\dfrac{b}{2a}\right)^2\).

Step 4: Rewrite the left side as a square:

\[x^2+\frac{b}{a}x+\left(\frac{b}{2a}\right)^2=\left(x+\frac{b}{2a}\right)^2\]

Step 5: Simplify the right side to get the form \((x-p)^2=q\).

Flowchart from ax^2 + bx + c = 0 to ax^2 + bx = -c, then x^2 + (b/a)x = -c/a, then add (b/2a)^2, then rewrite as a squared binomial, ending with (x - p)^2 = q
Figure 2: Flowchart from ax^2 + bx + c = 0 to ax^2 + bx = -c, then x^2 + (b/a)x = -c/a, then add (b/2a)^2, then rewrite as a squared binomial, ending with (x - p)^2 = q

Notice that the target form is written as \((x-p)^2=q\), but \((x+p)^2=q\) is just as acceptable because subtraction of a negative number gives addition. For example, \((x+4)^2=9\) can be written as \((x-(-4))^2=9\). The important feature is that a square is isolated on one side.

Solved example 1

Let us solve a quadratic that already has leading coefficient \(1\): \(x^2+6x-7=0\).

Worked example: Solve \(x^2+6x-7=0\) by completing the square.

Step 1: Move the constant term.

From \(x^2+6x-7=0\), we get \(x^2+6x=7\).

Step 2: Add the square of half the coefficient of \(x\).

Half of \(6\) is \(3\), and \(3^2=9\). Add \(9\) to both sides: \(x^2+6x+9=7+9\).

Step 3: Rewrite the left side and simplify.

\((x+3)^2=16\).

Step 4: Take square roots.

\(x+3=\pm 4\).

Step 5: Solve both equations.

From \(x+3=4\), \(x=1\). From \(x+3=-4\), \(x=-7\).

Therefore, the solutions are \[x=1 \textrm{ or } x=-7\]

You can check these values in the original equation. Substituting \(x=1\) gives \(1+6-7=0\), and substituting \(x=-7\) gives \(49-42-7=0\). Both work.

Solved example 2

Now consider a quadratic whose leading coefficient is not \(1\): \(2x^2+8x-3=0\). In this situation, students often forget to divide every term by the leading coefficient before completing the square.

Worked example: Solve \(2x^2+8x-3=0\) by completing the square.

Step 1: Move the constant term.

\(2x^2+8x=3\).

Step 2: Divide by the coefficient of \(x^2\).

Divide every term by \(2\): \(x^2+4x=\dfrac{3}{2}\).

Step 3: Complete the square.

Half of \(4\) is \(2\), so add \(4\) to both sides: \(x^2+4x+4=\dfrac{3}{2}+4\).

Step 4: Rewrite and simplify.

\((x+2)^2=\dfrac{11}{2}\).

Step 5: Take square roots and solve.

\(x+2=\pm\sqrt{\dfrac{11}{2}}\), so \(x=-2\pm\sqrt{\dfrac{11}{2}}\).

The exact solutions are: \[x=-2\pm\sqrt{\frac{11}{2}}\]

If you prefer, you can rewrite \(\sqrt{\dfrac{11}{2}}\) as \(\dfrac{\sqrt{22}}{2}\). Then the solutions become \(x=-2\pm\dfrac{\sqrt{22}}{2}\). Both forms are equivalent.

Solved example 3

Completing the square also works when the solutions are not integers and the square root does not simplify much. That is one reason the method is so powerful.

Worked example: Solve \(x^2-5x+1=0\) by completing the square.

Step 1: Move the constant term.

\(x^2-5x=-1\).

Step 2: Complete the square.

Half of \(-5\) is \(-\dfrac{5}{2}\), and its square is \(\dfrac{25}{4}\). Add \(\dfrac{25}{4}\) to both sides: \(x^2-5x+\dfrac{25}{4}=-1+\dfrac{25}{4}\).

Step 3: Rewrite and simplify.

\(\left(x-\dfrac{5}{2}\right)^2=\dfrac{21}{4}\).

Step 4: Take square roots.

\(x-\dfrac{5}{2}=\pm\dfrac{\sqrt{21}}{2}\).

Step 5: Solve for \(x\).

\(x=\dfrac{5\pm\sqrt{21}}{2}\).

The solutions are: \[x=\frac{5\pm\sqrt{21}}{2}\]

This result is exact, which is often better than a decimal approximation. In algebra, exact forms preserve the full value without rounding error.

Special cases and what the value of \(q\) tells you

Once an equation is in the form \((x-p)^2=q\), the value of \(q\) tells you a great deal. It connects the algebra to the graph of the parabola and shows how many times the graph meets the \(x\)-axis.

[Figure 3] There are three main cases:

If \(q>0\), then \((x-p)^2=q\) has two real solutions because \(x-p=\pm\sqrt{q}\).

If \(q=0\), then \((x-p)^2=0\) has one real solution, namely \(x=p\). This is sometimes called a repeated or double root.

If \(q<0\), then there is no real solution because the square of a real number cannot be negative.

Three side-by-side parabolas on coordinate planes, one crossing the x-axis twice, one touching once at the vertex, and one not crossing, labeled to match q>0, q=0, q<0
Figure 3: Three side-by-side parabolas on coordinate planes, one crossing the x-axis twice, one touching once at the vertex, and one not crossing, labeled to match q>0, q=0, q<0

This is one reason completing the square is conceptually important. It does not just produce answers; it explains why some quadratics have two real solutions, one real solution, or no real solutions. Later, when complex numbers are introduced, equations with \(q<0\) can also be solved in a broader number system.

The same algebraic structure that solves quadratics also reveals the vertex form of a parabola. Rewriting an expression by completing the square helps identify the turning point of the graph immediately.

The single-touch case corresponds to the vertex lying exactly on the \(x\)-axis. That geometric fact matches the algebraic condition \((x-p)^2=0\).

Deriving the quadratic formula

Now we use the general method on \(ax^2+bx+c=0\). This derivation is not something to memorize line by line before understanding it. Instead, notice how each step follows the same logic used in the worked examples.

Start with

\(ax^2+bx+c=0\)

Move the constant term:

\(ax^2+bx=-c\)

Divide every term by \(a\):

\[x^2+\frac{b}{a}x=-\frac{c}{a}\]

Add \(\left(\dfrac{b}{2a}\right)^2\) to both sides:

\[x^2+\frac{b}{a}x+\left(\frac{b}{2a}\right)^2=-\frac{c}{a}+\left(\frac{b}{2a}\right)^2\]

Rewrite the left side as a square:

\[\left(x+\frac{b}{2a}\right)^2=-\frac{c}{a}+\frac{b^2}{4a^2}\]

Write the right side with a common denominator of \(4a^2\):

\[\left(x+\frac{b}{2a}\right)^2=\frac{-4ac+b^2}{4a^2}=\frac{b^2-4ac}{4a^2}\]

Take square roots:

\[x+\frac{b}{2a}=\pm\frac{\sqrt{b^2-4ac}}{2a}\]

Subtract \(\dfrac{b}{2a}\) from both sides:

\[x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}\]

This is the quadratic formula. It came directly from completing the square, not from nowhere. The formula is really a shortcut version of the whole process.

Why the formula always matches the completed-square method

Every time you use the quadratic formula, you are using the exact same reasoning as completing the square. The formula packages all the algebra into one expression, but the underlying structure is still the transformation from \(ax^2+bx+c=0\) to a squared binomial equal to a number.

Because the derivation uses only operations that preserve solutions, the formula gives exactly the same solutions as the original equation. That is why transforming to \((x-p)^2=q\) is not just a trick; it is a logically equivalent form of the equation.

Understanding the discriminant

The expression under the square root, \(b^2-4ac\), is called the discriminant. It appears naturally during the derivation, and it determines the nature of the solutions.

If \(b^2-4ac>0\), there are two distinct real solutions. If \(b^2-4ac=0\), there is one real repeated solution. If \(b^2-4ac<0\), there are no real solutions. This matches the three cases from \((x-p)^2=q\), because the value of \(q\) in the derivation is \(\dfrac{b^2-4ac}{4a^2}\), and \(4a^2\) is always positive.

ConditionWhat it meansNumber of real solutions
\(b^2-4ac>0\)Positive square root\(2\)
\(b^2-4ac=0\)Square root is \(0\)\(1\)
\(b^2-4ac<0\)Negative inside square root\(0\) real

Table 1. How the discriminant determines the number of real solutions of a quadratic equation.

This is a strong example of algebra revealing structure. A single expression, computed from the coefficients alone, tells you what kind of answer to expect before you solve the entire equation.

Real-world applications

[Figure 4] Quadratics often model situations with a maximum or minimum value. The path of a launched object, such as a kicked soccer ball or a thrown baseball, is approximately parabolic. Solving a quadratic equation can tell you when the ball reaches a certain height or when it lands.

Suppose the height of an object is modeled by \(h=-16t^2+48t+5\), where \(t\) is time in seconds and \(h\) is height in feet. To find when the object hits the ground, set \(h=0\): \(-16t^2+48t+5=0\). You can solve this by completing the square or by using the quadratic formula derived from it.

Graph of a projectile path as a parabola with launch point, highest point, and landing point labeled on coordinate axes
Figure 4: Graph of a projectile path as a parabola with launch point, highest point, and landing point labeled on coordinate axes

Quadratics also appear in design and geometry. If a rectangular garden has area \(60\) square meters and one side is \(x\) meters while the other is \(x+4\) meters, then \(x(x+4)=60\), which becomes \(x^2+4x-60=0\). Solving the equation gives the possible dimensions.

Engineers and physicists value methods like completing the square because they reveal more than just the final answer. The rewritten form can show symmetry, turning points, and constraints on possible values.

Common mistakes to avoid

One common error is forgetting to move the constant term before completing the square. Another is adding the needed square to only one side of the equation. A third is forgetting the \(\pm\) when taking square roots.

Students also often make a subtle mistake when \(a\neq 1\): they try to complete the square before dividing by \(a\). Although there are ways to manage that, the most straightforward method at this level is to divide first. The flow summarized earlier in [Figure 2] helps prevent this error.

Finally, remember that completing the square changes the form of the equation, not its solutions. If the algebra is done correctly, the new equation is equivalent to the original one.

Download Primer to continue