$M_n(F)$ is the set of all $n\times n$ matrices over field $F$. Suppose $A\in M_n(F)$. Show that: $$A^2=A \iff \text{rank}(A)+\text{rank}(A-I)=n$$ Actually I'm somehow new to linear algebra and I'm not familiar with its techniques. I tried to find row/column spaces of $A$ and $A^2$ or $A-I$ and find their basis. But I wasn't that much successful. Also I tried to connect this problem to linear transformations, but I counldn't find out how.
Any help ot hints is so much appreciated.
Assuming you know how to diagonalize a matrix:
Notice that $A^2=A$ if and only if $A(A-I)=0$, which is equivalent to the minimal polynomial of $A$ dividing $x(x-1)$. So $A$ has to be diagonalizable and its eigenvalues are all included in the set $\{0,1\}$. Assume that the multiplicity of $0$ as an eigenvalue is $k$ and therefore of $1$, as an eigenvalue, is $n-k$. Since $k=\dim(\ker(A))=n-\operatorname{rank}(A)$ and $n-k=\dim(\ker(A-I))=n-\operatorname{rank}(A-I)$ we have that $$\operatorname{rank}(A)+\operatorname{rank}(A-I)=(n-k)+k=n$$