## Compute the Jordan canonical form of a given matrix over QQ

Compute the Jordan canonical form over $\mathbb{Q}$ of the $n \times n$ matrix whose every entry is equal to 1.

Let $A = [1]$ be an $n \times n$ matrix. Note the following.

 $A(A-nI)$ = $[1][1-\delta_{i,j}n]$ = $[\sum_k 1_{i,k}(1_{k,j} - \delta_{k,j}n)]$ = $[\sum_k 1 - \sum_k \delta_{k,j} n]$ = $[n-n]$ = $[0]$

So we have $A(A-nI) = 0$, and thus the minimal polynomial of $A$ divides $x(x-n)$. Since $A \neq 0$ and $A \neq nI$, the minimal polynomial of $A$ is $x(x-n)$.

Next we prove a lemma.

Lemma: Let $A$ be an $n \times n$ matrix over a field $F$ containing the eigenvalues of $A$, and let $\lambda$ be an eigenvalue of $A$ with eigenspace $W \subseteq F^n$. If the minimal polynomial of $A$ over $F$ is a product of distinct linear factors, then the dimension of $W$ (over $F$) is precisely the multiplicity of $\lambda$ among the roots of the characteristic polynomial of $A$. Proof: Let $V = F^n$. As an $F[x]$ module via $A$, we have $V = \bigoplus_{i=1}^n F[x]/(x-\lambda_i)$, where $\lambda_i$ are the eigenvalues of $A$. The eigenspace of $\lambda$ consists precisely of those direct factors with $\lambda_i = \lambda$, each of which has dimension 1 over $F$. $\square$

For our given matrix $A$, we claim that the eigenspace $W$ of the eigenvalue $n$ has dimension 1 over $F$. To see this, let $v = [v_1\ \ldots\ v_n]^\mathsf{T}$ and suppose $Av = nv$. Evidently, every entry of $Av$ is $\sum_k v_k$, and so we have $nv_i = nv_j$ for all $i,j$. Since $n \neq 0$, we have $v_i = v_j$ for all $i,j$, and so $v = v_1[1\ \ldots\ 1]^\mathsf{T}$. So $W$ has a basis containing one element, and so has dimension 1 over $F$ as desired.

By the lemma, $n$ has multiplicity 1 among the roots of the characteristic polynomial of $A$. Since the remaining roots are 0, the invariant factors of $A$ are $x$ $n-2$ times and $x(x-n)$. The corresponding Jordan canonical form matrix is $J = [b_{i,j}]$, with $b_{n,n} = n$ and $b_{i,j} = 0$ otherwise.