<s>[INST] 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.
 [/INST] Consider the integral
\begin{align}
I = \int \sqrt{x^{2}+ a^{2}} \, dx.
\end{align}
Make the substitution $x = a \sinh(t)$, $dx = a \cosh(t) dt$, it is seen that
\begin{align}
I &= a \int \sqrt{ a^{2} (1 + \sinh^{2}(t))} \, \cosh(t) \, dt \\
&= a^{2} \int \sqrt{\cosh^{2}(t)} \cosh(t) \, dt \\
&= a^{2} \int \cosh^{2}(t) \, dt \\
&= \frac{a^{2}}{2} \int (1 + \cosh(2t)) dt \\
&= \frac{a^{2}}{2} \left[ t + \frac{1}{2} \sinh(2t) \right] \\
&= \frac{a^{2}}{2} \left[ t + \sinh(t) \cosh(t) \right].
\end{align}
Now back substitute to obtain
\begin{align}
\int \sqrt{x^{2}+ a^{2}} \, dx &= \frac{a^{2}}{2} \left[ \sinh^{-1}(x/a) + (x/a) \cosh(\sinh^{-1}(x/a)) \right] \\
&= \frac{x}{2} \sqrt{x^{2} + a^{2}} + \frac{a^{2}}{2} \sinh^{-1}\left( \frac{x}{a} \right).
\end{align}
</s>