# What is the number of (binary) 4 x 4 matrices over GF(2) (the field with 2 elements) that do not have an eigenvalue of 0 or 1

My code below returns 4032. The OEIS sequence A002820 says there are 5824 such matrices. Is there something wrong with my code. I am assuming that the eigenvalues of a matrix are precisely the roots of the characteristic polynomial. If the characteristic polynomial of a matrix is irreducible over the underlying field then the matrix has no eigenvalues. Right?

Count[Map[
IrreduciblePolynomialQ[CharacteristicPolynomial[#, x],
Modulus -> 2] &, Tuples[Tuples[{0, 1}, 4], 4]], True]

• The characteristic polynomial could have irreducible quadratic factors. – Daniel Lichtblau Dec 14 '17 at 19:29

noLinearFax[mat_] :=
Module[{x},
With[{fax =
FactorList[CharacteristicPolynomial[mat, x], Modulus -> 2]},
(Length[fax] == 2 && fax[[2, 2]] != 4) || (Length[fax] == 3 &&
Rest[fax][[All, 2]] === {1, 1} &&
Map[Exponent[#, x] &, Rest[fax][[All, 1]]] == {2, 2})]]

AbsoluteTiming[
Count[Map[noLinearFax, Tuples[Tuples[{0, 1}, 4], 4]], True]]

(* Out= {12.913031, 5824} *)