If for a random variable $X$ we have that $$e^{\mathbb{E}[X]} = \mathbb{E}[{e^{X}}],$$
how can I show that $$X= c$$ almost surely, where $c$ is constant?
Proof: Suppose that $$ \exp\left(\int_X f(x)d\mu(x)\right) = \int_X e^{f(x)}d\mu(x). \qquad (1)$$ We want to show that if equality holds then $f$ is constant.
Let us denote $c=\int_X f(x) \,\mathrm{d}\mu(x)$. The above inequality can now be rewritten as $e^c = \int_X e^{f(x)} \,\mathrm{d}\mu(x)$.
Suppose that $f$ is not constant, i.e. $f(x)\ne c$ on a set of positive measure. Then both sets $A=\{x; f(x)>c\}$ and $B=\{x; f(x)<c\}$ must have positive measure. (Otherwise we would get a contradiction with the definition of $c$ as the mean value of $f$.)
For any $t\ne c$ we have $e^t>e^c+e^c(t-c)$, since the graph of $e^x$ lies above the tangent line at the point $c$. (The factor $e^c$ is the slope at the point $c$.) This means $$e^t-e^c>e^c(t-c).$$
Thus for any $x\in A\cup B$ we have strict inequality $e^{f(x)}-e^c>(f(x)-c)e^{c}$. For any $x$ we have $e^{f(x)}-e^c \ge (f(x)-c)e^c$. Integrating gives $$\int_X e^{f(x)} \,\mathrm{d}\mu(x) - e^c > e^c \left(\int_X f(x) \,\mathrm{d}\mu(x) -c \right) = 0,$$ contradicting the equality (1).
Am I getting it right?