# Projection of vector

The projection of a vector $$x$$ onto a vector $$u$$ is $$proj_u(x) =\frac{\langle x, u \rangle}{\langle u, u \rangle}u.$$

Projection onto $$u$$ is given by matrix multiplication $$proj_u(x)=Px$$ where $$P=\frac{1}{\left\lVert u \right\rVert^2}uu^T$$

I don't understand the calculation of $$P=\frac{1}{\left\lVert u \right\rVert^2}uu^T$$ from $$\frac{\langle x, u \rangle}{\langle u, u \rangle}u.$$ Anyone help me to understand.

Recall $$\langle a,b\rangle=a^\top b=b^\top a$$. Thus, $$\operatorname{proj}_u(x)=\frac{x^\top u}{\|u\|^2}u=\frac{u^\top x}{\|u\|^2}u=\frac{uu^\top}{\|u\|^2}x$$ Now, $$u^\top x$$ is a scalar depending on $$x$$. It doesn't matter if you write $$\lambda x$$ or $$x\lambda$$ (where $$\lambda$$ is a scalar and $$x$$ a vector) so you can write $$(u^\top x)u=u(u^\top x)$$.
• How $$\frac{u^\top x}{\|u\|^2}u=\frac{uu^\top}{\|u\|^2}x$$? Apr 23 at 21:04
• Why $u^Tx$ is scalar? Would you explain little bit. Apr 23 at 21:28
• @Brett: $u^\top x=u_1x_1+\dots+u_nx_n$ is just the inner product. It belongs to $\mathbb R$ (or whatever the base field is), hence a scalar. Apr 24 at 2:07