Which matricies are a product of projections? I believe that if $A$ is an $n$ by $n$ matrix over $\mathbb{R}$, then $A$ can be written as a product of projections as long as $A$ is not invertible. However, I don't know how to prove this.
By projection I mean a matrix $P$ which satisfies $P^2 = P$. 
I know how the show this if $n = 2$, however the method involves explicitly calculating such a representation. I think it would be extremely messy to generalize this and hope that someone finds a simpler solution.
 A: I show below that any $n\times n$ matrix of rank $r<n$ is the product of exactly
$r+1$ projections. I prefer to present my proof below in terms of linear maps $a$ rather than matrices $A$, but this changes nothing of course. 
Let us start with a basis $(b_{r+1},\ldots,b_n)$ of ${\sf Ker}(a)$, and complete
it into a full basis $(b_{1},\ldots,b_n)$ of ${\mathbb R}^n$. Define an endomorphism $q$ of ${\mathbb R}^n$ by $q(b_k)=b_k$ when $k \leq r$ and $q(b_k)=0$ otherwise. Then $q^2=q$ is a projection, and agrees with $a$ on $b_{r+1},\ldots,b_n$. The idea is to multiply
$q$ by projections on the left, making the product agree with $a$ on more and more
vectors. We will thus have a product $p_1\ldots p_r q$, where $p_k\ldots p_r q$
coincides with $a$ on $b_{k},\ldots,b_n$ for every $k\leq r$. 
A sufficient condition for this to work is that for $k\in[|1,r|]$, $p_k$ fixes
all the elements in ${\cal F}_k=\lbrace b_j | 1\leq j \leq k\rbrace \cup 
\lbrace ab_j | k\leq j \leq r\rbrace $ except $b_k$ which it sends to $ab_k$.
If ${\cal F}_k$ is linearly independent, those set of conditions uniquely define
a projection on the subpace spanned by ${\cal F}_k$, which can then be easily extended
to a projection defined on the whole of ${\mathbb R}^n$. So it will suffice to show
the following :
Lemma. There is a choice of $b_1,b_2,\ldots,b_r$ such each of that 
${\cal F}_1,{\cal F}_2,\ldots, {\cal F}_r$ is linearly independent.
Proof of lemma. Start with an arbitrary $(c_1,\ldots,c_r)$ on which
$a$ is injective. We will construct $b_1,\ldots,b_r$ by a descending
induction, starting
with $b_r$, and then proceeding to $b_{r-1},\ldots,b_1$. The induction hypothesis
which our $b_l$ must satisfy at each step is that the families 
${\cal F}^l_k=\lbrace b_j | l\leq j \leq k\rbrace \cup 
\lbrace ab_j | k\leq j \leq r\rbrace$ for $k\in[|l,r|]$ must all be linearly
independent.
Base case : when $l=r$, we only have one condition, namely that
${\cal F}^r_r=\lbrace b_r,ab_r \rbrace$ must be linearly independent. If $c_r$
satisfies this condition, then fine, we take $b_r=c_r$ otherwise we simply
take $b_r=c_r+z$ where $z$ is any nonzero vector in ${\sf Ker}(a)$.
Induction step : suppose now that $l<r$ and that $b_{l+1},\ldots, b_r$ have already
been constructed. Our to-be-defined $b_l$ will have to satisfy :
$$
\begin{array}[cl]
\ (i) & b_l \not\in {\sf span}(G_k), \ \text{where} \ G_k=
\lbrace b_j | l+1\leq j \leq k\rbrace \cup 
\lbrace ab_j | k\leq j \leq r\rbrace \ \text{for} \ l+1\leq k\leq r \\
(ii) & \lbrace b_l,ab_l \rbrace \ \cup aH \ \text{is linearly independent, where} \ 
H=\lbrace b_j | l+1\leq j \leq r\rbrace 
\end{array}
$$
Before finding a vector satisfying both (i) and (ii), let us note that we can
separately find vectors satisfying just (i) and vectors satisfying just (ii). For (i)
this is a well-known linear algebra exercise, that the union of strict subspaces is never equal to the whole subspace on an infinite base field. Also (ii) can be rephrased
as : $\lbrace \pi b_l,\pi a b_l \rbrace$ is linearly independent, where $\pi$ is the
canonical projection $\pi : {\mathbb R}^n \to \frac{{\mathbb R}^n}{{\sf span}(aH)}$. Note that
$\pi a$ is injective on $K={\sf span}(c_1,\ldots,c_l)$, and since
the dimensions of $K$ and $\frac{{\mathbb R}^n}{{\sf span}(aH)}$ coincide, $\pi a$ is a linear isomorphism. If $\lbrace \pi k,\pi a k \rbrace$ is linearly dependent for every
$k\in K$, another well-known linear algebra exercise shows that there is a constant
$\lambda$ such that $\pi a k=\lambda \pi k$ for every $k\in K$.  In this situation,
$k+h$ satisfies (ii) for any $k\in K$ and any $h\in{\sf span}(H)$.
Finally, we note that all the conditions in (i) or (ii) are polynomial, of the form $q(x_1,\ldots,x_n)\neq 0$ where $q$ is a polynomial. Since
each condition can be satisfied separately, each polynomial is nonzero, so their
product is nonzero, showing that some vector will satisfy all the conditions at once.
This finishes the proof.
