<s>[INST] Help with inverse trigonometric substitutions $ \int x^2\sqrt{a^2+x^2}\,dx $. how would I go about integrating this? It is a lecture exercise.
$$
\int x^2\sqrt{a^2+x^2}\,dx
$$
I used a substitution of $x=a\tan\theta$ and ended up with $$\int a^4\tan^2\theta \sec^3\theta \,d\theta.$$ I was thinking by parts but then I would have to integrate a $\ln|\sec\theta+\tan\theta|$. Can't seem to think of the appropriate identity to collapse it. I am given the answer to verify but I don't know any mental algorithms to even begin doing inverse trigonometric substitution. The answer given is:
$$
\frac{x}{8}(a^2+2x^2)\sqrt{a^2+x^2}-\frac{a^2}{8}\ln\left(x+\sqrt{a^2+x^2}\right)
$$
Also, what are some things I should be thinking about first when looking at such questions when I need to substitute trigonometric functions into the x-variable? Should I attempt to make odd powers into even? How do I do so?
Thank you very much for your help.
 [/INST] Integrate by parts directly without substitutions
\begin{align}
\int x^2\sqrt{a^2+x^2}dx
= &\frac14 \int \frac x{\sqrt{a^2+x^2}}d[(a^2+x^2)^2]\\
= &\frac14 x{(a^2+x^2)^{3/2}}- \frac{a^2}4\int \frac{\sqrt{a^2+x^2}}{2x}d(x^2)\\
 =& \frac14 x{(a^2+x^2)^{3/2}}- \frac{a^2}8x{\sqrt{a^2+x^2}}-\frac{a^4}8\int \frac{dx}{\sqrt{a^2+x^2}}\\
\end{align}
where $\int \frac{dx}{\sqrt{a^2+x^2}}= \sinh^{-1}\frac xa$.
</s>