27.1 Number Fields

Module: sage.rings.number_field.number_field

Number Fields

Author Log:

NOTE:

Unlike in PARI/GP, class group computations *in SAGE* do *not* by default assume the Generalized Riemann Hypothesis. To do class groups computations not provably correctly you must often pass the flag proof=False to functions or call the function proof.number_field(False). It can easily take 1000's of times longer to do computations with proof=True (the default).

This example follows one in the Magma reference manual:

sage: K.<y> = NumberField(x^4 - 420*x^2 + 40000)
sage: z = y^5/11; z
420/11*y^3 - 40000/11*y
sage: R.<y> = PolynomialRing(K)
sage: f = y^2 + y + 1
sage: L.<a> = K.extension(f); L
Number Field in a with defining polynomial y^2 + y + 1 over its base field
sage: KL.<b> = NumberField([x^4 - 420*x^2 + 40000, x^2 + x + 1]); KL
Number Field in b0 with defining polynomial x^4 + (-420)*x^2 + 40000 over
its base field

We do some arithmetic in a tower of relative number fields:

sage: K.<cuberoot2> = NumberField(x^3 - 2)
sage: L.<cuberoot3> = K.extension(x^3 - 3)
sage: S.<sqrt2> = L.extension(x^2 - 2)
sage: S
Number Field in sqrt2 with defining polynomial x^2 - 2 over its base field
sage: sqrt2 * cuberoot3
cuberoot3*sqrt2
sage: (sqrt2 + cuberoot3)^5
(20*cuberoot3^2 + 15*cuberoot3 + 4)*sqrt2 + 3*cuberoot3^2 + 20*cuberoot3 +
60
sage: cuberoot2 + cuberoot3
cuberoot3 + cuberoot2
sage: cuberoot2 + cuberoot3 + sqrt2
sqrt2 + cuberoot3 + cuberoot2
sage: (cuberoot2 + cuberoot3 + sqrt2)^2
(2*cuberoot3 + 2*cuberoot2)*sqrt2 + cuberoot3^2 + 2*cuberoot2*cuberoot3 +
cuberoot2^2 + 2
sage: cuberoot2 + sqrt2
sqrt2 + cuberoot2
sage: a = S(cuberoot2); a
cuberoot2
sage: a.parent()
Number Field in sqrt2 with defining polynomial x^2 - 2 over its base field

WARNING: Doing arithmetic in towers of relative fields that depends on canonical coercions is currently VERY SLOW. It is much better to explicitly coerce all elements into a common field, then do arithmetic with them there (which is quite fast).

TESTS:

sage: y = polygen(QQ,'y'); K.<beta> = NumberField([y^3 - 3, y^2 - 2])
sage: K(y^10)
(-3024*beta1 + 1530)*beta0^2 + (-2320*beta1 + 5067)*beta0 - 3150*beta1 +
7592

Module-level Functions

CyclotomicField( n, [names=None])

Return the n-th cyclotomic field, where n is a positive integer.

Input:

n
- a positive integer
names
- name of generator (optional - defaults to zetan).

We create the $ 7$ th cyclotomic field $ \mathbf{Q}(\zeta_7)$ with the default generator name.

sage: k = CyclotomicField(7); k
Cyclotomic Field of order 7 and degree 6
sage: k.gen()
zeta7

Cyclotomic fields are of a special type.

sage: type(k)
<class 'sage.rings.number_field.number_field.NumberField_cyclotomic'>

We can specify a different generator name as follows.

sage: k.<z7> = CyclotomicField(7); k
Cyclotomic Field of order 7 and degree 6
sage: k.gen()
z7

The $ n$ must be an integer.

sage: CyclotomicField(3/2)
Traceback (most recent call last):
...
TypeError: no coercion of this rational to integer

The degree must be positive.

sage: CyclotomicField(0)
Traceback (most recent call last):
...
ValueError: n (=0) must be a positive integer

The special case $ n=1$ does not return the rational numbers:

sage: CyclotomicField(1)
Cyclotomic Field of order 1 and degree 1

sage: cf6 = CyclotomicField(6) ; z6 = cf6.0
sage: cf3 = CyclotomicField(3) ; z3 = cf3.0
sage: cf3(z6)
zeta3 + 1
sage: cf6(z3)
zeta6 - 1
sage: cf9 = CyclotomicField(9) ; z9 = cf9.0
sage: cf18 = CyclotomicField(18) ; z18 = cf18.0
sage: cf18(z9)
zeta18^2
sage: cf9(z18)
-zeta9^5
sage: cf18(z3)
zeta18^3 - 1
sage: cf18(z6)
zeta18^3
sage: cf18(z6)**2
zeta18^3 - 1
sage: cf9(z3)
zeta9^3

NumberField( polynomial, [name=None], [check=True], [names=None], [cache=True])

Return the number field defined by the given irreducible polynomial and with variable with the given name. If check is True (the default), also verify that the defining polynomial is irreducible and over Q.

Input:

polynomial
- a polynomial over QQ or a number field, or a list of polynomials.
name
- a string (default: 'a'), the name of the generator
check
- bool (default: True); do type checking and irreducibility checking.

sage: z = QQ['z'].0
sage: K = NumberField(z^2 - 2,'s'); K
Number Field in s with defining polynomial z^2 - 2
sage: s = K.0; s
s
sage: s*s    
2
sage: s^2
2

Constructing a relative number field

sage: K.<a> = NumberField(x^2 - 2)
sage: R.<t> = K[]
sage: L.<b> = K.extension(t^3+t+a); L
Number Field in b with defining polynomial t^3 + t + a over its base field
sage: L.absolute_field('c')
Number Field in c with defining polynomial x^6 + 2*x^4 + x^2 - 2
sage: a*b
a*b
sage: L(a)
a
sage: L.lift_to_base(b^3 + b)
-a

Constructing another number field:

sage: k.<i> = NumberField(x^2 + 1)
sage: R.<z> = k[]
sage: m.<j> = NumberField(z^3 + i*z + 3)
sage: m
Number Field in j with defining polynomial z^3 + i*z + 3 over its base
field

Number fields are globally unique.

sage: K.<a>= NumberField(x^3-5)     
sage: a^3
5
sage: L.<a>= NumberField(x^3-5)
sage: K is L
True

Having different defining polynomials makes them fields different:

sage: x = polygen(QQ, 'x'); y = polygen(QQ, 'y')
sage: k.<a> = NumberField(x^2 + 3)
sage: m.<a> = NumberField(y^2 + 3)
sage: k
Number Field in a with defining polynomial x^2 + 3
sage: m
Number Field in a with defining polynomial y^2 + 3

An example involving a variable name that defines a function in PARI:

sage: theta = polygen(QQ, 'theta')
sage: M.<z> = NumberField([theta^3 + 4, theta^2 + 3]); M
Number Field in z0 with defining polynomial theta^3 + 4 over its base field

NumberFieldTower( v, names, [check=True])

Return the tower of number fields defined by the polynomials or number fields in the list v.

This is the field constructed first from v[0], then over that field from v[1], etc. If all is False, then each v[i] must be irreducible over the previous fields. Otherwise a list of all possible fields defined by all those polynomials is output.

If names defines a variable name a, say, then the generators of the intermediate number fields are a0, a1, a2, ...

Input:

v
- a list of polynomials or number fields
names
- variable names
check
- bool (default: True) only relevant if all is False. Then check irreducibility of each input polynomial.

Output: a single number field or a list of number fields

sage: k.<a,b,c> = NumberField([x^2 + 1, x^2 + 3, x^2 + 5]); k
Number Field in a with defining polynomial x^2 + 1 over its base field
sage: a^2
-1
sage: b^2
-3
sage: c^2
-5
sage: (a+b+c)^2
(2*b + 2*c)*a + 2*c*b - 9

The Galois group is a product of 3 groups of order 2:

sage: k.galois_group()
Galois group PARI group [8, 1, 3, "E(8)=2[x]2[x]2"] of degree 8 of the
Number Field in a with defining polynomial x^2 + 1 over its base field

Repeatedly calling base_field allows us to descend the internally constructed tower of fields:

sage: k.base_field()
Number Field in b with defining polynomial x^2 + 3 over its base field
sage: k.base_field().base_field()
Number Field in c with defining polynomial x^2 + 5
sage: k.base_field().base_field().base_field()
Rational Field

In the following example the second polynomial is reducible over the first, so we get an error:

sage: v = NumberField([x^3 - 2, x^3 - 2], names='a')
Traceback (most recent call last):
...
ValueError: defining polynomial (x^3 - 2) must be irreducible

We mix polynomial parent rings:

sage: k.<y> = QQ[]
sage: m = NumberField([y^3 - 3, x^2 + x + 1, y^3 + 2], 'beta')
sage: m
Number Field in beta0 with defining polynomial y^3 - 3 over its base field
sage: m.base_field ()
Number Field in beta1 with defining polynomial x^2 + x + 1 over its base
field

A tower of quadratic fields:

sage: K.<a> = NumberField([x^2 + 3, x^2 + 2, x^2 + 1])
sage: K
Number Field in a0 with defining polynomial x^2 + 3 over its base field
sage: K.base_field()
Number Field in a1 with defining polynomial x^2 + 2 over its base field
sage: K.base_field().base_field()
Number Field in a2 with defining polynomial x^2 + 1

A bigger tower of quadratic fields.

sage: K.<a2,a3,a5,a7> = NumberField([x^2 + p for p in [2,3,5,7]]); K
Number Field in a2 with defining polynomial x^2 + 2 over its base field
sage: a2^2
-2
sage: a3^2
-3
sage: (a2+a3+a5+a7)^3
((6*a5 + 6*a7)*a3 + 6*a7*a5 - 47)*a2 + (6*a7*a5 - 45)*a3 + (-41)*a5 - 37*a7

NumberField_absolute_v1( poly, name, latex_name)

This is used in pickling generic number fields.

sage: from sage.rings.number_field.number_field import NumberField_generic_v1
sage: R.<x> = QQ[]
sage: NumberField_generic_v1(x^2 + 1, 'i', 'i')
Number Field in i with defining polynomial x^2 + 1

NumberField_cyclotomic_v1( zeta_order, name)

This is used in pickling cyclotomic fields.

sage: from sage.rings.number_field.number_field import NumberField_cyclotomic_v1
sage: NumberField_cyclotomic_v1(5,'a')
Cyclotomic Field of order 5 and degree 4
sage: NumberField_cyclotomic_v1(5,'a').variable_name()
'a'

NumberField_extension_v1( base_field, poly, name, latex_name)

This is used in pickling relative fields.

sage: from sage.rings.number_field.number_field import NumberField_relative_v1
sage: R.<x> = CyclotomicField(3)[]
sage: NumberField_relative_v1(CyclotomicField(3), x^2 + 7, 'a', 'a')
Number Field in a with defining polynomial x^2 + 7 over its base field

NumberField_generic_v1( poly, name, latex_name)

This is used in pickling generic number fields.

sage: from sage.rings.number_field.number_field import NumberField_generic_v1
sage: R.<x> = QQ[]
sage: NumberField_generic_v1(x^2 + 1, 'i', 'i')
Number Field in i with defining polynomial x^2 + 1

NumberField_quadratic_v1( poly, name)

This is used in pickling quadratic fields.

sage: from sage.rings.number_field.number_field import NumberField_quadratic_v1
sage: R.<x> = QQ[]
sage: NumberField_quadratic_v1(x^2 - 2, 'd')
Number Field in d with defining polynomial x^2 - 2

NumberField_relative_v1( base_field, poly, name, latex_name)

This is used in pickling relative fields.

sage: from sage.rings.number_field.number_field import NumberField_relative_v1
sage: R.<x> = CyclotomicField(3)[]
sage: NumberField_relative_v1(CyclotomicField(3), x^2 + 7, 'a', 'a')
Number Field in a with defining polynomial x^2 + 7 over its base field

QuadraticField( D, names, [check=True])

Return a quadratic field obtained by adjoining a square root of $ D$ to the rational numbers, where $ D$ is not a perfect square.

Input:

D
- a rational number
name
- variable name
check
- bool (default: True)

Output: A number field defined by a quadratic polynomial.

sage: QuadraticField(3, 'a')
Number Field in a with defining polynomial x^2 - 3
sage: K.<theta> = QuadraticField(3); K
Number Field in theta with defining polynomial x^2 - 3
sage: QuadraticField(9, 'a')
Traceback (most recent call last):
...
ValueError: D must not be a perfect square.
sage: QuadraticField(9, 'a', check=False)
Number Field in a with defining polynomial x^2 - 9

Quadratic number fields derive from general number fields.

sage: type(K)
<class 'sage.rings.number_field.number_field.NumberField_quadratic'>
sage: is_NumberField(K)
True

gp( )

Return the unique copy of the gp (PARI) interpreter used for number field computations.

sage: from sage.rings.number_field.number_field import gp
sage: gp()
GP/PARI interpreter

is_AbsoluteNumberField( x)

Return True if x is an absolute number field.

sage: is_AbsoluteNumberField(NumberField(x^2+1,'a'))
True
sage: is_AbsoluteNumberField(NumberField([x^3 + 17, x^2+1],'a'))
False

The rationals are a number field, but they're not of the absolute number field class.

sage: is_AbsoluteNumberField(QQ)
False

is_CyclotomicField( x)

Return True if x is a cyclotomic field, i.e., of the special cyclotomic field class. This function does not return True for a number field that just happens to be isomorphic to a cyclotomic field.

sage: is_CyclotomicField(NumberField(x^2 + 1,'zeta4'))
False
sage: is_CyclotomicField(CyclotomicField(4))
True
sage: is_CyclotomicField(CyclotomicField(1))
True
sage: is_CyclotomicField(QQ)
False
sage: is_CyclotomicField(7)
False

is_QuadraticField( x)

Return True if x is of the quadratic number field type.

sage: is_QuadraticField(QuadraticField(5,'a'))
True
sage: is_QuadraticField(NumberField(x^2 - 5, 'b'))
True
sage: is_QuadraticField(NumberField(x^3 - 5, 'b'))
False

A quadratic field specially refers to a number field, not a finite field:

sage: is_QuadraticField(GF(9,'a'))
False

is_RelativeNumberField( x)

Return True if x is a relative number field.

sage: is_RelativeNumberField(NumberField(x^2+1,'a'))
False
sage: k.<a> = NumberField(x^3 - 2)
sage: l.<b> = k.extension(x^3 - 3); l
Number Field in b with defining polynomial x^3 - 3 over its base field
sage: is_RelativeNumberField(l)
True
sage: is_RelativeNumberField(QQ)
False

is_fundamental_discriminant( D)

Return True if the integer $ D$ is a fundamental discriminant, i.e., if $ D \equiv 0,1\pmod{4}$ , and $ D\neq 0, 1$ and either (1) $ D$ is square free or (2) we have $ D\equiv 0\pmod{4}$ with $ D/4 \equiv 2,3\pmod{4}$ and $ D/4$ square free. These are exactly the discriminants of quadratic fields.

sage: [D for D in range(-15,15) if is_fundamental_discriminant(D)]
[-15, -11, -8, -7, -4, -3, 5, 8, 12, 13]
sage: [D for D in range(-15,15) if not is_square(D) and QuadraticField(D,'a').disc() == D]
[-15, -11, -8, -7, -4, -3, 5, 8, 12, 13]

proof_flag( t)

Used for easily determining the correct proof flag to use.

put_natural_embedding_first( v)

Class: NumberField_absolute

class NumberField_absolute
NumberField_absolute( self, polynomial, name, [latex_name=None], [check=True])

Functions: absolute_polynomial,$ \,$ absolute_vector_space,$ \,$ base_field,$ \,$ change_names,$ \,$ embeddings,$ \,$ galois_closure,$ \,$ is_absolute,$ \,$ maximal_order,$ \,$ Minkowski_embedding,$ \,$ optimized_representation,$ \,$ optimized_subfields,$ \,$ order,$ \,$ places,$ \,$ real_places,$ \,$ relativize,$ \,$ subfields,$ \,$ vector_space

absolute_polynomial( self)

Return absolute polynomial that defines this absolute field. This is the same as self.polynomial().

sage: K.<a> = NumberField(x^2 + 1)
sage: K.absolute_polynomial ()
x^2 + 1

absolute_vector_space( self)

Return vector space over $ \mathbf{Q}$ corresponding to this number field, along with maps from that space to this number field and in the other direction.

For an absolute extension this is identical to self.vector_space().

sage: K.<a> = NumberField(x^3 - 5)
sage: K.absolute_vector_space()
(Vector space of dimension 3 over Rational Field,
 Isomorphism from Vector space of dimension 3 over Rational Field to Number
Field in a with defining polynomial x^3 - 5,
 Isomorphism from Number Field in a with defining polynomial x^3 - 5 to
Vector space of dimension 3 over Rational Field)

base_field( self)

Returns the base field of self, which is always QQ

sage: K = CyclotomicField(5)
sage: K.base_field()
Rational Field

change_names( self, names)

Return number field isomorphic to self but with the given generator name.

Input:

names
- should be exactly one variable name.

Also, K.structure() returns from_K and to_K, where from_K is an isomorphism from K to self and to_K is an isomorphism from self to K.

sage: K.<z> = NumberField(x^2 + 3); K
Number Field in z with defining polynomial x^2 + 3
sage: L.<ww> = K.change_names()
sage: L
Number Field in ww with defining polynomial x^2 + 3
sage: L.structure()[0]
Number field isomorphism from Number Field in ww with defining polynomial
x^2 + 3 to Number Field in z with defining polynomial x^2 + 3 given by
variable name change
sage: L.structure()[0](ww + 5/3)
z + 5/3

embeddings( self, K)

Compute all field embeddings of self into the field K (which need not even be a number field, e.g., it could be the complex numbers). This will return an identical result when given K as input again.

If possible, the most natural embedding of K into self is put first in the list.

Input:

K
- a number field

sage: K.<a> = NumberField(x^3 - 2)
sage: L.<a1> = K.galois_closure(); L
Number Field in a1 with defining polynomial x^6 + 40*x^3 + 1372
sage: K.embeddings(L)[0]
Ring morphism:
  From: Number Field in a with defining polynomial x^3 - 2
  To:   Number Field in a1 with defining polynomial x^6 + 40*x^3 + 1372
  Defn: a |--> 1/84*a1^4 + 13/42*a1
sage: K.embeddings(L)  is K.embeddings(L)
True

We embed a quadratic field into a cyclotomic field:

sage: L.<a> = QuadraticField(-7)
sage: K = CyclotomicField(7)
sage: L.embeddings(K)
[
Ring morphism:
  From: Number Field in a with defining polynomial x^2 + 7
  To:   Cyclotomic Field of order 7 and degree 6
  Defn: a |--> 2*zeta7^4 + 2*zeta7^2 + 2*zeta7 + 1,
Ring morphism:
  From: Number Field in a with defining polynomial x^2 + 7
  To:   Cyclotomic Field of order 7 and degree 6
  Defn: a |--> -2*zeta7^4 - 2*zeta7^2 - 2*zeta7 - 1
]

We embed a cubic field in the complex numbers:

sage: K.<a> = NumberField(x^3 - 2)
sage: K.embeddings(CC)
[
Ring morphism:
  From: Number Field in a with defining polynomial x^3 - 2
  To:   Complex Field with 53 bits of precision
  Defn: a |--> -0.62996052494743... - 1.09112363597172*I,
Ring morphism:
  From: Number Field in a with defining polynomial x^3 - 2
  To:   Complex Field with 53 bits of precision
  Defn: a |--> -0.62996052494743... + 1.09112363597172*I,
Ring morphism:
  From: Number Field in a with defining polynomial x^3 - 2
  To:   Complex Field with 53 bits of precision
  Defn: a |--> 1.25992104989487
]

galois_closure( self, [names=None])

Return number field $ K$ that is the Galois closure of self, i.e., is generated by all roots of the defining polynomial of self

Input:

names
- variable name for Galois closure

sage: K.<a> = NumberField(x^4 - 2)
sage: M = K.galois_closure('b'); M
Number Field in b with defining polynomial x^8 + 28*x^4 + 2500
sage: L.<a2> = K.galois_closure(); L
Number Field in a2 with defining polynomial x^8 + 28*x^4 + 2500
sage: K.galois_group().order()
8

sage: phi = K.embeddings(L)[0]
sage: phi(K.0)
1/120*a2^5 + 19/60*a2
sage: phi(K.0).minpoly()
x^4 - 2

is_absolute( self)

Returns True since self is an absolute field.

sage: K = CyclotomicField(5)
sage: K.is_absolute()
True

maximal_order( self, [v=None])

Return the maximal order, i.e., the ring of integers, associated to this number field.

Input:

v
- (default: None) None, a prime, or a list of primes. * if v is None, return the maximal order. * if v is a prime, return an order that is p-maximal. * if v is a list, return an order that is maximal at each prime in the list v.

In this example, the maximal order cannot be generated by a single element.

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

We compute $ p$ -maximal orders for several $ p$ . Note that computing a $ p$ -maximal order is much faster in general than computing the maximal order:

sage: p = next_prime(10^22); q = next_prime(10^23)
sage: K.<a> = NumberField(x^3 - p*q)
sage: K.maximal_order([3]).basis()
[1/3*a^2 + 1/3*a + 1/3, a, a^2]
sage: K.maximal_order([2]).basis()
[1, a, a^2]
sage: K.maximal_order([p]).basis()
[1, a, a^2]
sage: K.maximal_order([q]).basis()
[1, a, a^2]
sage: K.maximal_order([p,3]).basis()
[1/3*a^2 + 1/3*a + 1/3, a, a^2]

An example with bigger discriminant:

sage: p = next_prime(10^97); q = next_prime(10^99)
sage: K.<a> = NumberField(x^3 - p*q)
sage: K.maximal_order(prime_range(10000)).basis()
[1, a, a^2]

Minkowski_embedding( self, [B=None], [prec=None])

Return an nxn matrix over RDF whose columns are the images of the basis $ \{1, \alpha, \dots, \alpha^{n-1}\}$ of self over $ \mathbf{Q}$ (as vector spaces), where here $ \alpha$ is the generator of self over $ \mathbf{Q}$ , i.e. self.gen(0). If B is not None, return the images of the vectors in B as the columns instead. If prec is not None, use RealField(prec) instead of RDF.

This embedding is the so-called "Minkowski embedding" of a number field in $ \mathbf{R}^n$ : given the $ n$ embeddings $ \sigma_1, \dots, \sigma_n$ of self in $ \mathbf{C}$ , write $ \sigma_1, \dots, \sigma_r$ for the real embeddings, and $ \sigma_{r+1}, \dots, \sigma_{r+s}$ for choices of one of each pair of complex conjugate embeddings (in our case, we simply choose the one where the image of $ \alpha$ has positive real part). Here $ (r,s)$ is the signature of self. Then the Minkowski embedding is given by:

x |-> ( $ \sigma_1(x)$ , $ \dots$ , $ \sigma_r(x)$ , $ \sqrt{2}\Re(\sigma_{r+1}(x))$ , $ \sqrt{2}\Im(\sigma_{r+1}(x))$ , $ \dots$ , $ \sqrt{2}\Re(\sigma_{r+s}(x))$ , $ \sqrt{2}\Im(\sigma_{r+s}(x))$ )

Equivalently, this is an embedding of self in $ \mathbf{R}^n$ so that the usual norm on $ \mathbf{R}^n$ coincides with $ \Vert x\Vert = \sum_i \vert\sigma_i(x)\vert^2$ on self.

TODO: This could be much improved by implementing homomorphisms over VectorSpaces.

sage: F.<alpha> = NumberField(x^3+2)
sage: F.Minkowski_embedding() # random low-order bits
[ 1.00000000000000 -1.25992104989487  1.58740105196820]
[ 1.41421356237000 0.890898718138390 -1.12246204830692]
[0.000000000000000  1.54308184421368  1.94416129723541]
sage: F.Minkowski_embedding([1, alpha+2, alpha^2-alpha]) # random low-order bits
[ 1.00000000000000 0.740078950105127  2.84732210186307]
[ 1.41421356237000  3.71932584287839 -2.01336076644531]
[0.000000000000000  1.54308184421368 0.401079453021736]
sage: F.Minkowski_embedding() * (alpha + 2).vector().transpose() # random low-order bits
[0.740078950105127]
[ 3.71932584287839]
[ 1.54308184421368]

optimized_representation( self, [names=None], [both_maps=True])

Return a field isomorphic to self with a better defining polynomial if possible, along with field isomorphisms from the new field to self and from self to the new field.

We construct a compositum of 3 quadratic fields, then find an optimized representation and transform elements back and forth.

sage: K = NumberField([x^2 + p for p in [5, 3, 2]],'a').absolute_field('b'); K
Number Field in b with defining polynomial x^8 + 40*x^6 + 352*x^4 + 960*x^2
+ 576
sage: L, from_L, to_L = K.optimized_representation()
sage: L    # your answer may different, since algorithm is random
Number Field in a14 with defining polynomial x^8 + 4*x^6 + 7*x^4 + 36*x^2 +
81
sage: to_L(K.0)   # random
4/189*a14^7 - 1/63*a14^6 + 1/27*a14^5 + 2/9*a14^4 - 5/27*a14^3 + 8/9*a14^2
+ 3/7*a14 + 3/7
sage: from_L(L.0)   # random
1/1152*a1^7 + 1/192*a1^6 + 23/576*a1^5 + 17/96*a1^4 + 37/72*a1^3 + 5/6*a1^2
+ 55/24*a1 + 3/4

The transformation maps are mutually inverse isomorphisms.

sage: from_L(to_L(K.0))
b
sage: to_L(from_L(L.0))     # random
a14

optimized_subfields( self, [degree=0], [name=None], [both_maps=True])

Return optimized representations of many (but *not* necessarily all!) subfields of self of degree 0, or of all possible degrees if degree is 0.

sage: K = NumberField([x^2 + p for p in [5, 3, 2]],'a').absolute_field('b'); K
Number Field in b with defining polynomial x^8 + 40*x^6 + 352*x^4 + 960*x^2
+ 576
sage: L = K.optimized_subfields(name='b')
sage: L[0][0]
Number Field in b0 with defining polynomial x - 1
sage: L[1][0]
Number Field in b1 with defining polynomial x^2 - x + 1
sage: [z[0] for z in L]          # random -- since algorithm is random
[Number Field in b0 with defining polynomial x - 1,
 Number Field in b1 with defining polynomial x^2 - x + 1,
 Number Field in b2 with defining polynomial x^4 - 5*x^2 + 25,
 Number Field in b3 with defining polynomial x^4 - 2*x^2 + 4,
 Number Field in b4 with defining polynomial x^8 + 4*x^6 + 7*x^4 + 36*x^2 +
81]

We examine one of the optimized subfields in more detail:

sage: M, from_M, to_M = L[2]
sage: M                             # random
Number Field in b2 with defining polynomial x^4 - 5*x^2 + 25
sage: from_M     # may be slightly random
Ring morphism:
  From: Number Field in b2 with defining polynomial x^4 - 5*x^2 + 25
  To:   Number Field in a1 with defining polynomial x^8 + 40*x^6 + 352*x^4
+ 960*x^2 + 576
  Defn: b2 |--> -5/1152*a1^7 + 1/96*a1^6 - 97/576*a1^5 + 17/48*a1^4 -
95/72*a1^3 + 17/12*a1^2 - 53/24*a1 - 1

The to_M map is None, since there is no map from K to M:

sage: to_M

We apply the from_M map to the generator of M, which gives a rather large element of $ K$ :

sage: from_M(M.0)          # random
-5/1152*a1^7 + 1/96*a1^6 - 97/576*a1^5 + 17/48*a1^4 - 95/72*a1^3 +
17/12*a1^2 - 53/24*a1 - 1

Nevertheless, that large-ish element lies in a degree 4 subfield:

sage: from_M(M.0).minpoly()   # random
x^4 - 5*x^2 + 25

order( self)

Return the order with given ring generators in the maximal order of this number field.

Input:

gens
- list of elements of self; if no generators are given, just returns the cardinality of this number field (oo) for consistency.
check_is_integral
- bool (default: True), whether to check that each generator is integral.
check_rank
- bool (default: True), whether to check that the ring generated by gens is of full rank.
allow_subfield
- bool (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.

sage: k.<i> = NumberField(x^2 + 1)
sage: k.order(2*i)
Order in Number Field in i with defining polynomial x^2 + 1
sage: k.order(10*i)
Order in Number Field in i with defining polynomial x^2 + 1
sage: k.order(3)
Traceback (most recent call last):
...
ValueError: the rank of the span of gens is wrong
sage: k.order(i/2)
Traceback (most recent call last):
...
ValueError: each generator must be integral

Alternatively, an order can be constructed by adjoining elements to $ \mathbf{Z}$ :

places( self, [all_complex=False], [prec=None])

Return the collection of all places of self. By default, this returns the set of real places as homomorphisms into RIF first, followed by a choice of one of each pair of complex conjugate homomorphisms into CIF.

On the other hand, if prec is not None, we simply return places into RealField(prec) and ComplexField(prec) (or RDF, CDF if prec=53).

There is an optional flag all_complex, which defaults to False. If all_complex is True, then the real embeddings are returned as embeddings into CIF instead of RIF.

sage: F.<alpha> = NumberField(x^3-100*x+1) ; F.places()
[Ring morphism:
From: Number Field in alpha with defining polynomial x^3 - 100*x + 1
To:   Real Field with 106 bits of precision
Defn: alpha |--> -10.00499625499181184573367219280,
Ring morphism:
From: Number Field in alpha with defining polynomial x^3 - 100*x + 1
To:   Real Field with 106 bits of precision
Defn: alpha |--> 0.01000001000003000012000055000273,
Ring morphism:
From: Number Field in alpha with defining polynomial x^3 - 100*x + 1
To:   Real Field with 106 bits of precision
Defn: alpha |--> 9.994996244991781845613530439509]

sage: F.<alpha> = NumberField(x^3+7) ; F.places()
[Ring morphism:
From: Number Field in alpha with defining polynomial x^3 + 7
To:   Real Field with 106 bits of precision
Defn: alpha |--> -1.912931182772389101199116839549,
Ring morphism:
From: Number Field in alpha with defining polynomial x^3 + 7
To:   Complex Field with 53 bits of precision
Defn: alpha |--> 0.956465591386195 + 1.65664699997230*I]

sage: F.<alpha> = NumberField(x^3+7) ; F.places(all_complex=True)
[Ring morphism:
From: Number Field in alpha with defining polynomial x^3 + 7
To:   Complex Field with 53 bits of precision
Defn: alpha |--> -1.91293118277239,
Ring morphism:
From: Number Field in alpha with defining polynomial x^3 + 7
To:   Complex Field with 53 bits of precision
Defn: alpha |--> 0.956465591386195 + 1.65664699997230*I]
sage: F.places(prec=10)
[Ring morphism:
From: Number Field in alpha with defining polynomial x^3 + 7
To:   Real Field with 10 bits of precision
Defn: alpha |--> -1.9,
Ring morphism:
From: Number Field in alpha with defining polynomial x^3 + 7
To:   Complex Field with 10 bits of precision
Defn: alpha |--> 0.96 + 1.7*I]

real_places( self, [prec=None])

Return all real places of self as homomorphisms into RIF.

sage: F.<alpha> = NumberField(x^4-7) ; F.real_places()
[Ring morphism:
From: Number Field in alpha with defining polynomial x^4 - 7
To:   Real Field with 106 bits of precision
Defn: alpha |--> -1.626576561697785743211232345494,
Ring morphism:
From: Number Field in alpha with defining polynomial x^4 - 7
To:   Real Field with 106 bits of precision
Defn: alpha |--> 1.626576561697785743211232345494]

relativize( self, alpha, names)

Given an element alpha in self, return a relative number field $ K$ isomorphic to self that is relative over the absolute field $ \mathbf{Q}(\alpha)$ , along with isomorphisms from $ K$ to self and from self to K.

Input:

alpha
- an element of self.
names
- 2-tuple of names of generator for output field K and the subfield QQ(alpha) names[0] generators K and names[1] QQ(alpha).

Output:
K
- relative number field

Also, K.structure() returns from_K and to_K, where from_K is an isomorphism from K to self and to_K is an isomorphism from self to K.

sage: K.<a> = NumberField(x^10 - 2)
sage: L.<c,d> = K.relativize(a^4 + a^2 + 2); L
Number Field in c with defining polynomial x^2 - 1/5*d^4 + 8/5*d^3 -
23/5*d^2 + 7*d - 18/5 over its base field
sage: c.absolute_minpoly()
x^10 - 2
sage: d.absolute_minpoly()
x^5 - 10*x^4 + 40*x^3 - 90*x^2 + 110*x - 58
sage: (a^4 + a^2 + 2).minpoly()
x^5 - 10*x^4 + 40*x^3 - 90*x^2 + 110*x - 58
sage: from_L, to_L = L.structure()
sage: to_L(a)
c
sage: to_L(a^4 + a^2 + 2)
d
sage: from_L(to_L(a^4 + a^2 + 2))
a^4 + a^2 + 2

subfields( self, [degree=0], [name=None])

sage: K.<a> = NumberField( [x^3 - 2, x^2 + x + 1] );
sage: K = K.absolute_field('b')
sage: S = K.subfields()
sage: len(S)
6
sage: [k[0].polynomial() for k in S]
[x - 3,
 x^2 - 3*x + 9,
 x^3 - 3*x^2 + 3*x + 1,
 x^3 - 3*x^2 + 3*x + 1,
 x^3 - 3*x^2 + 3*x - 17,
 x^6 - 3*x^5 + 6*x^4 - 11*x^3 + 12*x^2 + 3*x + 1]

vector_space( self)

Return a vector space V and isomorphisms self -> V and V -> self.

Output:

V
- a vector space over the rational numbers
from_V
- an isomorphism from V to self
to_V
- an isomorphism from self to V

sage: k.<a> = NumberField(x^3 + 2)
sage: V, from_V, to_V  = k.vector_space()
sage: from_V(V([1,2,3]))
3*a^2 + 2*a + 1
sage: to_V(1 + 2*a + 3*a^2)
(1, 2, 3)
sage: V
Vector space of dimension 3 over Rational Field
sage: to_V
Isomorphism from Number Field in a with defining polynomial x^3 + 2 to
Vector space of dimension 3 over Rational Field
sage: from_V(to_V(2/3*a - 5/8))
2/3*a - 5/8
sage: to_V(from_V(V([0,-1/7,0])))
(0, -1/7, 0)

Special Functions: __init__,$ \,$ __reduce__,$ \,$ _subfields_helper

__reduce__( self)

TESTS:

sage: Z = var('Z')
sage: K.<w> = NumberField(Z^3 + Z + 1)
sage: L = loads(dumps(K))
sage: print L
Number Field in w with defining polynomial Z^3 + Z + 1
sage: print L == K
True

Class: NumberField_cyclotomic

class NumberField_cyclotomic
Create a cyclotomic extension of the rational field.

The command CyclotomicField(n) creates the n-th cyclotomic field, obtained by adjoining an n-th root of unity to the rational field.

sage: CyclotomicField(3)
Cyclotomic Field of order 3 and degree 2
sage: CyclotomicField(18)
Cyclotomic Field of order 18 and degree 6
sage: z = CyclotomicField(6).gen(); z
zeta6
sage: z^3
-1
sage: (1+z)^3
6*zeta6 - 3

sage: K = CyclotomicField(197)
sage: loads(K.dumps()) == K
True
sage: loads((z^2).dumps()) == z^2
True

sage: cf12 = CyclotomicField( 12 )
sage: z12 = cf12.0
sage: cf6 = CyclotomicField( 6 )
sage: z6 = cf6.0
sage: FF = Frac( cf12['x'] )
sage: x = FF.0
sage: print z6*x^3/(z6 + x)
zeta12^2*x^3/(x + zeta12^2)

sage: cf6 = CyclotomicField(6) ; z6 = cf6.gen(0)
sage: cf3 = CyclotomicField(3) ; z3 = cf3.gen(0)
sage: cf3(z6)
zeta3 + 1
sage: cf6(z3)
zeta6 - 1
sage: type(cf6(z3))
<type 'sage.rings.number_field.number_field_element_quadratic.NumberFieldEl
ement_quadratic'>
sage: cf1 = CyclotomicField(1) ; z1 = cf1.0
sage: cf3(z1)
1
sage: type(cf3(z1))
<type 'sage.rings.number_field.number_field_element_quadratic.NumberFieldEl
ement_quadratic'>
NumberField_cyclotomic( self, n, names)

A cyclomotic field, i.e., a field obtained by adjoining an n-th root of unity to the rational numbers.

sage: k = CyclotomicField(3)
sage: type(k)
<class 'sage.rings.number_field.number_field.NumberField_cyclotomic'>

Functions: complex_embedding,$ \,$ complex_embeddings,$ \,$ discriminant,$ \,$ integral_basis,$ \,$ is_galois,$ \,$ is_isomorphic,$ \,$ next_split_prime,$ \,$ number_of_roots_of_unity,$ \,$ real_embeddings,$ \,$ roots_of_unity,$ \,$ signature,$ \,$ zeta,$ \,$ zeta_order

complex_embedding( self, [prec=53])

Return the embedding of this cyclotomic field into the approximate complex field with precision prec obtained by sending the generator $ \zeta$ of self to exp(2*pi*i/n), where $ n$ is the multiplicative order of $ \zeta$ .

If prec is 53 (the default), then the complex double field is used; otherwise the arbitrary precision (but slow) complex field is used.

sage: C = CyclotomicField(4)
sage: C.complex_embedding()
Ring morphism:
  From: Cyclotomic Field of order 4 and degree 2
  To:   Complex Double Field
  Defn: zeta4 |--> 6.12323399574e-17 + 1.0*I

Note in the example above that the way zeta is computed (using sin and cosine in MPFR) means that only the prec bits of the number after the decimal point are valid.

sage: K = CyclotomicField(3)
sage: phi = K.complex_embedding(10)
sage: phi(K.0)
-0.50 + 0.87*I
sage: phi(K.0^3)
1.0
sage: phi(K.0^3 - 1)
0
sage: phi(K.0^3 + 7)
8.0

complex_embeddings( self, [prec=53])

Return all embeddings of this cyclotomic field into the approximate complex field with precision prec.

If prec is 53 (the default), then the complex double field is used; otherwise the arbitrary precision (but slow) complex field is used. If you want 53-bit arbitrary precision then do self.embeddings(ComplexField(53)).

sage: CyclotomicField(5).complex_embeddings()
[
Ring morphism:
  From: Cyclotomic Field of order 5 and degree 4
  To:   Complex Double Field
  Defn: zeta5 |--> 0.309016994375 + 0.951056516295*I,
Ring morphism:
  From: Cyclotomic Field of order 5 and degree 4
  To:   Complex Double Field
  Defn: zeta5 |--> -0.809016994375 + 0.587785252292*I,
Ring morphism:
  From: Cyclotomic Field of order 5 and degree 4
  To:   Complex Double Field
  Defn: zeta5 |--> -0.809016994375 - 0.587785252292*I,
Ring morphism:
  From: Cyclotomic Field of order 5 and degree 4
  To:   Complex Double Field
  Defn: zeta5 |--> 0.309016994375 - 0.951056516295*I
]

discriminant( self, [v=None])

Returns the discriminant of the ring of integers of the cyclotomic field self, or if v is specified, the determinant of the trace pairing on the elements of the list v.

Uses the formula for the discriminant of a prime power cyclotomic field and Hilbert Theorem 88 on the discriminant of composita.

Input:

v (optional)
- list of element of this number field
Output: Integer if v is omitted, and Rational otherwise.

sage: CyclotomicField(20).discriminant()
4000000
sage: CyclotomicField(18).discriminant()
-19683

integral_basis( self, [v=None])

Return a list of elements of this number field that are a basis for the full ring of integers.

This field is cyclomotic, so this is a trivial computation, since the power basis on the generator is an integral basis. Thus the v parameter is ignored.

sage: CyclotomicField(5).integral_basis()
[1, zeta5, zeta5^2, zeta5^3]

is_galois( self)

Return True since all cyclotomic fields are automatically Galois.

sage: CyclotomicField(29).is_galois()
True

is_isomorphic( self, other)

Return True if the cyclotomic field self is isomorphic as a number field to other.

sage: CyclotomicField(11).is_isomorphic(CyclotomicField(22))
True
sage: CyclotomicField(11).is_isomorphic(CyclotomicField(23))
False
sage: CyclotomicField(3).is_isomorphic(NumberField(x^2 + x +1, 'a'))
True

next_split_prime( self, [p=2])

Return the next prime integer $ p$ that splits completely in this cyclotomic field (and does not ramify).

sage: K.<z> = CyclotomicField(3)
sage: K.next_split_prime(7)
13

number_of_roots_of_unity( self)

Return number of roots of unity in this cyclotomic field.

sage: K.<a> = CyclotomicField(21)
sage: K.number_of_roots_of_unity()
42

real_embeddings( self, [prec=53])

Return all embeddings of this cyclotomic field into the approximate real field with precision prec.

If prec is 53 (the default), then the real double field is used; otherwise the arbitrary precision (but slow) real field is used.

Mostly, of course, there are no such embeddings.

sage: CyclotomicField(4).real_embeddings()
[]
sage: CyclotomicField(2).real_embeddings()
[
Ring morphism:
  From: Cyclotomic Field of order 2 and degree 1
  To:   Real Double Field
  Defn: -1 |--> -1.0
]

roots_of_unity( self)

Return all the roots of unity in this cyclotomic field, primitive or not.

sage: K.<a> = CyclotomicField(3)
sage: zs = K.roots_of_unity(); zs
[1, a, -a - 1, -1, -a, a + 1]
sage: [ z**K.number_of_roots_of_unity() for z in zs ]
[1, 1, 1, 1, 1, 1]

signature( self)

Return (r1, r2), where r1 and r2 are the number of real embeddings and pairs of complex embeddings of this cyclotomic field, respectively.

Trivial since, apart from QQ, cyclotomic fields are totally complex.

sage: CyclotomicField(5).signature()
(0, 2)
sage: CyclotomicField(2).signature()
(1, 0)

zeta( self, [n=None], [all=False])

Returns an element of multiplicative order $ n$ in this this cyclotomic field, if there is one. Raises a ValueError if there is not.

Input:

n
- integer (default: None, returns element of maximal order)
all
- bool (default: False) - whether to return a list of all n-th roots.

Output: root of unity or list

sage: k = CyclotomicField(7)
sage: k.zeta()
zeta7
sage: k.zeta().multiplicative_order()
7
sage: k = CyclotomicField(49)
sage: k.zeta().multiplicative_order()
49
sage: k.zeta(7).multiplicative_order()
7
sage: k.zeta()
zeta49
sage: k.zeta(7)
zeta49^7

sage: K.<a> = CyclotomicField(7)
sage: K.zeta(14, all=True)
[-a^4, -a^5, a^5 + a^4 + a^3 + a^2 + a + 1, -a, -a^2, -a^3]
sage: K.<a> = CyclotomicField(10)
sage: K.zeta(20, all=True)
Traceback (most recent call last):
...
ValueError: n (=20) does not divide order of generator

sage: K.<a> = CyclotomicField(5)
sage: K.zeta(4)
Traceback (most recent call last):
...
ValueError: n (=4) does not divide order of generator
sage: v = K.zeta(5, all=True); v
[a, a^2, a^3, -a^3 - a^2 - a - 1]
sage: [b^5 for b in v]
[1, 1, 1, 1]

zeta_order( self)

Return the order of the maximal root of unity contained in this cyclotomic field.

sage: CyclotomicField(1).zeta_order()
2
sage: CyclotomicField(4).zeta_order()
4
sage: CyclotomicField(5).zeta_order()
10
sage: CyclotomicField(5)._n()
5
sage: CyclotomicField(389).zeta_order()
778

Special Functions: __call__,$ \,$ __init__,$ \,$ __reduce__,$ \,$ _coerce_from_gap,$ \,$ _coerce_from_other_cyclotomic_field,$ \,$ _coerce_impl,$ \,$ _Hom_,$ \,$ _latex_,$ \,$ _magma_init_,$ \,$ _multiplicative_order_table,$ \,$ _n,$ \,$ _repr_

__call__( self, x)

Create an element of this cyclotomic field from $ x$ .

The following example illustrates coercion from the cyclotomic field Q(zeta_42) to the cyclotomic field Q(zeta_6), in a case where such coercion is defined:

sage: k42 = CyclotomicField(42)
sage: k6 = CyclotomicField(6)
sage: a = k42.gen(0)
sage: b = a^7
sage: b
zeta42^7
sage: k6(b)
zeta6
sage: b^2
zeta42^7 - 1
sage: k6(b^2)
zeta6 - 1

Coercion of GAP cyclotomic elements is also supported.

sage: K.<z> = CyclotomicField(7)
sage: O = K.maximal_order()
sage: K(O.1)
z
sage: K(O.1^2 + O.1 - 2)
z^2 + z - 2

__reduce__( self)

TESTS:

sage: K.<zeta7> = CyclotomicField(7)
sage: L = loads(dumps(K))
sage: print L
Cyclotomic Field of order 7 and degree 6
sage: print L == K
True

_coerce_from_gap( self, x)

Attempt to coerce a GAP number field element into this cyclotomic field.

sage: k5.<z> = CyclotomicField(5)
sage: gap('E(5)^7 + 3')
-3*E(5)-2*E(5)^2-3*E(5)^3-3*E(5)^4
sage: w = gap('E(5)^7 + 3')
sage: z^7 + 3
z^2 + 3
sage: k5(w)
z^2 + 3

_coerce_from_other_cyclotomic_field( self, x, [only_canonical=False])

Coerce an element x of a cyclotomic field into self, if at all possible.

Input:

x
- number field element
only_canonical
- bool (default: False); Attempt to work, even in some cases when x is not in a subfield of the cyclotomics (as long as x is a root of unity).

sage: K = CyclotomicField(24) ; L = CyclotomicField(48)
sage: L._coerce_from_other_cyclotomic_field(K.0+1)
zeta48^2 + 1
sage: K(L.0**2)
zeta24

_coerce_impl( self, x)

Canonical implicit coercion of x into self.

Elements of other compatible cyclotomic fields coerce in, as do elements of the rings that coerce to all number fields (e.g., integers, rationals).

sage: CyclotomicField(15)._coerce_impl(CyclotomicField(5).0 - 17/3)
zeta15^3 - 17/3
sage: K.<a> = CyclotomicField(16)
sage: K(CyclotomicField(4).0)
a^4

_Hom_( self, codomain, [cat=None])

Return homset of homomorphisms from the cyclotomic field self to the number field codomain.

The cat option is currently ignored.

This function is implicitly caled by the Hom method or function.

sage: K.<a> = NumberField(x^2 + 3); K
Number Field in a with defining polynomial x^2 + 3
sage: CyclotomicField(3).Hom(K)
Set of field embeddings from Cyclotomic Field of order 3 and degree 2 to
Number Field in a with defining polynomial x^2 + 3
sage: End(CyclotomicField(21))
Automorphism group of Cyclotomic Field of order 21 and degree 12

_latex_( self)

Return the latex representation of this cyclotomic field.

sage: Z = CyclotomicField(4)
sage: Z.gen()
zeta4
sage: latex(Z)
\mathbf{Q}(\zeta_{4})

Latex printing respects the generator name.

sage: k.<a> = CyclotomicField(4)
sage: latex(k)
\mathbf{Q}[a]/(a^{2} + 1)
sage: k
Cyclotomic Field of order 4 and degree 2
sage: k.gen()
a

_multiplicative_order_table( self)

Return a dictionary that maps powers of zeta to their order. This makes computing the orders of the elements of finite order in this field faster.

sage: v = CyclotomicField(6)._multiplicative_order_table()
sage: w = v.items(); w.sort(); w
[(-1, 2), (1, 1), (-x, 3), (-x + 1, 6), (x - 1, 3), (x, 6)]

_n( self)

Return the n used to create this cyclotomic field.

sage: CyclotomicField(3).zeta_order()
6
sage: CyclotomicField(3)._n()
3

_repr_( self)

Return string representation of this cyclotomic field.

The ``order'' of the cyclotomic field $ \mathbf{Q}(\zeta_n)$ in the string output refers to the order of the $ \zeta_n$ , i.e., it is the integer $ n$ . The degree is the degree of the field as an extension of $ \mathbf{Q}$ .

sage: CyclotomicField(4)._repr_()
'Cyclotomic Field of order 4 and degree 2'
sage: CyclotomicField(400)._repr_()
'Cyclotomic Field of order 400 and degree 160'

Class: NumberField_generic

class NumberField_generic

sage: K.<a> = NumberField(x^3 - 2); K
Number Field in a with defining polynomial x^3 - 2
sage: loads(K.dumps()) == K
True
NumberField_generic( self, polynomial, name, [latex_name=None], [check=True])

Create a number field.

sage: NumberField(x^97 - 19, 'a')
Number Field in a with defining polynomial x^97 - 19

If you use check=False, you avoid checking irreducibility of the defining polynomial, which can save time.

sage: K.<a> = NumberField(x^2 - 1, check=False)

It can also be dangerous:

sage: (a-1)*(a+1)
0

Functions: absolute_degree,$ \,$ absolute_field,$ \,$ category,$ \,$ change_generator,$ \,$ characteristic,$ \,$ class_group,$ \,$ class_number,$ \,$ complex_embeddings,$ \,$ composite_fields,$ \,$ defining_polynomial,$ \,$ degree,$ \,$ different,$ \,$ disc,$ \,$ discriminant,$ \,$ elements_of_norm,$ \,$ extension,$ \,$ factor,$ \,$ fractional_ideal,$ \,$ galois_group,$ \,$ gen,$ \,$ ideal,$ \,$ ideals_of_bdd_norm,$ \,$ integral_basis,$ \,$ integral_elements_with_trace,$ \,$ is_absolute,$ \,$ is_field,$ \,$ is_galois,$ \,$ is_isomorphic,$ \,$ is_relative,$ \,$ is_totally_imaginary,$ \,$ is_totally_real,$ \,$ latex_variable_name,$ \,$ narrow_class_group,$ \,$ ngens,$ \,$ number_of_roots_of_unity,$ \,$ order,$ \,$ pari_bnf,$ \,$ pari_bnf_certify,$ \,$ pari_nf,$ \,$ pari_polynomial,$ \,$ polynomial,$ \,$ polynomial_ntl,$ \,$ polynomial_quotient_ring,$ \,$ polynomial_ring,$ \,$ prime_above,$ \,$ primes_above,$ \,$ primes_of_degree_one_iter,$ \,$ primes_of_degree_one_list,$ \,$ primitive_element,$ \,$ real_embeddings,$ \,$ reduced_basis,$ \,$ reduced_gram_matrix,$ \,$ regulator,$ \,$ residue_field,$ \,$ roots_of_unity,$ \,$ signature,$ \,$ structure,$ \,$ subfield,$ \,$ trace_pairing,$ \,$ uniformizer,$ \,$ units,$ \,$ zeta,$ \,$ zeta_coefficients,$ \,$ zeta_function,$ \,$ zeta_order

absolute_degree( self)

Return the degree of self over $ \mathbf{Q}$ .

sage: NumberField(x^3 + x^2 + 997*x + 1, 'a').absolute_degree()
3
sage: NumberField(x + 1, 'a').absolute_degree()
1
sage: NumberField(x^997 + 17*x + 3, 'a', check=False).absolute_degree()
997

absolute_field( self, names)

Returns self as an absolute extension over QQ.

Output:

K
- this number field (since it is already absolute)

Also, K.structure() returns from_K and to_K, where from_K is an isomorphism from K to self and to_K is an isomorphism from self to K.

sage: K = CyclotomicField(5)
sage: K.absolute_field('a')
Number Field in a with defining polynomial x^4 + x^3 + x^2 + x + 1

category( self)

Return the category of number fields.

sage: NumberField(x^2 + 3, 'a').category()
Category of number fields
sage: category(NumberField(x^2 + 3, 'a'))
Category of number fields

The special types of number fields, e.g., quadratic fields, don't have their own category:

sage: QuadraticField(2,'d').category()
Category of number fields

change_generator( self, alpha, [name=None])

Given the number field self, construct another isomorphic number field $ K$ generated by the element alpha of self, along with isomorphisms from $ K$ to self and from self to $ K$ .

sage: K.<i> = NumberField(x^2 + 1); K
Number Field in i with defining polynomial x^2 + 1
sage: L.<i> = NumberField(x^2 + 1); L
Number Field in i with defining polynomial x^2 + 1
sage: K, from_K, to_K = L.change_generator(i/2 + 3)
sage: K
Number Field in i0 with defining polynomial x^2 - 6*x + 37/4
sage: from_K
Ring morphism:
  From: Number Field in i0 with defining polynomial x^2 - 6*x + 37/4
  To:   Number Field in i with defining polynomial x^2 + 1
  Defn: i0 |--> 1/2*i + 3
sage: to_K
Ring morphism:
  From: Number Field in i with defining polynomial x^2 + 1
  To:   Number Field in i0 with defining polynomial x^2 - 6*x + 37/4
  Defn: i |--> 2*i0 - 6

We compute the image of the generator $ \sqrt{-1}$ of $ L$ .

sage: to_K(L.0)
2*i0 - 6

Note that he image is indeed a square root of -1.

sage: to_K(L.0)^2
-1
sage: from_K(to_K(L.0))
i
sage: to_K(from_K(K.0))
i0

characteristic( self)

Return the characteristic of this number field, which is of course 0.

sage: k.<a> = NumberField(x^99 + 2); k
Number Field in a with defining polynomial x^99 + 2
sage: k.characteristic()
0

class_group( self, [proof=None], [names=c])

Return the class group of the ring of integers of this number field.

Input:

proof
- if True then compute the classgroup provably correctly. Default is True. Call number_field_proof to change this default globally.
names
- names of the generators of this class group.

Output: The class group of this number field.

sage: K.<a> = NumberField(x^2 + 23)
sage: G = K.class_group(); G
Class group of order 3 with structure C3 of Number Field in a with defining
polynomial x^2 + 23
sage: G.0
Fractional ideal class (2, 1/2*a - 1/2)
sage: G.gens()
[Fractional ideal class (2, 1/2*a - 1/2)]

sage: G.number_field()
Number Field in a with defining polynomial x^2 + 23
sage: G is K.class_group()
True
sage: G is K.class_group(proof=False)
False
sage: G.gens()
[Fractional ideal class (2, 1/2*a - 1/2)]

There can be multiple generators:

sage: k.<a> = NumberField(x^2 + 20072)
sage: G = k.class_group(); G
Class group of order 76 with structure C38 x C2 of Number Field in a with
defining polynomial x^2 + 20072
sage: G.gens()
[Fractional ideal class (41, a + 10), Fractional ideal class (2, -1/2*a)]
sage: G.0
Fractional ideal class (41, a + 10)
sage: G.0^20
Fractional ideal class (43, a + 3)
sage: G.0^38
Trivial principal fractional ideal class
sage: G.1
Fractional ideal class (2, -1/2*a)
sage: G.1^2
Trivial principal fractional ideal class

Class groups of Hecke polynomials tend to be very small:

sage: f = ModularForms(97, 2).T(2).charpoly()
sage: f.factor()
(x - 3) * (x^3 + 4*x^2 + 3*x - 1) * (x^4 - 3*x^3 - x^2 + 6*x - 1)
sage: for g,_ in f.factor(): print NumberField(g,'a').class_group().order()
...
1
1
1

class_number( self, [proof=None])

Return the class number of this number field, as an integer.

Input:

proof
- bool (default: True unless you called number_field_proof)

sage: NumberField(x^2 + 23, 'a').class_number()
3
sage: NumberField(x^2 + 163, 'a').class_number()
1
sage: NumberField(x^3 + x^2 + 997*x + 1, 'a').class_number(proof=False)
1539

complex_embeddings( self, [prec=53])

Return all homomorphisms of this number field into the approximate complex field with precision prec.

If prec is 53 (the default), then the complex double field is used; otherwise the arbitrary precision (but slow) complex field is used. If you want 53-bit arbitrary precision then do self.embeddings(ComplexField(53)).

sage: k.<a> = NumberField(x^5 + x + 17)
sage: v = k.complex_embeddings()
sage: [phi(k.0^2) for phi in v] # random low order bits
[2.97572074038 + 1.73496602657e-16*I,
 -2.40889943716 + 1.90254105304*I,
 -2.40889943716 - 1.90254105304*I,
 0.921039066973 + 3.07553311885*I,
 0.921039066973 - 3.07553311885*I]
sage: K.<a> = NumberField(x^3 + 2)
sage: K.complex_embeddings() # random low order bits
[
Ring morphism:
  From: Number Field in a with defining polynomial x^3 + 2
  To:   Complex Double Field
  Defn: a |--> -1.25992104989 - 3.88578058619e-16*I,
Ring morphism:
  From: Number Field in a with defining polynomial x^3 + 2
  To:   Complex Double Field
  Defn: a |--> 0.629960524947 - 1.09112363597*I,
Ring morphism:
  From: Number Field in a with defining polynomial x^3 + 2
  To:   Complex Double Field
  Defn: a |--> 0.629960524947 + 1.09112363597*I
]

composite_fields( self, other, [names=None])

List of all possible composite number fields formed from self and other.

Input:

other
- a number field
names
- generator name for composite fields

Output:
list
- list of the composite fields.

sage: K.<a> = NumberField(x^4 - 2)
sage: K.composite_fields(K)
[Number Field in a0 with defining polynomial x^4 - 162,
 Number Field in a1 with defining polynomial x^4 - 2,
 Number Field in a2 with defining polynomial x^8 + 28*x^4 + 2500]
sage: k.<a> = NumberField(x^3 + 2)
sage: m.<b> = NumberField(x^3 + 2)
sage: k.composite_fields(m, 'c')
[Number Field in c0 with defining polynomial x^3 - 2,
 Number Field in c1 with defining polynomial x^6 - 40*x^3 + 1372]

defining_polynomial( self)

Return the defining polynomial of this number field.

This is exactly the same as self.polynomal().

sage: k5.<z> = CyclotomicField(5)
sage: k5.defining_polynomial()
x^4 + x^3 + x^2 + x + 1
sage: y = polygen(QQ,'y')
sage: k.<a> = NumberField(y^9 - 3*y + 5); k
Number Field in a with defining polynomial y^9 - 3*y + 5
sage: k.defining_polynomial()
y^9 - 3*y + 5

degree( self)

Return the degree of this number field.

sage: NumberField(x^3 + x^2 + 997*x + 1, 'a').degree()
3
sage: NumberField(x + 1, 'a').degree()
1
sage: NumberField(x^997 + 17*x + 3, 'a', check=False).degree()
997

different( self)

Compute the different fractional ideal of this number field.

The different is the set of all $ x$ in $ K$ such that the trace of $ xy$ is an integer for all $ y \in O_K$ .

sage: k.<a> = NumberField(x^2 + 23)
sage: d = k.different()
sage: d        # random sign in output
Fractional ideal (-a)
sage: d.norm()
23
sage: k.disc()
-23

The different is cached:

sage: d is k.different()
True

Another example:

sage: k.<b> = NumberField(x^2 - 123)
sage: d = k.different(); d
Fractional ideal (2*b)
sage: d.norm()
492
sage: k.disc()
492

disc( self, [v=None])

Shortcut for self.discriminant.

sage: k.<b> = NumberField(x^2 - 123)
sage: k.disc()
492

discriminant( self, [v=None])

Returns the discriminant of the ring of integers of the number field, or if v is specified, the determinant of the trace pairing on the elements of the list v.

Input:

v (optional)
- list of element of this number field
Output: Integer if v is omitted, and Rational otherwise.

sage: K.<t> = NumberField(x^3 + x^2 - 2*x + 8)
sage: K.disc()
-503
sage: K.disc([1, t, t^2])
-2012
sage: K.disc([1/7, (1/5)*t, (1/3)*t^2])
-2012/11025
sage: (5*7*3)^2
11025

elements_of_norm( self, n, [proof=None])

Return a list of solutions modulo units of positive norm to $ Norm(a) = n$ , where a can be any integer in this number field.

Input:

proof
- default: True, unless you called number_field_proof and set it otherwise.

sage: K.<a> = NumberField(x^2+1)
sage: K.elements_of_norm(3)
[]
sage: K.elements_of_norm(50)
[7*a - 1, -5*a + 5, a - 7]           # 32-bit
[7*a - 1, -5*a + 5, -7*a - 1]        # 64-bit

extension( self, poly, [name=None], [names=None], [check=True])

Return the relative extension of this field by a given polynomial.

sage: K.<a> = NumberField(x^3 - 2)
sage: R.<t> = K[]
sage: L.<b> = K.extension(t^2 + a); L
Number Field in b with defining polynomial t^2 + a over its base field

We create another extension.

sage: k.<a> = NumberField(x^2 + 1); k
Number Field in a with defining polynomial x^2 + 1
sage: y = var('y')
sage: m.<b> = k.extension(y^2 + 2); m
Number Field in b with defining polynomial y^2 + 2 over its base field

Note that b is a root of $ y^2 + 2$ :

sage: b.minpoly()
x^2 + 2
sage: b.minpoly('z')
z^2 + 2

A relative extension of a relative extension.

sage: k.<a> = NumberField([x^2 + 1, x^3 + x + 1])
sage: R.<z> = k[]
sage: L.<b> = NumberField(z^3 + 3 + a); L
Number Field in b with defining polynomial z^3 + a0 + 3 over its base field

factor( self, n)

Ideal factorization of the principal ideal of the ring of integers generated by $ n$ .

Here we show how to factor gaussian integers. First we form a number field defined by $ x^2 + 1$ :

sage: K.<I> = NumberField(x^2 + 1); K
Number Field in I with defining polynomial x^2 + 1

Here are the factors:

sage: fi, fj = K.factor(13); fi,fj
((Fractional ideal (-3*I - 2), 1), (Fractional ideal (3*I - 2), 1))

Now we extract the reduced form of the generators:

sage: zi = fi[0].gens_reduced()[0]; zi
-3*I - 2
sage: zj = fj[0].gens_reduced()[0]; zj
3*I - 2

We recover the integer that was factored in $ \mathbf{Z}[i]$

sage: zi*zj
13

One can also factor elements of the number field:

sage: K.<a> = NumberField(x^2 + 1)
sage: K.factor(1/3)
Fractional ideal (3)^-1
sage: K.factor(1+a)
Fractional ideal (a + 1)
sage: K.factor(1+a/5)
(Fractional ideal (-3*a - 2)) * (Fractional ideal (a + 1)) * (Fractional
ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1

Author: Alex Clemesha (2006-05-20): examples

fractional_ideal( self)

Return the ideal in $ \mathcal{O}_K$ generated by gens. This overrides the sage.rings.ring.Field method to use the sage.rings.ring.Ring one instead, since we're not really concerned with ideals in a field but in its ring of integers.

Input:

gens
- a list of generators, or a number field ideal.

sage: K.<a> = NumberField(x^3-2)
sage: K.fractional_ideal([1/a])
Fractional ideal (1/2*a^2)

One can also input in a number field ideal itself.

sage: K.fractional_ideal(K.ideal(a))
Fractional ideal (a)

The zero ideal is not a fractional ideal!

sage: K.fractional_ideal(0)
Traceback (most recent call last):
...
ValueError: gens must have a nonzero element (zero ideal is not a
fractional ideal)

galois_group( self, [pari_group=True], [use_kash=False])

Return the Galois group of the Galois closure of this number field as an abstract group.

For more (important!) documentation, so the documentation for Galois groups of polynomials over $ \mathbf{Q}$ , e.g., by typing K.polynomial().galois_group?, where $ K$ is a number field.

To obtain actual field automorphisms that can be applied to elements, use End(K).list() and K.galois_closure() together (see example below).

sage: k.<b> = NumberField(x^2 - 14)
sage: k.galois_group ()
Galois group PARI group [2, -1, 1, "S2"] of degree 2 of the Number Field in
b with defining polynomial x^2 - 14

sage: NumberField(x^3-2, 'a').galois_group(pari_group=True)
Galois group PARI group [6, -1, 2, "S3"] of degree 3 of the Number Field in
a with defining polynomial x^3 - 2

sage: NumberField(x-1, 'a').galois_group(pari_group=False)    # optional database_gap package
Galois group Transitive group number 1 of degree 1 of the Number Field in a
with defining polynomial x - 1
sage: NumberField(x^2+2, 'a').galois_group(pari_group=False)  # optional database_gap package
Galois group Transitive group number 1 of degree 2 of the Number Field in a
with defining polynomial x^2 + 2
sage: NumberField(x^3-2, 'a').galois_group(pari_group=False)  # optional database_gap package
Galois group Transitive group number 2 of degree 3 of the Number Field in a
with defining polynomial x^3 - 2

EXPLICIT GALOIS GROUP: We compute the Galois group as an explicit group of automorphisms of the Galois closure of a field.

sage: K.<a> = NumberField(x^3 - 2)
sage: L.<b1> = K.galois_closure(); L
Number Field in b1 with defining polynomial x^6 + 40*x^3 + 1372
sage: G = End(L); G
Automorphism group of Number Field in b1 with defining polynomial x^6 +
40*x^3 + 1372
sage: G.list()
[
Ring endomorphism of Number Field in b1 with defining polynomial x^6 +
40*x^3 + 1372
  Defn: b1 |--> b1,
...
Ring endomorphism of Number Field in b1 with defining polynomial x^6 +
40*x^3 + 1372
  Defn: b1 |--> -2/63*b1^4 - 31/63*b1
]
sage: G[1](b1)
1/36*b1^4 + 1/18*b1

gen( self, [n=0])

Return the generator for this number field.

Input:

n
- must be 0 (the default), or an exception is raised.

sage: k.<theta> = NumberField(x^14 + 2); k
Number Field in theta with defining polynomial x^14 + 2
sage: k.gen()
theta
sage: k.gen(1)
Traceback (most recent call last):
...
IndexError: Only one generator.

ideal( self)

K.ideal() returns a fractional ideal of the field, except for the zero ideal which is not a fractional ideal.

sage: K.<i>=NumberField(x^2+1)
sage: K.ideal(2)
Fractional ideal (2)
sage: K.ideal(2+i)
Fractional ideal (i + 2)
sage: K.ideal(0)
Ideal (0) of Number Field in i with defining polynomial x^2 + 1

ideals_of_bdd_norm( self, bound)

All integral ideals of bounded norm.

Input:

bound
- a positive integer

Output: A dict of all integral ideals I such that Norm(I) <= bound, keyed by norm.

sage: K.<a> = NumberField(x^2 + 23)
sage: d = K.ideals_of_bdd_norm(10)
sage: for n in d:
...       print n
...       for I in d[n]:
...           print I
1
Fractional ideal (1)
2
Fractional ideal (2, 1/2*a - 1/2)
Fractional ideal (2, 1/2*a + 1/2)
3
Fractional ideal (3, -1/2*a + 1/2)
Fractional ideal (3, -1/2*a - 1/2)
4
Fractional ideal (4, 1/2*a + 3/2)
Fractional ideal (2)
Fractional ideal (4, 1/2*a + 5/2)
5
6
Fractional ideal (-1/2*a + 1/2)
Fractional ideal (6, 1/2*a + 5/2)
Fractional ideal (6, 1/2*a + 7/2)
Fractional ideal (1/2*a + 1/2)
7
8
Fractional ideal (-1/2*a - 3/2)
Fractional ideal (4, a - 1)
Fractional ideal (4, a + 1)
Fractional ideal (1/2*a - 3/2)
9
Fractional ideal (9, 1/2*a + 11/2)
Fractional ideal (3)
Fractional ideal (9, 1/2*a + 7/2)
10

integral_basis( self, [v=None])

Return a list of elements of this number field that are a basis for the full ring of integers.

Input:

v
- None, a prime, or a list of primes. See the documentation for self.maximal_order.

sage: K.<a> = NumberField(x^5 + 10*x + 1)
sage: K.integral_basis()
[1, a, a^2, a^3, a^4]

Next we compute the ring of integers of a cubic field in which 2 is an "essential discriminant divisor", so the ring of integers is not generated by a single element.

sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
sage: K.integral_basis()
[1, a, 1/2*a^2 + 1/2*a]

integral_elements_with_trace( self, C)

Find all integral elements in self with trace in the interval C.

NOTE: This is currently only implemented in the case that self is totally real, since it requires exact computation of self.reduced_gram_matrix().

sage: K.<alpha> = NumberField(ZZ['x'].0^2-2)
sage: K.integral_elements_with_trace([0,5])
[alpha + 2, 2, 1]
sage: L.<beta> = NumberField(ZZ['x'].0^2+1)
sage: L.integral_elements_with_trace([5,11])
Traceback (most recent call last):
...
NotImplementedError: exact computation of LLL reduction only implemented in
the totally real case

is_field( self)

Return True since a number field is a field.

sage: NumberField(x^5 + x + 3, 'c').is_field()
True

is_galois( self)

Return True if this number field is a Galois extension of $ \mathbf{Q}$ .

sage: NumberField(x^2 + 1, 'i').is_galois()
True
sage: NumberField(x^3 + 2, 'a').is_galois()
False

is_isomorphic( self, other)

Return True if self is isomorphic as a number field to other.

sage: k.<a> = NumberField(x^2 + 1)
sage: m.<b> = NumberField(x^2 + 4)
sage: k.is_isomorphic(m)
True
sage: m.<b> = NumberField(x^2 + 5)
sage: k.is_isomorphic (m)
False

sage: k = NumberField(x^3 + 2, 'a')
sage: k.is_isomorphic(NumberField((x+1/3)^3 + 2, 'b'))
True
sage: k.is_isomorphic(NumberField(x^3 + 4, 'b'))
True
sage: k.is_isomorphic(NumberField(x^3 + 5, 'b'))
False

is_relative( self)

sage: K.<a> = NumberField(x^10 - 2)
sage: K.is_absolute()
True
sage: K.is_relative()
False

is_totally_imaginary( self)

Return True if self is totally imaginary, and False otherwise.

Totally imaginary means that no isomorphic embedding of self into the complex numbers has image contained in the real numbers.

sage: NumberField(x^2+2, 'alpha').is_totally_imaginary()
True
sage: NumberField(x^2-2, 'alpha').is_totally_imaginary()
False
sage: NumberField(x^4-2, 'alpha').is_totally_imaginary()
False

is_totally_real( self)

Return True if self is totally real, and False otherwise.

Totally real means that every isomorphic embedding of self into the complex numbers has image contained in the real numbers.

sage: NumberField(x^2+2, 'alpha').is_totally_real()
False
sage: NumberField(x^2-2, 'alpha').is_totally_real()
True
sage: NumberField(x^4-2, 'alpha').is_totally_real()
False

latex_variable_name( self, [name=None])

Return the latex representation of the variable name for this number field.

sage: NumberField(x^2 + 3, 'a').latex_variable_name()
'a'
sage: NumberField(x^3 + 3, 'theta3').latex_variable_name()
'\theta_{3}'
sage: CyclotomicField(5).latex_variable_name()
'\zeta_{5}'

narrow_class_group( self, [proof=None])

Return the narrow class group of this field.

Input:

proof
- default: None (use the global proof setting, which defaults to True).

sage: NumberField(x^3+x+9, 'a').narrow_class_group()
Multiplicative Abelian Group isomorphic to C2

ngens( self)

Return the number of generators of this number field (always 1).

Output: the python integer 1.

sage: NumberField(x^2 + 17,'a').ngens()
1
sage: NumberField(x + 3,'a').ngens()
1
sage: k.<a> = NumberField(x + 3)
sage: k.ngens()
1
sage: k.0
-3

number_of_roots_of_unity( self)

Return number of roots of unity in this field.

sage: K.<b> = NumberField(x^2+1)
sage: K.number_of_roots_of_unity()
4

order( self)

Return the order of this number field (always +infinity).

Output: always positive infinity

sage: NumberField(x^2 + 19,'a').order()
+Infinity

pari_bnf( self, [certify=False], [units=True])

PARI big number field corresponding to this field.

sage: k.<a> = NumberField(x^2 + 1); k
Number Field in a with defining polynomial x^2 + 1
sage: len(k.pari_bnf())
10
sage: k.pari_bnf()[:4]
[[;], matrix(0,7), [;], ...]
sage: len(k.pari_nf())
9

pari_bnf_certify( self)

Run the PARI bnfcertify function to ensure the correctness of answers.

If this function returns True (and doesn't raise a ValueError), then certification succeeded, and results that use the PARI bnf structure with this field are supposed to be correct.

WARNING: I wouldn't trust this to mean that everything computed involving this number field is actually correct.

sage: k.<a> = NumberField(x^7 + 7); k
Number Field in a with defining polynomial x^7 + 7
sage: k.pari_bnf_certify()
True

pari_nf( self)

PARI number field corresponding to this field.

This is the number field constructed using nfinit. This is the same as the number field got by doing pari(self) or gp(self).

sage: k.<a> = NumberField(x^4 - 3*x + 7); k
Number Field in a with defining polynomial x^4 - 3*x + 7
sage: k.pari_nf()[:4]
[x^4 - 3*x + 7, [0, 2], 85621, 1]
sage: pari(k)[:4]
[x^4 - 3*x + 7, [0, 2], 85621, 1]

sage: k.<a> = NumberField(x^4 - 3/2*x + 5/3); k
Number Field in a with defining polynomial x^4 - 3/2*x + 5/3
sage: k.pari_nf()
Traceback (most recent call last):
...
TypeError: Unable to coerce number field defined by non-integral polynomial
to PARI.
sage: pari(k)
Traceback (most recent call last):
...
TypeError: Unable to coerce number field defined by non-integral polynomial
to PARI.
sage: gp(k)
Traceback (most recent call last):
...
TypeError: Unable to coerce number field defined by non-integral polynomial
to PARI.

pari_polynomial( self, [name=x])

PARI polynomial corresponding to polynomial that defines this field. By default, this is a polynomial in the variable "x".

sage: y = polygen(QQ)
sage: k.<a> = NumberField(y^2 - 3/2*y + 5/3)
sage: k.pari_polynomial()
x^2 - 3/2*x + 5/3
sage: k.pari_polynomial('a')
a^2 - 3/2*a + 5/3

polynomial( self)

Return the defining polynomial of this number field.

This is exactly the same as self.defining_polynomal().

sage: NumberField(x^2 + (2/3)*x - 9/17,'a').polynomial()
x^2 + 2/3*x - 9/17

polynomial_ntl( self)

Return defining polynomial of this number field as a pair, an ntl polynomial and a denominator.

This is used mainly to implement some internal arithmetic.

sage: NumberField(x^2 + (2/3)*x - 9/17,'a').polynomial_ntl()
([-27 34 51], 51)

polynomial_quotient_ring( self)

Return the polynomial quotient ring isomorphic to this number field.

sage: K = NumberField(x^3 + 2*x - 5, 'alpha')
sage: K.polynomial_quotient_ring()
Univariate Quotient Polynomial Ring in alpha over Rational Field with
modulus x^3 + 2*x - 5

polynomial_ring( self)

Return the polynomial ring that we view this number field as being a quotient of (by a principal ideal).

An example with an absolute field:

sage: k.<a> = NumberField(x^2 + 3)
sage: y = polygen(QQ, 'y')
sage: k.<a> = NumberField(y^2 + 3)
sage: k.polynomial_ring()
Univariate Polynomial Ring in y over Rational Field

An example with a relative field:

sage: y = polygen(QQ, 'y')
sage: M.<a> = NumberField([y^3 + 97, y^2 + 1]); M
Number Field in a0 with defining polynomial y^3 + 97 over its base field
sage: M.polynomial_ring()
Univariate Polynomial Ring in y over Number Field in a1 with defining
polynomial y^2 + 1

prime_above( self, x, [degree=None])

Return a prime ideal of self lying over x.

Input:

- x: usually an element or ideal of self. It should be such that self.ideal(x) is sensible. This excludes x=0.
- degree (default: None): None or an integer. If one, find a prime above x of any degree. If an integer, find a prime above x such that the resulting residue field has exactly this degree.

Output: A prime ideal of self lying over x. If degree is specified and no such ideal exists, raises a ValueError.

WARNING: at this time we factor the ideal x, which may not be supported for relative number fields.

sage: x = ZZ['x'].gen()
sage: F.<t> = NumberField(x^3 - 2)

sage: P2 = F.prime_above(2)
sage: P2 # random
Fractional ideal (-t)
sage: 2 in P2
True
sage: P2.is_prime()
True
sage: P2.norm()
2

sage: P3 = F.prime_above(3)
sage: P3 # random
Fractional ideal (t + 1)
sage: 3 in P3
True
sage: P3.is_prime()
True
sage: P3.norm()
3

The ideal (3) is totally ramified in F, so there is no degree 2 prime above 3:

sage: F.prime_above(3, degree=2)
Traceback (most recent call last):
...
ValueError: No prime of degree 2 above Fractional ideal (3)
sage: [ id.residue_class_degree() for id, _ in F.ideal(3).factor() ]
[1]

Asking for a specific degree works:

sage: P5_1 = F.prime_above(5, degree=1)
sage: P5_1 # random
Fractional ideal (-t^2 - 1)
sage: P5_1.residue_class_degree()
1

sage: P5_2 = F.prime_above(5, degree=2)
sage: P5_2 # random
Fractional ideal (t^2 - 2*t - 1)
sage: P5_2.residue_class_degree()
2

TESTS: It doesn't make sense to factor the ideal (0):

sage: F.prime_above(0)
Traceback (most recent call last):
...
AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'

Sage can't factor ideals over extension fields yet:

sage: G = F.extension(x^2 - 11, 'b')
sage: G.prime_above(13)
Traceback (most recent call last):
...
NotImplementedError

primes_above( self, x, [degree=None])

Return prime ideals of self lying over x.

Input:

- x: usually an element or ideal of self. It should be such that self.ideal(x) is sensible. This excludes x=0.
- degree (default: None): None or an integer. If None, find all primes above x of any degree. If an integer, find all primes above x such that the resulting residue field has exactly this degree.

Output: A list of prime ideals of self lying over x. If degree is specified and no such ideal exists, returns the empty list.

WARNING: at this time we factor the ideal x, which may not be supported for relative number fields.

sage: x = ZZ['x'].gen()
sage: F.<t> = NumberField(x^3 - 2)

sage: P2s = F.primes_above(2)
sage: P2s # random
[Fractional ideal (-t)]
sage: all(2 in P2 for P2 in P2s)
True
sage: all(P2.is_prime() for P2 in P2s)
True
sage: [ P2.norm() for P2 in P2s ]
[2]

sage: P3s = F.primes_above(3)
sage: P3s # random
[Fractional ideal (t + 1)]
sage: all(3 in P3 for P3 in P3s)
True
sage: all(P3.is_prime() for P3 in P3s)
True
sage: [ P3.norm() for P3 in P3s ]
[3]

The ideal (3) is totally ramified in F, so there is no degree 2 prime above 3:

sage: F.primes_above(3, degree=2)
[]
sage: [ id.residue_class_degree() for id, _ in F.ideal(3).factor() ]
[1]

Asking for a specific degree works:

sage: P5_1s = F.primes_above(5, degree=1)
sage: P5_1s # random
[Fractional ideal (-t^2 - 1)]
sage: P5_1 = P5_1s[0]; P5_1.residue_class_degree()
1

sage: P5_2s = F.primes_above(5, degree=2)
sage: P5_2s # random
[Fractional ideal (t^2 - 2*t - 1)]
sage: P5_2 = P5_2s[0]; P5_2.residue_class_degree()
2

TESTS: It doesn't make sense to factor the ideal (0):

sage: F.primes_above(0)
Traceback (most recent call last):
...
AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'

Sage can't factor ideals over extension fields yet:

sage: G = F.extension(x^2 - 11, 'b')
sage: G.primes_above(13)
Traceback (most recent call last):
...
NotImplementedError

primes_of_degree_one_iter( self, [num_integer_primes=10000], [max_iterations=100])

Return an iterator yielding prime ideals of absolute degree one and small norm.

WARNING: It is possible that there are no primes of $ K$ of absolute degree one of small prime norm, and it possible that this algorithm will not find any primes of small norm.

See module sage.rings.number_field.small_primes_of_degree_one for details.

Input:

num_integer_primes (default: 10000)
- an integer. We try to find primes of absolute norm no greater than the num_integer_primes-th prime number. For example, if num_integer_primes is 2, the largest norm found will be 3, since the second prime is 3.
max_iterations (default: 100)
- an integer. We test max_iterations integers to find small primes before raising StopIteration.

sage: K.<z> = CyclotomicField(10)
sage: it = K.primes_of_degree_one_iter()
sage: Ps = [ it.next() for i in range(3) ]
sage: Ps # random
[Fractional ideal (z^3 + z + 1), Fractional ideal (3*z^3 - z^2 + z - 1),
Fractional ideal (2*z^3 - 3*z^2 + z - 2)]
sage: [ P.norm() for P in Ps ] # random
[11, 31, 41]
sage: [ P.residue_class_degree() for P in Ps ]
[1, 1, 1]

primes_of_degree_one_list( self, n, [num_integer_primes=10000], [max_iterations=100])

Return a list of n prime ideals of absolute degree one and small norm.

WARNING: It is possible that there are no primes of $ K$ of absolute degree one of small prime norm, and it possible that this algorithm will not find any primes of small norm.

See module sage.rings.number_field.small_primes_of_degree_one for details.

Input:

num_integer_primes (default: 10000)
- an integer. We try to find primes of absolute norm no greater than the num_integer_primes-th prime number. For example, if num_integer_primes is 2, the largest norm found will be 3, since the second prime is 3.
max_iterations (default: 100)
- an integer. We test max_iterations integers to find small primes before raising StopIteration.

sage: K.<z> = CyclotomicField(10)
sage: Ps = K.primes_of_degree_one_list(3)
sage: Ps
[Fractional ideal (z^3 + z + 1), Fractional ideal (3*z^3 - z^2 + z - 1),
Fractional ideal (2*z^3 - 3*z^2 + z - 2)]
sage: [ P.norm() for P in Ps ]
[11, 31, 41]
sage: [ P.residue_class_degree() for P in Ps ]
[1, 1, 1]

primitive_element( self)

Return a primitive element for this field, i.e., an element that generates it over $ \mathbf{Q}$ .

sage: K.<a> = NumberField(x^3 + 2)
sage: K.primitive_element()
a
sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
sage: K.primitive_element()
a + (-1)*b + c
sage: alpha = K.primitive_element(); alpha
a + (-1)*b + c
sage: alpha.minpoly()
x^2 + (2*b - 2*c)*x + (-2*c)*b + 6
sage: alpha.absolute_minpoly()
x^8 - 40*x^6 + 352*x^4 - 960*x^2 + 576

real_embeddings( self, [prec=53])

Return all homomorphisms of this number field into the approximate real field with precision prec.

If prec is 53 (the default), then the real double field is used; otherwise the arbitrary precision (but slow) real field is used.

sage: K.<a> = NumberField(x^3 + 2)
sage: K.real_embeddings()
[
Ring morphism:
  From: Number Field in a with defining polynomial x^3 + 2
  To:   Real Double Field
  Defn: a |--> -1.25992104989
]
 sage: K.real_embeddings(16)
 [
 Ring morphism:
   From: Number Field in a with defining polynomial x^3 + 2
   To:   Real Field with 16 bits of precision
   Defn: a |--> -1.260
 ]
sage: K.real_embeddings(100)
[
Ring morphism:
  From: Number Field in a with defining polynomial x^3 + 2
  To:   Real Field with 100 bits of precision
  Defn: a |--> -1.2599210498948731647672106073
]

reduced_basis( self, [prec=None])

This function returns an LLL-reduced basis for the Minkowski-embedding of the maximal order of a number field.

Input:

self
- number field, the base field
prec (default: None)
- the precision with which to compute the Minkowski embedding. (See NOTE below.)

Output: An LLL-reduced basis for the Minkowski-embedding of the maximal order of a number field, given by a sequence of (integral) elements from the field.

NOTE: In the non-totally-real case, the LLL routine we call is currently Pari's qflll(), which works with floating point approximations, and so the result is only as good as the precision promised by Pari. The matrix returned will always be integral; however, it may only be only "almost" LLL-reduced when the precision is not sufficiently high.

sage: F.<t> = NumberField(x^6-7*x^4-x^3+11*x^2+x-1)
sage: F.maximal_order().basis()
[1/2*t^5 + 1/2*t^4 + 1/2*t^2 + 1/2, t, t^2, t^3, t^4, t^5]
sage: F.reduced_basis()
[1,
1/2*t^5 - 1/2*t^4 - 3*t^3 + 3/2*t^2 + 4*t - 1/2,
t,
1/2*t^5 + 1/2*t^4 - 4*t^3 - 5/2*t^2 + 7*t + 1/2,
1/2*t^5 - 1/2*t^4 - 2*t^3 + 3/2*t^2 - 1/2,
1/2*t^5 - 1/2*t^4 - 3*t^3 + 5/2*t^2 + 4*t - 5/2]

sage: F.<alpha> = NumberField(x^4+x^2+712312*x+131001238)
sage: F.integral_basis()
[1, alpha, alpha^2, 1/2*alpha^3 + 1/2*alpha^2]
sage: F.reduced_basis(prec=10)
[1, alpha, alpha^2 - 15*alpha + 8, alpha^3 - 16*alpha^2 + 471*alpha +
266719]
sage: F.reduced_basis(prec=300)
[1, alpha, alpha^2 - 15*alpha, alpha^3 - 16*alpha^2 + 469*alpha + 267109]

reduced_gram_matrix( self, [prec=None])

This function returns the Gram matrix of an LLL-reduced basis for the Minkowski embedding of the maximal order of a number field.

Input:

self
- number field, the base field
prec (default: None)
- the precision with which to calculate the Minkowski embedding. (See NOTE below.)

Output: The Gram matrix $ [<x_i,x_j>]$ of an LLL reduced basis for the maximal order of self, where the integral basis for self is given by $ \{x_0, \dots, x_{n-1}\}$ . Here < , > is the usual inner product on $ \mathbf{R}^n$ , and self is embedded in $ \mathbf{R}^n$ by the Minkowski embedding. See the docstring for self.Minkowski_embedding for more information.

NOTE: In the non-totally-real case, the LLL routine we call is currently Pari's qflll(), which works with floating point approximations, and so the result is only as good as the precision promised by Pari. In particular, in this case, the returned matrix will *not* be integral, and may not have enough precision to recover the correct gram matrix (which is known to be integral for theoretical reasons). Thus the need for the prec flag above.

sage: F.<t> = NumberField(x^6-7*x^4-x^3+11*x^2+x-1)
sage: F.reduced_gram_matrix()
[ 6 -3  0 -2  0 -1]
[-3  9  0  1  0  3]
[ 0  0 14  6 -2  3]
[-2  1  6 16 -3  3]
[ 0  0 -2 -3 16  6]
[-1  3  3  3  6 19]
sage: Matrix(6, [(x*y).trace() for x in F.integral_basis() for y in F.integral_basis()])
[   6    0   14    3   54   52]
[   0   14    3   54   30  133]
[  14    3   54   30  233  259]
[   3   54   30  233  217  664]
[  54   30  233  217 1078 1368]
[  52  133  259  664 1368 2550]

sage: var('x')
x
sage: F.<alpha> = NumberField(x^4+x^2+712312*x+131001238)
sage: F.reduced_gram_matrix() # random low-order bits
[   3.99999999998249   0.000000000000000    1.99999999997817
-1.06846799999532e6]
[  0.000000000000000    46721.5393313587    11488.9100265019
-1.12285582008158e7]
[   1.99999999997817    11488.9100265019  5.56589153102570e8 
8.06191790906345e9]
[-1.06846799999532e6 -1.12285582008158e7  8.06191790906345e9
5.87118790062408e12]

regulator( self, [proof=None])

Return the regulator of this number field.

Note that PARI computes the regulator to higher precision than the SAGE default.

Input:

proof
- default: True, unless you set it otherwise.

sage: NumberField(x^2-2, 'a').regulator()
0.88137358701954305
sage: NumberField(x^4+x^3+x^2+x+1, 'a').regulator()
0.96242365011920694

residue_field( self, prime, [names=None], [check=False])

Return the residue field of this number field at a given prime, ie $ O_K / p O_K$ .

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.

sage: R.<x> = QQ[]
sage: K.<a> = NumberField(x^4+3*x^2-17)
sage: P = K.ideal(61).factor()[0][0]
sage: K.residue_field(P)
Residue field in abar of Fractional ideal (-2*a^2 + 1)

roots_of_unity( self)

Return all the roots of unity in this field, primitive or not.

sage: K.<b> = NumberField(x^2+1)
sage: zs = K.roots_of_unity(); zs
[b, -1, -b, 1]
sage: [ z**K.number_of_roots_of_unity() for z in zs ]
[1, 1, 1, 1]

signature( self)

Return (r1, r2), where r1 and r2 are the number of real embeddings and pairs of complex embeddings of this field, respectively.

sage: NumberField(x^2+1, 'a').signature()
(0, 1)
sage: NumberField(x^3-2, 'a').signature()
(1, 1)

structure( self)

Return fixed isomorphism or embedding structure on self.

This is used to record various isomorphisms or embeddings that arise naturally in other constructions.

sage: K.<z> = NumberField(x^2 + 3)
sage: L.<a> = K.absolute_field(); L
Number Field in a with defining polynomial x^2 + 3
sage: L.structure()
(Number field isomorphism from Number Field in a with defining polynomial
x^2 + 3 to Number Field in z with defining polynomial x^2 + 3 given by
variable name change,
 Number field isomorphism from Number Field in z with defining polynomial
x^2 + 3 to Number Field in a with defining polynomial x^2 + 3 given by
variable name change)

subfield( self, alpha, [name=None])

Return an absolute number field K isomorphic to QQ(alpha) and a map from K to self that sends the generator of K to alpha.

Input:

alpha
- an element of self, or something that coerces to an element of self.

Output:
K
- a number field
from_K
- a homomorphism from K to self that sends the generator of K to alpha.

sage: K.<a> = NumberField(x^4 - 3); K
Number Field in a with defining polynomial x^4 - 3
sage: H, from_H = K.subfield(a^2, name='b')
sage: H
Number Field in b with defining polynomial x^2 - 3
sage: from_H(H.0)
a^2
sage: from_H
Ring morphism:
  From: Number Field in b with defining polynomial x^2 - 3
  To:   Number Field in a with defining polynomial x^4 - 3
  Defn: b |--> a^2

sage: K.<z> = CyclotomicField(5)
sage: K.subfield(z-z^2-z^3+z^4)
(Number Field in z0 with defining polynomial x^2 - 5,
Ring morphism:
From: Number Field in z0 with defining polynomial x^2 - 5
To:   Cyclotomic Field of order 5 and degree 4
Defn: z0 |--> -2*z^3 - 2*z^2 - 1)

You can also view a number field as having a different generator by just choosing the input to generate the whole field; for that it is better to use self.change_generator, which gives isomorphisms in both directions.

trace_pairing( self, v)

Return the matrix of the trace pairing on the elements of the list $ v$ .

sage: K.<zeta3> = NumberField(x^2 + 3)
sage: K.trace_pairing([1,zeta3])
[ 2  0]
[ 0 -6]

uniformizer( self, P, [others=positive])

Returns an element of self with valuation 1 at the prime ideal P.

Input:

self
- a number field
P
- a prime ideal of self
others
- either "positive" (default), in which case the element will have non-negative valuation at all other primes of self, or "negative", in which case the element will have non-positive valuation at all other primes of self.

NOTE: When P is principal (e.g. always when self has class number one) the result may or may not be a generator of P!

sage: K.<a> = NumberField(x^2 + 5); K
Number Field in a with defining polynomial x^2 + 5
sage: P,Q = K.ideal(3).prime_factors()
sage: P
Fractional ideal (3, a + 1)
sage: pi=K.uniformizer(P); pi
a + 1
sage: K.ideal(pi).factor()
(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1))
sage: pi=K.uniformizer(P,'negative'); pi
1/2*a + 1/2
sage: K.ideal(pi).factor()
(Fractional ideal (2, a + 1))^-1 * (Fractional ideal (3, a + 1))

sage: K = CyclotomicField(9)
sage: Plist=K.ideal(17).prime_factors()
sage: pilist = [K.uniformizer(P) for P in Plist]
sage: [pi.is_integral() for pi in pilist]
[True, True, True]
sage: [pi.valuation(P) for pi,P in zip(pilist,Plist)]
[1, 1, 1]
sage: [ pilist[i] in Plist[i] for i in range(len(Plist)) ]
[True, True, True]

units( self, [proof=None])

Return generators for the unit group modulo torsion.

ALGORITHM: Uses PARI's bnfunit command.

INPUTS: proof - default: True

sage: x = QQ['x'].0
sage: A = x^4 - 10*x^3 + 20*5*x^2 - 15*5^2*x + 11*5^3
sage: K = NumberField(A, 'a')
sage: K.units()
[8/275*a^3 - 12/55*a^2 + 15/11*a - 2]

Sage might not be able to provably compute the unit group:

sage: K = NumberField(x^17 + 3, 'a')
sage: K.units(proof=True) # default
Traceback (most recent call last):
...
PariError: not enough precomputed primes, need primelimit ~  (35)

In this case, one can ask for the conjectural unit group (correct if the Generalized Riemann Hypothesis is true):

sage: K.units(proof=False)
[a^9 + a - 1,
a^16 - a^15 + a^14 - a^12 + a^11 - a^10 - a^8 + a^7 - 2*a^6 + a^4 - 3*a^3 +
2*a^2 - 2*a + 1,
2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 +
3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4,
2*a^16 - 3*a^15 + 3*a^14 - 3*a^13 + 3*a^12 - a^11 + a^9 - 3*a^8 + 4*a^7 -
5*a^6 + 6*a^5 - 4*a^4 + 3*a^3 - 2*a^2 - 2*a + 4,
a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 -
3*a^2 - 2*a + 2,
a^16 - a^15 - 3*a^14 - 4*a^13 - 4*a^12 - 3*a^11 - a^10 + 2*a^9 + 4*a^8 +
5*a^7 + 4*a^6 + 2*a^5 - 2*a^4 - 6*a^3 - 9*a^2 - 9*a - 7,
a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a +
1,
3*a^16 + 3*a^15 + 3*a^14 + 3*a^13 + 3*a^12 + 2*a^11 + 2*a^10 + 2*a^9 + a^8
- a^7 - 2*a^6 - 3*a^5 - 3*a^4 - 4*a^3 - 6*a^2 - 8*a - 8]

The provable and the conjectural results are cached separately (this fixes trac #2504):

sage: K.units(proof=True)
Traceback (most recent call last):
...
PariError: not enough precomputed primes, need primelimit ~  (35)

zeta( self, [n=2], [all=False])

If all is False, return a primitive n-th root of unity in this field, or raise an ArithmeticError exception if there are none.

If all is True, return a list of all primitive n-th roots of unity in this field (possibly empty).

Note that if one wants to know the maximal root of unity in this field, one can use self.zeta_order().

Input:

n
- positive integer
all
- bool, default: False.

sage: K.<z> = NumberField(x^2 + 3)
sage: K.zeta(1)
1
sage: K.zeta(2)
-1
sage: K.zeta(2, all=True)
[-1]
sage: K.zeta(3)
1/2*z - 1/2            
sage: K.zeta(3, all=True)
[1/2*z - 1/2, -1/2*z - 1/2]
sage: K.zeta(4)
Traceback (most recent call last):
...
ArithmeticError: There are no 4-th roots of unity in self.

sage: r.<x> = QQ[]
sage: K.<b> = NumberField(x^2+1)
sage: K.zeta(4)
b
sage: K.zeta(4,all=True)
[b, -b]
sage: K.zeta(3)
Traceback (most recent call last):
...
ArithmeticError: There are no 3-rd roots of unity in self.
sage: K.zeta(3,all=True)
[]

zeta_coefficients( self, n)

Compute the first n coefficients of the Dedekind zeta function of this field as a Dirichlet series.

sage: x = QQ['x'].0
sage: NumberField(x^2+1, 'a').zeta_coefficients(10)
[1, 1, 0, 1, 2, 0, 0, 1, 1, 2]

zeta_function( self, [prec=53], [max_imaginary_part=0], [max_asymp_coeffs=40])

Return the Zeta function of this number field.

This actually returns an interface to Tim Dokchitser's program for computing with the Dedekind zeta function zeta_F(s) of the number field F.

Input:

prec
- integer (bits precision)
max_imaginary_part
- real number
max_asymp_coeffs
- integer

Output: The zeta function of this number field.

sage: K.<a> = NumberField(ZZ['x'].0^2+ZZ['x'].0-1)
sage: Z = K.zeta_function()
sage: Z
Zeta function associated to Number Field in a with defining polynomial x^2
+ x - 1
sage: Z(-1)
0.0333333333333333

zeta_order( self)

Return the number of roots of unity in this field.

sage: F.<alpha> = NumberField(x**22+3)
sage: F.zeta_order()
6
sage: F.<alpha> = NumberField(x**2-7)
sage: F.zeta_order()
2

Special Functions: __call__,$ \,$ __cmp__,$ \,$ __init__,$ \,$ _coerce_from_other_number_field,$ \,$ _coerce_from_str,$ \,$ _coerce_impl,$ \,$ _coerce_non_number_field_element_in,$ \,$ _fractional_ideal_class_,$ \,$ _gap_init_,$ \,$ _Hom_,$ \,$ _ideal_class_,$ \,$ _is_valid_homomorphism_,$ \,$ _latex_,$ \,$ _normalize_prime_list,$ \,$ _pari_init_,$ \,$ _repr_,$ \,$ _set_structure

__call__( self, x)

Coerce x into this number field.

sage: K.<a> = NumberField(x^3 + 17)
sage: K(a) is a
True
sage: K('a^2 + 2/3*a + 5')
a^2 + 2/3*a + 5
sage: K('1').parent()
Number Field in a with defining polynomial x^3 + 17
sage: K(3/5).parent()
Number Field in a with defining polynomial x^3 + 17

__cmp__( self, other)

Compare a number field with something else.

Input:

other
- arbitrary Python object.

If other is not a number field, then the types of self and other are compared. If both are number fields, then the variable names are compared. If those are the same, then the underlying defining polynomials are compared. If the polynomials are the same, the number fields are considered ``equal'', but need not be identical. Coercion between equal number fields is allowed.

sage: k.<a> = NumberField(x^3 + 2); m.<b> = NumberField(x^3 + 2)
sage: cmp(k,m)
-1
sage: cmp(m,k)
1
sage: k == QQ
False
sage: k.<a> = NumberField(x^3 + 2); m.<a> = NumberField(x^3 + 2)
sage: k is m
True
sage: m = loads(dumps(k))
sage: k is m
False
sage: k == m
True

_coerce_from_other_number_field( self, x)

Coerce a number field element x into this number field.

In most cases this currently doesn't work (since it is barely implemented) - it only works for constants.

Input:

x
- an element of some number field

sage: K.<a> = NumberField(x^3 + 2)
sage: L.<b> = NumberField(x^2 + 1)
sage: K._coerce_from_other_number_field(L(2/3))
2/3

_coerce_from_str( self, x)

Coerce a string representation of an element of this number field into this number field.

Input:

x
- string

sage: k.<theta25> = NumberField(x^3+(2/3)*x+1)
sage: k._coerce_from_str('theta25^3 + (1/3)*theta25')
-1/3*theta25 - 1

This function is called by the coerce method when it gets a string as input:

sage: k('theta25^3 + (1/3)*theta25')
-1/3*theta25 - 1

_coerce_impl( self, x)

Canonical coercion of x into self.

Currently integers, rationals, and this field itself coerce canonical into this field.

sage: S.<y> = NumberField(x^3 + x + 1)
sage: S._coerce_impl(int(4))
4
sage: S._coerce_impl(long(7))
7
sage: S._coerce_impl(-Integer(2))
-2
sage: z = S._coerce_impl(-7/8); z, type(z)
(-7/8, <type 'sage.rings.number_field.number_field_element.NumberFieldEleme
nt_absolute'>)
sage: S._coerce_impl(y) is y
True

There are situations for which one might imagine canonical coercion could make sense (at least after fixing choices), but which aren't yet implemented:

sage: K.<a> = QuadraticField(2)
sage: K._coerce_impl(sqrt(2))
Traceback (most recent call last):
...
TypeError

_coerce_non_number_field_element_in( self, x)

Coerce a non-number field element x into this number field.

Input:

x
- a non number field element x, e.g., a list, integer, rational, or polynomial.

sage: K.<a> = NumberField(x^3 + 2/3)
sage: K._coerce_non_number_field_element_in(-7/8)
-7/8
sage: K._coerce_non_number_field_element_in([1,2,3])
3*a^2 + 2*a + 1

The list is just turned into a polynomial in the generator.

sage: K._coerce_non_number_field_element_in([0,0,0,1,1])
-2/3*a - 2/3

Not any polynomial coerces in, e.g., not this one in characteristic 7.

sage: f = GF(7)['y']([1,2,3]); f
3*y^2 + 2*y + 1
sage: K._coerce_non_number_field_element_in(f)
Traceback (most recent call last):
...
TypeError

_fractional_ideal_class_( self)

Return the Python class used in defining fractional ideals of the ring of integers of this number field.

This function is required by the general ring/ideal machinery. The value defined here is the default value for all number fields *except* relative number fields; this function is overridden by one of the same name on class NumberField_relative.

sage: NumberField(x^2 + 2, 'c')._fractional_ideal_class_()
<class 'sage.rings.number_field.number_field_ideal.NumberFieldFractionalIde
al'>

_gap_init_( self)

Create a gap object representing self and return its name

sage: F=CyclotomicField(8)
sage: F.gen()
zeta8
sage: F._gap_init_() # the following variable name $sage1 represents the F.base_ring() in gap and is somehow random
'CallFuncList(function() local x,E; x:=Indeterminate($sage1,"x");
E:=AlgebraicExtension($sage1,x^4 + 1,"zeta8"); return E; end,[])'
sage: f=gap(F)
sage: f
<algebraic extension over the Rationals of degree 4>
sage: f.GeneratorsOfDivisionRing()
[ (zeta8) ]

_Hom_( self, codomain, [cat=None])

Return homset of homomorphisms from self to the number field codomain.

The cat option is currently ignored.

This function is implicitly called by the Hom method or function.

sage: K.<i> = NumberField(x^2 + 1); K
Number Field in i with defining polynomial x^2 + 1
sage: K.Hom(K)
Automorphism group of Number Field in i with defining polynomial x^2 + 1
sage: Hom(K, QuadraticField(-1, 'b'))
Set of field embeddings from Number Field in i with defining polynomial x^2
+ 1 to Number Field in b with defining polynomial x^2 + 1

_ideal_class_( self)

Return the Python class used in defining the zero ideal of the ring of integers of this number field.

This function is required by the general ring/ideal machinery. The value defined here is the default value for all number fields.

sage: NumberField(x^2 + 2, 'c')._ideal_class_()
<class 'sage.rings.number_field.number_field_ideal.NumberFieldIdeal'>

_is_valid_homomorphism_( self, codomain, im_gens)

Return whether or not there is a homomorphism defined by the given images of generators.

To do this we just check that the elements of the image of the given generator (im_gens always has length 1) satisfies the relation of the defining poly of this field.

sage: k.<a> = NumberField(x^2 - 3)
sage: k._is_valid_homomorphism_(QQ, [0])
False
sage: k._is_valid_homomorphism_(k, [])
False
sage: k._is_valid_homomorphism_(k, [a])
True
sage: k._is_valid_homomorphism_(k, [-a])
True
sage: k._is_valid_homomorphism_(k, [a+1])
False

_latex_( self)

Return latex representation of this number field. This is viewed as a polynomial quotient ring over a field.

sage: k.<a> = NumberField(x^13 - (2/3)*x + 3)
sage: k._latex_()
'\\mathbf{Q}[a]/(a^{13} - \\frac{2}{3} a + 3)'
sage: latex(k)
\mathbf{Q}[a]/(a^{13} - \frac{2}{3} a + 3)

Numbered variables are often correctly typeset:

sage: k.<theta25> = NumberField(x^25+x+1)
sage: print k._latex_()
\mathbf{Q}[\theta_{25}]/(\theta_{25}^{25} + \theta_{25} + 1)

_pari_init_( self)

Needed for conversion of number field to PARI.

This only works if the defining polynomial of this number field is integral and monic.

sage: k = NumberField(x^2 + x + 1, 'a')
sage: k._pari_init_()
'nfinit(x^2 + x + 1)'
sage: k._pari_()
[x^2 + x + 1, [0, 1], -3, 1, ... [1, x], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1,
1, -1]]
sage: pari(k)
[x^2 + x + 1, [0, 1], -3, 1, ...[1, x], [1, 0; 0, 1], [1, 0, 0, -1; 0, 1,
1, -1]]

_repr_( self)

Return string representation of this number field.

sage: k.<a> = NumberField(x^13 - (2/3)*x + 3)
sage: k._repr_()
'Number Field in a with defining polynomial x^13 - 2/3*x + 3'

Class: NumberField_quadratic

class NumberField_quadratic
Create a quadratic extension of the rational field.

The command QuadraticField(a) creates the field Q(sqrt(a)).

sage: QuadraticField(3, 'a')
Number Field in a with defining polynomial x^2 - 3
sage: QuadraticField(-4, 'b')
Number Field in b with defining polynomial x^2 + 4
NumberField_quadratic( self, polynomial, [name=None], [check=True])

Create a quadratic number field.

sage: k.<a> = QuadraticField(5, check=False); k
Number Field in a with defining polynomial x^2 - 5

Don't do this:

sage: k.<a> = QuadraticField(4, check=False); k
Number Field in a with defining polynomial x^2 - 4

Functions: class_number,$ \,$ coerce_map_from_impl,$ \,$ discriminant,$ \,$ hilbert_class_field,$ \,$ hilbert_class_polynomial,$ \,$ is_galois

class_number( self, [proof=None])

Return the size of the class group of self.

If proof = False (*not* the default!) and the discriminant of the field is negative, then the following warning from the PARI manual applies: IMPORTANT WARNING: For $ D<0$ , this function may give incorrect results when the class group has a low exponent (has many cyclic factors), because implementing Shank's method in full generality slows it down immensely.

sage: QuadraticField(-23,'a').class_number()
3

These are all the primes so that the class number of $ \mathbf{Q}(\sqrt{-p})$ is $ 1$ :

sage: [d for d in prime_range(2,300) if not is_square(d) and QuadraticField(-d,'a').class_number() == 1]
[2, 3, 7, 11, 19, 43, 67, 163]

It is an open problem to prove that there are infinity many positive square-free $ d$ such that $ \mathbf{Q}(\sqrt{d})$ has class number $ 1$ :n

sage: len([d for d in range(2,200) if not is_square(d) and QuadraticField(d,'a').class_number() == 1])
121

coerce_map_from_impl( self, S)

sage: K.<a> = QuadraticField(-3)
sage: f = K.coerce_map_from(QQ); f
Natural morphism:
  From: Rational Field
  To:   Number Field in a with defining polynomial x^2 + 3
sage: f(3/5)
3/5
sage: parent(f(3/5)) is K
True

discriminant( self, [v=None])

Returns the discriminant of the ring of integers of the number field, or if v is specified, the determinant of the trace pairing on the elements of the list v.

Input:

v (optional)
- list of element of this number field
Output: Integer if v is omitted, and Rational otherwise.

sage: K.<i> = NumberField(x^2+1)
sage: K.discriminant()
-4
sage: K.<a> = NumberField(x^2+5)
sage: K.discriminant()
-20
sage: K.<a> = NumberField(x^2-5)
sage: K.discriminant()
5

hilbert_class_field( self, names)

Returns the Hilbert class field of this quadratic field as an absolute extension of $ \mathbf{Q}$ . For a polynomial that defines a relative extension see the hilbert_class_polynomial command.

Note: Computed using PARI via Schertz's method. This implementation is amazingly fast.

sage: x = QQ['x'].0
sage: K = NumberField(x^2 + 23, 'a')
sage: K.hilbert_class_polynomial()
x^3 + x^2 - 1
sage: K.hilbert_class_field('h')
Number Field in h with defining polynomial x^6 + 2*x^5 + 70*x^4 + 90*x^3 +
1631*x^2 + 1196*x + 12743

hilbert_class_polynomial( self)

Returns a polynomial over $ \mathbf{Q}$ whose roots generate the Hilbert class field of this quadratic field.

Note: Computed using PARI via Schertz's method. This implementation is quite fast.

sage: K.<b> = QuadraticField(-23)
sage: K.hilbert_class_polynomial()
x^3 + x^2 - 1

sage: K.<a> = QuadraticField(-431)
sage: K.class_number()
21
sage: K.hilbert_class_polynomial()
x^21 + x^20 - 13*x^19 - 50*x^18 + 592*x^17 - 2403*x^16 + 5969*x^15 -
10327*x^14 + 13253*x^13 - 12977*x^12 + 9066*x^11 - 2248*x^10 - 5523*x^9 +
11541*x^8 - 13570*x^7 + 11315*x^6 - 6750*x^5 + 2688*x^4 - 577*x^3 + 9*x^2 +
15*x + 1

is_galois( self)

Return True since all quadratic fields are automatically Galois.

sage: QuadraticField(1234,'d').is_galois()
True

Special Functions: __init__,$ \,$ __reduce__

__reduce__( self)

This is used in pickling quadratic number fields.

TESTS:

sage: K.<z7> = QuadraticField(7)
sage: L = loads(dumps(K))
sage: print L
Number Field in z7 with defining polynomial x^2 - 7
sage: print L == K
True

Class: NumberField_relative

class NumberField_relative

sage: K.<a> = NumberField(x^3 - 2)
sage: t = K['x'].gen()
sage: L.<b> = K.extension(t^2+t+a); L
Number Field in b with defining polynomial x^2 + x + a over its base field
NumberField_relative( self, base, polynomial, name, [latex_name=None], [names=None], [check=True])

Input:

base
- the base field
polynomial
- must be defined in the ring K['x'], where K is the base field.
name
- variable name
latex_name
- latex variable name names -
check
- whether to check irreducibility of polynomial.

sage: K.<x> = CyclotomicField(5)[]
sage: W.<a> = NumberField(x^2 + 1)
sage: W
Number Field in a with defining polynomial x^2 + 1 over its base field
sage: type(W)
<class 'sage.rings.number_field.number_field.NumberField_relative'>

Test that check=False really skips the test:

sage: W.<a> = NumberField(K.cyclotomic_polynomial(5), check=False)
sage: W
Number Field in a with defining polynomial x^4 + x^3 + x^2 + x + 1 over its
base field

A relative extension of a relative extension:

sage: x = var('x')
sage: k.<a> = NumberField([x^2 + 2, x^2 + 1])
sage: l.<b> = k.extension(x^2 + 3)
sage: l
Number Field in b with defining polynomial x^2 + 3 over its base field
sage: l.base_field()
Number Field in a0 with defining polynomial x^2 + 2 over its base field
sage: l.base_field().base_field()
Number Field in a1 with defining polynomial x^2 + 1

Functions: absolute_base_field,$ \,$ absolute_degree,$ \,$ absolute_field,$ \,$ absolute_generator,$ \,$ absolute_polynomial,$ \,$ absolute_polynomial_ntl,$ \,$ absolute_vector_space,$ \,$ base_field,$ \,$ base_ring,$ \,$ change_names,$ \,$ embeddings,$ \,$ galois_closure,$ \,$ galois_group,$ \,$ gen,$ \,$ gens,$ \,$ is_absolute,$ \,$ is_free,$ \,$ is_galois,$ \,$ lift_to_base,$ \,$ maximal_order,$ \,$ ngens,$ \,$ number_of_roots_of_unity,$ \,$ order,$ \,$ pari_polynomial,$ \,$ pari_relative_polynomial,$ \,$ pari_rnf,$ \,$ polynomial,$ \,$ relative_discriminant,$ \,$ relativize,$ \,$ roots_of_unity,$ \,$ vector_space

absolute_base_field( self)

Return the base field of this relative extension, but viewed as an absolute field over QQ.

sage: K.<a,b,c> = NumberField([x^2 + 2, x^3 + 3, x^3 + 2])
sage: K
Number Field in a with defining polynomial x^2 + 2 over its base field
sage: K.base_field()
Number Field in b with defining polynomial x^3 + 3 over its base field
sage: K.absolute_base_field()[0]
Number Field in a with defining polynomial x^9 + 3*x^6 + 165*x^3 + 1
sage: K.base_field().absolute_field('z')
Number Field in z with defining polynomial x^9 + 3*x^6 + 165*x^3 + 1

absolute_degree( self)

sage: K.<a> = NumberField([x^2 + 3, x^2 + 2])
sage: K.absolute_degree()
4
sage: K.degree()
2

absolute_field( self, names)

Return an absolute number field K that is isomorphic to this field along with a field-theoretic bijection from self to K and from K to self.

Input:

names
- string; name of generator of the absolute field

Output:
K
- an absolute number field

Also, K.structure() returns from_K and to_K, where from_K is an isomorphism from K to self and to_K is an isomorphism from self to K.

sage: K.<a,b> = NumberField([x^4 + 3, x^2 + 2]); K
Number Field in a with defining polynomial x^4 + 3 over its base field
sage: L.<xyz> = K.absolute_field(); L
Number Field in xyz with defining polynomial x^8 + 8*x^6 + 30*x^4 - 40*x^2
+ 49
sage: L.<c> = K.absolute_field(); L
Number Field in c with defining polynomial x^8 + 8*x^6 + 30*x^4 - 40*x^2 +
49

sage: from_L, to_L = L.structure()
sage: from_L
Isomorphism from Number Field in c with defining polynomial x^8 + 8*x^6 +
30*x^4 - 40*x^2 + 49 to Number Field in a with defining polynomial x^4 + 3
over its base field
sage: from_L(c)
a - b
sage: to_L
Isomorphism from Number Field in a with defining polynomial x^4 + 3 over
its base field to Number Field in c with defining polynomial x^8 + 8*x^6 +
30*x^4 - 40*x^2 + 49
sage: to_L(a)
-5/182*c^7 - 87/364*c^5 - 185/182*c^3 + 323/364*c
sage: to_L(b)
-5/182*c^7 - 87/364*c^5 - 185/182*c^3 - 41/364*c
sage: to_L(a)^4
-3
sage: to_L(b)^2
-2

absolute_generator( self)

Return the chosen generator over QQ for this relative number field.

sage: y = polygen(QQ,'y')
sage: k.<a> = NumberField([y^2 + 2, y^4 + 3])
sage: g = k.absolute_generator(); g
a0 - a1
sage: g.minpoly()
x^2 + 2*a1*x + a1^2 + 2
sage: g.absolute_minpoly()
x^8 + 8*x^6 + 30*x^4 - 40*x^2 + 49

absolute_polynomial( self)

Return the polynomial over $ \mathbf{Q}$ that defines this field as an extension of the rational numbers.

sage: k.<a, b> = NumberField([x^2 + 1, x^3 + x + 1]); k
Number Field in a with defining polynomial x^2 + 1 over its base field
sage: k.absolute_polynomial()
x^6 + 5*x^4 - 2*x^3 + 4*x^2 + 4*x + 1

absolute_polynomial_ntl( self)

Return defining polynomial of this number field as a pair, an ntl polynomial and a denominator.

This is used mainly to implement some internal arithmetic.

sage: NumberField(x^2 + (2/3)*x - 9/17,'a').polynomial_ntl()
([-27 34 51], 51)

absolute_vector_space( self)

sage: K.<a,b> = NumberField([x^3 + 3, x^3 + 2]); K
Number Field in a with defining polynomial x^3 + 3 over its base field
sage: V,from_V,to_V = K.absolute_vector_space(); V
Vector space of dimension 9 over Rational Field
sage: from_V
Isomorphism from Vector space of dimension 9 over Rational Field to Number
Field in a with defining polynomial x^3 + 3 over its base field
sage: to_V
Isomorphism from Number Field in a with defining polynomial x^3 + 3 over
its base field to Vector space of dimension 9 over Rational Field
sage: c = (a+1)^5; c
7*a^2 + (-10)*a - 29
sage: to_V(c)
(-29, -712/9, 19712/45, 0, -14/9, 364/45, 0, -4/9, 119/45)
sage: from_V(to_V(c))
7*a^2 + (-10)*a - 29
sage: from_V(3*to_V(b))
3*b

base_field( self)

Return the base field of this relative number field.

sage: k.<a> = NumberField([x^3 + x + 1])
sage: R.<z> = k[]
sage: L.<b> = NumberField(z^3 + a)
sage: L.base_field()
Number Field in a with defining polynomial x^3 + x + 1
sage: L.base_field() is k
True

This is very useful because the print representation of a relative field doesn't describe the base field.

sage: L
Number Field in b with defining polynomial z^3 + a over its base field

base_ring( self)

This is exactly the same as base_field.

sage: k.<a> = NumberField([x^2 + 1, x^3 + x + 1])
sage: k.base_ring()
Number Field in a1 with defining polynomial x^3 + x + 1
sage: k.base_field()
Number Field in a1 with defining polynomial x^3 + x + 1

change_names( self, names)

Return relative number field isomorphic to self but with the given generator names.

Input:

names
- number of names should be at most the number of generators of self, i.e., the number of steps in the tower of relative fields.

Also, K.structure() returns from_K and to_K, where from_K is an isomorphism from K to self and to_K is an isomorphism from self to K.

sage: K.<a,b> = NumberField([x^4 + 3, x^2 + 2]); K
Number Field in a with defining polynomial x^4 + 3 over its base field
sage: L.<c,d> = K.change_names()
sage: L
Number Field in c with defining polynomial x^4 + 3 over its base field
sage: L.base_field()
Number Field in d with defining polynomial x^2 + 2

An example with a 3-level tower:

sage: K.<a,b,c> = NumberField([x^2 + 17, x^2 + x + 1, x^3 - 2]); K
Number Field in a with defining polynomial x^2 + 17 over its base field
sage: L.<m,n,r> = K.change_names()
sage: L
Number Field in m with defining polynomial x^2 + 17 over its base field
sage: L.base_field()
Number Field in n with defining polynomial x^2 + x + 1 over its base field
sage: L.base_field().base_field()
Number Field in r with defining polynomial x^3 - 2

embeddings( self, K)

Compute all field embeddings of the relative number field self into the field K (which need not even be a number field, e.g., it could be the complex numbers). This will return an identical result when given K as input again.

If possible, the most natural embedding of K into self is put first in the list.

Input:

K
- a number field

sage: K.<a,b> = NumberField([x^3 - 2, x^2+1])
sage: f = K.embeddings(ComplexField(58)); f
[
Relative number field morphism:
  From: Number Field in a with defining polynomial x^3 - 2 over its base
field
  To:   Complex Field with 58 bits of precision
  Defn: a |--> -0.62996052494743676 - 1.0911236359717214*I
        b |--> -1.9428902930940239e-16 + 1.0000000000000000*I,
...
Relative number field morphism:
  From: Number Field in a with defining polynomial x^3 - 2 over its base
field
  To:   Complex Field with 58 bits of precision
  Defn: a |--> 1.2599210498948731
        b |--> -0.99999999999999999*I
]
sage: f[0](a)^3
2.0000000000000002 - 8.6389229103644993e-16*I
sage: f[0](b)^2
-1.0000000000000001 - 3.8857805861880480e-16*I
sage: f[0](a+b)
-0.62996052494743693 - 0.091123635971721295*I

galois_closure( self, [names=None])

Return the absolute number field $ K$ that is the Galois closure of self.

galois_group( self, [pari_group=True], [use_kash=False])

Return the Galois group of the Galois closure of this number field as an abstract group. Note that even though this is an extension $ L/K$ , the group will be computed as if it were $ L/\mathbf{Q}$ .

For more (important!) documentation, so the documentation for Galois groups of polynomials over $ \mathbf{Q}$ , e.g., by typing K.polynomial().galois_group?, where $ K$ is a number field.

sage: x = QQ['x'].0
sage: K.<a> = NumberField(x^2 + 1)
sage: R.<t> = PolynomialRing(K)
sage: L = K.extension(t^5-t+a, 'b')
sage: L.galois_group()
Galois group PARI group [240, -1, 22, "S(5)[x]2"] of degree 10 of the
Number Field in b with defining polynomial t^5 + (-1)*t + a over its base
field

is_absolute( self)

sage: K.<a,b> = NumberField([x^4 + 3, x^2 + 2]); K
Number Field in a with defining polynomial x^4 + 3 over its base field
sage: K.is_absolute()
False
sage: K.is_relative()
True

is_free( self, [proof=None])

Determine whether or not $ L/K$ is free (i.e. if $ \mathcal{O}_L$ is a free $ \mathcal{O}_K$ -module).

Input:

proof
- default: True

sage: x = QQ['x'].0
sage: K.<a> = NumberField(x^2+6)
sage: L.<b> = K.extension(K['x'].gen()^2 + 3)    ## extend by x^2+3
sage: L.is_free()
False

is_galois( self)

Return True if this relative number field is Galois over $ \mathbf{Q}$ .

sage: k.<a> =NumberField([x^3 - 2, x^2 + x + 1])
sage: k.is_galois()
True
sage: k.<a> =NumberField([x^3 - 2, x^2 + 1])
sage: k.is_galois()
False

lift_to_base( self, element)

Lift an element of this extension into the base field if possible, or raise a ValueError if it is not possible.

sage: x = QQ['x'].0
sage: K = NumberField(x^3 - 2, 'a')
sage: R = K['x']
sage: L = K.extension(R.gen()^2 - K.gen(), 'b')
sage: b = L.gen()
sage: L.lift_to_base(b^4)
a^2
sage: L.lift_to_base(b)
Traceback (most recent call last):
...
ValueError: The element b is not in the base field

maximal_order( self)

Return the maximal order, i.e., the ring of integers of this number field.

sage: K.<a,b> = NumberField([x^2 + 1, x^2 - 3])
sage: OK = K.maximal_order(); OK.basis()
[1, 1/2*a - 1/2*b, (-1/2*b)*a + 1/2, a]
sage: charpoly(OK.1)
x^2 + b*x + 1
sage: charpoly(OK.2)
x^2 + (-1)*x + 1
sage: O2 = K.order([3*a, 2*b])
sage: O2.index_in(OK)
144

number_of_roots_of_unity( self)

Return number of roots of unity in this relative field.

sage: K.<a, b> = NumberField( [x^2 + x + 1, x^4 + 1] )
sage: K.number_of_roots_of_unity()
24
sage: K.roots_of_unity()[:5]
[(-b^3)*a, b^2*a + b^2, -b, (-1)*a, (-b^3)*a - b^3]

order( self)

Return the order with given ring generators in the maximal order of this number field.

Input:

gens
- list of elements of self; if no generators are given, just returns the cardinality of this number field (oo) for consistency.
check_is_integral
- bool (default: True), whether to check that each generator is integral.
check_rank
- bool (default: True), whether to check that the ring generated by gens is of full rank.
allow_subfield
- bool (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.

The check_is_integral and check_rank inputs must be given as explicit keyword arguments.

sage: P.<a,b,c> = QQ[2^(1/2), 2^(1/3), 3^(1/2)]
sage: R = P.order([a,b,c]); R
Relative Order in Number Field in sqrt2 with defining polynomial x^2 - 2
over its base field

The base ring of an order in a relative extension is still ZZ.

sage: R.base_ring()
Integer Ring

One must give enough generators to generate a ring of finite index in the maximal order:

sage: P.order([a,b])
Traceback (most recent call last):
...
ValueError: the rank of the span of gens is wrong

pari_polynomial( self)

PARI polynomial corresponding to the polynomial over the rationals that defines this field as an absolute number field.

sage: k.<a, c> = NumberField([x^2 + 3, x^2 + 1])
sage: k.pari_polynomial()
x^4 + 8*x^2 + 4
sage: k.defining_polynomial ()
x^2 + 3

pari_relative_polynomial( self)

Return the PARI relative polynomial associated to this number field. This is always a polynomial in x and y.

sage: k.<i> = NumberField(x^2 + 1)
sage: m.<z> = k.extension(k['w']([i,0,1]))
sage: m
Number Field in z with defining polynomial w^2 + i over its base field
sage: m.pari_relative_polynomial ()
x^2 + y

pari_rnf( self)

Return the PARI relative number field object associated to this relative extension.

sage: k.<a> = NumberField([x^4 + 3, x^2 + 2])
sage: k.pari_rnf()
[x^4 + 3, [], [[108, 0; 0, 108], [3, 0]~], ... 0]

polynomial( self)

Return the defining polynomial of this number field.

sage: y = polygen(QQ,'y')
sage: k.<a> = NumberField([y^2 + y + 1, x^3 + x + 1])
sage: k.polynomial()
y^2 + y + 1

This is the same as defining_polynomial:

sage: k.defining_polynomial()
y^2 + y + 1

Use absolute polynomial for a polynomial that defines the absolute extension.

sage: k.absolute_polynomial()
x^6 + 3*x^5 + 8*x^4 + 9*x^3 + 7*x^2 + 6*x + 3

relative_discriminant( self, [proof=None])

Return the relative discriminant of this extension $ L/K$ as an ideal of $ K$ . If you want the (rational) discriminant of $ L/Q$ , use e.g. L.discriminant().

TODO: Note that this uses PARI's rnfdisc function, which according to the documentation takes an nf parameter in GP but a bnf parameter in the C library. If the C library actually accepts an nf, then this function should be fixed and the proof parameter removed.

Input:

proof
- (default: False)

sage: K.<i> = NumberField(x^2 + 1)
sage: t = K['t'].gen()
sage: L.<b> = K.extension(t^4 - i)
sage: L.relative_discriminant()
Fractional ideal (256)
sage: factor(L.discriminant())
2^24
sage: factor( L.relative_discriminant().norm() )
2^16

relativize( self, alpha, names)

Given an element alpha in self, return a relative number field $ K$ isomorphic to self that is relative over the absolute field $ \mathbf{Q}(\alpha)$ , along with isomorphisms from $ K$ to self and from self to K.

Input:

alpha
- an element of self.
names
- name of generator for output field K.

Output:
K
- relative number field

Also, K.structure() returns from_K and to_K, where from_K is an isomorphism from K to self and to_K is an isomorphism from self to K.

sage: K.<a,b> = NumberField([x^4 + 3, x^2 + 2]); K
Number Field in a with defining polynomial x^4 + 3 over its base field
sage: L.<z,w> = K.relativize(a^2)
sage: z^2
z^2
sage: w^2
-3
sage: L
Number Field in z with defining polynomial x^4 + (-2*w + 4)*x^2 + 4*w + 1
over its base field
sage: L.base_field()
Number Field in w with defining polynomial x^2 + 3

roots_of_unity( self)

Return all the roots of unity in this relative field, primitive or not.

sage: K.<a, b> = NumberField( [x^2 + x + 1, x^4 + 1] )
sage: K.roots_of_unity()[:5]
[(-b^3)*a, b^2*a + b^2, -b, (-1)*a, (-b^3)*a - b^3]

vector_space( self)

Return vector space over the base field of self and isomorphisms from the vector space to self and in the other direction.

sage: K.<a,b,c> = NumberField([x^2 + 2, x^3 + 2, x^3 + 3]); K
Number Field in a with defining polynomial x^2 + 2 over its base field
sage: V, from_V, to_V = K.vector_space()
sage: from_V(V.0)
1
sage: to_V(K.0)
(0, 1)
sage: from_V(to_V(K.0))
a
sage: to_V(from_V(V.0))
(1, 0)
sage: to_V(from_V(V.1))
(0, 1)

The underlying vector space and maps is cached:

sage: W, from_V, to_V = K.vector_space()
sage: V is W
True

Special Functions: __call__,$ \,$ __init__,$ \,$ __reduce__,$ \,$ _coerce_impl,$ \,$ _fractional_ideal_class_,$ \,$ _gen_relative,$ \,$ _Hom_,$ \,$ _latex_,$ \,$ _NumberField_relative__base_inclusion,$ \,$ _pari_base_bnf,$ \,$ _pari_base_nf,$ \,$ _repr_

__call__( self, x)

Coerce x into this relative number field.

We construct the composite of three quadratic fields, then coerce from the quartic subfield of the relative extension:

sage: k.<a,b,c> = NumberField([x^2 + 5, x^2 + 3, x^2 + 1])
sage: m = k.base_field(); m
Number Field in b with defining polynomial x^2 + 3 over its base field
sage: k(m.0)
b
sage: k(2/3)
2/3
sage: k(m.0^4)
9

TESTS:

sage: K.<a> = NumberField(ZZ['x'].0^2 + 2, 'a')
sage: L.<b> = K.extension(ZZ['x'].0 - a, 'b')
sage: L(a)
a
sage: L(b+a)
2*a
sage: K.<a> = NumberField(ZZ['x'].0^5 + 2, 'a')
sage: L.<b> = K.extension(ZZ['x'].0 - a, 'b')
sage: L(a)
a
sage: L(a**3)
a^3
sage: L(a**2+b)
a^2 + a
sage: L.<b> = K.extension(ZZ['x'].0 + a/2, 'b')
sage: L(a)
a
sage: L(b)
-1/2*a

__reduce__( self)

TESTS:

sage: Z = var('Z')
sage: K.<w> = NumberField(Z^3 + Z + 1)
sage: L.<z> = K.extension(Z^3 + 2)
sage: L = loads(dumps(K))
sage: print L
Number Field in w with defining polynomial Z^3 + Z + 1
sage: print L == K
True

_coerce_impl( self, x)

Canonical implicit coercion of x into self.

Elements of this field canonically coerce in, as does anything that coerces into the base field of this field.

sage: k.<a> = NumberField([x^5 + 2, x^7 + 3])
sage: b = k(k.base_field().gen())
sage: b = k._coerce_impl(k.base_field().gen())
sage: b^7
-3
sage: k._coerce_impl(2/3)
2/3
sage: c = a + b  # this works

_fractional_ideal_class_( self)

Return the Python class used to represent ideals of a relative number field.

sage: k.<a> = NumberField([x^5 + 2, x^7 + 3])
sage: k._fractional_ideal_class_ ()
<class 'sage.rings.number_field.number_field_ideal_rel.NumberFieldFractiona
lIdeal_rel'>

_gen_relative( self)

Return root of defining polynomial, which is a generator of the relative number field over the base.

sage: k.<a> = NumberField(x^2+1); k
Number Field in a with defining polynomial x^2 + 1
sage: y = polygen(k)
sage: m.<b> = k.extension(y^2+3); m
Number Field in b with defining polynomial x^2 + 3 over its base field
sage: c = m.gen(); c
b
sage: c^2 + 3
0

_Hom_( self, codomain, [cat=None])

Return homset of homomorphisms from this relative number field to the codomain.

The cat option is currently ignored. The result is not cached.

This function is implicitly called by the Hom method or function.

sage: K.<a,b> = NumberField([x^3 - 2, x^2+1])
sage: K.Hom(K)
Automorphism group of Number Field in a with defining polynomial x^3 - 2
over its base field
sage: type(K.Hom(K))
<class 'sage.rings.number_field.morphism.RelativeNumberFieldHomset'>

_latex_( self)

Return a LaTeXrepresentation of the extension.

sage: x = QQ['x'].0
sage: K.<a> = NumberField(x^3 - 2)
sage: t = K['x'].gen()
sage: K.extension(t^2+t+a, 'b')._latex_()
'( \\mathbf{Q}[a]/(a^{3} - 2) )[b]/(b^{2} + b + a)'

_NumberField_relative__base_inclusion( self, element)

Given an element of the base field, give its inclusion into this extension in terms of the generator of this field.

This is called by the canonical coercion map on elements from the base field.

sage: k.<a> = NumberField([x^2 + 3, x^2 + 1])
sage: m = k.base_field(); m
Number Field in a1 with defining polynomial x^2 + 1
sage: k._coerce_(m.0 + 2/3)
a1 + 2/3
sage: s = k._coerce_(m.0); s
a1
sage: s^2
-1

This implicitly tests this coercion map:

sage: K.<a> = NumberField([x^2 + p for p in [5,3,2]])
sage: K._coerce_(K.base_field().0)
a1
sage: K._coerce_(K.base_field().0)^2
-3

_pari_base_bnf( self, [proof=None])

Return the PARI bnf (big number field) representation of the base field.

Input:

proof
- bool (default: True) if True, certify correctness of calculations (not assuming GRH).

sage: k.<a> = NumberField([x^3 + 2, x^2 + 2])
sage: k._pari_base_bnf()
[[;], matrix(0,9), [;], ... 0]

_pari_base_nf( self)

Return the PARI number field representation of the base field.

sage: y = polygen(QQ,'y')
sage: k.<a> = NumberField([y^3 + 2, y^2 + 2])
sage: k._pari_base_nf()
[y^2 + 2, [0, 1], -8, 1, ..., [1, 0, 0, -2; 0, 1, 1, 0]]

_repr_( self)

Return string representation of this relative number field.

The base field is not part of the string representation. To find out what the base field is use self.base_field().

sage: k.<a, b> = NumberField([x^5 + 2, x^7 + 3])
sage: k
Number Field in a with defining polynomial x^5 + 2 over its base field
sage: k.base_field()
Number Field in b with defining polynomial x^7 + 3

See About this document... for information on suggesting changes.