# Is there a formula for this gaussian integral

1. Apr 28, 2014

### skate_nerd

Is there a formula for this gaussian integral:

$$int_{-\infty}^{\infty}{x^4}{e^{-a(x-b)^2}}dx$$

I've tried wikipedia and they only have formulas for the integrand with only x*e^... not x^4e^...
Wolframalpha won't do it either, because I actually have an integral that looks just like that, unknown constants and all.

2. Apr 28, 2014

### Matterwave

Well, we know that:

$$\int_{-\infty}^\infty e^{-bx^2}dx=\sqrt{\frac{\pi}{b}}$$

Taking some derivatives:

$$\frac{d^2}{db^2}\int_{-\infty}^\infty e^{-bx^2}dx=\int_{-\infty}^{\infty}x^4e^{-bx^2}dx=\frac{3}{4}\frac{\sqrt{\pi}}{b^{5/2}}$$

I'm not sure if you can use this for your integral, but it looks possible.

3. Apr 28, 2014

### skate_nerd

Sorry, but you can't :/

4. Apr 28, 2014

### vanhees71

5. Apr 28, 2014

### pwsnafu

You are basically just asking for the moments of the normal distribution. These are well known:
$$\int_{-\infty}^{\infty} \frac{x^p}{\sigma \sqrt{2\pi}} e^{-(x-\mu)^2 / (2 \sigma^2)} dx= \sigma^p (p-1)!$$
when p is even, and zero when p is odd.

So $p=4$, $\sigma = \frac{1}{\sqrt{2a}}$ and $\mu = b$, which gives $\frac{3\sqrt{\pi}}{4 a^{5/2}}$ as Matterwave gave.

6. Apr 28, 2014

### skate_nerd

I'm sorry i just dont think that's correct. Try wolframalpha. I know the formulas for the x, x^2, x^3 cases, but not the x^4. But everything up to x^3 agrees with wolframalpha's output, and this formula you guys are giving doesnt look very similar and does not agree.
$$\int_{-\infty}^{\infty}{x}e^{-a(x-b)^2}dx=b\sqrt{\frac{\pi}{a}}$$
$$\int_{-\infty}^{\infty}{x^2}e^{-a(x-b)^2}dx=(\frac{1}{2a}+b^2)\sqrt{\frac{\pi}{a}}$$
$$\int_{-\infty}^{\infty}{x^3}e^{-a(x-b)^2}dx=(\frac{3b}{2a}+b^3)\sqrt{\frac{\pi}{a}}$$
There's a pattern here but I can't figure it out.

7. Apr 28, 2014

### pwsnafu

I'm an idiot, I looked up the central moments (and even that's wrong because it should be $(p-1)!!$). The non-central moments are

$\mu$
$\mu^2+\sigma^2$
$\mu^3+3\mu\sigma^2$
$\mu^4+6\mu^2\sigma^2+3\sigma^4$,
for p = 1, 2, 3, and 4. Those should agree with what you have.

8. Apr 28, 2014

### skate_nerd

Ahhh thank you thank you thank you! That works 100%! Man I've been trying to get this formula for a week...I really appreciate it.

9. Apr 28, 2014

### eigenperson

The "freshman calculus" way to do this is to integrate by parts:
$$u = x^3 \qquad dv = xe^{-x^2}\,dx$$so that
$$du = 3x^2 \qquad v = -{1 \over 2}e^{-x^2}$$and now the degree of the polynomial has been reduced by 2.

Now, that is for the case where a and b are 0, but the other cases are really the same. You just have to change variables; then you will have a more complicated polynomial in place of $x^4$, but once you know how to do $\int x^{2k}e^{-x^2}$ you can integrate any polynomial times $e^{-x^2}$.

10. Apr 28, 2014

### Matterwave

Another clever way to do this integral is to look at the characteristic function for a Gaussian distribution:

$$C(t)\equiv\left<e^{itx}\right>=\frac{1}{\sigma\sqrt{2\pi}} \int_{-\infty}^{\infty}e^{itx}e^{-(x-\mu)^2/2\sigma^2}$$

You can do this integral by completing the square in the exponential, or by just looking it up. You will find:

$$C(t)=e^{it\mu-\frac{1}{2}t^2\sigma^2}$$

You can expand this function in powers of t, and match it to the expansion of:

$$\left<e^{itx}\right>\approx 1+\left<itx\right>+\frac{\left<(itx)^2\right>}{2}+...$$

If you match the powers of t on both sides, you can get all the general moments of the Gaussian distribution. You can get all the odd ones too, for which the formula I gave earlier would no longer work. This Characteristic function is closely related to the moment generating function, but I'm more familiar with working with these.