KEVOS
ArticlesServicesCase studiesAboutContact
ArticlesServicesCase studiesAboutContact
← ArticlesImplementing the Jacobi Sum TestEngineering · Engineering MathematicsLesson 863/884← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin JoginimplementationJacobi sum testcyclotomic arithmeticprecomputation
On this page

Ask about this page

KEVOS AIImplementing the Jacobi Sum Test

KEVOS knowledge first · trusted web sources when needed

Modern Primality Tests

Implementing the Jacobi Sum Test

Practical implementation of the Jacobi sum test: precomputation, cyclotomic arithmetic, and the final divisor search.

Engineering / MathematicsModern Primality Tests2 min readKV-MATH-0661

The Jacobi sum test is intricate to implement. Most of the difficulty is in the bookkeeping — parameter tables, cyclotomic arithmetic and character construction — rather than in any single hard step.

Precomputation

What to precompute
Precomputed dataWhy
Parameter tables by size rangeSelecting the auxiliary integer at run time is a search in its own right
Primitive roots for the auxiliary primesNeeded to construct characters
Character tablesReused across many candidates
Cyclotomic reduction dataMultiplication in the cyclotomic ring needs the reduction relations

Key point

Nearly all the auxiliary data depends only on the size range, not on the specific candidate. Computing it once and tabulating it is what makes the test fast for repeated use.

Cyclotomic arithmetic

Elements are represented as coefficient vectors over a basis of the cyclotomic ring, with all coefficients reduced modulo the candidate. Multiplication is a convolution followed by reduction using the cyclotomic relations.

Cost

The cyclotomic degrees are small — typically under a hundred — so schoolbook convolution is appropriate. Reduction is a fixed linear map that should be precomputed as a table rather than recomputed.

The final search

The final divisor search

  1. Collect the constraintsEach passed condition restricts divisors to a congruence class.
  2. Enumerate candidatesPowers of the candidate modulo the auxiliary integer, reduced into the range below the square root.
  3. Trial divideTest each against the candidate.
  4. ConcludeFinding no divisor proves primality.

Key point

The search list has length roughly the auxiliary integer, which is small by construction. This is why the parameter choice matters: the auxiliary product must exceed the square root of the candidate while the integer itself stays small enough to enumerate.

Failure handling

Pitfall

A failed condition does not always prove compositeness immediately — some failures indicate a bad parameter choice rather than a composite candidate. The two must be distinguished, and conflating them produces false compositeness reports.

Testing

Caution

The special cases around characters of two-power order are where implementations go wrong, and the errors are input-specific. A test suite must include candidates exercising each case — the same discipline as for Galois group software.

Practical guidance

This is a test worth using through a mature library rather than implementing. The parameter tables alone represent substantial work — see software packages.

Source. Henri Cohen, A Course in Computational Algebraic Number Theory, Springer GTM 138 — 9.1.5-9.1.6. Structural reference unverified: the source file was not available during authoring; chapter and section numbers are taken from the published edition and have not been checked against a physical copy.

Related pages

  • Number Theory Software Packages
  • Checking the Condition C_p
  • The Goldwasser-Kilian Primality Test

Continue learning

Checking the Condition C_pArticle · Engineering MathematicsNEXT LESSON →The Goldwasser-Kilian Primality TestArticle · Engineering MathematicsStructure of the Jacobi Sum Primality TestArticle · Engineering MathematicsAtkin-Morain Elliptic Curve Primality ProvingArticle · Engineering Mathematics
KEVOS · Engineering, manufacturing and project improvement
ArticlesServicesCase studiesAboutContact
© 2026 KEVOS®