LocusBlog

Quadratic formula

The quadratic formula solves every equation that can be written as $ax^2 + bx + c = 0$ with $a \neq 0$:

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

$a$, $b$ and $c$ are the coefficients read off the equation after it has been rearranged so that one side is zero. OpenStax Algebra and Trigonometry states it in section 2.5 with that condition attached, and the condition is not decoration. An equation like $x^2 + 3x = 10$ has an $a$, a $b$ and something that looks like a $c$, and reading them off in that form gives the wrong answer.

Completing the square, every step

The formula is not a separate technique. It is completing the square carried out once on a general quadratic so nobody has to do it again.

Start from $ax^2 + bx + c = 0$ and divide through by $a$, which is legal because $a \neq 0$:

$$x^2 + \frac{b}{a}x + \frac{c}{a} = 0$$

Move the constant to the right:

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

Completing the square means adding whatever makes the left side a perfect square trinomial. A square $(x + k)^2$ expands to $x^2 + 2kx + k^2$, so the coefficient of $x$ is twice $k$. Here that coefficient is $b/a$, so $k = b/2a$, and the constant it needs is $k^2 = b^2/4a^2$. Add that to both sides:

$$x^2 + \frac{b}{a}x + \frac{b^2}{4a^2} = \frac{b^2}{4a^2} - \frac{c}{a}$$

The left side is now $\left(x + \frac{b}{2a}\right)^2$ by construction. Put the right side over the common denominator $4a^2$, which means multiplying $c/a$ by $4a/4a$:

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

Take the square root of both sides. This is where the $\pm$ enters, and it enters for a reason: $u^2 = k$ has two solutions whenever $k \neq 0$, since $(-u)^2 = u^2$. The denominator $\sqrt{4a^2}$ is $2|a|$, but the $\pm$ in front already covers both signs, so writing $2a$ loses nothing.

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

Subtract $b/2a$ and combine over the single denominator:

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

If completing the square is the part that feels shaky, that is the step worth practising on its own before trusting the formula that comes out of it.

What the discriminant decides

The quantity under the root, $D = b^2 - 4ac$, is the discriminant, and its sign settles the shape of the answer before any arithmetic is done.

If $D > 0$ the root is a nonzero real number, the $\pm$ produces two different values, and the parabola crosses the $x$-axis twice. If $D = 0$ the root term vanishes and both branches collapse to the single value $x = -b/2a$, the vertex sitting exactly on the axis. If $D < 0$ there is no real square root, the two solutions are complex conjugates $\frac{-b}{2a} \pm \frac{\sqrt{|D|}}{2a}i$, and the parabola misses the axis entirely.

There is a fourth case worth noticing. When $D$ is a perfect square the two roots are rational, which means the quadratic factors over the integers and you did not need the formula. A quick discriminant check tells you which method is cheaper.

A worked example, checked twice

Solve $3x^2 + 5x - 7 = 0$. Here $a = 3$, $b = 5$, $c = -7$.

$$D = 5^2 - 4(3)(-7) = 25 + 84 = 109$$

The two minus signs in $-4ac$ multiply to a plus, which is why $D$ grows rather than shrinks. 109 is positive and not a perfect square, so expect two irrational roots.

$$x = \frac{-5 \pm \sqrt{109}}{6}$$

With $\sqrt{109} = 10.440307$:

$$x_1 = \frac{-5 + 10.440307}{6} = \frac{5.440307}{6} = 0.906718$$

$$x_2 = \frac{-5 - 10.440307}{6} = \frac{-15.440307}{6} = -2.573384$$

Substitute $x_1$ back into the original equation. $0.906718^2 = 0.822138$, so $3 \times 0.822138 = 2.466414$, and $5 \times 0.906718 = 4.533590$. Then $2.466414 + 4.533590 - 7 = 0.000004$, which is zero to the six figures being carried.

Now check both roots at once, without substituting anything. Add the two branches of the formula and the square roots cancel:

$$x_1 + x_2 = \frac{-b + \sqrt{D}}{2a} + \frac{-b - \sqrt{D}}{2a} = \frac{-2b}{2a} = -\frac{b}{a}$$

Multiply them and the difference of squares does the same job:

$$x_1 x_2 = \frac{(-b)^2 - D}{4a^2} = \frac{b^2 - b^2 + 4ac}{4a^2} = \frac{c}{a}$$

These are Vieta’s relations. For this equation the sum should be $-5/3 = -1.666667$ and the product should be $-7/3 = -2.333333$. The computed roots give $0.906718 - 2.573384 = -1.666666$ and $0.906718 \times (-2.573384) = -2.333334$, each within one unit of the last place carried. Both land, so both roots are right, and the check took two operations instead of two substitutions.

The three ways it goes wrong

Dropping the $\pm$. Report only $x_1 = 0.906718$ and you have half an answer. Vieta catches it instantly: a single root of $3x^2 + 5x - 7$ cannot sum to $-5/3$ by itself.

Sign errors on $b$ when $b$ is already negative. Solve $x^2 - 6x + 5 = 0$. Here $b = -6$, so $-b = +6$ and $D = 36 - 20 = 16$, giving $x = (6 \pm 4)/2$, that is $5$ and $1$. Write $-b$ as $-6$ instead, because the equation has a minus sign in it, and you get $(-6 \pm 4)/2$, that is $-1$ and $-5$. Those are real numbers and they look plausible. They are the roots of $x^2 + 6x + 5$, a different equation. Vieta again: the sum has to be $-b/a = 6$, and $-1 + (-5) = -6$.

Forgetting to set the equation to zero. Take $x^2 + 3x = 10$ and read off $a = 1$, $b = 3$, $c = 10$. Then $D = 9 - 40 = -31$ and the answer comes out complex. It is not. Subtract 10 first: $x^2 + 3x - 10 = 0$, so $c = -10$ and $D = 9 + 40 = 49$, a perfect square, and $x = (-3 \pm 7)/2$ gives $2$ and $-5$. Substituting $x = 2$ into the original: $4 + 6 = 10$. This failure mode is the nastiest of the three because the wrong answer is not a wrong number, it is a wrong category, and nothing about “no real solutions” invites a second look.

The derivation above is worth reproducing from scratch once. After that, what keeps answers correct is the discriminant read before the arithmetic and Vieta’s pair read after it. Both are cheap. Timed practice on the formula generates coefficients that are negative often enough to make the $b$ trap show up.

References