← LibraryThe Quadratic Sieve: Sieving StageEngineering · MathematicsLesson 376/385← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin Joginquadratic sievesievinglogarithm approximationsmooth values

Modern Factoring Methods

The Quadratic Sieve: Sieving Stage

The sieving stage: identifying smooth polynomial values in bulk using logarithm accumulation rather than trial division.

Engineering / MathematicsModern Factoring Methods2 min readKV-MATH-0673

Sieving is what makes the quadratic sieve fast. Instead of testing each candidate for smoothness, it marks an entire interval at once, reducing the per-candidate cost to almost nothing.

The polynomial

Q(x) = (x + ceil(sqrt(n)))^2 - nValues are small near the start of the interval and grow away from it.

The sieve

The sieving procedure

  1. Allocate an arrayOne entry per position in the interval.
  2. For each factor base primeStart at the positions given by the precomputed square roots.
  3. Step by the primeEvery prime-th position is divisible.
  4. Add the logarithmAccumulate an approximate logarithm of the prime at each such position.
  5. ScanPositions whose accumulated total approaches the logarithm of the value are smoothness candidates.
  6. VerifyTrial divide only the candidates.

Logarithms are approximate

The large prime variation

Values that are smooth except for one prime slightly above the bound are kept. Two such partial relations sharing that prime combine into one full relation.

Large prime variations
VariationEffect
Single large primeSubstantially more relations for little extra work
Double large primeMore again; requires graph-based matching
Triple and beyondDiminishing returns; complex bookkeeping

Memory and cache

Parallelism

Different intervals and different polynomials sieve independently, so this stage distributes perfectly. The subsequent linear algebra does not.

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

Quadratic Sieve Factor Base SelectionArticle · MathematicsNEXT LESSON →The Multiple Polynomial Quadratic SieveArticle · MathematicsECM Stage Two and Practical TuningArticle · MathematicsThe Quadratic Sieve: Linear Algebra StageArticle · Mathematics