Number fields

Prime ideals

In Z[−5]\mathbb{Z}[\sqrt{-5}], 6=2⋅3=(1+−5)(1−−5)6 = 2 \cdot 3 = (1 + \sqrt{-5})(1 - \sqrt{-5}), and none of the four factors can be broken further. Unique factorisation of numbers is lost. It comes back for ideals: every ideal is a product of prime ideals in exactly one way.

How a prime decomposes

In the ring of integers O\mathcal{O} of a field of degree nn, a rational prime pp generates an ideal that factors as

pO=P1e1⋯Pgeg,∑ieifi=n, p\mathcal{O} = P_1^{e_1} \cdots P_g^{e_g}, \qquad \sum_{i} e_i f_i = n,

where fif_i is the residue degree, O/Pi≅Fpfi\mathcal{O}/P_i \cong \mathbb{F}_{p^{f_i}}, and eie_i the ramification index. The prime is inert when pOp\mathcal{O} is itself prime, ramified when some ei>1e_i > 1 (exactly the primes dividing the discriminant), and splits completely when there are nn primes of degree 1.

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

const K = NumberField.quadratic(-5);
const O = ringOfIntegers(K);
O.describePrime(2).text;     // "2·O = (2, 1 + √(-5))²"                    ramified
O.describePrime(3).text;     // "3·O = (3, 1 + √(-5)) · (3, 2 + √(-5))"    splits
O.describePrime(11).text;    // "11·O = (11)"                              inert

const [P2] = O.primesAbove(2);
[P2.p, P2.e, P2.f, P2.norm];   // [2n, 2, 1, 2n]
P2.generators;                 // 2, 1 + √(-5): every prime ideal has two generators, one of them p

Dedekind and Kummer

When pp does not divide the index [O:Z[α]][\mathcal{O} : \mathbb{Z}[\alpha]], the decomposition can be read from the polynomial: factor ff modulo pp,

f≡g1e1⋯grer(modp)⟹Pi=(p, gi(α)),fi=deg⁡gi. f \equiv g_1^{e_1} \cdots g_r^{e_r} \pmod p \quad\Longrightarrow\quad P_i = (p,\ g_i(\alpha)), \quad f_i = \deg g_i.

For Q(−5)\mathbb{Q}(\sqrt{-5}): x2+5≡(x+1)2(mod2)x^2 + 5 \equiv (x+1)^2 \pmod 2, ≡(x+1)(x+2)(mod3)\equiv (x+1)(x+2) \pmod 3, and it is irreducible modulo 11. That is the table above.

When pp divides the index the recipe fails, and Dedekind's cubic x3−x2−2x−8x^3 - x^2 - 2x - 8 is the standard example: modulo 2 the polynomial is x2(x+1)x^2(x+1), which suggests a ramified prime, while in truth 2 splits completely.

const D = ringOfIntegers(new NumberField([-8n, -2n, -1n, 1n]));
D.describePrime(2).text;
// "2·O = (2, (3/2)α + (1/2)α²) · (2, 1 + (1/2)α + (1/2)α²) · (2, 1 + α)"
D.primesAbove(2).map((P) => [P.e, P.f]);     // [[1, 1], [1, 1], [1, 1]]
D.describePrime(503).text;                   // "503·O = (503, 204 + α) · (503, 149 + α)²"
D.describePrime(5).text;                     // "5·O = (5, 4 + α) · (5, 3 + α²)": degrees 1 and 2

The library does not use the recipe as its method. For every prime it splits the finite ring A=O/pOA = \mathcal{O}/p\mathcal{O} directly: the radical of AA is found as in Round 2; modulo the radical, AA is a product of fields, one for each prime, and the elements fixed by x↦xpx \mapsto x^p form a copy of Fpg\mathbb{F}_p^g whose idempotents cut the product apart. The ramification index of each prime is then the valuation of pp. When the recipe applies, the second generator shown is the one it gives.

Ideals

An ideal is kept as a basis over Z\mathbb{Z} in Hermite normal form, so two ideals are equal exactly when their matrices are. Its norm is the index [O:I][\mathcal{O} : I], and the norm of a principal ideal is the absolute value of the norm of its generator.

const I = O.ideal(6);
String(I);              // "(2, 1 + √(-5))² · (3, 1 + √(-5)) · (3, 2 + √(-5))"
I.norm;                 // 36

const A = O.ideal(K.of([[1n, 1n], [1n, 1n]]));   // the ideal generated by 1 + √−5
String(A);              // "(2, 1 + √(-5)) · (3, 1 + √(-5))"
A.norm;                 // 6

const [P3, Q3] = O.primesAbove(3);
const J = P2.toIdeal().mul(P3);
J.equals(A);                         // true
J.basis;                             // 6, 1 + √(-5)
J.mul(J.inverse()).isOne;            // true: fractional ideals form a group
P3.toIdeal().add(Q3).isOne;          // true: different primes are coprime
P2.toIdeal().pow(2).equals(O.ideal(2));   // true

So the two factorisations of 6 are the same four prime ideals grouped in two ways: 2=P222 = P_2^2, 3=P3Q33 = P_3Q_3, 1+−5=P2P31 + \sqrt{-5} = P_2P_3, 1−−5=P2Q31 - \sqrt{-5} = P_2Q_3. The numbers 2, 3 and 1±−51 \pm \sqrt{-5} are irreducible because P2P_2, P3P_3, Q3Q_3 are not principal, which is the subject of Class groups.

Valuations

The exponent of a prime PP in an element or an ideal is its valuation vPv_P. It is computed with one multiplication per step: there is an element τ\tau with τP⊆pO\tau P \subseteq p\mathcal{O} but τ∉pO\tau \notin p\mathcal{O}, and vP(x)v_P(x) is the number of times xx can be multiplied by τ/p\tau/p and stay integral.

P2.valuation(8);                              // 6: 8 = 2³ and 2 = P₂²
P2.valuation(K.of([[1n, 1n], [1n, 1n]]));     // 1
P2.valuation(K.of([[1n, 4n]]));               // -4: valuations of fractions are negative
P2.valuation(I);                              // 2
I.factor().map((f) => [String(f.prime), f.exponent]);
// [["(2, 1 + √(-5))", 2], ["(3, 1 + √(-5))", 1], ["(3, 2 + √(-5))", 1]]

Factoring an ideal needs only the factorisation of its norm into rational primes: the primes above those are the only candidates, and a valuation settles each.

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