<s>[INST] How do you prove that $\int \frac{1}{\sqrt{x^2+r^2}} \,dx = \ln{\left\lvert x + \sqrt{x^2+r^2} \right\rvert + C}$? I would like to prove that
$$\int \frac{1}{\sqrt{x^2+r^2}} \,dx = \ln{\left\lvert x + \sqrt{x^2+r^2} \right\rvert} + C$$
I tried with applying derivative with respect to $x$ to $\ln{\left\lvert x + \sqrt{x^2+r^2}\right\rvert}$ and show it is equal to $\frac{1}{\sqrt{x^2+r^2}}$, but I ended up with $$ \frac{d}{dx} \ln{\left\lvert x + \sqrt{x^2+r^2}\right\rvert} = \dots = \frac{1}{x + \sqrt{x^2+r^2}}\left(1+\frac{1}{\sqrt{x^2+r^2}}\right)$$ and I do not see how it can be simplified to $\frac{1}{\sqrt{x^2+r^2}}$.
Any help would be appreciated (even involving complex calculus, if needed).
 [/INST] HINT
What about the substitution $x = r\sinh(u)$? In such case, one has that
\begin{align*}
\int\frac{1}{\sqrt{x^{2}+r^{2}}}\mathrm{d}x & = \int\frac{r\cosh(u)}{\sqrt{r^{2}\sinh^{2}(u) + r^{2}}}\mathrm{d}u = \int1\mathrm{d}u = u + c
\end{align*}
Can you take it from here?
EDIT
Since the $\sinh$ function is bijective, there is always a solution to
\begin{align*}
z = \sinh(w) = \frac{e^{w} - e^{-w}}{2} & \Longleftrightarrow (e^{w})^{2}  - 2ze^{w} - 1 = 0\\\\
& \Longleftrightarrow e^{w} = \frac{2z + 2\sqrt{z^{2}+1}}{2}\\\\
& \Longleftrightarrow w = \ln(z + \sqrt{z^{2}+1})
\end{align*}
At your case, we have that
\begin{align*}
\int\frac{\mathrm{d}x}{\sqrt{x^{2}+r^{2}}} = \sinh^{-1}\left(\frac{x}{r}\right) + c = \ln\left(\frac{x + \sqrt{x^{2} + r^{2}}}{r}\right) + c = \ln\left(x + \sqrt{x^{2} + r^{2}}\right) + C
\end{align*}
and we are done.
Hopefully this helps!
</s>