If I have an $N\times N$ idempotent matrix, how many degrees of freedom does it have? (For example, a non-special $N\times N$ matrix would have $N^2$ degrees of freedom).
Also, would it be possible to create a generator function for these matrices? Assuming $N>1$, there must be less than $N\times N$ degrees of freedom for an idempotent matrix; let’s call that number $D$.
Would it be possible to create a formula that takes $D$ input numbers but whose domain covers the entire space of all $N\times N$ idempotent matrices? (It would take $D$ numerical arguments and output an $N\times N$ idempotent matrix)
An idempotent matrix is diagonalizable with eigenvalues that are all either $1$ or $0$. Conversely, any matrix of the form $BDB^{-1}$ with invertible $B$ and diagonal $D$ with entries all either $1$ or $0$ is idempotent.
Thus you can construct an idempotent matrix by
Although all idempotent matrices can be obtained in this manner, there will be some redundancy in the above "generator," since, for instance, the order of the eigenvalues/eigenvectors can be shuffled without affecting the resulting idempotent matrix.
I suppose a more abstract way to think about this is to find two subspaces $W_1$ and $W_0$ such that $W_1 \oplus W_0 = \mathbb{R}^n$ (i.e., the two subspaces span $\mathbb{R}^n$ and have intersection $\{0\}$), and define your idempotent matrix to have its $1$-eigenspace to be $W_1$ and its kernel to be $W_0$.
Finally, the collection of idempotent matrices does not form a linear subspace of the vector space of $n \times n$ matrices, so I am not sure a simple notion of "degrees of freedom" can be obtained, although I may be wrong.