Dealing with absolute values after trigonometric substitution in $\int \frac{\sqrt{1+x^2}}{x} \text{ d}x$. I was doing this integral and wondered if the signum function would be a viable method for approaching such an integral. I can't seem to find any other way to help integrate the $|\sec \theta|$ term in the numerator of the integrand.
$$ \begin{aligned} \int \dfrac{\sqrt{x^2 + 1}}{x} \text{ d}x \ \ & \overset{x=\tan \theta}= \int \dfrac{\sqrt{\sec^2 \theta} \sec^2 \theta}{\tan \theta} \text{ d}\theta \\ & \ \ = \int \dfrac{|\sec \theta| \sec^2 \theta}{\tan \theta} \text{ d}\theta \\ & \ \ = \int \dfrac{\text{sgn} (\sec \theta) \sec^3 \theta}{\tan \theta} \text{ d}\theta \\ & \ \ = \text{sgn} (\sqrt{1+x^2}) \left( - \log \left| \dfrac{\sqrt{1+x^2} + 1}{x} \right| + \sqrt{1+x^2} \right) + \mathcal{C} \end{aligned} $$
It's clear that $\text{sgn} (\sqrt{1+x^2}) = 1$ since the sign of the argument of that function is always positive and the signum function extracts the sign. So I'd leave the integral as: $$ \begin{aligned} \int \dfrac{\sqrt{x^2 + 1}}{x} \text{ d}x = \log \left| x \right| - \log \left( \sqrt{1+x^2} + 1 \right) + \sqrt{1+x^2} + \mathcal{C} \end{aligned} $$
Would that be ok?
Also, apparently Wolfram has suggested that my final result should have $x$ as opposed to $|x|$ in the argument of the first logarithm. Why is that?
Any help would be greatly appreciated!

I want to share with you my method using rationalization. $$
\begin{aligned}
& \int \frac{\sqrt{x^{2}+1}}{x} d x \\
=& \int \frac{x^{2}+1}{x \sqrt{x^{2}+1}} d x \\
=& \int \frac{x^{2}+1}{x^{2}} d\left(\sqrt{x^{2}+1}\right) \\
=& \int\left(1+\frac{1}{x^{2}}\right) d\left(\sqrt{x^{2}+1}\right) \\
=& \int 1 d\left(\sqrt{x^{2}+1}\right)+\int \frac{1}{\left(\sqrt{x^{2}+1}\right)^{2}-1} d\left(\sqrt{x^{2}+1}\right) \\
=& \sqrt{x^{2}+1}+\frac{1}{2} \ln \left|\frac{\sqrt{x^{2}+1}-1}{\sqrt{x^{2}+1}+1}\right|+C
\end{aligned}
$$
Wish you enjoy the solution!
