# a matrix formula for a basis of orthogonal complement

Let $X$ be a matrix which contains independent vectors as columns. Then can we find a matrix formula for a basis of the orthogonal complement $\text{span}(X)^{\perp}$?

So basically I want to find a matrix $M$ the columns of which are basis vectors for the orthogonal complement (i.e., $\text{span}(X)^{\perp} = \text{span}(M)$ with the columns of $M$ being independent) and I want $M$ obtained by some multiplication of some matrices containing $X$. We may employ SVD or some other techniques.

• SVD automatically gives you an orthogonal set of vectors for the image and the coimage space. However, to get an orthogonal complement, all you need is to add enough linearly independent vectors to get to the full rank matrix, then perform Gram-Schmidt orthogonalization on the added ones (making each one orthogonal to all the previous ones). How to get the initial approximation for the initial approximation before orthogonalization? Random usually works. – orion Jun 30 '17 at 13:41

Here's a neat approach: note that $X(X^TX)^{-1}X^T$ is the orthogonal projection onto the column space of $X$. Thus, $I - X(X^TX)^{-1}X^T$ is the projection onto the orthogonal complement.
In order to obtain the desired basis, it suffices to select linearly independent columns from $I - X(X^TX)^{-1}X^T$.