Showing that $H=M\oplus M^{\perp}$ provided that $M$ is closed and $H$ is Hilbert space. I am a student of MSc second year,Mathematics.I always try to produce visually intuitive proofs so that it is easy to remember.Recently,we were taught a theorem in functional analysis which is as follows:
Statement: Let $H$ be a Hilbert space and $M$ be a closed subspace then $H=M\oplus M^{\perp}$.
My attempt: Let $x\in H$ ,we want to show $x\in M+M^{\perp}$.Let $y\in M$ be the unique vector such that $\|x-y\|\leq \|x-y'\|$ for all $y'\in M$.Then write $x=(x-y)+y$.If we could show that $x-y\in M^{\perp}$,we are through.So let $z\in M$ ,we have to show $\langle x-y,z\rangle=0$.On the contrary,let us assume that $\langle x-y,z\rangle\neq 0$ which pictorially means that $x-y$ is not perpendicular to $z$,so it will have a non-zero projection along $z$,which is given by $\frac{\langle x-y,z\rangle}{\|z\|^2}z$.Then it is intuitive that $x-y-\frac{\langle x-y,z\rangle}{\|z\|^2}z$ will be perpendicular to $z$,which can also be checked formally.But now,I am not able to figure out how to proceed.Can someone give me some hint?My guess is that this vector $x-y-\frac{\langle x-y,z\rangle}{\|z\|^2}z\in M^{\perp}$ but I am not able to show that.Even if I do,I have no way to proceed further.
Addendum
As mentioned by Chee Han.I provide here some background of what has been done before this theorem.Basically a lemma has been proved which says:
If $M$ is a closed subspace of a Hilbert space $H$,then for each $x\in H$ there exists a unique $y\in M$ such that $\|x-y\|\leq \|x-y'\|$ for all $y'\in M$.
Using this,I have to prove this theorem.
 A: Given that you have the minimization property, this is easy enough (the tough part, which uses completeness, is the lemma which tells you the existence of a unique $y$).
Ok, so let $x\in H$ be given, and let $y\in M$ be the unique element given by your lemma. You’re right, we now write $x=y+(x-y)$, and we wish to show the second part is in $M^{\perp}$. To do this, consider any $z\in M$, and consider the function $f:\Bbb{R}\to\Bbb{R}$ defined as $f(t)=\|x-y+tz\|^2$. Then, $f$ is a quadratic polynomial in $t$, so it is differentiable everywhere, and furthermore, $y,z\in M$ implies $y-tz\in M$; so by the minimizing property of $y$, it follows that $f$ has a (global) minimum at $t=0$. You can now differentiate at $t=0$ to get $\langle x-y,z\rangle=0$. This shows $x-y\in M^{\perp}$.
The idea is that a minimization problem is of course closely related to derivatives. Here, $M$ was a subspace which was crucial for us to say $y-tz\in M$ for all $t\in\Bbb{R}$, and hence $f(0)=\|x-y\|^2\leq \|x-(y-tz)\|^2=f(t)$, and thus $f’(0)=0$.

As a bonus: note that the existence of a unique minimizing $y$ also holds if you assume only that $M$ is a closed convex subset (when $M$ is a subspace, convexity is automatic). Try to derive the analogous condition on inner products in this case (hint: an inequality will be present, since convexity means that (a slight modification of) the above function is only defined for $t\in [0,1]$ and we have a minimum at an endpoint of the interval).
