Let $X \sim N(0,1)$

Then to find $E[X^2]$, we can do:

$$ \int_{-\infty}^\infty x^2\frac{1}{\sqrt{2\pi}}e^{-\frac{x^2}{2}} dx $$

Let's say we didn't know this is an odd function, and decided to take the integral by splitting it into 2 pieces:

$$ \frac{1}{\sqrt{2\pi}} \left( \int_{-\infty}^0 x^2e^{-\frac{x^2}{2}} \, dx + \int_0^\infty x^2 e^{-\frac{x^2}{2}} \, dx \right) $$

Then substitute $t = \frac{x^2}{2}$, we get:

$$ \frac{1}{\sqrt{2\pi}} \left( \int_\infty^0 \sqrt{2t}e^{-t} \, dt + \int_0^\infty \sqrt{2t}e^{-t} \, dt \right) \\ = \frac{1}{\sqrt{2\pi}} \left( - \int_0^\infty \sqrt{2t}e^{-t} \, dt + \int_0^\infty \sqrt{2t}e^{-t} \, dt \right) = 0 $$

Which is $= 0 $, but obviously it shouldn't be $0$. Those two integrals should be adding together instead of canceling each other out. Where did I make a mistake in my math? Thanks!

  • 2
    The integrand is an even function. – poweierstrass Oct 21 '16 at 16:34
  • Cause the integral is convergent and the integrand is an even function. – hamam_Abdallah Oct 21 '16 at 16:50
  • Lots of complicated answers have been posted, missing the fact that the error was really simple: $\displaystyle \sqrt{\frac{x^2} 2} = \frac{|x|}{\sqrt2}.$ You simply wrote $x$ where you needed $|x|.\qquad$ – Michael Hardy Oct 21 '16 at 17:30
up vote 1 down vote accepted

$$ \sqrt t = \sqrt{\frac{x^2} 2 } = \underbrace{\frac{|x|} {\sqrt2} = \frac{-x}{\sqrt 2}}_{\text{when }x\,<\,0}. $$ You omitted the absolute value sign.

Then when $x<0$ you have $\dfrac{dt}{2\sqrt t} = \dfrac{-dx}{\sqrt 2},$ with a minus sign.

But the easier way is to observe that you are integrating an even function over an interval that is symmetric about $0$, so you have $$ \int_{-\infty}^0 + \int_0^\infty = 2\int_0^\infty $$ and then go on from there.

$$ \frac{dt}{dx} = x $$ then $$dx = {\frac{1}{\sqrt{2t}}dt} $$ so

$$ \frac{1}{\sqrt{2\pi}} ( \int_{-\infty}^{\infty}x^2e^{-\frac{x^2}{2}} dx) $$

$$ = \frac{1}{\sqrt{2\pi}} ( \int_{-\infty}^{\infty}e^{-t} dt) \\ $$

Let \begin{align} I(a) &= \int\limits_{0}^{\infty} \mathrm{e}^{-ax^{2}} \mathrm{d}x \\ &= \frac{1}{\sqrt{a}} \int\limits_{0}^{\infty} \mathrm{e}^{-y^{2}} \mathrm{d}y \\ &= \frac{\sqrt{\pi}}{2} \frac{1}{\sqrt{a}} \mathrm{erf}(y) \Big|_{0}^{\infty} \\ &= \frac{\sqrt{\pi}}{2} \frac{1}{\sqrt{a}} \end{align} using the substitution $y^{2} = ax^{2}$.

Then \begin{align} I &= \frac{1}{\sqrt{2 \pi}} \int\limits_{-\infty}^{\infty} x^{2} \mathrm{e}^{-x^{2}/2} \mathrm{d}x = \frac{2}{\sqrt{2 \pi}} \int\limits_{0}^{\infty} x^{2} \mathrm{e}^{-x^{2}/2} \mathrm{d}x \\ &= -\frac{2}{\sqrt{2 \pi}} \lim_{a \to 1/2} \frac{\partial I(a)}{\partial a} = \frac{2}{\sqrt{2 \pi}} \lim_{a \to 1/2} \int\limits_{0}^{\infty} x^{2} \mathrm{e}^{-ax^{2}} \mathrm{d}x = \frac{2}{\sqrt{2 \pi}} \int\limits_{0}^{\infty} x^{2} \mathrm{e}^{-x^{2}/2} \mathrm{d}x \\ &= -\frac{2}{\sqrt{2 \pi}} \frac{\sqrt{\pi}}{2} \lim_{a \to 1/2} \frac{\partial}{\partial a} a^{-1/2} = -\frac{1}{\sqrt{2}} \left(-\frac{1}{2}\right) \lim_{a \to 1/2} a^{-3/2} \\ &= 1 \end{align}

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.