General rule for integrals of irrational functions involving $r = \sqrt{a^2 + x^2}$
If we denote the integral by $$I_k=\int\left(a^2+x^2\right)^{(2k+1)/2}\mathrm{d}x$$ then we can apply integration by parts to get $$\begin{align} I_k &=x\left(a^2+x^2\right)^{(2k+1)/2}-(2k+1)\int x^2\left(a^2+x^2\right)^{(2k-1)/2}\mathrm{d}x\\ &=x\left(a^2+x^2\right)^{(2k+1)/2}-(2k+1)\int \left(a^2+x^2\right)^{(2k+1)/2}-a^2\left(a^2+x^2\right)^{(2k-1)/2}\mathrm{d}x\\ &=x\left(a^2+x^2\right)^{(2k+1)/2}-(2k+1)I_k+a^2(2k+1)I_{k-1}\\ \end{align}$$ Then we have the reduction formula $$I_k=\frac1{2(k+1)}\left(x\left(a^2+x^2\right)^{(2k+1)/2}+a^2(2k+1)I_{k-1}\right)$$ So we then only need the solution to $I_1$ in order to calculate any other $I_k$. In fact it's easier to calculate $I_{-1}$ which is $$I_{-1}=\int\frac{\mathrm{d}x}{\sqrt{a^2+x^2}}=\ln{\left(x+\sqrt{a^2+x^2}\right)}+C=\text{arsinh}\left(\frac{x}a\right)+C$$
Assume $a\ge0$. From $r^2=a^2+x^2$ we obtain $rdr=xdx$. Therefore bu substituting we can write$$\int r^ndx=\int {r^{n+1}dr\over \sqrt{r^2-a^2}}$$Now by defining $r=a\cosh u$ we have$$I{=\int a^{n+1}\cosh^{n+1}udu\\=\left({a\over 2}\right)^{n+1}\int (e^u+e^{-u})^{n+1}du\\=\left({a\over 2}\right)^{n+1}\int \sum_{k=0}^{n+1}\binom{n+1}{k} e^{(2k-n-1)u}du\\=\left({a\over 2}\right)^{n+1}\left[\sum_{k=0\\k\ne {n+1\over 2}}^{n+1}\binom{n+1}{k} {e^{(2k-n-1)u}\over 2k-n-1}+\binom{n+1}{{n+1\over 2}}u\right]}$$also $$r=a\cosh u\iff e^u={r+x\over a}$$which by substituting yields to
$$I=\left({a\over 2}\right)^{n+1}\sum_{k=0\\k\ne {n+1\over 2}}^{n+1}\binom{n+1}{k} {\left({r+x\over a}\right)^{2k-n-1}\over 2k-n-1}+\left({a\over 2}\right)^{n+1}\binom{n+1}{n+1\over 2}\ln {r+x\over a}+C$$