# Is the rank of $AB$ always equal to the rank of $BA$?

I know that matrix multiplication is not commutative: $A \cdot B \neq B \cdot A$

Still, it may be possible that $\operatorname {rank} (A \cdot B) = \operatorname {rank} (B \cdot A)$ . But it seems to be not true.

How can it be proved that $\operatorname {rank} (A \cdot B) \neq \operatorname {rank} (B \cdot A)$ ?

(Usually it's not a big deal to prove a negative statement since it only take to find one example when the equality is not satisfied)

-
Hint: you can do this with two-by-two matrices. Look for $A$, $B$ such that $AB=0$ but $BA \neq 0$. – Chris Eagle Oct 31 '11 at 22:31
Try working with a single column full of $1$s and $0$s and a single row full of $1$s and $0$s. For ease, perhaps do the case where each is $2\times 1$ or $1\times 2$. – Jason DeVito Oct 31 '11 at 22:32
Why do you think that this seems not to be true? To prove that something is not true in general, you need to find a single counterexample... – N. S. Oct 31 '11 at 22:32
An other question is: determine $\max_{A\in\mathcal M_{n,p}(\mathbb R),B\in\mathcal M_{p,n}(\mathbb R)}\operatorname{rank}(A\cdot B)-\operatorname{rank}(B\cdot A)$ in terms of $n$ and $p$. – Davide Giraudo Oct 31 '11 at 22:52
@JasonDeVito Thanks for the hit. I made an answer basing on it. Still, I want some intuition why it's so. We can look on the first matrix in a multiplication as on some operator. And why if A operates on B the rank is r1 and when B operates on A is r2, and r1 is not equal to r2. The proof is a good thing, but it'll be forgotten over time. And only intuition is what will be carried over time. – ovgolovin Oct 31 '11 at 22:55

Let $A=\pmatrix{0&1\\0&0}$ and let $B=\pmatrix{1&0\\0&0}$. These are matrices of simple geometric transformations.

If $v$ is a point in the plane, viewed as a vector, then $Bv$ is the projection of $v$ on the $x$-axis.

And if $w$ is a point in the plane, then $Aw$ is projection onto the $y$-axis, followed by reflection in the line $y=x$.

Now look at $A(Bv)$. We have (i) projected $v$ onto the $x$-axis, and then (ii) projected the result onto the $y$-axis, then reflected in the line $y=x$. Before the reflection, we are already at $(0,0)$, so $AB$ kills every vector.

Look next at $B(Av)$. If the $y$-component of $v$ is non-zero, $Av$ is a non-zero point on the $x$ axis, and the projection $B$ does nothing to $Av$. Thus $B(Av)$ is not the $0$-vector for "most" $v$.

-

To prove that $\operatorname {rank} ( A \cdot B) \not= \operatorname {rank} ( B \cdot A)$ we just need to find one example when the equality is not satisfied.

As suggested in the comments to the answer, let's take $A = \begin{pmatrix} 0 & 1\\ 0 & 1 \end{pmatrix}$ and $B = \begin{pmatrix} 1 & 1\\ 0 & 0 \end{pmatrix}$.

$A \cdot B = \begin{pmatrix} 0 & 0\\ 0 & 0 \end{pmatrix}$ ; $\operatorname {rank} ( A \cdot B) = 0$ .

$B \cdot A = \begin{pmatrix} 0 & 2\\ 0 & 0 \end{pmatrix}$ ; $\operatorname {rank} ( B \cdot A) = 1$ .

The ranks don't match, so $\operatorname {rank} ( A \cdot B) \not= \operatorname {rank} ( B \cdot A)$ .

-
$A.B$ is surely [[1, 0], [0, 0]] – Peter Taylor Oct 31 '11 at 23:09

You asked for "intuition". One way of looking at it is this.
An $m \times n$ matrix $A$ operates on $n$-dimensional vectors, taking them to $m$-dimensional vectors. The rank $r_A$ of $A$ is the dimension of the range of $A$, and is also $n$ minus the dimension of the kernel of $A$. That is, you start with $n$ linearly independent vectors $v_j$ spanning ${\mathbb R}^n$; the images $A v_j$ of them under $A$ are not linearly independent, because there are $k$ independent relations between them corresponding to the dimension of the kernel of $A$, so we have only $r_A = n - k$ linearly independent vectors spanning the range of $A$. Now in $BA$, $B$ operates on these vectors so the rank of $BA$ is the number of linearly independent vectors in the range of $BA$. This is reduced from $r_A$, not by the dimension of the kernel of $B$, but by the dimension of the intersection of the kernel of $B$ with the range of $A$. That is, $\text{rank}(BA) = \text{rank}(A) - \dim(\ker (B) \cap \text{range}(A))$. Similarly ($B$ being $n \times m$ so that $AB$ and $BA$ both make sense) $\text{rank}(AB) = \text{rank}(B) - \dim(\ker(A) \cap \text{range}(B))$. And there is no reason for these to be the same.

Indeed, given $n$ and the ranks of $A$ and $B$, $\ker(A)$ and $\text{range}(B)$ can be any subspaces of ${\mathbb R}^n$ of dimensions $n - \text{rank}(A)$ and $\text{rank}(B)$ respectively, and their intersection can have any dimension from $\max(\text{rank}(B) - \text{rank(A)},0)$ to $\min(n - \text{rank}(A),\text{rank}(B))$.

For example, if $m=n = 5$ and $\text{rank}(A) = \text{rank}(B) = 3$, $\dim(\ker(A) \cap \text{range}(B)$ can have any dimension from 0 to 2, making $\text{rank}(AB)$ anything from 1 to 3, and similarly $\text{rank}(BA)$ can be anything from 1 to 3. To get an example with $\text{rank}(AB) = 3$ and $\text{rank}(BA) = 1$, you want $\ker(A)$ and $\text{range}(B)$ to be subspaces of ${\mathbb R}^5$ of dimensions 2 and 3 respectively with intersection of dimension 0, while $\ker(B)$ and $\text{range}(A)$ are subspaces of dimensions 2 and 3 with intersection of dimension 2. If $e_1$ to $e_5$ are the standard basis vectors of ${\mathbb R}^5$, you could for example have $\ker(A) = \text{span}(e_1,e_2)$ while $\ker(B) = \text{span}(e_4,e_5)$ with $\text{range}(A) = \text{range}(B) = \text{span}(e_3, e_4, e_5)$. Thus we could have $$A= \left[ \begin {array}{ccccc} 0&0&0&0&0\\ 0&0&0&0&0 \\ 0&0&1&0&0\\ 0&0&0&1&0 \\ 0&0&0&0&1\end {array} \right], \ B = \left[ \begin {array}{ccccc} 0&0&0&0&0\\ 0&0&0&0&0\\ 1&0&0&0&0\\ 0&1&0&0&0 \\ 0&0&1&0&0\end {array} \right]$$

-
Thank you for the answer. I even started watching videos on the Khan Academy site about the nullspace of a matrix after reading you answer! After watching this video I'll recur to your answer and hope I'll managed to grasp it completely. – ovgolovin Nov 1 '11 at 23:26