What is $\int_0^{\infty} x^2e^{\frac{(x-\mu)^2}{2 a^2}} dx$? How can we express the integral $\int_0^{\infty} x^2e^{-\frac{(x-\mu)^2}{2 a^2}} dx$ for example by means of the error function? The problem is of course, that the expectation value is shifted and we don't integrate from minus infinity to plus infinity. Thus, I doubt that it is possible to explicitely evaluate the integral.
 A: Put 
$$t^2=\frac{(x-\mu)^2}{2a^2} (\implies x=\sqrt 2\,a\,t+\mu)\implies dx=\sqrt2\,a\;dt$$
and then we get the integral
$$\sqrt2\,a\int\limits_{\frac\mu{\sqrt2\,a}}^\infty (\sqrt{2t}\,a+\mu)^2e^{-t^2}dt$$
and playing around with this you'll get a part with the err function and another with the whole integral.
A: Let $\Phi(t) = \int_{-\infty}^t e^{-x^2/2} \, dx$. Then
$$
\int_k^{\infty} x^2 e^{-x^2/2} \,dx = -\frac{d}{d\alpha}\Big|_{1/2}\int_k^{\infty}e^{-\alpha x^2}\,dx = - \frac{d}{d\alpha}\Big|_{1/2} \int_k^{\infty} e^{-(\sqrt{2 \alpha}x)^2/2}\,dx =\\ -\frac{d}{d\alpha}\Big|_{1/2} \Big( \frac{1}{\sqrt{2\alpha}} \int_{\sqrt{2 \alpha} k}^{\infty} e^{-x^2/2} \,dx \Big) = - \frac{d}{d\alpha}\Big|_{1/2}\Big[\frac{1}{\sqrt{2 \alpha}}\big( 1 - \Phi(\sqrt{2\alpha} \,k)\big)\Big] = \cdots
$$
Now
$$
x^2 = (x-\mu+\mu)^2 = (x-\mu)^2 +2 \mu(x-\mu) + \mu^2 
$$
so
$$
\int_{0}^{\infty} x^2 e^{- \frac{(x-\mu)^2}{2a^2}}\,dx =\\ a^2\int_{0}^{\infty} \frac{(x-\mu)^2}{a^2}  e^{- \frac{(x-\mu)^2}{2a^2}}\,dx + 2\mu \int_{0}^{\infty} (x-\mu) e^{- \frac{(x-\mu)^2}{2a^2}}\,dx + \mu^2 \int_{0}^{\infty} e^{- \frac{(x-\mu)^2}{2a^2}}\,dx\\
= a^2 \int_{-\mu/a}^{\infty}x^2 e^{-\frac{x^2}{2}} \,dx +\mu \int_{\mu^2}^{\infty}e^{-\frac{x}{2a^2}}\,dx + \mu^2 \int_{-\mu/a}^{\infty} e^{-\frac{x^2}{2}} \,dx
$$
The first term can now be found in terms of $\Phi$ using the derivation above, the third term is just $\mu^2 [1 - \Phi(-\mu/a)]$, and the middle term can be integrated easily.
