TITLE: How to do integral $\int_{-\infty}^{\infty} x^4 e^{-x^2/2}dx$
QUESTION [17 upvotes]: Can someone show me a simple way to do integral 
$\int_{-\infty}^{\infty} x^4 e^{-x^2/2}dx$?
I am working on something related to the moments of normal distribution and require the evaluation of the above integral. I can get the answer from W/A or Mathematica but I want to learn how to do this manually.

REPLY [2 votes]: I would normally do this as Mhenni did, using the Gamma function, but since he has shown that approach, I thought it might be useful to post a more elementary approach.
We can use integration by parts twice to get
$$
\begin{align}
\int_{-\infty}^\infty x^4e^{-x^2/2}\,\mathrm{d}x
&=-\int_{-\infty}^\infty x^3\,\mathrm{d}e^{-x^2/2}\\
&=\left[\vphantom{\int}-x^3e^{-x^2/2}\right]_{-\infty}^{+\infty}+3\int_{-\infty}^\infty x^2e^{-x^2/2}\,\mathrm{d}x\\
&=-3\int_{-\infty}^\infty x\,\mathrm{d}e^{-x^2/2}\\
&=\left[\vphantom{\int}-3xe^{-x^2/2}\right]_{-\infty}^{+\infty}+3\int_{-\infty}^\infty e^{-x^2/2}\,\mathrm{d}x\\[9pt]
&=3\sqrt{2\pi}
\end{align}
$$
To evaluate the last integral above, we can set
$$
I=\int_{-\infty}^\infty e^{-x^2/2}\,\mathrm{d}x
$$
Then convert from rectangular to polar coordinates
$$
\begin{align}
I^2
&=\int_{-\infty}^\infty\int_{-\infty}^\infty e^{-(x^2+y^2)/2}\,\mathrm{d}x\,\mathrm{d}y\\
&=\int_0^{2\pi}\int_0^\infty e^{-r^2/2}\,r\,\mathrm{d}r\,\mathrm{d}\theta\\
&=-\int_0^{2\pi}\int_0^\infty\,\mathrm{d}e^{-r^2/2}\,\mathrm{d}\theta\\
&=\int_0^{2\pi}1\,\mathrm{d}\theta\\[9pt]
&=2\pi
\end{align}\\
$$