MathOverflow is a question and answer site for professional mathematicians. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let $M$ be a square matrix with integer entries. Then Fermat's little theorem for matrices holds:

$$\text{tr}(M^p) \equiv \text{tr}(M) \bmod p.$$

This follows by an examination of the action of the Frobenius map on the roots of the characteristic polynomial of $M$ over a splitting field; there is also a combinatorial proof. (Incidentally, I have no idea who to credit for this result.)

This suggests the following definition generalizing the notion of Fermat pseudoprime, the notion of Fibonacci pseudoprime (it feels to me like the Wikipedia article has the names backwards), and the notion of Perrin pseudoprime: a pseudoprime to base $M$ is a positive integer $n$ such that

$$\text{tr}(M^n) \equiv \text{tr}(M) \bmod n.$$

This definition appears to be related to Grantham's notion of Frobenius pseudoprime, although it might be weaker. For concreteness, let $M$ be the companion matrix of your favorite monic irreducible polynomial over $\mathbb{Z}$.

Anyway, this looks like a reasonable primality test to me (choose random matrices, exponentiate them, etc.), but I don't really know anything about the subject. Does this notion appear anywhere in the literature? How does it compare to other primality tests?

share|cite|improve this question
An example would be a nice addition to this question. The problem with new primality tests is that under reasonable practical hypotheses (such as the Generalized Riemann Hypothesis), existing tests are already as good as one can hope for, see – Stopple Aug 8 '12 at 16:01
This is weaker than the notion of a Szekeres pseudoprime in the linked paper. – Will Sawin Aug 8 '12 at 16:47
@Will: good point! But it's not much weaker. It suffices to replace the computation of the trace by the computation of the characteristic polynomial, and to do this it suffices to test the bases $M, M+1, M+2, ... M + (d-1)$ (where $M$ is a $d \times d$ matrix), at least if $n$ is sufficiently large compared to $d$. @Stopple: I'm not hoping that this will be an improvement over existing algorithms; it just seems like a nice example for pedagogical purposes and I am wondering whether people already use it this way. – Qiaochu Yuan Aug 8 '12 at 16:52
up vote 8 down vote accepted

I think this is weaker than the notion of Frobenius pseudoprime. The trace of a matrix is the sum of the roots of its characteristic polynomial, so you're testing whether the sum of the roots remains invariant upon raising to the pth power. The Frobenius test is stronger than that.

share|cite|improve this answer
In particular, you've made the polynomial arithmetic more complicated than it needs to be by embedding it in a matrix operation. – Jon Grantham Aug 8 '12 at 17:15
Very good point! Sorry for the silly question. – Qiaochu Yuan Aug 8 '12 at 17:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.