KEVOS
ArticlesServicesCase studiesAboutContact
ArticlesServicesCase studiesAboutContact
← ArticlesThe Quadratic Sieve: Sieving StageEngineering · Engineering MathematicsLesson 875/884← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin Joginquadratic sievesievinglogarithm approximationsmooth values
On this page

Ask about this page

KEVOS AIThe Quadratic Sieve: Sieving Stage

KEVOS knowledge first · trusted web sources when needed

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.

Key point

Values grow as the interval extends, and larger values are less likely to be smooth. This is the fundamental limitation that multiple polynomials removes.

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.

Key point

Only additions occur in the inner loop — no divisions at all. That is the entire source of the speedup over CFRAC, which trial divides every candidate.

Logarithms are approximate

Note

Small integer approximations to logarithms are used, typically single bytes. The imprecision is absorbed by setting the acceptance threshold slightly below the exact value, and the verification step catches anything wrongly accepted.

Pitfall

Setting the threshold too tight loses genuine relations; setting it too loose floods the verification step. It is tuned by measurement, and it interacts with whether prime powers are sieved.

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

Key point

Matching partial relations is a graph problem: partials are edges labelled by their large prime, and cycles give full relations. This is the same combining idea as in class group relation collection.

Memory and cache

Cost

The sieve array should fit in cache. Large intervals are processed in cache-sized blocks, and the factor base is partitioned so that large primes — which hit each block rarely — are handled separately. This is where most of the practical engineering effort goes.

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.

Related pages

  • Square Roots Modulo a Prime: the Shanks-Tonelli Algorithm
  • Quadratic Sieve Factor Base Selection
  • The Multiple Polynomial Quadratic Sieve

Continue learning

Quadratic Sieve Factor Base SelectionArticle · Engineering MathematicsNEXT LESSON →The Multiple Polynomial Quadratic SieveArticle · Engineering MathematicsECM Stage Two and Practical TuningArticle · Engineering MathematicsThe Quadratic Sieve: Linear Algebra StageArticle · Engineering Mathematics
KEVOS · Engineering, manufacturing and project improvement
ArticlesServicesCase studiesAboutContact
© 2026 KEVOS®