# Writing a projection as a matrix

Here is a simple question which I can't figure out.

I know that a projection is a linear mapping, so it has a matrix representation. What I am interested is finding the matrix which represents:

$$\pi_d : \mathbb{R}^{d+1} \rightarrow \mathbb{R}^d$$

which maps $$\mathbb{R}^{d+1}$$ onto the hyperplane $$H=\{x \in \mathbb{R}^d : \langle x, \mathbf{1} \rangle = 1\}$$, where $$\mathbf{1}$$ is the all-ones vector.

I can easily compute the position of a given vector projection; for example, considering $$\pi_1$$:

$$\begin{bmatrix} 1 \\ 0 \end{bmatrix} \mapsto \begin{bmatrix} 1/2 \\ -1/2 \end{bmatrix}$$

but I am unsure on how to get this explicitly as a $$1$$-dimensional vector.

If you could provide a hint rather than a full answer, I would be appreciative!

• Isn't this under defined? Are there not infinitely many operations fulfilling your criteria? Jan 26 '21 at 21:42
• Ah, I forgot one more condition: I want it to be an orthogonal projection. Jan 26 '21 at 23:12

An orthogonal projection in $$R^d$$ is a type of linear transformation from $$R^d$$ into $$R^d$$. So its image is a subspace of $$R^d$$. Your $$H$$ is not a subspace of $$R^d$$, so there is no such thing as an orthogonal projection onto $$H$$.
You can fix that by moving $$H$$ to the origin; take $$H$$ to be the set of vectors orthogonal to $${\bf 1}$$.
Now the hint. You can find the projection $${\bf p}$$ of any vector $${\bf x}$$ onto the span of $${\bf 1}$$ by using the dot product as described in calculus books; it is the component of $${\bf x}$$ in that direction. Once you have that, the difference $${\bf x-p}$$ is what you are looking for. The matrix that you work out will be square of course, not $$d$$ by $$d+1$$.
• Thanks for the hint! Before I work this out, I was wondering why the matrix will be square? Say I am projecting $R^2$ onto a line; I want the image to have only one component, that is, the distance from $0$ on the line. The same for hyperplanes in $R^d$, so I'm mapping $d+1$-dimensional vectors onto $d$-dimensional vectors, which should be $d \times d+1$, right? Jan 27 '21 at 1:12
• No, a line through the origin of $R^2$ is not $R^1$, (it just looks kind of like it) it is a subspace of $R^2$. The projection of $R^2$ onto the $y$ axis for example, is $\begin{bmatrix}0 & 0 \cr 0 & 1 \end{bmatrix}$. Jan 27 '21 at 21:59
• I see. So I have another question: is there a natural way to consider a hyperplane in $R^{d+1}$ (we may assume it is a subspace) specifically as $R^{d}$ through a matrix transformation? I'd think not, but is there any mapping which captures how the subspace "looks like $R^d$"? For example, taking an order isomorphism from a line $L$ in $R^2$ (lexicographically ordered with the direction vector of the line being the first lexicographic comparison) to $R$ with the natural ordering. Jan 28 '21 at 17:26
• There is no natural way, because there are infinitely many ways, all equally good. A fundamental theorem of linear algebra is that every vector space of dimension $d$ is isomorphic to $R^d$, but there is no unique isomorphism. Every basis of the space gives rise to an isomorphism. For example when you say "the direction vector" of a line, you have chosen a basis vector. There are infinitely many direction vectors, all happen to be multiples of each other in this one dimensional case. Jan 28 '21 at 23:42