Orders in number fields

EXAMPLES:

We define an absolute order:

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^2 + 1); O = K.order(2*a)
sage: O.basis()
[1, 2*a]
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = K._first_ngens(1); O = K.order(Integer(2)*a)
>>> 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])
sage: O = K.order([3*a, 2*b])
sage: O.basis()
[1, 3*a - 2*b, -6*b*a + 6, 3*a]
>>> from sage.all import *
>>> K = NumberField([x**Integer(2) + Integer(1), x**Integer(2) - Integer(3)], names=('a', 'b',)); (a, b,) = K._first_ngens(2)
>>> O = K.order([Integer(3)*a, Integer(2)*b])
>>> 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 generated by a 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
>>> from sage.all import *
>>> K = NumberField((x+Integer(1))**Integer(10) + Integer(17), names=('a',)); (a,) = K._first_ngens(1)
>>> K.maximal_order()
Maximal Order generated by a 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 generated by 17*a 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
>>> from sage.all import *
>>> O = K.order(Integer(17)*a); O
Order generated by 17*a 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
>>> m = O.index_in(K.maximal_order()); m
23453165165327788911665591944416226304630809183732482257
>>> factor(m)
17^45

AUTHORS:

  • William Stein and Robert Bradshaw (2007-09): initial version

class sage.rings.number_field.order.AbsoluteOrderFactory[source]

Bases: OrderFactory

An order in an (absolute) number field.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<i> = NumberField(x^2 + 1)
sage: K.order(i)
Gaussian Integers generated by i in Number Field in i with defining polynomial x^2 + 1
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1)
>>> K.order(i)
Gaussian Integers generated by i in Number Field in i with defining polynomial x^2 + 1
create_key_and_extra_args(K, module_rep, is_maximal=None, check=True, is_maximal_at=())[source]

Return normalized arguments to create an absolute order.

create_object(version, key, is_maximal=None, is_maximal_at=())[source]

Create an absolute order.

reduce_data(order)[source]

Return the data that can be used to pickle an order created by this factory.

This overrides the default implementation to update the latest knowledge about primes at which the order is maximal.

EXAMPLES:

This also works for relative orders since they are wrapping absolute orders:

sage: x = polygen(ZZ, 'x')
sage: L.<a, b> = NumberField([x^2 - 1000003, x^2 - 5*1000099^2])
sage: O = L.maximal_order([5], assume_maximal=None)

sage: s = dumps(O)
sage: loads(s) is O
True

sage: N = L.maximal_order([7], assume_maximal=None)
sage: dumps(N) == s
False

sage: loads(dumps(N)) is O
True
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> L = NumberField([x**Integer(2) - Integer(1000003), x**Integer(2) - Integer(5)*Integer(1000099)**Integer(2)], names=('a', 'b',)); (a, b,) = L._first_ngens(2)
>>> O = L.maximal_order([Integer(5)], assume_maximal=None)

>>> s = dumps(O)
>>> loads(s) is O
True

>>> N = L.maximal_order([Integer(7)], assume_maximal=None)
>>> dumps(N) == s
False

>>> loads(dumps(N)) is O
True
sage.rings.number_field.order.EisensteinIntegers(names='omega')[source]

Return the ring of Eisenstein integers.

This is the ring of all complex numbers of the form \(a + b \omega\) with \(a\) and \(b\) integers and \(\omega = (-1 + \sqrt{-3})/2\).

EXAMPLES:

sage: R.<omega> = EisensteinIntegers()
sage: R
Eisenstein Integers generated by omega in Number Field in omega
 with defining polynomial x^2 + x + 1
 with omega = -0.50000000000000000? + 0.866025403784439?*I
sage: factor(3 + omega)
(-1) * (-omega - 3)
sage: CC(omega)
-0.500000000000000 + 0.866025403784439*I
sage: omega.minpoly()
x^2 + x + 1
sage: EisensteinIntegers().basis()
[1, omega]
>>> from sage.all import *
>>> R = EisensteinIntegers(names=('omega',)); (omega,) = R._first_ngens(1)
>>> R
Eisenstein Integers generated by omega in Number Field in omega
 with defining polynomial x^2 + x + 1
 with omega = -0.50000000000000000? + 0.866025403784439?*I
>>> factor(Integer(3) + omega)
(-1) * (-omega - 3)
>>> CC(omega)
-0.500000000000000 + 0.866025403784439*I
>>> omega.minpoly()
x^2 + x + 1
>>> EisensteinIntegers().basis()
[1, omega]
sage.rings.number_field.order.EquationOrder(f, names, **kwds)[source]

Return the equation order generated by a root of the irreducible polynomial \(f\) or list f of polynomials (to construct a relative equation order).

IMPORTANT: Note that the generators of the returned order need not be roots of \(f\), since the generators of an order are – in Sage – module generators.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: O.<a,b> = EquationOrder([x^2 + 1, x^2 + 2])
sage: O
Relative Order generated by [-b*a - 1, -3*a + 2*b] 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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> O = EquationOrder([x**Integer(2) + Integer(1), x**Integer(2) + Integer(2)], names=('a', 'b',)); (a, b,) = O._first_ngens(2)
>>> O
Relative Order generated by [-b*a - 1, -3*a + 2*b] in
 Number Field in a with defining polynomial x^2 + 1 over its base field
>>> O.gen(0)
-b*a - 1
>>> O.gen(1)
-3*a + 2*b

Of course the input polynomial must be integral:

sage: R = EquationOrder(x^3 + x + 1/3, 'alpha'); R
Traceback (most recent call last):
...
ValueError: each generator must be integral

sage: R = EquationOrder([x^3 + x + 1, x^2 + 1/2], 'alpha'); R
Traceback (most recent call last):
...
ValueError: each generator must be integral
>>> from sage.all import *
>>> R = EquationOrder(x**Integer(3) + x + Integer(1)/Integer(3), 'alpha'); R
Traceback (most recent call last):
...
ValueError: each generator must be integral

>>> R = EquationOrder([x**Integer(3) + x + Integer(1), x**Integer(2) + Integer(1)/Integer(2)], 'alpha'); R
Traceback (most recent call last):
...
ValueError: each generator must be integral
sage.rings.number_field.order.GaussianIntegers(names='I', latex_name='i')[source]

Return the ring of Gaussian integers.

This is the ring of all complex numbers of the form \(a + b I\) with \(a\) and \(b\) integers and \(I = \sqrt{-1}\).

EXAMPLES:

sage: ZZI.<I> = GaussianIntegers()
sage: ZZI
Gaussian Integers generated by I in Number Field in I with defining polynomial x^2 + 1 with I = 1*I
sage: factor(3 + I)
(-I) * (I + 1) * (2*I + 1)
sage: CC(I)
1.00000000000000*I
sage: I.minpoly()
x^2 + 1
sage: GaussianIntegers().basis()
[1, I]
>>> from sage.all import *
>>> ZZI = GaussianIntegers(names=('I',)); (I,) = ZZI._first_ngens(1)
>>> ZZI
Gaussian Integers generated by I in Number Field in I with defining polynomial x^2 + 1 with I = 1*I
>>> factor(Integer(3) + I)
(-I) * (I + 1) * (2*I + 1)
>>> CC(I)
1.00000000000000*I
>>> I.minpoly()
x^2 + 1
>>> GaussianIntegers().basis()
[1, I]
class sage.rings.number_field.order.Order(K)[source]

Bases: Parent, Order

An order in a number field.

An order is a subring of the number field that has \(\ZZ\)-rank equal to the degree of the number field over \(\QQ\).

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<theta> = NumberField(x^4 + x + 17)
sage: K.maximal_order()
Maximal Order generated by theta in Number Field in theta with defining polynomial x^4 + x + 17
sage: R = K.order(17*theta); R
Order generated by 17*theta 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
Maximal Order generated by theta 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 generated by 17*theta 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)
Traceback (most recent call last):
...
ValueError: the rank of the span of gens is wrong
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(4) + x + Integer(17), names=('theta',)); (theta,) = K._first_ngens(1)
>>> K.maximal_order()
Maximal Order generated by theta in Number Field in theta with defining polynomial x^4 + x + 17
>>> R = K.order(Integer(17)*theta); R
Order generated by 17*theta in Number Field in theta with defining polynomial x^4 + x + 17
>>> R.basis()
[1, 17*theta, 289*theta^2, 4913*theta^3]
>>> R = K.order(Integer(17)*theta, Integer(13)*theta); R
Maximal Order generated by theta in Number Field in theta with defining polynomial x^4 + x + 17
>>> R.basis()
[1, theta, theta^2, theta^3]
>>> R = K.order([Integer(34)*theta, Integer(17)*theta + Integer(17)]); R
Order generated by 17*theta in Number Field in theta with defining polynomial x^4 + x + 17
>>> K = NumberField(x**Integer(4) + x**Integer(2) + Integer(2), names=('b',)); (b,) = K._first_ngens(1)
>>> (b**Integer(2)).charpoly().factor()
(x^2 + x + 2)^2
>>> K.order(b**Integer(2))
Traceback (most recent call last):
...
ValueError: the rank of the span of gens is wrong
absolute_degree()[source]

Return the absolute degree of this order, i.e., the degree of this order over \(\ZZ\).

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^3 + 2)
sage: O = K.maximal_order()
sage: O.absolute_degree()
3
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(3) + Integer(2), names=('a',)); (a,) = K._first_ngens(1)
>>> O = K.maximal_order()
>>> O.absolute_degree()
3
ambient()[source]

Return the ambient number field that contains self.

This is the same as number_field() and fraction_field()

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: k.<z> = NumberField(x^2 - 389)
sage: o = k.order(389*z + 1)
sage: o
Order of conductor 778 generated by 389*z 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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> k = NumberField(x**Integer(2) - Integer(389), names=('z',)); (z,) = k._first_ngens(1)
>>> o = k.order(Integer(389)*z + Integer(1))
>>> o
Order of conductor 778 generated by 389*z in Number Field in z with defining polynomial x^2 - 389
>>> o.basis()
[1, 389*z]
>>> o.ambient()
Number Field in z with defining polynomial x^2 - 389
basis()[source]

Return a basis over \(\ZZ\) of this order.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^3 + x^2 - 16*x + 16)
sage: O = K.maximal_order(); O
Maximal Order generated by 1/4*a^2 + 1/4*a 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]
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(3) + x**Integer(2) - Integer(16)*x + Integer(16), names=('a',)); (a,) = K._first_ngens(1)
>>> O = K.maximal_order(); O
Maximal Order generated by 1/4*a^2 + 1/4*a in Number Field in a with defining polynomial x^3 + x^2 - 16*x + 16
>>> O.basis()
[1, 1/4*a^2 + 1/4*a, a^2]
class_group(proof=None, names='c')[source]

Return the class group of this order.

(Currently only implemented for the maximal order.)

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: k.<a> = NumberField(x^2 + 5077)
sage: O = k.maximal_order(); O
Maximal Order generated by a 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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> k = NumberField(x**Integer(2) + Integer(5077), names=('a',)); (a,) = k._first_ngens(1)
>>> O = k.maximal_order(); O
Maximal Order generated by a in Number Field in a with defining polynomial x^2 + 5077
>>> O.class_group()
Class group of order 22 with structure C22 of
 Number Field in a with defining polynomial x^2 + 5077
class_number(proof=None)[source]

Return the class number of this order.

EXAMPLES:

sage: ZZ[2^(1/3)].class_number()                                            # needs sage.symbolic
1
sage: QQ[sqrt(-23)].maximal_order().class_number()                          # needs sage.symbolic
3
sage: ZZ[120*sqrt(-23)].class_number()                                      # needs sage.symbolic
288
>>> from sage.all import *
>>> ZZ[Integer(2)**(Integer(1)/Integer(3))].class_number()                                            # needs sage.symbolic
1
>>> QQ[sqrt(-Integer(23))].maximal_order().class_number()                          # needs sage.symbolic
3
>>> ZZ[Integer(120)*sqrt(-Integer(23))].class_number()                                      # needs sage.symbolic
288

Note that non-maximal orders are only supported in quadratic fields:

sage: ZZ[120*sqrt(-23)].class_number()                                      # needs sage.symbolic
288
sage: ZZ[100*sqrt(3)].class_number()                                        # needs sage.symbolic
4
sage: ZZ[11*2^(1/3)].class_number()                                         # needs sage.symbolic
Traceback (most recent call last):
...
NotImplementedError: computation of class numbers of non-maximal orders
not in quadratic fields is not implemented
>>> from sage.all import *
>>> ZZ[Integer(120)*sqrt(-Integer(23))].class_number()                                      # needs sage.symbolic
288
>>> ZZ[Integer(100)*sqrt(Integer(3))].class_number()                                        # needs sage.symbolic
4
>>> ZZ[Integer(11)*Integer(2)**(Integer(1)/Integer(3))].class_number()                                         # needs sage.symbolic
Traceback (most recent call last):
...
NotImplementedError: computation of class numbers of non-maximal orders
not in quadratic fields is not implemented
conductor()[source]

For orders in quadratic number fields, return the conductor of this order.

The conductor is the unique positive integer \(f\) such that the discriminant of this order is \(f^2\) times the discriminant of the containing quadratic field.

Not implemented for orders in number fields of degree \(\neq 2\).

EXAMPLES:

sage: K.<t> = QuadraticField(-101)
sage: K.maximal_order().conductor()
1
sage: K.order(5*t).conductor()
5
sage: K.discriminant().factor()
-1 * 2^2 * 101
sage: K.order(5*t).discriminant().factor()
-1 * 2^2 * 5^2 * 101
>>> from sage.all import *
>>> K = QuadraticField(-Integer(101), names=('t',)); (t,) = K._first_ngens(1)
>>> K.maximal_order().conductor()
1
>>> K.order(Integer(5)*t).conductor()
5
>>> K.discriminant().factor()
-1 * 2^2 * 101
>>> K.order(Integer(5)*t).discriminant().factor()
-1 * 2^2 * 5^2 * 101
coordinates(x)[source]

Return the coordinate vector of \(x\) with respect to this order.

INPUT:

  • x – an element of the number field of this order

OUTPUT:

A vector of length \(n\) (the degree of the field) giving the coordinates of \(x\) 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 \(x\) 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
>>> from sage.all import *
>>> K = QuadraticField(-Integer(1), names=('i',)); (i,) = K._first_ngens(1)
>>> OK = K.ring_of_integers()
>>> OK_basis = OK.basis(); OK_basis
[1, i]
>>> a = Integer(23)-Integer(14)*i
>>> acoords = OK.coordinates(a); acoords
(23, -14)
>>> sum([OK_basis[j]*acoords[j] for j in range(Integer(2))]) == a
True
>>> OK.coordinates((Integer(120)+Integer(340)*i)/Integer(8))
(15, 85/2)

>>> O = K.order(Integer(3)*i)
>>> O.is_maximal()
False
>>> O.index_in(OK)
3
>>> acoords = O.coordinates(a); acoords
(23, -14/3)
>>> sum([O.basis()[j]*acoords[j] for j in range(Integer(2))]) == a
True
degree()[source]

Return the degree of this order, which is the rank of this order as a \(\ZZ\)-module.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: k.<c> = NumberField(x^3 + x^2 - 2*x+8)
sage: o = k.maximal_order()
sage: o.degree()
3
sage: o.rank()
3
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> k = NumberField(x**Integer(3) + x**Integer(2) - Integer(2)*x+Integer(8), names=('c',)); (c,) = k._first_ngens(1)
>>> o = k.maximal_order()
>>> o.degree()
3
>>> o.rank()
3
fraction_field()[source]

Return the fraction field of this order, which is the ambient number field.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<b> = NumberField(x^4 + 17*x^2 + 17)
sage: O = K.order(17*b); O
Order generated by 17*b 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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(4) + Integer(17)*x**Integer(2) + Integer(17), names=('b',)); (b,) = K._first_ngens(1)
>>> O = K.order(Integer(17)*b); O
Order generated by 17*b in Number Field in b with defining polynomial x^4 + 17*x^2 + 17
>>> O.fraction_field()
Number Field in b with defining polynomial x^4 + 17*x^2 + 17
fractional_ideal(*args, **kwds)[source]

Return the fractional ideal of the maximal order with given generators.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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)
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(2) + Integer(2), names=('a',)); (a,) = K._first_ngens(1)
>>> R = K.maximal_order()
>>> R.fractional_ideal(Integer(2)/Integer(3) + Integer(7)*a, a)
Fractional ideal (1/3*a)
free_module()[source]

Return the free \(\ZZ\)-module contained in the vector space associated to the ambient number field, that corresponds to this order.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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]
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(3) + x**Integer(2) - Integer(2)*x + Integer(8), names=('a',)); (a,) = K._first_ngens(1)
>>> O = K.maximal_order(); O.basis()
[1, 1/2*a^2 + 1/2*a, a^2]
>>> 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 \(\ZZ\)-module in the absolute field associated to the relative field:

sage: x = polygen(ZZ, 'x')
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]
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField([x**Integer(2) + Integer(1), x**Integer(2) + Integer(2)], names=('a', 'b',)); (a, b,) = K._first_ngens(2)
>>> 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]
>>> 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]
gen(i)[source]

Return \(i\)-th module generator of this order.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<c> = NumberField(x^3 + 2*x + 17)
sage: O = K.maximal_order(); O
Maximal Order generated by c 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)
Traceback (most recent call last):
...
IndexError: no 5th generator
sage: O.gen(-1)
Traceback (most recent call last):
...
IndexError: no -1th generator
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(3) + Integer(2)*x + Integer(17), names=('c',)); (c,) = K._first_ngens(1)
>>> O = K.maximal_order(); O
Maximal Order generated by c in Number Field in c with defining polynomial x^3 + 2*x + 17
>>> O.basis()
[1, c, c^2]
>>> O.gen(Integer(1))
c
>>> O.gen(Integer(2))
c^2
>>> O.gen(Integer(5))
Traceback (most recent call last):
...
IndexError: no 5th generator
>>> O.gen(-Integer(1))
Traceback (most recent call last):
...
IndexError: no -1th generator
gens()[source]

Return the generators as a tuple.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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)
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(3) + x**Integer(2) - Integer(2)*x + Integer(8), names=('a',)); (a,) = K._first_ngens(1)
>>> O = K.maximal_order()
>>> O.gens()
(1, 1/2*a^2 + 1/2*a, a^2)
ideal(*args, **kwds)[source]

Return the integral ideal with given generators.

Note

This method constructs an ideal of this (not necessarily maximal) order. To construct a fractional ideal in the ambient number field, use fractional_ideal().

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^2 + 7)
sage: R = K.maximal_order()
sage: R.ideal([7*a, 77 + 28*a])
Ideal (7/2*a + 7/2, 7*a) of Maximal Order generated by 1/2*a + 1/2 in Number Field in a with defining polynomial x^2 + 7
sage: R = K.order(4*a)
sage: R.ideal(8)
Ideal (8, 32*a) of Order of conductor 8 generated by 4*a
 in Number Field in a with defining polynomial x^2 + 7
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(2) + Integer(7), names=('a',)); (a,) = K._first_ngens(1)
>>> R = K.maximal_order()
>>> R.ideal([Integer(7)*a, Integer(77) + Integer(28)*a])
Ideal (7/2*a + 7/2, 7*a) of Maximal Order generated by 1/2*a + 1/2 in Number Field in a with defining polynomial x^2 + 7
>>> R = K.order(Integer(4)*a)
>>> R.ideal(Integer(8))
Ideal (8, 32*a) of Order of conductor 8 generated by 4*a
 in Number Field in a with defining polynomial x^2 + 7

This function is called implicitly below:

sage: R = EquationOrder(x^2 + 2, 'a'); R
Maximal Order generated by a in Number Field in a with defining polynomial x^2 + 2
sage: (3,15)*R
Ideal (3, 3*a) of Maximal Order generated by a in Number Field in a with defining polynomial x^2 + 2
>>> from sage.all import *
>>> R = EquationOrder(x**Integer(2) + Integer(2), 'a'); R
Maximal Order generated by a in Number Field in a with defining polynomial x^2 + 2
>>> (Integer(3),Integer(15))*R
Ideal (3, 3*a) of Maximal Order generated by a in Number Field in a with defining polynomial x^2 + 2

The zero ideal is handled properly:

sage: R.ideal(0)
Ideal (0) of Maximal Order generated by a in Number Field in a with defining polynomial x^2 + 2
>>> from sage.all import *
>>> R.ideal(Integer(0))
Ideal (0) of Maximal Order generated by a in Number Field in a with defining polynomial x^2 + 2
integral_closure()[source]

Return the integral closure of this order.

EXAMPLES:

sage: K.<a> = QuadraticField(5)
sage: O2 = K.order(2*a); O2
Order of conductor 4 generated by 2*a in Number Field in a
 with defining polynomial x^2 - 5 with a = 2.236067977499790?
sage: O2.integral_closure()
Maximal Order generated by 1/2*a + 1/2 in Number Field in a
 with defining polynomial x^2 - 5 with a = 2.236067977499790?
sage: OK = K.maximal_order()
sage: OK is OK.integral_closure()
True
>>> from sage.all import *
>>> K = QuadraticField(Integer(5), names=('a',)); (a,) = K._first_ngens(1)
>>> O2 = K.order(Integer(2)*a); O2
Order of conductor 4 generated by 2*a in Number Field in a
 with defining polynomial x^2 - 5 with a = 2.236067977499790?
>>> O2.integral_closure()
Maximal Order generated by 1/2*a + 1/2 in Number Field in a
 with defining polynomial x^2 - 5 with a = 2.236067977499790?
>>> OK = K.maximal_order()
>>> OK is OK.integral_closure()
True
is_field(proof=True)[source]

Return False (because an order is never a field).

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> L = NumberField(x**Integer(4) - x**Integer(2) + Integer(7), names=('alpha',)); (alpha,) = L._first_ngens(1)
>>> O = L.maximal_order() ; O.is_field()
False
>>> CyclotomicField(Integer(12)).ring_of_integers().is_field()
False
is_integrally_closed()[source]

Return True if this ring is integrally closed, i.e., is equal to the maximal order.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^2 + 189*x + 394)
sage: R = K.order(2*a)
sage: R.is_integrally_closed()
False
sage: R
Order of conductor 2 generated by 2*a in Number Field in a with defining polynomial x^2 + 189*x + 394
sage: S = K.maximal_order(); S
Maximal Order generated by a in Number Field in a with defining polynomial x^2 + 189*x + 394
sage: S.is_integrally_closed()
True
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(2) + Integer(189)*x + Integer(394), names=('a',)); (a,) = K._first_ngens(1)
>>> R = K.order(Integer(2)*a)
>>> R.is_integrally_closed()
False
>>> R
Order of conductor 2 generated by 2*a in Number Field in a with defining polynomial x^2 + 189*x + 394
>>> S = K.maximal_order(); S
Maximal Order generated by a in Number Field in a with defining polynomial x^2 + 189*x + 394
>>> S.is_integrally_closed()
True
is_noetherian()[source]

Return True (because orders are always Noetherian).

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> L = NumberField(x**Integer(4) - x**Integer(2) + Integer(7), names=('alpha',)); (alpha,) = L._first_ngens(1)
>>> O = L.maximal_order() ; O.is_noetherian()
True
>>> E = NumberField(x**Integer(2) - x + Integer(2), names=('w',)); (w,) = E._first_ngens(1)
>>> OE = E.ring_of_integers(); OE.is_noetherian()
True
is_suborder(other)[source]

Return True if self and other are both orders in the same ambient number field and self is a subset of other.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> W = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = W._first_ngens(1)
>>> O5 = W.order(Integer(5)*i)
>>> O10 = W.order(Integer(10)*i)
>>> O15 = W.order(Integer(15)*i)
>>> O15.is_suborder(O5)
True
>>> O5.is_suborder(O15)
False
>>> 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)
>>> from sage.all import *
>>> W2 = NumberField(x**Integer(2) + Integer(1), names=('j',)); (j,) = W2._first_ngens(1)
>>> P5 = W2.order(Integer(5)*j)

This is False because the ambient number fields are not equal.:

sage: O5.is_suborder(P5)
False
>>> from sage.all import *
>>> 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
>>> from sage.all import *
>>> K = NumberField(x**Integer(4) + Integer(1), names=('z',)); (z,) = K._first_ngens(1)
>>> M = K.order(Integer(5)*z)
>>> O5.is_suborder(M)
False
krull_dimension()[source]

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
>>> from sage.all import *
>>> K = QuadraticField(Integer(5), names=('a',)); (a,) = K._first_ngens(1)
>>> OK = K.maximal_order()
>>> OK.krull_dimension()
1
>>> O2 = K.order(Integer(2)*a)
>>> O2.krull_dimension()
1
ngens()[source]

Return the number of module generators of this order.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
sage: O = K.maximal_order()
sage: O.ngens()
3
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(3) + x**Integer(2) - Integer(2)*x + Integer(8), names=('a',)); (a,) = K._first_ngens(1)
>>> O = K.maximal_order()
>>> O.ngens()
3
number_field()[source]

Return the number field of this order, which is the ambient number field that this order is embedded in.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<b> = NumberField(x^4 + x^2 + 2)
sage: O = K.order(2*b); O
Order generated by 2*b 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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(4) + x**Integer(2) + Integer(2), names=('b',)); (b,) = K._first_ngens(1)
>>> O = K.order(Integer(2)*b); O
Order generated by 2*b in Number Field in b with defining polynomial x^4 + x^2 + 2
>>> O.basis()
[1, 2*b, 4*b^2, 8*b^3]
>>> O.number_field()
Number Field in b with defining polynomial x^4 + x^2 + 2
>>> O.number_field() is K
True
random_element(*args, **kwds)[source]

Return a random element of this order.

INPUT:

  • args, kwds – parameters passed to the random integer function. See the documentation for ZZ.random_element() for details.

OUTPUT:

A random element of this order, computed as a random \(\ZZ\)-linear combination of the basis.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(3) + Integer(2), names=('a',)); (a,) = K._first_ngens(1)
>>> OK = K.ring_of_integers()
>>> OK.random_element() # random output
-2*a^2 - a - 2
>>> OK.random_element(distribution='uniform') # random output
-a^2 - 1
>>> OK.random_element(-Integer(10),Integer(10)) # random output
-10*a^2 - 9*a - 2
>>> 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
>>> from sage.all import *
>>> K = CyclotomicField(Integer(17), names=('z',)); (z,) = K._first_ngens(1)
>>> OK = K.ring_of_integers()
>>> 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
>>> OK.random_element().is_integral()
True
>>> 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
>>> from sage.all import *
>>> K = NumberField([x**Integer(2) + Integer(2), x**Integer(2) + Integer(1000)*x + Integer(1)], names=('a', 'b',)); (a, b,) = K._first_ngens(2)
>>> OK = K.ring_of_integers()
>>> OK.random_element() # random output
(42221/2*b + 61/2)*a + 7037384*b + 7041
>>> OK.random_element().is_integral() # random output
True
>>> 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
>>> from sage.all import *
>>> K = QuadraticField(-Integer(3), names=('a',)); (a,) = K._first_ngens(1)
>>> R = K.ring_of_integers()
>>> A = K.order(a)
>>> A.index_in(R)
2
>>> R.random_element() # random output
-39/2*a - 1/2
>>> A.random_element() # random output
2*a - 1
>>> A.random_element().is_integral()
True
>>> A.random_element().parent() is A
True
rank()[source]

Return the rank of this order, which is the rank of the underlying \(\ZZ\)-module, or the degree of the ambient number field that contains this order.

This is a synonym for degree().

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: k.<c> = NumberField(x^5 + x^2 + 1)
sage: o = k.maximal_order(); o
Maximal Order generated by c in Number Field in c with defining polynomial x^5 + x^2 + 1
sage: o.rank()
5
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> k = NumberField(x**Integer(5) + x**Integer(2) + Integer(1), names=('c',)); (c,) = k._first_ngens(1)
>>> o = k.maximal_order(); o
Maximal Order generated by c in Number Field in c with defining polynomial x^5 + x^2 + 1
>>> o.rank()
5
residue_field(prime, names=None, check=False)[source]

Return the residue field of this order at a given prime, i.e., \(O/pO\).

INPUT:

  • prime – a prime ideal of the maximal order in this number field

  • names – the name of the variable in the residue field

  • check – whether or not to check the primality of prime

OUTPUT: the residue field at this prime

EXAMPLES:

sage: R.<x> = QQ[]
sage: x = polygen(ZZ, 'x')
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 (61, a^2 + 30)
sage: Fp.<b> = OK.residue_field(P)
sage: Fp
Residue field in b of Fractional ideal (61, a^2 + 30)
>>> from sage.all import *
>>> R = QQ['x']; (x,) = R._first_ngens(1)
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(4) + Integer(3)*x**Integer(2) - Integer(17), names=('a',)); (a,) = K._first_ngens(1)
>>> P = K.ideal(Integer(61)).factor()[Integer(0)][Integer(0)]
>>> OK = K.maximal_order()
>>> OK.residue_field(P)
Residue field in abar of Fractional ideal (61, a^2 + 30)
>>> Fp = OK.residue_field(P, names=('b',)); (b,) = Fp._first_ngens(1)
>>> Fp
Residue field in b of Fractional ideal (61, a^2 + 30)
ring_generators()[source]

Return generators for self as a ring.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<i> = NumberField(x^2 + 1)
sage: O = K.maximal_order(); O
Gaussian Integers generated by i in Number Field in i with defining polynomial x^2 + 1
sage: O.ring_generators()
[i]
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1)
>>> O = K.maximal_order(); O
Gaussian Integers generated by i in Number Field in i with defining polynomial x^2 + 1
>>> 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]
>>> from sage.all import *
>>> K = NumberField(x**Integer(3) + x**Integer(2) - Integer(2)*x + Integer(8), names=('a',)); (a,) = K._first_ngens(1)
>>> O = K.maximal_order(); O.basis()
[1, 1/2*a^2 + 1/2*a, a^2]
>>> O.ring_generators()
[1/2*a^2 + 1/2*a, a^2]

An example in a relative number field:

sage: K.<a, b> = NumberField([x^2 + x + 1, x^3 - 3])
sage: O = K.maximal_order()
sage: O.ring_generators()
[(-5/3*b^2 + 3*b - 2)*a - 7/3*b^2 + b + 3,
 (-5*b^2 - 9)*a - 5*b^2 - b,
 (-6*b^2 - 11)*a - 6*b^2 - b]
>>> from sage.all import *
>>> K = NumberField([x**Integer(2) + x + Integer(1), x**Integer(3) - Integer(3)], names=('a', 'b',)); (a, b,) = K._first_ngens(2)
>>> O = K.maximal_order()
>>> O.ring_generators()
[(-5/3*b^2 + 3*b - 2)*a - 7/3*b^2 + b + 3,
 (-5*b^2 - 9)*a - 5*b^2 - b,
 (-6*b^2 - 11)*a - 6*b^2 - b]
some_elements()[source]

Return a list of elements of the given order.

EXAMPLES:

sage: G = GaussianIntegers(); G
Gaussian Integers generated by I in Number Field in I with defining polynomial x^2 + 1 with I = 1*I
sage: G.some_elements()
[1, I, 2*I, -1, 0, -I, 2, 4*I, -2, -2*I, -4]

sage: R.<t> = QQ[]
sage: K.<a> = QQ.extension(t^3 - 2); K
Number Field in a with defining polynomial t^3 - 2
sage: Z = K.ring_of_integers(); Z
Maximal Order generated by a in Number Field in a with defining polynomial t^3 - 2
sage: Z.some_elements()
[1, a, a^2, 2*a, 0, 2, a^2 + 2*a + 1, ..., a^2 + 1, 2*a^2 + 2, a^2 + 2*a, 4*a^2 + 4]
>>> from sage.all import *
>>> G = GaussianIntegers(); G
Gaussian Integers generated by I in Number Field in I with defining polynomial x^2 + 1 with I = 1*I
>>> G.some_elements()
[1, I, 2*I, -1, 0, -I, 2, 4*I, -2, -2*I, -4]

>>> R = QQ['t']; (t,) = R._first_ngens(1)
>>> K = QQ.extension(t**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1); K
Number Field in a with defining polynomial t^3 - 2
>>> Z = K.ring_of_integers(); Z
Maximal Order generated by a in Number Field in a with defining polynomial t^3 - 2
>>> Z.some_elements()
[1, a, a^2, 2*a, 0, 2, a^2 + 2*a + 1, ..., a^2 + 1, 2*a^2 + 2, a^2 + 2*a, 4*a^2 + 4]
valuation(p)[source]

Return the \(p\)-adic valuation on this order.

EXAMPLES:

The valuation can be specified with an integer prime \(p\) that is completely ramified or unramified:

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^2 + 1)
sage: O = K.order(2*a)
sage: valuations.pAdicValuation(O, 2)
2-adic valuation

sage: GaussianIntegers().valuation(2)
2-adic valuation
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = K._first_ngens(1)
>>> O = K.order(Integer(2)*a)
>>> valuations.pAdicValuation(O, Integer(2))
2-adic valuation

>>> GaussianIntegers().valuation(Integer(2))
2-adic valuation

sage: GaussianIntegers().valuation(3)
3-adic valuation
>>> from sage.all import *
>>> GaussianIntegers().valuation(Integer(3))
3-adic valuation

A prime \(p\) that factors into pairwise distinct factors, results in an error:

sage: GaussianIntegers().valuation(5)
Traceback (most recent call last):
...
ValueError: The valuation Gauss valuation induced by 5-adic valuation does not
approximate a unique extension of 5-adic valuation with respect to x^2 + 1
>>> from sage.all import *
>>> GaussianIntegers().valuation(Integer(5))
Traceback (most recent call last):
...
ValueError: The valuation Gauss valuation induced by 5-adic valuation does not
approximate a unique extension of 5-adic valuation with respect to x^2 + 1

The valuation can also be selected by giving a valuation on the base ring that extends uniquely:

sage: CyclotomicField(5).ring_of_integers().valuation(ZZ.valuation(5))
5-adic valuation
>>> from sage.all import *
>>> CyclotomicField(Integer(5)).ring_of_integers().valuation(ZZ.valuation(Integer(5)))
5-adic valuation

When the extension is not unique, this does not work:

sage: GaussianIntegers().valuation(ZZ.valuation(5))
Traceback (most recent call last):
...
ValueError: The valuation Gauss valuation induced by 5-adic valuation does not
approximate a unique extension of 5-adic valuation with respect to x^2 + 1
>>> from sage.all import *
>>> GaussianIntegers().valuation(ZZ.valuation(Integer(5)))
Traceback (most recent call last):
...
ValueError: The valuation Gauss valuation induced by 5-adic valuation does not
approximate a unique extension of 5-adic valuation with respect to x^2 + 1

If the fraction field is of the form \(K[x]/(G)\), you can specify a valuation by providing a discrete pseudo-valuation on \(K[x]\) which sends \(G\) to infinity:

sage: R.<x> = QQ[]
sage: GV5 = GaussValuation(R, QQ.valuation(5))
sage: v = GaussianIntegers().valuation(GV5.augmentation(x + 2, infinity))
sage: w = GaussianIntegers().valuation(GV5.augmentation(x + 1/2, infinity))
sage: v == w
False
>>> from sage.all import *
>>> R = QQ['x']; (x,) = R._first_ngens(1)
>>> GV5 = GaussValuation(R, QQ.valuation(Integer(5)))
>>> v = GaussianIntegers().valuation(GV5.augmentation(x + Integer(2), infinity))
>>> w = GaussianIntegers().valuation(GV5.augmentation(x + Integer(1)/Integer(2), infinity))
>>> v == w
False
zeta(n=2, all=False)[source]

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: x = polygen(ZZ, 'x')
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)
Traceback (most recent call last):
...
ArithmeticError: there are no 3rd roots of unity in self
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> F = NumberField(x**Integer(2) + Integer(3), names=('alpha',)); (alpha,) = F._first_ngens(1)
>>> F.ring_of_integers().zeta(Integer(6))
-1/2*alpha + 1/2
>>> O = F.order([Integer(3)*alpha])
>>> O.zeta(Integer(3))
Traceback (most recent call last):
...
ArithmeticError: there are no 3rd roots of unity in self
class sage.rings.number_field.order.OrderFactory[source]

Bases: UniqueFactory

Abstract base class for factories creating orders, such as AbsoluteOrderFactory and RelativeOrderFactory.

get_object(version, key, extra_args)[source]

Create the order identified by key.

This overrides the default implementation to update the maximality of the order if it was explicitly specified.

EXAMPLES:

Even though orders are unique parents, this lets us update their internal state when they are recreated with more additional information available about them:

sage: x = polygen(ZZ, 'x')
sage: L.<a, b> = NumberField([x^2 - 1000003, x^2 - 5*1000099^2])
sage: O = L.maximal_order([2], assume_maximal=None)

sage: O._is_maximal_at(2)
True
sage: O._is_maximal_at(3) is None
True

sage: N = L.maximal_order([3], assume_maximal=None)
sage: N is O
True
sage: N._is_maximal_at(2)
True
sage: N._is_maximal_at(3)
True
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> L = NumberField([x**Integer(2) - Integer(1000003), x**Integer(2) - Integer(5)*Integer(1000099)**Integer(2)], names=('a', 'b',)); (a, b,) = L._first_ngens(2)
>>> O = L.maximal_order([Integer(2)], assume_maximal=None)

>>> O._is_maximal_at(Integer(2))
True
>>> O._is_maximal_at(Integer(3)) is None
True

>>> N = L.maximal_order([Integer(3)], assume_maximal=None)
>>> N is O
True
>>> N._is_maximal_at(Integer(2))
True
>>> N._is_maximal_at(Integer(3))
True
class sage.rings.number_field.order.Order_absolute(K, module_rep)[source]

Bases: Order

EXAMPLES:

sage: from sage.rings.number_field.order import *
sage: x = polygen(QQ)
sage: K.<a> = NumberField(x^3 + 2)
sage: V, from_v, to_v = K.vector_space()
sage: M = span([to_v(a^2), to_v(a), to_v(1)],ZZ)
sage: O = AbsoluteOrder(K, M); O
Maximal Order generated by a in Number Field in a with defining polynomial x^3 + 2

sage: M = span([to_v(a^2), to_v(a), to_v(2)],ZZ)
sage: O = AbsoluteOrder(K, M); O
Traceback (most recent call last):
...
ValueError: 1 is not in the span of the module, hence not an order
>>> from sage.all import *
>>> from sage.rings.number_field.order import *
>>> x = polygen(QQ)
>>> K = NumberField(x**Integer(3) + Integer(2), names=('a',)); (a,) = K._first_ngens(1)
>>> V, from_v, to_v = K.vector_space()
>>> M = span([to_v(a**Integer(2)), to_v(a), to_v(Integer(1))],ZZ)
>>> O = AbsoluteOrder(K, M); O
Maximal Order generated by a in Number Field in a with defining polynomial x^3 + 2

>>> M = span([to_v(a**Integer(2)), to_v(a), to_v(Integer(2))],ZZ)
>>> O = AbsoluteOrder(K, M); O
Traceback (most recent call last):
...
ValueError: 1 is not in the span of the module, hence not an order
absolute_discriminant()[source]

Return the discriminant of this order.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(8) + x**Integer(3) - Integer(13)*x + Integer(26), names=('a',)); (a,) = K._first_ngens(1)
>>> O = K.maximal_order()
>>> factor(O.discriminant())
3 * 11 * 13^2 * 613 * 1575917857
>>> L = K.order(Integer(13)*a**Integer(2))
>>> factor(L.discriminant())
3^3 * 5^2 * 11 * 13^60 * 613 * 733^2 * 1575917857
>>> factor(L.index_in(O))
3 * 5 * 13^29 * 733
>>> L.discriminant() / O.discriminant() == L.index_in(O)**Integer(2)
True
absolute_order()[source]

Return the absolute order associated to this order, which is just this order again since this is an absolute order.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^3 + 2)
sage: O1 = K.order(a); O1
Maximal Order generated by a in Number Field in a with defining polynomial x^3 + 2
sage: O1.absolute_order() is O1
True
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(3) + Integer(2), names=('a',)); (a,) = K._first_ngens(1)
>>> O1 = K.order(a); O1
Maximal Order generated by a in Number Field in a with defining polynomial x^3 + 2
>>> O1.absolute_order() is O1
True
basis()[source]

Return the basis over \(\ZZ\) for this order.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: k.<c> = NumberField(x^3 + x^2 + 1)
sage: O = k.maximal_order(); O
Maximal Order generated by c in Number Field in c with defining polynomial x^3 + x^2 + 1
sage: O.basis()
[1, c, c^2]
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> k = NumberField(x**Integer(3) + x**Integer(2) + Integer(1), names=('c',)); (c,) = k._first_ngens(1)
>>> O = k.maximal_order(); O
Maximal Order generated by c in Number Field in c with defining polynomial x^3 + x^2 + 1
>>> O.basis()
[1, c, c^2]

The basis is an immutable sequence:

sage: type(O.basis())
<class 'sage.structure.sequence.Sequence_generic'>
>>> from sage.all import *
>>> type(O.basis())
<class 'sage.structure.sequence.Sequence_generic'>

The generator functionality uses the basis method:

sage: O.0
1
sage: O.1
c
sage: O.basis()
[1, c, c^2]
sage: O.ngens()
3
>>> from sage.all import *
>>> O.gen(0)
1
>>> O.gen(1)
c
>>> O.basis()
[1, c, c^2]
>>> O.ngens()
3
change_names(names)[source]

Return a new order isomorphic to this one in the number field with given variable names.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: R = EquationOrder(x^3 + x + 1, 'alpha'); R
Order generated by alpha 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 generated by gamma in Number Field in gamma with defining polynomial x^3 + x + 1
sage: S.basis()
[1, gamma, gamma^2]
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> R = EquationOrder(x**Integer(3) + x + Integer(1), 'alpha'); R
Order generated by alpha in Number Field in alpha with defining polynomial x^3 + x + 1
>>> R.basis()
[1, alpha, alpha^2]
>>> S = R.change_names('gamma'); S
Order generated by gamma in Number Field in gamma with defining polynomial x^3 + x + 1
>>> S.basis()
[1, gamma, gamma^2]
discriminant()[source]

Return the discriminant of this order.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(8) + x**Integer(3) - Integer(13)*x + Integer(26), names=('a',)); (a,) = K._first_ngens(1)
>>> O = K.maximal_order()
>>> factor(O.discriminant())
3 * 11 * 13^2 * 613 * 1575917857
>>> L = K.order(Integer(13)*a**Integer(2))
>>> factor(L.discriminant())
3^3 * 5^2 * 11 * 13^60 * 613 * 733^2 * 1575917857
>>> factor(L.index_in(O))
3 * 5 * 13^29 * 733
>>> L.discriminant() / O.discriminant() == L.index_in(O)**Integer(2)
True
index_in(other)[source]

Return the index of self in other.

This is a lattice index, so it is a rational number if self is not contained in other.

INPUT:

  • other – another absolute order with the same ambient number field

OUTPUT: a rational number

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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 generated by [1/2*a^2 + 1/2*a, a^2] in Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
sage: O1 = k.order(a); O1
Order generated by a 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 generated by 2*a 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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> k = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = k._first_ngens(1)
>>> O1 = k.order(i)
>>> O5 = k.order(Integer(5)*i)
>>> O5.index_in(O1)
5

>>> k = NumberField(x**Integer(3) + x**Integer(2) - Integer(2)*x+Integer(8), names=('a',)); (a,) = k._first_ngens(1)
>>> o = k.maximal_order()
>>> o
Maximal Order generated by [1/2*a^2 + 1/2*a, a^2] in Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
>>> O1 = k.order(a); O1
Order generated by a in Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
>>> O1.index_in(o)
2
>>> O2 = k.order(Integer(1)+Integer(2)*a); O2
Order generated by 2*a in Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
>>> O1.basis()
[1, a, a^2]
>>> O2.basis()
[1, 2*a, 4*a^2]
>>> o.index_in(O2)
1/16
intersection(other)[source]

Return the intersection of this order with another order.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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]
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> k = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = k._first_ngens(1)
>>> O6 = k.order(Integer(6)*i)
>>> O9 = k.order(Integer(9)*i)
>>> O6.basis()
[1, 6*i]
>>> O9.basis()
[1, 9*i]
>>> O6.intersection(O9).basis()
[1, 18*i]
>>> (O6 & O9).basis()
[1, 18*i]
>>> (O6 + O9).basis()
[1, 3*i]
is_maximal(p=None)[source]

Return whether this is the maximal order.

INPUT:

  • p – integer prime or None (default: None); if set, return whether this order is maximal at the prime \(p\)

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<i> = NumberField(x^2 + 1)

sage: K.order(3*i).is_maximal()
False
sage: K.order(5*i).is_maximal()
False
sage: (K.order(3*i) + K.order(5*i)).is_maximal()
True
sage: K.maximal_order().is_maximal()
True
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1)

>>> K.order(Integer(3)*i).is_maximal()
False
>>> K.order(Integer(5)*i).is_maximal()
False
>>> (K.order(Integer(3)*i) + K.order(Integer(5)*i)).is_maximal()
True
>>> K.maximal_order().is_maximal()
True

Maximality can be checked at primes when the order is maximal at that prime by construction:

sage: K.maximal_order().is_maximal(p=3)
True
>>> from sage.all import *
>>> K.maximal_order().is_maximal(p=Integer(3))
True

And also at other primes:

   sage: K.order(3*i).is_maximal(p=3)
   False

An example involving a relative order::

   sage: K.<a, b> = NumberField([x^2 + 1, x^2 - 3])
   sage: O = K.order([3*a, 2*b])
   sage: O.is_maximal()
   False
module()[source]

Return the underlying free module corresponding to this order, embedded in the vector space corresponding to the ambient number field.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: k.<a> = NumberField(x^3 + x + 3)
sage: m = k.order(3*a); m
Order generated by 3*a 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]
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> k = NumberField(x**Integer(3) + x + Integer(3), names=('a',)); (a,) = k._first_ngens(1)
>>> m = k.order(Integer(3)*a); m
Order generated by 3*a in Number Field in a with defining polynomial x^3 + x + 3
>>> 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]
class sage.rings.number_field.order.Order_relative(K, absolute_order)[source]

Bases: 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.

absolute_discriminant()[source]

Return the absolute discriminant of self, which is the discriminant of the absolute order associated to self.

OUTPUT: integer

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> R = EquationOrder([x**Integer(2) + Integer(1), x**Integer(3) + Integer(2)], 'a,b')
>>> d = R.absolute_discriminant(); d
-746496
>>> d is R.absolute_discriminant()
True
>>> factor(d)
-1 * 2^10 * 3^6
absolute_order(names='z')[source]

Return underlying absolute order associated to this relative order.

INPUT:

  • names – string (default: 'z'); name of generator of absolute extension

Note

There is a default variable name, since this absolute order is frequently used for internal algorithms.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: R = EquationOrder([x^2 + 1, x^2 - 5], 'i,g'); R
Relative Order generated by [6*i - g, -g*i + 2, 7*i - g] 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 generated by [5/12*z^3 + 1/6*z, 1/2*z^2, 1/2*z^3] 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]
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> R = EquationOrder([x**Integer(2) + Integer(1), x**Integer(2) - Integer(5)], 'i,g'); R
Relative Order generated by [6*i - g, -g*i + 2, 7*i - g] in
 Number Field in i with defining polynomial x^2 + 1 over its base field
>>> R.basis()
[1, 6*i - g, -g*i + 2, 7*i - g]

>>> S = R.absolute_order(); S
Order generated by [5/12*z^3 + 1/6*z, 1/2*z^2, 1/2*z^3] in Number Field in z with defining polynomial x^4 - 8*x^2 + 36
>>> 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 generator of the number field that contains the absolute order be called gamma.:

sage: R = EquationOrder( [x^2 + 2, x^2 - 3], 'alpha'); R
Relative Order generated by [-alpha1*alpha0 + 1, 5*alpha0 + 2*alpha1, 7*alpha0 + 3*alpha1] in
 Number Field in alpha0 with defining polynomial x^2 + 2 over its base field
sage: R.absolute_order('gamma')
Order generated by [1/2*gamma^2 + 1/2, 7/10*gamma^3 + 1/10*gamma, gamma^3] 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]
>>> from sage.all import *
>>> R = EquationOrder( [x**Integer(2) + Integer(2), x**Integer(2) - Integer(3)], 'alpha'); R
Relative Order generated by [-alpha1*alpha0 + 1, 5*alpha0 + 2*alpha1, 7*alpha0 + 3*alpha1] in
 Number Field in alpha0 with defining polynomial x^2 + 2 over its base field
>>> R.absolute_order('gamma')
Order generated by [1/2*gamma^2 + 1/2, 7/10*gamma^3 + 1/10*gamma, gamma^3] in Number Field in gamma with defining polynomial x^4 - 2*x^2 + 25
>>> R.absolute_order('gamma').basis()
[1/2*gamma^2 + 1/2, 7/10*gamma^3 + 1/10*gamma, gamma^2, gamma^3]
basis()[source]

Return a basis for this order as \(\ZZ\)-module.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField([x**Integer(2) + Integer(1), x**Integer(2) + Integer(3)], names=('a', 'b',)); (a, b,) = K._first_ngens(2)
>>> O = K.order([a,b])
>>> O.basis()
[1, -2*a + b, -b*a - 2, -5*a + 3*b]
>>> z = O.gen(1); z
-2*a + b
>>> z.absolute_minpoly()
x^4 + 14*x^2 + 1
index_in(other)[source]

Return the index of self in other.

This is a lattice index, so it is a rational number if self is not contained in other.

INPUT:

  • other – another order with the same ambient absolute number field

OUTPUT: a rational number

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField([x**Integer(3) + x + Integer(3), x**Integer(2) + Integer(1)], names=('a', 'b',)); (a, b,) = K._first_ngens(2)
>>> R1 = K.order([Integer(3)*a, Integer(2)*b])
>>> R2 = K.order([a, Integer(4)*b])
>>> R1.index_in(R2)
729/8
>>> R2.index_in(R1)
8/729
is_maximal(p=None)[source]

Return whether this is the maximal order.

INPUT:

  • p – integer prime or None (default: None); if set, return whether this order is maximal at the prime \(p\)

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<a, b> = NumberField([x^2 + 1, x^2 - 5])

sage: K.order(3*a, b).is_maximal()
False
sage: K.order(5*a, b/2 + 1/2).is_maximal()
False
sage: (K.order(3*a, b) + K.order(5*a, b/2 + 1/2)).is_maximal()
True
sage: K.maximal_order().is_maximal()
True
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField([x**Integer(2) + Integer(1), x**Integer(2) - Integer(5)], names=('a', 'b',)); (a, b,) = K._first_ngens(2)

>>> K.order(Integer(3)*a, b).is_maximal()
False
>>> K.order(Integer(5)*a, b/Integer(2) + Integer(1)/Integer(2)).is_maximal()
False
>>> (K.order(Integer(3)*a, b) + K.order(Integer(5)*a, b/Integer(2) + Integer(1)/Integer(2))).is_maximal()
True
>>> K.maximal_order().is_maximal()
True

Maximality can be checked at primes when the order is maximal at that prime by construction:

sage: K.maximal_order().is_maximal(p=3)
True
>>> from sage.all import *
>>> K.maximal_order().is_maximal(p=Integer(3))
True

And at other primes:

sage: K.order(3*a, b).is_maximal(p=3)
False
>>> from sage.all import *
>>> K.order(Integer(3)*a, b).is_maximal(p=Integer(3))
False
is_suborder(other)[source]

Return True if self is a subset of the order other.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField([x**Integer(2) + Integer(1), x**Integer(3) + Integer(2)], names=('a', 'b',)); (a, b,) = K._first_ngens(2)
>>> R1 = K.order([a, b])
>>> R2 = K.order([Integer(2)*a, b])
>>> R3 = K.order([a + b, b + Integer(2)*a])
>>> R1.is_suborder(R2)
False
>>> R2.is_suborder(R1)
True
>>> R3.is_suborder(R1)
True
>>> R1.is_suborder(R3)
True
>>> R1 == R3
True
class sage.rings.number_field.order.RelativeOrderFactory[source]

Bases: OrderFactory

An order in a relative number field extension.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<i> = NumberField(x^2 + 1)
sage: R.<j> = K[]
sage: L.<j> = K.extension(j^2 - 2)
sage: L.order([i, j])
Relative Order generated by [-i*j + 1, -i] in
 Number Field in j with defining polynomial j^2 - 2 over its base field
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1)
>>> R = K['j']; (j,) = R._first_ngens(1)
>>> L = K.extension(j**Integer(2) - Integer(2), names=('j',)); (j,) = L._first_ngens(1)
>>> L.order([i, j])
Relative Order generated by [-i*j + 1, -i] in
 Number Field in j with defining polynomial j^2 - 2 over its base field
create_key_and_extra_args(K, absolute_order, is_maximal=None, check=True, is_maximal_at=())[source]

Return normalized arguments to create a relative order.

create_object(version, key, is_maximal=None, is_maximal_at=())[source]

Create a relative order.

sage.rings.number_field.order.absolute_order_from_module_generators(gens, check_integral=True, check_rank=True, check_is_ring=True, is_maximal=None, allow_subfield=False, is_maximal_at=())[source]

INPUT:

  • gens – list of elements of an absolute number field that generates an order in that number field as a \(\ZZ\)-module

  • check_integral – check that each generator is integral

  • check_rank – check that the gens span a module of the correct rank

  • check_is_ring – check that the module is closed under multiplication (this is very expensive)

  • is_maximal – boolean (or None); set if maximality of the generated order is known

  • is_maximal_at – tuple of primes where this order is known to be maximal

OUTPUT: an absolute order

EXAMPLES:

We have to explicitly import the function, since it is not meant for regular usage:

sage: from sage.rings.number_field.order import absolute_order_from_module_generators

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^4 - 5)
sage: O = K.maximal_order(); O
Maximal Order generated by [1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a] 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.basis(); 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)
Maximal Order generated by [1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a] in Number Field in a with defining polynomial x^4 - 5
>>> from sage.all import *
>>> from sage.rings.number_field.order import absolute_order_from_module_generators

>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(4) - Integer(5), names=('a',)); (a,) = K._first_ngens(1)
>>> O = K.maximal_order(); O
Maximal Order generated by [1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a] in Number Field in a with defining polynomial x^4 - 5
>>> O.basis()
[1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a, a^2, a^3]
>>> 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]
>>> g = O.basis(); g
[1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a, a^2, a^3]
>>> absolute_order_from_module_generators(g)
Maximal Order generated by [1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a] 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)
Maximal Order generated by [1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a] in Number Field in a with defining polynomial x^4 - 5
sage: absolute_order_from_module_generators(g,  check_rank=False)
Maximal Order generated by [1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a] in Number Field in a with defining polynomial x^4 - 5
sage: absolute_order_from_module_generators(g,  check_integral=False)
Maximal Order generated by [1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a] in Number Field in a with defining polynomial x^4 - 5
>>> from sage.all import *
>>> absolute_order_from_module_generators(g,  check_is_ring=False)
Maximal Order generated by [1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a] in Number Field in a with defining polynomial x^4 - 5
>>> absolute_order_from_module_generators(g,  check_rank=False)
Maximal Order generated by [1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a] in Number Field in a with defining polynomial x^4 - 5
>>> absolute_order_from_module_generators(g,  check_integral=False)
Maximal Order generated by [1/2*a^2 + 1/2, 1/2*a^3 + 1/2*a] 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 of conductor 4 generated by [2, 2*i]
 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 of conductor I generated by []
 in Number Field in i with defining polynomial x^2 + 1
sage: R.basis()
[1]
>>> from sage.all import *
>>> k = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = k._first_ngens(1)
>>> R = absolute_order_from_module_generators([Integer(2), Integer(2)*i],
...                                           check_is_ring=False); R
Order of conductor 4 generated by [2, 2*i]
 in Number Field in i with defining polynomial x^2 + 1
>>> R.basis()
[2, 2*i]
>>> R = absolute_order_from_module_generators([k(Integer(1))],
...                                           check_rank=False); R
Order of conductor I generated by []
 in Number Field in i with defining polynomial x^2 + 1
>>> R.basis()
[1]

If the order contains a non-integral element, even if we do not check that, we will find that the rank is wrong or that the order is not closed under multiplication:

sage: absolute_order_from_module_generators([1/2, i],
....:                                       check_integral=False)
Traceback (most recent call last):
...
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 of conductor 0 generated by [1/2, i] in Number Field in i with defining polynomial x^2 + 1
sage: R.basis()
[1/2, i]
>>> from sage.all import *
>>> absolute_order_from_module_generators([Integer(1)/Integer(2), i],
...                                       check_integral=False)
Traceback (most recent call last):
...
ValueError: the module span of the gens is not closed under multiplication.
>>> R = absolute_order_from_module_generators([Integer(1)/Integer(2), i],
...                                           check_is_ring=False,
...                                           check_integral=False); R
Order of conductor 0 generated by [1/2, i] in Number Field in i with defining polynomial x^2 + 1
>>> 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 of conductor 0 generated by [1/2, i] in Number Field in i with defining polynomial x^2 + 1
sage: R.basis()
[1/2, i]
>>> from sage.all import *
>>> R = absolute_order_from_module_generators([Integer(1)/Integer(2), i],
...                                           check_is_ring=False,
...                                           check_integral=False,
...                                           check_rank=False); R
Order of conductor 0 generated by [1/2, i] in Number Field in i with defining polynomial x^2 + 1
>>> 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 of conductor 2 generated by ... in Number Field in beta with defining polynomial ... with beta = ...
>>> from sage.all import *
>>> F = NumberField(x**Integer(4) + Integer(3), names=('alpha',)); (alpha,) = F._first_ngens(1)
>>> F.order([alpha**Integer(2)], allow_subfield=True)
Order of conductor 2 generated by ... in Number Field in beta with defining polynomial ... with beta = ...
sage.rings.number_field.order.absolute_order_from_ring_generators(gens, check_is_integral=True, check_rank=True, is_maximal=None, allow_subfield=False)[source]

INPUT:

  • gens – list of integral elements of an absolute order

  • check_is_integral – boolean (default: True); whether to check that each generator is integral

  • check_rank – boolean (default: True); whether to check that the ring generated by gens is of full rank

  • is_maximal – boolean (or None); set if maximality of the generated order is known

  • allow_subfield – boolean (default: False); if True and the generators do not generate an order, i.e., they generate a subring of smaller rank, instead of raising an error, return an order in a smaller number field

EXAMPLES:

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^4 - 5)
sage: K.order(a)
Order generated by a in Number Field in a with defining polynomial x^4 - 5
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(4) - Integer(5), names=('a',)); (a,) = K._first_ngens(1)
>>> K.order(a)
Order generated by a 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 generated by a in Number Field in a with defining polynomial x^4 - 5
sage: absolute_order_from_ring_generators([3*a, 2, 6*a + 1])
Order generated by 3*a in Number Field in a with defining polynomial x^4 - 5
>>> from sage.all import *
>>> from sage.rings.number_field.order import absolute_order_from_ring_generators
>>> absolute_order_from_ring_generators([a])
Order generated by a in Number Field in a with defining polynomial x^4 - 5
>>> absolute_order_from_ring_generators([Integer(3)*a, Integer(2), Integer(6)*a + Integer(1)])
Order generated by 3*a 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])
Traceback (most recent call last):
...
ValueError: each generator must be integral
>>> from sage.all import *
>>> absolute_order_from_ring_generators([a/Integer(2)])
Traceback (most recent call last):
...
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])
Traceback (most recent call last):
...
ValueError: the rank of the span of gens is wrong
>>> from sage.all import *
>>> absolute_order_from_ring_generators([a**Integer(2)])
Traceback (most recent call last):
...
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 generated by [1, 1/2*a, 1/4*a^2, 1/8*a^3] in Number Field in a with defining polynomial x^4 - 5
sage: absolute_order_from_ring_generators([a^2], check_rank=False)
Order generated by a^2 in Number Field in a with defining polynomial x^4 - 5
>>> from sage.all import *
>>> absolute_order_from_ring_generators([a/Integer(2)], check_is_integral=False)
Order generated by [1, 1/2*a, 1/4*a^2, 1/8*a^3] in Number Field in a with defining polynomial x^4 - 5
>>> absolute_order_from_ring_generators([a**Integer(2)], check_rank=False)
Order generated by a^2 in Number Field in a with defining polynomial x^4 - 5
sage.rings.number_field.order.each_is_integral(v)[source]

Return whether every element of the list v of elements of a number field is integral.

EXAMPLES:

sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> W = NumberField(x**Integer(2) - Integer(5), names=('sqrt5',)); (sqrt5,) = W._first_ngens(1)
>>> from sage.rings.number_field.order import each_is_integral
>>> each_is_integral([sqrt5, Integer(2), (Integer(1)+sqrt5)/Integer(2)])
True
>>> each_is_integral([sqrt5, (Integer(1)+sqrt5)/Integer(3)])
False
sage.rings.number_field.order.is_NumberFieldOrder(R)[source]

Return True if \(R\) is either an order in a number field or is the ring \(\ZZ\) of integers.

EXAMPLES:

sage: from sage.rings.number_field.order import is_NumberFieldOrder
sage: x = polygen(ZZ, 'x')
sage: is_NumberFieldOrder(NumberField(x^2 + 1, 'a').maximal_order())
doctest:warning...
DeprecationWarning: The function is_NumberFieldOrder is deprecated;
use 'isinstance(..., sage.rings.abc.Order) or ... == ZZ' instead.
See https://github.com/sagemath/sage/issues/38124 for details.
True
sage: is_NumberFieldOrder(ZZ)
True
sage: is_NumberFieldOrder(QQ)
False
sage: is_NumberFieldOrder(45)
False
>>> from sage.all import *
>>> from sage.rings.number_field.order import is_NumberFieldOrder
>>> x = polygen(ZZ, 'x')
>>> is_NumberFieldOrder(NumberField(x**Integer(2) + Integer(1), 'a').maximal_order())
doctest:warning...
DeprecationWarning: The function is_NumberFieldOrder is deprecated;
use 'isinstance(..., sage.rings.abc.Order) or ... == ZZ' instead.
See https://github.com/sagemath/sage/issues/38124 for details.
True
>>> is_NumberFieldOrder(ZZ)
True
>>> is_NumberFieldOrder(QQ)
False
>>> is_NumberFieldOrder(Integer(45))
False
sage.rings.number_field.order.quadratic_order_class_number(disc)[source]

Return the class number of the quadratic order of given discriminant.

EXAMPLES:

sage: from sage.rings.number_field.order import quadratic_order_class_number
sage: quadratic_order_class_number(-419)
9
sage: quadratic_order_class_number(60)
2
>>> from sage.all import *
>>> from sage.rings.number_field.order import quadratic_order_class_number
>>> quadratic_order_class_number(-Integer(419))
9
>>> quadratic_order_class_number(Integer(60))
2

ALGORITHM: Either pari:qfbclassno or pari:quadclassunit, depending on the size of the discriminant.

sage.rings.number_field.order.relative_order_from_ring_generators(gens, check_is_integral=True, check_rank=True, is_maximal=None, allow_subfield=False, is_maximal_at=())[source]

INPUT:

  • gens – list of integral elements of an absolute order

  • check_is_integral – boolean (default: True); whether to check that each generator is integral

  • check_rank – boolean (default: True); whether to check that the ring generated by gens is of full rank

  • is_maximal – boolean (or None); set if maximality of the generated order is known

EXAMPLES:

We have to explicitly import this function, since it is not meant for regular usage:

sage: from sage.rings.number_field.order import relative_order_from_ring_generators
sage: x = polygen(ZZ, 'x')
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 generated by [7*i - 2*a, -a*i + 8, 25*i - 7*a] in
 Number Field in i with defining polynomial x^2 + 1 over its base field
>>> from sage.all import *
>>> from sage.rings.number_field.order import relative_order_from_ring_generators
>>> x = polygen(ZZ, 'x')
>>> K = NumberField([x**Integer(2) + Integer(1), x**Integer(2) - Integer(17)], names=('i', 'a',)); (i, a,) = K._first_ngens(2)
>>> R = K.base_field().maximal_order()
>>> S = relative_order_from_ring_generators([i,a]); S
Relative Order generated by [7*i - 2*a, -a*i + 8, 25*i - 7*a] 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]
>>> from sage.all import *
>>> S.basis()
[1, 7*i - 2*a, -a*i + 8, 25*i - 7*a]