← LibraryComposition of Binary Quadratic FormsEngineering · Engineering MathematicsLesson 409/488← PrevNext →
ArticlePublished 7 Aug 2026Updated 8 Aug 20262 min readBy Kevin JogincompositionGauss compositionform class groupgroup law

Quadratic Fields

Composition of Binary Quadratic Forms

Gauss composition as the group law on form classes, its practical computation, and reduction between compositions.

Engineering / MathematicsQuadratic Fields2 min readKV-MATH-0603

Composition is the group law on form classes, corresponding to ideal multiplication. Gauss's original formulation is intricate; the modern treatment is a short computation with the extended Euclidean algorithm.

What it computes

Composition of forms <-> multiplication of the corresponding idealsBoth forms must have the same discriminant.

The computation

Composition of two forms

  1. Compute a GCDOf the two first coefficients and the average of the middle ones, with Bezout coefficients.
  2. Solve congruencesDetermine the middle coefficient of the composite from congruence conditions.
  3. Form the productThe first coefficient is the product of the originals divided by the square of the GCD.
  4. ReduceApply reduction immediately.

Squaring

Composing a form with itself admits a simplified formula, worth implementing separately because exponentiation by repeated squaring is dominated by squarings.

NUCOMP

Shanks's NUCOMP algorithm interleaves reduction with composition, keeping intermediate values small throughout rather than reducing afterwards. It is substantially faster for large discriminants and is the standard method in serious implementations.

Composition strategies
MethodIntermediate sizeSpeed
Compose then reduceGrows to the product of the coefficientsAdequate for small discriminants
NUCOMPBounded near the square root of the discriminantSubstantially faster for large discriminants

Uses

Composition is the group operation underlying class group structure computation, element orders in the class group, and Shanks's class group factoring method, where an ambiguous form reveals a factorisation.

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

Reduction of Positive Definite Binary FormsArticle · Engineering MathematicsNEXT LESSON →Imaginary Quadratic Class Numbers by Counting Reduced FormsArticle · Engineering MathematicsBinary Quadratic Forms and the Ideal CorrespondenceArticle · Engineering MathematicsClass Numbers from Analytic Class Number FormulasArticle · Engineering Mathematics