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.
Solution 1:
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}$$
Solution 2:
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.
Solution 3:
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, $$
where
$$\Gamma(z) = \int_0^\infty t^{z-1} e^{-t}\,{\rm d}t. $$
Solution 4:
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}\\ $$