# Swapping expectation operator with differential operator

Suppose I have a general SDE

$dx_{t} = \mu dt + \sigma dz_{t}$

Then I can put $E[]$ on both sides to get

$E[dx_{t}] = E[\mu dt] + E[\sigma dz_{t}]$

Now comes the question: I've seen some formulas where

$E[dx_{t}]$ becomes $dE[x_{t}]$

Is it ok to swap $E[.]$ with $d[.]$?

Thank you.

Remember that $dx_t = \mu_t dt + \sigma_t dz_t$ is just a shorter notation for $$x_t = x_0 + \int_0^t \mu_s ds + \int_0^t \sigma_s dz_s$$
Now, under mild hyopthesis on $\sigma$ the stochastic integral is a martingale so $E[\int_0^t \sigma_s dz_s] = E[\int_0^0 \sigma_s dz_s] = 0$. We are left with $$E[x_t] = x_0 + E[\int_0^t \mu_s ds] = x_0 + \int_0^t E[\mu_s] ds$$ by Fubini's theorem.
So $dE[x_t] = E[\mu_t] dt$. This justifies writing $dE[x_t] = E[dx_t]$.