# Expected Value: Strange/unexpected result

Assume $X$ is an exponential random variable with unit mean ($f_X(x)=e^{-x}$, $x>0$). I want to calculate the expected value of $\frac{1}{X}$. Since $X>0$, I am expecting that $\mathbb{E}(\frac{1}{X})>0$, but Mathematica gives some negative value. I tried the following input:

Expectation[1/x, {x \[Distributed] ExponentialDistribution}]

and Mathematica 's answer is: -EulerGamma

Is it possible? Am I doing some mistakes?

• What does Mathematica give you when you use the definition: $\int_0^\infty e^{-x}/x\,dx$ ... ? – GEdgar Aug 10 '12 at 14:00
• On Mathematica 9.0.0, Mathematica simply returns the input when entering your line of code. – Jacob Akkerboom Jul 17 '13 at 9:41

Instead of the exponential distribution, consider its truncation $\mathcal{E}_\epsilon(1)$ to $(\epsilon, \infty)$. The expectation can then be found, but it diverges as $\epsilon \downarrow 0$. Indeed, writing the expectation as integral: $$\int_0^\infty \frac{1}{x} \mathrm{e}^{-x} \mathrm{d} x$$ you see that the integral diverges at the lower bound. Thus, while it is natural to expect $\mathbb{E}\left(X^{-1}\right) > 0$, the expectation is infinite.
• @SjoerdC.deVries It could be Infinity, or it could bounce unevaluated. Current output results from use of GenerateConditions->False, as a way to turn off convergence checking. It has an undesirable side effect, that Integrate returns "renormalized answers", i.e. regularized and the divergent part subtracted. Try Integrate[Exp[-x]/x,{x,0,Infinity},GenerateConditions->False]. – Sasha Aug 10 '12 at 20:28
Here's a way to see why it diverges to infinity: Observe that $e^{-x}>1/3$ (since $0<e<3$) if $0<x<1$, so $$\int_0^\infty \frac 1 x e^{-x} \, dx \ge \int_0^1 \frac 1 x e^{-x} \, dx \ge \int_0^1 \frac 1 x \cdot \frac 1 3 \, dx = \infty.$$