Counting nilpotent matrices by the Fitting decomposition (source code)

= Counting nilpotent matrices by the Fitting decomposition

There are $q^{n^2-n}$ <nilpotent matrices> of size n over $F_q$. Every matrix has a unique invariant direct sum on which it is nilpotent and invertible. Counting those ordered decompositions gives $q^{n^2}/|GL_n(q)|=\sum_{k=0}^n a_k/|GL_k(q)|$. Subtraction at n and n−1 yields $a_n=q^{n^2-n}$. Translation by the identity counts <unipotent matrices>.