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.
 A: 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.
A: $\bf{My\; Solution::}$ Given $$\displaystyle \int\frac{(x-1)\cdot \sqrt{x^4+2x^3-x^2+2x+1}}{x^2(x+1)}dx = \int\frac{(x^2-1)\cdot \sqrt{x^4+2x^3-x^2+2x+1}}{x^2(x^2+2x+1)}dx$$
Above we multiply both $\bf{N_{r}}$ and $\bf{D_{r}}$ by $(x+1).$
$$\displaystyle = \int\frac{\left(1-\frac {1}{x^2}\right)\cdot \sqrt{x^2\cdot \left(x^2+2x-1+\frac{2}{x}+\frac{1}{x^2}\right)}}{ \left(x+2+\frac{1}{x}\right)}dx$$
Now Let $ \left(x-\frac{1}{x}\right) = t\;,$ Then $\displaystyle \left(1-\frac{1}{x^2}\right)dx = dt$
So Integral $$\displaystyle = \int\frac{\sqrt{t^2+2t-3}}{t+2}dt  = \frac{t^2+2t-3}{(t+2)\sqrt{t^2+2t-3}}dt = \int\frac{t(t+2)-3}{(t+2)\sqrt{t^2+2t-3}}dt$$
So Integral $$\displaystyle = \underbrace{\int\frac{t}{\sqrt{t^2+2t-3}}dt}_{I} - \underbrace{\int\frac{3}{(t+2)}\cdot \frac{1}{\sqrt{t^2+2t-3}}dt}_{J}..........\color{\red}\checkmark.$$
So $$\displaystyle I = \int\frac{t}{\sqrt{t^2+2t-3}}dt = \int\frac{(t+1)-1}{\sqrt{(t-1)^2-2^2}} = \int\frac{(t-1)}{\sqrt{(t-1)^2-2^2}}-\int\frac{1}{\sqrt{(t-1)^2-2^2}}dt$$
Now Let $(t-1) = z\;\;,$ Then $dt = dz$
So $$\displaystyle I = \int\frac{z}{\sqrt{z^2-2^2}}dz-\int\frac{1}{\sqrt{z^2-2^2}}dz = \sqrt{z^2-4}-\ln \left|(t+1)+\sqrt{t^2+2t-3}\right|$$
Now $$\displaystyle J = 3\int\frac{1}{(t+2)\sqrt{t^2+2t-3}}dt = 3\int\frac{1}{(t+2)\sqrt{(t+2)^2-2(t+2)+1-4}}$$
Now Let $(t+2) = u\;,$ Then $dt = du$ and Integral $$\displaystyle = 3\int\frac{1}{u\sqrt{u^2-2u+1-4}}=3\int\frac{1}{u\sqrt{(u-1)^2-4}}du$$
Now $\displaystyle (u-1) = 2\sec \theta \;, $ Then $du= 2\sec \theta \cdot \tan \theta.$
Now after that You can Solve It. 
