The basic objects in the number field package are number fields and orders. Given an irreducible polynomial f with integer coefficients, the number field K isomorphic to Q[X]/f(X) and the equation order E isomorphic to Z[X]/f(X) can be created using the NumberField and EquationOrder functions. Note that it is possible to create the factor rings Q[X]/f(X) and Z[X]/f(X) using the polynomial ring creation functions and the quo constructor, but that construction will only allow the user arithmetic in these rings, and does not in general give access to structural number field computations, unless a special FldNum flag is set.
It is also possible to make relative extensions, that is, extensions over number fields bigger than Q or orders bigger than Z.
The FieldOfFractions function enables the user to create the number
field associated with a given order.
NumberField(f) : RngUPolElt -> FldNum
Check: BoolElt Default: true
Given a monic irreducible polynomial f of degree n>1 and irreducible over Q, create the number field K=Q(alpha) obtained by adjoining a root alpha of f to Q. The polynomial f is allowed to have either integer coefficients or coefficients from the rational field, but in the latter case, if denominators greater than 1 occur, an equivalent polynomial will be used: instead of f(x) a root of the integral polynomial f'(x)=d^nf(x/d) is used to define K, where d is the least common multiple of the denominators of the coefficients of f.If the optional parameter Check is set to false then the polynomial is not checked for irreducibility. This is useful when building relative extensions (where factoring is time consuming).
The angle bracket notation may be used to assign the root alpha to an identifier: K<y> := NumberField(f).
Check: BoolElt Default: true
Given a sequence s of monic polynomials s_1, ..., s_m, each of degree greater than 1 and irreducible over Q, create the number field K=Q(alpha_1, ..., alpha_m) obtained by adjoining a root alpha_i of each s_i to Q. The polynomials s_i are allowed to have coefficients in Z or in Q, but if in the latter case denominators occur in the coefficients of s_i, an integral polynomial is used instead of s_i, as in the case of the definition of a number field by a single polynomial.If m>1, in fact a tower of extension fields K_0=Q subset K_1=Q(alpha_m) subset K_(2)=Q(alpha_(m - 1), alpha_(m)) subset ... subset K_m = Q(alpha_1, ..., alpha_m)=K is created, and K is a relative extension by s_1 over its ground field K_(m - 1)=Q(alpha_2, ..., alpha_m). Thus the result of this construction is similar to that after m uses of the ext constructor. The angle bracket notation may be used to assign the m generators alpha_i to identifiers: K<a_1, ..., a_m> := NumberField([ a_1, ..., a_m ]); thus the first generator a_1, which corresponds to K.1, generates K over its ground field.
Note that it is important to ensure that in each of the above steps the polynomial s_i is irreducible over K_(i - 1); by default Magma will check that this is the case. If the optional parameter Check is set to false then this checking will not be done.
Check: BoolElt Default: true
Given a monic irreducible polynomial f over the number field K, create the extension field K(alpha) obtained by adjoining a root alpha of f to K. Here K is allowed to be the rational field Q. The polynomial f is allowed to have coefficients in K, or in any order of K; however, if coefficients occur in f which require denominator greater than 1 when expressed on the basis of the equation order of K, the polynomial will be replaced by an equivalent one requiring no such denominators. Unless K equals Q, it is the responsibility of the user to ensure that f is irreducible over K; if K=Q an error results when f is reducible.The angle bracket notation may be used to assign the root alpha to an identifier: K<y> := ext< Q | f >.
Given a ring of polynomials R in one variable over a number field K, create the number field K(alpha) obtained by adjoining a root alpha of f to K. Here the coefficient ring K of R is allowed to be the rational field Q. The polynomial f is allowed to have coefficients in K, but if coefficients occur in f which require denominator greater than 1 when expressed on the basis of the equation order of K, the polynomial will be replaced by an equivalent one requiring no such denominators: f'(x)=d^nf(x/d), where n is the degree of f and d a common denominator. Unless K equals Q, it is the responsibility of the user to ensure that f is irreducible over K; if K=Q an error results when f is reducible.The angle bracket notation may be used to assign the root alpha to an identifier: K<y> := quo< FldNum : R | f >.
If the category FldNum is not specified, quo< R | f > creates the quotient ring R/f as a generic ring (not as a number field), in which only elementary arithmetic is possible.
Given a number field K with ground field G and an element e in K, return the number field H=G(e) generated by e (over G), as well as the embedding homomorphism from H to K.
Check: BoolElt Default: true
Let K be a number field. Let a be an integral element of K chosen such that a is not an n-th power for any n dividing d. Return the number field obtained by ajoining the d-th root of a to K.
Let K and L be number fields. Returns a sequence of fields [M_1, ..., M_r] such that each field M_i contains both a root of the generating polynomial of K and a root of the generating polynomial of L.
> R<x> := PolynomialRing(Integers()); > f := x^4 - 420*x^2 + 40000; > K<y> := NumberField(f);By assigning the generating element to y, we can from here on specify elements in the field as polynomials in y (and the elements will be printed as polynomials in Q[y]/f):
> z := y^5/11; > z; 420/11*y^3 - 40000/11*yThis illustrates the second purpose of the angle brackets K<y>, namely for use in output printing. Without the <y> the printing would use $.1 instead.
> R<x> := PolynomialRing(Integers()); > Composite := function( K, L ) > T<y> := PolynomialRing( K ); > f := T!DefiningPolynomial( L ); > ff := Factorization(f); > LKM := NumberField(ff[1][1]); > return AbsoluteField(LKM); > end function;To create, for example, the field Q(sqrt(2), sqrt(3), sqrt(5)), the above function should be applied twice:
> K := NumberField(x^2-3); > L := NumberField(x^2-2); > M := NumberField(x^2-5); > KL := Composite(K, L); > KLM<w> := Composite(KL, M); > KLM; NumberField( w^8 - 40*w^6 + 352*w^4 - 960*w^2 + 576 )
Return the number field that is the quotient field of the order O.
Given a number field K with ground field Q, this function will attempt to find an isomorphic field L with a better defining polynomial (in the sense defined below) than that of K. If such an L is found it will be returned; otherwise K will be returned.If the argument d is not specified, the polynomial g with integer coefficients is defined to be better than f if it is monic, irreducible, defines a number field isomorphic to K and its discriminant is smaller (in absolute value) than that of f. If a second argument d is specified, then g is defined to be better if in addition to the previous requirements d is not an index divisor, that is, if d does not divide the index [O_L : E_L] of the equation order E_L of L in the maximal order O_L.
These functions have been obsoleted by OptimizedRepresentation and will disappear in the next release. The return values are false if no better field could be found (in the sense mentioned under OptimizedRepresentation), otherwise true and the appropriate field or order.
> R<x> := PolynomialRing(Integers()); > K := NumberField(x^4-420*x^2+40000); > q, L := BetterPolynomial(K); > q; true > L; NumberField( $.1^4 + $.1^3 - 36*$.1^2 - 95*$.1 + 5 ) > r := BetterPolynomial(L); > r; false > f := x^4-420*x^2+40000; > Factorization(Discriminant(f)); [ <2, 18>, <5, 8>, <41, 2> ] > g := x^4+x^3-36*x^2-95*x+5; > Factorization(Discriminant(g)); [ <2, 6>, <5, 2>, <41, 2> ] > OL := MaximalOrder(L); > EL := EquationOrder(L); > Index(OL, EL); 8As we see from this computation, the prime 5 (as well as 41) still divides the discriminant of g twice. That means that, potentially, 5 would still divide the index of the equation order in the maximal order O_L of L. However, in fact E_L has only index 8 in O_L.
An important subring of a number field K is its ring of integers
( O)_K,
consisting of integral elements of the field; that is, elements
that are roots of monic integer polynomials. Subrings of finite index
of the ring of integers consisting of integral elements are called
orders of the field; the ring of integers itself is often called the
maximal order. The order
( E)_K=Z[alpha] of K=Q(alpha) isomorphic to Q[X]/f(X) is
called the equation order of K; obviously ( E)_K subset ( O)_K.
EquationOrder(f) : RngUPolElt -> RngOrd
Check: BoolElt Default: true
Given an irreducible monic integer polynomial f of degree greater than 1, return the equation order E=Z[X]/f(X) corresponding to f. If the optional parameter Check is set to false then the polynomial will not be checked for irreducibility.
Return the equation order corresponding to the polynomial with which the number field K was defined. Thus this function returns the extension of the equation order of the ground field of K by the defining polynomial of K.
Return the equation order corresponding to the polynomial with which the field of fractions K of O was defined.
Al: MonStrElt Default:
Dedekind: BoolElt Default: true
Splitting: BoolElt Default: true
ReducedDiscriminant: BoolElt Default: true
Create the ring of integers of the number field K; this includes the computation of an integral basis for K. The field K must have Q as its ground field.The parameter Al allows the user to select either the Round 2 or Round 4 algorithms. The default strategy is to use Round 4 for fields of degree larger than 2. If an order of degree two or less arises during the execution of the Round 4 algorithm, the Round 2 algorithm will be applied to it.
If the Round 2 algorithm is selected, and the parameter Splitting is true, an attempt is made to split the algebra Z[x]/<f> as in the Round 4 algorithm. If the Round 2 algorithm is selected by the user then splitting will be performed if the degree of the extension is 7 or greater. If, in addition, the parameter Dedekind is set true, then the extended Dedekind test is performed on the equation order (see Cohen's book, p 299). If ReducedDiscriminant is set true, the reduced discriminant is first factored so as to obtain the prime factors of the discriminant.
Check: BoolElt Default: true
Al: MonStrElt Default:
Dedekind: BoolElt Default: true
Splitting: BoolElt Default: true
ReducedDiscriminant: BoolElt Default: true
This is equivalent to MaximalOrder(NumberField(f)).
Al: MonStrElt Default:
Dedekind: BoolElt Default: true
Splitting: BoolElt Default: true
ReducedDiscriminant: BoolElt Default: true
This is equivalent to MaximalOrder(FieldOfFractions(O)).
> R<x> := PolynomialRing(Integers()); > K := NumberField(x^4-420*x^2+40000); > E := EquationOrder(K); > O := MaximalOrder(K); > Index(O, E); 64000but note that entirely different things happen here: for the equation order nothing has to be computed, but the determination of the maximal order involves the complicated Round 2 (or 4) algorithm. In our particular example above, E is a subring of index 2^9.5^3 in O_K (see also below).
Create the suborder of O generated (as an algebra over Z) by the elements a_1, ..., a_r in O, that is, create Z[a_1, ..., a_r]. If the algebra does not have full rank as a sub-module of O, an error results. Note however that it is currently not required that 1 is in the sub-ring.
Given an order O, and elements a_1, ..., a_r in the ring of integers of the field of fractions of O, create the order O[a_1, ..., a_r].
Given an order O in a number field K, and a polynomial f of degree n with coefficients in O, create the extension E of O by a root of f (which forms a free module of rank n over O: E isomorphic to O[alpha]); it is necessary for f to be irreducible over K.
Add two orders defined over the same suborder.
Create the equation order with basis Basis(O)*T/d.
Provided O is not an equation order, O is a transformation of some order O'. This function returns O' (and must not be called with an equation order as argument).
Al: MonStrElt Default:
Dedekind: BoolElt Default: true
Splitting: BoolElt Default: true
ReducedDiscriminant: BoolElt Default: true
The p-maximal overorder of O (see also the example below).
Returns the multiplicator ring of the ideal I of the order O, that is, the subring of elements of the field of fractions K of O multiplying I into itself: M={ x: x in K | xI subset I}. Here K must have ground field Q.
> pMaximalOverOrder := function(ord, p) > ovr := MultiplicatorRing(pRadical(ord,p)); > print "index is", Index(ovr, ord); > return (Index(ovr, ord) eq 1) select ovr else $$(ovr, p); > end function;which finds the largest overorder in which the given order has p-power index. This function is now simply called for the equation order, with all primes dividing the discriminant:
> Round2 := function(E, K) > // E should be the equation order of a number field K > d := Discriminant(E); > fact := Factorization(Abs(d)); > print fact; > M := E; > for x in fact do > M := M+pMaximalOverOrder(E, x[1]); > end for; > print "index of equation order in maximal order is:", Index(M, E); > return M; > end function;In our running example, this produces the following output:
> R<x> := PolynomialRing(Integers()); > K := NumberField(x^4-420*x^2+40000); > E := EquationOrder(K); > Round2(E, K); [ <2, 18>, <5, 8>, <41, 2> ] index is 2 index is 4 index is 8 index is 4 index is 2 index is 1 index is 5 index is 25 index is 1 index is 1 index of equation order in maximal order is: 64000 Order with field of fractions: NumberField( $.1^4 - 420*$.1^2 + 40000 )
Elements of number fields and of orders are displayed quite differently. Number field elements are always printed as a polynomial (of degree less than the degree of the field) with rational coefficients in the primitive element of the field; that is, as an element of G[x]/f, where f was the defining polynomial of the field over the ground field G. Since in general G will be a number field itself, elements in relative extensions (G strictly bigger than Q) will look like multivariate polynomials (in fact they are recursively defined univariate polynomials).
Elements of orders are displayed as sequences of integer coefficients, referring to the basis of the order. To convert this Z-basis representation to a polynomial expression (in the primitive element of the field of fractions), the element should be coerced into the field (using !).
Coerce a into the field K. Here a may be an integer or a rational field element, or an element from a subfield of K, or from an order in such.
Given the number field, K=G(alpha) of degree m and a sequence [a_0, ..., a_(m - 1)] of elements of G, construct the element a_0 + a_1alpha + ... a_(m - 1)alpha^(m - 1) of K.
Coerce a into the order O. Here a is allowed to be an integer, or an integral element of the field of fractions of O.
Given the order O of a number field K of degree m and elements a_0, a_(1), ..., a_(m - 1) in the ground order of O, construct the element a_0alpha_0 + a_1 alpha_1 + ... a_(m - 1) alpha_(m - 1) of O, where alpha_0, ..., alpha_(m - 1) is the basis for the order.
For an element a of a number field K, a sequence of coefficients (of length degree of K) with respect to the power basis is returned. For an element of an order O, the sequence of (integral) coefficients of the element with respect to the basis of O are returned.
Given an number field K and an interval R = [a, b], create a random element of K whose coefficients lie in the interval [a, b].
Given an orderO and an interval R = [a, b], create a random element of the order O whose coefficients lie in the interval [a, b].
> R<x> := PolynomialRing(Integers()); > K<y> := NumberField(x^4-420*x^2+40000); > O := MaximalOrder(K); > e := O ! (y^2/40 + y/4); > f := elt< O | [0, 0, 1, 0]>; > f eq e; trueThe construction will fail if the element is not in O.
The general ideal constructor can be used to create ideals in
orders of number fields, as described below. It should be noted
that ideals in orders are allowed to be fractional ideals,
so we allow number field elements as generators.
ideal< O | a_1, a_2, ... , a_m > : RngOrd, FldNumElt, ..., FldNumElt -> RngOrdIdl
Given an order O, as well as elements a_1, a_2, ..., a_n coercible into the field of fractions K of O, create the fractional ideal of O generated by these elements.Note that, contrary to the general case for the constructors, the right hand side elements are not necessarily contained in the left hand side.
The denominator of the ideal will be the smallest positive integer d such that all d.a_i are contained in O; the ideal will then be 1/d times the integral ideal generated by the d.a_i, i=1, ..., m.
Normal: Integer Default: 1Using the parameter Normal it is possible to specify that the elements given form a two-element presentation for the ideal. In this case m=1 or m=2 (that is, one or two generators can be specified only); Normal := n for some integer n>1 indicates that the two elements form a two element n-normal presentation for the ideal. If n=1, the presentation may or may not be normal.
> R<x> := PolynomialRing(Integers()); > f := x^4-420*x^2+40000; > K<y> := NumberField(f); > E := EquationOrder(K); > O := MaximalOrder(K); > elt := O ! (y^2/40+y/4); > elt in E; false > I := ideal< O | elt >; > I; Ideal of Maximal Order of E Basis: [ 5 0 0 15] [ 0 1 0 0] [ 0 0 1 0] [ 0 0 0 25]