# A completely different solution to a common integral

So we all know about the common integral:

$$\int{\frac{dx}{\sqrt{x^2+1}}} = \ln{|x + \sqrt{x^2+1}|} + C$$

Out of boredom I've decided to try and solve the integral to see if I could get the RHS expression. I've started with $$x = \tan{u}$$ and that substitution lead me to the following solution: $$\int{\frac{dx}{\sqrt{x^2+1}}} = \frac{1}{2}\ln{|\frac{1+\sin{(\arctan(x))}}{1 - \sin{(\arctan(x))}}|} +C$$

I wasn't sure whether it's correct so I've typed it up in an online derivative calculator and indeed got the original integral. So I'm wondering how can the solution differ by this much? Or is there a method to convert my expression into the original? If there is such a method then I'm really not seeing it.

There is no difference. Note that $$\sin(\theta)=\frac{\tan(\theta)}{\sqrt{1+\tan^2(\theta)}}.$$ Then, you have $$\theta=\arctan(x)$$ and you get $$\ln\left|\frac{1+\frac{x}{\sqrt{1+x^2}}}{1-\frac{x}{\sqrt{1+x^2}}}\right|$$ and you are done.