Three different result for the same indefinite integral I was killing time solving some indefinite integrals, when I found this one:
\begin{equation}
  \int\frac{1}{(x+1)\sqrt{x^2+2x}}\ \mathrm{d}x
  \tag{1}\label{integral}
\end{equation}
Not a particularly difficult one, I'll post my solution here:
\begin{equation}
  \begin{split}
  \int\frac{1}{(x+1)\sqrt{x^2+2x}}\ \mathrm{d}x = \int\frac{1}{(x+1)\sqrt{(x+1)^2-1}}\ \mathrm{d}x
  \end{split}
\tag{2}\label{calculus}
\end{equation}
by substituting $t = x+1$, d$t = \mathrm{d}x$, and then $s = \sqrt{t^2-1} \rightarrow \mathrm{d}s = \frac{t}{\sqrt{t^2-1}}\mathrm{d}t$
\begin{equation}
  \begin{split}
   = \int\frac{1}{t\sqrt{t^2-1}}\ \mathrm{d}t &= \int\frac{1}{(x+1)\sqrt{(x+1)^2-1}}\ \mathrm{d}x =\\
  &= \int\frac{\mathrm{d}s}{1+s^2} =\\
  &= \arctan{s} + \mathrm{cost}\\
  &= \arctan{\sqrt{t^2-1}} + \mathrm{cost}\\
  &= \arctan{\sqrt{\left(x+1\right)^2-1}} + \mathrm{cost}
  \end{split}
\tag{3}\label{calculus2}
\end{equation}
I then derived (I recommend, if you wanna check my results to use this online derivative calculator which actually shows steps...) my solution finding the starting function:
$$\frac{\mathrm{d}}{\mathrm{d}x}(\arctan{\sqrt{(x+1)^2-1}} + \mathrm{cost}) = \frac{1}{(x+1)\sqrt{x^2+2x}}$$
The graph (plotted with Grapher from Mac Os X), with $\color{red}{\text{function}}$ and $\color{blue}{\text{integral}}$ :

Now this integral comes from the exercise book Problems in Mathematical Analysis by Boris Demidovich and it's the number 1271, and even if I'm pretty sure this mine is the correct solution I lost quite time to understand the proposed solution of the book, which, if you don't have it and you can't check for yourself, is
1271. $\qquad-\arcsin(\frac{1}{1+x})$
deriving this function you'll find:
\begin{equation}
  \begin{split}
   \frac{\mathrm{d}}{\mathrm{d}x}&\left[-\arcsin(\frac{1}{1+x})\right] =\\
  &= \dfrac{1}{\left(x+1\right)^2\sqrt{1-\frac{1}{\left(x+1\right)^2}}}\\
  &= \dfrac{1}{\frac{\left(x+1\right)^2}{\sqrt{(x+1)^2}}\sqrt{\left(x+1\right)^2-1}}\\
 &= \dfrac{1}{\frac{\left(x+1\right)^2}{|x+1|}\sqrt{\left(x+1\right)^2-1}}\\
 &= \dfrac{1}{{\left(x+1\right)}\mathrm{sgn}(x+1)\sqrt{\left(x+1\right)^2-1}}\\
  \end{split}
\tag{4}\label{calculus3}
\end{equation}
Plotting the result will give you an idea about the mistakte he could have done, in cyan the $\color{cyan}{Demidovich's~~primitive}$:

So I was pretty sure I was right and he was not, so I tried integrate the \eqref{integral} with Mathematica, with another unsatisfying outcome:
\begin{equation}
  \int\frac{1}{(x+1)\sqrt{x^2+2x}}\ \mathrm{d}x = \frac{\sqrt{2}\sqrt{x}\sqrt{x+2}\arctan(\sqrt{\frac{x}{x+2}})}{\sqrt{x(x+2)}}
\end{equation}
This solution, in $\color{orange}{orange}$, is almost like mine, even if it does not comprehend the negative values of the function...

Also, if I try to derive (I've done it with calculator, as it's quite long to do for yourself...) you get
$$\left(\frac{\sqrt{2}\sqrt{x}\sqrt{x+2}\arctan(\sqrt{\frac{x}{x+2}})}{\sqrt{x(x+2)}}\right)' = $$
$$-\dfrac{\left(\sqrt{x+2}\left(-x^\frac{7}{2}-3x^\frac{5}{2}-2x^\frac{3}{2}\right)+\left(x+2\right)^\frac{3}{2}\left(x^\frac{5}{2}+x^\frac{3}{2}\right)\right)\arctan\left(\frac{\sqrt{x}}{\sqrt{x+2}}\right)-x^3-4x^2-4x}{\left(x\left(x+2\right)\right)^\frac{3}{2}\left(x^2+3x+2\right)}$$
Now, since I've found that in my range of definition $x^2-2x>0$ the primitive function that i found, derived, gives me the starting function, this should tell me that I am right and others (computer, this case) have bugs or they encounter problems deriving such a function. So which of the three solution $\color{blue}{mine}$, $\color{orange}{Mathematica's}$ or $\color{cyan}{Demidovich's}$ is the correct one? Why are them wrong, if they are? Does it depend on calculator's bug or it's my problem?
Thanks for attention.
 A: The expression provided by Mathematica simplifies in the case where $x < -2$ or $x > 0$:
FullSimplify[Integrate[1/((x + 1) Sqrt[x^2 + 2 x]), x], x^2 + 2 x > 0]

gives $$2 \tan^{-1} \sqrt{\frac{x}{x+2}}.$$  This is equivalent to your antiderivative on $x > 0$, and differs from your antiderivative by a constant factor on $x < -2$.  Therefore, they are equivalent.  What is clearly wrong is the "Demidovich" solution for $x < -2$:  the antiderivative cannot be increasing when $x$ is negative.
A: Noting that $\sqrt{x^2+2x}=\sqrt{(x+1)^2-1}$, it seem sensible to try $x+1=\sec(u)$:
$$
\begin{align}
\int\frac1{(x+1)\sqrt{x^2+2x}}\,\mathrm{d}x
&=\int\frac1{\sec(u)\tan(u)}\sec(u)\tan(u)\,\mathrm{d}u\\
&=u+C\\[8pt]
&=\sec^{-1}(x+1)+C
\end{align}
$$
Of course, the branch of $\sec^{-1}$ needs to be chosen to be in the third quadrant when its argument is negative (since $\sec(u)=x+1\le0$ and  $\tan(u)=\sqrt{x^2+2x}\ge0$). If we want to use the standard choice for $\sec^{-1}$ for negative arguments, we can alter the answer to be
$$
\int\frac1{(x+1)\sqrt{x^2+2x}}\,\mathrm{d}x=\operatorname{sgn}(x+1)\sec^{-1}(x+1)+C
$$
A: The primitives exist at $(-\infty,-2)$, and $(0,+\infty) $.

at $(0,+\infty) $ we put

$$x+1=\cosh (t) $$ 
the integral becomes
$$I=\int \frac {\sinh (t)dt}{\cosh (t)\sinh (t)} $$
$$=\int \frac {2e^t}{1+e^{2t}} $$
$$=2\arctan(e^t)+C $$
with
$$e^{2t}-2 (x+1)e^t+1=0$$
$$t=\ln ((x+1)+\sqrt {x^2+2x})$$
thus

$$I=2\arctan((x+1)+\sqrt {x^2+2x})+C $$

At $(-\infty,-2) $
we put $x+1=-\cosh (t) $.
You can finish.
