Find the probability that a matrix is diagonalizable

(I'm assuming $\Bbb Z_p$ means the integers modulo $p$ rather than the $p$-adic integers)

First let's do some simple counting.

  • The cardinality of $M_{2\times 2}(\Bbb Z_p)$ is $p^4$.
  • The cardinality of $GL_{2\times 2}(\Bbb Z_p)$ is $(p^2-1)(p^2-p)=p(p+1)(p-1)^2$.
  • The center of $GL_{2\times 2}(\Bbb Z_p)$ has cardinality $p-1$.
  • The cardinality of the diagonal matrices are $(p-1)^2$.

Now let's count the number of diagonalizable matrices. A matrix $A$ is diagonalizable if there is a $B\in GL_{2\times 2}(\Bbb Z_p)$ such that $BAB^{-1}$ is diagonal. We would be mistaken to say the number of diagonalizable matrices is $(p-1)^2\cdot p(p+1)(p-1)^2$ because we could have two different invertible matrices $G$ and $H$ such that $GAG^{-1}=HAH^{-1}$. However, if we have such a $G$ and $H$, they satisfy a non-trivial relation. Namey $A(G^{-1}H)=(G^{-1}H)A$. That is $A$ commutes with $G^{-1}H$. Thus $G^{-1}H$ is in the centralizer of $A$. Now $G^{-1}H$ is in the centralizer of $A$ if and only if $G$ and $H$ lie in the same coset of the centralizer of $A$. And the number of cosets of the centralizer of $A$ is $|GL_{2\times 2}(\Bbb Z_p)|/|Z(A)|$ where $Z(A)$ is the centralizer of $A$.

Another reason that $(p-1)^2\cdot(p+1)(p-1)^2$ is wrong is that there could be diagonal matrices which are similar. This happens if the eigenvalues on the diagonal are the same. So to avoid double counting, we will only consider diagonal matrices whose eigenvalues are weakly increasing. Thus, to find the number of diagonalizable matrices it suffices to figure out how to count $|Z(A)|$ for each matrix $A$, for then the number of diagonalizable matrices is $$\sum_{\substack{D\text{ diagonal}\\\text{increasing}}}\frac{(p^2-1)(p^2-p)}{|Z(D)|}$$

For elements of the center (which are diagonal matrices with a single non-zero scalar occuring) computing the center is easy - it's the whole group. Thus we have that the number of diagonalizable matrices is:

$$p-1+\sum_{\substack{D\text{ diagonal}\\\text{not central}\\\text{increasing}}}\frac{(p^2-1)(p^2-p)}{|Z(D)|}$$

That is, we want to compute $|Z(D)|$ for a matrix of the form $\left[\begin{smallmatrix}\lambda_1 & 0\\ 0 &\lambda 2\end{smallmatrix}\right]$ with $\lambda_1<\lambda_2$ (this is speaking loosely. There is no real order on $\Bbb Z_p$).

Now we abandon theory and actually do some 'dirty computation'. Another matrix $G\in GL_{2\times 2}(\Bbb Z_p)$ commutes with such a matrix if and only if $G=\left[\begin{smallmatrix}a &0\\0& b\end{smallmatrix}\right]$ for $a, b\in \Bbb Z_p^*$.

There are $(p-1)^2$ such matrices for a single matrix $D$. Thus our formula is now: $$p-1+\sum_{\substack{D\text{ diagonal}\\\text{not central}\\\text{increasing}}}\frac{(p^2-1)(p^2-p)}{(p-1)^2}=p-1+\sum_{\substack{D\text{ diagonal}\\\text{not central}\\\text{increasing}}}p(p+1)$$

Now we need to calculate the number of diagonal, non-central, (strictly) increasing matrices (we took care of the central matrices). There are $1+\cdots + (p-2)=(p-2)(p-1)/2$ such matrices. Thus we arrive at $$p-1+\frac{(p-1)(p-2)}{2}p(p+1)=\frac{p^4}{2}-p^3-\frac{p^2}{2}+2p-1$$

So for b) the probability that a matrix is diagonalizable is

$$1/2-1/p-1/2p^2+2/p^3-1/p^4$$

which interestingly approaches probability 1/2 as $p\rightarrow\infty$.

For a) recall a matrix's characteristic polynomial splits if and only if $\Bbb Z_p^2$ has a basis of generalized eigenvalues of the matrix. This is equivalent to a matrix being similar to a matrix in Jordan normal form. For a vector space of dimension two this is simple. You can rework what I did for Jordan normal matrices. You just need to consider matrices of the form $\left[\begin{smallmatrix}\lambda & 1\\0&\lambda\end{smallmatrix}\right]$ in addition.

Or you can read this paper which investigates a much more general question and actually does your problem as a simple case.

The number of matrices similar to a Jordan normal matrix is $$\frac{p^4}{2}+p^3-\frac{p}{2}$$ and the probability of $f_A$ splitting is

$$1/2+1/p-1/2p^3$$

UPDATE

As Julian Rosen remarked in the comments, there are diagonalizable matrices with $0$ as an eigenvalue. My answer only computes the invertible diagonalizable matrices. This gives another element in the 'center' and $p(p-1)/2$ diagonal, strictly increasing, matrices.

The updated computation is:

$$p+\frac{p(p-1)}{2}\cdot p(p+1)=\frac{p^4}{2}-\frac{p^2}{2}+p$$

which yields the probability

$$\frac{1}{2}-\frac{1}{2p^2}+\frac{1}{p^3}$$

the same as Julian Rosen posted.

The paper I linked took into the account the matrices $\left[\begin{smallmatrix} 0&0\\0&0\end{smallmatrix}\right]$ and $\left[\begin{smallmatrix} 0&1\\0&0\end{smallmatrix}\right]$. So that computation is still correct.


Say $A=(a,b; c,d)\in M_2(\mathbb{F}_p)$. The characteristic polynomial splits if and only if the discriminant of the characteristic polynomial, $(a+d)^2-4(ad-bc)$, is a square in $\mathbb{F}_p$. Consider two cases:

Case 1 ($b\neq 0$) There are $(p+1)/2$ squares in $\mathbb{F}_p$, and for fixed $a,b,d$, the map $c\mapsto (a+d)^2-4(ad-bc)$ is bijective on $\mathbb{F}_p$, so the discriminant is a square with probability $(p+1)/(2p)$.

Case 2 ($b=0$) In this case the discriminant is $(a-d)^2$ (always a square).

Case 1 happens with probability $(p-1)/p$ and Case 2 with probability $1/p$, so the probability the characteristic polynomial splits is $$ \frac{p-1}{p}\frac{p+1}{2p}+\frac{1}{p}1=\frac{1}{2}+\frac{1}{p}-\frac{1}{2p^2}. $$

To compute the probability of diagonalizability: a $2\times 2$ matrix has a defective eigenvalue if and only if it is of the form $\lambda\cdot I+M$, with $\lambda\in\mathbb{F}_p$, $I$ the $2\times 2$ identity matrix, and $M$ a non-zero matrix having 0 as an eigenvalue with multiplicity 2. Let’s count the number of such $M$. One checks that $M$ must have the form $M=(a,b;c,-a)\neq 0$, with $a^2+bc=0$.

If $a=0$ we need $b=0$ or $c=0$ but not both, so there are $2(p-1)$ possibilities.

For fixed $a\neq 0$, we need $bc=-a^2$, so each non-zero $b$ determines a values of $c$, giving $p-1$ possibilities. There are $p-1$ possibilities for $a$, so there are $(p-1)^2$ matrices of this form (with $a\neq 0$). This gives a total of $2(p-1)+(p-1)^2=p^2-1$ matrices $M$. There are $p$ possible values of $\lambda$, so we get $p(p^2-1)$ matrices with a defective eigenvalue. A matrix is diagonalizable if and only if its characteristic polynomial splits and there are no defective eigenvalues, so the probability a matrix is diagonalizable is $$ \frac{1}{2}+\frac{1}{p}-\frac{1}{2p^2}-\frac{p(p^2-1)}{p^4}=\frac{1}{2}-\frac{1}{2p^2}+\frac{1}{p^3}. $$