<s>[INST] $\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?
 [/INST] 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$$
</s>