It is well-known and can easily be proven that if a matrix $A$ is idempotent, then its trace equals its rank:
$$ A^2 = A \Rightarrow \mathrm{tr}(A) = \mathrm{rk}(A) $$
Does the inverse also hold? If yes, how can this be proven?
It is well-known and can easily be proven that if a matrix $A$ is idempotent, then its trace equals its rank:
$$ A^2 = A \Rightarrow \mathrm{tr}(A) = \mathrm{rk}(A) $$
Does the inverse also hold? If yes, how can this be proven?
The trace is linear, so we can achieve any desired value by simply multiplying $A$ by some scalar as long as $\operatorname{tr}(A)≠0$. For instance, $\widetilde{A}≔\tfrac{\operatorname{rk(A)}}{\operatorname{tr}(A)}A$ trivially satisfies $\operatorname{tr}(\widetilde{A}) = \operatorname{rk}(\widetilde{A})$.
The idea is $A$ is idempotent if and only if it has eigenvalues $0,1$, but the converse condition cannot ensure. So we can construct a counterexample with non-zero and non-one eigenvalues. For example, consider $$A=\begin{pmatrix}3 & 0 \\ 0 & -1\end{pmatrix}$$which you can see $A$ has rank $2$ and $\operatorname{tr}(A)=2$, but $A^2\ne A$.