Rings of integers
In the number is a root of : it has a denominator, yet it behaves like a whole number. The algebraic integers of a number field form a ring, a lattice of rank inside the field, and finding a basis of it is the first step of everything else: discriminants, prime ideals, class groups, units.
A field and its integers
A number field is for a root of an irreducible polynomial; here it is a NumberField from @ratmath/algebraic (re-exported), or just the coefficients of the polynomial, constant first. An element of is an algebraic integer when it is a root of a monic polynomial with whole coefficients. They form the ring , and has a basis over : an integral basis.
import { NumberField, ringOfIntegers } from "@ratmath/numtheory";
const K = new NumberField([-8n, -2n, -1n, 1n]); // α³ − α² − 2α − 8 = 0, Dedekind's field
const O = ringOfIntegers(K);
O.basis; // 1, α, (1/2)α + (1/2)α²
O.discriminant; // -503n
O.index; // 2n: Z[α] has index 2 in the ring of integers
O.signature; // [1, 1]: one real embedding, one pair of complex ones
O.contains(K.gen.mul(K.gen).add(K.gen).div(K.of(2n))); // true: (α² + α)/2 is an integer
O.coordinates(K.gen.mul(K.gen)); // 0, -1, 2: α² = −ω₂ + 2ω₃
String(O.element([0, 0, 1])); // "(1/2)α + (1/2)α²"
The quadratic case is the familiar one: when , and when .
ringOfIntegers(NumberField.quadratic(5)).basis; // 1, 1/2 + (1/2)√5
ringOfIntegers(NumberField.quadratic(-5)).basis; // 1, √(-5)
ringOfIntegers([-19n, 0n, 0n, 1n]).basis; // 1, α, 1/3 + (1/3)α + (1/3)α² (α³ = 19)
The discriminant
The discriminant of the field is , the squared volume of the lattice . It does not depend on the basis. For the lattice the same determinant is the discriminant of the polynomial, and the two differ by the square of the index:
So only primes whose square divides can divide the index. For Dedekind's field, , and the index is 2.
O.polyDiscriminant; // -2012n
O.traceMatrix; // [[3, 1, 3], [1, 5, 18], [3, 18, 29]], with determinant −503
fieldDiscriminant([1n, 1n, 1n, 1n, 1n]); // 125n: the fifth roots of unity
fieldDiscriminant([-2n, 0n, 0n, 0n, 1n]); // -2048n: Q(⁴√2)
O.ramifiedPrimes; // [503n]: the primes dividing the discriminant
How the basis is found: Round 2
Start with the order , where is scaled to be integral, and enlarge it one prime at a time. For a prime , let be the radical of : the elements with some power in . The theorem of Pohst and Zassenhaus says that
is an order containing , and that exactly when is already maximal at . Both steps are linear algebra over . The radical is the kernel of on once (or of the trace form when ), and comes from the kernel of the map sending to multiplication by on . Repeat until nothing grows, for each with .
O.steps;
// [{ p: 2n, exponent: 2, indexExponent: 1, rounds: 1, note: "the order grows by index 2 in 1 round" }]
ringOfIntegers([-19n, 0n, 0n, 1n]).steps.map((s) => s.note);
// ["the order grows by index 3 in 1 round", "already maximal at 19"]
The polynomial need not be monic or have whole coefficients: the generator is rescaled inside, and O.scale says by how much. The discriminant of the polynomial has to be factored, which is the one step that can be slow for large coefficients.
Why Dedekind's field is famous
One might hope that for a well-chosen , as in quadratic fields. In Dedekind's field no works. The prime 2 splits into three different prime ideals of norm 2 (see Prime ideals); if were , those primes would correspond to three different linear factors of a cubic modulo 2, and there are only two linear polynomials modulo 2. So every has even index.
Next: how primes factor in , in Prime ideals; then Class groups and Units.
@ratmath/numtheory and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.