# 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. – Sangchul Lee 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,$$

where

$$\Gamma(z) = \int_0^\infty t^{z-1} e^{-t}\,{\rm d}t.$$

-

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}\\

-

Rep 6 from Blogging Hazleton: http://blogginghazleton.blogspot.com $\renewcommand{\d}[1]{\operatorname{d}\!{#1}}$

Here is another example.

$$\int_{-\infty}^{+\infty}\Omega^6e^{-\Omega^2}\d\Omega$$ \begin{align} u&=\Omega^5&\d v&=\Omega e^{-\Omega^2}\\ \d u&=5\Omega^4\d\Omega&v&=-\frac12e^{-\Omega^2} \end{align} \begin{align} \int_{-\infty}^{+\infty}\Omega^6e^{-\Omega^2}\d\Omega&=\Omega^5\left[-\frac12e^{-\Omega^2}\right]_{-\infty}^{+\infty}+\int_{-\infty}^{+\infty}\frac12\cdot5\Omega^4e^{-\Omega^2}\d\Omega\tag{1}\\ &=0+\frac52\frac34\sqrt\pi\tag{2} \end{align} To go from $(1)$ to $(2)$, see Rep 4.

Get more examples here: http://blogginghazleton.blogspot.com

This wasn't my post. Someone else (Sean M. Donahue, I think) posted this, but with clunky images instead of LaTeX, so it got deleted. This is my LaTeX'd version of it. If anyone wants to LaTeX up his other post here — this one — they are more than welcome.

This is a Community Wiki post.

-
A good portion of people but not all will make post a CW when the answer is someone else. For instance, if you see someone answered in the comments, people will convert them to an answer and make it a CW. As a CW, you don't get the rep. – dustin Mar 30 '15 at 22:31
Yes that is correct. I recall voting to delete those post in the review queue. – dustin Mar 30 '15 at 22:33
@dustin He does have a point. Font shouldn't matter too much. – Akiva Weinberger Mar 30 '15 at 22:34
What happens if the server goes down that is hosting the image? The answer is then useless. – dustin Mar 30 '15 at 22:35
@dustin I added stuff to the end of the post. – Akiva Weinberger Mar 30 '15 at 22:37