Consider the hyperplane $H: \sum_{i=1}^n x_i=0$. Let $P$ denote the orthogonal projection onto $H$. What exactly is the matrix $P$ and how do we find it?
-
1Surprisingly few earlier threads about this theme. This is a good fit, but doesn't have much explanations. This has detailed explanations, but is more general, and not computationally easy in your case. – Jyrki Lahtonen Jun 12 '17 at 21:06
2 Answers
When $H\subseteq\Bbb{R}^n$ is the hyperplane through the origin, and $\vec{n}$ is the normal of $H$, the orthogonal projection $p:\Bbb{R}^n\to H$ is given by the recipe $$ p(\vec{x})=\vec{x}-\frac{\vec{x}\cdot\vec{n}}{||\vec{n}||^2}\vec{n}. $$ You can verify the recipe by checking that i) $p(\vec{x})\perp\vec{n}$ for all $\vec{x}$ and ii) $p(\vec{x})=\vec{x}$ whenever $\vec{x}\perp\vec{n}$.
You then get the matrix $P$ by the usual process of calculating the images of your basis vectors.
- 140,891
-
Thanks this is helpful. So I guess that in 2 dimensions the normal of $H$ is $(1,1)$ which gives me the projection matrix $$P=\left[\begin{array}{cc} 1/2 & -1/2\ -1/2 & 1/2 \end{array}\right].$$ It seems that $P$ correctly projects $(-1,1)$ and $(1,1)$. – user_lambda Jun 12 '17 at 21:12
-
1Correct, that is the normal. In 3D you should get $$P=\frac13\pmatrix{2&-1&-1\cr-1&2&-1\cr-1&-1&2}.$$ – Jyrki Lahtonen Jun 12 '17 at 21:15
The hyperplane $H$ is the orthogonal subspace of $(1,1,\ldots,1)^T$. It follows that the projection of $v\in\mathbb{R}^n$ on $H$ is a vector of the form $v-\lambda(1,1,\ldots,1)^T$ with the sum of its coordinates being zero. If we assume $v=(v_1,v_2,\ldots,v_n)^T$, we have that the projection $\pi_H$ on $H$ acts in the following way:
$$ \pi_H : (v_1,v_2,\ldots,v_n)^T \mapsto (v_1,v_2,\ldots,v_n)^T-\left(\frac{1}{n}\sum_{k=1}^{n}v_k\right)\cdot (1,1,\ldots,1)^T $$ hence the matrix $P$ representing $\pi_H$ has the following structure: $$ P = \begin{pmatrix}1-\frac{1}{n} & -\frac{1}{n}& \ldots & -\frac{1}{n} \\ -\frac{1}{n} & 1-\frac{1}{n} & \ldots & -\frac{1}{n} \\ \ldots & \ldots &1-\frac{1}{n} & \ldots \\ -\frac{1}{n} & -\frac{1}{n} & \ldots & 1-\frac{1}{n}\end{pmatrix} = I -\frac{1}{n}\mathbb{1} $$ where $I$ stands for the identity matrix and $\mathbb{1}$ stands for the matrix with every element being equal to one.
- 361,689
-
1One can additionally write the matrix of ones as the rank-one outer product $uu^T$ where $u$ is the column vectors on ones. Since $u^Tu=n$, we see that projector is idempotent as it should be. (This is familiar enough to anyone who has worked with projection matrices before but seems worth mentioning regardless.) – Semiclassical Jun 12 '17 at 21:24