# Use stochastic calculus (Ito's lemma) to compute the expectation

Calculate $E[\cos(X)e^X]$, where $X\sim N(0,\sigma^2)$. Use stochastic calculus instead of integrating w.r.t the normal density.

During the discussion with friends, we believe that we should use Brownian motion $B_t$ to represent X and then somehow use Ito's lemma to establish a differential equation. However, we don't understand Ito's lemma well. So we could not do it. Thank you!

-

Ok, so your idea was right - you should consider $$\mathsf E \left[\cos{B_t}\mathrm e^{B_t}\right]$$ at $t = \sigma^2$ since $B_t\sim\mathcal N(0,t).$ What is Ito lemma about? Given a function $f\in C^2$ you know that $$f(B_t) - f(B_0) = \frac12\int\limits_0^t f''(B_s)\,\mathrm d s+\int\limits_0^tf'(B_s)\mathrm dB_s,$$ so applying expectation to both sides you obtain $$\mathsf E[f(B_t)] - f(0) = \frac12\int\limits_0^t\mathsf E[f''(B_s)]\mathrm ds \quad(\star)$$ which is a simple application of Dynkin's formula. It holds since $\mathsf E\int\limits_0^tf'(B_s)\mathrm dB_s = 0$ since the process under the expectation sign is Ito integral which is always a martingale starting from zero.

Let us focus now on $f(x) = \cos x\cdot\mathrm e^x$, so $f(0) = 1$ and $f''(x) = \sin x\cdot\mathrm e^x$. If you denote $m(t) = \mathsf E f(B_t)$ then from $(\star)$ we have $$m(t) = 1-\int\limits_0^t \mathsf E[\sin B_s\cdot\mathrm e^{B_s}]\mathrm d s.$$ Denote $n(s) =E[\sin B_s\cdot\mathrm e^{B_s}]$, then $m(0) = 1$ and $$m'(t) = -n(t).$$

Applying Ito formula to the function $\sin x\mathrm e^x$ we obtain another equation: $n(0) = 0$ and $$n'(t) = m(t).$$

We can solve it by substitution: $m'' = -n' = -m$, so $m''+m = 0$ (do you know how to solve it?). The solution is $m(t) = \alpha \sin t+\beta\cos t$. Based on the initial condition, we find: $\beta = 1$ and $\alpha = 0$ so $$m(t) = \cos t$$ and $$\mathsf E[\cos X\mathrm e^X] = \cos \sigma^2.$$

I think it's also worth to say that here we have a textbook example in which just two steps were sufficient to calculate the expectation. If the function $f$ is arbitrary then you have to solve a PDE $$m_t = \frac12 m_{xx}$$ with $m(0,x) = f(x)$, see e.g. here. However, the only way to give a solution to this PDE can be $$m(t,x) = \int\limits_\mathbb R f(y)\frac1{\sqrt{2\pi t}}\mathrm e^{-y^2/2t^2}\mathrm d y$$ which is exactly just a usual formula for the expectation of the function of a Gaussian random variable.

-
Thank you, Gortaur! It will take me a while to digest the information. –  user16859 Sep 29 '11 at 12:31
@user16859: you're welcome. If anything is unclear to you - just write in a comment, I'll extend an answer. –  Ilya Sep 29 '11 at 12:43
Wow! I just finished reading your solution. So clear! By the way, I do understand that step where you use the characteristic equation to solve the ODE. Many thanks! –  user16859 Sep 30 '11 at 8:49
@user16859: correct me if I wrong. Do you want me to explain how to solve $m''+m=0$? –  Ilya Sep 30 '11 at 8:53
No. I mean I knew how to solve that. Thank you again. –  user16859 Oct 14 '11 at 0:53