The expectation of the half-normal distribution For the density function below, I need to find $E(X)$ and $E(X^2)$. For $E(X)$, I did the following steps and got the answer of $-2/\sqrt{2\pi}$. However, this is incorrect as the correct answer is $\sqrt{\frac{2}{\pi}}$. I am unsure what I did incorrectly. For $E(X^2)$, is there any easier way to do it than by integration by parts? Thanks for the help. 
Also, I tried a different approach that didn't work at all and I was wondering why it was incorrect. I split it up into two standard  normals by adding them. Then, I used the theorem that the sum of two normals is also normal with a mean that is the sum of the two original normals and a variance that is a sum of the variances of the original normals. Going by that logic, I should get a normal with a mean of $0$ and a variance of $2$; however, that is obviously incorrect, so I am just wondering why.
$$ f(x) = \frac{2}{\sqrt{2\pi}} e^{-\frac{x^2}{2}} dx, \ \ \ \ \ 0 < x < \infty $$
$$
E(X) = \frac{2}{\sqrt{2\pi}} \int_0^\infty x e^{-\frac{x^2}{2}} dx.
$$
Let $u = \frac{x^2}{2}$. 
$$
= - \frac{2}{\sqrt{2\pi}}.
$$
 A: Since you got a negative answer, my first suspicion is that you didn't deal carefully with the bounds of integration.  If $u=-x^2/2$, then as $x$ goes from $0$ to $\infty$, $u$ goes from $0$ to $-\infty$.  Since $du=-x\;dx$, the integral $\int_0^\infty$ becomres
$$\int_0^{-\infty} -e^u\;du.$$
So think about how to change that to $\int_{-\infty}^0\cdots\cdots$.
Also, it wouldn't hurt to recall a bit of algebra in order to understand the relationship between $\dfrac{2}{\sqrt{2\pi\;{}}}$ and $\dfrac{\sqrt{2}}{\sqrt{\pi}}$.
A: For calculating $E[X^2]$, you need not do integration by parts. 
HINT Suppose $Y$ is distributed according to the standard normal $N(0,1)$. Do you know how to calculate $E[Y^2]$ (given its mean and variance)? 
Secondly, the random variables $X^2$ and $Y^2$ are identically distributed. Can you see why? How would this fact help us? 
A: There is absolutely no way you can obtain a negative answer, since $x>0$ and $f(x)$ is always positive, since it is a pdf. Integration has to go along the following lines:
$\varphi(x) = \int_{0}^{\infty}x e^{-\frac{x^2}{2}}dx = \int_{0}^{\infty}e^{-\frac{x^2}{2}}d(\frac{x^2}{2}) =\int_{0}^{\infty}e^{-t}dt=-[e^{-\frac{x^2}{2}}] \vert^{\infty}_{0}=1$
