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. 
 A: The best way would be to start with André Nicolas' substitution.
But I will take it from where you left it. 
So far, I can't see how to avoid partial fraction decomposition (Edit: Now I see, and you got it).
We can rewrite the integrand as follows:
$$
\frac{1}{\cos^2\theta\sin\theta}=\frac{\sin\theta}{\cos^2\theta\sin^2\theta}=\frac{\sin\theta}{\cos^2\theta(1-\cos^2\theta)}
$$
Now we just have to use the substitution $u=\cos\theta$.
This yields the integral of a rational function.
Namely
$$
\int \frac{- du}{u^2(1-u^2)}=\int \frac{du}{u^2(u^2-1)}
$$
After decomposition into partial fractions, one has
$$
\int \left(-\frac{1}{u^2}+\frac{1/2}{u-1}-\frac{1/2}{u+1}\right)du=\frac{1}{u}+\frac{1}{2}\ln \left| \frac{u-1}{u+1}\right| + C
$$
Finally, going back to $x$, we get
$$
\sqrt{x^2+1} + \frac{1}{2}\ln \left| \frac{1-\sqrt{x^2+1}}{1+\sqrt{x^2+1}} \right|+C = \sqrt{x^2+1} + \frac{1}{2}\ln \left( \frac{\sqrt{x^2+1}-1}{\sqrt{x^2+1}+1} \right)+C
$$
A: $x = \tan u$ 
$dx = \sec^2u \,du$
Use the identity $\sec^2u = \tan^2u + 1$
$\sqrt{x^2 + 1 } = \sqrt{\tan^2(u) + 1} = \sqrt{\sec^2u} = \sec u$, $u = \tan^{-1}x$
Set up your integral with appropriate substitutions:
$$\int \csc u \sec^2 u \,du $$ $$= \int (1 + \tan^2 u)\csc u\,du $$ $$= \int \csc u + \tan^2 u \csc u\, du $$ $$= \int \csc u \,du + \int \tan u \sec u \,du $$
You can substitute again...For the integrand $\tan u \sec u$:
Let $t = \sec u, ds = \tan u \sec u$...
A: I solved it, the expression above is equivalent to $$\int\frac {\sec\theta}{\tan\theta}d\theta + \int\sec\theta\tan\theta\ d\theta = \int\csc\theta\ d\theta + \sec\theta + C$$
And we know that $$\int\csc\theta\ d\theta = \ln|\csc\theta - \cot\theta| + C_1$$ After substituting for the original variable, we get $$\ln\left|\frac{\sqrt{1+x^2} - 1}{x}\right| + \sqrt{x^2+1} + C_2$$
A: 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. :)
