Prime ideals
In , , 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 of a field of degree , a rational prime generates an ideal that factors as
where is the residue degree, , and the ramification index. The prime is inert when is itself prime, ramified when some (exactly the primes dividing the discriminant), and splits completely when there are 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 does not divide the index , the decomposition can be read from the polynomial: factor modulo ,
For : , , and it is irreducible modulo 11. That is the table above.
When divides the index the recipe fails, and Dedekind's cubic is the standard example: modulo 2 the polynomial is , 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 directly: the radical of is found as in Round 2; modulo the radical, is a product of fields, one for each prime, and the elements fixed by form a copy of whose idempotents cut the product apart. The ramification index of each prime is then the valuation of . When the recipe applies, the second generator shown is the one it gives.
Ideals
An ideal is kept as a basis over in Hermite normal form, so two ideals are equal exactly when their matrices are. Its norm is the index , 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: , , , . The numbers 2, 3 and are irreducible because , , are not principal, which is the subject of Class groups.
Valuations
The exponent of a prime in an element or an ideal is its valuation . It is computed with one multiplication per step: there is an element with but , and is the number of times can be multiplied by 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.
@ratmath/numtheory and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.