I would like to generalize the group of matrices of order $n\times n$, $A,B$ such that $\text{rk}(AB)=\text{rk}(BA)$. I'm pretty sure that if $AB$ and $BA$ are nonzero, the condition will hold. (clearly if $AB=0$ or $BA=0$ we can find counter-examples). I was thinking for some time and couldn't find any proof at all. I would like to get your help! Thanks!
Note: This wasn't asked here before! others have asked for counter-example for general $\text{rk}(AB)=\text{rk}(BA)$, but I added a condition.
Let's try and find two $3\times3$ matrices $A$ and $B$ such that the rank of $AB$ is $1$ and the rank of $BA$ is $2$: $$ A=\begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 0 \end{bmatrix} \qquad B=\begin{bmatrix} 1 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix} $$ Then $$ AB=\begin{bmatrix} 1 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix} \qquad BA=\begin{bmatrix} 1 & 0 & 0 \\ 0 & 0 & 0 \\ 0 & 1 & 0 \end{bmatrix} $$