## Compute the Jordan canonical form of a given matrix over a finite field

Let $p$ be a prime. Compute the Jordan canonical form over the finite field $\mathbb{F}_p$ of the $n \times n$ matrix whose every entry is 1. ($n \geq 2$.)

Let $A = [1]$. Now the computation in this previous exercise holds over $\mathbb{F}_p$ (indeed, over any ring with 1), and so we have $A(A-nI) = 0$.

If $n$ is not divisible by $p$, then $n$ is a unit in $\mathbb{F}_p$. If $v = [v_1\ \ldots\ v_n]^\mathsf{T}$ is an eigenvector with eigenvalue $n$, then evidently (as we saw in the exercise referenced above) $v = v_1[1\ \ldots\ 1]^\mathsf{T}$. So the eigenspace of $n$ has dimension 1, the characteristic polynomial of $A$ is $x^{n-1}(x-n)$, and the Jordan canonical form of $A$ is $J = [b_{i,j}]$ where $b_{n,n} = n$ and $b_{i,j} = 1$ otherwise.

Suppose $p$ divides $n$. Since $A \neq 0$, the minimal polynomial of $A$ is now $x^2$. We claim that the remaining invariant factors of $A$ are $x$. There is probably a slick linear-algebraic way to argue this, but I don’t see it. Instead I will show explicitly that $A$ is similar to a matrix in Jordan canonical form. (If anyone can offer a simplification of this proof I’d be grateful!)

If $n = 2$, then the minimal polynomial of $A$ is the only invariant factor, so the Jordan form of $A$ is $\begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}$. Suppose $n \geq 2$.

Let $U = [1\ \ldots\ 1]^\mathsf{T}$ have dimension $(n-1) \times 1$, and let $W$ be the $(n-1) \times (n-1)$ matrix whose every entry is 1. Note that $UU^\mathsf{T} = W$ and $U^\mathsf{T}U = [n-1]$. Let $P = \begin{bmatrix} 1 & 0 \\ U & I \end{bmatrix}$ and $Q = \begin{bmatrix} 1 & 0 \\ -U & I \end{bmatrix}$. Evidently $QP = I$, so that $Q = P^{-1}$. Moreover, we have $A = \begin{bmatrix} 1 & U^\mathsf{T} \\ U & W \end{bmatrix}$, and $P^{-1}AP = B = \begin{bmatrix} n & U^\mathsf{T} \\ 0 & 0 \end{bmatrix}$ $= \begin{bmatrix} 0 & U^\mathsf{T} \\ 0 & 0 \end{bmatrix}$.

Now let $V = [1\ \ldots\ 1]$ have dimension $1 \times (n-2)$. Let $R = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & -V \\ 0 & 0 & I \end{bmatrix}$ and $S = \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & V \\ 0 & 0 & I \end{bmatrix}$. Evidently, $RS = I$, so that $S = R^{-1}$. Now $B = \begin{bmatrix} 0 & 1 & V \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix}$, and we have $R^{-1}BR = \begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix}$. If we squint just right, this matrix is in Jordan canonical form, and is similar to $A$.