Gaussian integration by parts? How do we integrate this expression
$$\int_{-\infty}^\infty x^2e^{-ax^2}  \,dx$$
Using integration by parts? Whenever I attempt it the two terms just cancel and I'm left with 0, which is not what the answer is supposed to be, and no online source seems to solve this using integration by parts. 
 A: Hint
Consider
$$\int_{-\infty}^\infty x^2e^{-ax^2}  \,dx=-\frac 1 {2a}\int_{-\infty}^\infty x(-2axe^{-ax^2})  \,dx$$
Integrate by part
A: How about just differentiating under the integral sign?
$$\int_{-\infty}^{\infty}e^{-ax^{2}}dx=\sqrt{\frac{\pi}{a}}$$
Differentiate both sides w.r.t. $a$ to get:
$$\int_{-\infty}^{\infty}x^{2}e^{-ax^{2}}dx=\frac{\sqrt{\pi}}{2a^{\frac{3}{2}}}$$
A: $$\int_{-\infty}^{\infty} \color{red}x \cdot x e^{-ax^2} {\rm d} x = \Bigg[x \int x e^{-ax^2} {\rm d} x - \int \color{red} 1 \cdot \left( \int x e^{-ax^2} {\rm d} x \right) \Bigg]_{-\infty}^{\infty}  $$
A: $a>0$,
$\begin{align}J&=\int_{-\infty}^\infty x^2e^{-ax^2}  \,dx\\
&=2\int_{0}^\infty x^2e^{-ax^2}  \,dx\\
&=-\frac{1}{a}\Big[x\text{e}^{-ax^2}\Big]_0^{\infty}+\frac{1}{a}\int_0^{\infty}e^{-ax^2}  \,dx\\
&=\frac{1}{a}\int_0^{\infty}e^{-ax^2}  \,dx
\end{align}$
Perform the change of variable $y=\sqrt{a}x$,
$\begin{align}J&=\frac{1}{a^{\frac{3}{2}}}\int_0^{\infty}e^{-y^2}  \,dy\\
&=\boxed{\frac{1}{a^{\frac{3}{2}}}\frac{\sqrt{\pi}}{2}}\end{align}$
A: First, I want to establish that$$\int\limits_0^{\infty}dx\, e^{-ax^2}\color{red}{=\frac 12\sqrt{\frac {\pi}{a}}}$$This can be done by first squaring the expression, using Fubini’s theorem, then changing to polar coordinates$$\begin{align*}I^2(a) & =\int\limits_0^{\infty}\int\limits_0^{\infty}dx\, dy\, e^{-a(x^2+y^2)}\\ & =\int\limits_0^{\pi/2}\int\limits_0^{\infty}dr\, d\theta\, re^{-ar^2}=\frac {\pi}{4a}\end{align*}$$Since replacing $x$ with $-x$ generates the same result, it’s natural to see that$$J(a)=\int\limits_{\mathbb{R}}dx\, e^{-ax^2}\color{blue}{=\sqrt{\frac {\pi}a}}$$Now, differentiate with respect to $a$ gives$$J’(a)=-\int\limits_{\mathbb{R}}dx\, x^2e^{-a x^2}=-\frac {\sqrt{\pi}}{2a^{3/2}}$$So$$\int\limits_{-\infty}^{\infty}dx\, x^2e^{-ax^2}\color{brown}{=\frac 1{2a}\sqrt{\frac {\pi}a}}$$
