# What is wrong with my method of computing $\int_0^{\infty}x^2 e^{-x^2} \space dx$

I want to check if the following improper integral converges or diverges:

$$\int_0^{\infty} x^2e^{-x^2}\space dx$$

Rewriting the integrand:

$$\int_0^{\infty}-\frac{1}{2}x(-2x e^{-x^2}) \space dx$$

Integrating by parts:

$u=-\frac{1}{2}x; \space u'=-\frac{1}{2}; \space v=e^{-x^2}; \space v'=-2xe^{-x^2}$

$$\implies\int_0^{\infty} -\frac{1}{2}x(-2x e^{-x^2}) \space dx=((-\frac{1}{2}xe^{-x^2})_0^\infty-(-\frac{1}{2}e^{-x^2})_0^{\infty})$$

$$=(\lim_{N \to \infty}(Ne^{-N^2})-0)-(\lim_{N \to \infty}(-\frac{1}{2}e^{-N^2})-(-\frac{1}{2}))=\color{red}{-\frac{1}{2}}$$

As far as I know the answer should be $\frac{1}{4}$ but I can't figure out where I am making a mistake.

• When you integrate by parts you should end up with another integral... $\int f \frac{dg}{dx} dx = f g - \int \frac{df}{dx} g d x$ – johannesvalks Jul 20 '15 at 11:48
• Okay I see where I messed up now. However, how do you integrate $e^{-x^2}$. – qmd Jul 20 '15 at 11:55

$$\begin{eqnarray} \int_0^\infty x^2 e^{-x^2} dx &=& \Big[\frac{1}{2}x e^{-x^2}\Big]_0^\infty x^2 + \frac{1}{2} \int_0^\infty e^{-x^2} dx\\ &=& \frac{1}{4} \int_{-\infty}^\infty e^{-x^2} dx\\ &=& \frac{\sqrt{\pi}}{4} \end{eqnarray}$$

Your question in the comment - how to integrate $e^{-x^2}$... $$\begin{eqnarray} \int_{-\infty}^\infty e^{-x^2} dx &=& \sqrt{ \left( \int_{-\infty}^\infty e^{-x^2} dx \right)^2 }\\ &=& \sqrt{ \int_{-\infty}^\infty e^{-x^2} dx \int_{-\infty}^\infty e^{-y^2} dy}\\ &=& \sqrt{ \int_{-\infty}^\infty \int_{-\infty}^\infty e^{-x^2-y^2} dx dy}\\ &=& \sqrt{ \int_{0}^\infty \int_0^{2\pi} e^{-r^2} r d\phi dr }\\ &=& \sqrt{ \pi \int_{0}^\infty e^{-r^2} d\phi d(r^2) }\\ &=& \sqrt{ \pi } \end{eqnarray}$$

• Thanks. Can you explain how you went from $\frac{1}{2}\int_0^{\infty}e^{-x^2}$ to $\frac{1}{4}\int_{-\infty}^{\infty}e^{-x^2}$? – qmd Jul 20 '15 at 12:00
• @SuH $e^{-x^2}$ is an even function so $\int_{-a}^{a} e^{-x^2}=2\int_0^a e^{-x^2}$ – Hasan Saad Jul 20 '15 at 12:02
• @HasanSaad Thanks! That makes sense. – qmd Jul 20 '15 at 12:03
• Thanks for editing your to include the answer to my comment. – qmd Jul 20 '15 at 12:06
• @SuH - you are welcome! Thank you for the 'best answere' :) – johannesvalks Jul 20 '15 at 12:07

There is a small mistake in the integration by parts.

$$F(x) =\int x^2e^{-x^2}\space dx=-\frac12e^{-x^2} + \int \frac12 e^{-x^2}\space dx=-\frac12e^{-x^2} + \frac{\sqrt{\pi} \cdot \mathrm{erf}(x)}{4}+C$$

Since we have

$$\lim_{x\to\infty} -\frac12e^{-x^2} + \frac{\sqrt{\pi} \cdot \mathrm{erf}(x)}{4} = \lim_{x\to\infty} -\frac12e^{-x^2} + \frac{\sqrt{\pi}}{4} \lim_{x\to\infty} \mathrm{erf}(x) = \frac{\sqrt{\pi}}{4}$$

and $F(0)=0$, the result is $\frac{\sqrt{\pi}}{4}$.

• Thanks! This integral was "harder" than I thought. I have never seen the error function before. – qmd Jul 20 '15 at 11:59
• @SuH It is good to know some properties of the error function and the incomplete gamma functions once you get further in calculus. – wythagoras Jul 20 '15 at 12:03

$$\begin{eqnarray*}\int_{0}^{+\infty}-\frac{x}{2}(-2x e^{-x^2})\,dx &=& \left.-\frac{x}{2} e^{-x^2}\right|_{0}^{+\infty}+\frac{1}{2}\int_{0}^{+\infty}e^{-x^2}\,dx\\&=&\frac{1}{2}\cdot\frac{\sqrt{\pi}}{2}=\color{red}{\frac{\sqrt{\pi}}{4}}\end{eqnarray*}$$ or: $$\begin{eqnarray*}\int_{0}^{+\infty}x^2 e^{-x^2}\,dx = \frac{1}{2}\int_{0}^{+\infty}z^{1/2}e^{-z}\,dz = \frac{\Gamma(3/2)}{2} = \frac{\Gamma(1/2)}{4}=\color{red}{\frac{\sqrt\pi}{4}}.\end{eqnarray*}$$

• Thank you. I didn't/don't know how to integrate $e^{-x^2}$. Is that some sort of special integral I should know? – qmd Jul 20 '15 at 12:01
• @SuH: definitely yes. Just look at here. – Jack D'Aurizio Jul 20 '15 at 12:06