AUTHORS:
EXAMPLES:
We define an absolute order:
sage: K.<a> = NumberField(x^2 + 1); O = K.order(2*a)
sage: O.basis()
[1, 2*a]
We compute a basis for an order in a relative extension that is generated by 2 elements:
sage: K.<a,b> = NumberField([x^2 + 1, x^2 - 3]); O = K.order([3*a,2*b])
sage: O.basis()
[1, 3*a - 2*b, -6*b*a + 6, 3*a]
We compute a maximal order of a degree 10 field:
sage: K.<a> = NumberField((x+1)^10 + 17)
sage: K.maximal_order()
Maximal Order in Number Field in a with defining polynomial x^10 + 10*x^9 + 45*x^8 + 120*x^7 + 210*x^6 + 252*x^5 + 210*x^4 + 120*x^3 + 45*x^2 + 10*x + 18
We compute a suborder, which has index a power of 17 in the maximal order:
sage: O = K.order(17*a); O
Order in Number Field in a with defining polynomial x^10 + 10*x^9 + 45*x^8 + 120*x^7 + 210*x^6 + 252*x^5 + 210*x^4 + 120*x^3 + 45*x^2 + 10*x + 18
sage: m = O.index_in(K.maximal_order()); m
23453165165327788911665591944416226304630809183732482257
sage: factor(m)
17^45
Bases: sage.rings.number_field.order.Order
Return the discriminant of this order.
EXAMPLES:
sage: K.<a> = NumberField(x^8 + x^3 - 13*x + 26)
sage: O = K.maximal_order()
sage: factor(O.discriminant())
3 * 11 * 13^2 * 613 * 1575917857
sage: L = K.order(13*a^2)
sage: factor(L.discriminant())
3^3 * 5^2 * 11 * 13^60 * 613 * 733^2 * 1575917857
sage: factor(L.index_in(O))
3 * 5 * 13^29 * 733
sage: L.discriminant() / O.discriminant() == L.index_in(O)^2
True
Return the absolute order associated to this order, which is just this order again since this is an absolute order.
EXAMPLES:
sage: K.<a> = NumberField(x^3 + 2)
sage: O1 = K.order(a); O1
Order in Number Field in a with defining polynomial x^3 + 2
sage: O1.absolute_order() is O1
True
Return the basis over for this order.
EXAMPLES:
sage: k.<c> = NumberField(x^3 + x^2 + 1)
sage: O = k.maximal_order(); O
Maximal Order in Number Field in c with defining polynomial x^3 + x^2 + 1
sage: O.basis()
[1, c, c^2]
The basis is an immutable sequence:
sage: type(O.basis())
<class 'sage.structure.sequence.Sequence'>
The generator functionality uses the basis method:
sage: O.0
1
sage: O.1
c
sage: O.gens()
[1, c, c^2]
sage: O.ngens()
3
Return a new order isomorphic to this one in the number field with given variable names.
EXAMPLES:
sage: R = EquationOrder(x^3 + x + 1, 'alpha'); R
Order in Number Field in alpha with defining polynomial x^3 + x + 1
sage: R.basis()
[1, alpha, alpha^2]
sage: S = R.change_names('gamma'); S
Order in Number Field in gamma with defining polynomial x^3 + x + 1
sage: S.basis()
[1, gamma, gamma^2]
Return the discriminant of this order.
EXAMPLES:
sage: K.<a> = NumberField(x^8 + x^3 - 13*x + 26)
sage: O = K.maximal_order()
sage: factor(O.discriminant())
3 * 11 * 13^2 * 613 * 1575917857
sage: L = K.order(13*a^2)
sage: factor(L.discriminant())
3^3 * 5^2 * 11 * 13^60 * 613 * 733^2 * 1575917857
sage: factor(L.index_in(O))
3 * 5 * 13^29 * 733
sage: L.discriminant() / O.discriminant() == L.index_in(O)^2
True
Return the index of self in other. This is a lattice index, so it is a rational number if self isn’t contained in other.
INPUT:
OUTPUT:
a rational number
EXAMPLES:
sage: k.<i> = NumberField(x^2 + 1)
sage: O1 = k.order(i)
sage: O5 = k.order(5*i)
sage: O5.index_in(O1)
5
sage: k.<a> = NumberField(x^3 + x^2 - 2*x+8)
sage: o = k.maximal_order()
sage: o
Maximal Order in Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
sage: O1 = k.order(a); O1
Order in Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
sage: O1.index_in(o)
2
sage: O2 = k.order(1+2*a); O2
Order in Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
sage: O1.basis()
[1, a, a^2]
sage: O2.basis()
[1, 2*a, 4*a^2]
sage: o.index_in(O2)
1/16
Return the intersection of this order with another order.
EXAMPLES:
sage: k.<i> = NumberField(x^2 + 1)
sage: O6 = k.order(6*i)
sage: O9 = k.order(9*i)
sage: O6.basis()
[1, 6*i]
sage: O9.basis()
[1, 9*i]
sage: O6.intersection(O9).basis()
[1, 18*i]
sage: (O6 & O9).basis()
[1, 18*i]
sage: (O6 + O9).basis()
[1, 3*i]
Returns the underlying free module corresponding to this order, embedded in the vector space corresponding to the ambient number field.
EXAMPLES:
sage: k.<a> = NumberField(x^3 + x + 3)
sage: m = k.order(3*a); m
Order in Number Field in a with defining polynomial x^3 + x + 3
sage: m.module()
Free module of degree 3 and rank 3 over Integer Ring
Echelon basis matrix:
[1 0 0]
[0 3 0]
[0 0 9]
Return the equation order generated by a root of the irreducible polynomial f or list of polynomials (to construct a relative equation order).
IMPORTANT: Note that the generators of the returned order need not be roots of , since the generators of an order are – in Sage – module generators.
EXAMPLES:
sage: O.<a,b> = EquationOrder([x^2+1, x^2+2])
sage: O
Relative Order in Number Field in a with defining polynomial x^2 + 1 over its base field
sage: O.0
-b*a - 1
sage: O.1
-3*a + 2*b
Of course the input polynomial must be integral:
sage: R = EquationOrder(x^3 + x + 1/3, 'alpha'); R
...
ValueError: each generator must be integral
sage: R = EquationOrder( [x^3 + x + 1, x^2 + 1/2], 'alpha'); R
...
ValueError: each generator must be integral
Bases: sage.rings.ring.IntegralDomain
An order in a number field.
An order is a subring of the number field that has -rank equal to the degree of the number field over .
EXAMPLES:
sage: K.<theta> = NumberField(x^4 + x + 17)
sage: K.maximal_order()
Maximal Order in Number Field in theta with defining polynomial x^4 + x + 17
sage: R = K.order(17*theta); R
Order in Number Field in theta with defining polynomial x^4 + x + 17
sage: R.basis()
[1, 17*theta, 289*theta^2, 4913*theta^3]
sage: R = K.order(17*theta, 13*theta); R
Order in Number Field in theta with defining polynomial x^4 + x + 17
sage: R.basis()
[1, theta, theta^2, theta^3]
sage: R = K.order([34*theta, 17*theta + 17]); R
Order in Number Field in theta with defining polynomial x^4 + x + 17
sage: K.<b> = NumberField(x^4 + x^2 + 2)
sage: (b^2).charpoly().factor()
(x^2 + x + 2)^2
sage: K.order(b^2)
...
ValueError: the rank of the span of gens is wrong
Returns the absolute degree of this order, ie the degree of this order over .
EXAMPLES:
sage: K.<a> = NumberField(x^3 + 2)
sage: O = K.maximal_order()
sage: O.absolute_degree()
3
Return the ambient number field that contains self.
This is the same as self.number_field() and self.fraction_field()
EXAMPLES:
sage: k.<z> = NumberField(x^2 - 389)
sage: o = k.order(389*z + 1)
sage: o
Order in Number Field in z with defining polynomial x^2 - 389
sage: o.basis()
[1, 389*z]
sage: o.ambient()
Number Field in z with defining polynomial x^2 - 389
Return a basis over of this order.
EXAMPLES:
sage: K.<a> = NumberField(x^3 + x^2 - 16*x + 16)
sage: O = K.maximal_order(); O
Maximal Order in Number Field in a with defining polynomial x^3 + x^2 - 16*x + 16
sage: O.basis()
[1, 1/4*a^2 + 1/4*a, a^2]
Return the class group of this order.
(Currently only implemented for the maximal order.)
EXAMPLES:
sage: k.<a> = NumberField(x^2 + 5077)
sage: O = k.maximal_order(); O
Maximal Order in Number Field in a with defining polynomial x^2 + 5077
sage: O.class_group()
Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077
Return the class number of this order.
EXAMPLES:
sage: ZZ[2^(1/3)].class_number()
1
sage: QQ[sqrt(-23)].maximal_order().class_number()
3
Note that non-maximal orders aren’t supported yet:
sage: ZZ[3*sqrt(-3)].class_number()
...
NotImplementedError: computation of class numbers of non-maximal orders is not implemented
Returns the coordinate vector of with respect to this order.
INPUT:
OUTPUT:
A vector of length (the degree of the field) giving the coordinates of with respect to the integral basis of the order. In general this will be a vector of rationals; it will consist of integers if and only if is in the order.
AUTHOR: John Cremona 2008-11-15
ALGORITHM:
Uses linear algebra. The change-of-basis matrix is cached. Provides simpler implementations for _contains_(), is_integral() and smallest_integer().
EXAMPLES:
sage: K.<i> = QuadraticField(-1)
sage: OK = K.ring_of_integers()
sage: OK_basis = OK.basis(); OK_basis
[1, i]
sage: a = 23-14*i
sage: acoords = OK.coordinates(a); acoords
(23, -14)
sage: sum([OK_basis[j]*acoords[j] for j in range(2)]) == a
True
sage: OK.coordinates((120+340*i)/8)
(15, 85/2)
sage: O = K.order(3*i)
sage: O.is_maximal()
False
sage: O.index_in(OK)
3
sage: acoords = O.coordinates(a); acoords
(23, -14/3)
sage: sum([O.basis()[j]*acoords[j] for j in range(2)]) == a
True
Return the degree of this order, which is the rank of this order as a -module.
EXAMPLES:
sage: k.<c> = NumberField(x^3 + x^2 - 2*x+8)
sage: o = k.maximal_order()
sage: o.degree()
3
sage: o.rank()
3
Return the fraction field of this order, which is the ambient number field.
EXAMPLES:
sage: K.<b> = NumberField(x^4 + 17*x^2 + 17)
sage: O = K.order(17*b); O
Order in Number Field in b with defining polynomial x^4 + 17*x^2 + 17
sage: O.fraction_field()
Number Field in b with defining polynomial x^4 + 17*x^2 + 17
Return the fractional ideal of the maximal order with given generators.
EXAMPLES:
sage: K.<a> = NumberField(x^2 + 2)
sage: R = K.maximal_order()
sage: R.fractional_ideal(2/3 + 7*a, a)
Fractional ideal (-1/3*a)
Return the free -module contained in the vector space associated to the ambient number field, that corresponds to this ideal.
EXAMPLES:
sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
sage: O = K.maximal_order(); O.basis()
[1, 1/2*a^2 + 1/2*a, a^2]
sage: O.free_module()
Free module of degree 3 and rank 3 over Integer Ring
User basis matrix:
[ 1 0 0]
[ 0 1/2 1/2]
[ 0 0 1]
An example in a relative extension. Notice that the module is a -module in the absolute_field associated to the relative field:
sage: K.<a,b> = NumberField([x^2 + 1, x^2 + 2])
sage: O = K.maximal_order(); O.basis()
[(-3/2*b - 5)*a + 7/2*b - 2, -3*a + 2*b, -2*b*a - 3, -7*a + 5*b]
sage: O.free_module()
Free module of degree 4 and rank 4 over Integer Ring
User basis matrix:
[1/4 1/4 3/4 3/4]
[ 0 1/2 0 1/2]
[ 0 0 1 0]
[ 0 0 0 1]
Return ‘th module generator of this order.
EXAMPLES:
sage: K.<c> = NumberField(x^3 + 2*x + 17)
sage: O = K.maximal_order(); O
Maximal Order in Number Field in c with defining polynomial x^3 + 2*x + 17
sage: O.basis()
[1, c, c^2]
sage: O.gen(1)
c
sage: O.gen(2)
c^2
sage: O.gen(5)
...
IndexError: no 5th generator
sage: O.gen(-1)
...
IndexError: no -1th generator
Return a list of the module generators of this order.
Note
For a (much smaller) list of ring generators use ring_generators().
EXAMPLES:
sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
sage: O = K.maximal_order()
sage: O.gens()
[1, 1/2*a^2 + 1/2*a, a^2]
Return the integral ideal with given generators.
EXAMPLES:
sage: K.<a> = NumberField(x^2 + 7)
sage: R = K.maximal_order()
sage: R.ideal(2/3 + 7*a, a)
...
ValueError: ideal must be integral; use fractional_ideal to create a non-integral ideal.
sage: R.ideal(7*a, 77 + 28*a)
Fractional ideal (7)
sage: R = K.order(4*a)
sage: R.ideal(8)
...
NotImplementedError: ideals of non-maximal orders not yet supported.
This function is called implicitly below:
sage: R = EquationOrder(x^2 + 2, 'a'); R
Order in Number Field in a with defining polynomial x^2 + 2
sage: (3,15)*R
Fractional ideal (3)
The zero ideal is handled properly:
sage: R.ideal(0)
Ideal (0) of Number Field in a with defining polynomial x^2 + 2
Return the integral closure of this order.
EXAMPLES:
sage: K.<a> = QuadraticField(5)
sage: O2 = K.order(2*a); O2
Order in Number Field in a with defining polynomial x^2 - 5
sage: O2.integral_closure()
Maximal Order in Number Field in a with defining polynomial x^2 - 5
sage: OK = K.maximal_order()
sage: OK is OK.integral_closure()
True
Return False (because an order is never a field).
EXAMPLES:
sage: L.<alpha> = NumberField(x**4 - x**2 + 7)
sage: O = L.maximal_order() ; O.is_field()
False
sage: CyclotomicField(12).ring_of_integers().is_field()
False
Return True if this ring is integrally closed, i.e., is equal to the maximal order.
EXAMPLES:
sage: K.<a> = NumberField(x^2 + 189*x + 394)
sage: R = K.order(2*a)
sage: R.is_integrally_closed()
False
sage: R
Order in Number Field in a with defining polynomial x^2 + 189*x + 394
sage: S = K.maximal_order(); S
Maximal Order in Number Field in a with defining polynomial x^2 + 189*x + 394
sage: S.is_integrally_closed()
True
Returns True if this is the maximal order.
EXAMPLE:
sage: k.<i> = NumberField(x^2 + 1)
sage: O3 = k.order(3*i); O5 = k.order(5*i); Ok = k.maximal_order(); Osum = O3 + O5
sage: Osum.is_maximal()
True
sage: O3.is_maximal()
False
sage: O5.is_maximal()
False
sage: Ok.is_maximal()
True
An example involving a relative order::
sage: K.<a,b> = NumberField([x^2 + 1, x^2 - 3]); O = K.order([3*a,2*b]); O
Relative Order in Number Field in a with defining polynomial x^2 + 1 over its base field
sage: O.is_maximal()
False
Return True (because orders are always Noetherian)
EXAMPLES:
sage: L.<alpha> = NumberField(x**4 - x**2 + 7)
sage: O = L.maximal_order() ; O.is_noetherian()
True
sage: E.<w> = NumberField(x^2 - x + 2)
sage: OE = E.ring_of_integers(); OE.is_noetherian()
True
Return True if self and other are both orders in the same ambient number field and self is a subset of other.
EXAMPLES:
sage: W.<i> = NumberField(x^2 + 1)
sage: O5 = W.order(5*i)
sage: O10 = W.order(10*i)
sage: O15 = W.order(15*i)
sage: O15.is_suborder(O5)
True
sage: O5.is_suborder(O15)
False
sage: O10.is_suborder(O15)
False
We create another isomorphic but different field:
sage: W2.<j> = NumberField(x^2 + 1)
sage: P5 = W2.order(5*j)
This is False because the ambient number fields are not equal.:
sage: O5.is_suborder(P5)
False
We create a field that contains (in no natural way!) W, and of course again is_suborder returns False:
sage: K.<z> = NumberField(x^4 + 1)
sage: M = K.order(5*z)
sage: O5.is_suborder(M)
False
Return the Krull dimension of this order, which is 1.
EXAMPLES:
sage: K.<a> = QuadraticField(5)
sage: OK = K.maximal_order()
sage: OK.krull_dimension()
1
sage: O2 = K.order(2*a)
sage: O2.krull_dimension()
1
Return the number of module generators of this order.
EXAMPLES:
sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
sage: O = K.maximal_order()
sage: O.ngens()
3
Return the number field of this order, which is the ambient number field that this order is embedded in.
EXAMPLES:
sage: K.<b> = NumberField(x^4 + x^2 + 2)
sage: O = K.order(2*b); O
Order in Number Field in b with defining polynomial x^4 + x^2 + 2
sage: O.basis()
[1, 2*b, 4*b^2, 8*b^3]
sage: O.number_field()
Number Field in b with defining polynomial x^4 + x^2 + 2
sage: O.number_field() is K
True
Return a random element of this order.
INPUT:
OUTPUT:
A random element of this order, computed as a random -linear combination of the basis.
EXAMPLES:
sage: K.<a> = NumberField(x^3 + 2)
sage: OK = K.ring_of_integers()
sage: OK.random_element() # random output
-2*a^2 - a - 2
sage: OK.random_element(distribution="uniform") # random output
-a^2 - 1
sage: OK.random_element(-10,10) # random output
-10*a^2 - 9*a - 2
sage: K.order(a).random_element() # random output
a^2 - a - 3
sage: K.<z> = CyclotomicField(17)
sage: OK = K.ring_of_integers()
sage: OK.random_element() # random output
z^15 - z^11 - z^10 - 4*z^9 + z^8 + 2*z^7 + z^6 - 2*z^5 - z^4 - 445*z^3 - 2*z^2 - 15*z - 2
sage: OK.random_element().is_integral()
True
sage: OK.random_element().parent() is OK
True
A relative example:
sage: K.<a, b> = NumberField([x^2 + 2, x^2 + 1000*x + 1])
sage: OK = K.ring_of_integers()
sage: OK.random_element() # random output
(42221/2*b + 61/2)*a + 7037384*b + 7041
sage: OK.random_element().is_integral() # random output
True
sage: OK.random_element().parent() is OK # random output
True
An example in a non-maximal order:
sage: K.<a> = QuadraticField(-3)
sage: R = K.ring_of_integers()
sage: A = K.order(a)
sage: A.index_in(R)
2
sage: R.random_element() # random output
-39/2*a - 1/2
sage: A.random_element() # random output
2*a - 1
sage: A.random_element().is_integral()
True
sage: A.random_element().parent() is A
True
Return the rank of this order, which is the rank of the underlying -module, or the degree of the ambient number field that contains this order.
This is a synonym for degree().
EXAMPLES:
sage: k.<c> = NumberField(x^5 + x^2 + 1)
sage: o = k.maximal_order(); o
Maximal Order in Number Field in c with defining polynomial x^5 + x^2 + 1
sage: o.rank()
5
Return the residue field of this order at a given prime, ie .
INPUT:
OUTPUT:
The residue field at this prime.
EXAMPLES:
sage: R.<x> = QQ[]
sage: K.<a> = NumberField(x^4+3*x^2-17)
sage: P = K.ideal(61).factor()[0][0]
sage: OK = K.maximal_order()
sage: OK.residue_field(P)
Residue field in abar of Fractional ideal (-2*a^2 + 1)
Return generators for self as a ring.
EXAMPLES:
sage: K.<i> = NumberField(x^2 + 1)
sage: O = K.maximal_order(); O
Maximal Order in Number Field in i with defining polynomial x^2 + 1
sage: O.ring_generators()
[i]
This is an example where 2 generators are required (because 2 is an essential discriminant divisor).:
sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
sage: O = K.maximal_order(); O.basis()
[1, 1/2*a^2 + 1/2*a, a^2]
sage: O.ring_generators()
[1/2*a^2 + 1/2*a, a^2]
Return a primitive n-th root of unity in this order, if it contains one. If all is True, return all of them.
EXAMPLES:
sage: F.<alpha> = NumberField(x**2+3)
sage: F.ring_of_integers().zeta(6)
1/2*alpha + 1/2
sage: O = F.order([3*alpha])
sage: O.zeta(3)
...
ArithmeticError: There are no 3rd roots of unity in self.
Bases: sage.rings.number_field.order.Order
A relative order in a number field.
A relative order is an order in some relative number field
Invariants of this order may be computed with respect to the contained order.
Return the absolute discriminant of self, which is the discriminant of the absolute order associated to self.
OUTPUT:
an integer
EXAMPLES:
sage: R = EquationOrder([x^2 + 1, x^3 + 2], 'a,b')
sage: d = R.absolute_discriminant(); d
-746496
sage: d is R.absolute_discriminant()
True
sage: factor(d)
-1 * 2^10 * 3^6
Return underlying absolute order associated to this relative order.
INPUT:
Note
There is a default variable name, since this absolute order is frequently used for internal algorithms.
EXAMPLES:
sage: R = EquationOrder([x^2 + 1, x^2 - 5], 'i,g'); R
Relative Order in Number Field in i with defining polynomial x^2 + 1 over its base field
sage: R.basis()
[1, 6*i - g, -g*i + 2, 7*i - g]
sage: S = R.absolute_order(); S
Order in Number Field in z with defining polynomial x^4 - 8*x^2 + 36
sage: S.basis()
[1, 5/12*z^3 + 1/6*z, 1/2*z^2, 1/2*z^3]
We compute a relative order in alpha0, alpha1, then make the number field that contains the absolute order be called gamma.:
sage: R = EquationOrder( [x^2 + 2, x^2 - 3], 'alpha'); R
Relative Order in Number Field in alpha0 with defining polynomial x^2 + 2 over its base field
sage: R.absolute_order('gamma')
Order in Number Field in gamma with defining polynomial x^4 - 2*x^2 + 25
sage: R.absolute_order('gamma').basis()
[1/2*gamma^2 + 1/2, 7/10*gamma^3 + 1/10*gamma, gamma^2, gamma^3]
Return module basis for this relative order. This is a list of elements that generate this order over the base order.
Warning
For now this basis is actually just a basis over .
EXAMPLES:
sage: K.<a,b> = NumberField([x^2+1, x^2+3])
sage: O = K.order([a,b])
sage: O.basis()
[1, -2*a + b, -b*a - 2, -5*a + 3*b]
sage: z = O.1; z
-2*a + b
sage: z.absolute_minpoly()
x^4 + 14*x^2 + 1
Return the index of self in other. This is a lattice index, so it is a rational number if self isn’t contained in other.
INPUT:
OUTPUT:
a rational number
EXAMPLES:
sage: K.<a,b> = NumberField([x^3 + x + 3, x^2 + 1])
sage: R1 = K.order([3*a, 2*b])
sage: R2 = K.order([a, 4*b])
sage: R1.index_in(R2)
729/8
sage: R2.index_in(R1)
8/729
Returns true if self is a subset of the order other.
EXAMPLES:
sage: K.<a,b> = NumberField([x^2 + 1, x^3 + 2])
sage: R1 = K.order([a,b])
sage: R2 = K.order([2*a,b])
sage: R3 = K.order([a + b, b + 2*a])
sage: R1.is_suborder(R2)
False
sage: R2.is_suborder(R1)
True
sage: R3.is_suborder(R1)
True
sage: R1.is_suborder(R3)
True
sage: R1 == R3
True
INPUT:
OUTPUT:
an absolute order
EXAMPLES: We have to explicitly import the function, since it isn’t meant for regular usage:
sage: from sage.rings.number_field.order import absolute_order_from_module_generators
sage: K.<a> = NumberField(x^4 - 5)
sage: O = K.maximal_order(); O
Maximal Order in Number Field in a with defining polynomial x^4 - 5
sage: O.basis()
[1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a, a^2, a^3]
sage: O.module()
Free module of degree 4 and rank 4 over Integer Ring
Echelon basis matrix:
[1/2 0 1/2 0]
[ 0 1/2 0 1/2]
[ 0 0 1 0]
[ 0 0 0 1]
sage: g = O.gens(); g
[1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a, a^2, a^3]
sage: absolute_order_from_module_generators(g)
Order in Number Field in a with defining polynomial x^4 - 5
We illustrate each check flag – the output is the same but in case the function would run ever so slightly faster:
sage: absolute_order_from_module_generators(g, check_is_ring=False)
Order in Number Field in a with defining polynomial x^4 - 5
sage: absolute_order_from_module_generators(g, check_rank=False)
Order in Number Field in a with defining polynomial x^4 - 5
sage: absolute_order_from_module_generators(g, check_integral=False)
Order in Number Field in a with defining polynomial x^4 - 5
Next we illustrate constructing “fake” orders to illustrate turning off various check flags:
sage: k.<i> = NumberField(x^2 + 1)
sage: R = absolute_order_from_module_generators([2, 2*i], check_is_ring=False); R
Order in Number Field in i with defining polynomial x^2 + 1
sage: R.basis()
[2, 2*i]
sage: R = absolute_order_from_module_generators([k(1)], check_rank=False); R
Order in Number Field in i with defining polynomial x^2 + 1
sage: R.basis()
[1]
If the order contains a non-integral element, even if we don’t check that, we’ll find that the rank is wrong or that the order isn’t closed under multiplication:
sage: absolute_order_from_module_generators([1/2, i], check_integral=False)
...
ValueError: the module span of the gens is not closed under multiplication.
sage: R = absolute_order_from_module_generators([1/2, i], check_is_ring=False, check_integral=False); R
Order in Number Field in i with defining polynomial x^2 + 1
sage: R.basis()
[1/2, i]
We turn off all check flags and make a really messed up order:
sage: R = absolute_order_from_module_generators([1/2, i], check_is_ring=False, check_integral=False, check_rank=False); R
Order in Number Field in i with defining polynomial x^2 + 1
sage: R.basis()
[1/2, i]
An order that lives in a subfield:
sage: F.<alpha> = NumberField(x**4+3)
sage: F.order([alpha**2], allow_subfield=True)
Order in Number Field in alpha with defining polynomial x^4 + 3
INPUT:
EXAMPLES:
sage: K.<a> = NumberField(x^4 - 5)
sage: K.order(a)
Order in Number Field in a with defining polynomial x^4 - 5
We have to explicitly import this function, since typically it is called with K.order as above.:
sage: from sage.rings.number_field.order import absolute_order_from_ring_generators
sage: absolute_order_from_ring_generators([a])
Order in Number Field in a with defining polynomial x^4 - 5
sage: absolute_order_from_ring_generators([3*a, 2, 6*a+1])
Order in Number Field in a with defining polynomial x^4 - 5
If one of the inputs is non-integral, it is an error.:
sage: absolute_order_from_ring_generators([a/2])
...
ValueError: each generator must be integral
If the gens do not generate an order, i.e., generate a ring of full rank, then it is an error.:
sage: absolute_order_from_ring_generators([a^2])
...
ValueError: the rank of the span of gens is wrong
Both checking for integrality and checking for full rank can be turned off in order to save time, though one can get nonsense as illustrated below.:
sage: absolute_order_from_ring_generators([a/2], check_is_integral=False)
Order in Number Field in a with defining polynomial x^4 - 5
sage: absolute_order_from_ring_generators([a^2], check_rank=False)
Order in Number Field in a with defining polynomial x^4 - 5
Return True if each element of the list v of elements of a number field is integral.
EXAMPLES:
sage: W.<sqrt5> = NumberField(x^2 - 5)
sage: from sage.rings.number_field.order import each_is_integral
sage: each_is_integral([sqrt5, 2, (1+sqrt5)/2])
True
sage: each_is_integral([sqrt5, (1+sqrt5)/3])
False
Return True if R is either an order in a number field or is the ring of integers.
EXAMPLES:
sage: from sage.rings.number_field.order import is_NumberFieldOrder
sage: is_NumberFieldOrder(NumberField(x^2+1,'a').maximal_order())
True
sage: is_NumberFieldOrder(ZZ)
True
sage: is_NumberFieldOrder(QQ)
False
sage: is_NumberFieldOrder(45)
False
INPUT:
EXAMPLES: We have to explicitly import this function, since it isn’t meant for regular usage:
sage: from sage.rings.number_field.order import relative_order_from_ring_generators
sage: K.<i, a> = NumberField([x^2 + 1, x^2 - 17])
sage: R = K.base_field().maximal_order()
sage: S = relative_order_from_ring_generators([i,a]); S
Relative Order in Number Field in i with defining polynomial x^2 + 1 over its base field
Basis for the relative order, which is obtained by computing the algebra generated by i and a:
sage: S.basis()
[1, 7*i - 2*a, -a*i + 8, 25*i - 7*a]