# Quadratic Functions and the Completing the Square Technique

You may want to review:

Let $\,a\,,$ $\,b\,$ and $\,c\,$ be real numbers, with $\,a \ne 0\,.$

*quadratic function*is a function that can be written in the form: $$y = ax^2 + bx + c$$

*standard form*of the quadratic function.

*vertex form*of the quadratic function.

## Comments on the Definition

### What type of term must a quadratic function have?

If $\,a = 0\,$ in the expression
$\,ax^2 + bx + c\,,$ then the $\,x^2\,$ term disappears.
Thus, the requirement that $\,a\ne 0\,$ says that
a quadratic function *must* have an $\,x^2\,$ term.

### What other types of terms is a quadratic function allowed to have?

There are no restrictions placed on $\,b\,$ or $\,c\,$ in the definition of quadratic function; they can be any real number.

In particular, $\,b\,$ is allowed to equal zero, which causes the $\,x\,$ term to disappear. Thus, a quadratic function may or may not have an $\,x\,$ term.

Similarly, $\,c\,$ is allowed to equal zero, which causes the constant term to disappear. Thus, a quadratic function may or may not have a constant term.

### Summary of Terms Types in a Quadratic Function

A quadratic function *must have*
an $\,x^2\,$ term;
it is allowed to have an $\,x\,$ term;
it is allowed to have a constant term.
It may not have any other types of terms.

### Quadratic Functions Go By Different Names

Like all expressions, $\,ax^2 + bx + c\,$ has lots of different names. Standard form and vertex form are just two names that are popular (since they're quite useful).

Different names are good for different purposes, so you should be able to switch from one to the other.

Going from vertex form, $\,a(x-h)^2 + k\,,$ to standard form is easy—just multiply out. Going from standard form, $\,ax^2 + bx + c\,,$ to vertex form is harder, and requires a technique that is explored in this section—the ‘completing the square technique’.

### Why is the name ‘vertex form’ appropriate?

As derived in
Equations of Simple Parabolas,
equations of the form $\ y = a{(x-h)}^2 + k\ $ graph as parabolas,
where $\,(h,k)\,$ is the vertex of the parabola.
Hence, the name *vertex form* is appropriate,
since it's easy to read the coordinates of the vertex from vertex form.

### What does the graph of a quadratic function look like?

Every quadratic function graphs as a parabola with directrix parallel to the $x$-axis.

If $\,a \gt 0\,$ then the parabola is concave up (holds water).

If $\,a \lt 0\,$ then the parabola is concave down (sheds water).

Before discussing the technique of completing the square, a preliminary definition is needed:

*perfect square trinomial*is a trinomial that can be written in the form $\,(x+k)^2\,.$

All of the following are perfect square trinomials:

$$ \begin{gather} \cssId{s47}{x^2 + 2x + 1 = {(x+1)}^2}\cr\cr \cssId{s48}{x^2 - 6x + 9 = {(x-3)}^2}\cr\cr \cssId{s49}{x^2 + \frac{4}{5}x + \frac{4}{25} = {\bigl(x + \frac{2}{5}\bigr)}^2} \end{gather} $$shows that there is a very simple relationship between the coefficient of the $\,x\,$ term ($\,2k\,$) and the constant term ($\,k^2\,$) in a perfect square trinomial: take the coefficient of the $\,x\,$ term, divide it by $\,2\,,$ and then square the result, to obtain the constant term!

In other words, how can you get from $\,2k\,$ to $\,k^2\,$? Divide by two, and then square: $$ \cssId{s58}{2k} \ \ \cssId{s59}{\overset{\text{divide by } 2}{\rightarrow}} \ \ \cssId{s60}{k} \ \ \cssId{s61}{\overset{\text{square}}{\rightarrow}} \ \ \cssId{s62}{k^2} $$ This is the key observation in the following technique:

The process of finding the correct
number to add to an expression of the form $\ x^2+bx\ $
to form a perfect square trinomial
is called *completing the square*.

The correct number to add is: $$\cssId{s69}{ {\left(\frac{b}{2}\right)}^2}$$

That is, take the coefficient of the $\,x\,$ term, divide it by $\,2\,,$ and then square the result.

Then:

$$ \begin{align} &\cssId{s72}{\overset{\text{start with this }}{\overbrace{x^2 + bx}}} \cssId{s73}{+ \overset{\text{and add this number}}{\overbrace{ {\left(\frac{b}{2}\right)}^2}}}\cr\cr &\qquad\qquad \cssId{s74}{= \overset{\text{to get a perfect square}}{\overbrace{ {\left(x + \frac{b}{2}\right)}^2}}} \end{align} $$## Example (Completing the Square)

Question: What number must be added to $\ x^2 - 3x\ $ to form a perfect square trinomial? Then, what perfect square trinomial results?

Solution: The $\,x\,$ term is $\,-3x\,.$ The coefficient of the $\,x\,$ term is $\,-3\,.$ Take this number, divide it by $\,2\,,$ and then square it. Thus, the number to add is $\ {(\frac{-3}{2})}^2\,.$

The perfect square trinomial that results is: $$\cssId{s86}{x^2 - 3x + \bigl(\color{red}{\frac{-3}{2}}\bigr)^2 = {\bigl(x\color{blue}{-\frac{3}{2}}\bigr)}^2}$$

Notice that the number *inside* the parentheses
gets plopped down next to $\,x\,$ in the resulting
perfect square:

### Read-Through, Part 2

## Caution! Completing the Square Changes the Expression!

Be careful—when you add
$\,{(\frac{b}{2})}^2\,$ to complete the square,
*you are changing the expression that you started with*!

In other words, the expression you started with (which wasn't a perfect square) and the expression you end up with (which is a perfect square) are different.

Sometimes you just want to rename
an expression in a form that *involves*
a perfect square;
you don't want to change the
original expression.
In this situation,
when you add $\,{(\frac{b}{2})}^2\,,$
you also have to subtract it at the same time.
This is illustrated in the next example.

## Example (Renaming as an Expression Involving a Perfect Square Trinomial)

Question: Rename $\ x^2+6x\ $ as an expression involving a perfect square trinomial.

Solution: Note that $\,(\frac{6}{2})^2 = 3^2 = 9\,.$

$x^2+6x\,$ | starting expression |

$\ \ =x^2+6x+9-9$ | add zero in an appropriate form |

$\ \ =(x^2+6x+9)-9$ | regroup |

$\ \ =(x+3)^2-9$ | rename the perfect square |

The technique of completing the square only works when the coefficient of the $\,x^2\,$ term is $\,1\,.$ Any other coefficient must be factored out before completing the square, as shown next.

## Going From Standard Form to Vertex Form

In what follows, the completing the square technique is applied to the standard form, $\,ax^2+bx+c\,,$ to change it to vertex form, $\,a{(x-h)}^2+k\,$:

$ax^2+bx+c\,$ (original expression) |

$\quad = (ax^2+bx)+c$ (group first two terms) |

$\quad =a(x^2+\frac{b}{a}x)+c$ (factor $\,a\ne 0\,$ out of the first two terms) |

$
\quad =a\color{red}{\bigl(}x^2+\frac{b}{a}x
\color{blue}{+(\frac{b}{2a})^2 -
(\frac{b}{2a})^2} \color{red}{\bigr)}+c
$
(add zero in an appropriate form inside the parentheses; note that $ \frac{b}{a}\div 2 =\frac{b}{a}\cdot \frac{1}{2} =\frac{b}{2a} $) |

$
\quad =a\left(x^2+\frac{b}{a}x+{(\frac{b}{2a})}^2 \right)
- a{(\frac{b}{2a})}^2 + c
$
(distributive law) |

$\quad =a{(x+\frac{b}{2a})}^2 + \text{stuff}$ (rename as a perfect square) |

Notice that the $x$-value of the vertex is $\,-\frac{b}{2a}\,.$ This is worth recording and memorizing.

Don't bother memorizing the yucky formula for the $\,y$-value of the vertex. Once you have the $x$-value, it's easy to compute the corresponding $y$-value.

Let $\,a\ne 0\,.$

The vertex of the parabola $\ y=ax^2+bx+c\ $ has $x$-value equal to $\displaystyle\,-\frac{b}{2a}\,.$

In this context, the expression
$\,-\frac{b}{2a}\,$ is often called *the vertex formula*.

To conclude, we look at two different methods for going from standard form to vertex form:

## Example (Going from Standard Form to Vertex Form)

Second Solution: Use the vertex formula to find the $x$-value of the vertex:

$$\cssId{sb66}{-\frac{b}{2a} = -\frac{3}{2(5)} = -\frac{3}{10}}$$Substitute the values of $\,a\,,$ $\,h\,$ and $\,k\,$ into $\ y = a(x-h)^2 + k\,.$

With $\,h = -\frac{3}{10}\,,$ $\,k = -\frac{29}{20}\,,$ and $\,a = 5\,,$ vertex form is:

Finally, you could zip up to WolframAlpha and type in:

vertex of y = 5x^2 + 3x - 1

Using the coordinates of the vertex, it's then easy to write the vertex form yourself!