0

Given the equation and subspace $x_1 + x_2 + \cdots + x_n =C$ in $\mathbb{R}^n$ and a vector $v \in \mathbb{R}^n$. How would you find the projection of this vector $v$ on the subspace $x_1 + x_2 + \cdots + x_n =C$?

Thomas Andrews
  • 186,215
  • Subtract the normal until it lands on the hyperplane. – copper.hat Jan 14 '22 at 22:19
  • @copper.hat Hmm, okay. Could you expand on that or point me to any resources? Would be appreciated. – wednesdaymiko Jan 14 '22 at 22:20
  • You need to do some work yourself. – copper.hat Jan 14 '22 at 22:21
  • Your subspace has $n+1$ variables. Did you mean to start with $x_1?$ Also, this doesn’t define a vector subspace, since it isn’t closed under addition. It defines a hyper plane, which is not something we normally call a “subspace.” – Thomas Andrews Jan 14 '22 at 22:21
  • @ThomasAndrews Oh yeah, good catch. Supposed to start with $x_1$. It doesn't define a vector space? I was thinking of e.g. x + y + z = C which defines plane. So shouldn't the same apply to the equation above? – wednesdaymiko Jan 14 '22 at 22:23
  • 3
    A plane is not a vector subspace, unless it contains the $0$ vector. – Thomas Andrews Jan 14 '22 at 22:24
  • Draw a little picture for the $n=2$ case (set $C=1$ to be definite) and consider the first comment again. – copper.hat Jan 14 '22 at 22:24
  • A plane is an "affine subspace", which is not a "subspace" in the sense of linear algebra unless, as Thomas mentioned, it contains the zero vector. – Brian Moehring Jan 14 '22 at 22:26
  • Hint: a perpendicular vector,$u,$ to your hyper plane is hidden in your formula for the hyper plane. Then compute real $\lambda$ so that $v+\lambda u$ so that it is in your hyperplane. – Thomas Andrews Jan 14 '22 at 22:28
  • Was searching on this just now, is it correct that the normal is $(x_1, x_2, ..., x_n)$? Or am I totally on the wrong track?

    If that's the case, when you then subtract the normal vector from the vector we want to project, do you then get the correct projection?

    – wednesdaymiko Jan 14 '22 at 22:35
  • Did you mean the orthogonal projection? – robjohn Jan 15 '22 at 00:28
  • @robjohn Yup, I mean the orthogonal projection. – wednesdaymiko Jan 15 '22 at 00:32

2 Answers2

1

Note that the normal to the plane is $n=(1,...,1)^T$. The plane is defined by the set of points $p$ satisfying $n^T p = C$.

Compute $t$ such that $v+tn$ lies in the plane, that is $n^T (v+tn) = C$, or $t= {C-n^Tv \over \|n\|^2}$. Let $p = v+tn$.

Suppose $p'$ is any other point in the plane, then $\|v-p'\|^2 = \|v-p\|^2 + \|p-p'\|^2$ since $n^T (p-p') = 0$.

Hence $p$ is the closest point on the plane to $v$.

copper.hat
  • 178,207
  • I think I'm doing something wrong. Say we have the plane $x +y + z = 3$. Then the normal is $(1, 1, 1)^T$. We then calculate $t = \frac{9}{3}$. Plugging in $t = 3$ into the equation does not give the correct result and I can't figure out why. I do see that the solution is $t = -2$, which gets us the the correct answer when plugged in. – wednesdaymiko Jan 15 '22 at 00:30
  • Thanks for the help so far. Been tackling this all day, lmk if you know what I'm doing wrong if you could provide an example. Otherwise, have a good day/night. – wednesdaymiko Jan 15 '22 at 01:11
  • What do you mean setting $t$ as above does not give the right result? What point are you trying to project? – copper.hat Jan 15 '22 at 01:27
  • Eh, I messed up, the $t$ should have a minus sign. – copper.hat Jan 15 '22 at 01:28
  • Np. Was trying to project $v = (2, 3, 4)$. – wednesdaymiko Jan 15 '22 at 01:34
  • My formula for $t$ was missing a $C$, see above. For your numbers I get $t=-2$ and the projection is $(0,1,2)^T$. – copper.hat Jan 15 '22 at 01:53
0
  1. Rewrite this subspace into the form $\lbrace Ax+y: x \in \mathbb{R}^{n-1} \rbrace$ for appropriate matrix $A \in \mathbb{R}^{n \times (n-1)}$ and vector $y \in \mathbb{R}^n$. You do this by observing that all of the subspaces elements are of the form $$ \begin{pmatrix} -x_2-x_3-\dots -x_n + c \\ x_2 \\ x_3 \\ \vdots \\ x_n \end{pmatrix} = x_2\begin{pmatrix} -1 \\ 1\\ 0 \\ \vdots\\ \\0 \end{pmatrix} + x_3 \begin{pmatrix} -1 \\ 0\\ 1 \\ \vdots\\ \\0 \end{pmatrix} + \dots + x_n \begin{pmatrix} -1 \\ 0\\ 0 \\ \vdots\\ \\1 \end{pmatrix} + \begin{pmatrix} c \\ 0\\ 0 \\ \vdots\\ \\0 \end{pmatrix}. $$ I am sure that you can see the pattern.
  2. The projection is an optimization problem $$ \min_{x \in \mathbb{R}^{n-1}}\lVert v-Ax-y \rVert^2_2. $$ You can check the optimality conditions but the solution is $$ x=\left(A^\top A\right)^{-1} (A^\top v - A^\top b). $$
  3. The vector $x=(x_2, ..., x_n)$ gives you the values for every coefficient but $x_1$. That you can find out by substituting those into the equation $$ x_1 + x_2 + \dots + x_n = C. $$

Yes, you can just check at which point the perpendicular vector $(1, 1, \dots, 1)$ enters the plane. But I chose the above reasoning because it can also be applied when the perpendicular vector is not known.