TITLE: Relation between trace and rank for projection matrices
QUESTION [15 upvotes]: If $A $ is  an  $n \times n$  matrix  over $\mathbb C$ such that $A^2=A$ then is it true  that  $\operatorname{trace} A = \operatorname{rank} A$?

REPLY [2 votes]: Here is a marginally different perspective:
If $Av = \lambda v$ for some non zero $v$, then $Av = \lambda Av$ so we must have either $\lambda = 1$ or $\lambda = 0$. Hence
$\operatorname{tr} A$ is the algebraic multiplicity of the 1 eigenvalue in the characteristic polynomial.
Note that $\ker A^m = \ker A$ for all $m \in \mathbb{N}$, so the Jordan block corresponding to the zero eigenvalue has size $\nu = \dim \ker A$.
Hence $\dim {\cal R} A = n - \dim \ker A = n - \nu$, and from above, we see that
the algebraic multiplicity of the 1 eigenvalue must be $n -\nu$, hence
$\operatorname{tr} A= \dim {\cal R} A$.