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.
 A: 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$.
A: Let us consider the integral $$\int\tan^2x\sec^3xdx=I.$$ Then using the identity $1+\tan^2x=\sec^2x,$ this becomes $$\int\sec^5xdx-\int\sec^3xdx.$$
Then integrating by parts, we find that $$\int\sec^5xdx=\sec^3x\tan x-3I.$$ Also we find that $$\int\sec^3xdx=\sec x\tan x-\int\sec^3xdx+\int\sec xdx.$$ Since $$\int\sec xdx=\log|\sec x+\tan x|+c,$$ we can easily find $$\int\sec^3xdx.$$
Finally, we get that $$4I=\sec^3x\tan x-\frac 12\left(\sec x\tan x+\log|\sec x+\tan x|\right)+C.$$
A: Another way to proceed with the original integral is to use the substitution $x=a\sinh y,$ so that the integral now is $$a^4\int \sinh^2y\cosh^2y dy=\frac{a^4}{4}\int\sinh^22y dy=\frac{a^4}{8}\int(1-\cosh 4y)dy=\frac{a^4}{8}\left(y-\frac14\sinh 4y\right)+k,$$ for some constant $k.$ Reverting the substitution now gives $$\frac{a^4}{8}\left[\log\left(\frac x a+\sqrt{\frac{x^2}{a^2}+1}\right)-\frac x a\left(1+\frac{x^2}{a^2}\right)-\frac{x^3}{a^3}\sqrt{1+\frac{x^2}{a^2}}\right]+C,$$ for some constant $C.$
A: $$\int x^2\sqrt{a^2+x^2}dx\\
x=a\sinh{(y)}\Rightarrow dx=a\cosh{(y)}dy\\
\int x^2\sqrt{a^2+x^2}dx=\frac{a^{4}}{4}\int\sinh^{2}{(2y)}dy=\frac{a^{4}}{4}\int\frac{\cosh{(4y)-1}}{2}dy\\
=\frac{a^{4}}{32}\sinh{(4y)}-\frac{a^{4}}{8}\sinh^{-1}(\frac{x}{a})\\$$
