TITLE: Expectation of an exponential function
QUESTION [6 upvotes]: Why is the expectation of an exponential function: 
$$\mathbb{E}[\exp(A x)] = \exp((1/2) A^2)\,?$$
I am struggling to find references that shows this, can anyone help me please?
If anyone could enlighten me it would be great!

REPLY [10 votes]: Let $X\sim\mathcal{N}(0,1)$ and $a\in\mathbb R$. Then
$$
\begin{align*}
E[\exp(aX)]&=\int_{\mathbb R}\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{1}{2}x^2\right)\exp(ax)\,\mathrm dx=\int_{\mathbb R}\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{1}{2}(x-a)^2+\frac{1}{2}a^2\right)\\
&=\exp\left(\frac{1}{2}a^2\right)\int_{\mathbb{R}}\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{1}{2}(x-a)^2\right)=\exp\left(\frac{1}{2}a^2\right)
\end{align*}
$$
because
$$
x\mapsto \frac{1}{\sqrt{2\pi}}\exp\left(-\frac{1}{2}(x-a)^2\right)
$$
is the density of an $\mathcal{N}(a,1)$ distribution.