← LibraryThe Baillie-PSW Compositeness TestEngineering · MathematicsLesson 352/385← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin JoginBaillie PSWprobable primecombined testno known counterexample

Classical Primality and Factoring

The Baillie-PSW Compositeness Test

The Baillie-PSW test combining a strong base-two test with a strong Lucas test, and its status as the practical standard.

Engineering / MathematicsClassical Primality and Factoring2 min readKV-MATH-0649

Baillie-PSW combines a strong pseudoprime test to base two with a strong Lucas test. No composite is known to pass it, and it is the practical standard for probable-prime testing.

The test

The Baillie-PSW test

  1. Trial divideBy small primes.
  2. Check for a perfect squareThe Lucas parameter search requires it — see perfect powers.
  3. Strong test base twoA strong pseudoprime test.
  4. Select Lucas parametersBy scanning for a non-residue discriminant.
  5. Strong Lucas testSee Lucas sequences.

Why it is trusted

Status of Baillie-PSW
PropertyStatus
Counterexamples knownNone, despite extensive search
Proven to have no counterexamplesNo
Heuristic arguments for infinitely manyYes
Verified below large boundsYes, exhaustively

Cost

When it is not enough

For adversarial input, or where a mathematical claim depends on primality, a proof is required. See ECPP and certificates.

Combination with random bases

Some implementations add several random-base strong tests to Baillie-PSW. This guards against an adversary who has constructed a counterexample to the fixed-parameter test, at modest additional cost.

Source. Henri Cohen, A Course in Computational Algebraic Number Theory, Springer GTM 138 — 8.3. 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.

Continue learning

Lucas Sequences and Lucas PseudoprimesArticle · MathematicsNEXT LESSON →The Pocklington-Lehmer N-1 Primality TestArticle · MathematicsFermat and Strong Pseudoprime TestsArticle · MathematicsN+1 Tests and the Lucas-Lehmer TestArticle · Mathematics