Skip to main content

Math Trailhead

Section Where the quadratic formula comes from

The formula is the result of one reusable idea: completing the square. We give a visual example of this below and then show how the quadratic formula can be derived.

Visual example of completing the square.

Consider \(x^2+6x=7\text{.}\) For the picture, temporarily suppose \(x>0\) so it represents a length. Draw a square of area \(x^2\text{,}\) and split the rectangle of area \(6x\) into two strips, each with area \(3x\text{.}\) Place one strip on the right and one below the square. A \(3\)-by-\(3\) corner is missing.
Two area diagrams. The first has a square labeled x squared with two adjacent strips labeled 3x and a dashed missing 3 by 3 corner. The second fills the corner with area 9, making a square of side x+3. Below: x squared plus 6x plus 9 equals (x+3) squared.
Figure 116. Split the linear term in half, then fill the missing corner. Adding area \(9\) creates a square with side \(x+3\text{.}\)
The equation balances two quantities. Add \(9\) to both sides, not just to the picture:
\begin{align*} x^2+6x&=7,\\ x^2+6x+9&=7+9,\\ (x+3)^2&=16,\\ x+3&=\pm4,\\ x&=1\quad\text{or}\quad x=-7. \end{align*}
Although negative \(x\) cannot serve as a side length in this picture, the identity \(x^2+6x+9=(x+3)^2\) holds for every real \(x\text{.}\) Both algebraic solutions are valid: \(1+6=7\) and \(49-42=7\text{.}\) The diagram motivates the identity; the algebra is what extends it to all inputs.
For a general linear coefficient \(p\text{,}\) half of it is \(p/2\) and the missing corner has square \((p/2)^2\text{:}\)
\begin{equation*} x^2+px+\left(\frac p2\right)^2 =\left(x+\frac p2\right)^2. \end{equation*}
Expanding the right side verifies this even when \(p\) or \(x\) is negative, so no assumption about positive lengths is needed in the derivation below.

Quadratic formula derivation.

Start with \(ax^2+bx+c=0\) and \(a\ne0\text{.}\) The steps work for positive or negative \(a\text{.}\)
  1. Divide by \(a\) and move the constant. A leading coefficient of \(1\) lets us use the square identity:
    \begin{equation*} x^2+\frac ba x=-\frac ca. \end{equation*}
  2. Halve the coefficient of \(x\text{,}\) square it, and add to both sides. Here the half-coefficient is \(b/(2a)\text{:}\)
    \begin{equation*} x^2+\frac ba x+\frac{b^2}{4a^2} =-\frac ca+\frac{b^2}{4a^2}. \end{equation*}
  3. Write the left side as a square and combine the right side over a common denominator. Since \(-c/a=-4ac/(4a^2)\text{,}\)
    \begin{equation*} \left(x+\frac{b}{2a}\right)^2 =\frac{b^2-4ac}{4a^2}. \end{equation*}
    This explains the discriminant: \(b^2-4ac\) appears when we combine the two terms on the right.
  4. Multiply both sides by \(4a^2\text{.}\) This avoids having to simplify \(\sqrt{a^2}=|a|\text{:}\)
    \begin{equation*} (2ax+b)^2=b^2-4ac. \end{equation*}
  5. Take both square-root branches, then solve for \(x\text{.}\) When \(D=b^2-4ac\ge0\text{,}\)
    \begin{align*} 2ax+b&=\pm\sqrt{b^2-4ac},\\ 2ax&=-b\pm\sqrt{b^2-4ac},\\ x&=\boxed{\frac{-b\pm\sqrt{b^2-4ac}}{2a}.} \end{align*}
    If \(D<0\text{,}\) a real square cannot equal \(D\text{,}\) so there are no real solutions. Allowing complex square roots gives the same formula for the two complex solutions.
Every step preserves the solutions: we divide only by the nonzero numbers \(a\) and \(2a\text{,}\) add equal quantities to both sides, and keep both possibilities when undoing a square. The symbol \(\pm\) is essential because both a positive number and its negative have the same square.

Graphical interpretation of completing the square.

The completed-square equation also says
\begin{equation*} \left(x-\left(-\frac b{2a}\right)\right)^2 =\frac{D}{4a^2}. \end{equation*}
If \(D>0\text{,}\) the two real roots lie the same horizontal distance from the symmetry line \(x=-b/(2a)\text{.}\) That distance is \(\sqrt{D}/(2|a|)\text{.}\) For the function in our first page, \(f(x)=x^2-2x-3=(x-1)^2-4\text{,}\) the equation \(f(x)=0\) becomes \((x-1)^2=4\text{.}\) The roots are two units to either side of \(x=1\text{.}\)
Graph of (x-1) squared minus 4 with vertex (1,-4), symmetry line x=1, and roots -1 and 3. Two arrows show a horizontal distance of 2 from the symmetry line to each root.
Figure 117. The two signs in the formula locate roots on opposite sides of the symmetry line. Here \(x=1\pm2\) gives \(-1\) and \(3\text{.}\)
If \(D=0\text{,}\) that distance is zero: the two branches coincide at the vertex. If \(D<0\text{,}\) there is no real distance with that square, and the graph has no x-intercept. This is why the formula, factoring, and the graph all tell the same story.

Example 118.

Solve \(x^2-6x+2=0\) by completing the square, then compare with the quadratic formula.
Solution.
Move the constant to obtain \(x^2-6x=-2\text{.}\) Half of \(-6\) is \(-3\text{;}\) its square is \(9\text{.}\) Add \(9\) to both sides:
\begin{align*} x^2-6x+9&=-2+9,\\ (x-3)^2&=7,\\ x&=3\pm\sqrt{7}. \end{align*}
The formula agrees: \(D=(-6)^2-4(1)(2)=28\) and \(x=(6\pm\sqrt{28})/2=3\pm\sqrt{7}\text{.}\) Completing the square uses the same steps that produced the formula.

Checkpoint 119.

What must be added to \(x^2-10x\) to complete the square? Use it to solve \(x^2-10x+13=0\text{.}\) Explain why you add the same number to both sides and why you need two signs.
Solution.
Half of \(-10\) is \(-5\text{,}\) whose square is \(25\text{.}\) Starting with \(x^2-10x=-13\text{,}\) add \(25\) to both sides to preserve equality. This gives \((x-5)^2=12\text{,}\) hence \(x=5\pm2\sqrt{3}\text{.}\) Both signs are needed because both \(2\sqrt{3}\) and \(-2\sqrt{3}\) square to \(12\text{.}\)
Return to Solving with the quadratic formula for practice, or to the Quadratic functions, equations, and zeros page for the lesson overview.