Prove there is a unique $x_0 \in M$ such that $\|x_0 - z\| = \inf_{x \in M} \|x-z\|$ and show $z-x_0 \perp M$ Prove there is a unique $x_0 \in M$ such that $$\|x_0 - z\| = \inf_{x \in M} \|x-z\|$$ and show $z-x_0 \perp M$.
Here, $X$ is a finite dimensional inner product space and $M$ is a proper, nonempty closed linear subspace of $X$ and $z\in X$. 
I've been thinking about this for a bit and I'm not really sure what to do with it. I feel like $x_0$ should be in $M$ because $M$ is closed but I'm not really sure. Any ideas or hints that could help me figure this out? 

By drawing a picture and recalling basic geometric facts one can see that $x_0$ should be the orthogonal projection of $x$ on $M$. 
Indeed, if $x_0$ is the orthogonal projection of $x$ on $M$ and $m \in M$, then 
$||m -x||^2 = ||m -x_0||^2 +  ||x -x_0||^2$ by the Pythagorean theorem, which holds in any inner product space. 
The orthogonal projection can be found as $\sum_i \langle x , m_i \rangle m_i $ where $(m_i)_i$ is an orthonormal  basis of $M$. (Note this is finite.)
