Relation between trace and rank for projection matrices
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$?
Solution 1:
Easy to show (for example, from Jordan normal form): $\lambda_k^2 = \lambda_k$, i.e., $\lambda_k \in \{0, 1\}$ are the eigenvalues of $A$. The trace is the sum of all eigenvalues and the rank is the number of non-zero eigenvalues, which - in this case - is the same thing.
Solution 2:
Yes it's true. Notice that $A$ is diagonalizable since the polynomial with simple roots $x^2-x$ annihilates it and the eigenvalues of $A$ belong to the set $\{0,1\}$ so $A$ is similar to $\operatorname{diag}(\underbrace{1,\ldots,1}_{r\;\text{times}},0,\ldots,0)$ hence we see that
$$\operatorname{rank}(A)=r=\operatorname{trace}(A)$$