If $A$ and $B$ have the same rank and $A^2=A$ and $B^2=B$, prove that $A$ and $B$ are similar. Let $A$ and $B$ be $n \times n$ matrices over a field $F$ such
that $A^2 = A$ and $B^2 = B$. Suppose that $A$ and $B$ have the same rank. Prove that $A$ and $B$ are similar.
My Attempt (with Lord Shark's hint):
Both $A$ and $B$ are clearly diagonalizable since their minimal polynomials, which must divide $x^2-x$ factors into distinct linear factors, so they are diagonalizable. 
We can write $A = P_1D_1P_1^{-1}$ and $A = P_2D_2P_2^{-1}$ and there is a nice diagonal matrix $D$ such that $D_1 = DD_2$. But I can't seem to massage this into $A$ and $B$ are diagonal.
 A: If $M^2=M$, then the minimal polynomial of $M$ divides $\lambda(\lambda-1)$. Split your work into cases. 
Note that it cannot be that $A$ has minimal polynomial $\lambda$ while $B$ has minimal polynomial $\lambda-1$ (or the other way around), for then they have different rank.


*

*Case one: $A$ and $B$ both have minimal polynomial $\lambda$


Then each matrix is the zero matrix, and they are obviously similar.


*

*Case two: $A$ and $B$ both have minimal polynomial $\lambda-1$


Then each matrix is the identity matrix, and they are obviously similar.


*

*Case three: $A$ and $B$ both have minimal polynomial $\lambda(\lambda-1)$


Then $A$ and $B$ are each diagonalizable with eigenvalues $0$ and $1$, with rank equal to the number of $1$'s along their diagonalizations. So we can bring each matrix into a diagonal form where all the $1$'s on the main diagonal precede all the $0$'s. So there are change-of-basis matrices $P$ and $Q$ such that $$PAP^{-1}=QBQ^{-1}\implies A=(P^{-1}Q)B(P^{-1}Q)^{-1}$$
Hence $A$ and $B$ are similar.
