Fast way to do this well-known integral (gaussian-distribution) I want to evaluate $$ \frac{1}{\sqrt{2 \pi } \sigma}\int_{-\infty}^{\infty} x^2e^{-\frac{(x-\mu)^2}{2\sigma ^2}}dx.$$ The problem is, I don't want to run into heavy calculations. Therefore, maybe there is somebody here who knows some nifty tricks, to shorten this calculation at least somewhat.
 A: I assume you know
$$ \int_{-\infty}^\infty \exp(-t^2/2)\ dt = \sqrt{2\pi}$$
from which, by the change of variables $x = \sigma t$, for $\sigma > 0$ we have  $$\int_{-\infty}^\infty \exp(-x^2/(2\sigma^2))\ dx = \sqrt{2\pi} \sigma$$
Take the derivative of that with respect to $\sigma$:
$$ \int_{-\infty}^\infty \dfrac{d}{d\sigma} \exp(- x^2/(2\sigma^2))\ dx =
\dfrac{1}{\sigma^3}\int_{-\infty}^\infty x^2 \exp(-x^2/(2 \sigma^2))\ dx = \sqrt{2\pi}$$
i.e.
$$ \int_{-\infty}^\infty x^2 \exp(-x^2/(2 \sigma^2))\ dx = \sqrt{2\pi} \sigma^3$$
and then by the change of variables $x = y - \mu$
$$ \eqalign{\int_{-\infty}^\infty y^2 \exp(-(y-\mu)^2/(2 \sigma^2))\ dy &= 
\int_{-\infty}^\infty (x + \mu)^2 \exp(-x^2/(2 \sigma^2))\ dx \cr
&= \int_{-\infty}^\infty (x^2 + 2 \mu x + \mu^2)  \exp(-x^2/(2 \sigma^2))\ dx\cr &= \sqrt{2\pi} (\sigma^3 + 0 + \mu^2 \sigma)\cr}$$
A: $\newcommand{\+}{^{\dagger}}%
 \newcommand{\angles}[1]{\left\langle #1 \right\rangle}%
 \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%
 \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%
 \newcommand{\dd}{{\rm d}}%
 \newcommand{\isdiv}{\,\left.\right\vert\,}%
 \newcommand{\ds}[1]{\displaystyle{#1}}%
 \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}%
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}%
 \newcommand{\fermi}{\,{\rm f}}%
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}%
 \newcommand{\ic}{{\rm i}}%
 \newcommand{\imp}{\Longrightarrow}%
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}%
 \newcommand{\pars}[1]{\left( #1 \right)}%
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}%
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}%
 \newcommand{\sech}{\,{\rm sech}}%
 \newcommand{\sgn}{\,{\rm sgn}}%
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}%
 \newcommand{\verts}[1]{\left\vert #1 \right\vert}%
 \newcommand{\yy}{\Longleftrightarrow}$
$\ds{\int_{-\infty}^{\infty}\expo{-\beta x^{2}}\,\dd x = \beta^{-1/2}\root{\pi}\,,
     \quad\beta > 0.\quad}$ Derivating both sides, respect of $\beta$, we'll get several identities:
\begin{align}
-\int_{-\infty}^{\infty}x^{2}\expo{-\beta x^{2}}\,\dd x
= -\,{1 \over 2}\,\beta^{-3/2}\root{\pi}\,,
\qquad
\int_{-\infty}^{\infty}x^{4}\expo{-\beta x^{2}}\,\dd x
&= {3 \over 4}\,\beta^{-5/2}\root{\pi}
\\[3mm]
-\int_{-\infty}^{\infty}x^{6}\expo{-\beta x^{2}}\,\dd x
= -\,{15 \over 8}\,\beta^{-7/2}\root{\pi}\,,
\qquad
\int_{-\infty}^{\infty}x^{8}\expo{-\beta x^{2}}\,\dd x
&= {105 \over 16}\,\beta^{-5/2}\root{\pi}
\\ \mbox{and so on...}
\end{align}
In particular:
$\ds{\int_{-\infty}^{\infty}x^{2}\expo{-\beta x^{2}}\,\dd x
     = {\root{\pi} \over 2}\,{1 \over \beta^{3/2}}}$. Then,
\begin{align}
&\color{#0000ff}{\large{1 \over \root{2\pi}\sigma}\int_{-\infty}^{\infty}x^{2}
\exp\,\pars{-\,{\bracks{x - \mu}^{2} \over 2\sigma^{2}}}\,\dd x}
=
{1 \over \root{2\pi}\sigma}\int_{-\infty}^{\infty}\pars{x + \mu}^{2}
\exp\,\pars{-\,{x^{2} \over 2\sigma^{2}}}\,\dd x
\\[3mm]&=
{1 \over \root{2\pi}\sigma}\,\braces{%
{\root{\pi} \over 2}\,{1 \over \bracks{1/\pars{2\sigma^{2}}}^{3/2}}
+
\mu^{2}\,\root{\pi}\,{1 \over \bracks{1/\pars{2\sigma^{2}}}^{1/2}}}
\\[3mm]&=
{1 \over \root{2\pi}\sigma}\,\braces{%
\root{2\pi}\sigma^{3}
+
\mu^{2}\,\root{2\pi}\sigma} = \color{#0000ff}{\large\sigma^{2} + \mu^{2}}
\end{align}
A: Maybe this is what you want to show, but if not, you can make use of the following:
$$
V(X)=E(X^2)-[E(X)]^2\Longrightarrow E(X^2)=V(X)+[E(X)]^2.
$$
Since your integral is
$$
\int_{-\infty}^\infty\frac{x^2}{\sqrt{2\pi\sigma^2}}\exp\left\{-\frac{(x-\mu)^2}{2\sigma^2}\right\}dx=E(X^2)
$$
it follows that it evaluates to
$$
\int_{-\infty}^\infty\frac{x^2}{\sqrt{2\pi\sigma^2}}\exp\left\{-\frac{(x-\mu)^2}{2\sigma^2}\right\}dx=V(X)+[E(X)]^2=\sigma^2+\mu^2.
$$
