# Counting diagonalizable matrices in $\mathcal{M}_{n}(\mathbb{Z}/p\mathbb{Z})$

How many diagonalizable matrices are there in $\mathcal{M}_{n}(\mathbb{Z}/p\mathbb{Z})$ ? Where $p$ is a prime number.

Attempt : By definition a matrix is called diagonalizable if there exists an invertible matrix $P$ such that $P^{−1}AP$ is diagonal. Given that the number of non-singular matrices of $\mathcal{G}\mathcal{L}_{n}(\Bbb{Z}/p\Bbb{Z})$ is $\prod\limits^{n-1}_{i=0}(p^{n}-p^{i})$, we can prove this by counting the number of basis of $\Bbb{Z}/p\Bbb{Z}^{n}$. And the number of diagonal matrices is $p^n$. So basically I would say that the result is $$\prod\limits^{n-1}_{i=0}(p^{n}-p^{i})\times p^{n}.$$

Does I miss something ?

EDIT : Ok it's wrong according to Blue comments.

• Why do you think that counts the number of diagonal matrices? Use your words! – blue Aug 12 '14 at 22:57
• @blue My first sentence is the definition, after that it's my words! Second comment : You are right. NB : No need to be rude. – user146010 Aug 12 '14 at 23:05
• (You explained how to count the number of invertible matrices and diagonalizable matrices, but did not say why you thought multiplying those two numbers counted the number of diagonalizable matrices. That is what my comment is getting at.) – blue Aug 12 '14 at 23:11

Your formula assumes that diagonal matrices can be represented as $PDP^{-1}$ for some diagonal matrix $D$ and invertible matrix $P$ uniquely. This is not true: $D$ is unique, but $P$ isn't.

Without loss of generality we can work over arbitrary $\Bbb F_q$; this adds no difficult.

We need to compute the size of the orbit of a given diagonal matrix under the action of ${\rm GL}_n(\Bbb F_q)$ and then sum over all possible diagonal matrices modulo permutation. By the orbit-stabilizer theorem, the size of an orbit is equal to $|{\rm GL}_n(\Bbb F_q)|$ divided by the stabilizer of a given matrix.

Given a diagonal matrix ${\rm diag}(\lambda_1,\cdots,\lambda_n)$, which $P\in{\rm GL}_n(\Bbb F_q)$ act trivially on it by conjugation?

First thoughts: this is equivalent to $P\in {\rm GL}_n(\Bbb F_q)$ preserving the decomposition of $\Bbb F_q^n$ into eigenspaces, which means such $P$ are direct sums of arbitrary invertible maps on them.

Using this approach I get

$$\sum_{r=1}^n \binom{q}{r}\sum_{\substack{m\vdash n \\ {\rm len}(m)=r}}\langle m\rangle^r\frac{|{\rm GL}_n(\Bbb F_q)|}{|{\rm GL}_{m_1}(\Bbb F_q)|\cdots|{\rm GL}_{m_r}(\Bbb F_q)|}.$$

where $\langle m\rangle$ for my purposes denotes the number of distinct entires in the $r$-tuple $m$.

(Think I finally have it right.) Not sure how to simplify it though.

• Actually even $D$ is not unique : $\begin{bmatrix} \lambda_1 & 0 \\ 0 & \lambda_2 \end{bmatrix}$ is equivalent to (same matrix but swap $\lambda_1$ and $\lambda_2$). Just change the basis by swapping the two basis vectors. – Patrick Da Silva Aug 12 '14 at 23:28
• So you only have uniqueness of the set of eigenvalues, counted with multiplicity. – Patrick Da Silva Aug 12 '14 at 23:30