A367978 Number of distinct characteristic polynomials for 4 X 4 matrices with entries from {0, 1, ..., n}.
1, 333, 58335, 2875405, 47125558
Offset: 0
Programs
-
Mathematica
mat[n_Integer?Positive] := mat[n] = Array[m, {n, n}]; flatMat[n_Integer?Positive] := flatMat[n] = Flatten[mat[n]]; charPolyMat[n_Integer?Positive] := charPolyMat[n] = FullSimplify[CoefficientList[Expand[CharacteristicPolynomial[mat[n], x]], x]]; a[d_Integer?Positive, 0] = 1; a[d_Integer?Positive, n_Integer?Positive] := a[d, n] = Length[DeleteDuplicates[Flatten[Table[Evaluate[charPolyMat[d]], ##] & @@ Table[{flatMat[d][[i]], 0, n}, {i, 1, d^2}], d^2 - 1]]]; Table[a[4, n], {n, 0, 2}]
-
Sage
import itertools def a(n): ans, W = set(), itertools.product(range(n+1), repeat=16) for w in W: ans.add(Matrix(ZZ, 4, 4, w).charpoly()) return len(ans) # Robin Visser, May 04 2025
Extensions
a(4) from Robin Visser, May 04 2025