$\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?

$$\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$.
