<s>[INST] Conditions for generalized projection matrix of size (2x2)? My results seem incorrect... I am trying to derive the general conditions that must be imposed upon the real-valued entries of a $2 \times 2$ orthogonal projection matrix. However, I am coming to a conclusion that seems wrong and hope someone can point me in the right direction.
The prompt reads as follows:

Find conditions on $a,b,c,d \in \mathbb{R}$ that guarantee the matrix $\begin{pmatrix} a & b \\ c & d\end{pmatrix}$ defines a rank-1 orthogonal projection.

I begin by imposing the conditions that all projection matrices $P$ must fulfill, namely
(i) $P = P^T$
(ii) $P = P^2$
Applying condition (i),
$\begin{pmatrix} a & b \\ c & d\end{pmatrix} \overset{!}{=} \begin{pmatrix} a & c \\ b & d\end{pmatrix}$
I get $b=c$ and so I continue working with $\begin{pmatrix} a & c \\ c & d\end{pmatrix}$ and move on to condition (ii):
$\begin{pmatrix} a & c \\ c & d\end{pmatrix} \overset{!}{=} \begin{pmatrix} a & c \\ c & d\end{pmatrix}\begin{pmatrix} a & c \\ c & d\end{pmatrix}=\begin{pmatrix} a^2 +c^2 & ac + cd \\ ac +cd & d^2 + c^2\end{pmatrix}$
From that, I get three equations:
(1) $a = a^2 +c^2$
(2) $c=ac+cd=c(a+d)$
(3) $d=d^2 + c^2$
Further working out (2) by striking $c$ from each side, the system is then
(1) $a = a^2 +c^2$
(2) $1=a+d$
(3) $d=d^2+c^2$
I re-arrange (1) and (3) to get
(1) $c^2 = a - a^2$
(3) $c^2 = d - d^2$
and thus $a-a^2 = d-d^2$ from which I conclude that $a = d$. Returning to equation (2), I then get
(2) $1 = a+d = 2a$
and so $a = \frac{1}{2}$ and $d = \frac{1}{2}$.
Plugging either one of these into equation (1) or (3) then allows me to solve for $c$,
$\frac{1}{2} = \left ( \frac{1}{2} \right )^2+c^2$
or
$c^2 = \frac{1}{4}$
And thus $c=\pm \frac{1}{2}$.
So, according to these results, to be guaranteed an orthogonal projection matrix of rank-1, my matrix $P$ must be one of two possibilities (as indicated by $\pm$):
$P = \frac{1}{2} \begin{pmatrix} 1 & \pm 1 \\ \pm 1 & 1\end{pmatrix}$
This result is unsettling. First of all, I was expecting a broader range of possibilities for $a,b,c,d$ or at least for one or two variables. It seems odd that $a$ and $d$ are wholly constrained to one value and that $c$ only has two options.
Is this correct? It seems like there should be more here that is possible. Aren't matrices such as $\begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix}$ or $\begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix}$ also to be included here?
For example, when I apply $\begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix}$ to a general vector $\begin{pmatrix} x \\ y \end{pmatrix}$, it's easy for me to see the orthogonal projection:
$\begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix} \begin{pmatrix} x \\ y\end{pmatrix} = \begin{pmatrix} x \\ 0\end{pmatrix}$
But when I apply the resulting projection matrix from above to the same generalized vector, I get a result that does reveal orthogonal projection to me (using $c = + \frac{1}{2}$):
$\begin{pmatrix} \frac{1}{2} & \frac{1}{2} \\ \frac{1}{2} & \frac{1}{2}\end{pmatrix} \begin{pmatrix} x \\ y\end{pmatrix} = \frac{1}{2} \begin{pmatrix} x+y \\ x+y\end{pmatrix}$
How can that be an orthogonal projection? Isn't that simply a change in length along the same direction? Am I not understanding the fundamental concept?
Thanks for any help you might be able to provide.
 [/INST] There are two places where you lose some solutions:

*

*From $c = c(a+d)$ to $1 = a+d$, you theoretically lose some solutions with $c=0$: the diagonal matrices. This turns out to be unimportant because there are four diagonal solutions: the zero matrix and the identity matrix (which we throw out because they don't have rank 1) and the solutions where $\{a,d\} = \{0,1\}$ in some order (which happen to satisfy $1 = a+d$ anyway). But it's important to be careful about this sort of thing!


*More importantly, from $a - a^2 = d - d^2$ or $a(1-a) = d(1-d)$, we cannot conclude $a=d$; this is also possible by taking $a=1-d$, and in fact since we already know that $a+d=1$, we already know that $a=1-d$.
So let's return to the step where we have
\begin{align}
   a &= a^2 + c^2 \\
   1 &= a+d \\
   d &= d^2 + c^2
\end{align}
Setting $d = 1-a$, we see that $1-a = (1-a)^2+c^2$ simplifies to $a = a^2+c^2$, so the third equation is redundant. We could at this point describe all solutions as
$$
   P = 
   \begin{bmatrix}
      a & \pm \sqrt{a-a^2} \\
      \pm \sqrt{a-a^2} & 1-a
   \end{bmatrix}.
$$
In order for $\sqrt{a-a^2}$ to be real, we want $0 \le a \le 1$, but any value of $a$ in this range works (and so does either choice of $\pm$, assuming we choose the same $\pm$ for both off-diagonal entries).

To resolve another point of confusion, the map $(x,y) \mapsto (\frac{x+y}{2}, \frac{x+y}{2})$ is an orthogonal projection: it's an orthogonal projection onto the diagonal line $x=y$.
</s>