Today we learn how to integrate rational functions.
Partial Fractions
We are interested in finding integrals of the form $$\int \frac{p(x)}{q(x)} \, dx$$ where $p(x)$ and $q(x)$ are polynomials.
There will be several cases to consider which we will introduce by example.
Example: Distinct Linear Factors, $\deg p(x) \lt \deg q(x)$
Find the indefinite integral. $\displaystyle \int \frac{5x-3}{x^2-2x-3} \, dx$
We first factor the denominator to reveal its linear factors.
$$x^2-2x-3=(x+1)(x-3).$$
Our goal is to rewrite the integrand in the form
$$\frac{5x-3}{x^2-2x-3}=\frac{5x-3}{(x+1)(x-3)}=\frac{A}{x+1}+\frac{B}{x-3}$$
where $A$ and $B$ are constants.
To determine $A$ and $B,$ we work backward and combine the last expression above over a common denominator. $$\frac{A}{x+1}+\frac{B}{x-3}=\frac{A(x-3)}{(x+1)(x-3)}+\frac{B(x+1)}{(x-3)(x+1)}=\frac{(A+B)x+(-3A+B)}{x^2-2x+3}$$ The last of the above must equal $\displaystyle \frac{5x-3}{x^2-2x-3},$ thus, we set $A+B=5$ and $-3A+B=-3.$ That is, we have a linear system of equations. $$ \begin{cases} A&+B=5\\ -3A&+B=-3 \end{cases} $$ Solving this system...
...we have $A=2$ and $B=3.$ From this we have, $$\frac{5x-3}{x^2-2x-3}=\frac{2}{x+1}+\frac{3}{x-3}$$ We may now integrate! $$ \begin{array}{lll} \displaystyle \int \frac{5x-3}{x^2-2x-3}\,dx&=\displaystyle\int \frac{2}{x+1}+\frac{3}{x-3}\,dx &\mbox{}\\ &=\displaystyle 2\int \frac{1}{x+1} \,dx+3\int \frac{1}{x-3}\,dx &\mbox{}\\ &=\displaystyle 2\ln|x+1|+3\ln|x-3| +C&\mbox{}\\ %&=\displaystyle \ln|x+1|^2+\ln|x-3|^3 +C&\mbox{}\\ %&=\displaystyle \ln\left(|x+1|^2|x-3|^3\right)+C&\mbox{}\\ %&=\displaystyle \ln\left((x+1)^2|x-3|^3\right)+C&\mbox{}\\ \end{array} $$
To determine $A$ and $B,$ we work backward and combine the last expression above over a common denominator. $$\frac{A}{x+1}+\frac{B}{x-3}=\frac{A(x-3)}{(x+1)(x-3)}+\frac{B(x+1)}{(x-3)(x+1)}=\frac{(A+B)x+(-3A+B)}{x^2-2x+3}$$ The last of the above must equal $\displaystyle \frac{5x-3}{x^2-2x-3},$ thus, we set $A+B=5$ and $-3A+B=-3.$ That is, we have a linear system of equations. $$ \begin{cases} A&+B=5\\ -3A&+B=-3 \end{cases} $$ Solving this system...
...we have $A=2$ and $B=3.$ From this we have, $$\frac{5x-3}{x^2-2x-3}=\frac{2}{x+1}+\frac{3}{x-3}$$ We may now integrate! $$ \begin{array}{lll} \displaystyle \int \frac{5x-3}{x^2-2x-3}\,dx&=\displaystyle\int \frac{2}{x+1}+\frac{3}{x-3}\,dx &\mbox{}\\ &=\displaystyle 2\int \frac{1}{x+1} \,dx+3\int \frac{1}{x-3}\,dx &\mbox{}\\ &=\displaystyle 2\ln|x+1|+3\ln|x-3| +C&\mbox{}\\ %&=\displaystyle \ln|x+1|^2+\ln|x-3|^3 +C&\mbox{}\\ %&=\displaystyle \ln\left(|x+1|^2|x-3|^3\right)+C&\mbox{}\\ %&=\displaystyle \ln\left((x+1)^2|x-3|^3\right)+C&\mbox{}\\ \end{array} $$
Example: Distinct Linear Factors, $\deg p(x) \lt \deg q(x)$
Find the indefinite integral. $\displaystyle \int \frac{x^2+4x+1}{(x-1)(x+1)(x+3)} \, dx$
We do the same thing as before except we have more linear factors. That is, we want to work our integrand into the form
$$\frac{A}{x-1}+\frac{B}{x+1}+\frac{C}{x+3}$$
Working backward as before,
$$
\begin{array}{ll}
\displaystyle \frac{x^2+4x+1}{(x-1)(x+1)(x+3)}&=\displaystyle\frac{A}{x-1}+\frac{B}{x+1}+\frac{C}{x+3}&\\
&=\displaystyle\frac{A(x+1)(x+3)}{(x-1)(x+1)(x+3)}+\frac{B(x-1)(x+3)}{(x+1)(x-1)(x+3)}+\frac{C(x-1)(x+1)}{(x+3)(x-1)(x+1)}\\
&=\displaystyle\frac{A(x^2+4x+3)}{(x-1)(x+1)(x+3)}+\frac{B(x^2+2x-3)}{(x+1)(x-1)(x+3)}+\frac{C(x^2-1)}{(x+3)(x-1)(x+1)}\\
&=\displaystyle\frac{(A+B+C)x^2+(4A+2B)x+3A-3B-C}{(x-1)(x+1)(x+3)}\\
\end{array}
$$
Equating coefficients, we have the system
$$
\begin{cases}
A&+B&+C&=1\\
4A&+2B&&=4\\
3A&-3B&-C&=1\\
\end{cases}
$$
Solving this system...
...we have $\displaystyle A=\frac{3}{4},$ $\displaystyle B=\frac{1}{2},$ and $\displaystyle C=-\frac{1}{4}.$
We may now integrate! $$ \begin{array}{lll} \displaystyle \int \frac{x^2+4x+1}{(x-1)(x+1)(x+3)} \, dx&=\displaystyle \int \frac{3/4}{x-1}+\frac{1/2}{x+1}+\frac{-1/4}{x+3} \, dx&\mbox{}\\ &=\displaystyle \frac{3}{4}\int \frac{1}{x-1}\,dx +\frac{1}{2}\int \frac{1}{x+1}\,dx-\frac{1}{4}\int \frac{1}{x+3} \, dx&\mbox{}\\ &=\displaystyle \frac{3}{4}\ln|x-1| +\frac{1}{2}\ln|x+1|-\frac{1}{4}\ln|x+3|+C&\mbox{}\\ \end{array} $$
...we have $\displaystyle A=\frac{3}{4},$ $\displaystyle B=\frac{1}{2},$ and $\displaystyle C=-\frac{1}{4}.$
We may now integrate! $$ \begin{array}{lll} \displaystyle \int \frac{x^2+4x+1}{(x-1)(x+1)(x+3)} \, dx&=\displaystyle \int \frac{3/4}{x-1}+\frac{1/2}{x+1}+\frac{-1/4}{x+3} \, dx&\mbox{}\\ &=\displaystyle \frac{3}{4}\int \frac{1}{x-1}\,dx +\frac{1}{2}\int \frac{1}{x+1}\,dx-\frac{1}{4}\int \frac{1}{x+3} \, dx&\mbox{}\\ &=\displaystyle \frac{3}{4}\ln|x-1| +\frac{1}{2}\ln|x+1|-\frac{1}{4}\ln|x+3|+C&\mbox{}\\ \end{array} $$
What to Do When $\deg p(x) \geq \deg q(x),$
In the case that $\deg p(x) \geq \deg q(x),$ perform polynomial long division and re-express $\displaystyle \frac{p(x)}{q(x)}$ as $\displaystyle Q(x)+\frac{R(x)}{q(x)}$ where $Q(x)$ and $R(x)$ are the quotient and remainder after performing polynomial long division. Then $$\int \frac{p(x)}{q(x)} \, dx =\int Q(x)+\frac{R(x)}{q(x)} \, dx$$ with $\deg R(x) \lt \deg q(x).$
Example: Distinct Linear Factors, $\deg p(x) \geq \deg q(x)$
Find the indefinite integral. $\displaystyle \int \frac{2x^3-4x^2-x-3}{x^2-2x-3} \, dx$
We first perform polynomial long division. Are you ready????
$$ x^2-2x-3\,\overline{)2x^3-4x^2-x-3} $$
Our quotient is $2x$ and our remainder is $5x-3.$ That is, $$\frac{2x^3-4x^2-x-3}{x^2-2x-3}=2x+\frac{5x-3}{x^2-2x-3}.$$ Thus, $$ \begin{array}{lll} \displaystyle \int \frac{2x^3-4x^2-x-3}{x^2-2x-3} \, dx &=\displaystyle \int 2x+\frac{5x-3}{x^2-2x-3} \, dx &\mbox{}\\ &=\displaystyle \int 2x+\frac{5x-3}{x^2-2x-3} \, dx &\mbox{}\\ &=\displaystyle \int 2x \,dx +\int \frac{5x-3}{x^2-2x-3} \, dx &\mbox{}\\ &=\displaystyle x^2 +2\ln|x+1|+3\ln|x-3| +C &\mbox{from our first example! ;)}\\ \end{array} $$
$$ x^2-2x-3\,\overline{)2x^3-4x^2-x-3} $$
Our quotient is $2x$ and our remainder is $5x-3.$ That is, $$\frac{2x^3-4x^2-x-3}{x^2-2x-3}=2x+\frac{5x-3}{x^2-2x-3}.$$ Thus, $$ \begin{array}{lll} \displaystyle \int \frac{2x^3-4x^2-x-3}{x^2-2x-3} \, dx &=\displaystyle \int 2x+\frac{5x-3}{x^2-2x-3} \, dx &\mbox{}\\ &=\displaystyle \int 2x+\frac{5x-3}{x^2-2x-3} \, dx &\mbox{}\\ &=\displaystyle \int 2x \,dx +\int \frac{5x-3}{x^2-2x-3} \, dx &\mbox{}\\ &=\displaystyle x^2 +2\ln|x+1|+3\ln|x-3| +C &\mbox{from our first example! ;)}\\ \end{array} $$
Example: Repeated Linear Factors
Find the indefinite integral. $\displaystyle \int \frac{6x+7}{(x+2)^2} \, dx$
This is a different situation because we have a repeated linear factor.
In this situation we need to rewrite our integrand a little differently than you might expect.
This time we want to write our integrand in the form
$$
\frac{6x+7}{(x+2)^2}=\frac{A}{x+2}+\frac{B}{(x+2)^2}
$$
That is, the repeated factor is written in ascending powers.
As in previous examples, combining over a common denominator, $$ \frac{6x+7}{(x+2)^2}=\frac{A}{x+2}+\frac{B}{(x+2)^2}=\frac{A(x+2)}{(x+2)^2}+\frac{B}{(x+2)^2}=\frac{Ax+2A+B}{(x+2)^2} $$ Equating coefficients, we have $$ \begin{cases} A&&=6\\ 2A&+B&=7 \end{cases} $$ Solving the system...
...we have $A=6$ and $B=-5.$ Thus, $$ \begin{array}{lll} \displaystyle \int \frac{6x+7}{(x+2)^2} \, dx&=\displaystyle \int \frac{6}{x+2}-\frac{5}{(x+2)^2} \, dx&\mbox{}\\ &=\displaystyle 6\int \frac{1}{x+2}\,dx-5\int\frac{1}{(x+2)^2} \, dx&\mbox{}\\ &=\displaystyle 6\ln|x+2|+\frac{5}{x+2}+C&\mbox{}\\ \end{array} $$
As in previous examples, combining over a common denominator, $$ \frac{6x+7}{(x+2)^2}=\frac{A}{x+2}+\frac{B}{(x+2)^2}=\frac{A(x+2)}{(x+2)^2}+\frac{B}{(x+2)^2}=\frac{Ax+2A+B}{(x+2)^2} $$ Equating coefficients, we have $$ \begin{cases} A&&=6\\ 2A&+B&=7 \end{cases} $$ Solving the system...
...we have $A=6$ and $B=-5.$ Thus, $$ \begin{array}{lll} \displaystyle \int \frac{6x+7}{(x+2)^2} \, dx&=\displaystyle \int \frac{6}{x+2}-\frac{5}{(x+2)^2} \, dx&\mbox{}\\ &=\displaystyle 6\int \frac{1}{x+2}\,dx-5\int\frac{1}{(x+2)^2} \, dx&\mbox{}\\ &=\displaystyle 6\ln|x+2|+\frac{5}{x+2}+C&\mbox{}\\ \end{array} $$
Example: Repeated Linear Factors
Find the indefinite integral. $\displaystyle \int \frac{x^4-2x^2+4x+1}{x^3-x^2-x+1} \, dx$
Since $\deg p(x) \geq \deg q(x)$ we once again need to polish off our polynomial long division skills!
$$ x^3-x^2-x+1\overline{)x^4+0x^3-2x^2+4x+1} $$
Thus, we have a quotient of $x+1$ and a remainder of $4x.$ That is $$ \frac{x^4-2x^2+4x+1}{x^3-x^2-x+1}=x+1+\frac{4x}{x^3-x^2-x+1} $$ We now now dust off our factoring by grouping skills to factor the denominator! $$ \begin{array}{lll} x^3-x^2-x+1&=x^2(x-1)-(x-1)&\mbox{factor in groups}\\ &=(x-1)(x^2-1)&\mbox{factor out common $x-1$ factor}\\ &=(x-1)(x-1)(x+1)&\mbox{factor difference of squares}\\ &=(x-1)^2(x+1)&\\ \end{array} $$ We have so far that $$ \frac{x^4-2x^2+4x+1}{x^3-x^2-x+1}=x+1+\frac{4x}{(x-1)^2(x+1)} $$ We now want to rewrite the rational part. Note the repeated linear factor. $$ \frac{4x}{(x-1)^2(x+1)}=\frac{A}{x-1}+\frac{B}{(x-1)^2}+\frac{C}{x+1} $$ Combining over a common denominator, $$ \begin{array}{lll} \displaystyle\frac{4x}{(x-1)^2(x+1)}&=\displaystyle \frac{A}{x-1}+\frac{B}{(x-1)^2}+\frac{C}{x+1}\\ &=\displaystyle \frac{A(x-1)(x+1)}{(x-1)(x-1)(x+1)}+\frac{B(x+1)}{(x-1)^2(x+1)}+\frac{C(x-1)(x-1)}{(x+1)(x-1)(x-1)} &\mbox{}\\ &=\displaystyle \frac{A(x^2-1)}{(x-1)^2(x+1)}+\frac{B(x+1)}{(x-1)^2(x+1)}+\frac{C(x^2-2x+1)}{(x-1)^2(x+1)} &\mbox{}\\ &=\displaystyle \frac{(A+C)x^2+(B-2C)x-A+B+C}{(x-1)^2(x+1)} &\mbox{}\\ \end{array} $$ Equating coefficients we have the system $$ \begin{cases} A&&+C&=0\\ &B&-2C&=4\\ -A&+B&+C&=0\\ \end{cases} $$ Solving this system...
...we have $A=1,$ $B=2,$ $C=-1.$ Thus, $$ \frac{x^4-2x^2+4x+1}{x^3-x^2-x+1}=x+1+\frac{1}{x-1}+\frac{2}{(x-1)^2}-\frac{1}{x+1} $$ We may now integrate. (Finally!!) $$ \begin{array}{lll} \displaystyle \int \frac{x^4-2x^2+4x+1}{x^3-x^2-x+1} \, dx&=\displaystyle \int x+1+\frac{1}{x-1}+\frac{2}{(x-1)^2}-\frac{1}{x+1} \, dx&\mbox{}\\ &=\displaystyle \frac{1}{2}x^2+x+\int \frac{1}{x-1}\,dx+2\int \frac{1}{(x-1)^2}\,dx-\int\frac{1}{x+1} \, dx&\mbox{}\\ &=\displaystyle \frac{1}{2}x^2+x+\ln|x-1|-\frac{2}{x-1}-\ln|x+1|+C&\mbox{}\\ \end{array} $$
$$ x^3-x^2-x+1\overline{)x^4+0x^3-2x^2+4x+1} $$
Thus, we have a quotient of $x+1$ and a remainder of $4x.$ That is $$ \frac{x^4-2x^2+4x+1}{x^3-x^2-x+1}=x+1+\frac{4x}{x^3-x^2-x+1} $$ We now now dust off our factoring by grouping skills to factor the denominator! $$ \begin{array}{lll} x^3-x^2-x+1&=x^2(x-1)-(x-1)&\mbox{factor in groups}\\ &=(x-1)(x^2-1)&\mbox{factor out common $x-1$ factor}\\ &=(x-1)(x-1)(x+1)&\mbox{factor difference of squares}\\ &=(x-1)^2(x+1)&\\ \end{array} $$ We have so far that $$ \frac{x^4-2x^2+4x+1}{x^3-x^2-x+1}=x+1+\frac{4x}{(x-1)^2(x+1)} $$ We now want to rewrite the rational part. Note the repeated linear factor. $$ \frac{4x}{(x-1)^2(x+1)}=\frac{A}{x-1}+\frac{B}{(x-1)^2}+\frac{C}{x+1} $$ Combining over a common denominator, $$ \begin{array}{lll} \displaystyle\frac{4x}{(x-1)^2(x+1)}&=\displaystyle \frac{A}{x-1}+\frac{B}{(x-1)^2}+\frac{C}{x+1}\\ &=\displaystyle \frac{A(x-1)(x+1)}{(x-1)(x-1)(x+1)}+\frac{B(x+1)}{(x-1)^2(x+1)}+\frac{C(x-1)(x-1)}{(x+1)(x-1)(x-1)} &\mbox{}\\ &=\displaystyle \frac{A(x^2-1)}{(x-1)^2(x+1)}+\frac{B(x+1)}{(x-1)^2(x+1)}+\frac{C(x^2-2x+1)}{(x-1)^2(x+1)} &\mbox{}\\ &=\displaystyle \frac{(A+C)x^2+(B-2C)x-A+B+C}{(x-1)^2(x+1)} &\mbox{}\\ \end{array} $$ Equating coefficients we have the system $$ \begin{cases} A&&+C&=0\\ &B&-2C&=4\\ -A&+B&+C&=0\\ \end{cases} $$ Solving this system...
...we have $A=1,$ $B=2,$ $C=-1.$ Thus, $$ \frac{x^4-2x^2+4x+1}{x^3-x^2-x+1}=x+1+\frac{1}{x-1}+\frac{2}{(x-1)^2}-\frac{1}{x+1} $$ We may now integrate. (Finally!!) $$ \begin{array}{lll} \displaystyle \int \frac{x^4-2x^2+4x+1}{x^3-x^2-x+1} \, dx&=\displaystyle \int x+1+\frac{1}{x-1}+\frac{2}{(x-1)^2}-\frac{1}{x+1} \, dx&\mbox{}\\ &=\displaystyle \frac{1}{2}x^2+x+\int \frac{1}{x-1}\,dx+2\int \frac{1}{(x-1)^2}\,dx-\int\frac{1}{x+1} \, dx&\mbox{}\\ &=\displaystyle \frac{1}{2}x^2+x+\ln|x-1|-\frac{2}{x-1}-\ln|x+1|+C&\mbox{}\\ \end{array} $$
Method Summary: Linear Factors. $\displaystyle \int \frac{p(x)}{q(x)} \, dx$ when $\deg p(x) \lt \deg q(x)$
Case 1: If $q(x)$ can be factored into distinct linear factors $(a_1 x+b_1)(a_2 x+b_1) \cdots (a_n x+b_n),$ find constants $A_1,$ $A_2,$ $\ldots$ $A_n$ such that $$\displaystyle \frac{p(x)}{q(x)}=\frac{p(x)}{(a_1 x+b_1)(a_2 x+b_1) \cdots (a_n x+b_n)}=\frac{A_1}{a_1 x + b_1}+\frac{A_2}{a_2 x + b_2}+\cdots+\frac{A_n}{a_n x + b_n}$$
Case 2: If $q(x)$ has a repeated linear factor $(ax+b)^n,$ find constants $A_1,$ $A_2,$ $\ldots,$ $A_n$ such that $$\displaystyle \frac{p(x)}{q(x)}=\frac{p(x)}{(ax+b)^n}=\frac{A_1}{a x + b}+\frac{A_2}{(ax+b)^2}+\cdots+\frac{A_n}{(ax+b)^n}$$ If $\deg p(x) \geq \deg q(x),$ do polynomial long division and rewrite the integrand $\displaystyle \frac{p(x)}{q(x)}$ as $\displaystyle Q(x)+\frac{R(x)}{q(x)}$ with $\deg R(x) \lt \deg q(x).$
Examples: Distinct Irreducible Quadratic Factors
Find the indefinite integral. $\displaystyle \int \frac{-2x+4}{(x^2+1)(x-1)^2} \, dx$
The integrand contains an irreducible quadratic factor $x^2+1.$ The term irreducible simply means we cannot factor it (over the real numbers).
For quadratic factors, we need to do something a bit different. For the integrand in question, we will write $$ \frac{-2x+4}{(x^2+1)(x-1)^2}=\frac{Ax+B}{x^2+1}+\frac{C}{x-1}+\frac{D}{(x-1)^2} $$ That is to say, the numerator corresponding to an irreducible quadratic factor is linear.
As usual, we combine over a common denominator. $$ \begin{array}{lll} \displaystyle \frac{-2x+4}{(x^2+1)(x-1)^2}&=\displaystyle \frac{Ax+B}{x^2+1}+\frac{C}{x-1}+\frac{D}{(x-1)^2}&\mbox{}\\ &=\displaystyle \frac{(Ax+B)(x-1)^2}{(x^2+1)(x-1)^2}+\frac{C(x^2+1)(x-1)}{(x^2+1)(x-1)^2}+\frac{D(x^2+1)}{(x^2+1)(x-1)^2}&\mbox{}\\ &=\displaystyle \frac{(Ax+B)(x^2-2x+1)}{(x^2+1)(x-1)^2}+\frac{C(x^3-x^2+x-1)}{(x^2+1)(x-1)^2}+\frac{D(x^2+1)}{(x^2+1)(x-1)^2}&\mbox{}\\ &=\displaystyle \frac{A(x^3-2x^2+x)+B(x^2-2x+1)}{(x^2+1)(x-1)^2}+\frac{C(x^3-x^2+x-1)}{(x^2+1)(x-1)^2}+\frac{D(x^2+1)}{(x^2+1)(x-1)^2}&\mbox{}\\ &=\displaystyle \frac{(A+C)x^3+(-2A+B-C+D)x^2+(A-2B+C)x+B-C+D}{(x^2+1)(x-1)^2}&\mbox{}\\ \end{array} $$ Equating coefficients we have the system $$ \begin{cases} A&&+C&&=0\\ -2A&+B&-C&+D&=0\\ A&-2B&+C&&=-2\\ &B&-C&+D&=4\\ \end{cases} $$ Solving this system...
...we have $A=2,$ $B=1,$ $C=-2,$ and $D=1.$ Thus, $$ \frac{-2x+4}{(x^2+1)(x-1)^2}=\frac{Ax+B}{x^2+1}+\frac{C}{x-1}+\frac{D}{(x-1)^2}=\frac{2x+1}{x^2+1}-\frac{2}{x-1}+\frac{1}{(x-1)^2} $$ and we may now integrate. $$ \begin{array}{lll} \displaystyle \int \frac{-2x+4}{(x^2+1)(x-1)^2} \, dx&=\displaystyle \int \frac{2x+1}{x^2+1}-\frac{2}{x-1}+\frac{1}{(x-1)^2} \, dx&\mbox{}\\ &=\displaystyle \int \frac{2x}{x^2+1}+\frac{1}{x^2+1}-\frac{2}{x-1}+\frac{1}{(x-1)^2} \, dx&\mbox{}\\ &=\displaystyle \ln(x^2+1)+\tan^{-1}x-2\ln|x-1|-\frac{1}{x-1}+C&\mbox{}\\ \end{array} $$
For quadratic factors, we need to do something a bit different. For the integrand in question, we will write $$ \frac{-2x+4}{(x^2+1)(x-1)^2}=\frac{Ax+B}{x^2+1}+\frac{C}{x-1}+\frac{D}{(x-1)^2} $$ That is to say, the numerator corresponding to an irreducible quadratic factor is linear.
As usual, we combine over a common denominator. $$ \begin{array}{lll} \displaystyle \frac{-2x+4}{(x^2+1)(x-1)^2}&=\displaystyle \frac{Ax+B}{x^2+1}+\frac{C}{x-1}+\frac{D}{(x-1)^2}&\mbox{}\\ &=\displaystyle \frac{(Ax+B)(x-1)^2}{(x^2+1)(x-1)^2}+\frac{C(x^2+1)(x-1)}{(x^2+1)(x-1)^2}+\frac{D(x^2+1)}{(x^2+1)(x-1)^2}&\mbox{}\\ &=\displaystyle \frac{(Ax+B)(x^2-2x+1)}{(x^2+1)(x-1)^2}+\frac{C(x^3-x^2+x-1)}{(x^2+1)(x-1)^2}+\frac{D(x^2+1)}{(x^2+1)(x-1)^2}&\mbox{}\\ &=\displaystyle \frac{A(x^3-2x^2+x)+B(x^2-2x+1)}{(x^2+1)(x-1)^2}+\frac{C(x^3-x^2+x-1)}{(x^2+1)(x-1)^2}+\frac{D(x^2+1)}{(x^2+1)(x-1)^2}&\mbox{}\\ &=\displaystyle \frac{(A+C)x^3+(-2A+B-C+D)x^2+(A-2B+C)x+B-C+D}{(x^2+1)(x-1)^2}&\mbox{}\\ \end{array} $$ Equating coefficients we have the system $$ \begin{cases} A&&+C&&=0\\ -2A&+B&-C&+D&=0\\ A&-2B&+C&&=-2\\ &B&-C&+D&=4\\ \end{cases} $$ Solving this system...
...we have $A=2,$ $B=1,$ $C=-2,$ and $D=1.$ Thus, $$ \frac{-2x+4}{(x^2+1)(x-1)^2}=\frac{Ax+B}{x^2+1}+\frac{C}{x-1}+\frac{D}{(x-1)^2}=\frac{2x+1}{x^2+1}-\frac{2}{x-1}+\frac{1}{(x-1)^2} $$ and we may now integrate. $$ \begin{array}{lll} \displaystyle \int \frac{-2x+4}{(x^2+1)(x-1)^2} \, dx&=\displaystyle \int \frac{2x+1}{x^2+1}-\frac{2}{x-1}+\frac{1}{(x-1)^2} \, dx&\mbox{}\\ &=\displaystyle \int \frac{2x}{x^2+1}+\frac{1}{x^2+1}-\frac{2}{x-1}+\frac{1}{(x-1)^2} \, dx&\mbox{}\\ &=\displaystyle \ln(x^2+1)+\tan^{-1}x-2\ln|x-1|-\frac{1}{x-1}+C&\mbox{}\\ \end{array} $$
Examples: Repeated Irreducible Quadratic Factors
Find the indefinite integral. $\displaystyle \int \frac{1}{x(x^2+1)^2} \, dx$
We have a repeated irreducible quadratic factor.
The process is similar to that of repeated linear factors in that we include a term for each power of the repeated factor.
That is, we will attempt to rewrite the integrand as
$$
\frac{1}{x(x^2+1)^2}=\frac{A}{x}+\frac{Bx+C}{x^2+1}+\frac{Dx+E}{(x^2+1)^2}
$$
Combining over a common denominator,
$$
\begin{array}{lll}
\displaystyle \frac{1}{x(x^2+1)^2}&=\displaystyle \frac{A}{x}+\frac{Bx+C}{x^2+1}+\frac{Dx+E}{(x^2+1)^2}&\mbox{}\\
&=\displaystyle \frac{A(x^2+1)^2}{x(x^2+1)^2}+\frac{(Bx+C)x(x^2+1)}{x(x^2+1)^2}+\frac{(Dx+E)x}{x(x^2+1)^2}&\mbox{}\\
&=\displaystyle \frac{A(x^4+2x^2+1)}{x(x^2+1)^2}+\frac{(Bx+C)(x^3+x)}{x(x^2+1)^2}+\frac{(Dx+E)x}{x(x^2+1)^2}&\mbox{}\\
&=\displaystyle \frac{A(x^4+2x^2+1)}{x(x^2+1)^2}+\frac{B(x^4+x^2)+C(x^3+x)}{x(x^2+1)^2}+\frac{Dx^2+Ex}{x(x^2+1)^2}&\mbox{}\\
&=\displaystyle \frac{(A+B)x^4+Cx^3+(2A+B+D)x^2+(C+E)x+A}{x(x^2+1)^2}&\mbox{}\\
\end{array}
$$
Equating coefficients we have the system
$$
\begin{cases}
A&+B&&&&=0\\
&&C&&&=0\\
2A&+B&&+D&&=0\\
&&C&&+E&=0\\
A&&&&&=1\\
\end{cases}
$$
Solving this system...
...we have $A=1,$ $B=-1,$ $C=0,$ and $D=-1,$ and $E=0.$ Thus, $$ \frac{1}{x(x^2+1)^2}=\frac{A}{x}+\frac{Bx+C}{x^2+1}+\frac{Dx+E}{(x^2+1)^2}=\frac{1}{x}-\frac{x}{x^2+1}-\frac{x}{(x^2+1)^2} $$ We now integrate: $$ \begin{array}{lll} \displaystyle \int \frac{1}{x(x^2+1)^2}\,dx &=\displaystyle \int \frac{1}{x}-\frac{x}{x^2+1}-\frac{x}{(x^2+1)^2}\,dx &\mbox{}\\ &=\displaystyle \ln|x|-\int \frac{x}{x^2+1} \, dx-\int \frac{x}{(x^2+1)^2}\,dx&\mbox{}\\ &=\displaystyle \ln|x|-\frac{1}{2}\int \frac{1}{u}\,du-\frac{1}{2}\int \frac{1}{u^2}\,du&\mbox{letting $u=x^2+1$ so that $\frac{1}{2}\,du=x\,dx$}\\ &=\displaystyle \ln|x|-\frac{1}{2}\ln|u|+\frac{1}{2}\frac{1}{u}+C&\mbox{}\\ &=\displaystyle \ln|x|-\frac{1}{2}\ln(x^2+1)+\frac{1}{2(x^2+1)}+C&\mbox{}\\ \end{array} $$
...we have $A=1,$ $B=-1,$ $C=0,$ and $D=-1,$ and $E=0.$ Thus, $$ \frac{1}{x(x^2+1)^2}=\frac{A}{x}+\frac{Bx+C}{x^2+1}+\frac{Dx+E}{(x^2+1)^2}=\frac{1}{x}-\frac{x}{x^2+1}-\frac{x}{(x^2+1)^2} $$ We now integrate: $$ \begin{array}{lll} \displaystyle \int \frac{1}{x(x^2+1)^2}\,dx &=\displaystyle \int \frac{1}{x}-\frac{x}{x^2+1}-\frac{x}{(x^2+1)^2}\,dx &\mbox{}\\ &=\displaystyle \ln|x|-\int \frac{x}{x^2+1} \, dx-\int \frac{x}{(x^2+1)^2}\,dx&\mbox{}\\ &=\displaystyle \ln|x|-\frac{1}{2}\int \frac{1}{u}\,du-\frac{1}{2}\int \frac{1}{u^2}\,du&\mbox{letting $u=x^2+1$ so that $\frac{1}{2}\,du=x\,dx$}\\ &=\displaystyle \ln|x|-\frac{1}{2}\ln|u|+\frac{1}{2}\frac{1}{u}+C&\mbox{}\\ &=\displaystyle \ln|x|-\frac{1}{2}\ln(x^2+1)+\frac{1}{2(x^2+1)}+C&\mbox{}\\ \end{array} $$
Method Summary: Quadratic Factors. $\displaystyle \int \frac{p(x)}{q(x)} \, dx$
Case 3: If $q(x)$ can be factored into distinct irreducible quadratic factors $(a_1 x^2+b_1 x+c_1)(a_2 x^2+b_1 x+c_2) \cdots (a_n x^2+b_n x +c_n),$ find constants $A_1,$ $A_2,$ $\ldots,$ $A_n$ and $B_1,$ $B_2,$ $\ldots,$ $B_n$ such that $\displaystyle \frac{p(x)}{(a_1 x^2+b_1 x +c_1)(a_2 x^2+b_1 x+c_1) \cdots (a_n x^2+b_n x +c_n)}$ can be written as $$\displaystyle \frac{A_1 x + B_1}{a_1 x^2+b_1 x +c_1}+\frac{A_2 x + B_2}{a_2 x^2+b_2 x +c_2}+\cdots+\frac{A_n x+ B_n}{a_n x^2+b_n x +c_n}$$ Case 4: If $q(x)$ can be factored into a repeated irreducible quadratic factor $(ax^2+bx+c)^n,$ find constants $A_1,$ $A_2,$ $\ldots,$ $A_n$ and $B_1,$ $B_2,$ $\ldots,$ $B_n$ such that $$\displaystyle \frac{p(x)}{(ax^2+bx+c)^n} =\frac{A_1 x + B_1}{ax^2+bx +c}+\frac{A_2 x + B_2}{(ax^2+bx+c)^2}+\cdots+\frac{A_n x+ B_n}{(ax^2+bx+c)^n}$$ If $\deg p(x) \geq \deg q(x),$ do polynomial long division and rewrite the integrand $\displaystyle \frac{p(x)}{q(x)}$ as $\displaystyle Q(x)+\frac{R(x)}{q(x)}$ with $\deg R(x) \lt \deg q(x).$
Integrals Resulting in Partial Fractions
Use substitution to convert the integral to an integral of rational functions. Then use partial fractions to find the integral. $$\displaystyle \int \frac{\sin x}{1-\cos^2 x} \, dx$$
Here we let $u=\cos x$ so that $-du=\sin x \,dx.$
Then
$$
\begin{array}{lll}
\displaystyle \int \frac{\sin x}{1-\cos^2 x} \, dx&= \displaystyle -\int \frac{1}{1-u^2} \,(-du)&\\
&=\displaystyle \int \frac{1}{u^2-1} \, du&\\
&=\displaystyle \int \frac{1}{(u+1)(u-1)} \, du&\\
\end{array}
$$
Our goal now is to rewrite the integrand.
$$
\frac{1}{(u+1)(u-1)}=\frac{A}{u+1}+\frac{B}{u-1}.
$$
Combining over a common denominator,
$$
\begin{array}{lll}
\displaystyle \frac{1}{(u+1)(u-1)} &=\displaystyle \frac{A}{u+1}+\frac{B}{u-1} &\mbox{}\\
&=\displaystyle \frac{A(u-1)}{(u+1)(u-1)}+\frac{B(u+1)}{(u+1)(u-1)} &\mbox{}\\
&=\displaystyle \frac{(A+B)u-A+B}{(u+1)(u-1)} &\mbox{}\\
\end{array}
$$
Thus, $A+B=0$ and $-A+B=1.$ Solving this system, $\displaystyle A=-\frac{1}{2}$ and $\displaystyle B=\frac{1}{2}.$
Then $$ \begin{array}{lll} \displaystyle \int \frac{\sin x}{1-\cos^2 x} \, dx&=\displaystyle \int \frac{1}{(u+1)(u-1)} \, du&\\ &=\displaystyle \int -\frac{1}{2}\frac{1}{u+1}+\frac{1}{2}\frac{1}{u-1} \, du&\\ &=\displaystyle -\frac{1}{2}\int\frac{1}{u+1}\,du+\frac{1}{2}\int\frac{1}{u-1} \, du&\\ &=\displaystyle -\frac{1}{2}\ln|u+1|+\frac{1}{2}\ln|u-1|+C&\\ &=\displaystyle \frac{1}{2}\left(\ln|u-1|-\ln|u+1|\right)+C&\\ &=\displaystyle \frac{1}{2}\ln\frac{|u-1|}{|u+1|}+C&\\ &=\displaystyle \frac{1}{2}\ln\left|\frac{u-1}{u+1}\right|+C&\\ &=\displaystyle \frac{1}{2}\ln\left|\frac{\cos x-1}{\cos x+1}\right|+C&\mbox{Don't forget to restate in terms of $x!$}\\ \end{array} $$
Then $$ \begin{array}{lll} \displaystyle \int \frac{\sin x}{1-\cos^2 x} \, dx&=\displaystyle \int \frac{1}{(u+1)(u-1)} \, du&\\ &=\displaystyle \int -\frac{1}{2}\frac{1}{u+1}+\frac{1}{2}\frac{1}{u-1} \, du&\\ &=\displaystyle -\frac{1}{2}\int\frac{1}{u+1}\,du+\frac{1}{2}\int\frac{1}{u-1} \, du&\\ &=\displaystyle -\frac{1}{2}\ln|u+1|+\frac{1}{2}\ln|u-1|+C&\\ &=\displaystyle \frac{1}{2}\left(\ln|u-1|-\ln|u+1|\right)+C&\\ &=\displaystyle \frac{1}{2}\ln\frac{|u-1|}{|u+1|}+C&\\ &=\displaystyle \frac{1}{2}\ln\left|\frac{u-1}{u+1}\right|+C&\\ &=\displaystyle \frac{1}{2}\ln\left|\frac{\cos x-1}{\cos x+1}\right|+C&\mbox{Don't forget to restate in terms of $x!$}\\ \end{array} $$