Skip to main content

Section A.2 Completing the Square

Let \(a\neq 0\text{.}\) Any quadratic polynomial \(ax^2+bx+c\) can be rewritten in the form
\begin{equation*} ax^2+bx+c = a(x-h)^2 + k. \end{equation*}
This rewriting is called completing the square.
Expanding the right side gives
\begin{equation*} a(x-h)^2 + k = a(x^2-2hx+h^2)+k = ax^2-2ahx+(ah^2+k). \end{equation*}
The coefficient of \(x^2\) is already \(a\text{,}\) which we can read off directly from \(ax^2+bx+c\text{.}\) So we only need to match the coefficients of \(x\) and the constant term:
\begin{equation*} -2ah=b, \qquad ah^2+k=c. \end{equation*}
Solving for \(h\) and \(k\text{,}\) we obtain
\begin{equation*} h = -\frac{b}{2a}, \qquad k = c-\frac{b^2}{4a}. \end{equation*}
So
\begin{equation*} ax^2+bx+c = a\left(x+\frac{b}{2a}\right)^2 + c - \frac{b^2}{4a}. \end{equation*}
The point \((h,k)\) is the extremum (vertex) of the quadratic: it is a minimum if \(a \gt 0\) and a maximum if \(a \lt 0\text{.}\)

Example A.3.

Rewrite \(q(x)=3x^2-12x+7\) in the form \(a(x-h)^2+k\text{.}\) Find \(a\text{,}\) \(h\text{,}\) and \(k\) in two different ways.
Method 1 (comparing coefficients). Suppose
\begin{equation*} 3x^2-12x+7 = 3(x-h)^2+k = 3x^2-6hx+(3h^2+k). \end{equation*}
Comparing coefficients gives \(-6h=-12\text{,}\) so \(h=2\text{.}\) Then \(3h^2+k=7\) becomes \(3(2)^2+k=7\text{,}\) hence \(k=-5\text{.}\) Therefore
\begin{equation*} 3x^2-12x+7 = 3(x-2)^2-5. \end{equation*}
Method 2 (differentiation). The point \((h,k)\) is the extremum of \(q(x)\text{.}\) Differentiate:
\begin{equation*} q'(x)=6x-12. \end{equation*}
Solve \(q'(x)=0\text{:}\) we get \(x=2\text{,}\) so \(h=2\text{.}\) Then
\begin{equation*} k=q(2)=3(2)^2-12(2)+7=-5. \end{equation*}
The leading coefficient is \(a=3\text{,}\) so again
\begin{equation*} q(x)=3(x-2)^2-5. \end{equation*}
Since \(a=3 \gt 0\text{,}\) this extremum is a minimum.
Geometrically, completing the square identifies the vertex of the parabola \(y=ax^2+bx+c\text{.}\) In the form \(y=a(x-h)^2+k\text{,}\) the vertex is exactly \((h,k)\text{.}\)
Upward-opening parabola y equals 3x squared minus 12x plus 7 on coordinate axes, with the vertex (minimum) at (2, -5) marked by a red dot.
Figure A.4.