When 2 matrices commute and have the same rank

matricesmatrix-rank

When 2 matrices commute and have the same rank?

I know that $AB = BA$ when:

1.$ A=B$.
2.Either $A=cI$ or $B=cI.$
3.$A$ and $B$ are both diagonal matrices.
4.There exists an invertible matrix $P$ such that $P^{-1}AP$ and $P^{-1}BP$ are both diagonal.
5.$A = cB.$
6.$A = cB^{-1}.$
7.$A = 0$ or $B = 0.$

But couldn't go further to find when $AB=BA$ and they both have the same rank.
Any help would be appreciated.

EDIT :

In case it would help to answer, I need to find all the pairs of matrices $(A, B)$ that respect the following equations $AB = aA + bB$, where $A, B$ are 2 matrices and $a, b ∈ C^*.$ My hypothesis was that these 2 must first commute and have the same rank in order to respect the equations.

Best Answer

Let $C=b^{-1}A$ and $D=a^{-1}B.$ Then $CD=C+D$ and $C(D-I)=D.$ Thus $\ker (D-I)\subset \ker D.$ Hence $\ker(D-I)=\{0\},$ i.e. $D-I$ is invertible and consequently $C=D(D-I)^{-1}.$ Therefore $C$ and $D$ commute and their ranks coincide.

Summarizing the equation $CD=C+D$ admits solutions of the form $C$ and $D,$ where $D$ is any matrix so that $D-I$ is invertible and $C=D(D-I)^{-1}.$

In terms of $A$ and $B,$ the matrix $B-aI$ must be invertible and $A=bB(B-aI)^{-1}.$