How to compute the following integral? $$\int\frac{\sqrt{1+x^2}}{x}dx$$
I tried letting $x=\tan\theta\ $ where $\frac{-\pi}{2} < \theta < \frac{\pi}{2}$ so that $dx = \sec^2\theta\,d\theta$ and after making the substitution one gets to $$\int\frac{\sec^3\theta}{\tan\theta} d\theta$$ which is equivalent to $$\int\frac{1}{\cos^2\theta\sin\theta}d\theta$$
After this, I don't know how to proceed. I tried looking for the same integral elsewhere and I found a solution that involves a method called partial fraction decomposition, I believe. But, I have not been taught that method yet and this integral appears on the section of the book that I am currently working on. 

Add and subtract $\displaystyle{\frac{1}{x}}$ to the integrand:
$$
\begin{aligned}
\int\frac{\sqrt{1+x^2}-1}{x}\,\mathrm{d}x + \int\frac{\mathrm{d}x}{x}&=\ln\left|x\right| + \int \frac{\left(\sqrt{x^2+1}-1\right)\left(\sqrt{x^2 +1}+1\right)}{x\left(\sqrt{x^2 +1}+1\right)}\,\mathrm{d}x \\
&= \ln \left|x \right| + \int\frac{x}{\sqrt{x^2 + 1}+1}\,\mathrm{d}x
\end{aligned}
$$
Now, set $u = 1 + \sqrt{x^2 +1}$ and $x\,\mathrm{d}x = \left(u-1\right)\,\mathrm{d}u$ to obtain
$$
\begin{aligned}
\ln\left|x\right| + \int \frac{u-1}{u}\,\mathrm{d}u &= \ln\left|x\right| + u - \ln\left|u\right| + C_{0}\\
&=u + \ln\left|\frac{x}{u}\right| + C_{0} \\
& = \sqrt{1 + x^2} + \ln\left|\frac{x}{1 + \sqrt{1+x^2}}\right| + \underbrace{1 + C_{0}}_{C} \\
&=\sqrt{1+x^2} + \ln\left|\frac{x}{1+\sqrt{1+x^2}}\right| + C
\end{aligned}
$$
And we are done. :)
