I have to find equations which satisfy functions : $E(S(t))$ and $Var(S(t))$ where $S(t)$ satisfy
$dS(t)=\mu S(t)dt+\sigma S(t)dW_t$
$S(0)=S_0>0$
In the first case I calculate:
$S(t)=S(0)+\mu \int_0^t S(u)du +\sigma \int_0^tS(u)dW_u$
$E(S(t))=S(0)+\mu \int_0^t E(S(u))du$
Denote $E(S(t))=f(t)$
$f(t)=S(0)+\mu \int_0^t f(u)du $
$df(t)=\mu f(t)dt$
Then I solve it and get $f(t)=S(0)e^{\mu t}$
How to do the same now but for variance?
According to the Ito-formula $$ d(S^2(t))= 2S(t) dS(t) + d[S](t) = 2S(t)(\mu S(t)dt +\sigma S(t) dW_t) + \sigma^2 S^2(t)$$ whence $$ d( E S^2(t))= (2\mu +\sigma^2) ES^2(t) dt$$ and so $$ Var(S(t))= S_0^2e^{2\mu t}(e^{\sigma^2t} -1). $$ Some things were swept under the carpet though. 1. differentiation and expectation can be interchanged. 2. $\int_0^t S^2(u)dW_u$ is a martingale and so its expectation exists and is 0.