Sub topic 14
From Completing the Square to the Quadratic Formula
Prerequisites and the goal
Assume you can expand binomials, solve linear equations, work with fractions and square roots, and complete the square. This chapter derives one formula that solves every quadratic equation
\[ ax^2+bx+c=0,\qquad a\ne0. \]
The formula is
\[ x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}. \]
The symbol \(\pm\) means that both the plus and minus cases must be calculated.
Deriving the formula
Start with the general quadratic equation:
\[ ax^2+bx+c=0. \]
First divide every term by \(a\):
\[ x^2+\frac ba x+\frac ca=0. \]
Move the constant term to the other side:
\[ x^2+\frac ba x=-\frac ca. \]
The coefficient of \(x\) is \(b/a\). To complete the square, add the square of half that coefficient:
\[ \left(\frac{1}{2}\cdot\frac ba\right)^2 = \left(\frac{b}{2a}\right)^2 = \frac{b^2}{4a^2}. \]
Add this expression to both sides:
\[ x^2+\frac ba x+\frac{b^2}{4a^2} = \frac{b^2}{4a^2}-\frac ca. \]
The left side is a perfect square:
\[ \left(x+\frac{b}{2a}\right)^2. \]
Rewrite the right side with the common denominator \(4a^2\):
\[ \frac{b^2}{4a^2}-\frac ca = \frac{b^2-4ac}{4a^2}. \]
Therefore,
\[ \left(x+\frac{b}{2a}\right)^2 = \frac{b^2-4ac}{4a^2}. \]
Take the square root of both sides:
\[ x+\frac{b}{2a} = \pm\frac{\sqrt{b^2-4ac}}{2a}. \]
Finally, subtract \(b/(2a)\):
\[ x = -\frac{b}{2a} \pm\frac{\sqrt{b^2-4ac}}{2a} = \frac{-b\pm\sqrt{b^2-4ac}}{2a}. \]
The expression \(b^2-4ac\) is called the discriminant. It determines the number and type of real solutions.
| Discriminant | Real solutions | Meaning |
|---|---|---|
| \(b^2-4ac>0\) | Two | Two different real roots |
| \(b^2-4ac=0\) | One | One repeated real root |
| \(b^2-4ac<0\) | None | No real roots |
Using the formula
For \(2x^2+3x-2=0\), identify
\[ a=2,\qquad b=3,\qquad c=-2. \]
The discriminant is
\[ 3^2-4(2)(-2)=25. \]
Thus,
\[ x=\frac{-3\pm\sqrt{25}}{4} =\frac{-3\pm5}{4}. \]
The two solutions are
\[ x=\frac{2}{4}=\frac12 \quad\text{and}\quad x=\frac{-8}{4}=-2. \]
import math
def quadratic_roots(a, b, c):
if a == 0:
raise ValueError("a must not be zero")
discriminant = b * b - 4 * a * c
if discriminant < 0:
return ()
root = math.sqrt(discriminant)
values = {(-b + root) / (2 * a), (-b - root) / (2 * a)}
return tuple(sorted(values))
print(quadratic_roots(2, 3, -2)) # (-2.0, 0.5)Choosing and checking
Factoring can be faster when the factors are easy to recognize. Completing the square explains the structure of the formula and works even when factoring is difficult. After solving, substitute each value into the original equation. This catches sign errors and incorrect denominators.
Exercise
Derive the quadratic formula from \(3x^2-6x+1=0\) by identifying \(a\), \(b\), and \(c\), then use the formula to find both roots.
Show answer
\(a=3\), \(b=-6\), and \(c=1\). The discriminant is \(24\), so \(x=(6\pm\sqrt{24})/6=1\pm\sqrt{6}/3\).