# Some use this matrix to disprove that the number of eigenvalues is equal to rank.

Claim: For any matrix, the number of non-zero eigenvalues – including algebraic multiplicity – seems to always be equal to the rank of the matrix. Here is a non-counterexample:

$$\begin{bmatrix} 3 & 0 & 0 \\ 0 & 3 & 0 \\ 0 & 0 & 3 \end{bmatrix}$$

The above matrix has an eigenvalue of 3 with an algebraic multiplicity of 3. The rank is also three. I have read about this topic: What is the relation between rank of a matrix, its eigenvalues and eigenvectors

However, I see a few people use this counterexample:

$$\begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}$$

They claim: (1) the rank is 1, and (2) the eigenvalue is 0 with an algebraic multiplicity of 2. I dispute the latter.

Why not just switch row 1 and row 2?

Is there something illegal about that? Then the rank would still be 1 and the eigenvalues would be 1 and 0. Thus, the claim that the number of non-zero eigenvalues is the rank of a matrix holds true.

Is there a better counterexample matrix that disproves my original claim?

Because that changes the eigenvalues, their multiplicities (geometric and algebraic), and the eigenspaces. Elementary row operations do not preserve eigenanythings. Note that $$1$$ is now an eigenvalue, and $$0$$ is now has multiplicity $$1$$.
Fun fact: what does work is, for every elementary row operation you perform, you perform immediately afterwards the corresponding inverse elementary column operation! For example, if you multiply the $$i$$th row by $$\alpha \neq 0$$, then divide the $$i$$th column by $$\alpha$$. This will actually preserve eigenvalues (but not eigenvectors).
So, in your example, after swapping the rows, if you swap the columns, you get $$\begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}$$ which is another counterexample with rank $$1$$ and eigenvalue $$0$$ with multiplicity $$2$$.
• @Matthew I'm not sure I know what you mean by samples and features, but no, it doesn't work the way you thought it did. Note that every non-singular square matrix is row-equivalent to the identity matrix, so if you could just apply whatever row operations you wished, then every matrix would have only the eigenvalue $1$ (or basically, whatever non-zero eigenvalues you wanted). Commented May 20, 2020 at 6:42
• @Matthew Think of matrix as representing a function acting on a vector. So the effect of $A=\begin{bmatrix}0&1\\0&0\end{bmatrix}$ on $\mathbf{x}=\begin{bmatrix}x\\y\end{bmatrix}$ is $A\mathbf{x}=\begin{bmatrix}y\\0\end{bmatrix}$, whereas that of $B=\begin{bmatrix}0&0\\0&1\end{bmatrix}$ on $\mathbf{x}=\begin{bmatrix}x\\y\end{bmatrix}$ is $B\mathbf{x}=\begin{bmatrix}0\\y\end{bmatrix}$. Thus row operations can change the function and hence the eigen values/vectors etc. Commented May 20, 2020 at 6:43