How to solve this integral by parts? I was solving a problem of mean values, and I would like to solve and evaluate this integral:
$$
\langle x^2\rangle=\int_{-\infty}^{\infty}\left(\frac{2\alpha}{\pi}\right)^{1/2}x^2 e^{-2\alpha(x-\beta)^2} dx
$$
I have tried integrating by parts, but I get stuck there. The integration must be done with the constants $\alpha, \beta$, because it is a general case.
Thank you in advance.
 A: Hint:
Expand  $x^2$  along the powers of $x-\beta$ first:
$$x^2=(x-\beta)^2+2\beta(x-\beta)+\beta^2$$
and split into three integrals. Use integration parts for 
$$\int_{-\infty}^{\infty}(x-\beta)^2 \mathrm e^{-2\alpha(x-\beta)^2}\mathrm d\mkern1mu x.$$
A: $$
\langle x^2\rangle=\int_{-\infty}^{\infty}\left(\frac{2\alpha}{\pi}\right)^{1/2}x^2 e^{-2\alpha(x-\beta)^2} dx
$$
$$
\langle x^2\rangle=\left(\frac{2\alpha}{\pi}\right)^{1/2}\int_{-\infty}^{\infty}(y+\beta)^2 e^{-2\alpha y^2} dy
$$
$$
\langle x^2\rangle=2\left(\frac{2\alpha}{\pi}\right)^{1/2}\left(\int_{0}^{\infty}y^2 e^{-2\alpha y^2} dy + \beta^2\int_{0}^{\infty}e^{-2\alpha y^2} dy\right)
$$
$$
\langle x^2\rangle=2\left(\frac{2\alpha}{\pi}\right)^{1/2}\left(-\dfrac12I'(\alpha) + \beta^2I(\alpha)\right),
$$
where
$$
I(\alpha) = \int_{0}^{\infty}e^{-2\alpha y^2} dy.
$$
$$
I^2(\alpha) = \int_{0}^{\infty}e^{-2\alpha x^2} dx\cdot \int_{0}^{\infty}e^{-2\alpha y^2} dy = \int_{0}^{\infty} \int_{0}^{\infty}e^{-2\alpha (x^2 + y^2)} dxdy 
$$
Passing to polar coordinates:
$$
I^2(\alpha) = \int_{0}^{\infty} \int_{0}^{2\pi}e^{-2\alpha r^2}r\,d\phi\, dr 
$$
$$
I^2(\alpha) = -\dfrac{2\pi}{4\alpha}e^{-2\alpha r^2}\biggr|_0^{\infty} = \dfrac{\pi}{2\alpha}. 
$$
$$
I(\alpha) = \left(\dfrac{\pi}{2\alpha}\right)^\frac12
$$
$$
I'(\alpha) = \left(\dfrac{\pi}{2\alpha}\right)^{\frac12}\left(-\dfrac1{2\alpha}\right)
$$
$$
\langle x^2\rangle = 2\left(-\dfrac1{2\alpha}+\beta^2\right)
$$
$$
\boxed{\langle x^2\rangle = 2\beta^2-\dfrac1\alpha}
$$
A: A statistical approach. You are trying to find $\mathbb{E}(X^2)$ where
 $X$ is a normal random variable with mean $\mathbb{E}(X)=\beta$ and 
variance $\mathbb{V}(X)={1\over 4\alpha}.$ Therefore 
$$\mathbb{E}(X^2)=\mathbb{V}(X)+\mathbb{E}(X)^2={1\over 4\alpha}+\beta^2.$$
A: Hint:
The integral 
$$
\int x^2e^{-2\alpha(x-\beta)^2}dx
$$
with the substitution 
$$
\sqrt{2\alpha}(x-\beta)=t \quad \Rightarrow \quad dx=\frac{dt}{\sqrt{2\alpha}}
$$
$$
x^2=\frac{t^2}{2\alpha}+\frac{2\beta t}{\sqrt{2\alpha}}+\beta^2
$$
becomes:
$$
\frac{1}{\sqrt{(2\alpha)^3}}\int t^2e^{-t^2}dt+\frac{\beta}{\alpha}\int t e^{-t^2}dt+\frac{\beta^2}{\sqrt{2\alpha}} \int e^{-t^2}dt
$$
The second integral can be easily solved by substitution:
$$
\int t e^{-t^2}dt=-\frac{e^{-t^2}}{2}
$$
and from this, integrating by parts the first integral we have:
$$
\int t^2e^{-t^2}dt=\int t d\left(-e^{-t^2}\right)=\frac{-te^{-t^2}}{2}+\frac{1}{2} \int e^{-t^2}dt
$$
Now we have to find the integral $\int e^{-t^2}dt$ that cannot be done with elementary functions. We use the error function, defined as:
$$
\frac{d}{dx} \mbox{erf}(x)=\frac{2}{\sqrt{\pi}}e^{-x^2}
$$
so:
$$
\int e^{-t^2} dt=\frac{\sqrt{\pi}}{2}\mbox{erf}(t)
$$
and
$$
\int t^2e^{-t^2}dt=\frac{\sqrt{\pi}}{4}\mbox{erf}(t) -\frac{te^{-t^2}}{2}
$$
Now you can back substitute and find the primitive of your function.
For the limits of the given integral you can use:
$$
\lim_{x\to \infty}\mbox{erf}(x)=1 \qquad \lim_{x\to -\infty}\mbox{erf}(x)=-1
$$
that is a consequence of the Gaussian integral.
