# Is there a trick to solving this definite integral?

1. Sep 3, 2009

### CuppoJava

Hi,
For evaluating the entropy of a gaussian distribution, I need to evaluate this integral:
$$\int^{\infty}_{-\infty}exp(x^2)x^2dx$$
There is no analytical solution for the indefinite integral, but is there a trick for evaluating this particular definite one?

Thanks a lot
-Patrick

2. Sep 3, 2009

### jgens

It looks like that definite integral never converges . . .

3. Sep 4, 2009

### HallsofIvy

As jgens said, that integral does not converge. Since you are talking about a Gaussian distribution I suspect you actually meant
$$\int_{-\infty}^\infty x^2e^{-x^2} dx$$

$e^{-x^2}$ is $\sqrt{2}$ times the Gaussian distribution with mean 0 and standard deviation 1. The square of the standard deviation of any probability density function, f(x), is $\int (x-\mu)^2 f(x)dx$ and, with $\mu= 0$, $\sigma= 1$, as here, $\int x^2f(x)dx= 1$. That is,
$$\frac{1}{\sqrt{2}}\int_{-\infty}^\infty x^2e^{-x^2}dx= 1$$
so
$$\int_{-\infty}^\infty x^2e^{-x^2}dx= \sqrt{2}[/itex] Last edited by a moderator: Sep 4, 2009 4. Sep 4, 2009 ### D H Staff Emeritus You forgot the normalization factor, Halls. The "trick" (not much of a trick) is to integrate by parts using $u=x$, $dv=x\exp(-x^2)\;dx$, from which $du=dx$, $v=-1/2\exp(-x^2)$. Then [tex]\int_{-\infty}^{\infty} x^2\exp(-x^2)\,dx = \left.-\,\frac 1 2 x \exp(-x^2)\right|_{-\infty}^{\infty} \,\,+\quad \frac 1 2 \int_{-\infty}^{\infty} \exp(-x^2)\,dx$$

The first term vanishes at the integration limits. The second term is just half the Gaussian integral. Thus

$$\int_{-\infty}^{\infty} x^2\exp(-x^2)\,dx = \frac{\sqrt \pi}{2}$$

OR one could use Hall's approach and look at this as the expected value of x2 for some normal distribution. The normal distribution is

$$f(x;\mu,\sigma) = \frac 1 {\sigma\sqrt{2\pi}} \exp\left(-\,\frac 1 2 \left(\frac {x-\mu}{\sigma}\right)^2\right)$$

While the given function is not in the form of a Gaussian pdf, it is very close. By inspection, the given function is the Gaussian pdf for a mean of zero and a variance of 1/2, but without the normalization factor:

$$g(x) = \surd{\pi} \,f(x;0,1/\surd 2)$$

Using the fact that the expected value of x2 for a normal distribution is the variance $\sigma^2$,

$$\int_{-\infty}^{\infty} x^2\exp(-x^2)\,dx = \frac{\sqrt \pi}{2}$$

5. Sep 4, 2009

### CuppoJava

Thank you very much for the help. You guys interpreted my mistake correctly. I did mean to have exp(-x^2) not exp(x^2).

The tip on properly using integration by parts helped very much. Thank you DH. I've tried integration by parts, but failed to find the right u and dv to use. Clearly I haven't done enough exercises in Calculus I.

Thanks again
-Patrick

6. Sep 4, 2009

### Mute

For Gaussian integrals like that I like to use the following trick: consider the integral

$$\int_{-\infty}^\infty dx~e^{-\alpha x^2} = \sqrt{\frac{\pi}{\alpha}};$$

any integral of the form

$$\int_{-\infty}^\infty dx~x^{2n} e^{-\alpha x^2}$$

can then be computed by taking derivatives of the first integral with respect to $\alpha$, then at the end of the calculation set $\alpha$ to whatever it actually is in the problem.