# why $f(t,u) \neq E_t^Q [r(u)]$ when $r$ is random?

If I suppose the short rate $$r$$ deterministic, and the risk neutral measure $$Q$$, I can write the following :

$$f(t,u) = -\frac{d}{du}\ln P(t,u) = -\frac{d}{du} E_t^Q \left[ e^{-\int_t^{u}r_sds} \right] = E_t^Q \left[ \frac{d}{du} \int_t^{u}r_sds \right] = E_t^Q \left[ \frac{d}{du} (R_u - R_t) \right] = E_t^Q [r_u]$$

with $$f$$ the instantaneous forward rate and $$P$$ the price of a zero coupon bond.

Now I wonder, which one of the equalities here that doesn't hold when $$r$$ is a random process? Any help please?

Your equations are flawed. Also there is no expectation if the process $$\{r_s\}$$ is deterministic.
The correct reasoning is, assuming $$\{r_s\}$$ is stochastic: $$f(t,u)=-\frac{d}{du}\ln P(t,u)=-\frac{\frac{d}{du}P(t,u)}{P(t,u)}\\ =-\frac{\frac{d}{du}E^Q_t[e^{-\int_t^u r_s ds}]}{P(t,u)} =\frac{E^Q_t[e^{-\int_t^u r_s ds} r_u]}{P(t,u)} =E^Q_t\left[\frac{e^{-\int_t^u r_s ds}}{P(t,u)} r_u\right]\\ =E^{Q^u}_t[r_u]$$ where $$Q^u$$ is the $$u$$-forward measure (the measure associated with $$P(.,u)$$ as numeraire) defined as $$\frac{dQ^u}{dQ}=\frac{e^{-\int_t^u r_s ds}}{P(t,u)}$$
If $$\{r_s\}$$ is deterministic then $$\frac{dQ^u}{dQ}=1$$, i.e. the two measures are identical.