Prove that $r(A)=\operatorname{tr}(A^2)$ Let $A\in M_n(\mathbb{C})$. Show that if $A^3=A$, then $r(A)=\operatorname{tr}(A^2)$.

Since $A^3=A$, the possible eigenvalues are $0,1,-1$. I don't know from here how to compute the rank of $A$.
Edited
Since eigenvalues of $A$ are $0,1,-1$ SO eigenvalues of $A^2=0,1$ So $r(A^2)=tr(A^2)$ Now we have to show $r(A^2)=r(A)$ where rank of $A^2$ is the number of non-zero eigenvalues .

The rank is the number of nonzero eigenvalues and as their squares are 0 or 1, this number is just the same as the sum of the squares.
