# Three different result for the same indefinite integral

I was killing time solving some indefinite integrals, when I found this one: $$\int\frac{1}{(x+1)\sqrt{x^2+2x}}\ \mathrm{d}x \tag{1}\label{integral}$$ Not a particularly difficult one, I'll post my solution here: $$\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}$$ 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{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{(x+1)^2-1}} + \mathrm{cost} \end{split} \tag{3}\label{calculus2}$$

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}{function}$ and $\color{blue}{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{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}$$

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:

$$\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)}}$$

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.

• on the last one $2\sqrt x \sqrt {x+2} \cdots$ and not $(\sqrt 2\sqrt x \cdots$ and then it will tie out, at least it will for $x\ge0$ all three tie out $x\ge 0$ – Doug M Jun 17 '17 at 0:29

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.

• But if it differs from my antiderivative by a constant one of the two solutions it's not correct... who's right? – opisthofulax Jun 17 '17 at 9:06

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.

• You're saying that dividing the ranges of definition before integrate will change the result? I derivate your result and I got the same starting function that i find if i derive my solution... Are we both right? How's it possible? Of course exists an entire family of antiderivatives, but they're plus a constant, not different functions such as your $\arctan{\left((x+1) + \sqrt{x^2+2x}\right)}$ and $\arctan{(\sqrt{x^2+2x})}$... Am I missing something? – opisthofulax Jun 17 '17 at 9:26
• @opisthofulax Yes. try to integrate $\frac {1}{\sqrt {|x^2-1|}}$. – hamam_Abdallah Jun 17 '17 at 11:23

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$$

• The $\sec^{-1}(x+1)$ function derivative gives me the same solution of Wolfram $$\dfrac{1}{\left(x+1\right)^2\sqrt{1-\frac{1}{\left(x+1\right)^2}}},$$ which is not the starting function... Plus $\sec^{-1}(x+1)$ increases as $x$ approaches -1, which is clear not possible as its derivative (the starting function) goes to $-\infty$ as $x\rightarrow-1^-$... Also there aren't branches in the third quadrant as you can notice by plotting that function. – opisthofulax Jun 17 '17 at 9:15
• That is the starting function for $x\gt0$. For $x\lt-2$, Wolfram is taking the wrong branch of $\sec^{-1}(x+1)$. For $x\lt-2$, $\sec^{-1}(x+1)$ can be in the second or third quadrant. The usual choice is the second quadrant, so if you want to use the usual choice for $\sec^{-1}(x+1)$, you can alter the answer to use $\operatorname{sgn(x+1)}\sec^{-1}(x+1)$. – robjohn Jun 17 '17 at 10:34
• So, basically, it's all matter of notation for the function $\sec^{-1}$? Also, is my result $\arctan{(\sqrt{x^2-2x})}$ right as well as your? If it is, why their graphs differ (even if only for a constant)? Thanks for your attention so much... – opisthofulax Jun 18 '17 at 16:02
• @opisthofulax: indefinite integrals can be known up to an additive constant. This is why we say $\int x\,\mathrm{d}x=\frac12x^2\color{#C00}{+C}$. Since the derivative of any constant is $0$, the antiderivative of $0$ can be any constant. – robjohn Jun 18 '17 at 18:48
• Yes, of course I know, but I was a little bit confused as the two different solutions do not have $\color{red}{+C)$, but look much more different, so actually I said that they differ for a constant only when I looked at the graph solving my doubt without noticing it. Thanks a lot! – opisthofulax Jun 18 '17 at 21:40