TITLE: Why can $\int_{x=0}^{\infty} x\,\mathrm{e}^{-\alpha x^2}\mathrm {d}x$ not be evaluated by parts to obtain $\frac{1}{2\alpha}$?
QUESTION [11 upvotes]: Can $\int_{x=0}^{\infty} x\mathrm{e}^{-\alpha x^2}\,\mathrm {d}x$ be evaluated by parts to show that $\int_{x=0}^{\infty} x\mathrm{e}^{-\alpha x^2}\,\mathrm {d}x= \frac{1}{2\alpha}$
I know that this can be done without parts by  means of the substitution $-\alpha x^2=u \Rightarrow -2\alpha x\, \mathrm {d}x=\mathrm {d}u$, then $x\mathrm dx=\frac {-1}{2\alpha}\mathrm du$; such that
$\displaystyle\int_{x=0}^{\infty} xe^{-\alpha x^2}\,dx=\frac {-1}{2\alpha}\displaystyle\int_{x=0}^{\infty} e^u \mathrm du= \left [ \frac {-1}{2\alpha}\displaystyle e^{-\alpha x^2} \right]_{x=0}^{\infty}=\frac{1}{2\alpha}$
However; Can it be done like this?
$\color{blue}{I}$ $=\displaystyle\int_{x=0}^{\infty} xe^{-\alpha x^2}\,dx= x\int_{x=0}^{\infty}e^{-\alpha x^2} - \int_{x=0}^{\infty}\left(\int_{x=0}^{\infty}e^{-\alpha x^2}\mathrm dx\right)\mathrm{d}x$
Now $$\int_{x=0}^{\infty}e^{-\alpha x^2}\mathrm dx= \frac{1}{2}\left(\frac{\pi}{\alpha}\right)^\frac{1}{2}\tag{1}$$ 
Now by insertion of $(1)$ into $\color{blue}{I}$ yields,
$\color{blue}{I}=\displaystyle\int_{x=0}^{\infty} xe^{-\alpha x^2}\,\mathrm{d}x=\underbrace{ \left [ x\frac{1}{2}\left(\frac{\pi}{\alpha}\right)^\frac{1}{2} \right ]_{x=0}^{\infty} - \int_{x=0}^{\infty} \frac{1}{2}\left(\frac{\pi}{\alpha}\right)^\frac{1}{2} \mathrm {d}x}_{\large\text{$\color{red}{\mathrm{Undefined}}$}}\ne \frac{1}{2\alpha}$ which is clearly a contradiction.
I realize that this may be blatantly obvious to many of you why this will never work, but it is not clear to me. 
What I can't understand is that if asked to evaluate say $\int x\sin x\,\mathrm{d}x$ by parts I would do the following: $\int x\sin x\,\mathrm dx= x\int \sin x\,\mathrm dx-\int\left(\int \sin x\,\mathrm dx\right)\mathrm{d}x= \sin x -x\cos x$ + C. But the method does not work for $\int_{x=0}^{\infty} x\mathrm{e}^{-\alpha x^2}\,\mathrm dx$ by parts as shown above. Why is this?
Could someone please explain to me why I cannot perform this integral by parts to get the answer $\dfrac{1}{2\alpha}$?

REPLY [2 votes]: You can integrate by parts, but it will probably lead to a more difficult integral.  For example,
$$
\begin{align}
\int_0^\infty xe^{-ax^2}\,\mathrm{d}x
&=\frac12\int_0^\infty\overbrace{\ e^{-ax^2}\ }^{\large u}\,\overbrace{\ \ \mathrm{d}x^2\ \ \vphantom{e^{-ax^2}}}^{\large\mathrm{d}v}\\
&=\frac12\left[x^2e^{-ax^2}\right]_0^\infty-\frac12\int_0^\infty\overbrace{\ \ \ x^2\ \ \ \vphantom{\mathrm{d}e^{-ax^2}}}^{\large v}\,\overbrace{\mathrm{d}e^{-ax^2}}^{\large\mathrm{d}u}\\[9pt]
&=a\int_0^\infty x^3e^{-ax^2}\,\mathrm{d}x
\end{align}
$$