back to the math tutorial index back to the math tutorial index

Computing Integrals by Completing the Square

We will review the method of completing the square in the context of evaluating integrals:

Example

Let's start by evaluating \[\int\frac{dx}{2x^2-12x+26}.\] The denominator does not factor with rational coefficients, so partial fractions is not a viable option. There is also no obvious substitution to make. Instead, we will complete the square in the denominator to get a recognizable form for the integral.

Now \begin{eqnarray*} 2x^2-12x+26&=&2[x^2-6x+13]\\ &=&2[(x^2-6x+9)+4]\\ &=&2[(x-3)^2+4]. \end{eqnarray*} Returning to the integral, \begin{eqnarray*} \int\frac{dx}{2x^2-12x+26}&=&\int\frac{dx}{2[(x-3)^2+4]}\\ &=&\frac{1}{2}\int\frac{dx}{(x-3)^2+2^2}\\ &=&\frac{1}{2}\left[\frac{1}{2}\arctan\left(\frac{x-3}{2}\right)\right]+C\\ &=&\frac{1}{4}\arctan\left(\frac{x-3}{2}\right)+C. \end{eqnarray*}

Certain other types of integrals can be evaluated by this method as well:

Example

Consider \[\int \frac{dx}{\sqrt{21-4x-x^2}}.\] Now \begin{eqnarray*} 21-4x-x^2&=&21-[x^2+4x]\\ &=&21+4-[x^2+4x+4]\\ &=&25-(x+2)^2. \end{eqnarray*} Returning to the integral, \begin{eqnarray*} \int \frac{dx}{\sqrt{21-4x-x^2}}&=&\int \frac{dx}{\sqrt{25-(x+2)^2}}\\ &=& \arcsin \left(\frac{x+2}{5}\right)+C. \end{eqnarray*}

Completing the square is a powerful method that is used to derive the quadratic formula:

We will find the roots of $ax^2+bx+c=0$: \begin{eqnarray*} ax^2+bx+c&=&0\\ x^2+\frac{b}{a}x+\frac{c}{a}&=&0\\ x^2+\frac{b}{a}x\qquad&=&-\frac{c}{a}\\ x^2+\frac{b}{a}x+\frac{b^2}{4a^2}&=&\frac{b^2}{4a^2}-\frac{c}{a}\\ \left(x+\frac{b}{2a}\right)^2&=&\frac{b^2-4ac}{4a^2}\\ x+\frac{b}{2a}&=&\pm \frac{\sqrt{b^2-4ac}}{2a}\\ x&=&\frac{-b\pm \sqrt{b^2-4ac}}{2a} \end{eqnarray*} which is the familiar quadratic formula!


Key Concept

By completing the square, we may rewrite any quadratic polynomial \[ax^2+bx+x\] in the form \[a\left[(x+k_1)^2+k_2\right]\] where $k_1$ and $k_2$ may be positive or negative. Integrals containing negative or non-integer powers of $ax^2+bx+c$ can often be computed using a trigonometric substitution or looked up in an integral table after being rewritten in this form.