Is there a trick to solving this definite integral?

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
5 replies · 7K views
CuppoJava
Messages
23
Reaction score
0
Hi,
For evaluating the entropy of a gaussian distribution, I need to evaluate this integral:
[tex]\int^{\infty}_{-\infty}exp(x^2)x^2dx[/tex]
There is no analytical solution for the indefinite integral, but is there a trick for evaluating this particular definite one?

Thanks a lot
-Patrick
 
Physics news on Phys.org
It looks like that definite integral never converges . . .
 
As jgens said, that integral does not converge. Since you are talking about a Gaussian distribution I suspect you actually meant
[tex]\int_{-\infty}^\infty x^2e^{-x^2} dx[/tex]

[itex]e^{-x^2}[/itex] is [itex]\sqrt{2}[/itex] 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 [itex]\int (x-\mu)^2 f(x)dx[/itex] and, with [itex]\mu= 0[/itex], [itex]\sigma= 1[/itex], as here, [itex]\int x^2f(x)dx= 1[/itex]. That is,
[tex]\frac{1}{\sqrt{2}}\int_{-\infty}^\infty x^2e^{-x^2}dx= 1[/tex]
so
[tex]\int_{-\infty}^\infty x^2e^{-x^2}dx= \sqrt{2}[/itex][/tex]
 
Last edited by a moderator:
HallsofIvy said:
[itex]e^{-x^2}[/itex] is [itex]\sqrt{2}[/itex] times the Gaussian distribution with mean 0 and standard deviation 1. ... so
[tex]\int_{-\infty}^\infty x^2e^{-x^2}dx= \sqrt{2}[/itex][/tex]
[tex] You forgot the normalization factor, Halls.<br /> <br /> The "trick" (not much of a trick) is to integrate by parts using [itex]u=x[/itex], [itex]dv=x\exp(-x^2)\;dx[/itex], from which [itex]du=dx[/itex], [itex]v=-1/2\exp(-x^2)[/itex]. Then<br /> <br /> [tex]\int_{-\infty}^{\infty} x^2\exp(-x^2)\,dx =<br /> \left.-\,\frac 1 2 x \exp(-x^2)\right|_{-\infty}^{\infty} \,\,+\quad<br /> \frac 1 2 \int_{-\infty}^{\infty} \exp(-x^2)\,dx[/tex]<br /> <br /> The first term vanishes at the integration limits. The second term is just half the Gaussian integral. Thus<br /> <br /> [tex]\int_{-\infty}^{\infty} x^2\exp(-x^2)\,dx = \frac{\sqrt \pi}{2}[/tex]OR one could use Hall's approach and look at this as the expected value of <i>x</i><sup>2</sup> for some normal distribution. The normal distribution is<br /> <br /> [tex]f(x;\mu,\sigma) = \frac 1 {\sigma\sqrt{2\pi}} \exp\left(-\,\frac 1 2 \left(\frac {x-\mu}{\sigma}\right)^2\right)[/tex]<br /> <br /> 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:<br /> <br /> [tex]g(x) = \surd{\pi} \,f(x;0,1/\surd 2)[/tex]<br /> <br /> Using the fact that the expected value of <i>x</i><sup>2</sup> for a normal distribution is the variance [itex]\sigma^2[/itex],<br /> <br /> [tex]\int_{-\infty}^{\infty} x^2\exp(-x^2)\,dx = \frac{\sqrt \pi}{2}[/tex][/tex]
 
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
 
For Gaussian integrals like that I like to use the following trick: consider the integral

[tex]\int_{-\infty}^\infty dx~e^{-\alpha x^2} = \sqrt{\frac{\pi}{\alpha}};[/tex]

any integral of the form

[tex]\int_{-\infty}^\infty dx~x^{2n} e^{-\alpha x^2}[/tex]

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