# Finding the characteristic polynomial of a matrix modulus n

Given a square matrix, is it possible to calculate its characteristic polynomial modulo n? Unfortunately, this function CharacteristicPolynomial doesn't have the Modulus option that many other functions have.

-

There is no need for the Modulus option in CharacteristicPolynomial, since PolynomialMod serves that purpose. Assume we have a matrix m e.g. :

m = RandomInteger[10, {5, 5}]
m // MatrixForm

{{10, 1, 4, 10, 9}, {1, 9, 6, 1, 5}, {9, 7, 9, 1, 0}, {1, 10, 8, 0, 4}, {4, 0, 4, 7, 10}}


then

CharacteristicPolynomial[m, x]

2310 - 4008 x + 1739 x^2 - 370 x^3 + 38 x^4 - x^5


while e.g. a characteristic polynomial modulo 5 is :

PolynomialMod[ CharacteristicPolynomial[m, x], 5]

2 x + 4 x^2 + 3 x^4 + 4 x^5


Edit

If there are specific reasons for a characteristic polynomial different than knowing its PolynomialMod, one can use directly Modulus in functions like Solve, Factor or other with that option.

Let us factor PolynomialMod[ CharacteristicPolynomial[m, x], 5] as well as CharacteristicPolynomial[m, x] over $\mathbb{Z}_5$ :

Factor[ CharacteristicPolynomial[ m, x], Modulus -> 5]

Factor[ PolynomialMod[ CharacteristicPolynomial[ m, x], 5], Modulus -> 5] ===
Factor[ CharacteristicPolynomial[ m, x], Modulus -> 5]

4 x (3 + x + 2 x^3 + x^4)

True


analogically with Solve, e.g. :

Solve[ CharacteristicPolynomial[ m, x] == 0, x, Modulus -> 5]

Solve[ PolynomialMod[ CharacteristicPolynomial[ m, x], 5] == 0, x, Modulus -> 5] ==
Solve[ CharacteristicPolynomial[ m, x] == 0, x, Modulus -> 5]

{{x -> 0}}
True


Therefore the option Modulus -> n in CharacteristicPolynomial would be superfluous.

Consider another simple polynomial :

p2 = PolynomialMod[ -1 + 4 x^2, 5]
p1 = Factor[        -1 + 4 x^2, Modulus -> 5]

4 + 4 x^2
4 (2 + x) (3 + x)


apparently they are different, however they are certainly the same modulo 5, i.e. :

PolynomialMod[ p1 - p2, 5]

0

-
+1 Excellent answer! –  R Hall Jul 9 '12 at 11:31
@RHall Thank You ! –  Artes Jul 9 '12 at 11:43