Unit 2, lesson 15

Completing the Square

How to rewrite a quadratic as a constant multiple of a square plus a constant without changing its value, and how that form shows the smallest or largest value at a glance.

  • Theory part 29
  • Practice part 30
  • Radicals and Quadratics

What is the smallest value of x2+6x+2x^2 + 6x + 2? Trying numbers gets close, but it never proves anything. Rewrite the same expression as (x+3)2−7(x + 3)^2 - 7 and the answer is in plain sight, because a square is never negative. Completing the square is that rewriting, and calculus uses it to find extreme values, to sketch graphs and to bring integrals into a standard form.

Key terms

Square term

Definition A square term is an expression of the form (x+p)2(x + p)^2 with pp a real constant. For every real xx,

(x+p)2=x2+2px+p2.(x + p)^2 = x^2 + 2px + p^2.

A quadratic x2+bx+cx^2 + bx + c is a perfect square exactly when c=(b2)2c = \left(\frac{b}{2}\right)^2, and then it equals (x+b2)2\left(x + \frac{b}{2}\right)^2.

In plain words In a perfect square the coefficient of xx is twice pp, and the constant is pp squared. So half the middle coefficient, squared, is the constant you need.

Example For (x+3)2(x + 3)^2 the expansion is x2+6x+9x^2 + 6x + 9. Half of 66 is 33, and 32=93^2 = 9, which matches the constant.

Completing the square

Definition For every real xx and every real constant bb,

x2+bx=(x+b2)2−(b2)2.x^2 + bx = \left(x + \frac{b}{2}\right)^2 - \left(\frac{b}{2}\right)^2.

Completing the square means using this identity to rewrite a quadratic expression as a square term, or a constant multiple of one, plus a constant.

In plain words The part x2+bxx^2 + bx is a square that is missing its last piece. Add the missing piece inside the square and take the same amount away outside.

Example With b=6b = 6, half of 66 is 33 and 32=93^2 = 9.

x2+6x+2=(x+3)2−9+2=(x+3)2−7.\begin{aligned} x^2 + 6x + 2 &= (x + 3)^2 - 9 + 2 \\[0.4em] &= (x + 3)^2 - 7. \end{aligned}

At x=1x = 1 both sides equal 99, which is a good quick check.

Constant adjustment

Definition Adding a number kk and subtracting the same kk changes no value, since E=E+k−kE = E + k - k for every expression EE. In completing the square the adjustment is k=(b2)2k = \left(\frac{b}{2}\right)^2. It is added to build the perfect square and subtracted at once to keep the expression equal to what it was.

In plain words Every number you add to make the square has to be paid back right away. Keep both in view so each line is visibly equal to the one before.

Example For x2−10x+4x^2 - 10x + 4, half of −10-10 is −5-5 and (−5)2=25(-5)^2 = 25.

x2−10x+4=(x2−10x+25)−25+4=(x−5)2−21.\begin{aligned} &x^2 - 10x + 4 \\[0.4em] &\quad = \left(x^2 - 10x + 25\right) - 25 + 4 \\[0.4em] &\quad = (x - 5)^2 - 21. \end{aligned}

Notice that p=−5p = -5 here, so the square is (x−5)2(x - 5)^2 with a minus sign inside.

Leading coefficient

Definition The leading coefficient of ax2+bx+cax^2 + bx + c is aa, assumed nonzero. To complete the square, factor aa out of the two terms that contain xx,

ax2+bx+c=a(x2+bax)+c,ax^2 + bx + c = a\left(x^2 + \frac{b}{a}x\right) + c,

and then complete the square inside the parentheses. Anything added inside the parentheses is multiplied by aa, so the outside compensation must be aa times the inside adjustment.

In plain words Pull the leading number out first. Then remember that whatever you add inside the bracket actually counts aa times.

Example Rewrite 2x2+12x+52x^2 + 12x + 5. Factor 22 from the xx terms and add 99 inside, which really adds 2⋅9=182 \cdot 9 = 18, so subtract 1818 outside.

2x2+12x+5=2(x2+6x+9)−18+5=2(x+3)2−13.\begin{aligned} &2x^2 + 12x + 5 \\[0.4em] &\quad = 2\left(x^2 + 6x + 9\right) - 18 + 5 \\[0.4em] &\quad = 2(x + 3)^2 - 13. \end{aligned}

Subtracting only 99 outside is the classic slip and gives the wrong constant −4-4.

Equivalent form

Definition Completing the square turns ax2+bx+cax^2 + bx + c with a≠0a \ne 0 into the vertex form

ax2+bx+c=a(x−h)2+k,h=−b2a,k=c−b24a.\begin{gathered} ax^2 + bx + c = a(x - h)^2 + k, \\[0.4em] h = -\frac{b}{2a}, \quad k = c - \frac{b^2}{4a}. \end{gathered}

This is an identity, true for every real xx, so the two forms are equivalent everywhere. The graph of y=ax2+bx+cy = ax^2 + bx + c is a parabola with vertex (h,k)(h, k).

In plain words Nothing about the function changes. You only write it in a shape that shows where the parabola turns.

Example From before, 2x2+12x+5=2(x+3)2−132x^2 + 12x + 5 = 2(x + 3)^2 - 13, so h=−3h = -3 and k=−13k = -13. The formulas agree, since −124=−3-\frac{12}{4} = -3 and 5−1448=−135 - \frac{144}{8} = -13. At x=1x = 1 the original gives 2+12+5=192 + 12 + 5 = 19 and the new form gives 2⋅16−13=192 \cdot 16 - 13 = 19.

Minimum value

Definition For every real xx we have (x−h)2≥0(x - h)^2 \ge 0, with equality only at x=hx = h. If a>0a > 0, then a(x−h)2≥0a(x - h)^2 \ge 0 as well, so

a(x−h)2+k≥kfor every real x,\begin{gathered} a(x - h)^2 + k \ge k \\[0.4em] \text{for every real } x, \end{gathered}

with equality exactly at x=hx = h. The minimum value of the quadratic is kk, attained only at x=hx = h, and there is no maximum. If a<0a < 0 the inequality reverses, kk is the maximum value, and there is no minimum.

In plain words A square is smallest when it is zero. When aa is positive, the whole expression is smallest exactly where the square vanishes.

Example Since 2(x+3)2−13≥−132(x + 3)^2 - 13 \ge -13 with equality only at x=−3x = -3, the minimum value of 2x2+12x+52x^2 + 12x + 5 is −13-13, at x=−3x = -3. For a negative leading coefficient, −x2+4x+1=−(x−2)2+5-x^2 + 4x + 1 = -(x - 2)^2 + 5, so that quadratic has maximum value 55 at x=2x = 2.

Check yourself

  1. Complete the square in x2−8x+3x^2 - 8x + 3 and find its minimum value.
Show the answer

Half of −8-8 is −4-4 and (−4)2=16(-4)^2 = 16, so

x2−8x+3=(x−4)2−16+3=(x−4)2−13.\begin{aligned} x^2 - 8x + 3 &= (x - 4)^2 - 16 + 3 \\[0.4em] &= (x - 4)^2 - 13. \end{aligned}

The minimum value is −13-13, at x=4x = 4.

  1. Complete the square in 3x2−12x+73x^2 - 12x + 7 and find its minimum value.
Show the answer

Factor 33 from the xx terms. Adding 44 inside the parentheses adds 1212 in total, so subtract 1212 outside.

3x2−12x+7=3(x2−4x+4)−12+7=3(x−2)2−5.\begin{aligned} &3x^2 - 12x + 7 \\[0.4em] &\quad = 3\left(x^2 - 4x + 4\right) - 12 + 7 \\[0.4em] &\quad = 3(x - 2)^2 - 5. \end{aligned}

Because 3>03 > 0, the minimum value is −5-5, at x=2x = 2.

  1. A student writes 2x2+8x+1=2(x+2)2−4+12x^2 + 8x + 1 = 2(x + 2)^2 - 4 + 1. Find the mistake and correct it.
Show the answer

The 44 added inside the parentheses is multiplied by 22, so 88 must be subtracted, not 44. The correct form is

2x2+8x+1=2(x+2)2−8+1=2(x+2)2−7.\begin{aligned} 2x^2 + 8x + 1 &= 2(x + 2)^2 - 8 + 1 \\[0.4em] &= 2(x + 2)^2 - 7. \end{aligned}

At x=0x = 0 the original gives 11, and 2⋅4−7=12 \cdot 4 - 7 = 1 confirms it.

How this lesson connects