Most direct way of calculating $\int_0^B \frac{x^2 dx}{\sqrt{x^2 +A}}$? What's the optimal way of calculating this integral?
$$\int_0^B \frac{x^2 dx}{\sqrt{x^2 +A}}, \quad A,B>0$$
I tried the substitution$$\frac{x}{\sqrt{A}} = \sinh t,$$
but this leads to an integral of the form $$\int_0^{t_0} \frac{dt}{\cosh t}$$ which requires more hassle. I also tried writing the original integral as
$$2\frac{\partial}{\partial A} \int_0^B dx \ x^2\sqrt{x^2 +A}$$
and then the hyperbolic substitution, but that leads to
$$\int_0^{t_0}  dt \sinh^2 t \cosh^2 t.$$
All of this is of course doable, but is there a more elegant solution?

There are three ways that come to mind for me.

The first is trig sub.  This may be ideal if $A$ and $B$ are numbers that "play nicely" with trig sub.  For example, if $A = 4$ and $B = \pi/3$, then we could make the substitution $x = 2\tan\theta$, so that $dx = 2\sec^2\theta \, d\theta$ and the new limits of integration are $\theta = 0$ to $\theta = \sqrt3$, and we have
$$
  \int_0^{\pi/3} \frac{x^2}{\sqrt{x^2+4}} \, dx = \int_0^{\sqrt3} \frac{4\tan^2\theta}{\sqrt{4\tan^2\theta + 4}} 2\sec^2\theta \, d\theta = \int_0^{\sqrt3} 4\tan^2\theta \sec\theta \, d\theta.
$$
Ok, maybe that last integral isn't so pleasant, but trig sub is still one approach.

Another possibility is to use the Euler substitution $\sqrt{x^2+A} = -x + t$, which gives us $x = \dfrac{t^2-A}{2t}$ and so $dx = \dfrac{t^2+A}{2t^2} \, dt$.  Also, the new limits of integration are $t = \sqrt A$ to $t = B + \sqrt{B^2 + A}$.  Then we have
\begin{align*}
\int_0^B \frac{x^2}{\sqrt{x^2+A}} \, dx &= \int\limits_{\sqrt A}^{B + \sqrt{A+B^2}} \left(\frac{t^2-A}{2t}\right)^2 \cdot \frac1{t-\frac{t^2-A}{2t}} \cdot \frac{t^2+A}{2t} \, dt\\[0.3cm]
    &= \int\limits_{\sqrt A}^{B + \sqrt{A+B^2}} \frac{t^4 - 2At^2 + A^2}{4t^2} \, dt
\end{align*}
This last integral is trivial, albeit messy, after splitting the integrand into three separate terms.

Another way is to use this incredibly helpful trick:
\begin{align*}
\int_0^B \frac{x^2}{\sqrt{x^2+A}} \, dx &= \int_0^B \frac{x^2 \color{red}{+A-A}}{\sqrt{x^2+A}} \, dx\\[0.3cm]
  &= \int_0^B \frac{x^2+A}{\sqrt{x^2+A}} \, dx - \int_0^B \frac A{\sqrt{x^2+A}} \, dx\\[0.3cm]
  &= \int_0^B\sqrt{x^2+A} \, dx - \int_0^B \frac A{\sqrt{x^2+A}} \, dx
\end{align*}
The first integral in that last line can be done by parts with $u = \sqrt{x^2+A}$ or you can check a table of integration formulas.  The second integral can be done with the trig sub $x = \sqrt A \tan\theta$ or you can check a table of integration formulas for it as well.  There may be another way to calculate that second integral without trig sub but I can't look into it now.
