Finite dimensional subspaces of inner product spaces are orthogonally complemented Can someone please explain the proof of the theorem below? I've been looking at it for hours and couldn't figure out how to prove it. Thanks!

Suppose $U$ is a finite-dimensional subspace of $V$. Then $V$ is the direct sum of $U$ and its orthogonal complement. 

I know that to prove direct sums, you must show two things:
1) the sum of $U$ and the orthogonal complement of $U$ equals the space $V$;
2) the intersection of $U$ and the its orthogonal complement is $\{0\}$. 
 A: Since $U\subset V$ is finite-dimensional (and thus closed), we have a projection $\pi:V \to U$ given by $\pi(x) = \sum(x, u_i)u_i$, where $\{u_i\}$ is a basis of $U$. Then $(x - \pi(x), u_i) = 0$ for all $i$, so $x = \pi(x) + (x - \pi(x))$ with $x - \pi(x)\in U^\perp$. The second condition follows from the nondegeneracy of the inner product.
A: I'm assuming you're working on a finite-dimensional inner-product space $X$, either real or complex. Let $N$ be the dimension of $X$.
Suppose that $V$ is a linear subspace of $X$ with basis $\{ v_{j}\}_{j=1}^{n}$. You can apply Gram-Schmidt orthonormalization to obtain an equivalent orthonormal basis $\{ e_{j}\}_{j=1}^{n}$. Then you can complete this basis to a full orthonormal basis $\{ e_{j}\}_{j=1}^{N}$. Every $x \in X$ be written as
$$
        x = \sum_{j=1}^{n}(x,e_{j})e_{j}+\sum_{j=n+1}^{N}(x,e_{j})e_{j}.
$$
The first sum is a vector in $V$ which is orthogonal to the sum on the right. Let $W$ denote the subspace spanned by $\{ e_{j}\}_{j=n+1}^{N}$. Then $X=V\oplus W$ where the decomposition is orthogonal. The orthogonal projections $P_{V}$, $P_{W}$ onto $V$, $W$, respectively, are
$$
 P_{V}x = \sum_{j=1}^{n}(x,e_{j})e_{j},\;\;\; P_{W}x = \sum_{j=n+1}^{N}(x,e_{j})e_{j}.
$$
Projections such as this satisfy $P_{V}^{2}=P_{V}$ and $P_{W}^{2}=P_{W}$. That's because once you project, projecting again doesn't change anything. The reason these are called orthogonal projections is that they're the same types of projections used in 3D where you project points onto lines through the origin, or points onto planes through the origin. The orthogonal projection of $x$ onto the 'plane' $V$ is the unique vector $v \in V$ such that $(x-v)\perp V$.
You can check that's exactly what is going on here: $(x-P_{V}x)\perp V$. So $P_{V}x$ should be thought of as the classical orthogonal projection (equivalently, closest-point projection) of $x$ onto $V$. It can be shown that $\|x-P_{V}x\| \le \|x-v\|$ for all $v\in V$, and you have equality for some $v$ iff $v=P_{V}x$.
