# Integration of Rational Functions

A rational function is of the form \(\frac{f(x)}{g(x)}\), where both \(f\) and \(g\) are polynomials.

We will first present the partial fraction approach, which can be used for all rational functions, though it could be a slow and painful process. After that, we will see the \(u\)-substitution approach, in which making the right observation makes the solution easier.

## Partial Fraction Approach

This approach assumes that you are able to factorize the denominator into linear and quadratic terms with real coefficients. Hence, it will not work for cases where the factorization isn't easily known. Refer to Partial Fractions if you are unfamiliar with this process.

We first perform partial fractions on \( \frac{f(x) } { g(x) } \) to convert it into the remainder polynomial and linear and quadratic denominators. We have

\[ \frac{f(x) } { g(x) } = r(x) + \sum \left( \frac{k_i}{ ( x - a_i ) ^ { n_i} } \right) + \sum \left( \frac{l_j x + m_j } { \big( (x-b_j)^2 + c_j ^ 2 \big) ^ {n_j} } \right). \]

**Type 1:** the remainder polynomial \( r(x) \)

- Since this is a polynomial, we know how to integrate it.

**Type 2a:** \( \frac{1}{ x -a } \), linear term to first power

- We know from derivatives of logarithmic functions that \(\frac{d}{dx} \ln |x - a| = \frac{1}{ x - a }\). We have \( \int \frac{1}{ x-a } \, dx = \ln |x-a| + C \).

**Type 2b:** \( \frac{1}{ (x-a) ^ n } \), linear term to \( n \geq 2 \) power

- We have \( \int \frac{1}{ (x-a) ^ n } \, dx = \int ( x-a)^{-n} \, dx = \frac{ 1 }{ -n + 1 } \times \frac{1}{ (x-a)^{n-1} } + C \).

**Type 3a:** \( \frac{1}{ (x-b)^2 + c^2 } \), quadratic term to first power

- We can evaluate this using trigonometric \(u\)-substitution. We substitute \(u = \arctan \frac{ x-b} { c}\). We get \( \int \frac{1}{ ( x-b) ^2 + c^2 } \, dx = \frac{1}{c} \arctan \frac{ x-b} { c} + C \).

**Type 3b:** \( \frac{2x-2b}{ (x-b)^2 + c^2 } \), linear over quadratic term to first power

- We have \( \int \frac{2x-2b} { (x-b) ^2 + c^2 } \, dx = \ln \big|( x-b)^2 + c^2 \big| + C \). This result can be proved using \(u\)-substitution (see below).

**Type 3c:** \( \frac{1}{ (x^2 + bx + c)^n } \) with \( b^2 - 4c < 0 \), quadratic term to \( n \geq 2 \) power

- We have to perform integration by parts iteratively to reduce the power down to a linear term:

\[ \begin{array} { l l } \displaystyle \int\frac{1}{(x^2+bx+c)^n} \, dx & = \displaystyle \frac{2x+b}{(n-1)(4c-b^2)(x^2+bx+c)^{n-1}} +\frac{(2n-3)2}{(n-1)(4c-b^2)}\int\frac{1}{(x^2+bx+c)^{n-1}} \, dx + C \\\\ \displaystyle \int\frac{x}{(x^2+bx+c)^n} \, dx & = \displaystyle -\frac{bx+2c}{(n-1)(4c-b^2)(x^2+bx+c)^{n-1}} -\frac{b(2n-3)}{(n-1)(4c-b^2)}\int\frac{1}{(x^2+bx+c)^{n-1}} \, dx + C. \end{array} \]

The best way to understand how this works would be to work through several examples to see how to deal with each of these types.

## Basic Examples

We will start with some basic examples which involve only one type of partial fractions. These are relatively easy to solve.

Evaluate \(\displaystyle \int \frac{ 2x }{ x^2-1 }\, \mathrm dx \).

The denominator is of the form \( x^2 -1 = (x-1)(x+1) \) and partial fractions yields

\[ \frac{2x}{ (x-1)(x+1) } = \frac{ 1}{ x+1} + \frac{1}{ x-1} . \]

We integrate each term separately as Type 2a to obtain

\[ \begin{align}

\int \frac{2x}{ (x-1)(x+1) } \, \mathrm dx & = \int \frac{ 1}{ x+1} \, \mathrm dx + \int \frac{1}{ x-1} \, \mathrm dx \\ & = \ln \left|x+1\right| + \ln \left|x-1\right| + C.\ _\square \end{align} \]For the sake of this wiki page, partial fraction is used to solve this problem. However, the common way to solve this is via \(u\)-substitution:

Let \(u\) be \(x^2-1\), then \(du = 2x \, \mathrm dx\) and the integral becomes

\[ \int \frac 1 u\, \mathrm du,\]

which can be solved easily as

\[ \ln u + C. \]

And substitute \(u\) back as

\[ \ln \big|x^2-1\big| + C.\]

Evaluate \(\displaystyle \int \frac{ x} {( x + 1)^3 } \, dx\).

The denominator is the power of a linear term. Applying partial fractions, we get

\[ \frac{x}{ (x+1)^3 } = \frac{1}{ (x+1)^2 } - \frac{1}{ (x+1)^ 3 } . \]

These are of Type 2b, so we can integrate them to obtain

\[ \begin{align} \int \frac{ x} {( x + 1)^3 } \, dx & = \int \frac{1}{ (x+1)^2 } \, dx - \int \frac{1}{ (x+1)^ 3 } \, dx \\ & = \left(- \frac{1}{1} \right) \frac{1}{ x+1} - \left( -\frac{1}{2} \right) \frac{1}{ (x+1) ^2 } + C \\ & = - \frac{ 2x+1} { 2(x+1)^ 2} + C .\ _\square \end{align} \]

## Intermediate Examples

Let's look at more complicated examples. In the following problems, we will encounter multiple types of partial fractions in a single example.

Evaluate \( \displaystyle \int \frac{ 4x+5 } { x^2 + 2x + 3 } \, dx\).

The discriminant of the denominator is \( 2^2 - 4 \times 3 < 0 \), so it is irreducible. We have \( x^2 + 2x + 3 = (x+1) ^2 + \left(\sqrt{2} \right)^2 \).

We know how to integrate \( \frac{ 2x + 2 } { x^2 + 2x + 3 } \) (Type 3a) and \( \frac {1}{ x^2 + 2x + 3 } \) (Type 3b), so our goal is to split it up into those forms. We have

\[ \frac{4x+5} { x^2 + 2x + 3 } = A \times \frac{2x+2} { x^2 + 2x + 3 } + B \times \frac{1}{ x^2 + 2x + 3 } . \]

Multiplying throughout by \( x^2 + 2x + 3 \) and comparing linear terms gives us \( 4x = 2Ax, \) or \( A = 2 \). Comparing the constant terms gives us \( 5 = 2A + B \), or \( B = 5 - 2 \times 2 = 1 \). Hence,

\[ \begin{align} \int \frac{ 4x+5 } { x^2 + 2x + 3 } \, dx & = 2 \int \frac{2x+2} { x^2 + 2x + 3 } \, dx + 1 \int \frac{1}{ x^2 + 2x + 3 } \, dx \\ & = 2 \ln \left|x^2 + 2x + 3 \right| + \frac{1}{ \sqrt{2} } \arctan \frac{ x+1 } { \sqrt{2} } + C. \ _\square \end{align} \]

Evaluate \(\displaystyle \int \frac{ x^2 + 2 x + 3 } { 4x+5 } \, dx \).

Since this is a mixed fraction, we perform long division to get

\[ \frac{ x^2 + 2 x + 3 } { 4x+5 } = \frac{x}{4} + \frac{3}{16} + \frac{ 33}{ 16 (4x+ 5 ) }. \]

The remainder polynomial is easily integrated as \( \frac{1}{8} x^2 + \frac{3}{16} x \).

If we look at the linear polynomial, it is not of the form \( \frac{1}{ x+ a } \) as yet. However, we can write it as \( \frac{ 33}{64} \times \frac{ 1} { x + \frac{5}{4} } \), which we can thus integrate. Hence,

\[ \begin{align}

\int \frac{ x^2 + 2 x + 3 } { 4x+5 } \, dx & = \int \frac{x}{4} \, dx + \int \frac{3}{16}\, dx + \int \frac{ 33}{ 16 (4x+ 5 ) } \, dx \\ & = \frac{1}{8} x^2 + \frac{3}{16} x + \frac{33}{64} \ln \left| x + \frac{5}{4} \right| + C.\ _\square \end{align} \]

Evaluate \(\displaystyle \int \frac{ 1 } { (x^2 + 1 ) ^ 2 } \, dx \).

We have a quadratic polynomial to a "high" degree, which is of Type 3c. This is troublesome to integrate, and we have to do it iteratively. Using \( u = \frac{1}{ x^2 + 1 } \) and \( dv = dx \), we have \( du = - \frac{ 2x} { (x^2+1)^2 } \) and \( v = x \). This gives us

\[ \begin{align} \int \frac{ 1}{ x^2 + 1} \, dx & = \frac{ x}{ x^2 + 1 } + \int \frac{ 2x^2 }{ (x^2 + 1 ) ^2 } \, dx \\ & = \frac{ x}{ x^2 + 1 } + 2 \int \frac{ 1}{ x^2 + 1 } \, dx - 2 \int \frac{1}{ (x^2 + 1)^2 }\, dx. \end{align} \]

This allows us to conclude that

\[ \begin{align} \int \frac{1}{ (x^2 + 1) ^2 } \, dx

& = \frac{1}{2} \left( \frac{x}{ x^2 + 1 } + \int \frac{1}{ x^2 + 1 } \, dx \right) \\ & = \frac{1}{2} \left( \frac{x}{ x^2+1} + \arctan x + C \right).\ _\square \end{align} \]

This approach allows us to iteratively figure out what \({\displaystyle \int} \frac{1}{ \big( ( x + b)^2 + c^2 \big)^n } \) is. It can be very time-consuming.

Evaluate \(\displaystyle \int \frac{ x } { \left( x^2 + c^2 \right) ^ n } \, dx \).

Using the substitution \( u = x ^2 + c^2 \), we have \( du = 2x \, dx \). As such,

\[ \int \frac{ x } { \left( x^2 + c^2 \right) ^ n } \, dx = \int \frac{ du } { 2 u^n } = \frac{1}{2 ( 1-n) } \frac{1} { \left( x^2 + c^2 \right) ^ {n-1} } + C.\ _\square \]

This approach allows us to easily figure out how to integrate \( \frac{ x-b} { \big( (x-b)^2 + c^2 \big) ^ n } \).

Show that \(\displaystyle \int_0 ^ \infty \frac{1}{ x^3 + 1 } \, dx = \frac{ 2 \sqrt{3} \pi } { 9 } \).

To find the definite integral, we must first find the expression of the indefinite integral.

We see that the denominator can be easily factored as \( x^3 + 1 = (x + 1) ( x^2 - x + 1), \) so we will use the partial fraction approach. Using partial fractions,

\[ \frac{ 1 } { x^3 + 1 } = \frac{ 1 }{ 3(x + 1) } + \frac{ - x + 2 }{3( x^2 - x + 1) }. \]

We will integrate the first term as Type 2a and the second term as Type 3b:

\[ \begin{align} \int \frac{ 1 }{ x^3 + 1 } \, dx

& = \int \left(\frac{ 1 }{ 3(x + 1) } + \frac{ - x + 2 }{ 3( x^2 - x + 1) }\right) dx \\ & = \frac{ 1 }{ 3 } \ln | x + 1| - \frac{1}{3} \int \frac{ x - 2 }{ x^2 - x + 1 } \, dx \\ & = \frac{ 1 }{ 3 } \ln | x + 1| - \frac{1}{6} \int \frac{ (2x - 1) - 3 }{ \left( x - \frac{1}{2} \right)^{2} + \frac{3}{4} } \, dx \\ & = \frac{ 1 }{ 3 } \ln | x + 1| - \frac{1}{6} \int \frac{ 2x - 1 }{ \left( x - \frac{1}{2} \right)^{2} + \frac{3}{4} } \, dx - \frac{1}{6} \int \frac{ -3 }{ \left( x - \frac{1}{2} \right)^{2} + \frac{3}{4} } \, dx \\

& = \frac{ 1 }{ 3 } \ln | x + 1| - \frac{1}{6} \ln \left| \left( x - \frac{1}{2} \right)^{2} + \frac{3}{4}\right| + \frac{1}{2} \cdot \frac{2}{\sqrt{3}} \arctan \left( \frac {x - \frac{1}{2}}{\frac{\sqrt{3}}{2}} \right) + C \\ & = \frac{ 1 }{ 3 } \ln | x + 1| - \frac{1}{6} \ln \left| x^2 - x + 1\right| + \frac{1}{\sqrt{3}} \arctan \left( \frac {2x -1}{\sqrt{3}} \right) + C. \end{align} \]The function \( \frac{1}{x^3 + 1}\) is continuous from \(0\) to \(\infty\), so we can use the fundamental theorem of calculus. To calculate the definite integral, we will evaluate the indefinite integral at \(x = 0\) and \(\infty\).

At \(x = 0 \), the first two terms become \(\ln 1,\) which is equal to zero. The third term is \(\frac{1}{\sqrt{3}} \arctan\frac{-1}{\sqrt{3}} =\frac{1}{\sqrt{3}} \cdot \frac{ - \pi} {6} = - \frac{\pi}{6 \sqrt{3}}\).

Now we find the limit of the above expression as \(x \to \infty\). For the first two terms, we can use the properties of logarithms and write them as \(\ln \left( \frac{(x + 1 )^2 }{x^2 - x + 1} \right)\). As \(x\) tends to infinity, the argument of \(\ln\) tends to \(1\), so the sum of the first two terms tends to \(0\). The third term becomes \( \frac{1}{\sqrt{3}} \cdot \frac{\pi}{2} = \frac{\pi }{2 \sqrt{3}}:\)

\[ \int_0 ^ \infty \frac{1}{ x^3 + 1 } \, dx = \frac{ \pi } { 2\sqrt{3} } - \frac{ -\pi } { 6 \sqrt{3} } = \frac{ 2 \pi } {3 \sqrt{3} } = \frac{ 2 \sqrt{3} \pi } { 9 }.\ _\square \]

\[ Y = \int _{ 0 }^{ 1 }{ \frac { 2{ x }^{ 2 }+3x+3 }{ (x+1)({ x }^{ 2 }+2x+2) } } dx \]

Which of the following options are equal to \(Y?\)

(A) \(\ \frac { \pi }{ 4 } +2\log2-\arctan { 2 }\)

(B) \(\ \frac { \pi }{ 4 } +2\log2-\arctan {\frac{1}{3}}\)

(C) \(\ 2 \log 2 - \text{arccot 3}\)

(D) \(\ -\frac{\pi}{4}+\log4+\text{arccot 2}\)

## \(u\)-substitution Approach

The partial fraction approach is highly dependent on assuming that we can factorize the denominator into linear and quadratic terms. Sometimes, that isn't nice, or that doesn't yield a nice result. In such cases, we should give \(u\)-substitution a try.

Recall that we use \(u\)-substitution when an integral is of the following type:

\[\int g\big(f(x)\big) \cdot f'(x) \, dx,\]

where \(g\) is easy to integrate. We substitute \(u = f(x)\), and we get \( du = f'(x) \, dx\). The integration simplifies to \(\int g(u) \, du\), which is easy to evaluate. Let's look at a few examples which are difficult to solve by partial fractions approach but are very easy using \(u\)-substitution.

Evaluate \( \displaystyle \int \dfrac{ x^2 }{ x^3 + 1 } \, dx \).

We will try to apply U-substitution here. Note that the derivative of \(x^3 + 1\) wrt \(x\) is \(3x^2\). We already have \(x^2\) in the numerator. If we could have \(3x^2\) in the numerator, then the integration would become of the form \(\int \frac{f'(x)}{f(x)} \, dx\). We know how to integrate it: we substitute \(u = f(x)\). So how can we make the numerator \(3x^2\)? We multiply and divide by three. We get

\[\frac{1}{3} \int \frac{3 x^2 }{ x^3 + 1 } \, dx\]

Let \(f(x) = x^3 + 1\). then \(f'(x) = 3x^2\). We substitute \(u = x^3 + 1\), and \(du = 3x^2 \, dx\). We are left with \(\int \frac{1}{u} \, du\). This is a standard integral, we know it evaluates to \(\ln |u| + C\). We substitute the value of \(u\) back and we obtain:

\[ \int \frac{ x^2 }{ x^3 + 1 } \, dx = \frac{1}{3} \ln \left| x^3 + 1 \right| + C.\ _\square\]

Here are some more problems that can be solved in the same way. You may want to try and prove them as an exercise.

\(1. \displaystyle \int \dfrac{ x^2 + 1 } { x^3 + 3x + 7} \, dx = \frac{1}{3} \ln \left| x^3 + 3x + 7 \right| + C\)

\(2. \displaystyle \int \dfrac{ x^3 } { x^4 + 1 } \, dx = \frac{1}{4} \ln \left| x^4 + 1 \right| + C \)

Exercise: Prove that \(\displaystyle \int\frac{x}{(x + b)^n} \, dx= \frac{(1 - n)x - b}{(n - 1)(n - 2)(x + b)^{n-1}} + C \) for \( n \neq 1, 2. \)

Hint:Use \(u\)-substitution \((u = x + b).\)

Here is another example where \(u\)-substitution can be used:

Evaluate \( \displaystyle \int \dfrac{x}{ x^4 + 1 } \, dx\).

The integral can also be written as

\[ \frac{1}{2} \int \frac{2x}{ (x^2)^2 + 1 } \, dx. \]

Note that numerator is the derivative of \(x^2\) and that the denominator is a function of \(x^2\). If we substitute \(u = x^2\), then perhaps we will be able to simplify things a bit.

Let \(u = x^2\), then \(du = 2x \, dx:\)

\[ \frac{1}{2} \int \frac{1}{ u^2 + 1 } \, du. \]

This is a standard integral, and it evaluates to \(\arctan u + C\). If we put back the value \(u = x^2\), we obtain

\[ \int \frac{x}{ x^4 + 1 } \, dx = \frac{1}{2} \arctan x^2 + C.\ _\square \]

It may be hard to see at first, but U-substitution works here wonderfully:

Evaluate \(\displaystyle \int \dfrac{x^2 + 1}{x^4 + \lambda x^2 + 1} \, dx \), if \(\lambda\) is any real number.

(This method is not very intuitive, but you will see it is very simple to use and works great.)

We first divide the numerator and the denominator by \(x^2\). We get

\[\int \frac{1 + \frac{1}{x^{2}}}{x^{2} + \frac{1}{x^{2}} + \lambda} \, dx.\]

Let \(u = x - \frac{1}{x}\). On differentiating both sides, \(du = 1 + \frac{1}{x^{2}} \, dx\). \(\big(\)Note that \(u^2 = x^2 + \frac{1}{x^{2}} - 2\big).\)

We can rewrite the integral as

\[ \int \frac{1}{u^{2} + 2 + \lambda} \, du.\]

This is now very easy to solve. If \(2 + \lambda\) is a negative quantity, then using the \(a^2 - b^2 = (a+b)(a-b)\) identity, we can split the term into two terms with linear denominator. Otherwise, if \(2 + \lambda\) is positive, then it is of Type 3a, and we know how to solve it, too. So, we are done. \(_\square\)

For an extra challenge, try this generalized problem using the same principle:

**Evaluate \(\displaystyle \int \dfrac{\nu x^2 + \mu}{x^4 + \lambda x^2 + 1} \, dx \) for \(\lambda, \mu, \nu \in \mathbb{R}\).**

**Cite as:**Integration of Rational Functions .

*Brilliant.org*. Retrieved from https://brilliant.org/wiki/integration-of-rational-functions-easy/