# How to solve gaussian integral for $x^2e^{-\frac{x^2}{w}}$?

I am trying to find $$\sigma=\displaystyle\sqrt{\int _{-\infty \:}^{\infty \:}x^2e^{-\frac{x^2}{w}}dx}$$ for the function $$f(x)=e^{-\frac{x^2}{w}}$$. I have tried tabular integration by parts, but it quickly got messy and I stopped after the second integration $$\sqrt{w}\frac{\sqrt{\pi }}{2}\text{erf}\left(\frac{x}{\sqrt{w}}\right)$$. From some quick research no elementary function exists for the indefinite integral. So how would I find the definite integral in this case? I would be grateful for any help.

Starting with $$\displaystyle \int_{-\infty}^{\infty}e^{- x^2}\,\mathrm{dx} = \sqrt{\pi}$$, let $$x \mapsto \sqrt{\lambda} x$$ then $$\displaystyle \int_{-\infty}^{\infty}e^{-\lambda x^2}\,\mathrm{dx} = \frac{\sqrt{\pi}}{\sqrt{\lambda}}$$

Define $$\displaystyle$$ $$\displaystyle f(\lambda) := \int_{-\infty}^{\infty}e^{-\lambda x^2}\,\mathrm{dx} = \frac{\sqrt{\pi}}{\sqrt{\lambda}}$$ then $$\displaystyle f'(\lambda)=-\int_{-\infty}^{\infty}x^2 e^{-\lambda x^2}\,\mathrm{dx} = -\frac{\sqrt{\pi}}{2\lambda^{3/2}}$$

so that $$\int_{-\infty}^{\infty}x^2 e^{-\frac{1}{w} x^2}\,\mathrm{dx} = \frac{1}{2}w^{3/2}\sqrt{\pi}.$$

• Thank you that works with the standard deviation for my model.
– user809100
Jul 18 '20 at 6:38
• Quick question, if you have a moment, I'm not really following the notation and why is it a function of $\lambda$?
– user809100
Jul 18 '20 at 6:51
• We introduce the $\lambda$-parameter so that we can differentiate under the integral sign; after we define $f(\lambda)$ both sides are functions of $\lambda$ and we differentiate both sides with respect to $\lambda$. Jul 18 '20 at 6:57
• Oh, so similar to Feynman's method. Get it now, thanks.
– user809100
Jul 18 '20 at 7:00
• It's indeed the Feyman technique. I should say the notation $x \mapsto \sqrt{\lambda} x$ is the same as subbing $x = \sqrt{\lambda} t$ in case it causes confusion. Jul 18 '20 at 7:44

Hint: Try integration by parts with $$u = x(-\frac{w}{2})$$ and $$v = e^{-\frac{x^2}{w}}$$. Then use that $$\int_{-\infty}^\infty e^{-\frac{x^2}{w}}dx = \sqrt{2\pi w}$$.

• For integration by parts doesn't $\int \:udv=uv-\int \:vdu$. So wouldn't, $e^{-\frac{x^2}{w}}=dv$ instead of $v$. Then two integration would be required. I'm probably missing something.
– user809100
Jul 18 '20 at 6:27
• Close, $dv = -\frac{2x}{w}e^{-\frac{x^2}{w}}$. Also I forgot a scaling term and have made the edit for $u$. Jul 18 '20 at 6:29
• Thanks for the pointers: I'm working though it now.
– user809100
Jul 18 '20 at 6:39