KEVOS
ArticlesServicesCase studiesAboutContact
ArticlesServicesCase studiesAboutContact
← ArticlesShanks's Square Forms Factorisation (SQUFOF)Engineering · Engineering MathematicsLesson 858/884← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin JoginSQUFOFsquare formsindefinite formscontinued fraction
On this page

Ask about this page

KEVOS AIShanks's Square Forms Factorisation (SQUFOF)

KEVOS knowledge first · trusted web sources when needed

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.

Key point

The square form marks the halfway point of a cycle whose traversal reaches an ambiguous form. Reversing from the square root reaches that ambiguous form in about the same number of steps, so the total cost is roughly twice the forward search.

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

Cost

The decisive advantage is that all arithmetic fits in machine words for the input sizes where it applies. No multiprecision arithmetic is needed at all, which makes it dramatically faster than methods with the same asymptotic complexity.

Multipliers

Note

The traversal may fail to produce a usable square form for a given multiplier. Running several multipliers in parallel — interleaving the traversals — is standard and makes failure essentially impossible.

The range

Pitfall

Beyond about eighteen or nineteen digits the intermediate values exceed machine word size and the principal advantage evaporates. SQUFOF is not a general method and should not be pushed beyond its range — see choosing a factoring method.

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.

Key point

It is a specialist tool used constantly rather than a headline method used occasionally. Most large factoring computations call SQUFOF millions of times without ever using it on the main input.

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.

Related pages

  • Integer Square Root and Perfect Power Detection
  • Reduction of Indefinite Forms and the Cycle Structure
  • Shanks's Class Group Factoring Method

Continue learning

Shanks's Class Group Factoring MethodArticle · Engineering MathematicsNEXT LESSON →The Modern Primality Testing LandscapeArticle · Engineering MathematicsThe Pollard p-1 MethodArticle · Engineering MathematicsGauss Sums and Jacobi SumsArticle · Engineering Mathematics
KEVOS · Engineering, manufacturing and project improvement
ArticlesServicesCase studiesAboutContact
© 2026 KEVOS®