# Evaluating $\int{\frac{1}{\sqrt{x^2+y^2}}\mathrm dx}$

Attempting to calculate $\displaystyle \int{\dfrac{1}{\sqrt{x^2+y^2}}\mathrm dx}$, $$\int{\dfrac{1}{\sqrt{x^2+y^2}}\mathrm dx}=\int{\frac{1}{\sqrt{(y\tan\theta)^2+y^2}}y\sec^2\theta \mathrm d\theta}=\int{\sec\theta d\theta}=\ln(\sec\theta +\tan\theta)=\ln\left(\sqrt{\left(\frac{x}{y}\right)^2+1}+\frac{x}{y}\right)=\ln\left(\frac{1}{x}\left(\sqrt{x^2+y^2}+x\right)\right),$$ where $x=y\tan\theta$

However Wolfram Integrator somehow returns $$\ln\left(2\left(\sqrt{x^2+y^2}+x\right)\right)$$ as the answer. Where did I go wrong? Many thanks.

• For one, you should have factored out a $1/y$ rather than a $1/x$. The factor of two can be wrapped up in an integration constant. Commented Oct 5, 2013 at 12:21
• The only nitpick I have so far is that the coefficient in front of the natural logarithm at the end of your solution should be $\frac{1}{y}$ and not $1/x$. Commented Oct 5, 2013 at 12:21
• I think the wolfram integrator is wrong see wolframalpha.com/input/… Commented Oct 5, 2013 at 12:24
• @Shobhit: It isn't wrong, it just chose a (seemingly arbitrary) specific constant of $\ln(2)$. The only thing I dislike is how both have absorbed the $-\ln(y)$ into the constant. Commented Oct 5, 2013 at 12:27
• In you know $$\int\frac{dx}{\sqrt{x^2+1}} = \operatorname{asinh}(x)+C$$then you can do this integral as $\operatorname{asinh}(x/y)+C$. Commented Aug 20, 2023 at 17:15

## 3 Answers

To find out the reason you only requires some basic knowledge of logarithms. In short, there is only a constant difference between these two logarithms.

Since we are integrating with respect to $$x$$, we regard $$y$$ as constant and therefore $$\ln y$$ is const. Let's add the constant term of indefinite integral: \begin{align} \int\frac1{\sqrt{x^2+y^2}}dx & = \ln\left(\frac1y\left(\sqrt{x^2+y^2}+x\right)\right)+C \\ & = \ln\left(\sqrt{x^2+y^2}+x\right)-\ln y+C \\ & = \ln\left(\sqrt{x^2+y^2}+x\right)+C_0 \\ & = \ln\left(\sqrt{x^2+y^2}+x\right)+\ln 2+C' \\ & = \ln\left(2\left(\sqrt{x^2+y^2}+x\right)\right)+C' \\ \end{align} so the two answers are exactly the same.

Hint: after you fix the mistake in the last step, differentiate the function $$x\mapsto \ln\left(\frac{1}{y}\left(\sqrt{x^2+y^2}+x\right)\right)-\ln\left(2\left(\sqrt{x^2+y^2}+x\right)\right)$$ with respect to $x$. It's easy to do so in your head. Also do not forget that you should consider the absolute value appropriately ($\int \frac 1x\mathrm dx)=\ln (|x|)$) and to add an arbitrary constant when you integrate.

• It's even easier if you expand the right-hand side to see how much cancellation there is and then differentiate :) Commented Oct 5, 2013 at 12:29
• @Clayton That's exactly what I have in mind. Commented Oct 5, 2013 at 12:30
• Ah, I apologize for stating what you already knew. I thought you were implying taking the derivative of the function as it looks was very easy, and I personally didn't want to do that. Commented Oct 5, 2013 at 12:32
• @Clayton I'm glad for your comment. If it wasn't clear to you what I meant, it won't be for other people either. Commented Oct 5, 2013 at 12:32

One alternative approach via $$\sin(ix)=\sinh(x)$$ or $$\sin^{-1}(ix)=i\sinh^{-1}(x)$$ and the known the formula $$\int{\dfrac{1}{\sqrt{a^2-x^2}}\mathrm dx}=\sin^{-1}\frac{x}{a}$$ then if let $$x=it$$ $$\int{\dfrac{1}{\sqrt{x^2+y^2}}\mathrm dx}=i\int{\dfrac{1}{\sqrt{y^2-t^2}}\mathrm dt}=i\sin^{-1}\frac{t}{y}=i\sin^{-1}\left(-i\frac{x}{y}\right)=-i^2\arcsin{\frac{x}{y}}=\arcsin{\frac{x}{y}}$$ where the oddity of $$\sin^{-1}(x)$$ has been used as well.