From this question we know that if $x\in\mathbb{R}^{n\times1}$ is a vector, then the (normalized) outer product matrix $$ \frac{x x^\top}{||x||^2}\, \in \mathbb{R}^{n\times n} $$ can operate on another vector $y\in\mathbb{R}^{n\times 1}$ and projects orthogonally onto the line spanned by $x$.

How does this generalize to a basis of vectors?

Suppose $X\in\mathbb{R}^{n\times m}$ is a matrix and let $[x_1 \, \cdots x_m]$ be its columns. I would like to find a matrix $A\in\mathbb{R}^{n\times n}$ such that it projects a vector $y\in\mathbb{R}^{n\times 1}$ onto the space spanned by the columns on $X$.


2 Answers 2


I have chosen to rewrite my answer since my recollection of the formula was not quite satisfactionary. The formula I presented actually holds in general. If $A$ is a matrix, the matrix

$$P = A (A^\top A)^{-1} A^\top$$

is always the projection onto the column space of $A$. In the case where $A$ is orthogonal, this reduces to $AA^\top$. You can find a simple derivation under "Intuition" in this Wikipedia-article: https://en.wikipedia.org/wiki/Projection_matrix.

  • $\begingroup$ Thank you! How did you arrive at the expression for $P$? Also, in my very specific case I am quite lucky cause the columns are already normalized, so that works perfectly! Is there a way to perform this projection more efficiently in practice? $\endgroup$ Jun 22, 2021 at 9:36
  • $\begingroup$ Perhaps using some matrix decomposition $\endgroup$ Jun 22, 2021 at 9:39
  • 1
    $\begingroup$ I have edited the answer. $\endgroup$ Jun 22, 2021 at 10:06

let consider a generic vector ${v}$. one can decompose this vector in the tangential and the orthogonal vector components as follows

$v=(v\cdot \hat{n})\hat{n}+(v\cdot\hat{t})\hat{t}$

moving the normal component to the LHS it has


where $I$ is the identity matrix. Therefore one can define the rejection and the projection operators




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.