The Cubic Frobenius probabilistic primality test

The Miller–Rabin test asks whether a random unit modulo NN behaves as it would if NN were prime. The cubic Frobenius test asks the same question in a rank-three algebra. Its prime-case identity is zN=τ(z)z^N=\tau(z), where a cubic residue calculation selects one of two nonidentity conjugations.

This overview explains the test, the determinant-norm unit screen, an exact product formula for squarefree inputs, and the bound ρN,q<N−3/2\rho_{N,q}<N^{-3/2} when NN is a product of two distinct odd primes. It also reports what large computations do—and do not—suggest beyond the proved semiprime case. The work is preliminary and has not been peer reviewed.

Four ways into the story

Reader Main point
Algebraist A finite é\acute{e}tale cubic algebra over 𝐙/N𝐙\mathbf Z/N\mathbf Z, its determinant norm, and an explicit order-three automorphism.
Number theorist A cubic residue symbol selects Frobenius; local splitting data and gcds determine every unit-liar count.
Probabilist One round has an exact error probability ρN,q\rho_{N,q}, conditional on a uniformly sampled unit.
Algorithm designer Arithmetic is three-coordinate modular arithmetic plus exponentiation and gcd; a public reference implementation is available.

I use abf as a short project label, not as a claim that the name has become standard. The descriptive name is the cubic Frobenius unit test.

From Fermat liars to algebra liars

For an odd integer NN, the Fermat congruence

aN−1≡1(modN)a^{N-1}\equiv1\pmod N

holds for every unit aa when NN is prime. A composite may nevertheless pass for some choices of aa; these are the Fermat liars. Miller–Rabin strengthens the congruence and has a celebrated uniform bound: at most one quarter of the eligible bases are strong liars for any odd composite NN [Rabin; Monier].

Frobenius tests replace the scalar ring 𝐙/N𝐙\mathbf Z/N\mathbf Z by a polynomial quotient algebra and replace the identity map by a Frobenius conjugation. This idea has a substantial history, including Atkin’s normal cubics and Grantham’s general framework for Frobenius pseudoprimes [Atkin; Grantham]. The present construction fixes a particularly explicit cyclic cubic family and randomizes the element of the algebra, rather than the polynomial.

The central question is therefore familiar:

For a fixed composite NN, what proportion of random algebra units imitate the prime-case Frobenius identity?

An exact answer is more informative than an isolated experiment. It reveals which arithmetic coincidences make an input deceptive and where a uniform bound could be sharp.

The cubic algebra and its conjugations

Choose a prime

q=t2+t+7,a=2t+1,q=t^2+t+7, \qquad a=2t+1,

so that 4q−27=a24q-27=a^2. The first possibilities are q=7,13,19,37,79,97,…q=7,13,19,37,79,97,\ldots. Put

fq(X)=X3−qX−q,AN=(𝐙/N𝐙)[X]/(fq),f_q(X)=X^3-qX-q, \qquad A_N=(\mathbf Z/N\mathbf Z)[X]/(f_q),

and let α=[X]\alpha=[X]. Since fqf_q is monic, every element has a unique form

z=ℓα2+mα+n,ℓ,m,n∈𝐙/N𝐙.z=\ell\alpha^2+m\alpha+n, \qquad \ell,m,n\in\mathbf Z/N\mathbf Z.

When NN is composite, ANA_N is generally not a field. It is an algebra over the commutative ring 𝐙/N𝐙\mathbf Z/N\mathbf Z, and a free module of rank three. That distinction is useful rather than troublesome: the Chinese remainder theorem lets us read the algebra one prime factor of NN at a time.

The discriminant

disc(fq)=q2(4q−27)=(qa)2\operatorname{disc}(f_q)=q^2(4q-27)=(qa)^2

is a square. Consequently, away from primes dividing 2aq2aq, the reduction of fqf_q is either irreducible or splits completely; the linear-times-quadratic pattern does not occur. Moreover, the other two roots are explicit quadratic polynomials in α\alpha. For example,

P+(X)=6X2−(a+9)X−4q2a,P−(X)=−6X2+(9−a)X+4q2a.P_+(X)=\frac{6X^2-(a+9)X-4q}{2a}, \qquad P_-(X)=\frac{-6X^2+(9-a)X+4q}{2a}.

Substitution σ(α)=P+(α)\sigma(\alpha)=P_+(\alpha) defines a (𝐙/N𝐙)(\mathbf Z/N\mathbf Z)-algebra automorphism of order three, with σ2(α)=P−(α)\sigma^2(\alpha)=P_-(\alpha). Thus there are two nonidentity conjugations, σ\sigma and σ2\sigma^2, and a prime input must tell us which one is its Frobenius.

Which conjugation does a prime obey?

Set h=(q−1)/3h=(q-1)/3. The cubic character

χq(N)≡Nh(modq)\chi_q(N)\equiv N^h\pmod q

takes values among the three cube roots of unity modulo qq:

1,s1≡−a−36(modq),s2≡a−36(modq).1, \qquad s_1\equiv\frac{-a-3}{6}\pmod q, \qquad s_2\equiv\frac{a-3}{6}\pmod q.

Call qq admissible for NN when

gcd(N,2aq)=1andχq(N)≠1.\gcd(N,2aq)=1 \qquad\text{and}\qquad \chi_q(N)\ne1.

The explicit Frobenius-selection theorem says that, for prime NN, χq(N)=s1\chi_q(N)=s_1 selects σ2\sigma^2, while χq(N)=s2\chi_q(N)=s_2 selects σ\sigma [Bernier, companion manuscript]. Write the selected map as τN,q\tau_{N,q}. Then every prime input satisfies

zN=τN,q(z)(z∈AN).\label{eq:primeidentity} z^N=\tau_{N,q}(z) \qquad (z\in A_N).

The extension from α\alpha to an arbitrary element is elementary, but worth writing out. Every element of ANA_N has a unique expression

z=ℓα2+mα+n,ℓ,m,n∈𝐅N.z=\ell\alpha^2+m\alpha+n, \qquad \ell,m,n\in\mathbf F_N.

Because NN is prime here, the coefficients satisfy ℓN=ℓ\ell^N=\ell, mN=mm^N=m, and nN=nn^N=n. The freshman’s dream and the identity αN=τN,q(α)\alpha^N=\tau_{N,q}(\alpha) therefore give

zN=(ℓα2+mα+n)N=ℓNα2N+mNαN+nN=ℓ(αN)2+mαN+n=ℓτN,q(α)2+mτN,q(α)+n=τN,q(ℓα2+mα+n)=τN,q(z).\begin{aligned} z^N &=\bigl(\ell\alpha^2+m\alpha+n\bigr)^N \\ &=\ell^N\alpha^{2N}+m^N\alpha^N+n^N \\ &=\ell\bigl(\alpha^N\bigr)^2+m\alpha^N+n \\ &=\ell\,\tau_{N,q}(\alpha)^2 +m\,\tau_{N,q}(\alpha)+n \\ &=\tau_{N,q}\bigl(\ell\alpha^2+m\alpha+n\bigr) =\tau_{N,q}(z). \end{aligned}

In the penultimate line we used the fact that τN,q\tau_{N,q} is an 𝐅N\mathbf F_N-algebra automorphism: it fixes the coefficients and preserves addition and multiplication. Thus, once the correct image of the single generator α\alpha is known, the identity follows for every element of the algebra. For composite NN, exponentiation by NN is still a homomorphism on the multiplicative unit group, but it is not generally a ring homomorphism. Equation (1) can then hold only accidentally.

One randomized unit round

Why sample only units? Because the passing elements then form a subgroup. Multiplication by zz is a linear endomorphism Mz:AN→ANM_z:A_N\to A_N of the free rank-three module. Define

Nm(z)=det(Mz)∈𝐙/N𝐙.\operatorname{Nm}(z)=\det(M_z)\in\mathbf Z/N\mathbf Z.

The adjugate identity gives the clean criterion

z∈AN×⇔gcd(Nm(z),N)=1.\label{eq:unitscreen} z\in A_N^\times \quad\Longleftrightarrow\quad \gcd\bigl(\operatorname{Nm}(z),N\bigr)=1.

Thus a round is concrete:

  1. Choose an admissible qq (the computations below use the least one) and determine τN,q\tau_{N,q}.

  2. Choose ℓ,m,n\ell,m,n uniformly modulo NN and put z=ℓα2+mα+nz=\ell\alpha^2+m\alpha+n.

  3. Compute g=gcd(Nm(z),N)g=\gcd(\operatorname{Nm}(z),N). If 1<g<N1<g<N, a factor has been found. If g=Ng=N, discard zz and resample. If g=1g=1, the retained element is uniform in AN×A_N^\times.

  4. Compute zNz^N and τN,q(z)\tau_{N,q}(z). A mismatch proves that NN is composite; a match passes this round.

The unit liars are

HN,q={z∈AN×:zN=τN,q(z)}.H_{N,q}=\{z\in A_N^\times:z^N=\tau_{N,q}(z)\}.

Because AN×A_N^\times is abelian, HN,qH_{N,q} is the kernel of z↦zNτN,q(z)−1z\mapsto z^N\tau_{N,q}(z)^{-1}. Its relative size

ρN,q=|HN,q||AN×|\rho_{N,q}=\frac{|H_{N,q}|}{|A_N^\times|}

is exactly the error probability of one uniformly sampled unit round. Repeating independent rounds raises this probability to the corresponding power.

The arithmetic cost is O(logN)O(\log N) multiplications in a three-dimensional algebra, plus small-parameter work and gcds. This is a larger constant than one Miller–Rabin round. The point of the present work is therefore not a premature claim of practical superiority, but a structural and quantitative analysis of a new randomized parameter space.

The exact squarefree formula

Suppose NN is squarefree. At each prime p∣Np\mid N, the local algebra is one of

Ap≃{𝐅p×𝐅p×𝐅p,fq splits modulo p,𝐅p3,fq is irreducible modulo p.A_p\simeq \begin{cases} \mathbf F_p\times\mathbf F_p\times\mathbf F_p,& f_q\text{ splits modulo }p,\\ \mathbf F_{p^3},& f_q\text{ is irreducible modulo }p. \end{cases}

Call the cases split and inert. At an inert prime, the selected conjugation restricts to z↦zpupz\mapsto z^{p^{u_p}} for a unique up∈{1,2}u_p\in\{1,2\}. The exact formula is

ρN,q=∏p∣Npsplitgcd(N3−1,p−1)(p−1)3∏p∣Npinertgcd(|N−pup|,p3−1)p3−1.\label{eq:exactformula} \boxed{ \rho_{N,q} = \prod_{\substack{p\mid N\\p\ \mathrm{split}}} \frac{\gcd(N^3-1,p-1)}{(p-1)^3} \prod_{\substack{p\mid N\\p\ \mathrm{inert}}} \frac{\gcd\!\left(|N-p^{u_p}|,p^3-1\right)}{p^3-1}. }

The proof is a compact local calculation. The Chinese remainder theorem decomposes AN×A_N^\times into its prime components. In the inert case, 𝐅p3×\mathbf F_{p^3}^\times is cyclic and the local equation is zN−pup=1z^{N-p^{u_p}}=1, giving the second gcd. In the split case, τ\tau cyclically permutes three copies of 𝐅p×\mathbf F_p^\times; three linked equations reduce to xN3−1=1x^{N^3-1}=1, giving the first gcd. Multiplying the local counts proves the displayed product formula.

This is the cubic analogue of what makes Monier’s formula so useful for Miller–Rabin: the probability is no longer a black box. It is a finite product whose unusually large factors can be studied one at a time.

The star witness: squarefree semiprimes

The cleanest theorem occurs when N=prN=pr with p≠rp\ne r odd primes.

Theorem 1 (Squarefree semiprime bound [Bernier, 2026]). For every prime qq admissible for N=prN=pr, ρN,q<N−3/2.\boxed{\rho_{N,q}<N^{-3/2}.}

Thus one cubic unit round rejects a squarefree semiprime with probability greater than 1−N−3/21-N^{-3/2}. The statement is uniform in the admissible parameter qq, not merely valid for the least choice used in experiments.

This is not dimension counting. Although ANA_N has about N3N^3 elements, the two local kernels can be enlarged by common divisors coming from cross-prime congruences. The theorem is a gcd-clash statement: the two primes cannot simultaneously donate enough local resonance to reach the N−3/2N^{-3/2} boundary.

The exponent is conditionally sharp. If admissible primes satisfy

r=p3+p−1,r=p^3+p-1,

then ρpr,q(pr)3/2→1−\rho_{pr,q}(pr)^{3/2}\to1^- along any unbounded such family. No infinitude is claimed; simultaneous primality here is a Bateman–Horn type problem. The small instance

N=2443=7⋅349,q=937N=2443=7\cdot349,\qquad q=937

already gives

ρ2443,937−1=124294,ρ2443,93724433/2=0.971482621….\rho_{2443,937}^{-1}=124294, \qquad \rho_{2443,937}\,2443^{3/2}=0.971482621\ldots.

The comparison with Miller–Rabin should be read correctly. The classical 1/41/4 bound applies to every odd composite and comes with decades of implementation experience. The N−3/2N^{-3/2} bound is far smaller but presently proved only for squarefree semiprimes, and a cubic round is more expensive. The mathematical novelty is the decaying, essentially sharp bound in this specific family.

What the computations say

For a consistent census, let qmin(N)q_{\min}(N) be the least admissible prime q=t2+t+7q=t^2+t+7, and write

E(N)=−logρN,qmin(N)logN.E(N)=-\frac{\log\rho_{N,q_{\min}(N)}}{\log N}.

Then ρ=N−E\rho=N^{-E}, so a smaller EE means a more deceptive composite. The semiprime theorem says E>3/2E>3/2 for every squarefree semiprime and every admissible qq.

An exhaustive exact-formula census of all 36,410,418,78436{,}410{,}418{,}784 odd squarefree composites through 101110^{11} found a smaller value once more prime factors were allowed:

N=4,928,864,721=3⋅11⋅61⋅149⋅16433,qmin=7,ρN,7=1855,135,194,823,E(N)=1.231027170….\begin{aligned} N&=4{,}928{,}864{,}721 =3\cdot11\cdot61\cdot149\cdot16433,\\ q_{\min}&=7,\\ \rho_{N,7}&=\frac{1}{855{,}135{,}194{,}823},\\ E(N)&=1.231027170\ldots. \end{aligned}

Figure 1 shows the full distribution. The bulk is far to the right of the displayed record; the logarithmic vertical axis is essential. This computation is evidence, not a theorem. In particular, it does not prove E(N)>1E(N)>1, even for squarefree NN.

Histogram of ABF minimal-q unit-liar exponents for odd squarefree composites through 10^11
Exact minimal-qq unit-liar exponents for all odd squarefree composites N≤1011N\le10^{11}. The red line is the presently unproved threshold E=1E=1; the orange line is the proved semiprime threshold E=3/2E=3/2. Values left of 3/23/2 necessarily have at least three prime factors.

Separate exact computations on Carmichael numbers through 102410^{24} are also informative because Carmichael numbers inherit all the p−1p-1 divisibility supplied by Korselt’s criterion. The smallest observed exponent in that census was

E(739,243,849,201)=1.354882088….E(739{,}243{,}849{,}201)=1.354882088\ldots.

This suggests that the difficult cases are structured rather than random. It does not rule out a future example below 11, and it does not replace a proof.

What remains open

The exact formula turns broad questions into arithmetic ones.

  1. Can a composite fool every unit? The extreme event ρN,q=1\rho_{N,q}=1 would be a cubic analogue of Carmichael behavior for this selected Frobenius congruence. No example is known.

  2. Can E(N)<1E(N)<1? Equivalently, can ρN,q>1/N\rho_{N,q}>1/N? Current data show a substantial margin but no general theorem.

  3. What happens at fixed ω(N)\omega(N)? The semiprime case is understood sharply. Even a positive asymptotic lower bound for EE at each fixed number of prime factors would be meaningful progress.

  4. What changes at prime powers? Squarefreeness turns ANA_N into a product of finite fields. Nonsquarefree inputs introduce congruence subgroups and a genuine lifting problem in finite local rings.

  5. Where does the test belong computationally? A useful implementation should be benchmarked inside a conservative pipeline, alongside established tests, with reproducible random sampling and adversarial test sets. The mathematics does not yet justify replacing Miller–Rabin or Baillie–PSW.

To me, the conceptual question is broader than one algorithm:

How much finite-field structure can a composite modulus imitate before arithmetic compatibility forces the imitation to collapse?

The cubic algebra makes that question concrete. Its units can be sampled, its liars form a group, and—in the squarefree case—their proportion can be written down exactly.

Code, paper, and status

The preprint, companion manuscript, and source archive are available at Zenodo record 21705261. A single-threaded C/GMP reference implementation and an exact-guided tally demonstration are at github.com/mariotrevi/cubic-frobenius-unit-test.

This is a preliminary research project. The public implementation is a readable reference, not a certified cryptographic library. AI systems used under the names Fable, ChatGPT, and Kimi K3 contributed substantially to discussion, exposition, code review, and cross-checking. The author revised the material and takes responsibility for the statements and computations presented here.

References

A. O. L. Atkin, Intelligent primality test offer, in Computational Perspectives on Number Theory, AMS/IP Studies in Advanced Mathematics 7 (1998), 1–11.

D. Bernier, Unit Liars in a Cubic Frobenius Test: An Exact Formula and an N−3/2N^{-3/2} Semiprime Bound, v0.3.1, 2026. Zenodo record 21705261.

D. Bernier, Which root does Frobenius pick? An explicit rule for x3−qx−qx^3-qx-q, proved from scratch, companion manuscript, 2026.

A. Fiori and A. Shallue, Average liar count for degree-2 Frobenius pseudoprimes, Math. Comp. 89 (2020), 493–514.

J. Grantham, Frobenius pseudoprimes, Math. Comp. 70 (2001), 873–891.

P. Laurent and P. Underwood, A Cubic Composite Test, arXiv:2505.02167, 2025.

L. Monier, Evaluation and comparison of two efficient probabilistic primality testing algorithms, Theoret. Comput. Sci. 12 (1980), 97–108.

M. O. Rabin, Probabilistic algorithm for testing primality, J. Number Theory 12 (1980), 128–138.

meditationatae's avatar

By meditationatae

Canadian

2 comments

Comments are closed.

Discover more from meditationatae

Subscribe now to keep reading and get access to the full archive.

Continue reading