$\int \frac{x^3+3x+2}{(x^2+1)^2 (x+1)} \ dx$ without using partial fraction decomposition One way to evaluate the integral $$\int \frac{x^3+3x+2}{(x^2+1)^2(x+1)} \ dx $$ is to rewrite it as $$ \int \frac{x^3+x+2x+2}{(x^2+1)^2(x+1)} dx \\=\int\frac{x(x^2+1) +2(x+1)}{(x^2+1)^2(x+1)}dx\\=\int\frac{x}{(x^2+1)(x+1)}dx+\int\frac{2}{(x^2+1)^2}dx$$ and then proceed by using partial fraction decomposition on the first integral. The second integral could be dealt with by substituting $x=\tan \theta$.
Is there a way to evaluate this integral without using partial fractions, and preferably without splitting it into two integrals as I did here?
 A: Let
$$\frac{x^2+1}{(x+1)^2}=t\implies x=\frac{\sqrt{2 t-1}-t}{t-1}\implies dx=\frac{dt}{1-t \left(\sqrt{2 t-1}+2\right)}$$ to make
$$I=\int \frac{x^3+3x+2}{(x^2+1)^2(x+1)} \, dx=\int\left(-\frac{1}{2 t^2}+\frac{1}{4 t}-\frac{3}{4 t \sqrt{2 t-1}}\right)\,dt$$ which does not seem too bad.
$$I=\frac{1}{2 t}+\frac 14 \log(t)-\frac{3}{2} \tan ^{-1}\left(\sqrt{2 t-1}\right)+C$$
A: To avoid partially fractionizing the integrand, proceed with the substitution below instead
\begin{align}
\int\frac{x^3+3x+2}{(x^2+1)^2(x+1)}\overset{x=\frac{1-y}{1+y}}{dx}
=&\ \frac12\int \frac{y^3-3y^2-3y-3}{(1+ y^2)^2}dy\\
=& \ \frac12\int \frac{(y^2-3)y}{(1+ y^2)^2}-\frac3{1+ y^2}\ dy\\
=& \ \frac1{1+ y^2}+\frac14\ln(1+ y^2)-\frac32\tan^{-1}y
\end{align}
A: $$\operatorname*{Res}_{z=-1}\frac{z^3+3z+2}{(z^2+1)^2(z+1)}=\lim_{z\to -1}\frac{z^3+3z+2}{(z^2+1)^2}=-\frac{1}{2}$$
so we know in advance that the integrand function plus $\frac{1}{2(x+1)}$ can be written as $\frac{p(x)}{(x^2+1)^2}$:
$$ \frac{x^3+3x+2}{(x^2+1)^2(x+1)}+\frac{1}{2(x+1)} = \frac{x^3+x^2+x+5}{2(x^2+1)^2}=\frac{x}{2(x^2+1)}+\frac{x^2+5}{2(x^2+1)^2}. $$
This leads to the decomposition
$$ \frac{x^3+3x+2}{(x^2+1)^2(x+1)}=-\frac{1}{2(x+1)}+\frac{x}{2(x^2+1)}+\frac{1}{2(x^2+1)}+\frac{2}{(x^2+1)^2} $$
and also to
$$\int\frac{x^3+3x+2}{(x^2+1)^2(x+1)}\,dx= -\frac{1}{2}\log(x+1)+\frac{1}{4}\log(x^2+1)+\frac{1}{2}\arctan(x)+2\int\frac{dx}{(x^2+1)^2} $$
where the last integral is immediately solved by $x\mapsto\tan\theta$.
