# How to do integral $\int_{-\infty}^{\infty} x^4 e^{-x^2/2}dx$

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.

-
Here are some possible approaches: 1. Use integration by parts repeatedly, reducing the degree of the polynomial term. 2. Use Gamma function. –  sos440 Mar 12 '13 at 2:59
If I had asked you to solve $\displaystyle\int_{-\infty}^{\infty} \! e^{-x^2 / 2} \, dx$, could you solve it? If not, then you may want to look into the solution of that integral. If so, then you should be able to spam IBP to get your answer. –  meh Mar 12 '13 at 3:00
You might, once and for all, calculate the moment generating function of the standard normal. –  André Nicolas Mar 12 '13 at 3:07

Recall that $$I(a) = \int_{-\infty}^{\infty} e^{-ax^2}dx = \sqrt{\dfrac{\pi}a}$$ $$I'(a) = \int_{-\infty}^{\infty} (-x^2) e^{-ax^2}dx = -\dfrac12 \dfrac{\sqrt{\pi}}{a^{3/2}}$$ $$I''(a) = \int_{-\infty}^{\infty} x^4 e^{-ax^2}dx = \dfrac12 \dfrac32 \dfrac{\sqrt{\pi}}{a^{5/2}}$$ Setting $a=1$, we get $$\int_{-\infty}^{\infty} x^4 e^{-x^2}dx = \dfrac{3\sqrt{\pi}}4$$

From this you get that, in general, $$\int_{-\infty}^{\infty} x^{n} e^{-x^2} dx = \begin{cases} 0 & \text{If } n \text{ is odd.}\\ \dfrac12 \cdot \dfrac32 \cdot \dfrac52 \cdots \dfrac{n-1}{2}\sqrt{\pi} = \dfrac{n! \sqrt{\pi}}{2^n (n/2)!} & \text{If }n \text{ is even.}\end{cases}$$

-

After scaling it suffices to compute $$\int^{\infty}_{-\infty} x^{2n} \exp(-x^2) dx$$ for $n$ even (for even powers the integrand is odd so the integral is zero. To do this, recall that

$$\int^{\infty}_{-\infty} \exp(-zx^2) dx = \sqrt{ \frac{\pi}{z} }$$

and see what repeatedly differentiating both sides with respect to $z$ gives you.

-
The change of variables $y=\frac{x^2}{2}$ transforms the integral in terms of the gamma function
$$\int_{-\infty}^{\infty} x^4 e^{-x^2/2}dx= 2\int_{0}^{\infty} x^4 e^{-x^2/2}dx=2^{\frac{5}{2}}\int_{0}^{\infty} y^{\frac{3}{2}} e^{-y}dx = 2^{\frac{5}{2}}\Gamma\left(\frac{5}{2}\right)=3\sqrt{2}\,\pi,$$
$$\Gamma(z) = \int_0^\infty t^{z-1} e^{-t}\,{\rm d}t.$$