Evaluating an indefinite integral $\int\sqrt {x^2 + a^2} dx$ indefinite integral $$\int\sqrt {x^2 + a^2} dx$$
After some transformations and different substitution, I got stuck at this
$$a^2\ln|x+(x^2+a^2)| + \int\sec\theta\tan^2\theta d\theta$$
I am not sure I am getting the first step correct. Tried substituting $ x=a\tan \theta$ but that doesn't help either.

Let $x=a\tan\theta$, so $dx=a\sec^{2}\theta d\theta$ to get
$\int\sqrt{x^2+a^2}\;dx=a^2\int\sec^{3}\theta\;d\theta$.  Using integration by parts with $u=\sec\theta$ and $dv=\sec^{2}\theta\;d\theta$ gives
$\hspace{.6 in}\sec^{3}\theta\;d\theta=\frac{1}{2}\left(\sec\theta\tan\theta+\ln|\sec\theta+\tan\theta|\right)+C$,
so $\int\sqrt{x^2+a^2}=\frac{a^2}{2}\left(\frac{\sqrt{x^2+a^2}}{a}\frac{x}{a}+\ln\left|\frac{\sqrt{x^2+a^2}}{a}+\frac{x}{a}\right|\right)+C$
$\hspace{.9 in}=\frac{1}{2}\left({x\sqrt{x^2+a^2}}+a^2\ln\left(\sqrt{x^2+a^2}+x\right)\right)+C$
