The question states:
$U$ is a subspace of $\mathbb{R}^n$, and $\{u_1,...,u_k\}$ is a basis of $U$. Prove that if Gram-Schmidt is applied to the basis $\{u_1,...,u_k,v_1,...,v_{n-k}\}$ of $\mathbb{R}^n$, producing an orthogonal basis $\{e_1,...,e_k,f_1,...,f_{n-k}\}$, then $\{e_1,...,e_k\}$ is a basis for $U$ and {$f_1,...,f_{n-k}$} is a basis for the complement of $U$.
I am unsure of how to complete this proof... it's got me stuck.
Ok, we are given a $k$ dimensional subspace $U$ with a basis $u_1,\dots,u_k$ of the $n$ dimensional space $V$.
First, we arbitrarily extend $u_i$ to a basis $(u_i),(v_j)_{j=1}^{n-k}\,$ of $V$,
then, we apply Gram-Schmidt to obtain
$e_1=u_1$ (or $e_1=\frac1{\|u_1\|}u_1$ if we also want to normalize the basis),
$e_2$ in the span of $u_1,u_2$ that is orthogonal to $e_1$, ...
$e_k$ in the span of $u_1,\dots,u_k$ that is orthogonal to $e_i$ for $i<k$, ....
$f_1$ in the span of $u_1,\dots,u_k,v_1$ that is orthogonal to all $e_i$
etc.
Now, $e_i$ are all in $U=\mathrm{span}(u_1,\dots,u_k)$, they are pairwise orthogonal to each other, so linearly independent, there are $k$ of them, so they are a basis of the $k$ dimensional subspace $U$.
The other statement is that $U^\perp=\mathrm{span}(f_1,\dots,f_{n-k})$.
From the construction, it's clear that $f_j\perp e_i$ for each $j$ and $i$, hence $f_j\in U^\perp$.
On the other hand, if a vector $v\in V$ is orthogonal to $U$, then write it up in the new orthogonal basis $(e_i),(f_j)$ and verify that $v\in\mathrm{span}(f_1,\dots,f_{n-k})$.