← LibraryShanks's Square Forms Factorisation (SQUFOF)Engineering · MathematicsLesson 359/385← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin JoginSQUFOFsquare formsindefinite formscontinued fraction

Classical Primality and Factoring

Shanks's Square Forms Factorisation (SQUFOF)

SQUFOF: factoring by finding a square form in the cycle of an indefinite quadratic form, and why it excels for small inputs.

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

SQUFOF factors an integer by traversing the cycle of an indefinite quadratic form until a square form appears. It is remarkably efficient for numbers up to about eighteen digits and uses essentially no memory.

The method

Traverse the cycle of reduced indefinite forms of discriminant equal to the number, or a small multiple. When a form with square first coefficient appears, reversing the traversal from its square root yields a factor.

SQUFOF

  1. Set upForm the principal indefinite form of the appropriate discriminant.
  2. Traverse forwardApply the reduction operator, watching for a square first coefficient — see indefinite reduction.
  3. Take the square rootConstruct the form with the square root as its first coefficient.
  4. Traverse backwardFrom that form until the cycle returns to an ambiguous form.
  5. Read the factorThe ambiguous form gives the factorisation.

Why it is fast in practice

SQUFOF characteristics
PropertyValue
ComplexityFourth root of the number
MemoryEssentially none
ArithmeticSingle-precision for inputs up to about 18 digits
ConstantsVery small

Multipliers

The range

Where it is used

SQUFOF is the standard method for the small factorisations that appear as subroutines throughout: splitting cofactors during smoothness testing, factoring small norms in ideal factorisation, and clearing residues in sieve methods.

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

Shanks's Class Group Factoring MethodArticle · MathematicsNEXT LESSON →The Modern Primality Testing LandscapeArticle · MathematicsThe Pollard p-1 MethodArticle · MathematicsGauss Sums and Jacobi SumsArticle · Mathematics