Show that Rank $(A)$ = Rank$(A^2)$ $\iff \exists$ B invertible s.t. $A^2= B A$. Given $n \times n$ matrix $A$, not necessarily invertible, what invertible matrix $B$ solves $A^2= B A$?
$B$ should be $A$ but that is what not being said in the claim above. Please help. Thanks in advance.
 A: $\DeclareMathOperator{\rank}{rank}$
$\DeclareMathOperator{\Im}{Im}$
Let $F$ be the underlying field.
Recall that $\rank(M) = \dim(\Im(M))$. Now $\Im(A^2)$ is a subspace of $\Im(A)$ that has the same dimension; then $\Im(A^2) = \Im(A)$. Choose a basis of $\Im(A)$ and choose a basis $k$ of $F^n$ which contains the chosen basis of $\Im(A)$.  Then define a linear map $g : F^n \to F^n$ which sends elements $x \in k$ which are in $\Im(A)$ to $Ax$, and which sends elements $x \in k$ which are not in $\Im(A)$ to $x$. Then $g$ is invertible; furthermore, for $x \in \Im(A)$, $g(x) = Ax$. Pick its matrix representation $B$ in the standard basis. Then $BA = A$ and $B$ is invertible.
A: Here's a more explicit matrix proof.  The key idea is
$d =\text{rank}\big(A^2\big) = \text{rank}\big(A\big)\longrightarrow \text{im} \big(A\big) \cap \ker \big(A\big) =\{\mathbf 0\}$
The former is generated by $\{\mathbf q_1, \mathbf q_2,...,\mathbf q_d\}$ while the latter is generated by $\{\mathbf q_{d+1}, \mathbf q_{d+2},...,\mathbf q_n\}$.  Collect these in matrix $Q$.
$ A $
$=  A  Q Q^{-1} $
$=  A \bigg[\begin{array}{c|c|c|c|c|c} 
\mathbf q_1 & \mathbf q_2 &\cdots & \mathbf q_{d} & \mathbf q_{d+1} &\cdots & \mathbf q_{n} 
\end{array}\bigg] Q^{-1} $
$=  \bigg[\begin{array}{c|c|c|c|c|c} 
 A\mathbf q_1 & A\mathbf q_2 &\cdots & A\mathbf q_{d} & \mathbf 0 &\cdots & \mathbf 0 
\end{array}\bigg] Q^{-1}   $
$=Q\begin{bmatrix}C_d &\mathbf 0\\ \mathbf 0 &\mathbf 0\end{bmatrix}Q^{-1}$
for some $d \times d$ matrix $C_d$
$d=\operatorname{rank}\big(A\big)=\operatorname{rank}\left(Q\begin{bmatrix}C_d &\mathbf 0\\ \mathbf 0 &\mathbf 0\end{bmatrix}Q^{-1}\right)=\operatorname{rank}\big(C_d\big)$ i.e. $C_d$ is invertible.
now we may select e.g.
$B:=Q\begin{bmatrix}C_d &\mathbf 0\\ \mathbf 0 &I_{n-d}\end{bmatrix}Q^{-1}$
where $B$ is invertible and $AB=BA = A^2$
A: We have yet to see that the converse is true, so here is a bit about that.
Consider an $n \times n$ matrix over the field $k.$ Given an invertible matrix $B$ such that $A^2 = BA,$ we claim that $\ker(A^2) = \ker(BA) = \ker(A).$ Certainly, we have that $\ker(A) \subseteq \ker(A^2),$ as any vector $v$ such that $Av = 0$ gives $A^2 v = A(Av) = A(0) = 0.$ Conversely, for $v \in \ker(A^2) = \ker(BA),$ then we have that $0 = (BA)v = B(Av)$ so that $Av$ is in $\ker(B).$ But as $B$ is invertible, we must have that $Av = 0$ so that $v \in \ker(A).$ By the Rank-Nullity Theorem, we have that $$\operatorname{rank}(A^2) + \operatorname{nullity}(A^2) = n^2 = \operatorname{rank}(A) + \operatorname{nullity}(A),$$ but in view of the fact that $\ker(A^2) = \ker(A),$ we find that $\operatorname{rank}(A^2) = \operatorname{rank}(A).$
A: The equation $A^2=BA$ can be rewritten as
$$(B-A)A=0. \tag{*}$$
Let's define $C=B-A$, that is, $B=A+C$. So what properties does $C$ need to have?
Let's first consider a vector $v$ in the image of $A$, that is, there exists a vector $w$ such that $w=Av$. But then we have $Cv = CAw = 0$ because of $(*)$.
On the other hand, be $v$ a non-zero vector orthogonal to the image of $A$. Then $Bv = Av + Cv = Cv$. But $B$ is invertible, therefore $Bv\ne 0$.
Therefore the kernel of $C$ is exactly the image of $A$.
Finally we have the condition $\operatorname{rank} A=\operatorname{rank} (A^2)$. Clearly $\operatorname{im}(A^2)\subseteq\operatorname{im} A$. Now since the rank is the dimension of the image, and a finite dimensional subspace has the same dimension as the full space only if it is the full space, we get
$$\operatorname{im} A = \operatorname{im}(A^2).$$
This implies that the image and kernel of $A$ intersect only on the zero vector.
Now using all the above, I claim that if $P$ is the orthogonal projection onto the image of $A$, then $C=I-A$ (where $I$ is the identity matrix) gives the desired matrix, which therefore exists.
Proof:

*

*$BA=A^2$:
By definition of $P$, we have $PA=A$. Therefore we have
$$CA = (I-P)A = IA-PA = A-A = 0. \tag{(**)}$$
And therefore we get
$$BA = (A+C)A = A^2 + CA = A^2$$


*$B$ is invertible:
Be $v\ne 0$. Then we have
\begin{align}
Bv &= (A+C)v\\
   &= (P+C)(A+C)v && \text{because $P+C=I$}\\
   &= PAv + CAv + PCv + C^2v \\
   &= Av + CPAv + PCv + C^2v && \text{$PA=A$ by definition of $P$}\\
   &= Av + Cv && \text{$CP=PC=0, C^2=C$}
\end{align}
Now $Av$ clearly lies in the image of $A$, while $Cv$ lies in the kernel of $A$. But as we have seen above, image and kernel of $A$ only intersect in the zero vector, that is, $Av$ and $Cv$ are linearly independent. Therefore $Av+Cv=0$ implies both $Av=0$ and $Cv=0$. But since the kernel of $C$ is the image of $A$, $Cv=0$ implies that $v$ is in the image of $A$, which in turn implies that $Av\ne 0$.
So we see that $v\ne 0$ implies $Bv\ne 0$, therefore $B$ is invertible. $\square$
