Integrate with square root in square $\int \left(1 + \sqrt{\frac{x-1}{x+1}}\right)^2 dx$
How would you attack this? I've tried variable substitution with $t = \sqrt{\frac{x-1}{x+1}}$
 A: OK
$$
t = \sqrt{\frac{x-1}{x+1}} \\
x = \frac{1+t^2}{1-t^2} \\
dx = \frac{4t}{(1-t^2)^2}\;dt = \frac{4t}{(1-t)^2(1+t)^2}\;dt \\
\int\left(1+\sqrt{\frac{x-1}{x+1}}\right)^2 dx =
\int (1+t)^2\frac{4t}{(1-t)^2(1+t)^2}\;dt
= \int \frac{4t}{(1-t)^2}\;dt \\
\qquad = \int\left(\frac{4}{t-1} + \frac{4}{(t-1)^2}\right) dt
= 4\log(t-1) - \frac{4}{t-1} +C
$$
and substitute back to get the answer in terms of $x$.
A: Expand the square
$$\int {\left( {1 + \frac{{x - 1}}{{x + 1}}} \right)dx + 2\int {\sqrt {\frac{{x - 1}}{{x + 1}}} } } dx$$
Rearrange the first integral and collect $2$
$$2\left[ {\int {\left( {1 - \frac{1}{{x + 1}}} \right)} \;dx + \int {\sqrt {\frac{{x - 1}}{{x + 1}}} dx} } \right]$$
First integral is easy; for the second substitute $\dfrac{x-1}{x+1}=t$ 
Solve for $x$ and substitute
$$x = \frac{{t + 1}}{{1 - t}};\quad dx = \frac{{2\,dt}}{{{{\left( {t - 1} \right)}^2}}}$$
$$\int {\sqrt {\frac{{x - 1}}{{x + 1}}} \,dx}  = \int {\frac{{2\sqrt t }}{{{{\left( {t - 1} \right)}^2}}}} \;dt$$
Substitute again $u=\sqrt{t};\;t=u^2;\;dt=2u\,du$
$$\int {\frac{{2u \cdot 2u\,du}}{{{{\left( {{u^2} - 1} \right)}^2}}}}  = \int {\frac{{4{u^2}\,du}}{{{{\left( {{u^2} - 1} \right)}^2}}}} $$
use partial fraction to get
$$\frac{{4{u^2}}}{{{{\left( {{u^2} - 1} \right)}^2}}} = \frac{1}{{{{\left( {u + 1} \right)}^2}}} + \frac{1}{{{{\left( {u - 1} \right)}^2}}} + \frac{1}{{u - 1}} - \frac{1}{{u + 1}}$$
and integrate
$$\int {\frac{{4{u^2}}}{{{{\left( {{u^2} - 1} \right)}^2}}}} \,du = \int {\frac{{du}}{{{{\left( {u + 1} \right)}^2}}}}  + \int {\frac{{du}}{{{{\left( {u - 1} \right)}^2}}}}  + \int {\frac{{du}}{{u - 1}}}  - \int {\frac{{du}}{{u + 1}}} $$
$$ - \frac{1}{{u + 1}} + \frac{1}{{1 - u}} + \ln \left( {u - 1} \right) - \ln \left( {u + 1} \right) + C=$$
$$=\frac{{2u}}{{1 - {u^2}}} + \ln \frac{{u - 1}}{{u + 1}} + C = \frac{{2u}}{{1 - {u^2}}} + \ln \left( {1 - \frac{2}{{u + 1}}} \right) + C=$$
$$=\frac{{2\sqrt {\frac{{x - 1}}{{x + 1}}} }}{{1 - \frac{{x - 1}}{{x + 1}}}} + \ln \frac{{\sqrt {\frac{{x - 1}}{{x + 1}}}  - 1}}{{\sqrt {\frac{{x - 1}}{{x + 1}}}  + 1}} + C$$
Simplified result should be
$$2\left( {x+\ln \left( {\sqrt {\frac{{x - 1}}{{x + 1}}}  - \frac{x}{{x + 1}}} \right) + \left( {x + 1} \right)\sqrt {\frac{{x - 1}}{{x + 1}}} } \right) + C$$
