MathsAlgebra

Completing the Square
calculator.

Completing the square rewrites a quadratic so its vertex and roots can be read off.

How it's worked out

The aim is to turn ax2+bx+cax^2 + bx + c into a(x−h)2+ka(x - h)^2 + k. OpenStax calls this the vertex form, because (h,k)(h, k) is the turning point of the parabola.

  • If a is not 1, take it out of the x terms and leave c outside the bracket.
  • Halve the x number inside the bracket, then square it.
  • Add that square and take it away inside the bracket, which changes nothing.
  • Write the first three terms as a perfect square.
  • Bring the leftover out, multiplying it by a, and combine it with c.

The result gives a formula for each part. Here h is the x of the vertex and also the axis of symmetry, a vertical line that splits the parabola in half. The value k is the y of the vertex.

h\displaystyle h=−b2a\displaystyle {}= -\frac{b}{2a}
k\displaystyle k=c−b24a\displaystyle {}= c - \frac{b^2}{4a}

Setting y to 0 now takes a single square root, and that is the same route the book uses to solve an equation by this method. The sign under the root decides the kind of root.

x\displaystyle x=h±−ka\displaystyle {}= h \pm \sqrt{-\frac{k}{a}}

Worked examples

Jo works through an odd middle number

Jo has x2+3x+1x^2 + 3x + 1. Half of 3 is 32\frac{3}{2}, and its square is 94\frac{9}{4}. Taking that from 1 leaves −54-\frac{5}{4}.

y\displaystyle y=(x+32)2−54\displaystyle {}= (x + \frac{3}{2})^2 - \frac{5}{4}

The vertex is at (−1.5, −1.25) as decimals. Setting y to 0 gives x=−3±52x = \frac{-3 \pm \sqrt{5}}{2}, or about −2.618034 and −0.381966. Keeping fractions until the last line is what makes this one come out clean.

Open this example in the tool

Ravi handles a leading number of 2

For 2x2+8x+62x^2 + 8x + 6, Ravi takes 2 out of the x terms and gets 2(x2+4x)+62(x^2 + 4x) + 6. Half of 4 is 2, and its square is 4.

That 4 sits inside a bracket with 2 in front, so it comes out as 8. This step is easy to miss. Then 6−86 - 8 gives −2, and the answer is y=2(x+2)2−2y = 2(x + 2)^2 - 2, with roots x=−3 or x=−1x = -3\text{ or }x = -1.

Open this example in the tool

Kim finds the top of a thrown ball

A ball thrown from a 40 foot building at 80 feet per second has a height of −16t2+80t+40-16t^2 + 80t + 40 feet after t seconds. Kim wants the top of the path, so she needs the vertex.

The vertex is at 2.5 seconds and 140 feet. Since a is negative, the parabola opens downward and that point is the highest, which matches the book's answer. Only the later root makes sense here, as time starts at 0.

Open this example in the tool

Reading your result

The sign of a tells you the direction. When a is above 0 the parabola opens upward and k is the smallest value of y. When a is below 0 it opens downward and k is the largest. A bigger a in size makes a narrower curve.

k and a together predict the roots. Opposite signs mean two real roots, since the curve crosses the axis. A k of 0 means one repeated root. Matching signs mean complex roots, as in y=(x+1)2+4y = (x + 1)^2 + 4, whose roots are x=−1±2ix = -1 \pm 2i. This is the same split the discriminant gives.

Exact forms need whole-number coefficients. Any decimal among a, b or c switches the answer to decimals, shown to the places you pick. To check a result, multiply the bracket out and compare with what you started from, as the last step of the working does.

Vertex forms of some common quadratics
Standard formVertex formRoots
x² − 2x − 3(x−1)2−4(x - 1)^2 - 4x=−1 or x=3x = -1\text{ or }x = 3
x² + 4x + 7(x+2)2+3(x + 2)^2 + 3x=−2±3ix = -2 \pm \sqrt{3}i
x² − 5x + 6(x−52)2−14(x - \frac{5}{2})^2 - \frac{1}{4}x=2 or x=3x = 2\text{ or }x = 3
2x² − 12x + 102(x−3)2−82(x - 3)^2 - 8x=1 or x=5x = 1\text{ or }x = 5
−x² + 6x − 5−(x−3)2+4-(x - 3)^2 + 4x=1 or x=5x = 1\text{ or }x = 5
4x² + 4x − 34(x+12)2−44(x + \frac{1}{2})^2 - 4x=−32 or x=12x = -\frac{3}{2}\text{ or }x = \frac{1}{2}

Common mistakes

  • Reading h with the wrong sign. The form has a minus built in, so y=(x+3)2−4y = (x + 3)^2 - 4 has h = −3, not 3. The vertex sits where the bracket equals 0.
  • Forgetting a when the square leaves the bracket. In Ravi's example, 4 comes out as 8. Bringing out 4 gives the wrong k.
  • Adding the square without taking it away. On an expression you must do both, or you change its value. On an equation you may add it to both sides instead, which is how the book writes it.
  • Halving b when a is not 1. The number to halve is the x number inside the bracket, which is b over a.

Questions people ask

Take that number out of the x terms first, then work inside the bracket. On an equation you can also divide every term by it, as the OpenStax text does. Both routes give the same vertex, such as (−2, −2) for 2x squared plus 8x plus 6.

Sources