Number fields

Class groups

The class group measures how far a ring of integers is from unique factorisation. Its elements are the ideals up to multiplication by a number; it is finite; it is trivial exactly when every ideal is principal. Here it is computed with a proof, not a heuristic.

The group

Two ideals are in the same class when one is the other times a field element. Classes multiply, the principal ideals are the identity class, and the resulting group Cl⁡(K)\operatorname{Cl}(K) is finite. Its order is the class number hh.

import { NumberField, idealClassGroup, ringOfIntegers } from "@ratmath/numtheory";

const K = NumberField.quadratic(-5);
const cl = idealClassGroup(K);
cl.h;              // 2n
cl.structure;      // [2n]: a cyclic group of order 2
cl.generators;     // [(2, 1 + √(-5))], as an Ideal
cl.proven;         // true

const O = ringOfIntegers(K);
const [P2] = O.primesAbove(2);
const [P3] = O.primesAbove(3);
cl.classOf(P2);                    // [1n]: the non-trivial class
cl.isPrincipal(P2);                // { principal: false, generator: null }
cl.isPrincipal(P2.toIdeal().mul(P3));
// { principal: true, generator: 1 + √(-5) }

structure lists invariant factors d1∣d2∣⋯d_1 \mid d_2 \mid \cdots: the group is Z/d1×Z/d2×⋯\mathbb{Z}/d_1 \times \mathbb{Z}/d_2 \times \cdots, with one generator ideal for each. classOf gives the exponents of an ideal's class on those generators.

const C = idealClassGroup([-65n, 0n, 0n, 1n]);     // Q(∛65)
String(C);          // "class group of Q(α), α a root of x³ − 65: C3 × C6, h = 18"
C.structure;        // [3n, 6n]

const [T] = C.order.primesAbove(2);
C.classOf(T);       // [1n, 5n]
C.orderOf(T);       // 6n
String(C.isPrincipal(T.toIdeal().pow(6)).generator);   // "49 + 24α − 9α²"

Minkowski's bound

Geometry of numbers shows that every class contains an ideal of norm at most

MK=n!nn(4π)r2∣dK∣. M_K = \frac{n!}{n^n} \left(\frac{4}{\pi}\right)^{r_2} \sqrt{|d_K|}.

So the prime ideals of norm up to MKM_K generate the class group, and there are finitely many. For Q(−5)\mathbb{Q}(\sqrt{-5}) the bound is 2.8: the single prime above 2 generates everything, and it is not principal because a2+5b2=2a^2 + 5b^2 = 2 has no solution. That is the whole computation by hand.

minkowskiBound(NumberField.quadratic(-5));       // 2n
minkowskiBound(NumberField.quadratic(-163));     // 8n: and 2, 3, 5, 7 are all inert, so h = 1
minkowskiBound([-65n, 0n, 0n, 1n]);              // 95n
C.factorBase.length;                             // 44 prime ideals above the primes up to 95

Relations

Call the generating primes P1,…,PkP_1, \dots, P_k. An element xx whose norm has only small prime factors gives a relation: (x)=∏Piai(x) = \prod P_i^{a_i} means ∑ai[Pi]=0\sum a_i[P_i] = 0 in the class group. The relations form a lattice Λ⊆Zk\Lambda \subseteq \mathbb{Z}^k, and

Cl⁡(K)≅Zk/Λall, \operatorname{Cl}(K) \cong \mathbb{Z}^k / \Lambda_{\text{all}},

where Λall\Lambda_{\text{all}} is the lattice of all relations. The library searches short vectors of O\mathcal{O} and of the primes themselves for elements with smooth norm, reduces the lattice they span, and reads off the Smith normal form. If the lattice found is Λ\Lambda, its index h′h' is a multiple of hh: relations can be missing, never wrong.

Certifying the answer

Systems such as PARI and Sage compute class groups quickly by assuming the generalised Riemann hypothesis, and offer a separate certification step. Here the certification is part of the answer, and no hypothesis is used.

The kernel of the relations gives units, with regulator R′R' (see Units). Let GG be the group generated by all relation elements and the roots of unity. Inside the group of all numbers supported on P1,…,PkP_1, \dots, P_k, the index of GG is

h′h⋅R′R. \frac{h'}{h} \cdot \frac{R'}{R}.

A prime ℓ\ell divides this index exactly when some element of GG is an ℓ\ell-th power in KK without being an ℓ\ell-th power in GG. That can be refuted: reduce GG modulo a prime ideal q\mathfrak{q} of degree 1 with ℓ∣q−1\ell \mid q - 1; raising to the power (q−1)/ℓ(q-1)/\ell gives a homomorphism G/Gℓ→Z/ℓG/G^\ell \to \mathbb{Z}/\ell, which kills every true ℓ\ell-th power. Once as many independent such maps are found as the dimension of G/GℓG/G^\ell, no hidden ℓ\ell-th power exists.

  • For each prime ℓ\ell dividing h′h', this test is run on GG.
  • Any other prime can only divide R′/RR'/R. Friedman proved that the regulator of every number field is at least 0.20520.2052, so R′/R≤R′/0.2052R'/R \le R'/0.2052, and for the primes ℓ\ell up to that bound the same test is run on the units.

When every test passes, h′=hh' = h and R′=RR' = R. A test that fails says more than no: it names a product of the generators that every map takes for an ℓ\ell-th power. The library takes the ℓ\ell-th root of that product in the field (numerically at each embedding, then checked exactly), adds the root to the relation elements, and runs the computation again. The certificate counts these under rootsTaken.

C.certificate;
// { method: "saturation", minkowskiBound: 95n, relations: 68, regulatorLowerBound: 0.2052,
//   unitIndexBound: 18, classNumberPrimes: [2, 3], primesChecked: 7, rootsTaken: 0 }

// the first relations found for Q(⁴√30) give 8; the test at 2 fails, and a square root brings it to 4
idealClassGroup([-30n, 0n, 0n, 0n, 1n], { certify: false }).h;    // 8n, marked proven: false
idealClassGroup([-30n, 0n, 0n, 0n, 1n]).h;                        // 4n, proven

Options: certify: false skips the proof (the result then has proven: false, and the true class number divides the one shown); maxBound (default 2000) refuses fields whose Minkowski bound is larger, since the number of primes grows with it; maxIndexPrime caps the primes ℓ\ell tested. A cubic field with Minkowski bound near 100 takes about half a second; bound 1500 takes ten.

Quadratic fields and forms

For a quadratic field the classes of ideals correspond to classes of binary quadratic forms of the same discriminant, and there the class number is found by listing reduced forms, with no search. Quadratic fields are certified that way: the relation computation has to agree with the count of forms. For a real quadratic field, forms give the narrow class number, which is twice the class number when the fundamental unit has norm +1+1.

const R = idealClassGroup(NumberField.quadratic(79));
R.h;                                // 3n
R.certificate.narrowClassNumber;    // 6n: the fundamental unit 80 + 9√79 has norm +1

const F = NumberField.quadratic(-23);
const I = formToIdeal([2, 1, 3], F);   // the form 2x² + xy + 3y² as an ideal
String(I);                             // "(2, 3/2 + (1/2)√(-23))"
idealClassGroup(F).orderOf(I);         // 3n

For imaginary quadratic fields the class number is also a special value of an L-function, h=L(0,χD)h = L(0, \chi_D) when D<−4D < -4: see Zeta and L values.

Try itEdit the code and run it with @ratmath/numtheory and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs