Evaluate $\int \sqrt{x^2 + a^2}\mathrm{d}x$ I tried using integration by parts and could get to this point:
\begin{align}
\int \sqrt{x^2 + a^2}\mathrm{d}x &= x\sqrt{x^2+a^2} - \int x\frac{2x}{\sqrt{x^2 + a^2}}\mathrm{d}x 
\\\\ &= x\sqrt{x^2+a^2} -2\int \sqrt{x^2 + a^2}\mathrm{d}x + \int \frac{2a^2}{\sqrt{x^2 + a^2}}\mathrm{d}x 
\end{align}
then, I don't know how to get:
$$\int \frac{2a^2}{\sqrt{x^2 + a^2}}\mathrm{d}x$$
 A: You have a little mistake in the integration by parts, $\displaystyle(\sqrt{x^2 + a^2})' = \frac{x}{x^2 + a^2}$ therefore
$$
\int \sqrt{x^2 + a^2}\,dx = x\sqrt{x^2 + a^2} - \int \sqrt{x^2 + a^2}\,dx + a^2\int\frac{1}{\sqrt{x^2 + a^2}}.
$$
The latter integral is simply a can be calculated using the hyperbolic trig substitution or you can recall that $\displaystyle\left(\sinh^{-1}(x)\right)' = \frac{1}{x^2 + 1}$.
A: Those types of integrals usually take advantage of some properties of the hyperbolic sine and cosine functions - $$\sinh t=\frac{e^t-e^{-t}}{2}\\\cosh t=\frac{e^t+e^{-t}}{2}\\(\sinh t)'=\cosh t\\(\cosh t)'=-\sinh t$$ We solve by plugging in $x=a\sinh t$: $$\int\sqrt{x^2+a^2}dx=\int a\sqrt{a^2\sinh^2 t+a^2}\cosh tdt=\int a^2\sqrt{\sinh^2 t+1}\cosh tdt=a^2\int\sqrt{\cosh^2 t}\cosh^2 tdt=a^2\int \cosh^2 tdt$$
Where the last equality is true since $\sinh^2 t+1=\cosh^2 t$. Another identity of the hyperbolic sine and cosine functions is: $$\cosh^2 t=\frac{\cosh 2t+1}{2}$$ So the integral becomes: $$a^2\int \cosh^2 tdt=a^2\int \frac{\cosh 2t+1}{2}dt=\frac{a^2}{2}\left(\frac{\sinh 2t}{2}+t\right)=\frac{a^2}{2}\left(\sinh t\cosh t+t\right)$$
Since $\sinh 2t=2\sinh t\cosh t$.
Finally, plugging $x$ back, we get:
$$x=a\sinh t\Rightarrow \cosh t=\frac{\sqrt{a^2\sinh^2 t+a^2}}{a^2}=\frac{\sqrt{x^2+a^2}}{a^2}$$
And  also:  $$x=a\sinh t\Rightarrow t=\text{arcsinh} \frac{x}{a}$$
Hence: $$\int\sqrt{x^2+a^2}dx=\frac{a^2}{2}\left(\frac{\sqrt{x^2+a^2}}{a^2}+\text{arcsinh} \frac{x}{a}\right)+C$$
A: W.l.o.g. we can assume that $a>0$ (because, otherwise one can replace $a$ with its absolute value)
Setting
$$
x=a\tan(u),
$$
we have
$$
dx=a\sec^2(u)du,
$$
so we get
\begin{eqnarray}
\int\sqrt{x^2+a^2}dx
&=&\int a\sec^2(u)\sqrt{a^2\tan^2(u)+a^2}du\\
&=&\int a\sec^2(u)\sqrt{a^2(1+\tan^2(u))}du\\
&=&\int a\sec^2(u)\sqrt{a^2\sec^2(u)}du\\
&=& a^2\int \sec^3(u)du
\end{eqnarray}
Using integration by parts, we have
\begin{eqnarray}
\int \sec^3(u)du
&=&\int \sec(u)[\tan(u)]’du\\
&=& \sec(u)\tan(u)-\int \tan(u)]\sec(u)]’du\\
&=&\sec(u)\tan(u)-\int\tan(u)\sec(u)\tan(u)du\\
 &=&\sec(u)\tan(u)-\int\sec(u)\tan^2(u)du\\
&=&\sec(u)\tan(u)-\int\sec(u)[\sec^2(u)-1]du\\
&=&\sec(u)\tan(u)+\int\sec(u)du-\int\sec^3(u)du\\
&=&\sec(u)\tan(u)+\ln|\sec(u)+\tan(u)|+2B-\int\sec^3(u)du
\end{eqnarray}
where $B$ is an arbitrary constant. Therefore
$$
\int\sec^3(u)du=\frac12\sec(u)\tan(u)+\frac12\ln|\sec(u)+\tan(u)|+B.
$$
Since
$$
\tan(u)=\frac{x}{a},
$$
we have
$$
\sec(u)=\frac1a\sqrt{x^2+a^2}.
$$
Hence
$$
\int\sqrt{x^2+a^2}dx=\frac12x\sqrt{x^2+a^2}+\frac12a^2\ln|x+\sqrt{x^2+a^2}|+C
$$
where
$$
C=B-\frac12a^2\ln(a).
$$
