Units
The units of a ring of integers are the elements of norm . Dirichlet's theorem says what the group looks like: finitely many roots of unity, times a free group whose rank is fixed by the number of real and complex embeddings. Finding generators is harder than knowing they exist.
Dirichlet's unit theorem
If has real embeddings and pairs of complex ones, then
where is the group of roots of unity in . A set of units generating the free part is a system of fundamental units.
import { NumberField, unitGroup } from "@ratmath/numtheory";
const U = unitGroup(NumberField.quadratic(2));
U.rank; // 1
U.torsionOrder; // 2: the roots of unity are ±1
U.fundamentalUnits; // [1 + √2]
U.regulator; // 0.881373587019543 = ln(1 + √2)
unitGroup(NumberField.gaussian()).torsionOrder; // 4: ±1, ±i, and rank 0
unitGroup(NumberField.quadratic(-3)).torsionOrder; // 6
const V = unitGroup([-2n, 0n, 0n, 1n]); // Q(∛2): r₁ = 1, r₂ = 1, rank 1
String(V.fundamentalUnits[0]); // "1 + α + α²"
const W = unitGroup([2n, 0n, -4n, 0n, 1n]); // totally real quartic: rank 3
W.fundamentalUnits.map(String); // ["1 − α", "3 + 4α − α² − α³", "1 + 2α − α³"]
For a real quadratic field the fundamental unit comes from the continued fraction of , and it can be large: for it is .
The regulator
Send a unit to the vector of over the embeddings (doubled at complex ones). The image of the unit group is a lattice of rank in the hyperplane where the coordinates sum to zero, and the regulator is the determinant of any minor of the matrix of fundamental units. A sub-system of units of index has regulator , so a regulator certifies itself only together with a lower bound: this is how the units are proven fundamental, as described in Class groups.
regulator([-2n, 0n, 0n, 1n]); // 1.347377348329384
regulator([1n, -3n, 0n, 1n]); // 0.8492874506461925: the cubic field inside Q(ζ₉)
V.certificate;
// { method: "saturation", …, regulatorLowerBound: 0.2052, unitIndexBound: 6, primesChecked: 3 }
For : the unit found has regulator 1.347; if it were an -th power of a smaller unit, that one would have regulator , so ; and reductions modulo suitable primes show that it is not a square, a cube or a fifth power, up to sign. Hence it is fundamental.
Roots of unity
If has a real embedding the only roots of unity are . Otherwise divides for every prime not dividing , which leaves few candidates after a handful of primes; each candidate is settled by looking for a root of the cyclotomic polynomial in , exactly.
const Z5 = unitGroup([1n, 1n, 1n, 1n, 1n]); // Q(ζ₅)
Z5.torsionOrder; // 10
String(Z5.rootOfUnity); // "1 + α + α² + α³", which is −ζ₅⁴: a primitive tenth root
Z5.fundamentalUnits.map(String); // ["α + α² + α³"], and its regulator is 2·ln((1 + √5)/2)
Writing a unit on the fundamental ones
Every unit is in one way. The exponents come from solving a linear system in the logarithms and rounding; the answer is then checked exactly.
const K = new NumberField([-2n, 0n, 0n, 1n]);
const [eps] = V.fundamentalUnits;
V.exponents(eps.pow(7).neg()); // { torsion: 1, exponents: [7n] }: −ε⁷
V.exponents(K.of([[-1n, 1n], [1n, 1n]])); // { torsion: 0, exponents: [-1n] }: α − 1 = 1/ε
V.isUnit(K.gen); // false: α has norm 2
Units are also what makes generators of principal ideals ambiguous: two generators differ by a unit. And they are the solutions of norm equations , of which Pell's equation is the quadratic case.
@ratmath/numtheory and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.