Prove: Taking conditional expectation of $L^2$ random variables is an orthogonal projection I have been going through a Basic Stochastic Process(undergraduate book).
I got a problem which is mentioned below. I think this problem is related to some upper level of classes. So I am unable to understand. 
Please help me to solve this problem. 
consider $L^2(F)= L^2(\Omega ,F, P)$ as a Hilbert space(complete
inner product space) with scalar product  
$L^2(F) \times L^2 (F) \ni (\xi
\varsigma)\in R$. 
Show that if $\xi$ is a random variable in
$L^2(F)$ and G is a $\sigma$-field contained in $F$, then $E(\xi|G)$ is the orthogonal projection of $\xi$ onto the subspace $L^2(G)$ in $L^2(F)$ consisting of
$G$-measurable random variables.
Here:$\Omega$= Finite Field, F= $\sigma$-field and P= probability measure. 
$(\Omega ,F, P)$ is a probability space. 
$E(\xi|G)$ is an expectation of $\xi$ given $G$.
I would really appreciate your help. Thank you 
 A: Recall that for a Hilbert space $H$ and its closed, convex, non-empty subset $C$ the projection of a point $x$ on to $C$ is the unique point $y \in C$ such that $\| x-y \| = \inf_{z \in C} \| x- z \|$. 
I will write $P_G$ for the orthogonal projection on to $L^2(G)$. We want to show $P_G \xi = \mathbb{E}[\xi | G]$ almost surely. 
Let $Y = P_G \xi$ and take $Z \in L^2(G)$. Consider $W = Y + aZ \in L^2(G)$ for $a \in \mathbb{R}$. It follows from the definition of the projection that 
$$ 0 \leq \| \xi - W \|_{L^2(F)}^2 - \| \xi - Y \|_{L^2(F)}^2 = a^2 \mathbb{E}[Z^2] - 2a \mathbb{E}[(\xi - Y)Z] $$
The right hand side is a quadratic in $a$ which is non-negative for all $a$ iff 
$\mathbb{E}[(\xi - Y)Z]=0$ so $\xi - Y \perp L^2(G)$. (This is a special case of the more general fact that if $P$ is an orthogonal projection on to a subspace $U$ of a Hilbert space $H$ then for $x \in H$, $x-Px \perp U$)
By considering $Z$ of the form $1_A$ for $A \in G$, it immediately follows that $Y$ is a version of $\mathbb{E}[\xi | G]$ and we are done.
