distance from a point to a subspace spanned by a set of vectors Can someone please help me with the following textbook problem? Find the closest point and the distance from $b=(1, 1, 2, -2)^T$ to the subspace spanned by $(1, 2, -1, 0)^T$, $(0, 1, -2, -1)^T$ and $(1, 0, 3, 2)^T$. I believe that I am supposed to use Gram matrix, but any help will be great. Thanks. 
 A: Think of how we might do this in one dimension less, i.e., find the distance from a point in $\mathbb{R}^3$ to a plane.  We would compute the normal vector to the plane $\vec{n}$, and then compute any vector connecting the point to the plane, call it $\vec{d}$.  The distance would then be the scalar projection of $\vec{d}$ onto $\vec{n}$.  This is a very standard problem, so if any of this is unfamiliar to you, it might be worth taking a quick look at any one of a number of examples online (just google "how to compute distance from a point to a plane").
We can do basically the same thing one dimension higher.  You have a set of three vectors in $\mathbb{R}^4$, and these vectors span a subspace $V$ or $\mathbb{R}^4$.  We can compute a vector that is normal to $V$ by computing a vector $\vec{n}$ that is perpendicular to all three of the original vectors (I assume you know how to do this:  Set $\vec{n} = (a, b, c, d)$, and solve the system of equations that results from dotting $\vec{n}$ with each of the three vectors and setting each dot product to $0$).  Once you solve for $n$, you will have a vector that is normal to the subspace $V$.  
Now compute any vector $\vec{d}$ that connects the point $b=(1, 1, 2, -2)$ to the subspace $V$, and compute the scalar projection of $\vec{d}$ onto $\vec{n}$.
A: It is rather simple to compute the distance as the height of a parallelepiped.  Explicitly, we have a 4-dimensional parallelepiped formed by the four vectors above whose base is a 3-dimensional parallelepiped formed by the three latter vectors.
Therefore, the distance is equal to $$\frac{|\det(b, v_1, v_2, v_3)|}{\sqrt{\mathrm{Gram}(v_1, v_2, v_3)}}$$ where $v_1, v_2, v_3$ are the three latter vectors.
To compute the orthogonal projection of $b$ over the subspace spanned by $v_1, v_2, v_3$ we can use Gram-Schmidt orthogonalisation process.
