2A - Completing the square

2A - Completing the square

How small can a quadratic expression become? You will rewrite quadratics as a multiple of one square plus a constant, making their minimum or maximum visible without plotting lots of points.

Making a perfect square

How small can x2+6x+5x^2+6x+5 become as xx varies over all real numbers?

At x=0x=0 it is 55; at x=−3x=-3 it is −4-4; at x=−6x=-6 it is 55 again. Those values suggest a lowest point near −3-3, but checking a few values cannot prove a minimum. We need a form that tells us about every real xx.

Expand one square:

(x+3)2=x2+6x+9.(x+3)^2=x^2+6x+9.

It has the right first two terms but the constant is 44 too large. Subtracting 44 gives

x2+6x+5=(x+3)2−4.x^2+6x+5=(x+3)^2-4.

A square cannot be negative, so this expression is at least −4-4, with equality when x=−3x=-3.

Completing the square

Completing the square means rewriting a quadratic as a single squared linear expression, possibly multiplied by a constant, plus a remaining constant. The new expression must be equal to the original for every value of the variable.

The coefficient of xx in (x+p)2=x2+2px+p2(x+p)^2=x^2+2px+p^2 is twice pp. That is why we halve the middle coefficient.

Completing a monic square

For real constants b,cb,c,

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

Halve bb, square that half, then compensate for the constant introduced.

Not on the formulae sheet: learn it.

Use the identity as a reason for the steps, rather than as a long formula to substitute into mechanically.

Worked example 1: an even middle coefficient

Question. Express x2+6x+5x^2+6x+5 in completed-square form.

Plan. Use (x+3)2(x+3)^2, then correct its constant term.

x2+6x+5=(x+3)2−9+5add and subtract 32=(x+3)2−4collect the constants\begin{aligned} x^2+6x+5&=(x+3)^2-9+5 &&\text{add and subtract }3^2\\ &=(x+3)^2-4 &&\text{collect the constants} \end{aligned}

Answer. (x+3)2−4(x+3)^2-4.

Check. Expansion gives x2+6x+9−4=x2+6x+5x^2+6x+9-4=x^2+6x+5.

Change only the middle coefficient from 66 to 55. Its half is a fraction; the method is unchanged.

Worked example 2: an odd middle coefficient

Question. Express x2+5x+5x^2+5x+5 in the form (x+p)2+q(x+p)^2+q.

Plan. Halve 55 and subtract the square of that half before adding the original constant.

x2+5x+5=(x+52)2−254+5compensate for (52)2=(x+52)2−54write 5=204\begin{aligned} x^2+5x+5&=\left(x+\frac52\right)^2-\frac{25}{4}+5 &&\text{compensate for }\left(\frac52\right)^2\\ &=\left(x+\frac52\right)^2-\frac54 &&\text{write }5=\frac{20}{4} \end{aligned}

Answer. p=52p=\frac52, q=−54q=-\frac54, giving (x+52)2−54\left(x+\frac52\right)^2-\frac54.

Check. The constant after expansion is 254−54=5\frac{25}{4}-\frac54=5, and the middle term is 2×52x=5x2\times\frac52x=5x.

The square of a bracket contains a cross term.

Watch out

(x+3)2≠x2+9(x+3)^2\ne x^2+9: the expansion is x2+6x+9x^2+6x+9. Also subtract the square of the half-coefficient, not the half-coefficient itself.

Keep fractions exact in the next expression.

Other leading coefficients

A leading coefficient other than one must be taken out before you complete the square inside a bracket.

For 2x2+6x+12x^2+6x+1, first write 2(x2+3x)+12(x^2+3x)+1. The middle coefficient inside is now 33, not 66. Every constant introduced inside that bracket is multiplied by the outside 22.

For any a≠0a\ne0, the first step is

ax2+bx+c=a(x2+bax)+c.ax^2+bx+c=a\left(x^2+\frac ba x\right)+c.

You may instead take aa out of all three terms, provided you divide the constant by aa too. Leaving the constant outside often keeps the arithmetic simpler.

Worked example 3: a positive leading coefficient

Question. Express 2x2+6x+12x^2+6x+1 in the form a(x+p)2+qa(x+p)^2+q.

Plan. Factor 22 from the first two terms, complete the square inside, then multiply out the correction.

2x2+6x+1=2(x2+3x)+1factor the leading coefficient=2[(x+32)2−94]+1halve 3 inside=2(x+32)2−92+1multiply the correction by 2=2(x+32)2−72collect constants\begin{aligned} 2x^2+6x+1&=2(x^2+3x)+1 &&\text{factor the leading coefficient}\\ &=2\left[\left(x+\frac32\right)^2-\frac94\right]+1 &&\text{halve }3\text{ inside}\\ &=2\left(x+\frac32\right)^2-\frac92+1 &&\text{multiply the correction by }2\\ &=2\left(x+\frac32\right)^2-\frac72 &&\text{collect constants} \end{aligned}

Answer. 2(x+32)2−722\left(x+\frac32\right)^2-\frac72.

Check. Expansion gives 2x2+6x+92−72=2x2+6x+12x^2+6x+\frac92-\frac72=2x^2+6x+1.

Keep the middle and constant terms but change the leading coefficient from 22 to −12-\frac12. This tests both a negative outside factor and division by a fraction.

Worked example 4: a negative fractional coefficient

Question. Express −12x2+6x+1-\frac12x^2+6x+1 in completed-square form.

Plan. Take out −12-\frac12 from the first two terms, so the bracket starts with x2x^2.

−12x2+6x+1=−12(x2−12x)+1since 6÷(−12)=−12=−12[(x−6)2−36]+1complete the square inside=−12(x−6)2+18+1multiply both bracket terms=−12(x−6)2+19collect constants\begin{aligned} -\frac12x^2+6x+1&=-\frac12(x^2-12x)+1 &&\text{since }6\div\left(-\frac12\right)=-12\\ &=-\frac12\big[(x-6)^2-36\big]+1 &&\text{complete the square inside}\\ &=-\frac12(x-6)^2+18+1 &&\text{multiply both bracket terms}\\ &=-\frac12(x-6)^2+19 &&\text{collect constants} \end{aligned}

Answer. −12(x−6)2+19-\frac12(x-6)^2+19.

Check. Expanding gives −12x2+6x−18+19=−12x2+6x+1-\frac12x^2+6x-18+19=-\frac12x^2+6x+1. In particular, x=0x=0 gives 11 in both forms.

The outside factor is part of the expression, so it affects the correction as well as the square.

Watch out

2[(x+32)2−94]+12[(x+\frac32)^2-\frac94]+1 becomes 2(x+32)2−92+12(x+\frac32)^2-\frac92+1, not 2(x+32)2−94+12(x+\frac32)^2-\frac94+1. Distribute the outside coefficient to every term.

Apply that same distribution carefully with a negative fraction.

Reading the completed-square form

A completed square locates a quadratic graph's turning point because it shows where the squared quantity is zero.

In y=(x+3)2−4y=(x+3)^2-4, putting x=−3x=-3 makes the square zero and gives y=−4y=-4. Moving the same distance to either side gives the same yy: for instance, x=−2x=-2 and x=−4x=-4 both give −3-3. The graph is symmetric about x=−3x=-3.

Vertex

The vertex of a quadratic graph is its turning point: its lowest point when the leading coefficient is positive, or its highest point when that coefficient is negative. The vertical line through it is the axis of symmetry.

For y=a(x−h)2+ky=a(x-h)^2+k, where a≠0a\ne0, the square is zero at x=hx=h. The vertex is therefore (h,k)(h,k) and the symmetry axis is x=hx=h. If a>0a>0, multiplying a nonnegative square by aa keeps it nonnegative, so y≥ky\ge k. If a<0a<0, the inequality reverses and y≤ky\le k. In either case the bound is attained at the vertex.

[DIAGRAM: asset_name: One vertex with a minimum or a maximum; asset_slug: completed-square-vertices; caption: Changing the sign of the squared term changes a minimum into a maximum at the same vertex; description: Two coordinate plots with the same scales compare y equals 3 times x minus 2 squared minus 5 and y equals minus 3 times x minus 2 squared minus 5. Both have vertex 2 comma minus 5 and symmetry line x equals 2. The first opens upward and has minimum minus 5; the second opens downward and has maximum minus 5. Equal-distance points on either side of x equals 2 are shown at x equals 1 and x equals 3.]
Changing the sign of the squared term changes a minimum into a maximum at the same vertex

The completed-square form also describes graph transformations: shift the graph of y=ax2y=ax^2 horizontally by hh and vertically by kk. A negative aa reflects its opening downwards.

Worked example 5: a minimum

Question. For y=3(x−2)2−5y=3(x-2)^2-5, find the vertex, axis of symmetry and minimum value.

Plan. Make the square zero and use the fact that a positive multiple of a square is nonnegative.

(x−2)2≥0every real square is nonnegative3(x−2)2−5≥−5multiply by 3 and subtract 5x=2  ⟹  y=−5the bound is attained\begin{aligned} (x-2)^2&\ge0 &&\text{every real square is nonnegative}\\ 3(x-2)^2-5&\ge-5 &&\text{multiply by }3\text{ and subtract }5\\ x=2&\implies y=-5 &&\text{the bound is attained} \end{aligned}

Answer. Vertex (2,−5)(2,-5), axis x=2x=2, minimum value −5-5.

Check. At x=1x=1 and x=3x=3, the value is −2-2, equally above the vertex. Expanding gives 3x2−12x+73x^2-12x+7, so the leading coefficient is positive as expected.

Change only the multiplier of the square from 33 to −3-3. The location where the square is zero stays fixed, but the bound becomes a maximum.

Worked example 6: a maximum

Question. For y=−3(x−2)2−5y=-3(x-2)^2-5, find the vertex, axis of symmetry and maximum value.

Plan. Multiply the nonnegative square by the negative coefficient before interpreting the bound.

(x−2)2≥0start with the square−3(x−2)2≤0multiplication by a negative reverses the signy=−3(x−2)2−5≤−5subtract 5\begin{aligned} (x-2)^2&\ge0 &&\text{start with the square}\\ -3(x-2)^2&\le0 &&\text{multiplication by a negative reverses the sign}\\ y=-3(x-2)^2-5&\le-5 &&\text{subtract }5 \end{aligned}

Equality occurs at x=2x=2.

Answer. Vertex (2,−5)(2,-5), axis x=2x=2, maximum value −5-5.

Check. At x=1x=1 and x=3x=3, y=−8y=-8, equally below the vertex. Expansion gives −3x2+12x−17-3x^2+12x-17, with negative leading coefficient.

Read the sign inside the bracket by asking what value makes it zero.

Watch out

For y=(x+3)2−4y=(x+3)^2-4, the vertex is (−3,−4)(-3,-4), not (3,−4)(3,-4). The minimum value is the yy-coordinate −4-4; the value of xx where it occurs is −3-3.

This proves the opening expression has minimum −4-4, rather than merely suggesting it from a few plotted values.

Quick Recap

  • Halve the middle coefficient inside a monic quadratic, then compensate for its square.
  • For another leading coefficient, factor it out first and multiply the constant correction by it.
  • The form a(x−h)2+ka(x-h)^2+k has vertex (h,k)(h,k) and symmetry axis x=hx=h.
  • Positive aa gives minimum kk; negative aa gives maximum kk, for all real xx.

The opening expression is (x+3)2−4(x+3)^2-4, so its minimum is exactly −4-4 at x=−3x=-3.