# Integration by Completing the Square and Substitution

Created by Anna Szczepanek, PhD
Reviewed by Rijk de Wet
Last updated: Sep 29, 2023

Completing the square is a method related to quadratic equations that we also use to calculate integrals of rational functions by partial fractions. In this article, we'll explain how this method works.

π If you're rather interested in solving quadratic equations, visit our quadratic formula calculator or completing the square calculator.

## Integrating rational functions

Recall that a rational function in mathematics is a function consisting of a polynomial divided by another polynomial, like:

$\frac{ 3x^2 + 9x + 7 }{ 5x^2 + x + 3 }$

The polynomial in the denominator should have a degree equal to at least one, meaning $x$ or a power thereof should feature somewhere below the line.

When it comes to the integration of a rational function, the difficulty of the problem depends on the actual expression you need to integrate. In the best-case scenario, it may boil down to a simple integration of polynomials. More complex examples will however lead to partial fractions. The first thing to check, however, is whether the degree of the numerator is greater than the degree of the denominator. If so, then you should use the polynomial long division calculator to simplify the problem.

## Integrating functions using long division and completing the square

Perform the following steps to integrate a rational function in the form $L(x) / M(x)$:

1. If the degree of the numerator $L(x)$ is greater than the degree of the denominator $M(x)$, perform long division on the polynomials to obtain $W$ and $R$ such that $M(x) = L(x)W(x)+R(x)$.
2. If you end up with no remainder (i.e., $R=0$), lucky you β there's only the polynomial $W$ to be integrated. Remember that the integral of $x^n$ is $x^{n+1}/(n+1)$, and you'll be done in no time.
3. If there is a remainder, you have to rewrite the rational function $R(x)/M(x)$ as the sum of partial fractions. Visit our partial fraction decomposition calculator to learn more.
4. Once you have partial fractions, integrate them one by one. The formulas for integrating fractions of the form $1/(x+b)^m$ and $(px+q)/(x^2+bx+c)^n$ are to be found in any table of integrals.
5. Quadratic partial fractions of the form $1/(x^2+bx+c)^n$ require your special attention. We integrate them by using the completing the square method and then by substitution. We will explain this in more detail in the next section.

## What are some of the steps to integrating rational functions by completing the square?

Here we discuss how to evaluate the integral of $1/(ax^2+bx+c)^n$ using the method of completing the square and by substitution.

1. Rewrite $x^2+bx+c$ as $(x + b/2)^2 + (c - b^2/4)$, i.e., add and subtract the constant term $b^2/4$.
2. Denoting $c - b^2/4 = a$ and $x + b/2 = \sqrt{a}u$ we get $au^2+a$. Note that $\text{d}x = \sqrt{a} \text{d}u$.
3. After this $u$ substitution, we arrive at the integral of $1/(1+u^2)^n$.
4. In the particular case of $n=1$, the solution is equal to $\arctan(u)$, but for higher $n$, the formula is much more complicated and can be found in integration tables.

As you can see, getting the correct answer to this calculus question requires quite a lot of computation. But don't get discouraged β as always, practice makes perfect. Going through a few exercises will certainly help, and soon you'll be the master of integration using completing the square method!

Anna Szczepanek, PhD
Related calculators
We will solve the quadratic equation
ax2 + bx + c = 0
Enter your respective coefficients:
a
b
c
People also viewedβ¦

### Books vs e-books

Discover the ultimate paper books vs. e-books calculator. Make an informed choice with our handy tool. Find out which is best for the environment!

### Height of a cone

Quickly obtain a cone's height given its radius and slanted height with the height of a cone calculator!

### Manhattan distance

The Manhattan distance calculator is a simple calculator that determines the Manhattan distance (also known as the taxicab or city block distance) between two points in up to four-dimensional Cartesian space.

### Secretary problem (Valentine's day)

Use the dating theory calculator to enhance your chances of picking the best lifetime partner.