8.1 Completing the Square; Maximum and Minimum Values
SL 2.6
- what a quadratic function is, and the notation \(f(x)\)
- how to write \(ax^2 + bx + c\) in completed square form \(a(x - h)^2 + k\)
- how to use this form to find the maximum or minimum value of a quadratic function, and the range of its values
- how completing the square gives the general vertex \(\left(-\dfrac{b}{2a},\, -\dfrac{b^2 - 4ac}{4a}\right)\) and the quadratic formula
A quadratic function is a function that can be written in the form
\[ y = ax^2 + bx + c, \qquad \text{where } a, b, c \text{ are constants and } a \neq 0 . \]
If \(a = 0\) there is no \(x^2\) term, and the function is linear, not quadratic.
Notation \(f(x)\)
In Unit 7 we drew straight lines \(y = mx + c\). The graph of \(y = ax^2 + bx + c\) is not straight: it is a curve.
In both cases, each input \(x\) gives exactly one output \(y\). A relationship like this is called a function.
We write \(y = f(x)\) to say that “\(y\) is a function of \(x\)”. So we can write
\[ f(x) = ax^2 + bx + c \quad\text{(quadratic)}, \qquad f(x) = mx + c \quad\text{(linear)} . \]
\(f(3)\) means “the output when the input is \(3\)”. For example, if \(f(x) = x^2 - 5x + 1\), then \(f(3) = 9 - 15 + 1 = -5\).
Completed square form
Look at \(f(x) = x^2 + 5\). Since \(x^2 \geq 0\) for every real \(x\), we have \(f(x) \geq 5\). The minimum value of \(f(x)\) is \(5\), and it happens when \(x = 0\). We can see this by inspection, without any working (Figure 1).
For a function such as \(f(x) = x^2 - 8x + 3\) this is not obvious. The idea is to rewrite it so that \(x\) appears only once, inside a square:
\[ f(x) = (x - h)^2 + k . \]
This is called completed square form (or vertex form). The method is called completing the square. Since \((x - h)^2 \geq 0\), the minimum value is \(k\), when \(x = h\): the vertex of the graph is \((h, k)\) (Figure 2).
Completing the square Not in the formula booklet
\[ x^2 + bx = \left(x + \frac{b}{2}\right)^2 - \left(\frac{b}{2}\right)^2 \]
Halve the coefficient of \(x\), square the bracket, then subtract the extra constant.
- \(b\): the coefficient of \(x\)
For example, \(\left(x + \frac{b}{2}\right)^2 = x^2 + bx + \frac{b^2}{4}\). The bracket gives an extra \(\frac{b^2}{4}\), so we take it away again.
Example 1 Express \(f(x) = x^2 - 8x + 3\) in the form \((x - h)^2 + k\), where \(h\) and \(k\) are constants. Hence find
(a) all possible real values of \(f(x)\),
(b) the minimum value of \(f(x)\),
(c) the value of \(x\) at which the minimum value occurs.
Half of \(-8\) is \(-4\):
\[ x^2 - 8x + 3 = (x - 4)^2 - 16 + 3 = (x - 4)^2 - 13 . \]
So \(h = 4\) and \(k = -13\).
(a) \((x - 4)^2 \geq 0\) for all real \(x\), so \((x - 4)^2 - 13 \geq -13\). Hence \(f(x) \geq -13\).
(b) The minimum value of \(f(x)\) is \(-13\).
(c) The minimum happens when \((x - 4)^2 = 0\), that is, when \(x = 4\).
When the coefficient of \(x^2\) is not 1, take \(a\) out as a factor of the \(x^2\) and \(x\) terms first.
Completing the square when \(a \neq 1\) Not in the formula booklet
- Factor \(a\) out of the first two terms: \(\;ax^2 + bx + c = a\left(x^2 + \dfrac{b}{a}x\right) + c\).
- Complete the square inside the bracket.
- Multiply out the outer bracket and collect the constants.
The result is \(a(x - h)^2 + k\).
- If \(a > 0\): \(f(x)\) has a minimum value \(k\), when \(x = h\).
- If \(a < 0\): \(f(x)\) has a maximum value \(k\), when \(x = h\).
- \(a\): the coefficient of \(x^2\) (\(a \neq 0\))
- \(b\): the coefficient of \(x\)
- \(c\): the constant term
- \(h\): the \(x\)-coordinate of the vertex
- \(k\): the \(y\)-coordinate of the vertex (the maximum or minimum value)
The reason: \((x - h)^2 \geq 0\). Multiplying by a positive \(a\) keeps it \(\geq 0\), so \(f(x) \geq k\). Multiplying by a negative \(a\) makes it \(\leq 0\), so \(f(x) \leq k\).
Example 2 Express each function in the form \(a(x - h)^2 + k\), where \(a\), \(h\) and \(k\) are constants. Hence find the maximum or minimum value of \(f(x)\). Justify your answers.
(a) \(f(x) = 2x^2 + 12x + 7\) \(\qquad\) (b) \(f(x) = -3x^2 + 5x + 1\)
(a)
\[ \begin{aligned} 2x^2 + 12x + 7 &= 2(x^2 + 6x) + 7 \\ &= 2\big[(x + 3)^2 - 9\big] + 7 \\ &= 2(x + 3)^2 - 18 + 7 \\ &= 2(x + 3)^2 - 11 . \end{aligned} \]
Since \((x + 3)^2 \geq 0\), we have \(2(x + 3)^2 \geq 0\), so \(f(x) \geq -11\). The minimum value is \(-11\), when \(x = -3\).
(b)
\[ \begin{aligned} -3x^2 + 5x + 1 &= -3\left(x^2 - \frac{5}{3}x\right) + 1 \\ &= -3\left[\left(x - \frac{5}{6}\right)^2 - \frac{25}{36}\right] + 1 \\ &= -3\left(x - \frac{5}{6}\right)^2 + \frac{25}{12} + 1 \\ &= -3\left(x - \frac{5}{6}\right)^2 + \frac{37}{12} . \end{aligned} \]
Since \(\left(x - \frac{5}{6}\right)^2 \geq 0\), we have \(-3\left(x - \frac{5}{6}\right)^2 \leq 0\), so \(f(x) \leq \dfrac{37}{12}\). The maximum value is \(\dfrac{37}{12}\), when \(x = \dfrac{5}{6}\).
The general case
We can complete the square for the general quadratic \(ax^2 + bx + c\). This gives two important results.
Example 3 Complete the square to write \(f(x) = ax^2 + bx + c\) in the form \(a(x - h)^2 + k\).
(a) Show that \(h = -\dfrac{b}{2a}\) and \(k = -\dfrac{b^2 - 4ac}{4a}\).
(b) Hence derive the quadratic formula for the solutions of \(f(x) = 0\).
(a)
\[ \begin{aligned} ax^2 + bx + c &= a\left(x^2 + \frac{b}{a}x\right) + c \\ &= a\left[\left(x + \frac{b}{2a}\right)^2 - \frac{b^2}{4a^2}\right] + c \\ &= a\left(x + \frac{b}{2a}\right)^2 - \frac{b^2}{4a} + \frac{4ac}{4a} \\ &= a\left(x - \left(-\frac{b}{2a}\right)\right)^2 - \frac{b^2 - 4ac}{4a} . \end{aligned} \]
So \(h = -\dfrac{b}{2a}\) and \(k = -\dfrac{b^2 - 4ac}{4a}\).
(b) Set \(f(x) = 0\):
\[ a\left(x + \frac{b}{2a}\right)^2 = \frac{b^2 - 4ac}{4a} \;\Longrightarrow\; \left(x + \frac{b}{2a}\right)^2 = \frac{b^2 - 4ac}{4a^2} . \]
Take the square root of both sides (remember \(\pm\)). Since \(\sqrt{4a^2} = 2|a|\) and we have \(\pm\) anyway,
\[ x + \frac{b}{2a} = \pm\frac{\sqrt{b^2 - 4ac}}{2a} \;\Longrightarrow\; x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} . \]
Vertex and quadratic formula Partly in the formula booklet
\[ f(x) = ax^2 + bx + c \;\Rightarrow\; \text{axis of symmetry is } x = -\frac{b}{2a} \]
In the booklet
The maximum or minimum value happens on the axis of symmetry. The value is \(\; -\dfrac{b^2 - 4ac}{4a}\).
\[ ax^2 + bx + c = 0 \;\Rightarrow\; x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}, \quad a \neq 0 \]
In the booklet
- \(a\): the coefficient of \(x^2\) (\(a \neq 0\))
- \(b\): the coefficient of \(x\)
- \(c\): the constant term
To find the maximum or minimum value, substitute \(x = -\frac{b}{2a}\) into \(f(x)\).
Graphs page: enter \(f_1(x)\), then Menu → Analyze Graph → Minimum (or Maximum). Move the cursor to the left of the turning point, click, move to the right, click. The calculator shows the coordinates of the vertex.
On Paper 1 you must complete the square by hand, as in Example 2.
Common errors
| ✗ Wrong | ✓ Right | Why |
|---|---|---|
| \(x^2 - 8x + 3 = (x - 4)^2 + 3\) | \((x - 4)^2 - 16 + 3\) | \((x - 4)^2\) makes an extra \(+16\); take it away. |
| \(2x^2 + 12x = 2(x + 3)^2 - 9\) | \(2(x + 3)^2 - 18\) | The \(-9\) is inside the bracket, so it is also multiplied by \(2\). |
| \(x^2 + 6x = (x + 6)^2 - 36\) | \((x + 3)^2 - 9\) | Use half of the coefficient of \(x\). |
| \((x + 3)^2 - 11\): minimum at \(x = 3\) | at \(x = -3\) | \((x + 3)^2 = 0\) when \(x = -3\). |
| \(-3(x - 1)^2 + 4\) has a minimum of \(4\) | a maximum of \(4\) | When \(a < 0\) the value is never more than \(k\). |
Exercises
1 Given \(f(x) = 2x^2 - 3x + 4\), find \(f(-2)\) and \(f\!\left(\dfrac{1}{2}\right)\).
\(f(-2) = 2(4) + 6 + 4 = 18\). \(\qquad f\!\left(\dfrac{1}{2}\right) = 2 \times \dfrac{1}{4} - \dfrac{3}{2} + 4 = \dfrac{1}{2} - \dfrac{3}{2} + 4 = 3\).
2 Write in the form \((x - h)^2 + k\):
(a) \(x^2 + 10x + 4\)
(b) \(x^2 - 6x + 11\)
(c) \(x^2 + 3x - 1\)
(a) \((x + 5)^2 - 25 + 4 = (x + 5)^2 - 21\).
(b) \((x - 3)^2 - 9 + 11 = (x - 3)^2 + 2\).
(c) \(\left(x + \dfrac{3}{2}\right)^2 - \dfrac{9}{4} - 1 = \left(x + \dfrac{3}{2}\right)^2 - \dfrac{13}{4}\).
3 Find the minimum value of \(f(x) = x^2 - 12x + 40\) and the value of \(x\) where it occurs. Write down all possible values of \(f(x)\).
\(f(x) = (x - 6)^2 - 36 + 40 = (x - 6)^2 + 4\).
The minimum value is \(4\), when \(x = 6\). All possible values: \(f(x) \geq 4\).
4 Write \(3x^2 - 18x + 20\) in the form \(a(x - h)^2 + k\).
\(3(x^2 - 6x) + 20 = 3\big[(x - 3)^2 - 9\big] + 20 = 3(x - 3)^2 - 27 + 20 = 3(x - 3)^2 - 7\).
5 Write \(-x^2 + 4x + 7\) in the form \(a(x - h)^2 + k\). State, with a reason, whether \(f(x) = -x^2 + 4x + 7\) has a maximum or a minimum value, and find it.
\(-(x^2 - 4x) + 7 = -\big[(x - 2)^2 - 4\big] + 7 = -(x - 2)^2 + 11\).
Since \(-(x - 2)^2 \leq 0\), \(f(x) \leq 11\). It has a maximum value of \(11\), when \(x = 2\).
6 Write \(2x^2 + 5x - 3\) in the form \(a(x - h)^2 + k\), and hence find its minimum value.
\[ 2\left(x^2 + \frac{5}{2}x\right) - 3 = 2\left[\left(x + \frac{5}{4}\right)^2 - \frac{25}{16}\right] - 3 = 2\left(x + \frac{5}{4}\right)^2 - \frac{25}{8} - 3 = 2\left(x + \frac{5}{4}\right)^2 - \frac{49}{8} . \]
The minimum value is \(-\dfrac{49}{8}\), when \(x = -\dfrac{5}{4}\).
7 Find the maximum value of \(g(x) = 5 - 4x - 2x^2\).
\(g(x) = -2(x^2 + 2x) + 5 = -2\big[(x + 1)^2 - 1\big] + 5 = -2(x + 1)^2 + 7\).
The maximum value is \(7\), when \(x = -1\).
8 Solve \(x^2 - 6x - 3 = 0\) by completing the square. Give exact answers.
\((x - 3)^2 - 9 - 3 = 0 \Rightarrow (x - 3)^2 = 12 \Rightarrow x - 3 = \pm\sqrt{12} = \pm 2\sqrt{3}\).
\(x = 3 \pm 2\sqrt{3}\).
9 Given that \(x^2 + px + 13 = (x - 3)^2 + q\) for all \(x\), find \(p\) and \(q\).
\((x - 3)^2 + q = x^2 - 6x + 9 + q\). Compare coefficients: \(p = -6\), and \(9 + q = 13\), so \(q = 4\).
10 Show that \(x^2 - 2x + 6 > 0\) for all real \(x\), and find the greatest value of \(\dfrac{10}{x^2 - 2x + 6}\).
\(x^2 - 2x + 6 = (x - 1)^2 + 5 \geq 5 > 0\) for all real \(x\).
The fraction is greatest when the denominator is smallest, that is, when it equals \(5\) (at \(x = 1\)). The greatest value is \(\dfrac{10}{5} = 2\).