I have this indefinite integral , with $a\in \Bbb R, \: a\neq 0$
$$\int \frac{dx}{\sqrt{a^2+x^2}}, \tag 1$$
I solve the integral $(1)$ with $x=at$, and using this approach,
$$\int \frac{dx}{\sqrt{1+x^2}}=\int \frac{dx}{\sqrt{1+x^2}}\cdot \frac{\sqrt{1+x^2}+x}{\sqrt{1+x^2}+x}=\cdots =\int \frac{1+\frac{x}{\sqrt{1+x^2}}}{\sqrt{1+x^2}+x}dx=\ln\lvert \sqrt{1+x^2}+x \rvert+k, \quad k\in\Bbb R \tag 2$$
Is there a fast mode to solve the $(1)$ and the $(2)$?
Hint: Substitute $x= a\tan\theta$ for $(1)$ and $x=\tan \theta$ for $(2)$.