<s>[INST] How to solve $\int \frac{(x-1)\sqrt{x^4+2x^3-x^2+2x+1}}{x^2(x+1)}dx$? I need to compute $$\int \frac{(x-1)\sqrt{x^4+2x^3-x^2+2x+1}}{x^2(x+1)}\ dx.$$ I tried it on wolfram but it timed out, maybe because I am on a mobile device. Any hint is appreciated.
 [/INST] Hint:
$$\begin{align}
I
&=\int\frac{x-1}{x^2\left(x+1\right)}\sqrt{\left(x^2+3x+1\right)\left(x^2-x+1\right)}\,\mathrm{d}x\\
&=\int\frac{y}{\left(\frac{1+y}{1-y}\right)^2}\sqrt{\left(\frac{5-y^2}{\left(1-y\right)^2}\right)\left(\frac{1+3y^2}{\left(1-y\right)^2}\right)}\,\frac{2\,\mathrm{d}y}{\left(1-y\right)^2};~~~\small{\left[\frac{x-1}{x+1}=y\right]}\\
&=\int\frac{2y}{\left(1+y\right)^2\left(1-y\right)^2}\sqrt{\left(5-y^2\right)\left(1+3y^2\right)}\,\mathrm{d}y\\
&=\int\frac{2y}{\left(1-y^2\right)^2}\sqrt{\left(5-y^2\right)\left(1+3y^2\right)}\,\mathrm{d}y\\
&=\int\frac{\sqrt{\left(5-z\right)\left(1+3z\right)}}{\left(1-z\right)^2}\,\mathrm{d}z;~~~\small{\left[y^2=z\right]}.\\
\end{align}$$
After that, you can complete the square under the radical and apply trigonometric substitutions to finish the integral.
</s>