Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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[1]}]

and Mathematica 's answer is: -EulerGamma

Is it possible? Am I doing some mistakes?

share|improve this question

migrated from Aug 10 '12 at 15:34

This question came from our site for people studying math at any level and professionals in related fields.

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$.

enter image description here

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.

share|improve this answer
Shouldn't Mathematica's output be Infinity instead of -EulerGamma? The latter is evidently wrong. – Sjoerd C. de Vries Aug 10 '12 at 20:23
@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. $$

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.