# Prove that if $E(X^2+Y^2) \lt \infty$, $E(X|Y)=Y$, $E(Y|X)=X$, then $P(X=Y)=1$ [duplicate]

Suppose that X and Y are random variables on a common probability space such that $E(X^2+Y^2) \lt \infty$, $E(X|Y)=Y$, $E(Y|X)=X$. Prove that $$P(X=Y)=1$$

My work: $E(X)=E(E(X|Y))=E(Y)$ and $E(Y)=E(E(Y|X))=E(X)$

But I don't know what to do next and I'm sure how to use the condition $E(X^2+Y^2) \lt \infty$.

\begin{align*} E( (X-Y)^2 )&= E(X^{2}+Y^{2}-2XY ) \\ &= E(X^{2}+Y^{2})-E(XY )-E(XY ) \\ &= E(X^{2} )+E(Y^{2} )-E(E(XY |X ))-E(E(XY |Y )) \\ &= E(X^{2} )+E(Y^{2} )-E(XE(Y |X ))-E(YE(X |Y )) \\ &= E(X^{2} )+E(Y^{2} )-E(X^2 )-E(Y^2 ) \\ &=0 \end{align*} Therefore, $X=Y$ almost surely.
• @CMonsour The same holds when $X,Y \in L^{1}$. – clark Jun 8 '18 at 2:22
• $NYRAHHH it is hard to answer this in a comment since the proof is slightly longer. Why don't you ask a separate question? – Kavi Rama Murthy Jun 8 '18 at 6:07 • For the proof without the$L_2\$ inegrability, see e.g. this. math.stackexchange.com/questions/666843/… – Clement C. Jun 8 '18 at 13:30