<s>[INST] Comparing $\int \frac{\sqrt{1+x}}{1-x} dx$ with answer from book and sage [Edit: It turns out the answer from my book was incorrect and a later revision of the book has the correct answer:
$$
-2\sqrt{1+x} + \sqrt{2}\ln{\left| \frac{\sqrt{1+x} + \sqrt{2}}{\sqrt{1+x} - \sqrt{2}} \right|} + C \tag{0}
$$
]
I'm trying to integrate this function but I don't understand how my answer is different from my book and different from sage too:
$$
\int \frac{\sqrt{1+x}}{1-x} dx \tag{1}
$$
Substitute $u = 1+x$:
$$
\int \frac{\sqrt{u}}{2-u} du \tag{2}
$$
Substitute $v = \sqrt{u}$:
$$
\int \frac{2v^2}{2-v^2} dv \tag{3}
$$
Use partial fractions:
$$
\int -2 dv + \int \frac{\sqrt{2}}{\sqrt{2}+v} dv + \int \frac{\sqrt{2}}{\sqrt{2}-v} dv \tag{4}
$$
Integrate with v:
$$
-2v + \sqrt{2} \ln{\left| \frac{\sqrt{2} + v}{\sqrt{2} - v} \right|} + C \tag{5}
$$
Replace $v$ with $u$:
$$
-2\sqrt{u} + \sqrt{2} \ln{\left| \frac{\sqrt{2} + \sqrt{u}}{\sqrt{2} - \sqrt{u}} \right|} + C \tag{6}
$$
Replace $u$ with $x$:
$$
-2\sqrt{1+x} + \sqrt{2} \ln{\left| \frac{\sqrt{2} + \sqrt{1+x}}{\sqrt{2} - \sqrt{1+x}} \right|} + C \tag{7}
$$
The answer in my book is:
$$
-2\sqrt{1+x} + 2\sqrt{2}\ln{\left| \frac{\sqrt{1+x} + 2}{1-x} \right|} + C \tag{8}
$$
But I don't understand how to get that numerator when I multiply by the conjugate of the denominator, I get:
$$
-2\sqrt{1+x} + \sqrt{2} \ln{\left| \frac{x + 2\sqrt{2}\sqrt{1+x} + 3}{1-x} \right|} + C \tag{9}
$$
The answer in sage is (latex(simplify(integral(sqrt(1+x)/(1-x))))):
$$
- 2 \, \sqrt{x + 1} -\sqrt{2} \log\left(-\frac{\sqrt{2} - \sqrt{x + 1}}{\sqrt{2} + \sqrt{x + 1}}\right) + C \tag{10}
$$
But I don't understand how to get that negative in the log, however I do understand how the negative of the log should simply inverse the numerator and denominator.
So, I would very much appreciate if someone could shed some light on what I don't understand both from my book, which might be incorrect, and from sage, which is less likely to be incorrect :)
Thank you!
 [/INST] setting $u= \sqrt {1+x}$ so we get
$x=u^2-1$ and $dx=2udu$ and our integral will be $$\int\frac {2u^2}{2-u^2}du$$ and is easy to solve the right result is $$-2\,\sqrt {1+x}+2\,\sqrt {2}{\rm arctanh} \left(1/2\,\sqrt {1+x}\sqrt 
{2}\right)
$$
</s>