# Find the orthogonal projector of a vector onto a subspace

So I have this question here which asks me to find the orthogonal projection of $v=(1,2,3)$ onto the subspace $W$spanned by the vectors $u_1=(2,-2,1)$ and $u_2=(-1,1,4)$.

I notice that both $u_1$ and $u_2$ are orthogonal to each other so I am guessing that's some kind of clue.

Since I'm working in 3 dimensions, I'm guessing the cross product comes into play somehow but I am not sure. Can someone please suggest how I can approach this problem? Thanks!

• Do you know the Gram-Schmidt process? Mar 19, 2017 at 7:38
• I do but since I was working with 3 dimensions, i was hoping to avoid it with cross product. Mar 19, 2017 at 7:41
• I don't think that's going to work ... the cross product has two inputs, but you have three vectors that will influence the quantity you want. Mar 19, 2017 at 7:44

There's a quick formula that you can use. Some explanations to guide you to it. We're working on a finite-dimensional vector space. You know that $\mathbb{R}^3=W\oplus W^\perp$. Since $(u_1,u_2)$ is an orthogonal basis of $W$, if you take $u_3$ any nonzero element in $W^\perp$, then $(u_1,u_2,u_3)$ is an orthogonal basis of $\mathbb R^3$. So there are $\alpha_1,\alpha_2,\alpha_3\in\mathbb R$ such that $$v=\alpha_1u_1+\alpha_2u_2+\alpha_3u_3\tag{1}$$

What is the orthogonal projection of $v$ onto $W$? Well, $v$ can be uniquely written as $v=x+y$ where $x\in W$ and $y\in W^\perp$, right? The orthogonal projection of $v$ onto $W$ is simply $x$, which is the vector $\alpha_1u_1+\alpha_2u_2$ by $(1)$. Two things to motivate this: Firstly, as $v$ can be written in a unique manner as a sum of two orthogonal vectors, one of which is in $W$, it is natural to give this definition. Secondly, you can actually show that $x$ is the unique vector that satisfies $$\|v-x\|=\inf_{w\in W}\|v-w\|\tag{2}$$ so $(2)$ gets us back to the orthogonal projection we used in in high-school ;)

So, using $(1)$, the orthogonal projection of $v$ is $\alpha_1u_1+\alpha_2u_2$. Using inner products, can you find what are $\alpha_1$ and $\alpha_2$? Don't forget that $u_1,u_2$ and $u_3$ are orthogonal ;)

• Everything seems to essentially using least squares. Is that right? Mar 19, 2017 at 8:32
• @SubhashisChakraborty There's a connexion as orthogonal projections are involved in least squares by $(2)$. However, I wrote this equation to give yous a geometric interpretation of the orthogonal projection. All you need is to use inner products to solve this problem. Mar 19, 2017 at 8:47
• Okay how about this? From your statement, I would use cross product on $u_1$ and $u_2$ to get a new vector $u_3$ that is orthogonal to both $u_1$ and $u_2$. Then I would use inner product on all 3 vectors and set up a system of equations to find $\alpha_1$ $\alpha_2$ and $\alpha_3$. Does that sound good? Mar 19, 2017 at 8:51
• @SubhashisChakraborty That's the strategy. Notice though that you don't need to know $u_3$ or $\alpha_3$. It's existence is enaugh. We're interested in $\alpha_1$ and $\alpha_2$, and as $\langle u_1,u_3\rangle$ and $\langle u_2,u_3\rangle=0$, $\alpha_3$ will vanish and you will find $\alpha_1$ and $\alpha_2$ without troubles. Mar 19, 2017 at 8:55
• @SubhashisChakraborty Actually, you can find the projection onto $W$ by using $u_3=u_1\times u_2$. Since $v=\alpha_1u_1+\alpha_2+\alpha_3u_3$ and $u_3$ is orthogonal to the other two, you can compute $v$’s orthogonal projection onto $u_3$ and subtract that from $v$ to get its projection onto $W$. More generally, the projections onto a subspace $W$ and its orthogonal complement can be obtained by subtracting the other projection from the original vector.
– amd
Mar 19, 2017 at 18:52

suppose $W$ is a subspace spanned by orthogonal vectors $\{v_1, v_2, ..., v_n\}$ and you want to find the projection of $u$ onto $W$. Because each $v_i$ is orthogonal, you can find the projection of $u$ onto each "line" determined by each vector, then add them. In other words, you need to work out "how much of $u$ is in the $v_1$ direction", "how much of $u$ is in the $v_2$ direction" and so on, then add them up. Mathematically the formula is: \begin{align*} \mathrm{proj}_W(u) = \frac{u\cdot v_1}{\Vert v_1 \Vert^2}v_1 + \frac{u\cdot v_2}{\Vert v_2 \Vert^2}v_2 + \cdot\cdot\cdot + \frac{u\cdot v_n}{\Vert v_n \Vert^2}v_n \end{align*}

I'll leave the specific case of your question to you :)

• Nice answer with clear formula. Just put extra detail here, we prove $u - \text{proj}_{W}(u)\perp W$ by prove that $(u - \text{proj}_{W}(u))\cdot v_i = 0, i=1,...,n$. Here, just expand the dot products to see it. Remark that we can arrange order of basis in total space as $\{v_1,...,v_n,v_{n+1},...,v_{N}\}$ with $v_{n+1},...,v_N \in W^{\perp}$, so, in total space, we can represent $u=(u_1,...,u_n,...,u_N), v_i = (0,...,1,...,0)$ for each $i$, 1 in i-th position, here $N$ is dimension of total space. This rearrangement makes representation clearer. Oct 2, 2021 at 13:39