# Right quadratic variation for stochastic process

Say we have a filtered prob. space, $$M$$ an $$L^2$$ martingale on it and $$Y_{a_i}$$ $$\mathcal{F}_{a_i}$$ measurable random variable. Why does it hold that

$$E[(Y_{a_i}(M_{t \wedge a_{i+1}}-M_{t \wedge a_i}))^2] = E[Y_{a_i}^2(\langle M \rangle_{t \wedge a_{i+1}}- \langle M \rangle_{t\wedge a_i})]$$

The measurability of $$Y_{a_i}$$ is clear but does the equality work because the difference of quadratic variations on the right-hand side is the quadratic variation of $$(M_{t \wedge a_{i+1}}-M_{t \wedge a_i})$$? If so, why is that?

You say you understand the orthogonality of $$Y_{a_t}$$ (not necessarily independence), so I will show why $$E[(M_{t \wedge a_{t+1}}-M_{t \wedge a_t})^2] = E[\langle M \rangle_{t \wedge a_{t+1}} - \langle M \rangle_{t \wedge a_t}]$$. By definition, $$M_t^2 - \langle M\rangle_t$$ is a martingale, and since a stopped martingale is a martingale this implies $$M_{t \wedge a_{t+1}}^2 - \langle M \rangle_{t \wedge a_{t+1}}$$ and $$M_{t \wedge a_t}^2-\langle M \rangle_{t \wedge a_t}$$ are as well. Thus we compute \begin{align*} E[(M_{t \wedge a_{t+1}}-M_{t \wedge a_t})^2] &= E[M_{t \wedge a_{t+1}}^2-2 M_{t \wedge a_{t+1}}M_{t \wedge a_t} + M_{t \wedge a_{t}}^2] \\ &= E[M_{t \wedge a_{t+1}}^2 - \langle M \rangle_{t \wedge a_{t+1}} + \langle M \rangle_{t \wedge a_{t+1}} -2 M_{t \wedge a_{t+1}}M_{t \wedge a_t} + M_{t \wedge a_{t}}^2] \\ &= E[E[M_{t \wedge a_{t+1}}^2 - \langle M \rangle_{t \wedge a_{t+1}} | \mathcal F_{a_t}] + \langle M \rangle_{t \wedge a_{t+1}} -E[2 M_{t \wedge a_{t+1}}M_{t \wedge a_t}|\mathcal F_{a_t}] + M_{t \wedge a_{t}}^2] \\ &= E[M_{t \wedge a_t}^2 - \langle M \rangle_{t \wedge a_{t}}+ \langle M \rangle_{t \wedge a_{t+1}} -2 M_{t \wedge a_t}E[ M_{t \wedge a_{t+1}}|\mathcal F_{a_t}] + M_{t \wedge a_{t}}^2] \\ &= E[2 M_{t \wedge a_t}^2 + \langle M \rangle_{t \wedge a_{t+1}} - \langle M \rangle_{t \wedge a_{t}} - 2 M_{t \wedge a_t}^2] \\ &= E[\langle M \rangle_{t \wedge a_{t+1}} - \langle M \rangle_{t \wedge a_{t}}]. \end{align*}
A similar computation would show that $$(M_{t \wedge a_{t+1}}-M_{t \wedge a_t})^2 - (\langle M \rangle_{t \wedge a_{t+1}} - \langle M \rangle_{t \wedge a_{t}})$$ is a martingale, and $$\langle M \rangle_{t \wedge a_{t+1}} - \langle M \rangle_{t \wedge a_{t}}$$ is an increasing process, so the difference of the quadratic variations is indeed the quadratic variation of $$M_{t \wedge a_{t+1}}-M_{t \wedge a_t}$$.