# Evaluating the integral $\int{\frac{x^2-2x-1}{(x-1)^2(x^2+1)}}$

I successfully evaluated the following integral using partial fraction expansion, but am unsure of a few steps.

\int{\frac{x^2-2x-1}{(x-1)^2(x^2+1)}} = \int\left( \frac{A}{x-1} + \frac{B}{(x-1)^2} + \frac{Cx+D}{x^2+1} \right) \\\ \\ \\ x^2-2x-1 = A(x-1)(x^2+1) + B(x^2+1) + (Cx+D)(x-1)^2 \\\ \\ \\ x=1 \implies -2 = 2B \implies B = -1 \\\ \\ \begin{align} x=i \implies & -2-2i = (D+Ci)(i-1^2) = -2i(D+Ci) \\ \implies & -C+Di = 1+i \\ \implies &\ C=-1,\ \ D=1 \end{align} \\\ \\ \\ x^2-2x-1 = A(x-1)(x^2+1) - (x^2+1) - (x-1)^3 \\\ \\ \\ x=0 \implies -1 = -A \implies A = 1 \\\ \\ \\ \int{\frac{x^2-2x-1}{(x-1)^2(x^2+1)}} = \int\left(\frac{1}{x-1} - \frac{1}{(x-1)^2} + \frac{1-x}{x^2+1}\right) = \int \left( \frac{1}{x-1} - \frac{1}{(x-1)^2} - \frac{x}{x^2+1} + \frac{1}{x^2+1} \right) \\\ \\ \\ = \ln|x-1| + \frac{1}{x-1} - \frac{1}{2}\ln|x^2+1| + \arctan(x) + C\\\ \\

My main points of confusion are:

1. In general, how do you know which denominators to use in step 1?
2. Is it okay to find the variables by plugging in values for $x$? Does this work in general? Is there anything I should be aware of, particularly where $i$ is involved?

Notice:

• Your way of using partial fractions is right, and it works in general.
• Use this to find the partial fractions.
• The integral of $\frac{1}{x}$ is equal to $\ln|x|+\text{C}$.
• For $i$ notice that $i^2=-1$
• When $a,b\in\mathbb{R}$:

$$a+bi=|a+bi|e^{\arg(a+bi)i}=|a+bi|\left(\cos(\arg(a+bi))+\sin(\arg(a+bi))i\right)$$

• $|a+bi|=\sqrt{\Re^2(a+bi)+\Im^2(a+bi)}=\sqrt{a^2+b^2}$

$$\int\frac{x^2-2x-1}{(x-1)^2(x^2+1)}\space\text{d}x=$$ $$\int\left[\frac{1-x}{x^2+1}+\frac{1}{x-1}-\frac{1}{(x-1)^2}\right]\space\text{d}x=$$ $$\int\left[\frac{1}{x^2+1}-\frac{x}{x^2+1}+\frac{1}{x-1}-\frac{1}{(x-1)^2}\right]\space\text{d}x=$$ $$\int\frac{1}{x^2+1}\space\text{d}x-\int\frac{x}{x^2+1}\space\text{d}x+\int\frac{1}{x-1}\space\text{d}x-\int\frac{1}{(x-1)^2}\space\text{d}x=$$ $$\int\frac{1}{x^2+1}\space\text{d}x-\int\frac{x}{x^2+1}\space\text{d}x+\int\frac{1}{x-1}\space\text{d}x-\int\frac{1}{(x-1)^2}\space\text{d}x=$$

For the intergand $\frac{x}{x^2+1}$, substitute $u=x^2+1$ and $\text{d}u=2x\space\text{d}x$:

$$\int\frac{1}{x^2+1}\space\text{d}x-\frac{1}{2}\int\frac{1}{u}\space\text{d}u+\int\frac{1}{x-1}\space\text{d}x-\int\frac{1}{(x-1)^2}\space\text{d}x=$$ $$\arctan(x)-\frac{1}{2}\int\frac{1}{u}\space\text{d}u+\int\frac{1}{x-1}\space\text{d}x-\int\frac{1}{(x-1)^2}\space\text{d}x=$$

For the intergand $\frac{1}{x-1}$, substitute $s=x-1$ and $\text{d}s=\text{d}x$:

$$\arctan(x)-\frac{1}{2}\int\frac{1}{u}\space\text{d}u+\int\frac{1}{s}\space\text{d}s-\int\frac{1}{(x-1)^2}\space\text{d}x=$$

For the intergand $\frac{1}{(x-1)^2}$, substitute $p=x-1$ and $\text{d}p=\text{d}x$:

$$\arctan(x)-\frac{1}{2}\int\frac{1}{u}\space\text{d}u+\int\frac{1}{s}\space\text{d}s-\int\frac{1}{p^2}\space\text{d}p=$$ $$\arctan(x)-\frac{\ln\left|u\right|}{2}+\ln\left|s\right|+\frac{1}{p}+\text{C}=$$ $$\arctan(x)-\frac{\ln\left|x^2+1\right|}{2}+\ln\left|x-1\right|+\frac{1}{x-1}+\text{C}$$

• Thanks for the detailed answer. The Wikipedia page was helpful. Aside from the mistakes in the final step, am I reasoning correctly? I'm not sure what you're saying about $a+bi$. Is it not correct to reason $a+bi=x+yi \implies a = x+yi-bi = x$ (taking the real part) and then eliminating $a$ and $x$ to leave $xi=yi \implies x = y$?
– Zaz
Jan 29, 2016 at 16:25

In general you factor the denominator (this can be hard), then

every linear factor $(x-a)^r$ gives you $r$ terms $\frac {A_1}{x-a}$, $\frac {A_2}{(x-a)^2}$, $\ldots$, $\frac {A_r}{(x-a)^r}$

every quadratic factor $(x^2+ bx+c)^s$ (it has complex roots, otherwise factor it to linear terms and apply the above) gives you $s$ terms $\frac {B_1 x+C_1}{x^2+bx+c}$,$\frac {B_2x+C_2}{(x^2+bx+c)^2}$, $\ldots$, $\frac {B_sx+C_s}{(x^2+bx+c)^s}$

Next step is to solve for $A_i$, $B_j$ and $C_j$. It's a linear system that has unique solution. In the end integrate all the remaining integrals