This is an exercise in my functional analysis textbook:
Let $M_{1}, M_{2}$ be subspaces of an inner product space $X$. Show $M_{1} \perp M_{2}$ if and only if $\|m_{1} + m_{2}\|^{2} = \|m_{1}\|^{2} + \|m_{2}\|^{2}$ for all $m_{i} \in M_{i}$.
$M_{1}\perp M_{2}$ means $\langle x, y \rangle = 0$ for all $x \in M_{1}$ and $y \in M_{2}$, although this is not explicitly stated in the textbook. The necessity is easy to prove. But how can I prove the sufficiency? I am a little confused because it seems a very basic result but my first attempt led me to similar computations to those shown here, so I think I'm missing something. Any help or hint is welcome.