i want to derive the following expected value formular for $p(x)= N(\mu,\sigma^2)$ (see https://en.wikipedia.org/wiki/Truncated_normal_distribution):
$$E[X|a<X<b]=\mu+\sigma\frac{\phi(\alpha)-\phi(\beta)}{\Phi(\alpha)-\Phi(\beta)}$$
with $\phi(y):=\frac{1}{\sqrt{2\pi}}e^{-\frac{y^2}{2}}, \Phi(y):=\frac{1+erf(y/\sqrt(2))}{2}$ and $\alpha:=\frac{a-\mu}{\sigma}, \beta:=\frac{b-\mu}{\sigma}$ .
here's what i got so far: $$E:=\int_a^b xp(x)dx=\int_a^b (x-\mu)p(x)dx+\int_a^b \mu p(x)dx$$
the last integral simplifies to: $$\int_a^b \mu p(x)dx=\mu(\bar\Phi(b)-\bar\Phi(a))$$ with $$\bar\Phi(y):=\frac{1+erf((x-\mu)/\sqrt{2\sigma^2})}{2}$$
for the middle integral i got: $$\int_a^b(x-\mu)\frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{(x-\mu)^2}{2\sigma^2}}dx=\frac{\sigma}{\sqrt{2\pi}}\int_{(a-\mu)/\sigma}^{(b-\mu)/\sigma}ze^{-\frac{z^2}{2}}dz=\sigma(-\phi(\beta)+\phi(\alpha))$$
resulting in: $$E=\sigma(-\phi(\beta)+\phi(\alpha))+\mu(\bar\Phi(b)-\bar\Phi(a))$$.
not quite what i was looking for, somebody sees where i did a mistake?