Number fields#
We define a quartic number field and its quadratic extension:
sage: x = polygen(ZZ, 'x')
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
>>> from sage.all import *
>>> x = polygen(ZZ, 'x')
>>> K = NumberField(x**Integer(4) - Integer(420)*x**Integer(2) + Integer(40000), names=('y',)); (y,) = K._first_ngens(1)
>>> z = y**Integer(5)/Integer(11); z
420/11*y^3 - 40000/11*y
>>> R = PolynomialRing(K, names=('y',)); (y,) = R._first_ngens(1)
>>> f = y**Integer(2) + y + Integer(1)
>>> L = K.extension(f, names=('a',)); (a,) = L._first_ngens(1); L
Number Field in a with defining polynomial y^2 + y + 1 over its base field
>>> KL = NumberField([x**Integer(4) - Integer(420)*x**Integer(2) + Integer(40000), x**Integer(2) + x + Integer(1)], names=('b',)); (b,) = KL._first_ngens(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
>>> from sage.all import *
>>> K = NumberField(x**Integer(3) - Integer(2), names=('cuberoot2',)); (cuberoot2,) = K._first_ngens(1)
>>> L = K.extension(x**Integer(3) - Integer(3), names=('cuberoot3',)); (cuberoot3,) = L._first_ngens(1)
>>> S = L.extension(x**Integer(2) - Integer(2), names=('sqrt2',)); (sqrt2,) = S._first_ngens(1)
>>> S
Number Field in sqrt2 with defining polynomial x^2 - 2 over its base field
>>> sqrt2 * cuberoot3
cuberoot3*sqrt2
>>> (sqrt2 + cuberoot3)**Integer(5)
(20*cuberoot3^2 + 15*cuberoot3 + 4)*sqrt2 + 3*cuberoot3^2 + 20*cuberoot3 + 60
>>> cuberoot2 + cuberoot3
cuberoot3 + cuberoot2
>>> cuberoot2 + cuberoot3 + sqrt2
sqrt2 + cuberoot3 + cuberoot2
>>> (cuberoot2 + cuberoot3 + sqrt2)**Integer(2)
(2*cuberoot3 + 2*cuberoot2)*sqrt2 + cuberoot3^2 + 2*cuberoot2*cuberoot3 + cuberoot2^2 + 2
>>> cuberoot2 + sqrt2
sqrt2 + cuberoot2
>>> a = S(cuberoot2); a
cuberoot2
>>> 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).
AUTHORS:
William Stein (2004, 2005): initial version
Steven Sivek (2006-05-12): added support for relative extensions
William Stein (2007-09-04): major rewrite and documentation
Robert Bradshaw (2008-10): specified embeddings into ambient fields
Simon King (2010-05): improved coercion from GAP
Jeroen Demeyer (2010-07, 2011-04): upgraded PARI (Issue #9343, Issue #10430, Issue #11130)
Robert Harron (2012-08): added is_CM(), complex_conjugation(), and maximal_totally_real_subfield()
Christian Stump (2012-11): added conversion to universal cyclotomic field
Julian Rueth (2014-04-03): absolute number fields are unique parents
Vincent Delecroix (2015-02): comparisons/floor/ceil using embeddings
Kiran Kedlaya (2016-05): relative number fields hash based on relative polynomials
Peter Bruin (2016-06): made number fields fully satisfy unique representation
John Jones (2017-07): improved check for is_galois(), add is_abelian(), building on work in patch by Chris Wuthrich
Anna Haensch (2018-03): added
quadratic_defect()
Michael Daub, Chris Wuthrich (2020-09-01): added Dirichlet characters for abelian fields
- class sage.rings.number_field.number_field.CyclotomicFieldFactory[source]#
Bases:
UniqueFactory
Return the \(n\)-th cyclotomic field, where n is a positive integer, or the universal cyclotomic field if
n==0
.For the documentation of the universal cyclotomic field, see
UniversalCyclotomicField
.INPUT:
n
– a nonnegative integer, default:0
names
– name of generator (default:zetan
)bracket
– Defines the brackets in the case ofn==0
, and is ignored otherwise. Can be any even length string, with"()"
being the default.embedding
– bool or \(n\)-th root of unity in an ambient field (default:True
)
EXAMPLES:
If called without a parameter, we get the
universal cyclotomic field
:sage: CyclotomicField() # needs sage.libs.gap Universal Cyclotomic Field
>>> from sage.all import * >>> CyclotomicField() # needs sage.libs.gap Universal Cyclotomic Field
We create the \(7\)th cyclotomic field \(\QQ(\zeta_7)\) with the default generator name.
sage: k = CyclotomicField(7); k Cyclotomic Field of order 7 and degree 6 sage: k.gen() zeta7
>>> from sage.all import * >>> k = CyclotomicField(Integer(7)); k Cyclotomic Field of order 7 and degree 6 >>> k.gen() zeta7
The default embedding sends the generator to the complex primitive \(n^{th}\) root of unity of least argument.
sage: CC(k.gen()) 0.623489801858734 + 0.781831482468030*I
>>> from sage.all import * >>> CC(k.gen()) 0.623489801858734 + 0.781831482468030*I
Cyclotomic fields are of a special type.
sage: type(k) <class 'sage.rings.number_field.number_field.NumberField_cyclotomic_with_category'>
>>> from sage.all import * >>> type(k) <class 'sage.rings.number_field.number_field.NumberField_cyclotomic_with_category'>
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
>>> from sage.all import * >>> k = CyclotomicField(Integer(7), names=('z7',)); (z7,) = k._first_ngens(1); k Cyclotomic Field of order 7 and degree 6 >>> k.gen() z7
The \(n\) must be an integer.
sage: CyclotomicField(3/2) Traceback (most recent call last): ... TypeError: no conversion of this rational to integer
>>> from sage.all import * >>> CyclotomicField(Integer(3)/Integer(2)) Traceback (most recent call last): ... TypeError: no conversion of this rational to integer
The degree must be nonnegative.
sage: CyclotomicField(-1) Traceback (most recent call last): ... ValueError: n (=-1) must be a positive integer
>>> from sage.all import * >>> CyclotomicField(-Integer(1)) Traceback (most recent call last): ... ValueError: n (=-1) 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
>>> from sage.all import * >>> CyclotomicField(Integer(1)) Cyclotomic Field of order 1 and degree 1
Due to their default embedding into \(\CC\), cyclotomic number fields are all compatible.
sage: cf30 = CyclotomicField(30) sage: cf5 = CyclotomicField(5) sage: cf3 = CyclotomicField(3) sage: cf30.gen() + cf5.gen() + cf3.gen() zeta30^6 + zeta30^5 + zeta30 - 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
>>> from sage.all import * >>> cf30 = CyclotomicField(Integer(30)) >>> cf5 = CyclotomicField(Integer(5)) >>> cf3 = CyclotomicField(Integer(3)) >>> cf30.gen() + cf5.gen() + cf3.gen() zeta30^6 + zeta30^5 + zeta30 - 1 >>> cf6 = CyclotomicField(Integer(6)) ; z6 = cf6.gen(0) >>> cf3 = CyclotomicField(Integer(3)) ; z3 = cf3.gen(0) >>> cf3(z6) zeta3 + 1 >>> cf6(z3) zeta6 - 1 >>> cf9 = CyclotomicField(Integer(9)) ; z9 = cf9.gen(0) >>> cf18 = CyclotomicField(Integer(18)) ; z18 = cf18.gen(0) >>> cf18(z9) zeta18^2 >>> cf9(z18) -zeta9^5 >>> cf18(z3) zeta18^3 - 1 >>> cf18(z6) zeta18^3 >>> cf18(z6)**Integer(2) zeta18^3 - 1 >>> cf9(z3) zeta9^3
- sage.rings.number_field.number_field.NumberField(polynomial, name, check=None, names=True, embedding=None, latex_name=None, assume_disc_small=None, maximize_at_primes=False, structure=None, latex_names=None, **kwds)[source]#
Return the number field (or tower of number fields) defined by the irreducible
polynomial
.INPUT:
polynomial
– a polynomial over \(\QQ\) or a number field, or a list of such polynomials.names
(orname
) – a string or a list of strings, the names of the generatorscheck
– a boolean (default:True
); do type checking and irreducibility checking.embedding
–None
, an element, or a list of elements, the images of the generators in an ambient field (default:None
)latex_names
(orlatex_name
) –None
, a string, or a list of strings (default:None
), how the generators are printed for latex outputassume_disc_small
– a boolean (default:False
); ifTrue
, assume that no square of a prime greater than PARI’s primelimit (which should be 500000); only applies for absolute fields at present.maximize_at_primes
–None
or a list of primes (default:None
); if notNone
, then the maximal order is computed by maximizing only at the primes in this list, which completely avoids having to factor the discriminant, but of course can lead to wrong results; only applies for absolute fields at present.structure
–None
, a list or an instance ofstructure.NumberFieldStructure
(default:None
), internally used to pass in additional structural information, e.g., about the field from which this field is created as a subfield.
We accept
implementation
andprec
attributes for compatibility withAlgebraicExtensionFunctor
but we ignore them as they are not used.EXAMPLES:
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
>>> from sage.all import * >>> z = QQ['z'].gen(0) >>> K = NumberField(z**Integer(2) - Integer(2), 's'); K Number Field in s with defining polynomial z^2 - 2 >>> s = K.gen(0); s s >>> s*s 2 >>> s**Integer(2) 2
Constructing a relative number field:
sage: x = polygen(ZZ, 'x') 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
>>> from sage.all import * >>> x = polygen(ZZ, 'x') >>> K = NumberField(x**Integer(2) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> R = K['t']; (t,) = R._first_ngens(1) >>> L = K.extension(t**Integer(3) + t + a, names=('b',)); (b,) = L._first_ngens(1); L Number Field in b with defining polynomial t^3 + t + a over its base field >>> L.absolute_field('c') Number Field in c with defining polynomial x^6 + 2*x^4 + x^2 - 2 >>> a*b a*b >>> L(a) a >>> L.lift_to_base(b**Integer(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
>>> from sage.all import * >>> k = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = k._first_ngens(1) >>> R = k['z']; (z,) = R._first_ngens(1) >>> m = NumberField(z**Integer(3) + i*z + Integer(3), names=('j',)); (j,) = m._first_ngens(1) >>> 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
>>> from sage.all import * >>> K = NumberField(x**Integer(3) - Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> a**Integer(3) 5 >>> L = NumberField(x**Integer(3) - Integer(5), names=('a',)); (a,) = L._first_ngens(1) >>> K is L True
Equality of number fields depends on the variable name of the defining polynomial:
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 sage: k == m False
>>> from sage.all import * >>> x = polygen(QQ, 'x'); y = polygen(QQ, 'y') >>> k = NumberField(x**Integer(2) + Integer(3), names=('a',)); (a,) = k._first_ngens(1) >>> m = NumberField(y**Integer(2) + Integer(3), names=('a',)); (a,) = m._first_ngens(1) >>> k Number Field in a with defining polynomial x^2 + 3 >>> m Number Field in a with defining polynomial y^2 + 3 >>> k == m False
In case of conflict of the generator name with the name given by the preparser, the name given by the preparser takes precedence:
sage: K.<b> = NumberField(x^2 + 5, 'a'); K Number Field in b with defining polynomial x^2 + 5
>>> from sage.all import * >>> K = NumberField(x**Integer(2) + Integer(5), 'a', names=('b',)); (b,) = K._first_ngens(1); K Number Field in b with defining polynomial x^2 + 5
One can also define number fields with specified embeddings, may be used for arithmetic and deduce relations with other number fields which would not be valid for an abstract number field.
sage: K.<a> = NumberField(x^3 - 2, embedding=1.2) sage: RR.coerce_map_from(K) Composite map: From: Number Field in a with defining polynomial x^3 - 2 with a = 1.259921049894873? To: Real Field with 53 bits of precision Defn: Generic morphism: From: Number Field in a with defining polynomial x^3 - 2 with a = 1.259921049894873? To: Real Lazy Field Defn: a -> 1.259921049894873? then Conversion via _mpfr_ method map: From: Real Lazy Field To: Real Field with 53 bits of precision sage: RR(a) 1.25992104989487 sage: 1.1 + a 2.35992104989487 sage: b = 1/(a+1); b 1/3*a^2 - 1/3*a + 1/3 sage: RR(b) 0.442493334024442 sage: L.<b> = NumberField(x^6 - 2, embedding=1.1) sage: L(a) b^2 sage: a + b b^2 + b
>>> from sage.all import * >>> K = NumberField(x**Integer(3) - Integer(2), embedding=RealNumber('1.2'), names=('a',)); (a,) = K._first_ngens(1) >>> RR.coerce_map_from(K) Composite map: From: Number Field in a with defining polynomial x^3 - 2 with a = 1.259921049894873? To: Real Field with 53 bits of precision Defn: Generic morphism: From: Number Field in a with defining polynomial x^3 - 2 with a = 1.259921049894873? To: Real Lazy Field Defn: a -> 1.259921049894873? then Conversion via _mpfr_ method map: From: Real Lazy Field To: Real Field with 53 bits of precision >>> RR(a) 1.25992104989487 >>> RealNumber('1.1') + a 2.35992104989487 >>> b = Integer(1)/(a+Integer(1)); b 1/3*a^2 - 1/3*a + 1/3 >>> RR(b) 0.442493334024442 >>> L = NumberField(x**Integer(6) - Integer(2), embedding=RealNumber('1.1'), names=('b',)); (b,) = L._first_ngens(1) >>> L(a) b^2 >>> a + b b^2 + b
Note that the image only needs to be specified to enough precision to distinguish roots, and is exactly computed to any needed precision:
sage: RealField(200)(a) 1.2599210498948731647672106072782283505702514647015079800820
>>> from sage.all import * >>> RealField(Integer(200))(a) 1.2599210498948731647672106072782283505702514647015079800820
One can embed into any other field:
sage: K.<a> = NumberField(x^3 - 2, embedding=CC.gen() - 0.6) sage: CC(a) -0.629960524947436 + 1.09112363597172*I sage: # needs sage.rings.padics sage: L = Qp(5) sage: f = polygen(L)^3 - 2 sage: K.<a> = NumberField(x^3 - 2, embedding=f.roots()[0][0]) sage: a + L(1) 4 + 2*5^2 + 2*5^3 + 3*5^4 + 5^5 + 4*5^6 + 2*5^8 + 3*5^9 + 4*5^12 + 4*5^14 + 4*5^15 + 3*5^16 + 5^17 + 5^18 + 2*5^19 + O(5^20) sage: L.<b> = NumberField(x^6 - x^2 + 1/10, embedding=1) sage: K.<a> = NumberField(x^3 - x + 1/10, embedding=b^2) sage: a + b b^2 + b sage: CC(a) == CC(b)^2 True sage: K.coerce_embedding() Generic morphism: From: Number Field in a with defining polynomial x^3 - x + 1/10 with a = b^2 To: Number Field in b with defining polynomial x^6 - x^2 + 1/10 with b = 0.9724449978911874? Defn: a -> b^2
>>> from sage.all import * >>> K = NumberField(x**Integer(3) - Integer(2), embedding=CC.gen() - RealNumber('0.6'), names=('a',)); (a,) = K._first_ngens(1) >>> CC(a) -0.629960524947436 + 1.09112363597172*I >>> # needs sage.rings.padics >>> L = Qp(Integer(5)) >>> f = polygen(L)**Integer(3) - Integer(2) >>> K = NumberField(x**Integer(3) - Integer(2), embedding=f.roots()[Integer(0)][Integer(0)], names=('a',)); (a,) = K._first_ngens(1) >>> a + L(Integer(1)) 4 + 2*5^2 + 2*5^3 + 3*5^4 + 5^5 + 4*5^6 + 2*5^8 + 3*5^9 + 4*5^12 + 4*5^14 + 4*5^15 + 3*5^16 + 5^17 + 5^18 + 2*5^19 + O(5^20) >>> L = NumberField(x**Integer(6) - x**Integer(2) + Integer(1)/Integer(10), embedding=Integer(1), names=('b',)); (b,) = L._first_ngens(1) >>> K = NumberField(x**Integer(3) - x + Integer(1)/Integer(10), embedding=b**Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> a + b b^2 + b >>> CC(a) == CC(b)**Integer(2) True >>> K.coerce_embedding() Generic morphism: From: Number Field in a with defining polynomial x^3 - x + 1/10 with a = b^2 To: Number Field in b with defining polynomial x^6 - x^2 + 1/10 with b = 0.9724449978911874? Defn: a -> b^2
The
QuadraticField
andCyclotomicField
constructors create an embedding by default unless otherwise specified:sage: K.<zeta> = CyclotomicField(15) sage: CC(zeta) 0.913545457642601 + 0.406736643075800*I sage: L.<sqrtn3> = QuadraticField(-3) sage: K(sqrtn3) 2*zeta^5 + 1 sage: sqrtn3 + zeta 2*zeta^5 + zeta + 1
>>> from sage.all import * >>> K = CyclotomicField(Integer(15), names=('zeta',)); (zeta,) = K._first_ngens(1) >>> CC(zeta) 0.913545457642601 + 0.406736643075800*I >>> L = QuadraticField(-Integer(3), names=('sqrtn3',)); (sqrtn3,) = L._first_ngens(1) >>> K(sqrtn3) 2*zeta^5 + 1 >>> sqrtn3 + zeta 2*zeta^5 + zeta + 1
Comparison depends on the (real) embedding specified (or the one selected by default). Note that the codomain of the embedding must be
QQbar
orAA
for this to work (see Issue #20184):sage: N.<g> = NumberField(x^3 + 2, embedding=1) sage: 1 < g False sage: g > 1 False sage: RR(g) -1.25992104989487
>>> from sage.all import * >>> N = NumberField(x**Integer(3) + Integer(2), embedding=Integer(1), names=('g',)); (g,) = N._first_ngens(1) >>> Integer(1) < g False >>> g > Integer(1) False >>> RR(g) -1.25992104989487
If no embedding is specified or is complex, the comparison is not returning something meaningful.:
sage: N.<g> = NumberField(x^3 + 2) sage: 1 < g False sage: g > 1 True
>>> from sage.all import * >>> N = NumberField(x**Integer(3) + Integer(2), names=('g',)); (g,) = N._first_ngens(1) >>> Integer(1) < g False >>> g > Integer(1) True
Since SageMath 6.9, number fields may be defined by polynomials that are not necessarily integral or monic. The only notable practical point is that in the PARI interface, a monic integral polynomial defining the same number field is computed and used:
sage: K.<a> = NumberField(2*x^3 + x + 1) sage: K.pari_polynomial() x^3 - x^2 - 2
>>> from sage.all import * >>> K = NumberField(Integer(2)*x**Integer(3) + x + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> K.pari_polynomial() x^3 - x^2 - 2
Elements and ideals may be converted to and from PARI as follows:
sage: pari(a) Mod(-1/2*y^2 + 1/2*y, y^3 - y^2 - 2) sage: K(pari(a)) a sage: I = K.ideal(a); I Fractional ideal (a) sage: I.pari_hnf() [1, 0, 0; 0, 1, 0; 0, 0, 1/2] sage: K.ideal(I.pari_hnf()) Fractional ideal (a)
>>> from sage.all import * >>> pari(a) Mod(-1/2*y^2 + 1/2*y, y^3 - y^2 - 2) >>> K(pari(a)) a >>> I = K.ideal(a); I Fractional ideal (a) >>> I.pari_hnf() [1, 0, 0; 0, 1, 0; 0, 0, 1/2] >>> K.ideal(I.pari_hnf()) Fractional ideal (a)
Here is an example where the field has non-trivial class group:
sage: L.<b> = NumberField(3*x^2 - 1/5) sage: L.pari_polynomial() x^2 - 15 sage: J = L.primes_above(2)[0]; J Fractional ideal (2, 15*b + 1) sage: J.pari_hnf() [2, 1; 0, 1] sage: L.ideal(J.pari_hnf()) Fractional ideal (2, 15*b + 1)
>>> from sage.all import * >>> L = NumberField(Integer(3)*x**Integer(2) - Integer(1)/Integer(5), names=('b',)); (b,) = L._first_ngens(1) >>> L.pari_polynomial() x^2 - 15 >>> J = L.primes_above(Integer(2))[Integer(0)]; J Fractional ideal (2, 15*b + 1) >>> J.pari_hnf() [2, 1; 0, 1] >>> L.ideal(J.pari_hnf()) Fractional ideal (2, 15*b + 1)
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
>>> from sage.all import * >>> theta = polygen(QQ, 'theta') >>> M = NumberField([theta**Integer(3) + Integer(4), theta**Integer(2) + Integer(3)], names=('z',)); (z,) = M._first_ngens(1); M Number Field in z0 with defining polynomial theta^3 + 4 over its base field
- class sage.rings.number_field.number_field.NumberFieldFactory[source]#
Bases:
UniqueFactory
Factory for number fields.
This should usually not be called directly, use
NumberField()
instead.INPUT:
polynomial
– a polynomial over \(\QQ\) or a number field.name
– a string (default:'a'
), the name of the generatorcheck
– a boolean (default:True
); do type checking and irreducibility checking.embedding
–None
or an element, the images of the generator in an ambient field (default:None
)latex_name
–None
or a string (default:None
), how the generator is printed for latex outputassume_disc_small
– a boolean (default:False
); ifTrue
, assume that no square of a prime greater than PARI’s primelimit (which should be 500000); only applies for absolute fields at present.maximize_at_primes
–None
or a list of primes (default:None
); if notNone
, then the maximal order is computed by maximizing only at the primes in this list, which completely avoids having to factor the discriminant, but of course can lead to wrong results; only applies for absolute fields at present.structure
–None
or an instance ofstructure.NumberFieldStructure
(default:None
), internally used to pass in additional structural information, e.g., about the field from which this field is created as a subfield.
- sage.rings.number_field.number_field.NumberFieldTower(polynomials, names, check=True, embeddings=None, latex_names=None, assume_disc_small=False, maximize_at_primes=None, structures=None)[source]#
Create the tower of number fields defined by the polynomials in the list
polynomials
.INPUT:
polynomials
– a list of polynomials. Each entry must be polynomial which is irreducible over the number field generated by the roots of the following entries.names
– a list of strings or a string, the names of the generators of the relative number fields. If a single string, then names are generated from that string.check
– a boolean (default:True
), whether to check that the polynomials are irreducibleembeddings
– a list of elements orNone
(default:None
), embeddings of the relative number fields in an ambient field.latex_names
– a list of strings orNone
(default:None
), names used to print the generators for latex output.assume_disc_small
– a boolean (default:False
); ifTrue
, assume that no square of a prime greater than PARI’sprimelimit
(which should be 500000); only applies for absolute fields at present.maximize_at_primes
–None
or a list of primes (default:None
); if notNone
, then the maximal order is computed by maximizing only at the primes in this list, which completely avoids having to factor the discriminant, but of course can lead to wrong results; only applies for absolute fields at present.structures
–None
or a list (default:None
), internally used to provide additional information about the number field such as the field from which it was created.
OUTPUT:
The relative number field generated by a root of the first entry of
polynomials
over the relative number field generated by root of the second entry ofpolynomials
… over the number field over which the last entry ofpolynomials
is defined.EXAMPLES:
sage: x = polygen(ZZ, 'x') sage: k.<a,b,c> = NumberField([x^2 + 1, x^2 + 3, x^2 + 5]); k # indirect doctest 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
>>> from sage.all import * >>> x = polygen(ZZ, 'x') >>> k = NumberField([x**Integer(2) + Integer(1), x**Integer(2) + Integer(3), x**Integer(2) + Integer(5)], names=('a', 'b', 'c',)); (a, b, c,) = k._first_ngens(3); k # indirect doctest Number Field in a with defining polynomial x^2 + 1 over its base field >>> a**Integer(2) -1 >>> b**Integer(2) -3 >>> c**Integer(2) -5 >>> (a+b+c)**Integer(2) (2*b + 2*c)*a + 2*c*b - 9
The Galois group is a product of 3 groups of order 2:
sage: k.absolute_field(names='c').galois_group() # needs sage.groups Galois group 8T3 (2[x]2[x]2) with order 8 of x^8 + 36*x^6 + 302*x^4 + 564*x^2 + 121
>>> from sage.all import * >>> k.absolute_field(names='c').galois_group() # needs sage.groups Galois group 8T3 (2[x]2[x]2) with order 8 of x^8 + 36*x^6 + 302*x^4 + 564*x^2 + 121
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
>>> from sage.all import * >>> k.base_field() Number Field in b with defining polynomial x^2 + 3 over its base field >>> k.base_field().base_field() Number Field in c with defining polynomial x^2 + 5 >>> 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
>>> from sage.all import * >>> v = NumberField([x**Integer(3) - Integer(2), x**Integer(3) - Integer(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'); 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
>>> from sage.all import * >>> k = QQ['y']; (y,) = k._first_ngens(1) >>> m = NumberField([y**Integer(3) - Integer(3), x**Integer(2) + x + Integer(1), y**Integer(3) + Integer(2)], 'beta'); m Number Field in beta0 with defining polynomial y^3 - 3 over its base field >>> 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]); 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
>>> from sage.all import * >>> K = NumberField([x**Integer(2) + Integer(3), x**Integer(2) + Integer(2), x**Integer(2) + Integer(1)], names=('a',)); (a,) = K._first_ngens(1); K Number Field in a0 with defining polynomial x^2 + 3 over its base field >>> K.base_field() Number Field in a1 with defining polynomial x^2 + 2 over its base field >>> K.base_field().base_field() Number Field in a2 with defining polynomial x^2 + 1
LaTeX versions of generator names can be specified either as:
sage: K = NumberField([x^3 - 2, x^3 - 3, x^3 - 5], names=['a', 'b', 'c'], ....: latex_names=[r'\alpha', r'\beta', r'\gamma']) sage: K.inject_variables(verbose=False) sage: latex(a + b + c) \alpha + \beta + \gamma
>>> from sage.all import * >>> K = NumberField([x**Integer(3) - Integer(2), x**Integer(3) - Integer(3), x**Integer(3) - Integer(5)], names=['a', 'b', 'c'], ... latex_names=[r'\alpha', r'\beta', r'\gamma']) >>> K.inject_variables(verbose=False) >>> latex(a + b + c) \alpha + \beta + \gamma
or as:
sage: K = NumberField([x^3 - 2, x^3 - 3, x^3 - 5], names='a', latex_names=r'\alpha') sage: K.inject_variables() Defining a0, a1, a2 sage: latex(a0 + a1 + a2) \alpha_{0} + \alpha_{1} + \alpha_{2}
>>> from sage.all import * >>> K = NumberField([x**Integer(3) - Integer(2), x**Integer(3) - Integer(3), x**Integer(3) - Integer(5)], names='a', latex_names=r'\alpha') >>> K.inject_variables() Defining a0, a1, a2 >>> latex(a0 + a1 + a2) \alpha_{0} + \alpha_{1} + \alpha_{2}
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
>>> from sage.all import * >>> K = NumberField([x**Integer(2) + p for p in [Integer(2),Integer(3),Integer(5),Integer(7)]], names=('a2', 'a3', 'a5', 'a7',)); (a2, a3, a5, a7,) = K._first_ngens(4); K Number Field in a2 with defining polynomial x^2 + 2 over its base field >>> a2**Integer(2) -2 >>> a3**Integer(2) -3 >>> (a2+a3+a5+a7)**Integer(3) ((6*a5 + 6*a7)*a3 + 6*a7*a5 - 47)*a2 + (6*a7*a5 - 45)*a3 - 41*a5 - 37*a7
The function can also be called by name:
sage: NumberFieldTower([x^2 + 1, x^2 + 2], ['a','b']) Number Field in a with defining polynomial x^2 + 1 over its base field
>>> from sage.all import * >>> NumberFieldTower([x**Integer(2) + Integer(1), x**Integer(2) + Integer(2)], ['a','b']) Number Field in a with defining polynomial x^2 + 1 over its base field
- class sage.rings.number_field.number_field.NumberField_absolute(polynomial, name, latex_name=None, check=True, embedding=None, assume_disc_small=False, maximize_at_primes=None, structure=None)[source]#
Bases:
NumberField_generic
Function to initialize an absolute number field.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K = NumberField(x^17 + 3, 'a'); K Number Field in a with defining polynomial x^17 + 3 sage: type(K) <class 'sage.rings.number_field.number_field.NumberField_absolute_with_category'> sage: TestSuite(K).run()
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(17) + Integer(3), 'a'); K Number Field in a with defining polynomial x^17 + 3 >>> type(K) <class 'sage.rings.number_field.number_field.NumberField_absolute_with_category'> >>> TestSuite(K).run()
- abs_val(v, iota, prec=None)[source]#
Return the value \(|\iota|_{v}\).
INPUT:
v
– a place ofK
, finite (a fractional ideal) or infinite (element ofK.places(prec)
)iota
– an element ofK
prec
– (default:None
) the precision of the real field
OUTPUT:
The absolute value as a real number
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<xi> = NumberField(x^3 - 3) sage: phi_real = K.places()[0] sage: phi_complex = K.places()[1] sage: v_fin = tuple(K.primes_above(3))[0] sage: K.abs_val(phi_real, xi^2) 2.08008382305190 sage: K.abs_val(phi_complex, xi^2) 4.32674871092223 sage: K.abs_val(v_fin, xi^2) 0.111111111111111
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) - Integer(3), names=('xi',)); (xi,) = K._first_ngens(1) >>> phi_real = K.places()[Integer(0)] >>> phi_complex = K.places()[Integer(1)] >>> v_fin = tuple(K.primes_above(Integer(3)))[Integer(0)] >>> K.abs_val(phi_real, xi**Integer(2)) 2.08008382305190 >>> K.abs_val(phi_complex, xi**Integer(2)) 4.32674871092223 >>> K.abs_val(v_fin, xi**Integer(2)) 0.111111111111111
Check that Issue #28345 is fixed:
sage: K.abs_val(v_fin, K.zero()) 0.000000000000000
>>> from sage.all import * >>> K.abs_val(v_fin, K.zero()) 0.000000000000000
- absolute_degree()[source]#
A synonym for
degree()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<i> = NumberField(x^2 + 1) sage: K.absolute_degree() 2
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.absolute_degree() 2
- absolute_different()[source]#
A synonym for
different()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<i> = NumberField(x^2 + 1) sage: K.absolute_different() Fractional ideal (2)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.absolute_different() Fractional ideal (2)
- absolute_discriminant()[source]#
A synonym for
discriminant()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<i> = NumberField(x^2 + 1) sage: K.absolute_discriminant() -4
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.absolute_discriminant() -4
- absolute_generator()[source]#
An alias for
sage.rings.number_field.number_field.NumberField_generic.gen()
. This is provided for consistency with relative fields, where the element returned bysage.rings.number_field.number_field_rel.NumberField_relative.gen()
only generates the field over its base field (not necessarily over \(\QQ\)).EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^2 - 17) sage: K.absolute_generator() a
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) - Integer(17), names=('a',)); (a,) = K._first_ngens(1) >>> K.absolute_generator() a
- absolute_polynomial()[source]#
Return absolute polynomial that defines this absolute field. This is the same as
polynomial()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^2 + 1) sage: K.absolute_polynomial () x^2 + 1
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> K.absolute_polynomial () x^2 + 1
- absolute_vector_space(*args, **kwds)[source]#
Return vector space over \(\QQ\) 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
vector_space()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^3 - 5) sage: K.absolute_vector_space() (Vector space of dimension 3 over Rational Field, Isomorphism map: From: Vector space of dimension 3 over Rational Field To: Number Field in a with defining polynomial x^3 - 5, Isomorphism map: From: Number Field in a with defining polynomial x^3 - 5 To: Vector space of dimension 3 over Rational Field)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) - Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> K.absolute_vector_space() (Vector space of dimension 3 over Rational Field, Isomorphism map: From: Vector space of dimension 3 over Rational Field To: Number Field in a with defining polynomial x^3 - 5, Isomorphism map: From: Number Field in a with defining polynomial x^3 - 5 To: Vector space of dimension 3 over Rational Field)
- automorphisms()[source]#
Compute all Galois automorphisms of
self
.This uses PARI’s pari:nfgaloisconj and is much faster than root finding for many fields.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^2 + 10000) sage: K.automorphisms() [ Ring endomorphism of Number Field in a with defining polynomial x^2 + 10000 Defn: a |--> a, Ring endomorphism of Number Field in a with defining polynomial x^2 + 10000 Defn: a |--> -a ]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(10000), names=('a',)); (a,) = K._first_ngens(1) >>> K.automorphisms() [ Ring endomorphism of Number Field in a with defining polynomial x^2 + 10000 Defn: a |--> a, Ring endomorphism of Number Field in a with defining polynomial x^2 + 10000 Defn: a |--> -a ]
Here’s a larger example, that would take some time if we found roots instead of using PARI’s specialized machinery:
sage: K = NumberField(x^6 - x^4 - 2*x^2 + 1, 'a') sage: len(K.automorphisms()) 2
>>> from sage.all import * >>> K = NumberField(x**Integer(6) - x**Integer(4) - Integer(2)*x**Integer(2) + Integer(1), 'a') >>> len(K.automorphisms()) 2
\(L\) is the Galois closure of \(K\):
sage: L = NumberField(x^24 - 84*x^22 + 2814*x^20 - 15880*x^18 - 409563*x^16 ....: - 8543892*x^14 + 25518202*x^12 + 32831026956*x^10 ....: - 672691027218*x^8 - 4985379093428*x^6 + 320854419319140*x^4 ....: + 817662865724712*x^2 + 513191437605441, 'a') sage: len(L.automorphisms()) 24
>>> from sage.all import * >>> L = NumberField(x**Integer(24) - Integer(84)*x**Integer(22) + Integer(2814)*x**Integer(20) - Integer(15880)*x**Integer(18) - Integer(409563)*x**Integer(16) ... - Integer(8543892)*x**Integer(14) + Integer(25518202)*x**Integer(12) + Integer(32831026956)*x**Integer(10) ... - Integer(672691027218)*x**Integer(8) - Integer(4985379093428)*x**Integer(6) + Integer(320854419319140)*x**Integer(4) ... + Integer(817662865724712)*x**Integer(2) + Integer(513191437605441), 'a') >>> len(L.automorphisms()) 24
Number fields defined by non-monic and non-integral polynomials are supported (Issue #252):
sage: R.<x> = QQ[] sage: f = 7/9*x^3 + 7/3*x^2 - 56*x + 123 sage: K.<a> = NumberField(f) sage: A = K.automorphisms(); A [ Ring endomorphism of Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 Defn: a |--> a, Ring endomorphism of Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 Defn: a |--> -7/15*a^2 - 18/5*a + 96/5, Ring endomorphism of Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 Defn: a |--> 7/15*a^2 + 13/5*a - 111/5 ] sage: prod(x - sigma(a) for sigma in A) == f.monic() True
>>> from sage.all import * >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> f = Integer(7)/Integer(9)*x**Integer(3) + Integer(7)/Integer(3)*x**Integer(2) - Integer(56)*x + Integer(123) >>> K = NumberField(f, names=('a',)); (a,) = K._first_ngens(1) >>> A = K.automorphisms(); A [ Ring endomorphism of Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 Defn: a |--> a, Ring endomorphism of Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 Defn: a |--> -7/15*a^2 - 18/5*a + 96/5, Ring endomorphism of Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 Defn: a |--> 7/15*a^2 + 13/5*a - 111/5 ] >>> prod(x - sigma(a) for sigma in A) == f.monic() True
- base_field()[source]#
Return the base field of
self
, which is alwaysQQ
.EXAMPLES:
sage: K = CyclotomicField(5) sage: K.base_field() Rational Field
>>> from sage.all import * >>> K = CyclotomicField(Integer(5)) >>> K.base_field() Rational Field
- change_names(names)[source]#
Return number field isomorphic to
self
but with the given generator name.INPUT:
names
– should be exactly one variable name.
Also,
K.structure()
returnsfrom_K
andto_K
, wherefrom_K
is an isomorphism from \(K\) toself
andto_K
is an isomorphism fromself
to \(K\).EXAMPLES:
sage: x = polygen(QQ, 'x') 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] Isomorphism given by variable name change map: From: Number Field in ww with defining polynomial x^2 + 3 To: Number Field in z with defining polynomial x^2 + 3 sage: L.structure()[0](ww + 5/3) z + 5/3
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(3), names=('z',)); (z,) = K._first_ngens(1); K Number Field in z with defining polynomial x^2 + 3 >>> L = K.change_names(names=('ww',)); (ww,) = L._first_ngens(1) >>> L Number Field in ww with defining polynomial x^2 + 3 >>> L.structure()[Integer(0)] Isomorphism given by variable name change map: From: Number Field in ww with defining polynomial x^2 + 3 To: Number Field in z with defining polynomial x^2 + 3 >>> L.structure()[Integer(0)](ww + Integer(5)/Integer(3)) z + 5/3
- elements_of_bounded_height(**kwds)[source]#
Return an iterator over the elements of
self
with relative multiplicative height at mostbound
.This algorithm computes 2 lists: \(L\) containing elements \(x\) in \(K\) such that \(H_k(x) \leq B\), and a list \(L'\) containing elements \(x\) in \(K\) that, due to floating point issues, may be slightly larger than the bound. This can be controlled by lowering the tolerance.
In the current implementation, both lists \((L,L')\) are merged and returned in form of iterator.
ALGORITHM:
This is an implementation of the revised algorithm (Algorithm 4) in [DK2013]. Algorithm 5 is used for imaginary quadratic fields.
INPUT:
kwds:
bound
– a real numbertolerance
– (default: 0.01) a rational number in \((0,1]\)precision
– (default: 53) a positive integer
OUTPUT:
an iterator of number field elements
EXAMPLES:
There are no elements in a number field with multiplicative height less than 1:
sage: x = polygen(QQ, 'x') sage: K.<g> = NumberField(x^5 - x + 19) sage: list(K.elements_of_bounded_height(bound=0.9)) []
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(5) - x + Integer(19), names=('g',)); (g,) = K._first_ngens(1) >>> list(K.elements_of_bounded_height(bound=RealNumber('0.9'))) []
The only elements in a number field of height 1 are 0 and the roots of unity:
sage: K.<a> = NumberField(x^2 + x + 1) sage: list(K.elements_of_bounded_height(bound=1)) [0, a + 1, a, -1, -a - 1, -a, 1]
>>> from sage.all import * >>> K = NumberField(x**Integer(2) + x + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> list(K.elements_of_bounded_height(bound=Integer(1))) [0, a + 1, a, -1, -a - 1, -a, 1]
sage: K.<a> = CyclotomicField(20) sage: len(list(K.elements_of_bounded_height(bound=1))) 21
>>> from sage.all import * >>> K = CyclotomicField(Integer(20), names=('a',)); (a,) = K._first_ngens(1) >>> len(list(K.elements_of_bounded_height(bound=Integer(1)))) 21
The elements in the output iterator all have relative multiplicative height at most the input bound:
sage: K.<a> = NumberField(x^6 + 2) sage: L = K.elements_of_bounded_height(bound=5) sage: for t in L: ....: exp(6*t.global_height()) 1.00000000000000 1.00000000000000 1.00000000000000 2.00000000000000 2.00000000000000 2.00000000000000 2.00000000000000 4.00000000000000 4.00000000000000 4.00000000000000 4.00000000000000
>>> from sage.all import * >>> K = NumberField(x**Integer(6) + Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.elements_of_bounded_height(bound=Integer(5)) >>> for t in L: ... exp(Integer(6)*t.global_height()) 1.00000000000000 1.00000000000000 1.00000000000000 2.00000000000000 2.00000000000000 2.00000000000000 2.00000000000000 4.00000000000000 4.00000000000000 4.00000000000000 4.00000000000000
sage: K.<a> = NumberField(x^2 - 71) sage: L = K.elements_of_bounded_height(bound=20) sage: all(exp(2*t.global_height()) <= 20 for t in L) # long time (5 s) True
>>> from sage.all import * >>> K = NumberField(x**Integer(2) - Integer(71), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.elements_of_bounded_height(bound=Integer(20)) >>> all(exp(Integer(2)*t.global_height()) <= Integer(20) for t in L) # long time (5 s) True
sage: K.<a> = NumberField(x^2 + 17) sage: L = K.elements_of_bounded_height(bound=120) sage: len(list(L)) 9047
>>> from sage.all import * >>> K = NumberField(x**Integer(2) + Integer(17), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.elements_of_bounded_height(bound=Integer(120)) >>> len(list(L)) 9047
sage: K.<a> = NumberField(x^4 - 5) sage: L = K.elements_of_bounded_height(bound=50) sage: len(list(L)) # long time (2 s) 2163
>>> from sage.all import * >>> K = NumberField(x**Integer(4) - Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.elements_of_bounded_height(bound=Integer(50)) >>> len(list(L)) # long time (2 s) 2163
sage: K.<a> = CyclotomicField(13) sage: L = K.elements_of_bounded_height(bound=2) sage: len(list(L)) # long time (3 s) 27
>>> from sage.all import * >>> K = CyclotomicField(Integer(13), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.elements_of_bounded_height(bound=Integer(2)) >>> len(list(L)) # long time (3 s) 27
sage: K.<a> = NumberField(x^6 + 2) sage: L = K.elements_of_bounded_height(bound=60, precision=100) sage: len(list(L)) # long time (5 s) 1899
>>> from sage.all import * >>> K = NumberField(x**Integer(6) + Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.elements_of_bounded_height(bound=Integer(60), precision=Integer(100)) >>> len(list(L)) # long time (5 s) 1899
sage: K.<a> = NumberField(x^4 - x^3 - 3*x^2 + x + 1) sage: L = K.elements_of_bounded_height(bound=10, tolerance=0.1) sage: len(list(L)) 99
>>> from sage.all import * >>> K = NumberField(x**Integer(4) - x**Integer(3) - Integer(3)*x**Integer(2) + x + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.elements_of_bounded_height(bound=Integer(10), tolerance=RealNumber('0.1')) >>> len(list(L)) 99
AUTHORS:
John Doyle (2013)
David Krumm (2013)
Raman Raghukul (2018)
- embeddings(K)[source]#
Compute all field embeddings of this field 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 this field into \(K\) is put first in the list.
INPUT:
K
– a field
EXAMPLES:
sage: # needs sage.groups sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^3 - 2) sage: L.<a1> = K.galois_closure(); L Number Field in a1 with defining polynomial x^6 + 108 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 + 108 Defn: a |--> 1/18*a1^4 sage: K.embeddings(L) is K.embeddings(L) True
>>> from sage.all import * >>> # needs sage.groups >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.galois_closure(names=('a1',)); (a1,) = L._first_ngens(1); L Number Field in a1 with defining polynomial x^6 + 108 >>> K.embeddings(L)[Integer(0)] Ring morphism: From: Number Field in a with defining polynomial x^3 - 2 To: Number Field in a1 with defining polynomial x^6 + 108 Defn: a |--> 1/18*a1^4 >>> 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 with a = 2.645751311064591?*I 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 with a = 2.645751311064591?*I To: Cyclotomic Field of order 7 and degree 6 Defn: a |--> -2*zeta7^4 - 2*zeta7^2 - 2*zeta7 - 1 ]
>>> from sage.all import * >>> L = QuadraticField(-Integer(7), names=('a',)); (a,) = L._first_ngens(1) >>> K = CyclotomicField(Integer(7)) >>> L.embeddings(K) [ Ring morphism: From: Number Field in a with defining polynomial x^2 + 7 with a = 2.645751311064591?*I 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 with a = 2.645751311064591?*I 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: x = polygen(QQ, 'x') 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 ]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> 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 ]
Test that Issue #15053 is fixed:
sage: K = NumberField(x^3 - 2, 'a') sage: K.embeddings(GF(3)) []
>>> from sage.all import * >>> K = NumberField(x**Integer(3) - Integer(2), 'a') >>> K.embeddings(GF(Integer(3))) []
- free_module(base=None, basis=None, map=True)[source]#
Return a vector space \(V\) and isomorphisms
self
\(\to\) \(V\) and \(V\) \(\to\)self
.INPUT:
base
– a subfield (default:None
); the returned vector space is over this subfield \(R\), which defaults to the base field of this function fieldbasis
– a basis for this field over the basemaps
– boolean (defaultTrue
), whether to return \(R\)-linear maps to and from \(V\)
OUTPUT:
\(V\) – a vector space over the rational numbers
from_V
– an isomorphism from \(V\) toself
(if requested)to_V
– an isomorphism fromself
to \(V\) (if requested)
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: k.<a> = NumberField(x^3 + 2) sage: V, from_V, to_V = k.free_module() 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 map: 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)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(3) + Integer(2), names=('a',)); (a,) = k._first_ngens(1) >>> V, from_V, to_V = k.free_module() >>> from_V(V([Integer(1),Integer(2),Integer(3)])) 3*a^2 + 2*a + 1 >>> to_V(Integer(1) + Integer(2)*a + Integer(3)*a**Integer(2)) (1, 2, 3) >>> V Vector space of dimension 3 over Rational Field >>> to_V Isomorphism map: From: Number Field in a with defining polynomial x^3 + 2 To: Vector space of dimension 3 over Rational Field >>> from_V(to_V(Integer(2)/Integer(3)*a - Integer(5)/Integer(8))) 2/3*a - 5/8 >>> to_V(from_V(V([Integer(0),-Integer(1)/Integer(7),Integer(0)]))) (0, -1/7, 0)
- galois_closure(names=None, map=False)[source]#
Return number field \(K\) that is the Galois closure of
self
, i.e., is generated by all roots of the defining polynomial ofself
, and possibly an embedding ofself
into \(K\).INPUT:
names
– variable name for Galois closuremap
– (default:False
) also return an embedding ofself
into \(K\)
EXAMPLES:
sage: # needs sage.groups sage: x = polygen(QQ, 'x') 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(names=("a3")).order() 8
>>> from sage.all import * >>> # needs sage.groups >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(4) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> M = K.galois_closure('b'); M Number Field in b with defining polynomial x^8 + 28*x^4 + 2500 >>> L = K.galois_closure(names=('a2',)); (a2,) = L._first_ngens(1); L Number Field in a2 with defining polynomial x^8 + 28*x^4 + 2500 >>> K.galois_group(names=("a3")).order() 8
sage: # needs sage.groups 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 sage: # needs sage.groups sage: L, phi = K.galois_closure('b', map=True) sage: L Number Field in b with defining polynomial x^8 + 28*x^4 + 2500 sage: phi Ring morphism: From: Number Field in a with defining polynomial x^4 - 2 To: Number Field in b with defining polynomial x^8 + 28*x^4 + 2500 Defn: a |--> 1/240*b^5 - 41/120*b
>>> from sage.all import * >>> # needs sage.groups >>> phi = K.embeddings(L)[Integer(0)] >>> phi(K.gen(0)) 1/120*a2^5 + 19/60*a2 >>> phi(K.gen(0)).minpoly() x^4 - 2 >>> # needs sage.groups >>> L, phi = K.galois_closure('b', map=True) >>> L Number Field in b with defining polynomial x^8 + 28*x^4 + 2500 >>> phi Ring morphism: From: Number Field in a with defining polynomial x^4 - 2 To: Number Field in b with defining polynomial x^8 + 28*x^4 + 2500 Defn: a |--> 1/240*b^5 - 41/120*b
A cyclotomic field is already Galois:
sage: # needs sage.groups sage: K.<a> = NumberField(cyclotomic_polynomial(23)) sage: L.<z> = K.galois_closure() sage: L Number Field in z with defining polynomial x^22 + x^21 + x^20 + x^19 + x^18 + x^17 + x^16 + x^15 + x^14 + x^13 + x^12 + x^11 + x^10 + x^9 + x^8 + x^7 + x^6 + x^5 + x^4 + x^3 + x^2 + x + 1
>>> from sage.all import * >>> # needs sage.groups >>> K = NumberField(cyclotomic_polynomial(Integer(23)), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.galois_closure(names=('z',)); (z,) = L._first_ngens(1) >>> L Number Field in z with defining polynomial x^22 + x^21 + x^20 + x^19 + x^18 + x^17 + x^16 + x^15 + x^14 + x^13 + x^12 + x^11 + x^10 + x^9 + x^8 + x^7 + x^6 + x^5 + x^4 + x^3 + x^2 + x + 1
- hilbert_conductor(a, b)[source]#
This is the product of all (finite) primes where the Hilbert symbol is \(-1\). What is the same, this is the (reduced) discriminant of the quaternion algebra \((a,b)\) over a number field.
INPUT:
a
,b
– elements of the number fieldself
OUTPUT:
squarefree ideal of the ring of integers of
self
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: F.<a> = NumberField(x^2 - x - 1) sage: F.hilbert_conductor(2*a, F(-1)) Fractional ideal (2) sage: K.<b> = NumberField(x^3 - 4*x + 2) sage: K.hilbert_conductor(K(2), K(-2)) Fractional ideal (1) sage: K.hilbert_conductor(K(2*b), K(-2)) Fractional ideal (b^2 + b - 2)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> F = NumberField(x**Integer(2) - x - Integer(1), names=('a',)); (a,) = F._first_ngens(1) >>> F.hilbert_conductor(Integer(2)*a, F(-Integer(1))) Fractional ideal (2) >>> K = NumberField(x**Integer(3) - Integer(4)*x + Integer(2), names=('b',)); (b,) = K._first_ngens(1) >>> K.hilbert_conductor(K(Integer(2)), K(-Integer(2))) Fractional ideal (1) >>> K.hilbert_conductor(K(Integer(2)*b), K(-Integer(2))) Fractional ideal (b^2 + b - 2)
AUTHOR:
Aly Deines
- hilbert_symbol(a, b, P=None)[source]#
Return the Hilbert symbol \((a,b)_P\) for a prime \(P\) of
self
and non-zero elements \(a\) and \(b\) ofself
.If \(P\) is omitted, return the global Hilbert symbol \((a,b)\) instead.
INPUT:
a
,b
– elements ofself
P
– (default:None
) IfNone
, compute the global symbol. Otherwise, \(P\) should be either a prime ideal ofself
(which may also be given as a generator or set of generators) or a real or complex embedding.
OUTPUT:
If \(a\) or \(b\) is zero, returns 0.
If \(a\) and \(b\) are non-zero and \(P\) is specified, returns the Hilbert symbol \((a,b)_P\), which is \(1\) if the equation \(a x^2 + b y^2 = 1\) has a solution in the completion of
self
at \(P\), and is \(-1\) otherwise.If \(a\) and \(b\) are non-zero and \(P\) is unspecified, returns \(1\) if the equation has a solution in
self
and \(-1\) otherwise.EXAMPLES:
Some global examples:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^2 - 23) sage: K.hilbert_symbol(0, a + 5) 0 sage: K.hilbert_symbol(a, 0) 0 sage: K.hilbert_symbol(-a, a + 1) 1 sage: K.hilbert_symbol(-a, a + 2) -1 sage: K.hilbert_symbol(a, a + 5) -1
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) - Integer(23), names=('a',)); (a,) = K._first_ngens(1) >>> K.hilbert_symbol(Integer(0), a + Integer(5)) 0 >>> K.hilbert_symbol(a, Integer(0)) 0 >>> K.hilbert_symbol(-a, a + Integer(1)) 1 >>> K.hilbert_symbol(-a, a + Integer(2)) -1 >>> K.hilbert_symbol(a, a + Integer(5)) -1
That the latter two are unsolvable should be visible in local obstructions. For the first, this is a prime ideal above 19. For the second, the ramified prime above 23:
sage: K.hilbert_symbol(-a, a + 2, a + 2) -1 sage: K.hilbert_symbol(a, a + 5, K.ideal(23).factor()[0][0]) -1
>>> from sage.all import * >>> K.hilbert_symbol(-a, a + Integer(2), a + Integer(2)) -1 >>> K.hilbert_symbol(a, a + Integer(5), K.ideal(Integer(23)).factor()[Integer(0)][Integer(0)]) -1
More local examples:
sage: K.hilbert_symbol(a, 0, K.fractional_ideal(5)) 0 sage: K.hilbert_symbol(a, a + 5, K.fractional_ideal(5)) 1 sage: K.hilbert_symbol(a + 1, 13, (a+6)*K) -1 sage: [emb1, emb2] = K.embeddings(AA) sage: K.hilbert_symbol(a, -1, emb1) -1 sage: K.hilbert_symbol(a, -1, emb2) 1
>>> from sage.all import * >>> K.hilbert_symbol(a, Integer(0), K.fractional_ideal(Integer(5))) 0 >>> K.hilbert_symbol(a, a + Integer(5), K.fractional_ideal(Integer(5))) 1 >>> K.hilbert_symbol(a + Integer(1), Integer(13), (a+Integer(6))*K) -1 >>> [emb1, emb2] = K.embeddings(AA) >>> K.hilbert_symbol(a, -Integer(1), emb1) -1 >>> K.hilbert_symbol(a, -Integer(1), emb2) 1
Ideals P can be given by generators:
sage: K.<a> = NumberField(x^5 - 23) sage: pi = 2*a^4 + 3*a^3 + 4*a^2 + 15*a + 11 sage: K.hilbert_symbol(a, a + 5, pi) 1 sage: rho = 2*a^4 + 3*a^3 + 4*a^2 + 15*a + 11 sage: K.hilbert_symbol(a, a + 5, rho) 1
>>> from sage.all import * >>> K = NumberField(x**Integer(5) - Integer(23), names=('a',)); (a,) = K._first_ngens(1) >>> pi = Integer(2)*a**Integer(4) + Integer(3)*a**Integer(3) + Integer(4)*a**Integer(2) + Integer(15)*a + Integer(11) >>> K.hilbert_symbol(a, a + Integer(5), pi) 1 >>> rho = Integer(2)*a**Integer(4) + Integer(3)*a**Integer(3) + Integer(4)*a**Integer(2) + Integer(15)*a + Integer(11) >>> K.hilbert_symbol(a, a + Integer(5), rho) 1
This also works for non-principal ideals:
sage: K.<a> = QuadraticField(-5) sage: P = K.ideal(3).factor()[0][0] sage: P.gens_reduced() # random, could be the other factor (3, a + 1) sage: K.hilbert_symbol(a, a + 3, P) 1 sage: K.hilbert_symbol(a, a + 3, [3, a+1]) 1
>>> from sage.all import * >>> K = QuadraticField(-Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> P = K.ideal(Integer(3)).factor()[Integer(0)][Integer(0)] >>> P.gens_reduced() # random, could be the other factor (3, a + 1) >>> K.hilbert_symbol(a, a + Integer(3), P) 1 >>> K.hilbert_symbol(a, a + Integer(3), [Integer(3), a+Integer(1)]) 1
Primes above 2:
sage: K.<a> = NumberField(x^5 - 23) sage: p = [p[0] for p in (2*K).factor() if p[0].norm() == 16][0] sage: K.hilbert_symbol(a, a + 5, p) 1 sage: K.hilbert_symbol(a, 2, p) 1 sage: K.hilbert_symbol(-1, a - 2, p) -1
>>> from sage.all import * >>> K = NumberField(x**Integer(5) - Integer(23), names=('a',)); (a,) = K._first_ngens(1) >>> p = [p[Integer(0)] for p in (Integer(2)*K).factor() if p[Integer(0)].norm() == Integer(16)][Integer(0)] >>> K.hilbert_symbol(a, a + Integer(5), p) 1 >>> K.hilbert_symbol(a, Integer(2), p) 1 >>> K.hilbert_symbol(-Integer(1), a - Integer(2), p) -1
Various real fields are allowed:
sage: K.<a> = NumberField(x^3+x+1) sage: K.hilbert_symbol(a/3, 1/2, K.embeddings(RDF)[0]) 1 sage: K.hilbert_symbol(a/5, -1, K.embeddings(RR)[0]) -1 sage: [K.hilbert_symbol(a, -1, e) for e in K.embeddings(AA)] [-1]
>>> from sage.all import * >>> K = NumberField(x**Integer(3)+x+Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> K.hilbert_symbol(a/Integer(3), Integer(1)/Integer(2), K.embeddings(RDF)[Integer(0)]) 1 >>> K.hilbert_symbol(a/Integer(5), -Integer(1), K.embeddings(RR)[Integer(0)]) -1 >>> [K.hilbert_symbol(a, -Integer(1), e) for e in K.embeddings(AA)] [-1]
Real embeddings are not allowed to be disguised as complex embeddings:
sage: K.<a> = QuadraticField(5) sage: K.hilbert_symbol(-1, -1, K.embeddings(CC)[0]) Traceback (most recent call last): ... ValueError: Possibly real place (=Ring morphism: From: Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? To: Complex Field with 53 bits of precision Defn: a |--> -2.23606797749979) given as complex embedding in hilbert_symbol. Is it real or complex? sage: K.hilbert_symbol(-1, -1, K.embeddings(QQbar)[0]) Traceback (most recent call last): ... ValueError: Possibly real place (=Ring morphism: From: Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? To: Algebraic Field Defn: a |--> -2.236067977499790?) given as complex embedding in hilbert_symbol. Is it real or complex? sage: K.<b> = QuadraticField(-5) sage: K.hilbert_symbol(-1, -1, K.embeddings(CDF)[0]) 1 sage: K.hilbert_symbol(-1, -1, K.embeddings(QQbar)[0]) 1
>>> from sage.all import * >>> K = QuadraticField(Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> K.hilbert_symbol(-Integer(1), -Integer(1), K.embeddings(CC)[Integer(0)]) Traceback (most recent call last): ... ValueError: Possibly real place (=Ring morphism: From: Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? To: Complex Field with 53 bits of precision Defn: a |--> -2.23606797749979) given as complex embedding in hilbert_symbol. Is it real or complex? >>> K.hilbert_symbol(-Integer(1), -Integer(1), K.embeddings(QQbar)[Integer(0)]) Traceback (most recent call last): ... ValueError: Possibly real place (=Ring morphism: From: Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? To: Algebraic Field Defn: a |--> -2.236067977499790?) given as complex embedding in hilbert_symbol. Is it real or complex? >>> K = QuadraticField(-Integer(5), names=('b',)); (b,) = K._first_ngens(1) >>> K.hilbert_symbol(-Integer(1), -Integer(1), K.embeddings(CDF)[Integer(0)]) 1 >>> K.hilbert_symbol(-Integer(1), -Integer(1), K.embeddings(QQbar)[Integer(0)]) 1
\(a\) and \(b\) do not have to be integral or coprime:
sage: K.<i> = QuadraticField(-1) sage: K.hilbert_symbol(1/2, 1/6, 3*K) 1 sage: p = 1 + i sage: K.hilbert_symbol(p, p, p) 1 sage: K.hilbert_symbol(p, 3*p, p) -1 sage: K.hilbert_symbol(3, p, p) -1 sage: K.hilbert_symbol(1/3, 1/5, 1 + i) 1 sage: L = QuadraticField(5, 'a') sage: L.hilbert_symbol(-3, -1/2, 2) 1
>>> from sage.all import * >>> K = QuadraticField(-Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.hilbert_symbol(Integer(1)/Integer(2), Integer(1)/Integer(6), Integer(3)*K) 1 >>> p = Integer(1) + i >>> K.hilbert_symbol(p, p, p) 1 >>> K.hilbert_symbol(p, Integer(3)*p, p) -1 >>> K.hilbert_symbol(Integer(3), p, p) -1 >>> K.hilbert_symbol(Integer(1)/Integer(3), Integer(1)/Integer(5), Integer(1) + i) 1 >>> L = QuadraticField(Integer(5), 'a') >>> L.hilbert_symbol(-Integer(3), -Integer(1)/Integer(2), Integer(2)) 1
Various other examples:
sage: K.<a> = NumberField(x^3 + x + 1) sage: K.hilbert_symbol(-6912, 24, -a^2 - a - 2) 1 sage: K.<a> = NumberField(x^5 - 23) sage: P = K.ideal(-1105*a^4 + 1541*a^3 - 795*a^2 - 2993*a + 11853) sage: Q = K.ideal(-7*a^4 + 13*a^3 - 13*a^2 - 2*a + 50) sage: b = -a+5 sage: K.hilbert_symbol(a, b, P) 1 sage: K.hilbert_symbol(a, b, Q) 1 sage: K.<a> = NumberField(x^5 - 23) sage: P = K.ideal(-1105*a^4 + 1541*a^3 - 795*a^2 - 2993*a + 11853) sage: K.hilbert_symbol(a, a + 5, P) 1 sage: K.hilbert_symbol(a, 2, P) 1 sage: K.hilbert_symbol(a + 5, 2, P) -1 sage: K.<a> = NumberField(x^3 - 4*x + 2) sage: K.hilbert_symbol(2, -2, K.primes_above(2)[0]) 1
>>> from sage.all import * >>> K = NumberField(x**Integer(3) + x + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> K.hilbert_symbol(-Integer(6912), Integer(24), -a**Integer(2) - a - Integer(2)) 1 >>> K = NumberField(x**Integer(5) - Integer(23), names=('a',)); (a,) = K._first_ngens(1) >>> P = K.ideal(-Integer(1105)*a**Integer(4) + Integer(1541)*a**Integer(3) - Integer(795)*a**Integer(2) - Integer(2993)*a + Integer(11853)) >>> Q = K.ideal(-Integer(7)*a**Integer(4) + Integer(13)*a**Integer(3) - Integer(13)*a**Integer(2) - Integer(2)*a + Integer(50)) >>> b = -a+Integer(5) >>> K.hilbert_symbol(a, b, P) 1 >>> K.hilbert_symbol(a, b, Q) 1 >>> K = NumberField(x**Integer(5) - Integer(23), names=('a',)); (a,) = K._first_ngens(1) >>> P = K.ideal(-Integer(1105)*a**Integer(4) + Integer(1541)*a**Integer(3) - Integer(795)*a**Integer(2) - Integer(2993)*a + Integer(11853)) >>> K.hilbert_symbol(a, a + Integer(5), P) 1 >>> K.hilbert_symbol(a, Integer(2), P) 1 >>> K.hilbert_symbol(a + Integer(5), Integer(2), P) -1 >>> K = NumberField(x**Integer(3) - Integer(4)*x + Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> K.hilbert_symbol(Integer(2), -Integer(2), K.primes_above(Integer(2))[Integer(0)]) 1
Check that the bug reported at Issue #16043 has been fixed:
sage: K.<a> = NumberField(x^2 + 5) sage: p = K.primes_above(2)[0]; p Fractional ideal (2, a + 1) sage: K.hilbert_symbol(2*a, -1, p) 1 sage: K.hilbert_symbol(2*a, 2, p) -1 sage: K.hilbert_symbol(2*a, -2, p) -1
>>> from sage.all import * >>> K = NumberField(x**Integer(2) + Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> p = K.primes_above(Integer(2))[Integer(0)]; p Fractional ideal (2, a + 1) >>> K.hilbert_symbol(Integer(2)*a, -Integer(1), p) 1 >>> K.hilbert_symbol(Integer(2)*a, Integer(2), p) -1 >>> K.hilbert_symbol(Integer(2)*a, -Integer(2), p) -1
AUTHOR:
Aly Deines (2010-08-19): part of the doctests
Marco Streng (2010-12-06)
- hilbert_symbol_negative_at_S(S, b, check=True)[source]#
Return \(a\) such that the Hilbert conductor of \(a\) and \(b\) is \(S\).
INPUT:
S
– a list of places (or prime ideals) of even cardinalityb
– a non-zero rational number which is a non-square locally at every place in \(S\).check
– bool (default:True
) perform additional checks on the input and confirm the output
OUTPUT:
an element \(a\) that has negative Hilbert symbol \((a,b)_p\) for every (finite and infinite) place \(p\) in \(S\).
ALGORITHM:
The implementation is following algorithm 3.4.1 in [Kir2016]. We note that class and unit groups are computed using the generalized Riemann hypothesis. If it is false, this may result in an infinite loop. Nevertheless, if the algorithm terminates the output is correct.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^2 + 20072) sage: S = [K.primes_above(3)[0], K.primes_above(23)[0]] sage: b = K.hilbert_symbol_negative_at_S(S, a + 1) sage: [K.hilbert_symbol(b, a + 1, p) for p in S] [-1, -1] sage: K.<d> = CyclotomicField(11) sage: S = [K.primes_above(2)[0], K.primes_above(11)[0]] sage: b = d + 5 sage: a = K.hilbert_symbol_negative_at_S(S, b) sage: [K.hilbert_symbol(a,b,p) for p in S] [-1, -1] sage: k.<c> = K.maximal_totally_real_subfield()[0] sage: S = [k.primes_above(3)[0], k.primes_above(5)[0]] sage: S += k.real_places()[:2] sage: b = 5 + c + c^9 sage: a = k.hilbert_symbol_negative_at_S(S, b) sage: [k.hilbert_symbol(a, b, p) for p in S] [-1, -1, -1, -1]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(20072), names=('a',)); (a,) = K._first_ngens(1) >>> S = [K.primes_above(Integer(3))[Integer(0)], K.primes_above(Integer(23))[Integer(0)]] >>> b = K.hilbert_symbol_negative_at_S(S, a + Integer(1)) >>> [K.hilbert_symbol(b, a + Integer(1), p) for p in S] [-1, -1] >>> K = CyclotomicField(Integer(11), names=('d',)); (d,) = K._first_ngens(1) >>> S = [K.primes_above(Integer(2))[Integer(0)], K.primes_above(Integer(11))[Integer(0)]] >>> b = d + Integer(5) >>> a = K.hilbert_symbol_negative_at_S(S, b) >>> [K.hilbert_symbol(a,b,p) for p in S] [-1, -1] >>> k = K.maximal_totally_real_subfield()[Integer(0)]; (c,) = k._first_ngens(1) >>> S = [k.primes_above(Integer(3))[Integer(0)], k.primes_above(Integer(5))[Integer(0)]] >>> S += k.real_places()[:Integer(2)] >>> b = Integer(5) + c + c**Integer(9) >>> a = k.hilbert_symbol_negative_at_S(S, b) >>> [k.hilbert_symbol(a, b, p) for p in S] [-1, -1, -1, -1]
Note that the closely related Hilbert conductor takes only the finite places into account:
sage: k.hilbert_conductor(a, b) Fractional ideal (15)
>>> from sage.all import * >>> k.hilbert_conductor(a, b) Fractional ideal (15)
AUTHORS:
Simon Brandhorst, Anna Haensch (01-05-2018)
- is_absolute()[source]#
Return
True
sinceself
is an absolute field.EXAMPLES:
sage: K = CyclotomicField(5) sage: K.is_absolute() True
>>> from sage.all import * >>> K = CyclotomicField(Integer(5)) >>> K.is_absolute() True
- logarithmic_embedding(prec=53)[source]#
Return the morphism of
self
under the logarithmic embedding in the category Set.The logarithmic embedding is defined as a map from the number field
self
to \(\RR^n\).It is defined under Definition 4.9.6 in [Coh1993].
INPUT:
prec
– desired floating point precision.
OUTPUT:
the morphism of
self
under the logarithmic embedding in the category Set.EXAMPLES:
sage: CF.<a> = CyclotomicField(5) sage: f = CF.logarithmic_embedding() sage: f(0) (-1, -1) sage: f(7) (3.89182029811063, 3.89182029811063)
>>> from sage.all import * >>> CF = CyclotomicField(Integer(5), names=('a',)); (a,) = CF._first_ngens(1) >>> f = CF.logarithmic_embedding() >>> f(Integer(0)) (-1, -1) >>> f(Integer(7)) (3.89182029811063, 3.89182029811063)
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^3 + 5) sage: f = K.logarithmic_embedding() sage: f(0) (-1, -1) sage: f(7) (1.94591014905531, 3.89182029811063)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) + Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> f = K.logarithmic_embedding() >>> f(Integer(0)) (-1, -1) >>> f(Integer(7)) (1.94591014905531, 3.89182029811063)
sage: F.<a> = NumberField(x^4 - 8*x^2 + 3) sage: f = F.logarithmic_embedding() sage: f(0) (-1, -1, -1, -1) sage: f(7) (1.94591014905531, 1.94591014905531, 1.94591014905531, 1.94591014905531)
>>> from sage.all import * >>> F = NumberField(x**Integer(4) - Integer(8)*x**Integer(2) + Integer(3), names=('a',)); (a,) = F._first_ngens(1) >>> f = F.logarithmic_embedding() >>> f(Integer(0)) (-1, -1, -1, -1) >>> f(Integer(7)) (1.94591014905531, 1.94591014905531, 1.94591014905531, 1.94591014905531)
- minkowski_embedding(B=None, prec=None)[source]#
Return an \(n \times n\) matrix over
RDF
whose columns are the images of the basis \(\{1, \alpha, \dots, \alpha^{n-1}\}\) ofself
over \(\QQ\) (as vector spaces), where here \(\alpha\) is the generator ofself
over \(\QQ\), i.e.self.gen(0)
. If \(B\) is notNone
, return the images of the vectors in \(B\) as the columns instead. Ifprec
is notNone
, useRealField(prec)
instead ofRDF
.This embedding is the so-called “Minkowski embedding” of a number field in \(\RR^n\): given the \(n\) embeddings \(\sigma_1, \dots, \sigma_n\) of
self
in \(\CC\), 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 ofself
. Then the Minkowski embedding is given by\[x \mapsto ( \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 \(\RR^n\) so that the usual norm on \(\RR^n\) coincides with \(|x| = \sum_i |\sigma_i(x)|^2\) onself
.Todo
This could be much improved by implementing homomorphisms over VectorSpaces.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: F.<alpha> = NumberField(x^3 + 2) sage: F.minkowski_embedding() [ 1.00000000000000 -1.25992104989487 1.58740105196820] [ 1.41421356237... 0.8908987181... -1.12246204830...] [0.000000000000000 1.54308184421... 1.94416129723...] sage: F.minkowski_embedding([1, alpha+2, alpha^2-alpha]) [ 1.00000000000000 0.740078950105127 2.84732210186307] [ 1.41421356237... 3.7193258428... -2.01336076644...] [0.000000000000000 1.54308184421... 0.40107945302...] sage: F.minkowski_embedding() * (alpha + 2).vector().column() [0.740078950105127] [ 3.7193258428...] [ 1.54308184421...]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> F = NumberField(x**Integer(3) + Integer(2), names=('alpha',)); (alpha,) = F._first_ngens(1) >>> F.minkowski_embedding() [ 1.00000000000000 -1.25992104989487 1.58740105196820] [ 1.41421356237... 0.8908987181... -1.12246204830...] [0.000000000000000 1.54308184421... 1.94416129723...] >>> F.minkowski_embedding([Integer(1), alpha+Integer(2), alpha**Integer(2)-alpha]) [ 1.00000000000000 0.740078950105127 2.84732210186307] [ 1.41421356237... 3.7193258428... -2.01336076644...] [0.000000000000000 1.54308184421... 0.40107945302...] >>> F.minkowski_embedding() * (alpha + Integer(2)).vector().column() [0.740078950105127] [ 3.7193258428...] [ 1.54308184421...]
- optimized_representation(name=None, both_maps=True)[source]#
Return a field isomorphic to
self
with a better defining polynomial if possible, along with field isomorphisms from the new field toself
and fromself
to the new field.EXAMPLES: We construct a compositum of 3 quadratic fields, then find an optimized representation and transform elements back and forth.
sage: x = polygen(QQ, 'x') 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 b1 with defining polynomial x^8 + 4*x^6 + 7*x^4 + 36*x^2 + 81 sage: to_L(K.0) # random 4/189*b1^7 + 1/63*b1^6 + 1/27*b1^5 - 2/9*b1^4 - 5/27*b1^3 - 8/9*b1^2 + 3/7*b1 - 3/7 sage: from_L(L.0) # random 1/1152*b^7 - 1/192*b^6 + 23/576*b^5 - 17/96*b^4 + 37/72*b^3 - 5/6*b^2 + 55/24*b - 3/4
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField([x**Integer(2) + p for p in [Integer(5), Integer(3), Integer(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 >>> L, from_L, to_L = K.optimized_representation() >>> L # your answer may different, since algorithm is random Number Field in b1 with defining polynomial x^8 + 4*x^6 + 7*x^4 + 36*x^2 + 81 >>> to_L(K.gen(0)) # random 4/189*b1^7 + 1/63*b1^6 + 1/27*b1^5 - 2/9*b1^4 - 5/27*b1^3 - 8/9*b1^2 + 3/7*b1 - 3/7 >>> from_L(L.gen(0)) # random 1/1152*b^7 - 1/192*b^6 + 23/576*b^5 - 17/96*b^4 + 37/72*b^3 - 5/6*b^2 + 55/24*b - 3/4
The transformation maps are mutually inverse isomorphisms.
sage: from_L(to_L(K.0)) == K.0 True sage: to_L(from_L(L.0)) == L.0 True
>>> from sage.all import * >>> from_L(to_L(K.gen(0))) == K.gen(0) True >>> to_L(from_L(L.gen(0))) == L.gen(0) True
Number fields defined by non-monic and non-integral polynomials are supported (Issue #252):
sage: K.<a> = NumberField(7/9*x^3 + 7/3*x^2 - 56*x + 123) sage: K.optimized_representation() # representation varies, not tested (Number Field in a1 with defining polynomial x^3 - 7*x - 7, Ring morphism: From: Number Field in a1 with defining polynomial x^3 - 7*x - 7 To: Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 Defn: a1 |--> 7/225*a^2 - 7/75*a - 42/25, Ring morphism: From: Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 To: Number Field in a1 with defining polynomial x^3 - 7*x - 7 Defn: a |--> -15/7*a1^2 + 9)
>>> from sage.all import * >>> K = NumberField(Integer(7)/Integer(9)*x**Integer(3) + Integer(7)/Integer(3)*x**Integer(2) - Integer(56)*x + Integer(123), names=('a',)); (a,) = K._first_ngens(1) >>> K.optimized_representation() # representation varies, not tested (Number Field in a1 with defining polynomial x^3 - 7*x - 7, Ring morphism: From: Number Field in a1 with defining polynomial x^3 - 7*x - 7 To: Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 Defn: a1 |--> 7/225*a^2 - 7/75*a - 42/25, Ring morphism: From: Number Field in a with defining polynomial 7/9*x^3 + 7/3*x^2 - 56*x + 123 To: Number Field in a1 with defining polynomial x^3 - 7*x - 7 Defn: a |--> -15/7*a1^2 + 9)
- optimized_subfields(degree=0, name=None, both_maps=True)[source]#
Return optimized representations of many (but not necessarily all!) subfields of
self
of the givendegree
, or of all possible degrees ifdegree
is 0.EXAMPLES:
sage: x = polygen(QQ, 'x') 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 sage: L[1][0] Number Field in b1 with defining polynomial x^2 - 3*x + 3 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]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField([x**Integer(2) + p for p in [Integer(5), Integer(3), Integer(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 >>> L = K.optimized_subfields(name='b') >>> L[Integer(0)][Integer(0)] Number Field in b0 with defining polynomial x >>> L[Integer(1)][Integer(0)] Number Field in b1 with defining polynomial x^2 - 3*x + 3 >>> [z[Integer(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
>>> from sage.all import * >>> M, from_M, to_M = L[Integer(2)] >>> M # random Number Field in b2 with defining polynomial x^4 - 5*x^2 + 25 >>> 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 isNone
, since there is no map from \(K\) to \(M\):sage: to_M
>>> from sage.all import * >>> 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
>>> from sage.all import * >>> from_M(M.gen(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
>>> from sage.all import * >>> from_M(M.gen(0)).minpoly() # random x^4 - 5*x^2 + 25
- order(*args, **kwds)[source]#
Return the order with given ring generators in the maximal order of this number field.
INPUT:
gens
– list of elements in this number field; if no generators are given, just returns the cardinality of this number field (\(\infty\)) 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 bygens
is of full rank.allow_subfield
– bool (default:False
), ifTrue
and the generators do not generate an order, i.e., they generate a subring of smaller rank, instead of raising an error, return an order in a smaller number field.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: k.<i> = NumberField(x^2 + 1) sage: k.order(2*i) Order of conductor 2 generated by 2*i in Number Field in i with defining polynomial x^2 + 1 sage: k.order(10*i) Order of conductor 10 generated by 10*i 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = k._first_ngens(1) >>> k.order(Integer(2)*i) Order of conductor 2 generated by 2*i in Number Field in i with defining polynomial x^2 + 1 >>> k.order(Integer(10)*i) Order of conductor 10 generated by 10*i in Number Field in i with defining polynomial x^2 + 1 >>> k.order(Integer(3)) Traceback (most recent call last): ... ValueError: the rank of the span of gens is wrong >>> k.order(i/Integer(2)) Traceback (most recent call last): ... ValueError: each generator must be integral
Alternatively, an order can be constructed by adjoining elements to \(\ZZ\):
sage: K.<a> = NumberField(x^3 - 2) sage: ZZ[a] Order generated by a0 in Number Field in a0 with defining polynomial x^3 - 2 with a0 = a
>>> from sage.all import * >>> K = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> ZZ[a] Order generated by a0 in Number Field in a0 with defining polynomial x^3 - 2 with a0 = a
- places(all_complex=False, prec=None)[source]#
Return the collection of all infinite 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 intoCIF
.On the other hand, if
prec
is notNone
, we simply return places intoRealField(prec)
andComplexField(prec)
(orRDF
,CDF
ifprec=53
). One can also useprec=infinity
, which returns embeddings into the field \(\overline{\QQ}\) of algebraic numbers (or its subfield \(\mathbb{A}\) of algebraic reals); this permits exact computation, but can be extremely slow.There is an optional flag
all_complex
, which defaults toFalse
. Ifall_complex
isTrue
, then the real embeddings are returned as embeddings intoCIF
instead ofRIF
.EXAMPLES:
sage: x = polygen(QQ, 'x') 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]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> F = NumberField(x**Integer(3) - Integer(100)*x + Integer(1), names=('alpha',)); (alpha,) = F._first_ngens(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]
>>> from sage.all import * >>> F = NumberField(x**Integer(3) + Integer(7), names=('alpha',)); (alpha,) = F._first_ngens(1); 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]
>>> from sage.all import * >>> F = NumberField(x**Integer(3) + Integer(7), names=('alpha',)); (alpha,) = F._first_ngens(1); 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] >>> F.places(prec=Integer(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(prec=None)[source]#
Return all real places of
self
as homomorphisms intoRIF
.EXAMPLES:
sage: x = polygen(QQ, 'x') 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]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> F = NumberField(x**Integer(4) - Integer(7), names=('alpha',)); (alpha,) = F._first_ngens(1); 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]
- relative_degree()[source]#
A synonym for
degree()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<i> = NumberField(x^2 + 1) sage: K.relative_degree() 2
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.relative_degree() 2
- relative_different()[source]#
A synonym for
different()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<i> = NumberField(x^2 + 1) sage: K.relative_different() Fractional ideal (2)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.relative_different() Fractional ideal (2)
- relative_discriminant()[source]#
A synonym for
discriminant()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<i> = NumberField(x^2 + 1) sage: K.relative_discriminant() -4
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.relative_discriminant() -4
- relative_polynomial()[source]#
A synonym for
polynomial()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<i> = NumberField(x^2 + 1) sage: K.relative_polynomial() x^2 + 1
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.relative_polynomial() x^2 + 1
- relative_vector_space(*args, **kwds)[source]#
A synonym for
vector_space()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<i> = NumberField(x^2 + 1) sage: K.relative_vector_space() (Vector space of dimension 2 over Rational Field, Isomorphism map: From: Vector space of dimension 2 over Rational Field To: Number Field in i with defining polynomial x^2 + 1, Isomorphism map: From: Number Field in i with defining polynomial x^2 + 1 To: Vector space of dimension 2 over Rational Field)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.relative_vector_space() (Vector space of dimension 2 over Rational Field, Isomorphism map: From: Vector space of dimension 2 over Rational Field To: Number Field in i with defining polynomial x^2 + 1, Isomorphism map: From: Number Field in i with defining polynomial x^2 + 1 To: Vector space of dimension 2 over Rational Field)
- relativize(alpha, names, structure=None)[source]#
Given an element in
self
or an embedding of a subfield intoself
, return a relative number field \(K\) isomorphic toself
that is relative over the absolute field \(\QQ(\alpha)\) or the domain of \(\alpha\), along with isomorphisms from \(K\) toself
and fromself
to \(K\).INPUT:
alpha
– an element ofself
or an embedding of a subfield intoself
names
– 2-tuple of names of generator for output field \(K\) and the subfield \(\QQ(\alpha)\)structure
– an instance ofstructure.NumberFieldStructure
orNone
(default:None
), ifNone
, then the resulting field’sstructure()
will return isomorphisms from and to this field. Otherwise, the field will be equipped withstructure
.
OUTPUT:
\(K\) – relative number field
Also,
K.structure()
returnsfrom_K
andto_K
, wherefrom_K
is an isomorphism from \(K\) toself
andto_K
is an isomorphism fromself
to \(K\).EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(10) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.relativize(a**Integer(4) + a**Integer(2) + Integer(2), names=('c', 'd',)); (c, d,) = L._first_ngens(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 >>> c.absolute_minpoly() x^10 - 2 >>> d.absolute_minpoly() x^5 - 10*x^4 + 40*x^3 - 90*x^2 + 110*x - 58 >>> (a**Integer(4) + a**Integer(2) + Integer(2)).minpoly() x^5 - 10*x^4 + 40*x^3 - 90*x^2 + 110*x - 58 >>> from_L, to_L = L.structure() >>> to_L(a) c >>> to_L(a**Integer(4) + a**Integer(2) + Integer(2)) d >>> from_L(to_L(a**Integer(4) + a**Integer(2) + Integer(2))) a^4 + a^2 + 2
The following demonstrates distinct embeddings of a subfield into a larger field:
sage: K.<a> = NumberField(x^4 + 2*x^2 + 2) sage: K0 = K.subfields(2)[0][0]; K0 Number Field in a0 with defining polynomial x^2 - 2*x + 2 sage: rho, tau = K0.embeddings(K) sage: L0 = K.relativize(rho(K0.gen()), 'b'); L0 Number Field in b0 with defining polynomial x^2 - b1 + 2 over its base field sage: L1 = K.relativize(rho, 'b'); L1 Number Field in b with defining polynomial x^2 - a0 + 2 over its base field sage: L2 = K.relativize(tau, 'b'); L2 Number Field in b with defining polynomial x^2 + a0 over its base field sage: L0.base_field() is K0 False sage: L1.base_field() is K0 True sage: L2.base_field() is K0 True
>>> from sage.all import * >>> K = NumberField(x**Integer(4) + Integer(2)*x**Integer(2) + Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> K0 = K.subfields(Integer(2))[Integer(0)][Integer(0)]; K0 Number Field in a0 with defining polynomial x^2 - 2*x + 2 >>> rho, tau = K0.embeddings(K) >>> L0 = K.relativize(rho(K0.gen()), 'b'); L0 Number Field in b0 with defining polynomial x^2 - b1 + 2 over its base field >>> L1 = K.relativize(rho, 'b'); L1 Number Field in b with defining polynomial x^2 - a0 + 2 over its base field >>> L2 = K.relativize(tau, 'b'); L2 Number Field in b with defining polynomial x^2 + a0 over its base field >>> L0.base_field() is K0 False >>> L1.base_field() is K0 True >>> L2.base_field() is K0 True
Here we see that with the different embeddings, the relative norms are different:
sage: a0 = K0.gen() sage: L1_into_K, K_into_L1 = L1.structure() sage: L2_into_K, K_into_L2 = L2.structure() sage: len(K.factor(41)) 4 sage: w1 = -a^2 + a + 1; P = K.ideal([w1]) sage: Pp = L1.ideal(K_into_L1(w1)).ideal_below(); Pp == K0.ideal([4*a0 + 1]) True sage: Pp == w1.norm(rho) True sage: w2 = a^2 + a - 1; Q = K.ideal([w2]) sage: Qq = L2.ideal(K_into_L2(w2)).ideal_below(); Qq == K0.ideal([-4*a0 + 9]) True sage: Qq == w2.norm(tau) True sage: Pp == Qq False
>>> from sage.all import * >>> a0 = K0.gen() >>> L1_into_K, K_into_L1 = L1.structure() >>> L2_into_K, K_into_L2 = L2.structure() >>> len(K.factor(Integer(41))) 4 >>> w1 = -a**Integer(2) + a + Integer(1); P = K.ideal([w1]) >>> Pp = L1.ideal(K_into_L1(w1)).ideal_below(); Pp == K0.ideal([Integer(4)*a0 + Integer(1)]) True >>> Pp == w1.norm(rho) True >>> w2 = a**Integer(2) + a - Integer(1); Q = K.ideal([w2]) >>> Qq = L2.ideal(K_into_L2(w2)).ideal_below(); Qq == K0.ideal([-Integer(4)*a0 + Integer(9)]) True >>> Qq == w2.norm(tau) True >>> Pp == Qq False
- subfields(degree=0, name=None)[source]#
Return all subfields of
self
of the givendegree
, or of all possible degrees ifdegree
is 0. The subfields are returned as absolute fields together with an embedding intoself
. For the case of the field itself, the reverse isomorphism is also provided.EXAMPLES:
sage: x = polygen(QQ, 'x') 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] sage: R.<t> = QQ[] sage: L = NumberField(t^3 - 3*t + 1, 'c') sage: [k[1] for k in L.subfields()] [Ring morphism: From: Number Field in c0 with defining polynomial t To: Number Field in c with defining polynomial t^3 - 3*t + 1 Defn: 0 |--> 0, Ring morphism: From: Number Field in c1 with defining polynomial t^3 - 3*t + 1 To: Number Field in c with defining polynomial t^3 - 3*t + 1 Defn: c1 |--> c] sage: len(L.subfields(2)) 0 sage: len(L.subfields(1)) 1
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField([x**Integer(3) - Integer(2), x**Integer(2) + x + Integer(1)], names=('a',)); (a,) = K._first_ngens(1) >>> K = K.absolute_field('b') >>> S = K.subfields() >>> len(S) 6 >>> [k[Integer(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] >>> R = QQ['t']; (t,) = R._first_ngens(1) >>> L = NumberField(t**Integer(3) - Integer(3)*t + Integer(1), 'c') >>> [k[Integer(1)] for k in L.subfields()] [Ring morphism: From: Number Field in c0 with defining polynomial t To: Number Field in c with defining polynomial t^3 - 3*t + 1 Defn: 0 |--> 0, Ring morphism: From: Number Field in c1 with defining polynomial t^3 - 3*t + 1 To: Number Field in c with defining polynomial t^3 - 3*t + 1 Defn: c1 |--> c] >>> len(L.subfields(Integer(2))) 0 >>> len(L.subfields(Integer(1))) 1
- sage.rings.number_field.number_field.NumberField_absolute_v1(poly, name, latex_name, canonical_embedding=None)[source]#
Used for unpickling old pickles.
EXAMPLES:
sage: from sage.rings.number_field.number_field import NumberField_absolute_v1 sage: R.<x> = QQ[] sage: NumberField_absolute_v1(x^2 + 1, 'i', 'i') Number Field in i with defining polynomial x^2 + 1
>>> from sage.all import * >>> from sage.rings.number_field.number_field import NumberField_absolute_v1 >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> NumberField_absolute_v1(x**Integer(2) + Integer(1), 'i', 'i') Number Field in i with defining polynomial x^2 + 1
- class sage.rings.number_field.number_field.NumberField_cyclotomic(n, names, embedding=None, assume_disc_small=False, maximize_at_primes=None)[source]#
Bases:
NumberField_absolute
,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.EXAMPLES:
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
>>> from sage.all import * >>> CyclotomicField(Integer(3)) Cyclotomic Field of order 3 and degree 2 >>> CyclotomicField(Integer(18)) Cyclotomic Field of order 18 and degree 6 >>> z = CyclotomicField(Integer(6)).gen(); z zeta6 >>> z**Integer(3) -1 >>> (Integer(1)+z)**Integer(3) 6*zeta6 - 3
sage: K = CyclotomicField(197) sage: loads(K.dumps()) == K True sage: loads((z^2).dumps()) == z^2 True
>>> from sage.all import * >>> K = CyclotomicField(Integer(197)) >>> loads(K.dumps()) == K True >>> loads((z**Integer(2)).dumps()) == z**Integer(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: z6*x^3/(z6 + x) zeta12^2*x^3/(x + zeta12^2)
>>> from sage.all import * >>> cf12 = CyclotomicField(Integer(12)) >>> z12 = cf12.gen(0) >>> cf6 = CyclotomicField(Integer(6)) >>> z6 = cf6.gen(0) >>> FF = Frac(cf12['x']) >>> x = FF.gen(0) >>> z6*x**Integer(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)) <class 'sage.rings.number_field.number_field_element_quadratic.NumberFieldElement_quadratic'> sage: cf1 = CyclotomicField(1); z1 = cf1.0 sage: cf3(z1) 1 sage: type(cf3(z1)) <class 'sage.rings.number_field.number_field_element_quadratic.NumberFieldElement_quadratic'>
>>> from sage.all import * >>> cf6 = CyclotomicField(Integer(6)); z6 = cf6.gen(Integer(0)) >>> cf3 = CyclotomicField(Integer(3)); z3 = cf3.gen(Integer(0)) >>> cf3(z6) zeta3 + 1 >>> cf6(z3) zeta6 - 1 >>> type(cf6(z3)) <class 'sage.rings.number_field.number_field_element_quadratic.NumberFieldElement_quadratic'> >>> cf1 = CyclotomicField(Integer(1)); z1 = cf1.gen(0) >>> cf3(z1) 1 >>> type(cf3(z1)) <class 'sage.rings.number_field.number_field_element_quadratic.NumberFieldElement_quadratic'>
- complex_embedding(prec=53)[source]#
Return the embedding of this cyclotomic field into the approximate complex field with precision
prec
obtained by sending the generator \(\zeta\) ofself
to exp(2*pi*i/n), where \(n\) is the multiplicative order of \(\zeta\).EXAMPLES:
sage: C = CyclotomicField(4) sage: C.complex_embedding() Ring morphism: From: Cyclotomic Field of order 4 and degree 2 To: Complex Field with 53 bits of precision Defn: zeta4 |--> 6.12323399573677e-17 + 1.00000000000000*I
>>> from sage.all import * >>> C = CyclotomicField(Integer(4)) >>> C.complex_embedding() Ring morphism: From: Cyclotomic Field of order 4 and degree 2 To: Complex Field with 53 bits of precision Defn: zeta4 |--> 6.12323399573677e-17 + 1.00000000000000*I
Note in the example above that the way zeta is computed (using sine 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.00 sage: phi(K.0^3 + 7) 8.0
>>> from sage.all import * >>> K = CyclotomicField(Integer(3)) >>> phi = K.complex_embedding(Integer(10)) >>> phi(K.gen(0)) -0.50 + 0.87*I >>> phi(K.gen(0)**Integer(3)) 1.0 >>> phi(K.gen(0)**Integer(3) - Integer(1)) 0.00 >>> phi(K.gen(0)**Integer(3) + Integer(7)) 8.0
- complex_embeddings(prec=53)[source]#
Return all embeddings of this cyclotomic field into the approximate complex field with precision
prec
.If you want 53-bit double precision, which is faster but less reliable, then do
self.embeddings(CDF)
.EXAMPLES:
sage: CyclotomicField(5).complex_embeddings() [ Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Field with 53 bits of precision Defn: zeta5 |--> 0.309016994374947 + 0.951056516295154*I, Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Field with 53 bits of precision Defn: zeta5 |--> -0.809016994374947 + 0.587785252292473*I, Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Field with 53 bits of precision Defn: zeta5 |--> -0.809016994374947 - 0.587785252292473*I, Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Field with 53 bits of precision Defn: zeta5 |--> 0.309016994374947 - 0.951056516295154*I ]
>>> from sage.all import * >>> CyclotomicField(Integer(5)).complex_embeddings() [ Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Field with 53 bits of precision Defn: zeta5 |--> 0.309016994374947 + 0.951056516295154*I, Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Field with 53 bits of precision Defn: zeta5 |--> -0.809016994374947 + 0.587785252292473*I, Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Field with 53 bits of precision Defn: zeta5 |--> -0.809016994374947 - 0.587785252292473*I, Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Field with 53 bits of precision Defn: zeta5 |--> 0.309016994374947 - 0.951056516295154*I ]
- construction()[source]#
Return data defining a functorial construction of
self
.EXAMPLES:
sage: F, R = CyclotomicField(5).construction() sage: R Rational Field sage: F.polys [x^4 + x^3 + x^2 + x + 1] sage: F.names ['zeta5'] sage: F.embeddings [0.309016994374948? + 0.951056516295154?*I] sage: F.structures [None]
>>> from sage.all import * >>> F, R = CyclotomicField(Integer(5)).construction() >>> R Rational Field >>> F.polys [x^4 + x^3 + x^2 + x + 1] >>> F.names ['zeta5'] >>> F.embeddings [0.309016994374948? + 0.951056516295154?*I] >>> F.structures [None]
- different()[source]#
Return the different ideal of the cyclotomic field
self
.EXAMPLES:
sage: C20 = CyclotomicField(20) sage: C20.different() Fractional ideal (10, 2*zeta20^6 - 4*zeta20^4 - 4*zeta20^2 + 2) sage: C18 = CyclotomicField(18) sage: D = C18.different().norm() sage: D == C18.discriminant().abs() True
>>> from sage.all import * >>> C20 = CyclotomicField(Integer(20)) >>> C20.different() Fractional ideal (10, 2*zeta20^6 - 4*zeta20^4 - 4*zeta20^2 + 2) >>> C18 = CyclotomicField(Integer(18)) >>> D = C18.different().norm() >>> D == C18.discriminant().abs() True
- discriminant(v=None)[source]#
Return the discriminant of the ring of integers of the cyclotomic field
self
, or ifv
is specified, the determinant of the trace pairing on the elements of the listv
.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 elements of this number field
OUTPUT: Integer if
v
is omitted, and Rational otherwise.EXAMPLES:
sage: CyclotomicField(20).discriminant() 4000000 sage: CyclotomicField(18).discriminant() -19683
>>> from sage.all import * >>> CyclotomicField(Integer(20)).discriminant() 4000000 >>> CyclotomicField(Integer(18)).discriminant() -19683
- embeddings(K)[source]#
Compute all field embeddings of this field into the field \(K\).
INPUT:
K
– a field
EXAMPLES:
sage: CyclotomicField(5).embeddings(ComplexField(53))[1] Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Field with 53 bits of precision Defn: zeta5 |--> -0.809016994374947 + 0.587785252292473*I sage: CyclotomicField(5).embeddings(Qp(11, 4, print_mode='digits'))[1] # needs sage.rings.padics Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: 11-adic Field with capped relative precision 4 Defn: zeta5 |--> ...1525
>>> from sage.all import * >>> CyclotomicField(Integer(5)).embeddings(ComplexField(Integer(53)))[Integer(1)] Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Field with 53 bits of precision Defn: zeta5 |--> -0.809016994374947 + 0.587785252292473*I >>> CyclotomicField(Integer(5)).embeddings(Qp(Integer(11), Integer(4), print_mode='digits'))[Integer(1)] # needs sage.rings.padics Ring morphism: From: Cyclotomic Field of order 5 and degree 4 To: 11-adic Field with capped relative precision 4 Defn: zeta5 |--> ...1525
- is_abelian()[source]#
Return
True
since all cyclotomic fields are automatically abelian.EXAMPLES:
sage: CyclotomicField(29).is_abelian() True
>>> from sage.all import * >>> CyclotomicField(Integer(29)).is_abelian() True
- is_galois()[source]#
Return
True
since all cyclotomic fields are automatically Galois.EXAMPLES:
sage: CyclotomicField(29).is_galois() True
>>> from sage.all import * >>> CyclotomicField(Integer(29)).is_galois() True
- is_isomorphic(other)[source]#
Return
True
if the cyclotomic fieldself
is isomorphic as a number field toother
.EXAMPLES:
sage: CyclotomicField(11).is_isomorphic(CyclotomicField(22)) True sage: CyclotomicField(11).is_isomorphic(CyclotomicField(23)) False sage: x = polygen(QQ, 'x') sage: CyclotomicField(3).is_isomorphic(NumberField(x^2 + x + 1, 'a')) True sage: CyclotomicField(18).is_isomorphic(CyclotomicField(9)) True sage: CyclotomicField(10).is_isomorphic(NumberField(x^4 - x^3 + x^2 - x + 1, 'b')) True
>>> from sage.all import * >>> CyclotomicField(Integer(11)).is_isomorphic(CyclotomicField(Integer(22))) True >>> CyclotomicField(Integer(11)).is_isomorphic(CyclotomicField(Integer(23))) False >>> x = polygen(QQ, 'x') >>> CyclotomicField(Integer(3)).is_isomorphic(NumberField(x**Integer(2) + x + Integer(1), 'a')) True >>> CyclotomicField(Integer(18)).is_isomorphic(CyclotomicField(Integer(9))) True >>> CyclotomicField(Integer(10)).is_isomorphic(NumberField(x**Integer(4) - x**Integer(3) + x**Integer(2) - x + Integer(1), 'b')) True
Check Issue #14300:
sage: K = CyclotomicField(4) sage: N = K.extension(x^2 - 5, 'z') sage: K.is_isomorphic(N) False sage: K.is_isomorphic(CyclotomicField(8)) False
>>> from sage.all import * >>> K = CyclotomicField(Integer(4)) >>> N = K.extension(x**Integer(2) - Integer(5), 'z') >>> K.is_isomorphic(N) False >>> K.is_isomorphic(CyclotomicField(Integer(8))) False
- next_split_prime(p=2)[source]#
Return the next prime integer \(p\) that splits completely in this cyclotomic field (and does not ramify).
EXAMPLES:
sage: K.<z> = CyclotomicField(3) sage: K.next_split_prime(7) 13
>>> from sage.all import * >>> K = CyclotomicField(Integer(3), names=('z',)); (z,) = K._first_ngens(1) >>> K.next_split_prime(Integer(7)) 13
- number_of_roots_of_unity()[source]#
Return number of roots of unity in this cyclotomic field.
EXAMPLES:
sage: K.<a> = CyclotomicField(21) sage: K.number_of_roots_of_unity() 42
>>> from sage.all import * >>> K = CyclotomicField(Integer(21), names=('a',)); (a,) = K._first_ngens(1) >>> K.number_of_roots_of_unity() 42
- real_embeddings(prec=53)[source]#
Return all embeddings of this cyclotomic field into the approximate real field with precision
prec
.Mostly, of course, there are no such embeddings.
EXAMPLES:
sage: len(CyclotomicField(4).real_embeddings()) 0 sage: CyclotomicField(2).real_embeddings() [ Ring morphism: From: Cyclotomic Field of order 2 and degree 1 To: Real Field with 53 bits of precision Defn: -1 |--> -1.00000000000000 ]
>>> from sage.all import * >>> len(CyclotomicField(Integer(4)).real_embeddings()) 0 >>> CyclotomicField(Integer(2)).real_embeddings() [ Ring morphism: From: Cyclotomic Field of order 2 and degree 1 To: Real Field with 53 bits of precision Defn: -1 |--> -1.00000000000000 ]
- roots_of_unity()[source]#
Return all the roots of unity in this cyclotomic field, primitive or not.
EXAMPLES:
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]
>>> from sage.all import * >>> K = CyclotomicField(Integer(3), names=('a',)); (a,) = K._first_ngens(1) >>> zs = K.roots_of_unity(); zs [1, a, -a - 1, -1, -a, a + 1] >>> [z**K.number_of_roots_of_unity() for z in zs] [1, 1, 1, 1, 1, 1]
- signature()[source]#
Return \((r_1, r_2)\), where \(r_1\) and \(r_2\) 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.
EXAMPLES:
sage: CyclotomicField(5).signature() (0, 2) sage: CyclotomicField(2).signature() (1, 0)
>>> from sage.all import * >>> CyclotomicField(Integer(5)).signature() (0, 2) >>> CyclotomicField(Integer(2)).signature() (1, 0)
- zeta(n=None, all=False)[source]#
Return an element of multiplicative order \(n\) in this cyclotomic field.
If there is no such element, raise a
ValueError
.INPUT:
n
– integer (default:None
, returns element of maximal order)all
– bool (default:False
); whether to return a list of all primitive \(n\)-th roots of unity.
OUTPUT: root of unity or list
EXAMPLES:
sage: k = CyclotomicField(4) sage: k.zeta() zeta4 sage: k.zeta(2) -1 sage: k.zeta().multiplicative_order() 4
>>> from sage.all import * >>> k = CyclotomicField(Integer(4)) >>> k.zeta() zeta4 >>> k.zeta(Integer(2)) -1 >>> k.zeta().multiplicative_order() 4
sage: k = CyclotomicField(21) sage: k.zeta().multiplicative_order() 42 sage: k.zeta(21).multiplicative_order() 21 sage: k.zeta(7).multiplicative_order() 7 sage: k.zeta(6).multiplicative_order() 6 sage: k.zeta(84) Traceback (most recent call last): ... ValueError: 84 does not divide order of generator (42)
>>> from sage.all import * >>> k = CyclotomicField(Integer(21)) >>> k.zeta().multiplicative_order() 42 >>> k.zeta(Integer(21)).multiplicative_order() 21 >>> k.zeta(Integer(7)).multiplicative_order() 7 >>> k.zeta(Integer(6)).multiplicative_order() 6 >>> k.zeta(Integer(84)) Traceback (most recent call last): ... ValueError: 84 does not divide order of generator (42)
sage: K.<a> = CyclotomicField(7) sage: K.zeta(all=True) [-a^4, -a^5, a^5 + a^4 + a^3 + a^2 + a + 1, -a, -a^2, -a^3] 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.zeta(2, all=True) [-1] sage: K.<a> = CyclotomicField(10) sage: K.zeta(20, all=True) Traceback (most recent call last): ... ValueError: 20 does not divide order of generator (10)
>>> from sage.all import * >>> K = CyclotomicField(Integer(7), names=('a',)); (a,) = K._first_ngens(1) >>> K.zeta(all=True) [-a^4, -a^5, a^5 + a^4 + a^3 + a^2 + a + 1, -a, -a^2, -a^3] >>> K.zeta(Integer(14), all=True) [-a^4, -a^5, a^5 + a^4 + a^3 + a^2 + a + 1, -a, -a^2, -a^3] >>> K.zeta(Integer(2), all=True) [-1] >>> K = CyclotomicField(Integer(10), names=('a',)); (a,) = K._first_ngens(1) >>> K.zeta(Integer(20), all=True) Traceback (most recent call last): ... ValueError: 20 does not divide order of generator (10)
sage: K.<a> = CyclotomicField(5) sage: K.zeta(4) Traceback (most recent call last): ... ValueError: 4 does not divide order of generator (10) 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]
>>> from sage.all import * >>> K = CyclotomicField(Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> K.zeta(Integer(4)) Traceback (most recent call last): ... ValueError: 4 does not divide order of generator (10) >>> v = K.zeta(Integer(5), all=True); v [a, a^2, a^3, -a^3 - a^2 - a - 1] >>> [b**Integer(5) for b in v] [1, 1, 1, 1]
- zeta_order()[source]#
Return the order of the maximal root of unity contained in this cyclotomic field.
EXAMPLES:
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
>>> from sage.all import * >>> CyclotomicField(Integer(1)).zeta_order() 2 >>> CyclotomicField(Integer(4)).zeta_order() 4 >>> CyclotomicField(Integer(5)).zeta_order() 10 >>> CyclotomicField(Integer(5))._n() 5 >>> CyclotomicField(Integer(389)).zeta_order() 778
- sage.rings.number_field.number_field.NumberField_cyclotomic_v1(zeta_order, name, canonical_embedding=None)[source]#
Used for unpickling old pickles.
EXAMPLES:
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'
>>> from sage.all import * >>> from sage.rings.number_field.number_field import NumberField_cyclotomic_v1 >>> NumberField_cyclotomic_v1(Integer(5),'a') Cyclotomic Field of order 5 and degree 4 >>> NumberField_cyclotomic_v1(Integer(5),'a').variable_name() 'a'
- class sage.rings.number_field.number_field.NumberField_generic(polynomial, name, latex_name, check=True, embedding=None, category=None, assume_disc_small=False, maximize_at_primes=None, structure=None)[source]#
Bases:
WithEqualityById
,NumberField
Generic class for number fields defined by an irreducible polynomial over \(\QQ\).
EXAMPLES:
sage: x = polygen(ZZ, 'x') sage: K.<a> = NumberField(x^3 - 2); K Number Field in a with defining polynomial x^3 - 2 sage: TestSuite(K).run()
>>> from sage.all import * >>> x = polygen(ZZ, 'x') >>> K = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1); K Number Field in a with defining polynomial x^3 - 2 >>> TestSuite(K).run()
- S_class_group(S, proof=None, names='c')[source]#
Return the S-class group of this number field over its base field.
INPUT:
S
– a set of primes of the base fieldproof
– if False, assume the GRH in computing the class group. Default isTrue
. Callnumber_field_proof
to change this default globally.names
– names of the generators of this class group.
OUTPUT: The S-class group of this number field.
EXAMPLES:
A well known example:
sage: K.<a> = QuadraticField(-5) sage: K.S_class_group([]) S-class group of order 2 with structure C2 of Number Field in a with defining polynomial x^2 + 5 with a = 2.236067977499790?*I
>>> from sage.all import * >>> K = QuadraticField(-Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> K.S_class_group([]) S-class group of order 2 with structure C2 of Number Field in a with defining polynomial x^2 + 5 with a = 2.236067977499790?*I
When we include the prime \((2, a+1)\), the S-class group becomes trivial:
sage: K.S_class_group([K.ideal(2, a + 1)]) S-class group of order 1 of Number Field in a with defining polynomial x^2 + 5 with a = 2.236067977499790?*I
>>> from sage.all import * >>> K.S_class_group([K.ideal(Integer(2), a + Integer(1))]) S-class group of order 1 of Number Field in a with defining polynomial x^2 + 5 with a = 2.236067977499790?*I
- S_unit_group(proof=None, S=None)[source]#
Return the \(S\)-unit group (including torsion) of this number field.
ALGORITHM: Uses PARI’s pari:bnfsunit command.
INPUT:
proof
– bool (default:True
); flag passed to PARIS
– list or tuple of prime ideals, or an ideal, or a single ideal or element from which an ideal can be constructed, in which case the support is used. IfNone
, the global unit group is constructed; otherwise, the \(S\)-unit group is constructed.
Note
The group is cached.
EXAMPLES:
sage: x = polygen(QQ) sage: K.<a> = NumberField(x^4 - 10*x^3 + 20*5*x^2 - 15*5^2*x + 11*5^3) sage: U = K.S_unit_group(S=a); U S-unit group with structure C10 x Z x Z x Z of Number Field in a with defining polynomial x^4 - 10*x^3 + 100*x^2 - 375*x + 1375 with S = (Fractional ideal (5, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5), Fractional ideal (11, 1/275*a^3 + 4/55*a^2 - 5/11*a + 9)) sage: U.gens() (u0, u1, u2, u3) sage: U.gens_values() # random [-1/275*a^3 + 7/55*a^2 - 6/11*a + 4, 1/275*a^3 + 4/55*a^2 - 5/11*a + 3, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5, -14/275*a^3 + 21/55*a^2 - 29/11*a + 6] sage: U.invariants() (10, 0, 0, 0) sage: [u.multiplicative_order() for u in U.gens()] [10, +Infinity, +Infinity, +Infinity] sage: U.primes() (Fractional ideal (5, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5), Fractional ideal (11, 1/275*a^3 + 4/55*a^2 - 5/11*a + 9))
>>> from sage.all import * >>> x = polygen(QQ) >>> K = NumberField(x**Integer(4) - Integer(10)*x**Integer(3) + Integer(20)*Integer(5)*x**Integer(2) - Integer(15)*Integer(5)**Integer(2)*x + Integer(11)*Integer(5)**Integer(3), names=('a',)); (a,) = K._first_ngens(1) >>> U = K.S_unit_group(S=a); U S-unit group with structure C10 x Z x Z x Z of Number Field in a with defining polynomial x^4 - 10*x^3 + 100*x^2 - 375*x + 1375 with S = (Fractional ideal (5, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5), Fractional ideal (11, 1/275*a^3 + 4/55*a^2 - 5/11*a + 9)) >>> U.gens() (u0, u1, u2, u3) >>> U.gens_values() # random [-1/275*a^3 + 7/55*a^2 - 6/11*a + 4, 1/275*a^3 + 4/55*a^2 - 5/11*a + 3, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5, -14/275*a^3 + 21/55*a^2 - 29/11*a + 6] >>> U.invariants() (10, 0, 0, 0) >>> [u.multiplicative_order() for u in U.gens()] [10, +Infinity, +Infinity, +Infinity] >>> U.primes() (Fractional ideal (5, 1/275*a^3 + 4/55*a^2 - 5/11*a + 5), Fractional ideal (11, 1/275*a^3 + 4/55*a^2 - 5/11*a + 9))
With the default value of \(S\), the S-unit group is the same as the global unit group:
sage: x = polygen(QQ) sage: K.<a> = NumberField(x^3 + 3) sage: U = K.unit_group(proof=False) sage: U.is_isomorphic(K.S_unit_group(proof=False)) True
>>> from sage.all import * >>> x = polygen(QQ) >>> K = NumberField(x**Integer(3) + Integer(3), names=('a',)); (a,) = K._first_ngens(1) >>> U = K.unit_group(proof=False) >>> U.is_isomorphic(K.S_unit_group(proof=False)) True
The value of \(S\) may be specified as a list of prime ideals, or an ideal, or an element of the field:
sage: K.<a> = NumberField(x^3 + 3) sage: U = K.S_unit_group(proof=False, S=K.ideal(6).prime_factors()); U S-unit group with structure C2 x Z x Z x Z x Z of Number Field in a with defining polynomial x^3 + 3 with S = (Fractional ideal (-a^2 + a - 1), Fractional ideal (a + 1), Fractional ideal (a)) sage: K.<a> = NumberField(x^3 + 3) sage: U = K.S_unit_group(proof=False, S=K.ideal(6)); U S-unit group with structure C2 x Z x Z x Z x Z of Number Field in a with defining polynomial x^3 + 3 with S = (Fractional ideal (-a^2 + a - 1), Fractional ideal (a + 1), Fractional ideal (a)) sage: K.<a> = NumberField(x^3 + 3) sage: U = K.S_unit_group(proof=False, S=6); U S-unit group with structure C2 x Z x Z x Z x Z of Number Field in a with defining polynomial x^3 + 3 with S = (Fractional ideal (-a^2 + a - 1), Fractional ideal (a + 1), Fractional ideal (a)) sage: U.primes() (Fractional ideal (-a^2 + a - 1), Fractional ideal (a + 1), Fractional ideal (a)) sage: U.gens() (u0, u1, u2, u3, u4) sage: U.gens_values() [-1, a^2 - 2, -a^2 + a - 1, a + 1, a]
>>> from sage.all import * >>> K = NumberField(x**Integer(3) + Integer(3), names=('a',)); (a,) = K._first_ngens(1) >>> U = K.S_unit_group(proof=False, S=K.ideal(Integer(6)).prime_factors()); U S-unit group with structure C2 x Z x Z x Z x Z of Number Field in a with defining polynomial x^3 + 3 with S = (Fractional ideal (-a^2 + a - 1), Fractional ideal (a + 1), Fractional ideal (a)) >>> K = NumberField(x**Integer(3) + Integer(3), names=('a',)); (a,) = K._first_ngens(1) >>> U = K.S_unit_group(proof=False, S=K.ideal(Integer(6))); U S-unit group with structure C2 x Z x Z x Z x Z of Number Field in a with defining polynomial x^3 + 3 with S = (Fractional ideal (-a^2 + a - 1), Fractional ideal (a + 1), Fractional ideal (a)) >>> K = NumberField(x**Integer(3) + Integer(3), names=('a',)); (a,) = K._first_ngens(1) >>> U = K.S_unit_group(proof=False, S=Integer(6)); U S-unit group with structure C2 x Z x Z x Z x Z of Number Field in a with defining polynomial x^3 + 3 with S = (Fractional ideal (-a^2 + a - 1), Fractional ideal (a + 1), Fractional ideal (a)) >>> U.primes() (Fractional ideal (-a^2 + a - 1), Fractional ideal (a + 1), Fractional ideal (a)) >>> U.gens() (u0, u1, u2, u3, u4) >>> U.gens_values() [-1, a^2 - 2, -a^2 + a - 1, a + 1, a]
The exp and log methods can be used to create \(S\)-units from sequences of exponents, and recover the exponents:
sage: U.gens_orders() (2, 0, 0, 0, 0) sage: u = U.exp((3,1,4,1,5)); u -6*a^2 + 18*a - 54 sage: u.norm().factor() -1 * 2^9 * 3^5 sage: U.log(u) (1, 1, 4, 1, 5)
>>> from sage.all import * >>> U.gens_orders() (2, 0, 0, 0, 0) >>> u = U.exp((Integer(3),Integer(1),Integer(4),Integer(1),Integer(5))); u -6*a^2 + 18*a - 54 >>> u.norm().factor() -1 * 2^9 * 3^5 >>> U.log(u) (1, 1, 4, 1, 5)
- S_unit_solutions(S=[], prec=106, include_exponents=False, include_bound=False, proof=None)[source]#
Return all solutions to the \(S\)-unit equation \(x + y = 1\) over
self
.INPUT:
S
– a list of finite primes in this number fieldprec
– precision used for computations in real, complex, and p-adic fields (default: 106)include_exponents
– whether to include the exponent vectors in the returned value (default:True
).include_bound
– whether to return the final computed bound (default:False
)proof
– ifFalse
, assume the GRH in computing the class group. Default isTrue
.
OUTPUT:
A list \([(A_1, B_1, x_1, y_1), (A_2, B_2, x_2, y_2), \dots, (A_n, B_n, x_n, y_n)]\) of tuples such that:
The first two entries are tuples \(A_i = (a_0, a_1, \dots, a_t)\) and \(B_i = (b_0, b_1, \dots, b_t)\) of exponents. These will be omitted if
include_exponents
isFalse
.The last two entries are \(S\)-units \(x_i\) and \(y_i\) in
self
with \(x_i + y_i = 1\).If the default generators for the \(S\)-units of
self
are \((\rho_0, \rho_1, \dots, \rho_t)`\), then these satisfy \(x_i = \prod(\rho_i)^{(a_i)}\) and \(y_i = \prod(\rho_i)^{(b_i)}\).
If
include_bound
isTrue
, will return a pair(sols, bound)
wheresols
is as above andbound
is the bound used for the entries in the exponent vectors.EXAMPLES:
sage: # needs sage.rings.padics sage: x = polygen(QQ, 'x') sage: K.<xi> = NumberField(x^2 + x + 1) sage: S = K.primes_above(3) sage: K.S_unit_solutions(S) # random, due to ordering [(xi + 2, -xi - 1), (1/3*xi + 2/3, -1/3*xi + 1/3), (-xi, xi + 1), (-xi + 1, xi)]
>>> from sage.all import * >>> # needs sage.rings.padics >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + x + Integer(1), names=('xi',)); (xi,) = K._first_ngens(1) >>> S = K.primes_above(Integer(3)) >>> K.S_unit_solutions(S) # random, due to ordering [(xi + 2, -xi - 1), (1/3*xi + 2/3, -1/3*xi + 1/3), (-xi, xi + 1), (-xi + 1, xi)]
You can get the exponent vectors:
sage: # needs sage.rings.padics sage: K.S_unit_solutions(S, include_exponents=True) # random, due to ordering [((2, 1), (4, 0), xi + 2, -xi - 1), ((5, -1), (4, -1), 1/3*xi + 2/3, -1/3*xi + 1/3), ((5, 0), (1, 0), -xi, xi + 1), ((1, 1), (2, 0), -xi + 1, xi)]
>>> from sage.all import * >>> # needs sage.rings.padics >>> K.S_unit_solutions(S, include_exponents=True) # random, due to ordering [((2, 1), (4, 0), xi + 2, -xi - 1), ((5, -1), (4, -1), 1/3*xi + 2/3, -1/3*xi + 1/3), ((5, 0), (1, 0), -xi, xi + 1), ((1, 1), (2, 0), -xi + 1, xi)]
And the computed bound:
sage: # needs sage.rings.padics sage: solutions, bound = K.S_unit_solutions(S, prec=100, include_bound=True) sage: bound 7
>>> from sage.all import * >>> # needs sage.rings.padics >>> solutions, bound = K.S_unit_solutions(S, prec=Integer(100), include_bound=True) >>> bound 7
- S_units(S, proof=True)[source]#
Return a list of generators of the S-units.
INPUT:
S
– a set of primes of the base fieldproof
– ifFalse
, assume the GRH in computing the class group
OUTPUT: A list of generators of the unit group.
Note
For more functionality see the function
S_unit_group()
.EXAMPLES:
sage: K.<a> = QuadraticField(-3) sage: K.unit_group() Unit group with structure C6 of Number Field in a with defining polynomial x^2 + 3 with a = 1.732050807568878?*I sage: K.S_units([]) # random [1/2*a + 1/2] sage: K.S_units([])[0].multiplicative_order() 6
>>> from sage.all import * >>> K = QuadraticField(-Integer(3), names=('a',)); (a,) = K._first_ngens(1) >>> K.unit_group() Unit group with structure C6 of Number Field in a with defining polynomial x^2 + 3 with a = 1.732050807568878?*I >>> K.S_units([]) # random [1/2*a + 1/2] >>> K.S_units([])[Integer(0)].multiplicative_order() 6
An example in a relative extension (see Issue #8722):
sage: x = polygen(QQ, 'x') sage: L.<a,b> = NumberField([x^2 + 1, x^2 - 5]) sage: p = L.ideal((-1/2*b - 1/2)*a + 1/2*b - 1/2) sage: W = L.S_units([p]); [x.norm() for x in W] [9, 1, 1]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> L = NumberField([x**Integer(2) + Integer(1), x**Integer(2) - Integer(5)], names=('a', 'b',)); (a, b,) = L._first_ngens(2) >>> p = L.ideal((-Integer(1)/Integer(2)*b - Integer(1)/Integer(2))*a + Integer(1)/Integer(2)*b - Integer(1)/Integer(2)) >>> W = L.S_units([p]); [x.norm() for x in W] [9, 1, 1]
Our generators should have the correct parent (Issue #9367):
sage: _.<x> = QQ[] sage: L.<alpha> = NumberField(x^3 + x + 1) sage: p = L.S_units([ L.ideal(7) ]) sage: p[0].parent() Number Field in alpha with defining polynomial x^3 + x + 1
>>> from sage.all import * >>> _ = QQ['x']; (x,) = _._first_ngens(1) >>> L = NumberField(x**Integer(3) + x + Integer(1), names=('alpha',)); (alpha,) = L._first_ngens(1) >>> p = L.S_units([ L.ideal(Integer(7)) ]) >>> p[Integer(0)].parent() Number Field in alpha with defining polynomial x^3 + x + 1
- absolute_degree()[source]#
Return the degree of
self
over \(\QQ\).EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(3) + x**Integer(2) + Integer(997)*x + Integer(1), 'a').absolute_degree() 3 >>> NumberField(x + Integer(1), 'a').absolute_degree() 1 >>> NumberField(x**Integer(997) + Integer(17)*x + Integer(3), 'a', check=False).absolute_degree() 997
- absolute_field(names)[source]#
Return
self
as an absolute number field.INPUT:
names
– string; name of generator of the absolute field
OUTPUT:
K
– this number field (since it is already absolute)
Also,
K.structure()
returnsfrom_K
andto_K
, wherefrom_K
is an isomorphism from \(K\) toself
andto_K
is an isomorphism fromself
to \(K\).EXAMPLES:
sage: K = CyclotomicField(5) sage: K.absolute_field('a') Number Field in a with defining polynomial x^4 + x^3 + x^2 + x + 1
>>> from sage.all import * >>> K = CyclotomicField(Integer(5)) >>> K.absolute_field('a') Number Field in a with defining polynomial x^4 + x^3 + x^2 + x + 1
- absolute_polynomial_ntl()[source]#
Alias for
polynomial_ntl()
. Mostly for internal use.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: NumberField(x^2 + (2/3)*x - 9/17,'a').absolute_polynomial_ntl() ([-27 34 51], 51)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + (Integer(2)/Integer(3))*x - Integer(9)/Integer(17),'a').absolute_polynomial_ntl() ([-27 34 51], 51)
- algebraic_closure()[source]#
Return the algebraic closure of
self
(which isQQbar
).EXAMPLES:
sage: K.<i> = QuadraticField(-1) sage: K.algebraic_closure() Algebraic Field sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^3 - 2) sage: K.algebraic_closure() Algebraic Field sage: K = CyclotomicField(23) sage: K.algebraic_closure() Algebraic Field
>>> from sage.all import * >>> K = QuadraticField(-Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.algebraic_closure() Algebraic Field >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> K.algebraic_closure() Algebraic Field >>> K = CyclotomicField(Integer(23)) >>> K.algebraic_closure() Algebraic Field
- change_generator(alpha, name=None, names=None)[source]#
Given the number field
self
, construct another isomorphic number field \(K\) generated by the elementalpha
ofself
, along with isomorphisms from \(K\) toself
and fromself
to \(K\).EXAMPLES:
sage: x = polygen(ZZ, 'x') 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 with i0 = 1/2*i + 3 sage: from_K Ring morphism: From: Number Field in i0 with defining polynomial x^2 - 6*x + 37/4 with i0 = 1/2*i + 3 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 with i0 = 1/2*i + 3 Defn: i |--> 2*i0 - 6
>>> from sage.all import * >>> x = polygen(ZZ, 'x') >>> L = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = L._first_ngens(1); L Number Field in i with defining polynomial x^2 + 1 >>> K, from_K, to_K = L.change_generator(i/Integer(2) + Integer(3)) >>> K Number Field in i0 with defining polynomial x^2 - 6*x + 37/4 with i0 = 1/2*i + 3 >>> from_K Ring morphism: From: Number Field in i0 with defining polynomial x^2 - 6*x + 37/4 with i0 = 1/2*i + 3 To: Number Field in i with defining polynomial x^2 + 1 Defn: i0 |--> 1/2*i + 3 >>> 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 with i0 = 1/2*i + 3 Defn: i |--> 2*i0 - 6
We can also do
sage: K.<c>, from_K, to_K = L.change_generator(i/2 + 3); K Number Field in c with defining polynomial x^2 - 6*x + 37/4 with c = 1/2*i + 3
>>> from sage.all import * >>> K, from_K, to_K = L.change_generator(i/Integer(2) + Integer(3), names=('c',)); (c,) = K._first_ngens(1); K Number Field in c with defining polynomial x^2 - 6*x + 37/4 with c = 1/2*i + 3
We compute the image of the generator \(\sqrt{-1}\) of \(L\).
sage: to_K(i) 2*c - 6
>>> from sage.all import * >>> to_K(i) 2*c - 6
Note that the image is indeed a square root of \(-1\).
sage: to_K(i)^2 -1 sage: from_K(to_K(i)) i sage: to_K(from_K(c)) c
>>> from sage.all import * >>> to_K(i)**Integer(2) -1 >>> from_K(to_K(i)) i >>> to_K(from_K(c)) c
- characteristic()[source]#
Return the characteristic of this number field, which is of course 0.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: k.<a> = NumberField(x^99 + 2); k Number Field in a with defining polynomial x^99 + 2 sage: k.characteristic() 0
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(99) + Integer(2), names=('a',)); (a,) = k._first_ngens(1); k Number Field in a with defining polynomial x^99 + 2 >>> k.characteristic() 0
- class_group(proof=None, names='c')[source]#
Return the class group of the ring of integers of this number field.
INPUT:
proof
– ifTrue
then compute the class group provably correctly. Default isTrue
. Callnumber_field_proof()
to change this default globally.names
– names of the generators of this class group.
OUTPUT: The class group of this number field.
EXAMPLES:
sage: x = polygen(QQ, 'x') 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),)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(23), names=('a',)); (a,) = K._first_ngens(1) >>> G = K.class_group(); G Class group of order 3 with structure C3 of Number Field in a with defining polynomial x^2 + 23 >>> G.gen(0) Fractional ideal class (2, 1/2*a - 1/2) >>> 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),)
>>> from sage.all import * >>> G.number_field() Number Field in a with defining polynomial x^2 + 23 >>> G is K.class_group() True >>> G is K.class_group(proof=False) False >>> 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.0 # random Fractional ideal class (41, a + 10) sage: G.0^38 Trivial principal fractional ideal class sage: G.1 # random Fractional ideal class (2, -1/2*a) sage: G.1^2 Trivial principal fractional ideal class
>>> from sage.all import * >>> k = NumberField(x**Integer(2) + Integer(20072), names=('a',)); (a,) = k._first_ngens(1) >>> 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 >>> G.gen(0) # random Fractional ideal class (41, a + 10) >>> G.gen(0)**Integer(38) Trivial principal fractional ideal class >>> G.gen(1) # random Fractional ideal class (2, -1/2*a) >>> G.gen(1)**Integer(2) Trivial principal fractional ideal class
Class groups of Hecke polynomials tend to be very small:
sage: # needs sage.modular 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: [NumberField(g,'a').class_group().order() for g,_ in f.factor()] [1, 1, 1]
>>> from sage.all import * >>> # needs sage.modular >>> f = ModularForms(Integer(97), Integer(2)).T(Integer(2)).charpoly() >>> f.factor() (x - 3) * (x^3 + 4*x^2 + 3*x - 1) * (x^4 - 3*x^3 - x^2 + 6*x - 1) >>> [NumberField(g,'a').class_group().order() for g,_ in f.factor()] [1, 1, 1]
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 functionproof.number_field(False)
. It can easily take 1000’s of times longer to do computations withproof=True
(the default).
- class_number(proof=None)[source]#
Return the class number of this number field, as an integer.
INPUT:
proof
– bool (default:True
unless you callednumber_field_proof
)
EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + Integer(23), 'a').class_number() 3 >>> NumberField(x**Integer(2) + Integer(163), 'a').class_number() 1 >>> NumberField(x**Integer(3) + x**Integer(2) + Integer(997)*x + Integer(1), 'a').class_number(proof=False) 1539
- completely_split_primes(B=200)[source]#
Return a list of rational primes which split completely in the number field \(K\).
INPUT:
B
– a positive integer bound (default: 200)
OUTPUT:
A list of all primes \(p < B\) which split completely in
K
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<xi> = NumberField(x^3 - 3*x + 1) sage: K.completely_split_primes(100) [17, 19, 37, 53, 71, 73, 89]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) - Integer(3)*x + Integer(1), names=('xi',)); (xi,) = K._first_ngens(1) >>> K.completely_split_primes(Integer(100)) [17, 19, 37, 53, 71, 73, 89]
- completion(p, prec, extras={})[source]#
Return the completion of
self
at \(p\) to the specified precision.Only implemented at archimedean places, and then only if an embedding has been fixed.
EXAMPLES:
sage: K.<a> = QuadraticField(2) sage: K.completion(infinity, 100) Real Field with 100 bits of precision sage: K.<zeta> = CyclotomicField(12) sage: K.completion(infinity, 53, extras={'type': 'RDF'}) Complex Double Field sage: zeta + 1.5 # implicit test 2.36602540378444 + 0.500000000000000*I
>>> from sage.all import * >>> K = QuadraticField(Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> K.completion(infinity, Integer(100)) Real Field with 100 bits of precision >>> K = CyclotomicField(Integer(12), names=('zeta',)); (zeta,) = K._first_ngens(1) >>> K.completion(infinity, Integer(53), extras={'type': 'RDF'}) Complex Double Field >>> zeta + RealNumber('1.5') # implicit test 2.36602540378444 + 0.500000000000000*I
- complex_conjugation()[source]#
Return the complex conjugation of
self
.This is only well-defined for fields contained in CM fields (i.e. for totally real fields and CM fields). Recall that a CM field is a totally imaginary quadratic extension of a totally real field. For other fields, a
ValueError
is raised.EXAMPLES:
sage: QuadraticField(-1, 'I').complex_conjugation() Ring endomorphism of Number Field in I with defining polynomial x^2 + 1 with I = 1*I Defn: I |--> -I sage: CyclotomicField(8).complex_conjugation() Ring endomorphism of Cyclotomic Field of order 8 and degree 4 Defn: zeta8 |--> -zeta8^3 sage: QuadraticField(5, 'a').complex_conjugation() Identity endomorphism of Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? sage: x = polygen(QQ, 'x') sage: F = NumberField(x^4 + x^3 - 3*x^2 - x + 1, 'a') sage: F.is_totally_real() True sage: F.complex_conjugation() Identity endomorphism of Number Field in a with defining polynomial x^4 + x^3 - 3*x^2 - x + 1 sage: F.<b> = NumberField(x^2 - 2) sage: F.extension(x^2 + 1, 'a').complex_conjugation() Relative number field endomorphism of Number Field in a with defining polynomial x^2 + 1 over its base field Defn: a |--> -a b |--> b sage: F2.<b> = NumberField(x^2 + 2) sage: K2.<a> = F2.extension(x^2 + 1) sage: cc = K2.complex_conjugation() sage: cc(a) -a sage: cc(b) -b
>>> from sage.all import * >>> QuadraticField(-Integer(1), 'I').complex_conjugation() Ring endomorphism of Number Field in I with defining polynomial x^2 + 1 with I = 1*I Defn: I |--> -I >>> CyclotomicField(Integer(8)).complex_conjugation() Ring endomorphism of Cyclotomic Field of order 8 and degree 4 Defn: zeta8 |--> -zeta8^3 >>> QuadraticField(Integer(5), 'a').complex_conjugation() Identity endomorphism of Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? >>> x = polygen(QQ, 'x') >>> F = NumberField(x**Integer(4) + x**Integer(3) - Integer(3)*x**Integer(2) - x + Integer(1), 'a') >>> F.is_totally_real() True >>> F.complex_conjugation() Identity endomorphism of Number Field in a with defining polynomial x^4 + x^3 - 3*x^2 - x + 1 >>> F = NumberField(x**Integer(2) - Integer(2), names=('b',)); (b,) = F._first_ngens(1) >>> F.extension(x**Integer(2) + Integer(1), 'a').complex_conjugation() Relative number field endomorphism of Number Field in a with defining polynomial x^2 + 1 over its base field Defn: a |--> -a b |--> b >>> F2 = NumberField(x**Integer(2) + Integer(2), names=('b',)); (b,) = F2._first_ngens(1) >>> K2 = F2.extension(x**Integer(2) + Integer(1), names=('a',)); (a,) = K2._first_ngens(1) >>> cc = K2.complex_conjugation() >>> cc(a) -a >>> cc(b) -b
- complex_embeddings(prec=53)[source]#
Return all homomorphisms of this number field into the approximate complex field with precision
prec
.This always embeds into an MPFR based complex field. If you want embeddings into the 53-bit double precision, which is faster, use
self.embeddings(CDF)
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: k.<a> = NumberField(x^5 + x + 17) sage: v = k.complex_embeddings() sage: ls = [phi(k.0^2) for phi in v]; ls # random order [2.97572074038..., -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: ls = K.complex_embeddings(); ls # random order [ Ring morphism: From: Number Field in a with defining polynomial x^3 + 2 To: Complex Double Field Defn: a |--> -1.25992104989..., 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 ]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(5) + x + Integer(17), names=('a',)); (a,) = k._first_ngens(1) >>> v = k.complex_embeddings() >>> ls = [phi(k.gen(0)**Integer(2)) for phi in v]; ls # random order [2.97572074038..., -2.40889943716 + 1.90254105304*I, -2.40889943716 - 1.90254105304*I, 0.921039066973 + 3.07553311885*I, 0.921039066973 - 3.07553311885*I] >>> K = NumberField(x**Integer(3) + Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> ls = K.complex_embeddings(); ls # random order [ Ring morphism: From: Number Field in a with defining polynomial x^3 + 2 To: Complex Double Field Defn: a |--> -1.25992104989..., 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(other, names=None, both_maps=False, preserve_embedding=True)[source]#
Return the possible composite number fields formed from
self
andother
.INPUT:
other
– number fieldnames
– generator name for composite fieldsboth_maps
– boolean (default:False
)preserve_embedding
– boolean (default:True
)
OUTPUT:
A list of the composite fields, possibly with maps.
If
both_maps
isTrue
, the list consists of quadruples(F, self_into_F, other_into_F, k)
such thatself_into_F
is an embedding ofself
inF
,other_into_F
is an embedding of inF
, andk
is one of the following:an integer such that
F.gen()
equalsother_into_F(other.gen()) + k*self_into_F(self.gen())
;Infinity
, in which caseF.gen()
equalsself_into_F(self.gen())
;None
(whenother
is a relative number field).
If both
self
andother
have embeddings into an ambient field, then eachF
will have an embedding with respect to which bothself_into_F
andother_into_F
will be compatible with the ambient embeddings.If
preserve_embedding
isTrue
and ifself
andother
both have embeddings into the same ambient field, or into fields which are contained in a common field, only the compositum respecting both embeddings is returned. In all other cases, all possible composite number fields are returned.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^4 - 2) sage: K.composite_fields(K) [Number Field in a with defining polynomial x^4 - 2, Number Field in a0 with defining polynomial x^8 + 28*x^4 + 2500]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(4) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> K.composite_fields(K) [Number Field in a with defining polynomial x^4 - 2, Number Field in a0 with defining polynomial x^8 + 28*x^4 + 2500]
A particular compositum is selected, together with compatible maps into the compositum, if the fields are endowed with a real or complex embedding:
sage: # needs sage.symbolic sage: K1 = NumberField(x^4 - 2, 'a', embedding=RR(2^(1/4))) sage: K2 = NumberField(x^4 - 2, 'a', embedding=RR(-2^(1/4))) sage: K1.composite_fields(K2) [Number Field in a with defining polynomial x^4 - 2 with a = 1.189207115002722?] sage: [F, f, g, k], = K1.composite_fields(K2, both_maps=True); F Number Field in a with defining polynomial x^4 - 2 with a = 1.189207115002722? sage: f(K1.0), g(K2.0) (a, -a)
>>> from sage.all import * >>> # needs sage.symbolic >>> K1 = NumberField(x**Integer(4) - Integer(2), 'a', embedding=RR(Integer(2)**(Integer(1)/Integer(4)))) >>> K2 = NumberField(x**Integer(4) - Integer(2), 'a', embedding=RR(-Integer(2)**(Integer(1)/Integer(4)))) >>> K1.composite_fields(K2) [Number Field in a with defining polynomial x^4 - 2 with a = 1.189207115002722?] >>> [F, f, g, k], = K1.composite_fields(K2, both_maps=True); F Number Field in a with defining polynomial x^4 - 2 with a = 1.189207115002722? >>> f(K1.gen(0)), g(K2.gen(0)) (a, -a)
With
preserve_embedding
set toFalse
, the embeddings are ignored:sage: K1.composite_fields(K2, preserve_embedding=False) # needs sage.symbolic [Number Field in a with defining polynomial x^4 - 2 with a = 1.189207115002722?, Number Field in a0 with defining polynomial x^8 + 28*x^4 + 2500]
>>> from sage.all import * >>> K1.composite_fields(K2, preserve_embedding=False) # needs sage.symbolic [Number Field in a with defining polynomial x^4 - 2 with a = 1.189207115002722?, Number Field in a0 with defining polynomial x^8 + 28*x^4 + 2500]
Changing the embedding selects a different compositum:
sage: K3 = NumberField(x^4 - 2, 'a', embedding=CC(2^(1/4)*I)) # needs sage.symbolic sage: [F, f, g, k], = K1.composite_fields(K3, both_maps=True); F # needs sage.symbolic Number Field in a0 with defining polynomial x^8 + 28*x^4 + 2500 with a0 = -2.378414230005443? + 1.189207115002722?*I sage: f(K1.0), g(K3.0) # needs sage.symbolic (1/240*a0^5 - 41/120*a0, 1/120*a0^5 + 19/60*a0)
>>> from sage.all import * >>> K3 = NumberField(x**Integer(4) - Integer(2), 'a', embedding=CC(Integer(2)**(Integer(1)/Integer(4))*I)) # needs sage.symbolic >>> [F, f, g, k], = K1.composite_fields(K3, both_maps=True); F # needs sage.symbolic Number Field in a0 with defining polynomial x^8 + 28*x^4 + 2500 with a0 = -2.378414230005443? + 1.189207115002722?*I >>> f(K1.gen(0)), g(K3.gen(0)) # needs sage.symbolic (1/240*a0^5 - 41/120*a0, 1/120*a0^5 + 19/60*a0)
If no embeddings are specified, the maps into the compositum are chosen arbitrarily:
sage: Q1.<a> = NumberField(x^4 + 10*x^2 + 1) sage: Q2.<b> = NumberField(x^4 + 16*x^2 + 4) sage: Q1.composite_fields(Q2, 'c') [Number Field in c with defining polynomial x^8 + 64*x^6 + 904*x^4 + 3840*x^2 + 3600] sage: F, Q1_into_F, Q2_into_F, k = Q1.composite_fields(Q2, 'c', ....: both_maps=True)[0] sage: Q1_into_F Ring morphism: From: Number Field in a with defining polynomial x^4 + 10*x^2 + 1 To: Number Field in c with defining polynomial x^8 + 64*x^6 + 904*x^4 + 3840*x^2 + 3600 Defn: a |--> 19/14400*c^7 + 137/1800*c^5 + 2599/3600*c^3 + 8/15*c
>>> from sage.all import * >>> Q1 = NumberField(x**Integer(4) + Integer(10)*x**Integer(2) + Integer(1), names=('a',)); (a,) = Q1._first_ngens(1) >>> Q2 = NumberField(x**Integer(4) + Integer(16)*x**Integer(2) + Integer(4), names=('b',)); (b,) = Q2._first_ngens(1) >>> Q1.composite_fields(Q2, 'c') [Number Field in c with defining polynomial x^8 + 64*x^6 + 904*x^4 + 3840*x^2 + 3600] >>> F, Q1_into_F, Q2_into_F, k = Q1.composite_fields(Q2, 'c', ... both_maps=True)[Integer(0)] >>> Q1_into_F Ring morphism: From: Number Field in a with defining polynomial x^4 + 10*x^2 + 1 To: Number Field in c with defining polynomial x^8 + 64*x^6 + 904*x^4 + 3840*x^2 + 3600 Defn: a |--> 19/14400*c^7 + 137/1800*c^5 + 2599/3600*c^3 + 8/15*c
This is just one of four embeddings of
Q1
intoF
:sage: Hom(Q1, F).order() 4
>>> from sage.all import * >>> Hom(Q1, F).order() 4
Note that even with
preserve_embedding=True
, this method may fail to recognize that the two number fields have compatible embeddings, and hence return several composite number fields:sage: x = polygen(ZZ) sage: A.<a> = NumberField(x^3 - 7, embedding=CC(-0.95+1.65*I)) sage: r = QQbar.polynomial_root(x^9 - 7, RIF(1.2, 1.3)) sage: B.<a> = NumberField(x^9 - 7, embedding=r) sage: len(A.composite_fields(B, preserve_embedding=True)) 2
>>> from sage.all import * >>> x = polygen(ZZ) >>> A = NumberField(x**Integer(3) - Integer(7), embedding=CC(-RealNumber('0.95')+RealNumber('1.65')*I), names=('a',)); (a,) = A._first_ngens(1) >>> r = QQbar.polynomial_root(x**Integer(9) - Integer(7), RIF(RealNumber('1.2'), RealNumber('1.3'))) >>> B = NumberField(x**Integer(9) - Integer(7), embedding=r, names=('a',)); (a,) = B._first_ngens(1) >>> len(A.composite_fields(B, preserve_embedding=True)) 2
- conductor(check_abelian=True)[source]#
Computes the conductor of the abelian field \(K\). If
check_abelian
is set toFalse
and the field is not an abelian extension of \(\QQ\), the output is not meaningful.INPUT:
check_abelian
– a boolean (default:True
); check to see that this is an abelian extension of \(\QQ\)
OUTPUT:
Integer which is the conductor of the field.
EXAMPLES:
sage: # needs sage.groups sage: K = CyclotomicField(27) sage: k = K.subfields(9)[0][0] sage: k.conductor() 27 sage: x = polygen(QQ, 'x') sage: K.<t> = NumberField(x^3 + x^2 - 2*x - 1) sage: K.conductor() 7 sage: K.<t> = NumberField(x^3 + x^2 - 36*x - 4) sage: K.conductor() 109 sage: K = CyclotomicField(48) sage: k = K.subfields(16)[0][0] sage: k.conductor() 48 sage: NumberField(x,'a').conductor() 1 sage: NumberField(x^8 - 8*x^6 + 19*x^4 - 12*x^2 + 1, 'a').conductor() 40 sage: NumberField(x^8 + 7*x^4 + 1, 'a').conductor() 40 sage: NumberField(x^8 - 40*x^6 + 500*x^4 - 2000*x^2 + 50, 'a').conductor() 160
>>> from sage.all import * >>> # needs sage.groups >>> K = CyclotomicField(Integer(27)) >>> k = K.subfields(Integer(9))[Integer(0)][Integer(0)] >>> k.conductor() 27 >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) + x**Integer(2) - Integer(2)*x - Integer(1), names=('t',)); (t,) = K._first_ngens(1) >>> K.conductor() 7 >>> K = NumberField(x**Integer(3) + x**Integer(2) - Integer(36)*x - Integer(4), names=('t',)); (t,) = K._first_ngens(1) >>> K.conductor() 109 >>> K = CyclotomicField(Integer(48)) >>> k = K.subfields(Integer(16))[Integer(0)][Integer(0)] >>> k.conductor() 48 >>> NumberField(x,'a').conductor() 1 >>> NumberField(x**Integer(8) - Integer(8)*x**Integer(6) + Integer(19)*x**Integer(4) - Integer(12)*x**Integer(2) + Integer(1), 'a').conductor() 40 >>> NumberField(x**Integer(8) + Integer(7)*x**Integer(4) + Integer(1), 'a').conductor() 40 >>> NumberField(x**Integer(8) - Integer(40)*x**Integer(6) + Integer(500)*x**Integer(4) - Integer(2000)*x**Integer(2) + Integer(50), 'a').conductor() 160
ALGORITHM:
For odd primes, it is easy to compute from the ramification index because the \(p\)-Sylow subgroup is cyclic. For \(p=2\), there are two choices for a given ramification index. They can be distinguished by the parity of the exponent in the discriminant of a 2-adic completion.
- construction()[source]#
Construction of
self
.EXAMPLES:
sage: x = polygen(ZZ, 'x') sage: K.<a> = NumberField(x^3 + x^2 + 1, embedding=CC.gen()) sage: F, R = K.construction() sage: F AlgebraicExtensionFunctor sage: R Rational Field
>>> from sage.all import * >>> x = polygen(ZZ, 'x') >>> K = NumberField(x**Integer(3) + x**Integer(2) + Integer(1), embedding=CC.gen(), names=('a',)); (a,) = K._first_ngens(1) >>> F, R = K.construction() >>> F AlgebraicExtensionFunctor >>> R Rational Field
The construction functor respects distinguished embeddings:
sage: F(R) is K True sage: F.embeddings [0.2327856159383841? + 0.7925519925154479?*I]
>>> from sage.all import * >>> F(R) is K True >>> F.embeddings [0.2327856159383841? + 0.7925519925154479?*I]
- decomposition_type(p)[source]#
Return how the given prime of the base field splits in this number field.
INPUT:
p
– a prime element or ideal of the base field.
OUTPUT:
A list of triples \((e, f, g)\) where
\(e\) is the ramification index,
\(f\) is the residue class degree,
\(g\) is the number of primes above \(p\) with given \(e\) and \(f\)
EXAMPLES:
sage: R.<x> = ZZ[] sage: K.<a> = NumberField(x^20 + 3*x^18 + 15*x^16 + 28*x^14 + 237*x^12 + 579*x^10 ....: + 1114*x^8 + 1470*x^6 + 2304*x^4 + 1296*x^2 + 729) sage: K.is_galois() # needs sage.groups True sage: K.discriminant().factor() 2^20 * 3^10 * 53^10 sage: K.decomposition_type(2) [(2, 5, 2)] sage: K.decomposition_type(3) [(2, 1, 10)] sage: K.decomposition_type(53) [(2, 2, 5)]
>>> from sage.all import * >>> R = ZZ['x']; (x,) = R._first_ngens(1) >>> K = NumberField(x**Integer(20) + Integer(3)*x**Integer(18) + Integer(15)*x**Integer(16) + Integer(28)*x**Integer(14) + Integer(237)*x**Integer(12) + Integer(579)*x**Integer(10) ... + Integer(1114)*x**Integer(8) + Integer(1470)*x**Integer(6) + Integer(2304)*x**Integer(4) + Integer(1296)*x**Integer(2) + Integer(729), names=('a',)); (a,) = K._first_ngens(1) >>> K.is_galois() # needs sage.groups True >>> K.discriminant().factor() 2^20 * 3^10 * 53^10 >>> K.decomposition_type(Integer(2)) [(2, 5, 2)] >>> K.decomposition_type(Integer(3)) [(2, 1, 10)] >>> K.decomposition_type(Integer(53)) [(2, 2, 5)]
This example is only ramified at 11:
sage: K.<a> = NumberField(x^24 + 11^2*(90*x^12 - 640*x^8 + 2280*x^6 ....: - 512*x^4 + 2432/11*x^2 - 11)) sage: K.discriminant().factor() -1 * 11^43 sage: K.decomposition_type(11) [(1, 1, 2), (22, 1, 1)]
>>> from sage.all import * >>> K = NumberField(x**Integer(24) + Integer(11)**Integer(2)*(Integer(90)*x**Integer(12) - Integer(640)*x**Integer(8) + Integer(2280)*x**Integer(6) ... - Integer(512)*x**Integer(4) + Integer(2432)/Integer(11)*x**Integer(2) - Integer(11)), names=('a',)); (a,) = K._first_ngens(1) >>> K.discriminant().factor() -1 * 11^43 >>> K.decomposition_type(Integer(11)) [(1, 1, 2), (22, 1, 1)]
Computing the decomposition type is feasible even in large degree:
sage: K.<a> = NumberField(x^144 + 123*x^72 + 321*x^36 + 13*x^18 + 11) sage: K.discriminant().factor(limit=100000) 2^144 * 3^288 * 7^18 * 11^17 * 31^18 * 157^18 * 2153^18 * 13907^18 * ... sage: K.decomposition_type(2) [(2, 4, 3), (2, 12, 2), (2, 36, 1)] sage: K.decomposition_type(3) [(9, 3, 2), (9, 10, 1)] sage: K.decomposition_type(7) [(1, 18, 1), (1, 90, 1), (2, 1, 6), (2, 3, 4)]
>>> from sage.all import * >>> K = NumberField(x**Integer(144) + Integer(123)*x**Integer(72) + Integer(321)*x**Integer(36) + Integer(13)*x**Integer(18) + Integer(11), names=('a',)); (a,) = K._first_ngens(1) >>> K.discriminant().factor(limit=Integer(100000)) 2^144 * 3^288 * 7^18 * 11^17 * 31^18 * 157^18 * 2153^18 * 13907^18 * ... >>> K.decomposition_type(Integer(2)) [(2, 4, 3), (2, 12, 2), (2, 36, 1)] >>> K.decomposition_type(Integer(3)) [(9, 3, 2), (9, 10, 1)] >>> K.decomposition_type(Integer(7)) [(1, 18, 1), (1, 90, 1), (2, 1, 6), (2, 3, 4)]
It also works for relative extensions:
sage: K.<a> = QuadraticField(-143) sage: M.<c> = K.extension(x^10 - 6*x^8 + (a + 12)*x^6 + (-7/2*a - 89/2)*x^4 ....: + (13/2*a - 77/2)*x^2 + 25)
>>> from sage.all import * >>> K = QuadraticField(-Integer(143), names=('a',)); (a,) = K._first_ngens(1) >>> M = K.extension(x**Integer(10) - Integer(6)*x**Integer(8) + (a + Integer(12))*x**Integer(6) + (-Integer(7)/Integer(2)*a - Integer(89)/Integer(2))*x**Integer(4) ... + (Integer(13)/Integer(2)*a - Integer(77)/Integer(2))*x**Integer(2) + Integer(25), names=('c',)); (c,) = M._first_ngens(1)
There is a unique prime above \(11\) and above \(13\) in \(K\), each of which is unramified in \(M\):
sage: M.decomposition_type(11) [(1, 2, 5)] sage: P11 = K.primes_above(11)[0] sage: len(M.primes_above(P11)) 5 sage: M.decomposition_type(13) [(1, 1, 10)] sage: P13 = K.primes_above(13)[0] sage: len(M.primes_above(P13)) 10
>>> from sage.all import * >>> M.decomposition_type(Integer(11)) [(1, 2, 5)] >>> P11 = K.primes_above(Integer(11))[Integer(0)] >>> len(M.primes_above(P11)) 5 >>> M.decomposition_type(Integer(13)) [(1, 1, 10)] >>> P13 = K.primes_above(Integer(13))[Integer(0)] >>> len(M.primes_above(P13)) 10
There are two primes above \(2\), each of which ramifies in \(M\):
sage: Q0, Q1 = K.primes_above(2) sage: M.decomposition_type(Q0) [(2, 5, 1)] sage: q0, = M.primes_above(Q0) sage: q0.residue_class_degree() 5 sage: q0.relative_ramification_index() 2 sage: M.decomposition_type(Q1) [(2, 5, 1)]
>>> from sage.all import * >>> Q0, Q1 = K.primes_above(Integer(2)) >>> M.decomposition_type(Q0) [(2, 5, 1)] >>> q0, = M.primes_above(Q0) >>> q0.residue_class_degree() 5 >>> q0.relative_ramification_index() 2 >>> M.decomposition_type(Q1) [(2, 5, 1)]
Check that Issue #34514 is fixed:
sage: K.<a> = NumberField(x^4 + 18*x^2 - 1) sage: R.<y> = K[] sage: L.<b> = K.extension(y^2 + 9*a^3 - 2*a^2 + 162*a - 38) sage: [L.decomposition_type(i) for i in K.primes_above(3)] [[(1, 1, 2)], [(1, 1, 2)], [(1, 2, 1)]]
>>> from sage.all import * >>> K = NumberField(x**Integer(4) + Integer(18)*x**Integer(2) - Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> R = K['y']; (y,) = R._first_ngens(1) >>> L = K.extension(y**Integer(2) + Integer(9)*a**Integer(3) - Integer(2)*a**Integer(2) + Integer(162)*a - Integer(38), names=('b',)); (b,) = L._first_ngens(1) >>> [L.decomposition_type(i) for i in K.primes_above(Integer(3))] [[(1, 1, 2)], [(1, 1, 2)], [(1, 2, 1)]]
- defining_polynomial()[source]#
Return the defining polynomial of this number field.
This is exactly the same as
polynomial()
.EXAMPLES:
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
>>> from sage.all import * >>> k5 = CyclotomicField(Integer(5), names=('z',)); (z,) = k5._first_ngens(1) >>> k5.defining_polynomial() x^4 + x^3 + x^2 + x + 1 >>> y = polygen(QQ, 'y') >>> k = NumberField(y**Integer(9) - Integer(3)*y + Integer(5), names=('a',)); (a,) = k._first_ngens(1); k Number Field in a with defining polynomial y^9 - 3*y + 5 >>> k.defining_polynomial() y^9 - 3*y + 5
- degree()[source]#
Return the degree of this number field.
EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(3) + x**Integer(2) + Integer(997)*x + Integer(1), 'a').degree() 3 >>> NumberField(x + Integer(1), 'a').degree() 1 >>> NumberField(x**Integer(997) + Integer(17)*x + Integer(3), 'a', check=False).degree() 997
- different()[source]#
Compute the different fractional ideal of this number field.
The codifferent is the fractional ideal of all \(x\) in \(K\) such that the trace of \(xy\) is an integer for all \(y \in O_K\).
The different is the integral ideal which is the inverse of the codifferent.
See Wikipedia article Different_ideal
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: k.<a> = NumberField(x^2 + 23) sage: d = k.different() sage: d Fractional ideal (-a) sage: d.norm() 23 sage: k.disc() -23
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(2) + Integer(23), names=('a',)); (a,) = k._first_ngens(1) >>> d = k.different() >>> d Fractional ideal (-a) >>> d.norm() 23 >>> k.disc() -23
The different is cached:
sage: d is k.different() True
>>> from sage.all import * >>> 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
>>> from sage.all import * >>> k = NumberField(x**Integer(2) - Integer(123), names=('b',)); (b,) = k._first_ngens(1) >>> d = k.different(); d Fractional ideal (2*b) >>> d.norm() 492 >>> k.disc() 492
- dirichlet_group()[source]#
Given a abelian field \(K\), compute and return the set of all Dirichlet characters corresponding to the characters of the Galois group of \(K/\QQ\).
The output is random if the field is not abelian.
OUTPUT: a list of Dirichlet characters
EXAMPLES:
sage: # needs sage.groups sage.modular sage: x = polygen(QQ, 'x') sage: K.<t> = NumberField(x^3 + x^2 - 36*x - 4) sage: K.conductor() 109 sage: K.dirichlet_group() # optional - gap_package_polycyclic [Dirichlet character modulo 109 of conductor 1 mapping 6 |--> 1, Dirichlet character modulo 109 of conductor 109 mapping 6 |--> zeta3, Dirichlet character modulo 109 of conductor 109 mapping 6 |--> -zeta3 - 1] sage: # needs sage.modular sage: K = CyclotomicField(44) sage: L = K.subfields(5)[0][0] sage: X = L.dirichlet_group(); X # optional - gap_package_polycyclic [Dirichlet character modulo 11 of conductor 1 mapping 2 |--> 1, Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5, Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5^2, Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5^3, Dirichlet character modulo 11 of conductor 11 mapping 2 |--> -zeta5^3 - zeta5^2 - zeta5 - 1] sage: X[4]^2 # optional - gap_package_polycyclic Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5^3 sage: X[4]^2 in X # optional - gap_package_polycyclic True
>>> from sage.all import * >>> # needs sage.groups sage.modular >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) + x**Integer(2) - Integer(36)*x - Integer(4), names=('t',)); (t,) = K._first_ngens(1) >>> K.conductor() 109 >>> K.dirichlet_group() # optional - gap_package_polycyclic [Dirichlet character modulo 109 of conductor 1 mapping 6 |--> 1, Dirichlet character modulo 109 of conductor 109 mapping 6 |--> zeta3, Dirichlet character modulo 109 of conductor 109 mapping 6 |--> -zeta3 - 1] >>> # needs sage.modular >>> K = CyclotomicField(Integer(44)) >>> L = K.subfields(Integer(5))[Integer(0)][Integer(0)] >>> X = L.dirichlet_group(); X # optional - gap_package_polycyclic [Dirichlet character modulo 11 of conductor 1 mapping 2 |--> 1, Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5, Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5^2, Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5^3, Dirichlet character modulo 11 of conductor 11 mapping 2 |--> -zeta5^3 - zeta5^2 - zeta5 - 1] >>> X[Integer(4)]**Integer(2) # optional - gap_package_polycyclic Dirichlet character modulo 11 of conductor 11 mapping 2 |--> zeta5^3 >>> X[Integer(4)]**Integer(2) in X # optional - gap_package_polycyclic True
- disc(v=None)[source]#
Shortcut for
discriminant()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: k.<b> = NumberField(x^2 - 123) sage: k.disc() 492
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(2) - Integer(123), names=('b',)); (b,) = k._first_ngens(1) >>> k.disc() 492
- discriminant(v=None)[source]#
Return 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 listv
.INPUT:
v
– (optional) list of elements of this number field
OUTPUT:
Integer if
v
is omitted, and Rational otherwise.EXAMPLES:
sage: x = polygen(QQ, 'x') 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 sage: NumberField(x^2 - 1/2, 'a').discriminant() 8
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) + x**Integer(2) - Integer(2)*x + Integer(8), names=('t',)); (t,) = K._first_ngens(1) >>> K.disc() -503 >>> K.disc([Integer(1), t, t**Integer(2)]) -2012 >>> K.disc([Integer(1)/Integer(7), (Integer(1)/Integer(5))*t, (Integer(1)/Integer(3))*t**Integer(2)]) -2012/11025 >>> (Integer(5)*Integer(7)*Integer(3))**Integer(2) 11025 >>> NumberField(x**Integer(2) - Integer(1)/Integer(2), 'a').discriminant() 8
- elements_of_norm(n, proof=None)[source]#
Return a list of elements of norm \(n\).
INPUT:
n
– integerproof
– boolean (default:True
, unless you calledproof.number_field()
and set it otherwise)
OUTPUT:
A complete system of integral elements of norm \(n\), modulo units of positive norm.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^2 + 1) sage: K.elements_of_norm(3) [] sage: K.elements_of_norm(50) [-a - 7, 5*a - 5, 7*a + 1]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> K.elements_of_norm(Integer(3)) [] >>> K.elements_of_norm(Integer(50)) [-a - 7, 5*a - 5, 7*a + 1]
- extension(poly, name=None, names=None, latex_name=None, latex_names=None, *args, **kwds)[source]#
Return the relative extension of this field by a given polynomial.
EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> R = K['t']; (t,) = R._first_ngens(1) >>> L = K.extension(t**Integer(2) + a, names=('b',)); (b,) = L._first_ngens(1); 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 = polygen(QQ,'y') sage: m.<b> = k.extension(y^2 + 2); m Number Field in b with defining polynomial y^2 + 2 over its base field
>>> from sage.all import * >>> k = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = k._first_ngens(1); k Number Field in a with defining polynomial x^2 + 1 >>> y = polygen(QQ,'y') >>> m = k.extension(y**Integer(2) + Integer(2), names=('b',)); (b,) = m._first_ngens(1); 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
>>> from sage.all import * >>> b.minpoly() x^2 + 2 >>> 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
>>> from sage.all import * >>> k = NumberField([x**Integer(2) + Integer(1), x**Integer(3) + x + Integer(1)], names=('a',)); (a,) = k._first_ngens(1) >>> R = k['z']; (z,) = R._first_ngens(1) >>> L = NumberField(z**Integer(3) + Integer(3) + a, names=('b',)); (b,) = L._first_ngens(1); L Number Field in b with defining polynomial z^3 + a0 + 3 over its base field
Extension fields with given defining data are unique (Issue #20791):
sage: K.<a> = NumberField(x^2 + 1) sage: K.extension(x^2 - 2, 'b') is K.extension(x^2 - 2, 'b') True
>>> from sage.all import * >>> K = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> K.extension(x**Integer(2) - Integer(2), 'b') is K.extension(x**Integer(2) - Integer(2), 'b') True
- factor(n)[source]#
Ideal factorization of the principal ideal generated by \(n\).
EXAMPLES:
Here we show how to factor Gaussian integers (up to units). First we form a number field defined by \(x^2 + 1\):
sage: x = polygen(QQ, 'x') sage: K.<I> = NumberField(x^2 + 1); K Number Field in I with defining polynomial x^2 + 1
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('I',)); (I,) = K._first_ngens(1); K Number Field in I with defining polynomial x^2 + 1
Here are the factors:
sage: fi, fj = K.factor(17); fi,fj ((Fractional ideal (I + 4), 1), (Fractional ideal (I - 4), 1))
>>> from sage.all import * >>> fi, fj = K.factor(Integer(17)); fi,fj ((Fractional ideal (I + 4), 1), (Fractional ideal (I - 4), 1))
Now we extract the reduced form of the generators:
sage: zi = fi[0].gens_reduced()[0]; zi I + 4 sage: zj = fj[0].gens_reduced()[0]; zj I - 4
>>> from sage.all import * >>> zi = fi[Integer(0)].gens_reduced()[Integer(0)]; zi I + 4 >>> zj = fj[Integer(0)].gens_reduced()[Integer(0)]; zj I - 4
We recover the integer that was factored in \(\ZZ[i]\) (up to a unit):
sage: zi*zj -17
>>> from sage.all import * >>> zi*zj -17
One can also factor elements or ideals 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 (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
>>> from sage.all import * >>> K = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> K.factor(Integer(1)/Integer(3)) (Fractional ideal (3))^-1 >>> K.factor(Integer(1)+a) Fractional ideal (a + 1) >>> K.factor(Integer(1)+a/Integer(5)) (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
An example over a relative number field:
sage: pari('setrand(2)') sage: L.<b> = K.extension(x^2 - 7) sage: f = L.factor(a + 1) sage: f # representation varies, not tested (Fractional ideal (1/2*a*b - a + 1/2)) * (Fractional ideal (-1/2*a*b - a + 1/2)) sage: f.value() == a+1 True
>>> from sage.all import * >>> pari('setrand(2)') >>> L = K.extension(x**Integer(2) - Integer(7), names=('b',)); (b,) = L._first_ngens(1) >>> f = L.factor(a + Integer(1)) >>> f # representation varies, not tested (Fractional ideal (1/2*a*b - a + 1/2)) * (Fractional ideal (-1/2*a*b - a + 1/2)) >>> f.value() == a+Integer(1) True
It doesn’t make sense to factor the ideal \((0)\), so this raises an error:
sage: L.factor(0) Traceback (most recent call last): ... AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
>>> from sage.all import * >>> L.factor(Integer(0)) Traceback (most recent call last): ... AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
AUTHORS:
Alex Clemesha (2006-05-20), Francis Clarke (2009-04-21): examples
- fractional_ideal(*gens, **kwds)[source]#
Return the ideal in \(\mathcal{O}_K\) generated by
gens
. This overrides thesage.rings.ring.Field
method to use thesage.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.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^3 - 2) sage: K.fractional_ideal([1/a]) Fractional ideal (1/2*a^2)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> K.fractional_ideal([Integer(1)/a]) Fractional ideal (1/2*a^2)
One can also input a number field ideal itself, or, more usefully, for a tower of number fields an ideal in one of the fields lower down the tower.
sage: K.fractional_ideal(K.ideal(a)) Fractional ideal (a) sage: L.<b> = K.extension(x^2 - 3, x^2 + 1) sage: M.<c> = L.extension(x^2 + 1) sage: L.ideal(K.ideal(2, a)) Fractional ideal (a) sage: M.ideal(K.ideal(2, a)) == M.ideal(a*(b - c)/2) True
>>> from sage.all import * >>> K.fractional_ideal(K.ideal(a)) Fractional ideal (a) >>> L = K.extension(x**Integer(2) - Integer(3), x**Integer(2) + Integer(1), names=('b',)); (b,) = L._first_ngens(1) >>> M = L.extension(x**Integer(2) + Integer(1), names=('c',)); (c,) = M._first_ngens(1) >>> L.ideal(K.ideal(Integer(2), a)) Fractional ideal (a) >>> M.ideal(K.ideal(Integer(2), a)) == M.ideal(a*(b - c)/Integer(2)) True
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)
>>> from sage.all import * >>> K.fractional_ideal(Integer(0)) Traceback (most recent call last): ... ValueError: gens must have a nonzero element (zero ideal is not a fractional ideal)
- galois_group(type=None, algorithm='pari', names=None, gc_numbering=None)[source]#
Return the Galois group of the Galois closure of this number field.
INPUT:
type
– Deprecated; the different versions of Galois groups have been merged in Issue #28782.algorithm
–'pari'
,'gap'
,'kash'
,'magma'
. (default:'pari'
;for degrees between 12 and 15 default is
'gap'
, and when the degree is >= 16 it is'kash'
.)
names
– a string giving a name for the generator of the Galois closure ofself
, when this field is not Galois.gc_numbering
– ifTrue
, permutations will be written in terms of the action on the roots of a defining polynomial for the Galois closure, rather than the defining polynomial for the original number field. This is significantly faster; but not the standard way of presenting Galois groups. The default currently depends on the algorithm (True
for'pari'
,False
for'magma'
) and may change in the future.
The resulting group will only compute with automorphisms when necessary, so certain functions (such as
sage.rings.number_field.galois_group.GaloisGroup_v2.order()
) will still be fast. For more (important!) documentation, see the documentation for Galois groups of polynomials over \(\QQ\), e.g., by typingK.polynomial().galois_group?
, where \(K\) is a number field.EXAMPLES:
sage: # needs sage.groups sage: x = polygen(QQ, 'x') sage: k.<b> = NumberField(x^2 - 14) # a Galois extension sage: G = k.galois_group(); G Galois group 2T1 (S2) with order 2 of x^2 - 14 sage: G.gen(0) (1,2) sage: G.gen(0)(b) -b sage: G.artin_symbol(k.primes_above(3)[0]) (1,2) sage: # needs sage.groups sage: k.<b> = NumberField(x^3 - x + 1) # not Galois sage: G = k.galois_group(names='c'); G Galois group 3T2 (S3) with order 6 of x^3 - x + 1 sage: G.gen(0) (1,2,3)(4,5,6) sage: NumberField(x^3 + 2*x + 1, 'a').galois_group(algorithm='magma') # optional - magma, needs sage.groups Galois group Transitive group number 2 of degree 3 of the Number Field in a with defining polynomial x^3 + 2*x + 1
>>> from sage.all import * >>> # needs sage.groups >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(2) - Integer(14), names=('b',)); (b,) = k._first_ngens(1)# a Galois extension >>> G = k.galois_group(); G Galois group 2T1 (S2) with order 2 of x^2 - 14 >>> G.gen(Integer(0)) (1,2) >>> G.gen(Integer(0))(b) -b >>> G.artin_symbol(k.primes_above(Integer(3))[Integer(0)]) (1,2) >>> # needs sage.groups >>> k = NumberField(x**Integer(3) - x + Integer(1), names=('b',)); (b,) = k._first_ngens(1)# not Galois >>> G = k.galois_group(names='c'); G Galois group 3T2 (S3) with order 6 of x^3 - x + 1 >>> G.gen(Integer(0)) (1,2,3)(4,5,6) >>> NumberField(x**Integer(3) + Integer(2)*x + Integer(1), 'a').galois_group(algorithm='magma') # optional - magma, needs sage.groups Galois group Transitive group number 2 of degree 3 of the Number Field in a with defining polynomial x^3 + 2*x + 1
EXPLICIT GALOIS GROUP: We compute the Galois group as an explicit group of automorphisms of the Galois closure of a field.
sage: # needs sage.groups sage: K.<a> = NumberField(x^3 - 2) sage: L.<b1> = K.galois_closure(); L Number Field in b1 with defining polynomial x^6 + 108 sage: G = End(L); G Automorphism group of Number Field in b1 with defining polynomial x^6 + 108 sage: G.list() [ Ring endomorphism of Number Field in b1 with defining polynomial x^6 + 108 Defn: b1 |--> b1, ... Ring endomorphism of Number Field in b1 with defining polynomial x^6 + 108 Defn: b1 |--> -1/12*b1^4 - 1/2*b1 ] sage: G[2](b1) 1/12*b1^4 + 1/2*b1
>>> from sage.all import * >>> # needs sage.groups >>> K = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.galois_closure(names=('b1',)); (b1,) = L._first_ngens(1); L Number Field in b1 with defining polynomial x^6 + 108 >>> G = End(L); G Automorphism group of Number Field in b1 with defining polynomial x^6 + 108 >>> G.list() [ Ring endomorphism of Number Field in b1 with defining polynomial x^6 + 108 Defn: b1 |--> b1, ... Ring endomorphism of Number Field in b1 with defining polynomial x^6 + 108 Defn: b1 |--> -1/12*b1^4 - 1/2*b1 ] >>> G[Integer(2)](b1) 1/12*b1^4 + 1/2*b1
Many examples for higher degrees may be found in the online databases http://galoisdb.math.upb.de/ by Jürgen Klüners and Gunter Malle and https://www.lmfdb.org/NumberField/ by the LMFDB collaboration, although these might need a lot of computing time.
If \(L/K\) is a relative number field, this method will currently return \(Gal(L/\QQ)\). This behavior will change in the future, so it’s better to explicitly call
absolute_field()
if that is the desired behavior:sage: # needs sage.groups sage: x = polygen(QQ) 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() ...DeprecationWarning: Use .absolute_field().galois_group() if you want the Galois group of the absolute field See https://github.com/sagemath/sage/issues/28782 for details. Galois group 10T22 (S(5)[x]2) with order 240 of t^5 - t + a
>>> from sage.all import * >>> # needs sage.groups >>> x = polygen(QQ) >>> K = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> R = PolynomialRing(K, names=('t',)); (t,) = R._first_ngens(1) >>> L = K.extension(t**Integer(5) - t + a, 'b') >>> L.galois_group() ...DeprecationWarning: Use .absolute_field().galois_group() if you want the Galois group of the absolute field See https://github.com/sagemath/sage/issues/28782 for details. Galois group 10T22 (S(5)[x]2) with order 240 of t^5 - t + a
- gen(n=0)[source]#
Return the generator for this number field.
INPUT:
n
– must be 0 (the default), or an exception is raised.
EXAMPLES:
sage: x = polygen(QQ, 'x') 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.
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(14) + Integer(2), names=('theta',)); (theta,) = k._first_ngens(1); k Number Field in theta with defining polynomial x^14 + 2 >>> k.gen() theta >>> k.gen(Integer(1)) Traceback (most recent call last): ... IndexError: Only one generator.
- gen_embedding()[source]#
If an embedding has been specified, return the image of the generator under that embedding. Otherwise return
None
.EXAMPLES:
sage: QuadraticField(-7, 'a').gen_embedding() 2.645751311064591?*I sage: x = polygen(QQ, 'x') sage: NumberField(x^2 + 7, 'a').gen_embedding() # None
>>> from sage.all import * >>> QuadraticField(-Integer(7), 'a').gen_embedding() 2.645751311064591?*I >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + Integer(7), 'a').gen_embedding() # None
- ideal(*gens, **kwds)[source]#
Return a fractional ideal of the field, except for the zero ideal, which is not a fractional ideal.
EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.ideal(Integer(2)) Fractional ideal (2) >>> K.ideal(Integer(2) + i) Fractional ideal (i + 2) >>> K.ideal(Integer(0)) Ideal (0) of Number Field in i with defining polynomial x^2 + 1
- idealchinese(ideals, residues)[source]#
Return a solution of the Chinese Remainder Theorem problem for ideals in a number field.
This is a wrapper around the pari function pari:idealchinese.
INPUT:
ideals
– a list of ideals of the number field.residues
– a list of elements of the number field.
OUTPUT:
Return an element \(b\) of the number field such that \(b \equiv x_i \bmod I_i\) for all residues \(x_i\) and respective ideals \(I_i\).
See also
EXAMPLES:
This is the example from the pari page on
idealchinese
:sage: # needs sage.symbolic sage: K.<sqrt2> = NumberField(sqrt(2).minpoly()) sage: ideals = [K.ideal(4), K.ideal(3)] sage: residues = [sqrt2, 1] sage: r = K.idealchinese(ideals, residues); r -3*sqrt2 + 4 sage: all((r - a) in I for I, a in zip(ideals, residues)) True
>>> from sage.all import * >>> # needs sage.symbolic >>> K = NumberField(sqrt(Integer(2)).minpoly(), names=('sqrt2',)); (sqrt2,) = K._first_ngens(1) >>> ideals = [K.ideal(Integer(4)), K.ideal(Integer(3))] >>> residues = [sqrt2, Integer(1)] >>> r = K.idealchinese(ideals, residues); r -3*sqrt2 + 4 >>> all((r - a) in I for I, a in zip(ideals, residues)) True
The result may be non-integral if the results are non-integral:
sage: # needs sage.symbolic sage: K.<sqrt2> = NumberField(sqrt(2).minpoly()) sage: ideals = [K.ideal(4), K.ideal(21)] sage: residues = [1/sqrt2, 1] sage: r = K.idealchinese(ideals, residues); r -63/2*sqrt2 - 20 sage: all( ....: (r - a).valuation(P) >= k ....: for I, a in zip(ideals, residues) ....: for P, k in I.factor() ....: ) True
>>> from sage.all import * >>> # needs sage.symbolic >>> K = NumberField(sqrt(Integer(2)).minpoly(), names=('sqrt2',)); (sqrt2,) = K._first_ngens(1) >>> ideals = [K.ideal(Integer(4)), K.ideal(Integer(21))] >>> residues = [Integer(1)/sqrt2, Integer(1)] >>> r = K.idealchinese(ideals, residues); r -63/2*sqrt2 - 20 >>> all( ... (r - a).valuation(P) >= k ... for I, a in zip(ideals, residues) ... for P, k in I.factor() ... ) True
- ideals_of_bdd_norm(bound)[source]#
Return all integral ideals of bounded norm.
INPUT:
bound
– a positive integer
OUTPUT: A dict of all integral ideals \(I\) such that Norm(\(I\)) \(\leq\)
bound
, keyed by norm.EXAMPLES:
sage: x = polygen(QQ, 'x') 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 sorted(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 (2) Fractional ideal (4, 1/2*a + 3/2) Fractional ideal (4, 1/2*a + 5/2) 5 6 Fractional ideal (1/2*a - 1/2) Fractional ideal (1/2*a + 1/2) Fractional ideal (6, 1/2*a + 5/2) Fractional ideal (6, 1/2*a + 7/2) 7 8 Fractional ideal (4, a - 1) Fractional ideal (4, a + 1) Fractional ideal (1/2*a + 3/2) Fractional ideal (1/2*a - 3/2) 9 Fractional ideal (3) Fractional ideal (9, 1/2*a + 7/2) Fractional ideal (9, 1/2*a + 11/2) 10
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(23), names=('a',)); (a,) = K._first_ngens(1) >>> d = K.ideals_of_bdd_norm(Integer(10)) >>> for n in d: ... print(n) ... for I in sorted(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 (2) Fractional ideal (4, 1/2*a + 3/2) Fractional ideal (4, 1/2*a + 5/2) 5 6 Fractional ideal (1/2*a - 1/2) Fractional ideal (1/2*a + 1/2) Fractional ideal (6, 1/2*a + 5/2) Fractional ideal (6, 1/2*a + 7/2) 7 8 Fractional ideal (4, a - 1) Fractional ideal (4, a + 1) Fractional ideal (1/2*a + 3/2) Fractional ideal (1/2*a - 3/2) 9 Fractional ideal (3) Fractional ideal (9, 1/2*a + 7/2) Fractional ideal (9, 1/2*a + 11/2) 10
- integral_basis(v=None)[source]#
Return a list containing a
ZZ
-basis for the full ring of integers of this number field.INPUT:
v
–None
, a prime, or a list of primes. See the documentation formaximal_order()
.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^5 + 10*x + 1) sage: K.integral_basis() [1, a, a^2, a^3, a^4]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(5) + Integer(10)*x + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> 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, 1/2*a^2 + 1/2*a, a^2]
>>> from sage.all import * >>> K = NumberField(x**Integer(3) + x**Integer(2) - Integer(2)*x + Integer(8), names=('a',)); (a,) = K._first_ngens(1) >>> K.integral_basis() [1, 1/2*a^2 + 1/2*a, a^2]
ALGORITHM: Uses the PARI library (via pari:_pari_integral_basis).
- is_CM()[source]#
Return
True
ifself
is a CM field (i.e., a totally imaginary quadratic extension of a totally real field).EXAMPLES:
sage: x = polygen(QQ, 'x') sage: Q.<a> = NumberField(x - 1) sage: Q.is_CM() False sage: K.<i> = NumberField(x^2 + 1) sage: K.is_CM() True sage: L.<zeta20> = CyclotomicField(20) sage: L.is_CM() True sage: K.<omega> = QuadraticField(-3) sage: K.is_CM() True sage: L.<sqrt5> = QuadraticField(5) sage: L.is_CM() False sage: F.<a> = NumberField(x^3 - 2) sage: F.is_CM() False sage: F.<a> = NumberField(x^4 - x^3 - 3*x^2 + x + 1) sage: F.is_CM() False
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> Q = NumberField(x - Integer(1), names=('a',)); (a,) = Q._first_ngens(1) >>> Q.is_CM() False >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.is_CM() True >>> L = CyclotomicField(Integer(20), names=('zeta20',)); (zeta20,) = L._first_ngens(1) >>> L.is_CM() True >>> K = QuadraticField(-Integer(3), names=('omega',)); (omega,) = K._first_ngens(1) >>> K.is_CM() True >>> L = QuadraticField(Integer(5), names=('sqrt5',)); (sqrt5,) = L._first_ngens(1) >>> L.is_CM() False >>> F = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = F._first_ngens(1) >>> F.is_CM() False >>> F = NumberField(x**Integer(4) - x**Integer(3) - Integer(3)*x**Integer(2) + x + Integer(1), names=('a',)); (a,) = F._first_ngens(1) >>> F.is_CM() False
The following are non-CM totally imaginary fields.
sage: F.<a> = NumberField(x^4 + x^3 - x^2 - x + 1) sage: F.is_totally_imaginary() True sage: F.is_CM() False sage: F2.<a> = NumberField(x^12 - 5*x^11 + 8*x^10 - 5*x^9 - x^8 + 9*x^7 ....: + 7*x^6 - 3*x^5 + 5*x^4 + 7*x^3 - 4*x^2 - 7*x + 7) sage: F2.is_totally_imaginary() True sage: F2.is_CM() False
>>> from sage.all import * >>> F = NumberField(x**Integer(4) + x**Integer(3) - x**Integer(2) - x + Integer(1), names=('a',)); (a,) = F._first_ngens(1) >>> F.is_totally_imaginary() True >>> F.is_CM() False >>> F2 = NumberField(x**Integer(12) - Integer(5)*x**Integer(11) + Integer(8)*x**Integer(10) - Integer(5)*x**Integer(9) - x**Integer(8) + Integer(9)*x**Integer(7) ... + Integer(7)*x**Integer(6) - Integer(3)*x**Integer(5) + Integer(5)*x**Integer(4) + Integer(7)*x**Integer(3) - Integer(4)*x**Integer(2) - Integer(7)*x + Integer(7), names=('a',)); (a,) = F2._first_ngens(1) >>> F2.is_totally_imaginary() True >>> F2.is_CM() False
The following is a non-cyclotomic CM field.
sage: M.<a> = NumberField(x^4 - x^3 - x^2 - 2*x + 4) sage: M.is_CM() True
>>> from sage.all import * >>> M = NumberField(x**Integer(4) - x**Integer(3) - x**Integer(2) - Integer(2)*x + Integer(4), names=('a',)); (a,) = M._first_ngens(1) >>> M.is_CM() True
Now, we construct a totally imaginary quadratic extension of a totally real field (which is not cyclotomic).
sage: E_0.<a> = NumberField(x^7 - 4*x^6 - 4*x^5 + 10*x^4 + 4*x^3 ....: - 6*x^2 - x + 1) sage: E_0.is_totally_real() True sage: E.<b> = E_0.extension(x^2 + 1) sage: E.is_CM() True
>>> from sage.all import * >>> E_0 = NumberField(x**Integer(7) - Integer(4)*x**Integer(6) - Integer(4)*x**Integer(5) + Integer(10)*x**Integer(4) + Integer(4)*x**Integer(3) ... - Integer(6)*x**Integer(2) - x + Integer(1), names=('a',)); (a,) = E_0._first_ngens(1) >>> E_0.is_totally_real() True >>> E = E_0.extension(x**Integer(2) + Integer(1), names=('b',)); (b,) = E._first_ngens(1) >>> E.is_CM() True
Finally, a CM field that is given as an extension that is not CM.
sage: E_0.<a> = NumberField(x^2 - 4*x + 16) sage: y = polygen(E_0) sage: E.<z> = E_0.extension(y^2 - E_0.gen() / 2) sage: E.is_CM() True sage: E.is_CM_extension() False
>>> from sage.all import * >>> E_0 = NumberField(x**Integer(2) - Integer(4)*x + Integer(16), names=('a',)); (a,) = E_0._first_ngens(1) >>> y = polygen(E_0) >>> E = E_0.extension(y**Integer(2) - E_0.gen() / Integer(2), names=('z',)); (z,) = E._first_ngens(1) >>> E.is_CM() True >>> E.is_CM_extension() False
- is_abelian()[source]#
Return
True
if this number field is an abelian Galois extension of \(\QQ\).EXAMPLES:
sage: # needs sage.groups sage: x = polygen(QQ, 'x') sage: NumberField(x^2 + 1, 'i').is_abelian() True sage: NumberField(x^3 + 2, 'a').is_abelian() False sage: NumberField(x^3 + x^2 - 2*x - 1, 'a').is_abelian() True sage: NumberField(x^6 + 40*x^3 + 1372, 'a').is_abelian() False sage: NumberField(x^6 + x^5 - 5*x^4 - 4*x^3 + 6*x^2 + 3*x - 1, 'a').is_abelian() True
>>> from sage.all import * >>> # needs sage.groups >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + Integer(1), 'i').is_abelian() True >>> NumberField(x**Integer(3) + Integer(2), 'a').is_abelian() False >>> NumberField(x**Integer(3) + x**Integer(2) - Integer(2)*x - Integer(1), 'a').is_abelian() True >>> NumberField(x**Integer(6) + Integer(40)*x**Integer(3) + Integer(1372), 'a').is_abelian() False >>> NumberField(x**Integer(6) + x**Integer(5) - Integer(5)*x**Integer(4) - Integer(4)*x**Integer(3) + Integer(6)*x**Integer(2) + Integer(3)*x - Integer(1), 'a').is_abelian() True
- is_absolute()[source]#
Return
True
ifself
is an absolute field.This function will be implemented in the derived classes.
EXAMPLES:
sage: K = CyclotomicField(5) sage: K.is_absolute() True
>>> from sage.all import * >>> K = CyclotomicField(Integer(5)) >>> K.is_absolute() True
- is_field(proof=True)[source]#
Return
True
since a number field is a field.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: NumberField(x^5 + x + 3, 'c').is_field() True
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(5) + x + Integer(3), 'c').is_field() True
- is_galois()[source]#
Return
True
if this number field is a Galois extension of \(\QQ\).EXAMPLES:
sage: # needs sage.groups sage: x = polygen(QQ, 'x') sage: NumberField(x^2 + 1, 'i').is_galois() True sage: NumberField(x^3 + 2, 'a').is_galois() False sage: K = NumberField(x^15 + x^14 - 14*x^13 - 13*x^12 + 78*x^11 + 66*x^10 ....: - 220*x^9 - 165*x^8 + 330*x^7 + 210*x^6 - 252*x^5 ....: - 126*x^4 + 84*x^3 + 28*x^2 - 8*x - 1, 'a') sage: K.is_galois() True sage: K = NumberField(x^15 + x^14 - 14*x^13 - 13*x^12 + 78*x^11 + 66*x^10 ....: - 220*x^9 - 165*x^8 + 330*x^7 + 210*x^6 - 252*x^5 ....: - 126*x^4 + 84*x^3 + 28*x^2 - 8*x - 10, 'a') sage: K.is_galois() False
>>> from sage.all import * >>> # needs sage.groups >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + Integer(1), 'i').is_galois() True >>> NumberField(x**Integer(3) + Integer(2), 'a').is_galois() False >>> K = NumberField(x**Integer(15) + x**Integer(14) - Integer(14)*x**Integer(13) - Integer(13)*x**Integer(12) + Integer(78)*x**Integer(11) + Integer(66)*x**Integer(10) ... - Integer(220)*x**Integer(9) - Integer(165)*x**Integer(8) + Integer(330)*x**Integer(7) + Integer(210)*x**Integer(6) - Integer(252)*x**Integer(5) ... - Integer(126)*x**Integer(4) + Integer(84)*x**Integer(3) + Integer(28)*x**Integer(2) - Integer(8)*x - Integer(1), 'a') >>> K.is_galois() True >>> K = NumberField(x**Integer(15) + x**Integer(14) - Integer(14)*x**Integer(13) - Integer(13)*x**Integer(12) + Integer(78)*x**Integer(11) + Integer(66)*x**Integer(10) ... - Integer(220)*x**Integer(9) - Integer(165)*x**Integer(8) + Integer(330)*x**Integer(7) + Integer(210)*x**Integer(6) - Integer(252)*x**Integer(5) ... - Integer(126)*x**Integer(4) + Integer(84)*x**Integer(3) + Integer(28)*x**Integer(2) - Integer(8)*x - Integer(10), 'a') >>> K.is_galois() False
- is_isomorphic(other, isomorphism_maps=False)[source]#
Return
True
ifself
is isomorphic as a number field toother
.EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = k._first_ngens(1) >>> m = NumberField(x**Integer(2) + Integer(4), names=('b',)); (b,) = m._first_ngens(1) >>> k.is_isomorphic(m) True >>> m = NumberField(x**Integer(2) + Integer(5), names=('b',)); (b,) = m._first_ngens(1) >>> 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 sage: k = NumberField(x^2 - x - 1, 'b') sage: l = NumberField(x^2 - 7, 'a') sage: k.is_isomorphic(l, True) (False, []) sage: k = NumberField(x^2 - x - 1, 'b') sage: ky.<y> = k[] sage: l = NumberField(y, 'a') sage: k.is_isomorphic(l, True) (True, [-x, x + 1])
>>> from sage.all import * >>> k = NumberField(x**Integer(3) + Integer(2), 'a') >>> k.is_isomorphic(NumberField((x+Integer(1)/Integer(3))**Integer(3) + Integer(2), 'b')) True >>> k.is_isomorphic(NumberField(x**Integer(3) + Integer(4), 'b')) True >>> k.is_isomorphic(NumberField(x**Integer(3) + Integer(5), 'b')) False >>> k = NumberField(x**Integer(2) - x - Integer(1), 'b') >>> l = NumberField(x**Integer(2) - Integer(7), 'a') >>> k.is_isomorphic(l, True) (False, []) >>> k = NumberField(x**Integer(2) - x - Integer(1), 'b') >>> ky = k['y']; (y,) = ky._first_ngens(1) >>> l = NumberField(y, 'a') >>> k.is_isomorphic(l, True) (True, [-x, x + 1])
- is_relative()[source]#
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^10 - 2) sage: K.is_absolute() True sage: K.is_relative() False
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(10) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> K.is_absolute() True >>> K.is_relative() False
- is_totally_imaginary()[source]#
Return
True
ifself
is totally imaginary, andFalse
otherwise.Totally imaginary means that no isomorphic embedding of
self
into the complex numbers has image contained in the real numbers.EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + Integer(2), 'alpha').is_totally_imaginary() True >>> NumberField(x**Integer(2) - Integer(2), 'alpha').is_totally_imaginary() False >>> NumberField(x**Integer(4) - Integer(2), 'alpha').is_totally_imaginary() False
- is_totally_real()[source]#
Return
True
ifself
is totally real, andFalse
otherwise.Totally real means that every isomorphic embedding of
self
into the complex numbers has image contained in the real numbers.EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + Integer(2), 'alpha').is_totally_real() False >>> NumberField(x**Integer(2) - Integer(2), 'alpha').is_totally_real() True >>> NumberField(x**Integer(4) - Integer(2), 'alpha').is_totally_real() False
- lmfdb_page()[source]#
Open the LMFDB web page of the number field in a browser.
EXAMPLES:
sage: E = QuadraticField(-1) sage: E.lmfdb_page() # optional -- webbrowser
>>> from sage.all import * >>> E = QuadraticField(-Integer(1)) >>> E.lmfdb_page() # optional -- webbrowser
Even if the variable name is different it works:
sage: R.<y>= PolynomialRing(QQ, "y") sage: K = NumberField(y^2 + 1 , "i") sage: K.lmfdb_page() # optional -- webbrowser
>>> from sage.all import * >>> R = PolynomialRing(QQ, "y", names=('y',)); (y,) = R._first_ngens(1) >>> K = NumberField(y**Integer(2) + Integer(1) , "i") >>> K.lmfdb_page() # optional -- webbrowser
- maximal_order(v=None, assume_maximal='non-maximal-non-unique')[source]#
Return the maximal order, i.e., the ring of integers, associated to this number field.
INPUT:
v
–None
, a prime, or a list of integer primes (default:None
)if
None
, return the maximal order.if a prime \(p\), return an order that is \(p\)-maximal.
if a list, return an order that is maximal at each prime of these primes
assume_maximal
–True
,False
,None
, or"non-maximal-non-unique"
(default:"non-maximal-non-unique"
) ignored whenv
isNone
; otherwise, controls whether we assume that the orderorder.is_maximal()
outside ofv
.if
True
, the order is assumed to be maximal at all primes.if
False
, the order is assumed to be non-maximal at some prime not inv
.if
None
, no assumptions are made about primes not inv
.if
"non-maximal-non-unique"
(deprecated), likeFalse
, however, the order is not a unique parent, so creating the same order later does typically not poison caches with the information that the order is not maximal.
EXAMPLES:
In this example, the maximal order cannot be generated by a single element:
sage: x = polygen(QQ, 'x') sage: k.<a> = NumberField(x^3 + x^2 - 2*x+8) sage: o = k.maximal_order() sage: o Maximal Order generated by [1/2*a^2 + 1/2*a, a^2] in Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(3) + x**Integer(2) - Integer(2)*x+Integer(8), names=('a',)); (a,) = k._first_ngens(1) >>> o = k.maximal_order() >>> o Maximal Order generated by [1/2*a^2 + 1/2*a, a^2] in Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
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) sage: q = next_prime(10^23) sage: K.<a> = NumberField(x^3 - p*q) sage: K.maximal_order([3], assume_maximal=None).basis() [1/3*a^2 + 1/3*a + 1/3, a, a^2] sage: K.maximal_order([2], assume_maximal=None).basis() [1/3*a^2 + 1/3*a + 1/3, a, a^2] sage: K.maximal_order([p], assume_maximal=None).basis() [1/3*a^2 + 1/3*a + 1/3, a, a^2] sage: K.maximal_order([q], assume_maximal=None).basis() [1/3*a^2 + 1/3*a + 1/3, a, a^2] sage: K.maximal_order([p, 3], assume_maximal=None).basis() [1/3*a^2 + 1/3*a + 1/3, a, a^2]
>>> from sage.all import * >>> p = next_prime(Integer(10)**Integer(22)) >>> q = next_prime(Integer(10)**Integer(23)) >>> K = NumberField(x**Integer(3) - p*q, names=('a',)); (a,) = K._first_ngens(1) >>> K.maximal_order([Integer(3)], assume_maximal=None).basis() [1/3*a^2 + 1/3*a + 1/3, a, a^2] >>> K.maximal_order([Integer(2)], assume_maximal=None).basis() [1/3*a^2 + 1/3*a + 1/3, a, a^2] >>> K.maximal_order([p], assume_maximal=None).basis() [1/3*a^2 + 1/3*a + 1/3, a, a^2] >>> K.maximal_order([q], assume_maximal=None).basis() [1/3*a^2 + 1/3*a + 1/3, a, a^2] >>> K.maximal_order([p, Integer(3)], assume_maximal=None).basis() [1/3*a^2 + 1/3*a + 1/3, a, a^2]
An example with bigger discriminant:
sage: p = next_prime(10^97) sage: q = next_prime(10^99) sage: K.<a> = NumberField(x^3 - p*q) sage: K.maximal_order(prime_range(10000), assume_maximal=None).basis() [1, a, a^2]
>>> from sage.all import * >>> p = next_prime(Integer(10)**Integer(97)) >>> q = next_prime(Integer(10)**Integer(99)) >>> K = NumberField(x**Integer(3) - p*q, names=('a',)); (a,) = K._first_ngens(1) >>> K.maximal_order(prime_range(Integer(10000)), assume_maximal=None).basis() [1, a, a^2]
An example in a relative number field:
sage: K.<a, b> = NumberField([x^2 + 1, x^2 - 3]) sage: OK = K.maximal_order() sage: 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 - x + 1 sage: O2 = K.order([3*a, 2*b]) sage: O2.index_in(OK) 144
>>> from sage.all import * >>> K = NumberField([x**Integer(2) + Integer(1), x**Integer(2) - Integer(3)], names=('a', 'b',)); (a, b,) = K._first_ngens(2) >>> OK = K.maximal_order() >>> OK.basis() [1, 1/2*a - 1/2*b, -1/2*b*a + 1/2, a] >>> charpoly(OK.gen(1)) x^2 + b*x + 1 >>> charpoly(OK.gen(2)) x^2 - x + 1 >>> O2 = K.order([Integer(3)*a, Integer(2)*b]) >>> O2.index_in(OK) 144
An order that is maximal at a prime. We happen to know that it is actually maximal and mark it as such:
sage: K.<i> = NumberField(x^2 + 1) sage: K.maximal_order(v=2, assume_maximal=True) Gaussian Integers generated by i in Number Field in i with defining polynomial x^2 + 1
>>> from sage.all import * >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.maximal_order(v=Integer(2), assume_maximal=True) Gaussian Integers generated by i in Number Field in i with defining polynomial x^2 + 1
It is an error to create a maximal order and declare it non-maximal, however, such mistakes are only caught automatically if they evidently contradict previous results in this session:
sage: K.maximal_order(v=2, assume_maximal=False) Traceback (most recent call last): ... ValueError: cannot assume this order to be non-maximal because we already found it to be a maximal order
>>> from sage.all import * >>> K.maximal_order(v=Integer(2), assume_maximal=False) Traceback (most recent call last): ... ValueError: cannot assume this order to be non-maximal because we already found it to be a maximal order
- maximal_totally_real_subfield()[source]#
Return the maximal totally real subfield of
self
together with an embedding of it intoself
.EXAMPLES:
sage: F.<a> = QuadraticField(11) sage: F.maximal_totally_real_subfield() [Number Field in a with defining polynomial x^2 - 11 with a = 3.316624790355400?, Identity endomorphism of Number Field in a with defining polynomial x^2 - 11 with a = 3.316624790355400?] sage: F.<a> = QuadraticField(-15) sage: F.maximal_totally_real_subfield() [Rational Field, Natural morphism: From: Rational Field To: Number Field in a with defining polynomial x^2 + 15 with a = 3.872983346207417?*I] sage: F.<a> = CyclotomicField(29) sage: F.maximal_totally_real_subfield() (Number Field in a0 with defining polynomial x^14 + x^13 - 13*x^12 - 12*x^11 + 66*x^10 + 55*x^9 - 165*x^8 - 120*x^7 + 210*x^6 + 126*x^5 - 126*x^4 - 56*x^3 + 28*x^2 + 7*x - 1 with a0 = 1.953241111420174?, Ring morphism: From: Number Field in a0 with defining polynomial x^14 + x^13 - 13*x^12 - 12*x^11 + 66*x^10 + 55*x^9 - 165*x^8 - 120*x^7 + 210*x^6 + 126*x^5 - 126*x^4 - 56*x^3 + 28*x^2 + 7*x - 1 with a0 = 1.953241111420174? To: Cyclotomic Field of order 29 and degree 28 Defn: a0 |--> -a^27 - a^26 - a^25 - a^24 - a^23 - a^22 - a^21 - a^20 - a^19 - a^18 - a^17 - a^16 - a^15 - a^14 - a^13 - a^12 - a^11 - a^10 - a^9 - a^8 - a^7 - a^6 - a^5 - a^4 - a^3 - a^2 - 1) sage: x = polygen(QQ, 'x') sage: F.<a> = NumberField(x^3 - 2) sage: F.maximal_totally_real_subfield() [Rational Field, Coercion map: From: Rational Field To: Number Field in a with defining polynomial x^3 - 2] sage: F.<a> = NumberField(x^4 - x^3 - x^2 + x + 1) sage: F.maximal_totally_real_subfield() [Rational Field, Coercion map: From: Rational Field To: Number Field in a with defining polynomial x^4 - x^3 - x^2 + x + 1] sage: F.<a> = NumberField(x^4 - x^3 + 2*x^2 + x + 1) sage: F.maximal_totally_real_subfield() [Number Field in a1 with defining polynomial x^2 - x - 1, Ring morphism: From: Number Field in a1 with defining polynomial x^2 - x - 1 To: Number Field in a with defining polynomial x^4 - x^3 + 2*x^2 + x + 1 Defn: a1 |--> -1/2*a^3 - 1/2] sage: F.<a> = NumberField(x^4 - 4*x^2 - x + 1) sage: F.maximal_totally_real_subfield() [Number Field in a with defining polynomial x^4 - 4*x^2 - x + 1, Identity endomorphism of Number Field in a with defining polynomial x^4 - 4*x^2 - x + 1]
>>> from sage.all import * >>> F = QuadraticField(Integer(11), names=('a',)); (a,) = F._first_ngens(1) >>> F.maximal_totally_real_subfield() [Number Field in a with defining polynomial x^2 - 11 with a = 3.316624790355400?, Identity endomorphism of Number Field in a with defining polynomial x^2 - 11 with a = 3.316624790355400?] >>> F = QuadraticField(-Integer(15), names=('a',)); (a,) = F._first_ngens(1) >>> F.maximal_totally_real_subfield() [Rational Field, Natural morphism: From: Rational Field To: Number Field in a with defining polynomial x^2 + 15 with a = 3.872983346207417?*I] >>> F = CyclotomicField(Integer(29), names=('a',)); (a,) = F._first_ngens(1) >>> F.maximal_totally_real_subfield() (Number Field in a0 with defining polynomial x^14 + x^13 - 13*x^12 - 12*x^11 + 66*x^10 + 55*x^9 - 165*x^8 - 120*x^7 + 210*x^6 + 126*x^5 - 126*x^4 - 56*x^3 + 28*x^2 + 7*x - 1 with a0 = 1.953241111420174?, Ring morphism: From: Number Field in a0 with defining polynomial x^14 + x^13 - 13*x^12 - 12*x^11 + 66*x^10 + 55*x^9 - 165*x^8 - 120*x^7 + 210*x^6 + 126*x^5 - 126*x^4 - 56*x^3 + 28*x^2 + 7*x - 1 with a0 = 1.953241111420174? To: Cyclotomic Field of order 29 and degree 28 Defn: a0 |--> -a^27 - a^26 - a^25 - a^24 - a^23 - a^22 - a^21 - a^20 - a^19 - a^18 - a^17 - a^16 - a^15 - a^14 - a^13 - a^12 - a^11 - a^10 - a^9 - a^8 - a^7 - a^6 - a^5 - a^4 - a^3 - a^2 - 1) >>> x = polygen(QQ, 'x') >>> F = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = F._first_ngens(1) >>> F.maximal_totally_real_subfield() [Rational Field, Coercion map: From: Rational Field To: Number Field in a with defining polynomial x^3 - 2] >>> F = NumberField(x**Integer(4) - x**Integer(3) - x**Integer(2) + x + Integer(1), names=('a',)); (a,) = F._first_ngens(1) >>> F.maximal_totally_real_subfield() [Rational Field, Coercion map: From: Rational Field To: Number Field in a with defining polynomial x^4 - x^3 - x^2 + x + 1] >>> F = NumberField(x**Integer(4) - x**Integer(3) + Integer(2)*x**Integer(2) + x + Integer(1), names=('a',)); (a,) = F._first_ngens(1) >>> F.maximal_totally_real_subfield() [Number Field in a1 with defining polynomial x^2 - x - 1, Ring morphism: From: Number Field in a1 with defining polynomial x^2 - x - 1 To: Number Field in a with defining polynomial x^4 - x^3 + 2*x^2 + x + 1 Defn: a1 |--> -1/2*a^3 - 1/2] >>> F = NumberField(x**Integer(4) - Integer(4)*x**Integer(2) - x + Integer(1), names=('a',)); (a,) = F._first_ngens(1) >>> F.maximal_totally_real_subfield() [Number Field in a with defining polynomial x^4 - 4*x^2 - x + 1, Identity endomorphism of Number Field in a with defining polynomial x^4 - 4*x^2 - x + 1]
An example of a relative extension where the base field is not the maximal totally real subfield.
sage: E_0.<a> = NumberField(x^2 - 4*x + 16) sage: y = polygen(E_0) sage: E.<z> = E_0.extension(y^2 - E_0.gen() / 2) sage: E.maximal_totally_real_subfield() [Number Field in z1 with defining polynomial x^2 - 2*x - 5, Composite map: From: Number Field in z1 with defining polynomial x^2 - 2*x - 5 To: Number Field in z with defining polynomial x^2 - 1/2*a over its base field Defn: Ring morphism: From: Number Field in z1 with defining polynomial x^2 - 2*x - 5 To: Number Field in z with defining polynomial x^4 - 2*x^3 + x^2 + 6*x + 3 Defn: z1 |--> -1/3*z^3 + 1/3*z^2 + z - 1 then Isomorphism map: From: Number Field in z with defining polynomial x^4 - 2*x^3 + x^2 + 6*x + 3 To: Number Field in z with defining polynomial x^2 - 1/2*a over its base field]
>>> from sage.all import * >>> E_0 = NumberField(x**Integer(2) - Integer(4)*x + Integer(16), names=('a',)); (a,) = E_0._first_ngens(1) >>> y = polygen(E_0) >>> E = E_0.extension(y**Integer(2) - E_0.gen() / Integer(2), names=('z',)); (z,) = E._first_ngens(1) >>> E.maximal_totally_real_subfield() [Number Field in z1 with defining polynomial x^2 - 2*x - 5, Composite map: From: Number Field in z1 with defining polynomial x^2 - 2*x - 5 To: Number Field in z with defining polynomial x^2 - 1/2*a over its base field Defn: Ring morphism: From: Number Field in z1 with defining polynomial x^2 - 2*x - 5 To: Number Field in z with defining polynomial x^4 - 2*x^3 + x^2 + 6*x + 3 Defn: z1 |--> -1/3*z^3 + 1/3*z^2 + z - 1 then Isomorphism map: From: Number Field in z with defining polynomial x^4 - 2*x^3 + x^2 + 6*x + 3 To: Number Field in z with defining polynomial x^2 - 1/2*a over its base field]
- narrow_class_group(proof=None)[source]#
Return the narrow class group of this field.
INPUT:
proof
– default:None
(use the global proof setting, which defaults toTrue
).
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: NumberField(x^3 + x + 9, 'a').narrow_class_group() Multiplicative Abelian group isomorphic to C2
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(3) + x + Integer(9), 'a').narrow_class_group() Multiplicative Abelian group isomorphic to C2
- ngens()[source]#
Return the number of generators of this number field (always 1).
OUTPUT: the python integer 1.
EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + Integer(17),'a').ngens() 1 >>> NumberField(x + Integer(3),'a').ngens() 1 >>> k = NumberField(x + Integer(3), names=('a',)); (a,) = k._first_ngens(1) >>> k.ngens() 1 >>> k.gen(0) -3
- number_of_roots_of_unity()[source]#
Return the number of roots of unity in this field.
Note
We do not create the full unit group since that can be expensive, but we do use it if it is already known.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: F.<alpha> = NumberField(x^22 + 3) sage: F.zeta_order() 6 sage: F.<alpha> = NumberField(x^2 - 7) sage: F.zeta_order() 2
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> F = NumberField(x**Integer(22) + Integer(3), names=('alpha',)); (alpha,) = F._first_ngens(1) >>> F.zeta_order() 6 >>> F = NumberField(x**Integer(2) - Integer(7), names=('alpha',)); (alpha,) = F._first_ngens(1) >>> F.zeta_order() 2
- order()[source]#
Return the order of this number field (always +infinity).
OUTPUT: always positive infinity
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: NumberField(x^2 + 19,'a').order() +Infinity
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + Integer(19),'a').order() +Infinity
- pari_bnf(proof=None, units=True)[source]#
PARI big number field corresponding to this field.
INPUT:
proof
– IfFalse
, assume GRH. IfTrue
, run PARI’s pari:bnfcertify to make sure that the results are correct.units
– (default:True) If ``True
, insist on having fundamental units. IfFalse
, the units may or may not be computed.
OUTPUT:
The PARI
bnf
structure of this number field.Warning
Even with
proof=True
, I wouldn’t trust this to mean that everything computed involving this number field is actually correct.EXAMPLES:
sage: x = polygen(QQ, 'x') 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,3), [;], ...] sage: len(k.pari_nf()) 9 sage: k.<a> = NumberField(x^7 + 7); k Number Field in a with defining polynomial x^7 + 7 sage: dummy = k.pari_bnf(proof=True)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = k._first_ngens(1); k Number Field in a with defining polynomial x^2 + 1 >>> len(k.pari_bnf()) 10 >>> k.pari_bnf()[:Integer(4)] [[;], matrix(0,3), [;], ...] >>> len(k.pari_nf()) 9 >>> k = NumberField(x**Integer(7) + Integer(7), names=('a',)); (a,) = k._first_ngens(1); k Number Field in a with defining polynomial x^7 + 7 >>> dummy = k.pari_bnf(proof=True)
- pari_nf(important=True)[source]#
Return the PARI number field corresponding to this field.
INPUT:
important
– boolean (default:True
). IfFalse
, raise aRuntimeError
if we need to do a difficult discriminant factorization. This is useful when an integral basis is not strictly required, such as for factoring polynomials over this number field.
OUTPUT:
The PARI number field obtained by calling the PARI function pari:nfinit with
self.pari_polynomial('y')
as argument.Note
This method has the same effect as
pari(self)
.EXAMPLES:
sage: x = polygen(QQ, 'x') 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] [y^4 - 3*y + 7, [0, 2], 85621, 1] sage: pari(k)[:4] [y^4 - 3*y + 7, [0, 2], 85621, 1]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(4) - Integer(3)*x + Integer(7), names=('a',)); (a,) = k._first_ngens(1); k Number Field in a with defining polynomial x^4 - 3*x + 7 >>> k.pari_nf()[:Integer(4)] [y^4 - 3*y + 7, [0, 2], 85621, 1] >>> pari(k)[:Integer(4)] [y^4 - 3*y + 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() [y^4 - 324*y + 2160, [0, 2], 48918708, 216, ..., [36, 36*y, y^3 + 6*y^2 - 252, 6*y^2], [1, 0, 0, 252; 0, 1, 0, 0; 0, 0, 0, 36; 0, 0, 6, -36], [1, 0, 0, 0, 0, 0, -18, 42, 0, -18, -46, -60, 0, 42, -60, -60; 0, 1, 0, 0, 1, 0, 2, 0, 0, 2, -11, -1, 0, 0, -1, 9; 0, 0, 1, 0, 0, 0, 6, 6, 1, 6, -5, 0, 0, 6, 0, 0; 0, 0, 0, 1, 0, 6, -6, -6, 0, -6, -1, 2, 1, -6, 2, 0]] sage: pari(k) [y^4 - 324*y + 2160, [0, 2], 48918708, 216, ...] sage: gp(k) [y^4 - 324*y + 2160, [0, 2], 48918708, 216, ...]
>>> from sage.all import * >>> k = NumberField(x**Integer(4) - Integer(3)/Integer(2)*x + Integer(5)/Integer(3), names=('a',)); (a,) = k._first_ngens(1); k Number Field in a with defining polynomial x^4 - 3/2*x + 5/3 >>> k.pari_nf() [y^4 - 324*y + 2160, [0, 2], 48918708, 216, ..., [36, 36*y, y^3 + 6*y^2 - 252, 6*y^2], [1, 0, 0, 252; 0, 1, 0, 0; 0, 0, 0, 36; 0, 0, 6, -36], [1, 0, 0, 0, 0, 0, -18, 42, 0, -18, -46, -60, 0, 42, -60, -60; 0, 1, 0, 0, 1, 0, 2, 0, 0, 2, -11, -1, 0, 0, -1, 9; 0, 0, 1, 0, 0, 0, 6, 6, 1, 6, -5, 0, 0, 6, 0, 0; 0, 0, 0, 1, 0, 6, -6, -6, 0, -6, -1, 2, 1, -6, 2, 0]] >>> pari(k) [y^4 - 324*y + 2160, [0, 2], 48918708, 216, ...] >>> gp(k) [y^4 - 324*y + 2160, [0, 2], 48918708, 216, ...]
With
important=False
, we simply bail out if we cannot easily factor the discriminant:sage: p = next_prime(10^40); q = next_prime(10^41) sage: K.<a> = NumberField(x^2 - p*q) sage: K.pari_nf(important=False) Traceback (most recent call last): ... RuntimeError: Unable to factor discriminant with trial division
>>> from sage.all import * >>> p = next_prime(Integer(10)**Integer(40)); q = next_prime(Integer(10)**Integer(41)) >>> K = NumberField(x**Integer(2) - p*q, names=('a',)); (a,) = K._first_ngens(1) >>> K.pari_nf(important=False) Traceback (most recent call last): ... RuntimeError: Unable to factor discriminant with trial division
Next, we illustrate the
maximize_at_primes
andassume_disc_small
parameters of theNumberField
constructor. The following would take a very long time without themaximize_at_primes
option:sage: K.<a> = NumberField(x^2 - p*q, maximize_at_primes=[p]) sage: K.pari_nf() [y^2 - 100000000000000000000...]
>>> from sage.all import * >>> K = NumberField(x**Integer(2) - p*q, maximize_at_primes=[p], names=('a',)); (a,) = K._first_ngens(1) >>> K.pari_nf() [y^2 - 100000000000000000000...]
Since the discriminant is square-free, this also works:
sage: K.<a> = NumberField(x^2 - p*q, assume_disc_small=True) sage: K.pari_nf() [y^2 - 100000000000000000000...]
>>> from sage.all import * >>> K = NumberField(x**Integer(2) - p*q, assume_disc_small=True, names=('a',)); (a,) = K._first_ngens(1) >>> K.pari_nf() [y^2 - 100000000000000000000...]
- pari_polynomial(name='x')[source]#
Return the PARI polynomial corresponding to this number field.
INPUT:
name
– variable name (default:'x'
)
OUTPUT:
A monic polynomial with integral coefficients (PARI
t_POL
) defining the PARI number field corresponding toself
.Warning
This is not the same as simply converting the defining polynomial to PARI.
EXAMPLES:
sage: y = polygen(QQ) sage: k.<a> = NumberField(y^2 - 3/2*y + 5/3) sage: k.pari_polynomial() x^2 - x + 40 sage: k.polynomial().__pari__() x^2 - 3/2*x + 5/3 sage: k.pari_polynomial('a') a^2 - a + 40
>>> from sage.all import * >>> y = polygen(QQ) >>> k = NumberField(y**Integer(2) - Integer(3)/Integer(2)*y + Integer(5)/Integer(3), names=('a',)); (a,) = k._first_ngens(1) >>> k.pari_polynomial() x^2 - x + 40 >>> k.polynomial().__pari__() x^2 - 3/2*x + 5/3 >>> k.pari_polynomial('a') a^2 - a + 40
Some examples with relative number fields:
sage: x = polygen(ZZ, 'x') sage: k.<a, c> = NumberField([x^2 + 3, x^2 + 1]) sage: k.pari_polynomial() x^4 + 8*x^2 + 4 sage: k.pari_polynomial('a') a^4 + 8*a^2 + 4 sage: k.absolute_polynomial() x^4 + 8*x^2 + 4 sage: k.relative_polynomial() x^2 + 3 sage: k.<a, c> = NumberField([x^2 + 1/3, x^2 + 1/4]) sage: k.pari_polynomial() x^4 - x^2 + 1 sage: k.absolute_polynomial() x^4 - x^2 + 1
>>> from sage.all import * >>> x = polygen(ZZ, 'x') >>> k = NumberField([x**Integer(2) + Integer(3), x**Integer(2) + Integer(1)], names=('a', 'c',)); (a, c,) = k._first_ngens(2) >>> k.pari_polynomial() x^4 + 8*x^2 + 4 >>> k.pari_polynomial('a') a^4 + 8*a^2 + 4 >>> k.absolute_polynomial() x^4 + 8*x^2 + 4 >>> k.relative_polynomial() x^2 + 3 >>> k = NumberField([x**Integer(2) + Integer(1)/Integer(3), x**Integer(2) + Integer(1)/Integer(4)], names=('a', 'c',)); (a, c,) = k._first_ngens(2) >>> k.pari_polynomial() x^4 - x^2 + 1 >>> k.absolute_polynomial() x^4 - x^2 + 1
This fails with arguments which are not a valid PARI variable name:
sage: k = QuadraticField(-1) sage: k.pari_polynomial('I') Traceback (most recent call last): ... PariError: I already exists with incompatible valence sage: k.pari_polynomial('i') i^2 + 1 sage: k.pari_polynomial('theta') Traceback (most recent call last): ... PariError: theta already exists with incompatible valence
>>> from sage.all import * >>> k = QuadraticField(-Integer(1)) >>> k.pari_polynomial('I') Traceback (most recent call last): ... PariError: I already exists with incompatible valence >>> k.pari_polynomial('i') i^2 + 1 >>> k.pari_polynomial('theta') Traceback (most recent call last): ... PariError: theta already exists with incompatible valence
- pari_rnfnorm_data(L, proof=True)[source]#
Return the PARI pari:rnfisnorminit data corresponding to the extension \(L\) /
self
.EXAMPLES:
sage: x = polygen(QQ) sage: K = NumberField(x^2 - 2, 'alpha') sage: L = K.extension(x^2 + 5, 'gamma') sage: ls = K.pari_rnfnorm_data(L) ; len(ls) 8 sage: K.<a> = NumberField(x^2 + x + 1) sage: P.<X> = K[] sage: L.<b> = NumberField(X^3 + a) sage: ls = K.pari_rnfnorm_data(L); len(ls) 8
>>> from sage.all import * >>> x = polygen(QQ) >>> K = NumberField(x**Integer(2) - Integer(2), 'alpha') >>> L = K.extension(x**Integer(2) + Integer(5), 'gamma') >>> ls = K.pari_rnfnorm_data(L) ; len(ls) 8 >>> K = NumberField(x**Integer(2) + x + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> P = K['X']; (X,) = P._first_ngens(1) >>> L = NumberField(X**Integer(3) + a, names=('b',)); (b,) = L._first_ngens(1) >>> ls = K.pari_rnfnorm_data(L); len(ls) 8
- pari_zk()[source]#
Integral basis of the PARI number field corresponding to this field.
This is the same as
pari_nf().getattr('zk')
, but much faster.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: k.<a> = NumberField(x^3 - 17) sage: k.pari_zk() [1, 1/3*y^2 - 1/3*y + 1/3, y] sage: k.pari_nf().getattr('zk') [1, 1/3*y^2 - 1/3*y + 1/3, y]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(3) - Integer(17), names=('a',)); (a,) = k._first_ngens(1) >>> k.pari_zk() [1, 1/3*y^2 - 1/3*y + 1/3, y] >>> k.pari_nf().getattr('zk') [1, 1/3*y^2 - 1/3*y + 1/3, y]
- polynomial()[source]#
Return the defining polynomial of this number field.
This is exactly the same as
defining_polynomial()
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: NumberField(x^2 + (2/3)*x - 9/17,'a').polynomial() x^2 + 2/3*x - 9/17
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + (Integer(2)/Integer(3))*x - Integer(9)/Integer(17),'a').polynomial() x^2 + 2/3*x - 9/17
- polynomial_ntl()[source]#
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.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: NumberField(x^2 + (2/3)*x - 9/17,'a').polynomial_ntl() ([-27 34 51], 51)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + (Integer(2)/Integer(3))*x - Integer(9)/Integer(17),'a').polynomial_ntl() ([-27 34 51], 51)
- polynomial_quotient_ring()[source]#
Return the polynomial quotient ring isomorphic to this number field.
EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) + Integer(2)*x - Integer(5), 'alpha') >>> K.polynomial_quotient_ring() Univariate Quotient Polynomial Ring in alpha over Rational Field with modulus x^3 + 2*x - 5
- polynomial_ring()[source]#
Return the polynomial ring that we view this number field as being a quotient of (by a principal ideal).
EXAMPLES: An example with an absolute field:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> k = NumberField(x**Integer(2) + Integer(3), names=('a',)); (a,) = k._first_ngens(1) >>> y = polygen(QQ, 'y') >>> k = NumberField(y**Integer(2) + Integer(3), names=('a',)); (a,) = k._first_ngens(1) >>> 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
>>> from sage.all import * >>> y = polygen(QQ, 'y') >>> M = NumberField([y**Integer(3) + Integer(97), y**Integer(2) + Integer(1)], names=('a',)); (a,) = M._first_ngens(1); M Number Field in a0 with defining polynomial y^3 + 97 over its base field >>> M.polynomial_ring() Univariate Polynomial Ring in y over Number Field in a1 with defining polynomial y^2 + 1
- power_basis()[source]#
Return a power basis for this number field over its base field.
If this number field is represented as \(k[t]/f(t)\), then the basis returned is \(1, t, t^2, \ldots, t^{d-1}\) where \(d\) is the degree of this number field over its base field.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^5 + 10*x + 1) sage: K.power_basis() [1, a, a^2, a^3, a^4]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(5) + Integer(10)*x + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> K.power_basis() [1, a, a^2, a^3, a^4]
sage: L.<b> = K.extension(x^2 - 2) sage: L.power_basis() [1, b] sage: L.absolute_field('c').power_basis() [1, c, c^2, c^3, c^4, c^5, c^6, c^7, c^8, c^9]
>>> from sage.all import * >>> L = K.extension(x**Integer(2) - Integer(2), names=('b',)); (b,) = L._first_ngens(1) >>> L.power_basis() [1, b] >>> L.absolute_field('c').power_basis() [1, c, c^2, c^3, c^4, c^5, c^6, c^7, c^8, c^9]
sage: M = CyclotomicField(15) sage: M.power_basis() [1, zeta15, zeta15^2, zeta15^3, zeta15^4, zeta15^5, zeta15^6, zeta15^7]
>>> from sage.all import * >>> M = CyclotomicField(Integer(15)) >>> M.power_basis() [1, zeta15, zeta15^2, zeta15^3, zeta15^4, zeta15^5, zeta15^6, zeta15^7]
- prime_above(x, degree=None)[source]#
Return a prime ideal of
self
lying over \(x\).INPUT:
x
– usually an element or ideal ofself
. It should be such thatself.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\). Ifdegree
is specified and no such ideal exists, raises aValueError
.EXAMPLES:
sage: x = ZZ['x'].gen() sage: F.<t> = NumberField(x^3 - 2)
>>> from sage.all import * >>> x = ZZ['x'].gen() >>> F = NumberField(x**Integer(3) - Integer(2), names=('t',)); (t,) = F._first_ngens(1)
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
>>> from sage.all import * >>> P2 = F.prime_above(Integer(2)) >>> P2 # random Fractional ideal (-t) >>> Integer(2) in P2 True >>> P2.is_prime() True >>> 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
>>> from sage.all import * >>> P3 = F.prime_above(Integer(3)) >>> P3 # random Fractional ideal (t + 1) >>> Integer(3) in P3 True >>> P3.is_prime() True >>> 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]
>>> from sage.all import * >>> F.prime_above(Integer(3), degree=Integer(2)) Traceback (most recent call last): ... ValueError: No prime of degree 2 above Fractional ideal (3) >>> [ id.residue_class_degree() for id, _ in F.ideal(Integer(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
>>> from sage.all import * >>> P5_1 = F.prime_above(Integer(5), degree=Integer(1)) >>> P5_1 # random Fractional ideal (-t^2 - 1) >>> 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
>>> from sage.all import * >>> P5_2 = F.prime_above(Integer(5), degree=Integer(2)) >>> P5_2 # random Fractional ideal (t^2 - 2*t - 1) >>> P5_2.residue_class_degree() 2
Relative number fields are ok:
sage: G = F.extension(x^2 - 11, 'b') sage: G.prime_above(7) Fractional ideal (b + 2)
>>> from sage.all import * >>> G = F.extension(x**Integer(2) - Integer(11), 'b') >>> G.prime_above(Integer(7)) Fractional ideal (b + 2)
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 'prime_factors'...
>>> from sage.all import * >>> F.prime_above(Integer(0)) Traceback (most recent call last): ... AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- prime_factors(x)[source]#
Return a list of the prime ideals of
self
which divide the ideal generated by \(x\).OUTPUT: list of prime ideals (a new list is returned each time this function is called)
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<w> = NumberField(x^2 + 23) sage: K.prime_factors(w + 1) [Fractional ideal (2, 1/2*w - 1/2), Fractional ideal (2, 1/2*w + 1/2), Fractional ideal (3, 1/2*w + 1/2)]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(23), names=('w',)); (w,) = K._first_ngens(1) >>> K.prime_factors(w + Integer(1)) [Fractional ideal (2, 1/2*w - 1/2), Fractional ideal (2, 1/2*w + 1/2), Fractional ideal (3, 1/2*w + 1/2)]
- primes_above(x, degree=None)[source]#
Return prime ideals of
self
lying over \(x\).INPUT:
x
– usually an element or ideal ofself
. It should be such thatself.ideal(x)
is sensible. This excludes \(x=0\).degree
– (default:None
)None
or an integer. IfNone
, 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\). Ifdegree
is specified and no such ideal exists, returns the empty list. The output is sorted by residue degree first, then by underlying prime (or equivalently, by norm).EXAMPLES:
sage: x = ZZ['x'].gen() sage: F.<t> = NumberField(x^3 - 2)
>>> from sage.all import * >>> x = ZZ['x'].gen() >>> F = NumberField(x**Integer(3) - Integer(2), names=('t',)); (t,) = F._first_ngens(1)
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]
>>> from sage.all import * >>> P2s = F.primes_above(Integer(2)) >>> P2s # random [Fractional ideal (-t)] >>> all(Integer(2) in P2 for P2 in P2s) True >>> all(P2.is_prime() for P2 in P2s) True >>> [ 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]
>>> from sage.all import * >>> P3s = F.primes_above(Integer(3)) >>> P3s # random [Fractional ideal (t + 1)] >>> all(Integer(3) in P3 for P3 in P3s) True >>> all(P3.is_prime() for P3 in P3s) True >>> [ 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]
>>> from sage.all import * >>> F.primes_above(Integer(3), degree=Integer(2)) [] >>> [ id.residue_class_degree() for id, _ in F.ideal(Integer(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
>>> from sage.all import * >>> P5_1s = F.primes_above(Integer(5), degree=Integer(1)) >>> P5_1s # random [Fractional ideal (-t^2 - 1)] >>> P5_1 = P5_1s[Integer(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
>>> from sage.all import * >>> P5_2s = F.primes_above(Integer(5), degree=Integer(2)) >>> P5_2s # random [Fractional ideal (t^2 - 2*t - 1)] >>> P5_2 = P5_2s[Integer(0)]; P5_2.residue_class_degree() 2
Works in relative extensions too:
sage: PQ.<X> = QQ[] sage: F.<a, b> = NumberField([X^2 - 2, X^2 - 3]) sage: PF.<Y> = F[] sage: K.<c> = F.extension(Y^2 - (1 + a)*(a + b)*a*b) sage: I = F.ideal(a + 2*b) sage: P, Q = K.primes_above(I) sage: K.ideal(I) == P^4*Q True sage: K.primes_above(I, degree=1) == [P] True sage: K.primes_above(I, degree=4) == [Q] True
>>> from sage.all import * >>> PQ = QQ['X']; (X,) = PQ._first_ngens(1) >>> F = NumberField([X**Integer(2) - Integer(2), X**Integer(2) - Integer(3)], names=('a', 'b',)); (a, b,) = F._first_ngens(2) >>> PF = F['Y']; (Y,) = PF._first_ngens(1) >>> K = F.extension(Y**Integer(2) - (Integer(1) + a)*(a + b)*a*b, names=('c',)); (c,) = K._first_ngens(1) >>> I = F.ideal(a + Integer(2)*b) >>> P, Q = K.primes_above(I) >>> K.ideal(I) == P**Integer(4)*Q True >>> K.primes_above(I, degree=Integer(1)) == [P] True >>> K.primes_above(I, degree=Integer(4)) == [Q] True
It doesn’t make sense to factor the ideal \((0)\), so this raises an error:
sage: F.prime_above(0) Traceback (most recent call last): ... AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
>>> from sage.all import * >>> F.prime_above(Integer(0)) Traceback (most recent call last): ... AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- primes_of_bounded_norm(B)[source]#
Return a sorted list of all prime ideals with norm at most \(B\).
INPUT:
B
– a positive integer or real; upper bound on the norms of the primes generated.
OUTPUT:
A list of all prime ideals of this number field of norm at most \(B\), sorted by norm. Primes of the same norm are sorted using the comparison function for ideals, which is based on the Hermite Normal Form.
Note
See also
primes_of_bounded_norm_iter()
for an iterator version of this, but note that the iterator sorts the primes in order of underlying rational prime, not by norm.EXAMPLES:
sage: K.<i> = QuadraticField(-1) sage: K.primes_of_bounded_norm(10) [Fractional ideal (i + 1), Fractional ideal (-i - 2), Fractional ideal (2*i + 1), Fractional ideal (3)] sage: K.primes_of_bounded_norm(1) [] sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^3 - 2) sage: P = K.primes_of_bounded_norm(30) sage: P [Fractional ideal (a), Fractional ideal (a + 1), Fractional ideal (-a^2 - 1), Fractional ideal (a^2 + a - 1), Fractional ideal (2*a + 1), Fractional ideal (-2*a^2 - a - 1), Fractional ideal (a^2 - 2*a - 1), Fractional ideal (a + 3)] sage: [p.norm() for p in P] [2, 3, 5, 11, 17, 23, 25, 29]
>>> from sage.all import * >>> K = QuadraticField(-Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.primes_of_bounded_norm(Integer(10)) [Fractional ideal (i + 1), Fractional ideal (-i - 2), Fractional ideal (2*i + 1), Fractional ideal (3)] >>> K.primes_of_bounded_norm(Integer(1)) [] >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> P = K.primes_of_bounded_norm(Integer(30)) >>> P [Fractional ideal (a), Fractional ideal (a + 1), Fractional ideal (-a^2 - 1), Fractional ideal (a^2 + a - 1), Fractional ideal (2*a + 1), Fractional ideal (-2*a^2 - a - 1), Fractional ideal (a^2 - 2*a - 1), Fractional ideal (a + 3)] >>> [p.norm() for p in P] [2, 3, 5, 11, 17, 23, 25, 29]
- primes_of_bounded_norm_iter(B)[source]#
Iterator yielding all prime ideals with norm at most \(B\).
INPUT:
B
– a positive integer or real; upper bound on the norms of the primes generated.
OUTPUT:
An iterator over all prime ideals of this number field of norm at most \(B\).
Note
The output is not sorted by norm, but by size of the underlying rational prime.
EXAMPLES:
sage: K.<i> = QuadraticField(-1) sage: it = K.primes_of_bounded_norm_iter(10) sage: list(it) [Fractional ideal (i + 1), Fractional ideal (3), Fractional ideal (-i - 2), Fractional ideal (2*i + 1)] sage: list(K.primes_of_bounded_norm_iter(1)) []
>>> from sage.all import * >>> K = QuadraticField(-Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> it = K.primes_of_bounded_norm_iter(Integer(10)) >>> list(it) [Fractional ideal (i + 1), Fractional ideal (3), Fractional ideal (-i - 2), Fractional ideal (2*i + 1)] >>> list(K.primes_of_bounded_norm_iter(Integer(1))) []
- primes_of_degree_one_iter(num_integer_primes=10000, max_iterations=100)[source]#
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 thenum_integer_primes
-th prime number. For example, ifnum_integer_primes
is 2, the largest norm found will be 3, since the second prime is 3.max_iterations
– (default: 100) an integer. We testmax_iterations
integers to find small primes before raisingStopIteration
.
EXAMPLES:
sage: K.<z> = CyclotomicField(10) sage: it = K.primes_of_degree_one_iter() sage: Ps = [ next(it) 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]
>>> from sage.all import * >>> K = CyclotomicField(Integer(10), names=('z',)); (z,) = K._first_ngens(1) >>> it = K.primes_of_degree_one_iter() >>> Ps = [ next(it) for i in range(Integer(3)) ] >>> 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)] >>> [P.norm() for P in Ps] # random [11, 31, 41] >>> [P.residue_class_degree() for P in Ps] [1, 1, 1]
- primes_of_degree_one_list(n, num_integer_primes=10000, max_iterations=100)[source]#
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 is 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 thenum_integer_primes
-th prime number. For example, ifnum_integer_primes
is 2, the largest norm found will be 3, since the second prime is 3.max_iterations
– (default: 100) an integer. We testmax_iterations
integers to find small primes before raisingStopIteration
.
EXAMPLES:
sage: K.<z> = CyclotomicField(10) sage: Ps = K.primes_of_degree_one_list(3) sage: Ps # random output [Fractional ideal (-z^3 - z^2 + 1), Fractional ideal (2*z^3 - 2*z^2 + 2*z - 3), 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]
>>> from sage.all import * >>> K = CyclotomicField(Integer(10), names=('z',)); (z,) = K._first_ngens(1) >>> Ps = K.primes_of_degree_one_list(Integer(3)) >>> Ps # random output [Fractional ideal (-z^3 - z^2 + 1), Fractional ideal (2*z^3 - 2*z^2 + 2*z - 3), Fractional ideal (2*z^3 - 3*z^2 + z - 2)] >>> [P.norm() for P in Ps] [11, 31, 41] >>> [P.residue_class_degree() for P in Ps] [1, 1, 1]
- primitive_element()[source]#
Return a primitive element for this field, i.e., an element that generates it over \(\QQ\).
EXAMPLES:
sage: x = polygen(ZZ, 'x') 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 - b + c sage: alpha = K.primitive_element(); alpha a - 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
>>> from sage.all import * >>> x = polygen(ZZ, 'x') >>> K = NumberField(x**Integer(3) + Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> K.primitive_element() a >>> K = NumberField([x**Integer(2) - Integer(2), x**Integer(2) - Integer(3), x**Integer(2) - Integer(5)], names=('a', 'b', 'c',)); (a, b, c,) = K._first_ngens(3) >>> K.primitive_element() a - b + c >>> alpha = K.primitive_element(); alpha a - b + c >>> alpha.minpoly() x^2 + (2*b - 2*c)*x - 2*c*b + 6 >>> alpha.absolute_minpoly() x^8 - 40*x^6 + 352*x^4 - 960*x^2 + 576
- primitive_root_of_unity()[source]#
Return a generator of the roots of unity in this field.
OUTPUT: a primitive root of unity. No guarantee is made about which primitive root of unity this returns, not even for cyclotomic fields. Repeated calls of this function may return a different value.
Note
We do not create the full unit group since that can be expensive, but we do use it if it is already known.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<i> = NumberField(x^2 + 1) sage: z = K.primitive_root_of_unity(); z i sage: z.multiplicative_order() 4 sage: K.<a> = NumberField(x^2 + x + 1) sage: z = K.primitive_root_of_unity(); z a + 1 sage: z.multiplicative_order() 6 sage: x = polygen(QQ) sage: F.<a,b> = NumberField([x^2 - 2, x^2 - 3]) sage: y = polygen(F) sage: K.<c> = F.extension(y^2 - (1 + a)*(a + b)*a*b) sage: K.primitive_root_of_unity() -1
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> z = K.primitive_root_of_unity(); z i >>> z.multiplicative_order() 4 >>> K = NumberField(x**Integer(2) + x + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> z = K.primitive_root_of_unity(); z a + 1 >>> z.multiplicative_order() 6 >>> x = polygen(QQ) >>> F = NumberField([x**Integer(2) - Integer(2), x**Integer(2) - Integer(3)], names=('a', 'b',)); (a, b,) = F._first_ngens(2) >>> y = polygen(F) >>> K = F.extension(y**Integer(2) - (Integer(1) + a)*(a + b)*a*b, names=('c',)); (c,) = K._first_ngens(1) >>> K.primitive_root_of_unity() -1
We do not special-case cyclotomic fields, so we do not always get the most obvious primitive root of unity:
sage: K.<a> = CyclotomicField(3) sage: z = K.primitive_root_of_unity(); z a + 1 sage: z.multiplicative_order() 6 sage: K = CyclotomicField(3) sage: z = K.primitive_root_of_unity(); z zeta3 + 1 sage: z.multiplicative_order() 6
>>> from sage.all import * >>> K = CyclotomicField(Integer(3), names=('a',)); (a,) = K._first_ngens(1) >>> z = K.primitive_root_of_unity(); z a + 1 >>> z.multiplicative_order() 6 >>> K = CyclotomicField(Integer(3)) >>> z = K.primitive_root_of_unity(); z zeta3 + 1 >>> z.multiplicative_order() 6
- quadratic_defect(a, p, check=True)[source]#
Return the valuation of the quadratic defect of \(a\) at \(p\).
INPUT:
a
– an element ofself
p
– a prime idealcheck
– (default:True
); check if \(p\) is prime
ALGORITHM:
This is an implementation of Algorithm 3.1.3 from [Kir2016]
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^2 + 2) sage: p = K.primes_above(2)[0] sage: K.quadratic_defect(5, p) 4 sage: K.quadratic_defect(0, p) +Infinity sage: K.quadratic_defect(a, p) 1 sage: K.<a> = CyclotomicField(5) sage: p = K.primes_above(2)[0] sage: K.quadratic_defect(5, p) +Infinity
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> p = K.primes_above(Integer(2))[Integer(0)] >>> K.quadratic_defect(Integer(5), p) 4 >>> K.quadratic_defect(Integer(0), p) +Infinity >>> K.quadratic_defect(a, p) 1 >>> K = CyclotomicField(Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> p = K.primes_above(Integer(2))[Integer(0)] >>> K.quadratic_defect(Integer(5), p) +Infinity
- random_element(num_bound=None, den_bound=None, integral_coefficients=False, distribution=None)[source]#
Return a random element of this number field.
INPUT:
num_bound
– Bound on numerator of the coefficients of the resulting elementden_bound
– Bound on denominators of the coefficients of the resulting elementintegral_coefficients
– (default:False
) IfTrue
, then the resulting element will have integral coefficients. This option overrides any value ofden_bound
.distribution
– Distribution to use for the coefficients of the resulting element
OUTPUT: Element of this number field
EXAMPLES:
sage: x = polygen(ZZ, 'x') sage: K.<j> = NumberField(x^8 + 1) sage: K.random_element().parent() is K True sage: while K.random_element().list()[0] != 0: ....: pass sage: while K.random_element().list()[0] == 0: ....: pass sage: while K.random_element().is_prime(): ....: pass sage: while not K.random_element().is_prime(): ....: pass sage: K.<a,b,c> = NumberField([x^2 - 2, x^2 - 3, x^2 - 5]) sage: K.random_element().parent() is K True sage: while K.random_element().is_prime(): ....: pass sage: while not K.random_element().is_prime(): # long time ....: pass sage: K.<a> = NumberField(x^5 - 2) sage: p = K.random_element(integral_coefficients=True) sage: p.is_integral() True sage: while K.random_element().is_integral(): ....: pass
>>> from sage.all import * >>> x = polygen(ZZ, 'x') >>> K = NumberField(x**Integer(8) + Integer(1), names=('j',)); (j,) = K._first_ngens(1) >>> K.random_element().parent() is K True >>> while K.random_element().list()[Integer(0)] != Integer(0): ... pass >>> while K.random_element().list()[Integer(0)] == Integer(0): ... pass >>> while K.random_element().is_prime(): ... pass >>> while not K.random_element().is_prime(): ... pass >>> K = NumberField([x**Integer(2) - Integer(2), x**Integer(2) - Integer(3), x**Integer(2) - Integer(5)], names=('a', 'b', 'c',)); (a, b, c,) = K._first_ngens(3) >>> K.random_element().parent() is K True >>> while K.random_element().is_prime(): ... pass >>> while not K.random_element().is_prime(): # long time ... pass >>> K = NumberField(x**Integer(5) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> p = K.random_element(integral_coefficients=True) >>> p.is_integral() True >>> while K.random_element().is_integral(): ... pass
- real_embeddings(prec=53)[source]#
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. If you want embeddings into the 53-bit double precision, which is faster, useself.embeddings(RDF)
.Note
This function uses finite precision real numbers. In functions that should output proven results, one could use
self.embeddings(AA)
instead.EXAMPLES:
sage: x = polygen(QQ, 'x') 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 Field with 53 bits of precision Defn: a |--> -1.25992104989487 ] 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 ]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) + Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> K.real_embeddings() [ Ring morphism: From: Number Field in a with defining polynomial x^3 + 2 To: Real Field with 53 bits of precision Defn: a |--> -1.25992104989487 ] >>> K.real_embeddings(Integer(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 ] >>> K.real_embeddings(Integer(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 ]
As this is a numerical function, the number of embeddings may be incorrect if the precision is too low:
sage: K = NumberField(x^2 + 2*10^1000*x + 10^2000 + 1, 'a') sage: len(K.real_embeddings()) 2 sage: len(K.real_embeddings(100)) 2 sage: len(K.real_embeddings(10000)) 0 sage: len(K.embeddings(AA)) 0
>>> from sage.all import * >>> K = NumberField(x**Integer(2) + Integer(2)*Integer(10)**Integer(1000)*x + Integer(10)**Integer(2000) + Integer(1), 'a') >>> len(K.real_embeddings()) 2 >>> len(K.real_embeddings(Integer(100))) 2 >>> len(K.real_embeddings(Integer(10000))) 0 >>> len(K.embeddings(AA)) 0
- reduced_basis(prec=None)[source]#
Return an LLL-reduced basis for the Minkowski-embedding of the maximal order of a number field.
INPUT:
prec
(default:None
) – the precision with which to compute the Minkowski embedding.
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 pari: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.
EXAMPLES:
sage: x = polygen(QQ, 'x') 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: CyclotomicField(12).reduced_basis() [1, zeta12^2, zeta12, zeta12^3]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> F = NumberField(x**Integer(6) - Integer(7)*x**Integer(4) - x**Integer(3) + Integer(11)*x**Integer(2) + x - Integer(1), names=('t',)); (t,) = F._first_ngens(1) >>> 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] >>> 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] >>> CyclotomicField(Integer(12)).reduced_basis() [1, zeta12^2, zeta12, zeta12^3]
- reduced_gram_matrix(prec=None)[source]#
Return the Gram matrix of an LLL-reduced basis for the Minkowski embedding of the maximal order of a number field.
INPUT:
prec
(default:None
) – the precision with which to calculate the Minkowski embedding. (See NOTE below.)
OUTPUT: The Gram matrix \([\langle x_i,x_j \rangle]\) of an LLL reduced basis for the maximal order of
self
, where the integral basis forself
is given by \(\{x_0, \dots, x_{n-1}\}\). Here \(\langle , \rangle\) is the usual inner product on \(\RR^n\), andself
is embedded in \(\RR^n\) by the Minkowski embedding. See the docstring forNumberField_absolute.minkowski_embedding()
for more information.Note
In the non-totally-real case, the LLL routine we call is currently PARI’s pari: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
parameter above.If the following run-time error occurs: “PariError: not a definite matrix in lllgram (42)”, try increasing the
prec
parameter,EXAMPLES:
sage: x = polygen(QQ, 'x') 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 -2] [ 0 0 14 6 -2 3] [ 2 1 6 16 -3 3] [ 0 0 -2 -3 16 6] [ 1 -2 3 3 6 19] sage: Matrix(6, [(x*y).trace() ....: for x in F.integral_basis() for y in F.integral_basis()]) [2550 133 259 664 1368 3421] [ 133 14 3 54 30 233] [ 259 3 54 30 233 217] [ 664 54 30 233 217 1078] [1368 30 233 217 1078 1371] [3421 233 217 1078 1371 5224]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> F = NumberField(x**Integer(6) - Integer(7)*x**Integer(4) - x**Integer(3) + Integer(11)*x**Integer(2) + x - Integer(1), names=('t',)); (t,) = F._first_ngens(1) >>> F.reduced_gram_matrix() [ 6 3 0 2 0 1] [ 3 9 0 1 0 -2] [ 0 0 14 6 -2 3] [ 2 1 6 16 -3 3] [ 0 0 -2 -3 16 6] [ 1 -2 3 3 6 19] >>> Matrix(Integer(6), [(x*y).trace() ... for x in F.integral_basis() for y in F.integral_basis()]) [2550 133 259 664 1368 3421] [ 133 14 3 54 30 233] [ 259 3 54 30 233 217] [ 664 54 30 233 217 1078] [1368 30 233 217 1078 1371] [3421 233 217 1078 1371 5224]
sage: x = polygen(QQ) sage: F.<alpha> = NumberField(x^4 + x^2 + 712312*x + 131001238) sage: F.reduced_gram_matrix(prec=128) [ 4.0000000000000000000000000000000000000 0.00000000000000000000000000000000000000 -1.9999999999999999999999999999999999037 -0.99999999999999999999999999999999383702] [ 0.00000000000000000000000000000000000000 46721.539331563218381658483353092335550 -11488.910026551724275122749703614966768 -418.12718083977141198754424579680468382] [ -1.9999999999999999999999999999999999037 -11488.910026551724275122749703614966768 5.5658915310500611768713076521847709187e8 1.4179092271494070050433368847682152174e8] [ -0.99999999999999999999999999999999383702 -418.12718083977141198754424579680468382 1.4179092271494070050433368847682152174e8 1.3665897267919181137884111201405279175e12]
>>> from sage.all import * >>> x = polygen(QQ) >>> F = NumberField(x**Integer(4) + x**Integer(2) + Integer(712312)*x + Integer(131001238), names=('alpha',)); (alpha,) = F._first_ngens(1) >>> F.reduced_gram_matrix(prec=Integer(128)) [ 4.0000000000000000000000000000000000000 0.00000000000000000000000000000000000000 -1.9999999999999999999999999999999999037 -0.99999999999999999999999999999999383702] [ 0.00000000000000000000000000000000000000 46721.539331563218381658483353092335550 -11488.910026551724275122749703614966768 -418.12718083977141198754424579680468382] [ -1.9999999999999999999999999999999999037 -11488.910026551724275122749703614966768 5.5658915310500611768713076521847709187e8 1.4179092271494070050433368847682152174e8] [ -0.99999999999999999999999999999999383702 -418.12718083977141198754424579680468382 1.4179092271494070050433368847682152174e8 1.3665897267919181137884111201405279175e12]
- regulator(proof=None)[source]#
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.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: NumberField(x^2 - 2, 'a').regulator() 0.881373587019543 sage: NumberField(x^4 + x^3 + x^2 + x + 1, 'a').regulator() 0.962423650119207
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) - Integer(2), 'a').regulator() 0.881373587019543 >>> NumberField(x**Integer(4) + x**Integer(3) + x**Integer(2) + x + Integer(1), 'a').regulator() 0.962423650119207
- residue_field(prime, names=None, check=True)[source]#
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, or an element of the field which generates a principal prime ideal.names
– the name of the variable in the residue fieldcheck
– whether or not to check the primality ofprime
.
OUTPUT: The residue field at this prime.
EXAMPLES:
sage: R.<x> = QQ[] sage: K.<a> = NumberField(x^4 + 3*x^2 - 17) sage: P = K.ideal(61).factor()[0][0] sage: K.residue_field(P) Residue field in abar of Fractional ideal (61, a^2 + 30)
>>> from sage.all import * >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> K = NumberField(x**Integer(4) + Integer(3)*x**Integer(2) - Integer(17), names=('a',)); (a,) = K._first_ngens(1) >>> P = K.ideal(Integer(61)).factor()[Integer(0)][Integer(0)] >>> K.residue_field(P) Residue field in abar of Fractional ideal (61, a^2 + 30)
sage: K.<i> = NumberField(x^2 + 1) sage: K.residue_field(1+i) Residue field of Fractional ideal (i + 1)
>>> from sage.all import * >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.residue_field(Integer(1)+i) Residue field of Fractional ideal (i + 1)
- roots_of_unity()[source]#
Return all the roots of unity in this field, primitive or not.
EXAMPLES:
sage: x = polygen(QQ, 'x') 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]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('b',)); (b,) = K._first_ngens(1) >>> zs = K.roots_of_unity(); zs [b, -1, -b, 1] >>> [z**K.number_of_roots_of_unity() for z in zs] [1, 1, 1, 1]
- selmer_generators(S, m, proof=True, orders=False)[source]#
Compute generators of the group \(K(S,m)\).
INPUT:
S
– a set of primes ofself
m
– a positive integerproof
– ifFalse
, assume the GRH in computing the class grouporders
– (default:False
) ifTrue
, output two lists, the generators and their orders
OUTPUT:
A list of generators of \(K(S,m)\), and (optionally) their orders as elements of \(K^\times/(K^\times)^m\). This is the subgroup of \(K^\times/(K^\times)^m\) consisting of elements \(a\) such that the valuation of \(a\) is divisible by \(m\) at all primes not in \(S\). It fits in an exact sequence between the units modulo \(m\)-th powers and the \(m\)-torsion in the \(S\)-class group:
\[1 \longrightarrow O_{K,S}^\times / (O_{K,S}^\times)^m \longrightarrow K(S,m) \longrightarrow \operatorname{Cl}_{K,S}[m] \longrightarrow 0.\]The group \(K(S,m)\) contains the subgroup of those \(a\) such that \(K(\sqrt[m]{a})/K\) is unramified at all primes of \(K\) outside of \(S\), but may contain it properly when not all primes dividing \(m\) are in \(S\).
See also
NumberField_generic.selmer_space()
, which gives additional output when \(m=p\) is prime: as well as generators, it gives an abstract vector space over \(\GF{p}\) isomorphic to \(K(S,p)\) and maps implementing the isomorphism between this space and \(K(S,p)\) as a subgroup of \(K^*/(K^*)^p\).EXAMPLES:
sage: K.<a> = QuadraticField(-5) sage: K.selmer_generators((), 2) [-1, 2]
>>> from sage.all import * >>> K = QuadraticField(-Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> K.selmer_generators((), Integer(2)) [-1, 2]
The previous example shows that the group generated by the output may be strictly larger than the group of elements giving extensions unramified outside \(S\), since that has order just 2, generated by \(-1\):
sage: K.class_number() 2 sage: K.hilbert_class_field('b') Number Field in b with defining polynomial x^2 + 1 over its base field
>>> from sage.all import * >>> K.class_number() 2 >>> K.hilbert_class_field('b') Number Field in b with defining polynomial x^2 + 1 over its base field
When \(m\) is prime all the orders are equal to \(m\), but in general they are only divisors of \(m\):
sage: K.<a> = QuadraticField(-5) sage: P2 = K.ideal(2, -a + 1) sage: P3 = K.ideal(3, a + 1) sage: K.selmer_generators((), 2, orders=True) ([-1, 2], [2, 2]) sage: K.selmer_generators((), 4, orders=True) ([-1, 4], [2, 2]) sage: K.selmer_generators([P2], 2) [2, -1] sage: K.selmer_generators((P2,P3), 4) [2, -a - 1, -1] sage: K.selmer_generators((P2,P3), 4, orders=True) ([2, -a - 1, -1], [4, 4, 2]) sage: K.selmer_generators([P2], 3) [2] sage: K.selmer_generators([P2, P3], 3) [2, -a - 1] sage: K.selmer_generators([P2, P3, K.ideal(a)], 3) # random signs [2, a + 1, a]
>>> from sage.all import * >>> K = QuadraticField(-Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> P2 = K.ideal(Integer(2), -a + Integer(1)) >>> P3 = K.ideal(Integer(3), a + Integer(1)) >>> K.selmer_generators((), Integer(2), orders=True) ([-1, 2], [2, 2]) >>> K.selmer_generators((), Integer(4), orders=True) ([-1, 4], [2, 2]) >>> K.selmer_generators([P2], Integer(2)) [2, -1] >>> K.selmer_generators((P2,P3), Integer(4)) [2, -a - 1, -1] >>> K.selmer_generators((P2,P3), Integer(4), orders=True) ([2, -a - 1, -1], [4, 4, 2]) >>> K.selmer_generators([P2], Integer(3)) [2] >>> K.selmer_generators([P2, P3], Integer(3)) [2, -a - 1] >>> K.selmer_generators([P2, P3, K.ideal(a)], Integer(3)) # random signs [2, a + 1, a]
Example over \(\QQ\) (as a number field):
sage: K.<a> = NumberField(polygen(QQ)) sage: K.selmer_generators([],5) [] sage: K.selmer_generators([K.prime_above(p) for p in [2,3,5]],2) [2, 3, 5, -1] sage: K.selmer_generators([K.prime_above(p) for p in [2,3,5]],6, orders=True) ([2, 3, 5, -1], [6, 6, 6, 2])
>>> from sage.all import * >>> K = NumberField(polygen(QQ), names=('a',)); (a,) = K._first_ngens(1) >>> K.selmer_generators([],Integer(5)) [] >>> K.selmer_generators([K.prime_above(p) for p in [Integer(2),Integer(3),Integer(5)]],Integer(2)) [2, 3, 5, -1] >>> K.selmer_generators([K.prime_above(p) for p in [Integer(2),Integer(3),Integer(5)]],Integer(6), orders=True) ([2, 3, 5, -1], [6, 6, 6, 2])
- selmer_group_iterator(S, m, proof=True)[source]#
Return an iterator through elements of the finite group \(K(S,m)\).
INPUT:
S
– a set of primes ofself
m
– a positive integerproof
– ifFalse
, assume the GRH in computing the class group
OUTPUT:
An iterator yielding the distinct elements of \(K(S,m)\). See the docstring for
NumberField_generic.selmer_generators()
for more information.EXAMPLES:
sage: K.<a> = QuadraticField(-5) sage: list(K.selmer_group_iterator((), 2)) [1, 2, -1, -2] sage: list(K.selmer_group_iterator((), 4)) [1, 4, -1, -4] sage: list(K.selmer_group_iterator([K.ideal(2, -a + 1)], 2)) [1, -1, 2, -2] sage: list(K.selmer_group_iterator([K.ideal(2, -a + 1), K.ideal(3, a + 1)], 2)) [1, -1, -a - 1, a + 1, 2, -2, -2*a - 2, 2*a + 2]
>>> from sage.all import * >>> K = QuadraticField(-Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> list(K.selmer_group_iterator((), Integer(2))) [1, 2, -1, -2] >>> list(K.selmer_group_iterator((), Integer(4))) [1, 4, -1, -4] >>> list(K.selmer_group_iterator([K.ideal(Integer(2), -a + Integer(1))], Integer(2))) [1, -1, 2, -2] >>> list(K.selmer_group_iterator([K.ideal(Integer(2), -a + Integer(1)), K.ideal(Integer(3), a + Integer(1))], Integer(2))) [1, -1, -a - 1, a + 1, 2, -2, -2*a - 2, 2*a + 2]
Examples over \(\QQ\) (as a number field):
sage: K.<a> = NumberField(polygen(QQ)) sage: list(K.selmer_group_iterator([], 5)) [1] sage: list(K.selmer_group_iterator([], 4)) [1, -1] sage: list(K.selmer_group_iterator([K.prime_above(p) for p in [11,13]],2)) [1, -1, 13, -13, 11, -11, 143, -143]
>>> from sage.all import * >>> K = NumberField(polygen(QQ), names=('a',)); (a,) = K._first_ngens(1) >>> list(K.selmer_group_iterator([], Integer(5))) [1] >>> list(K.selmer_group_iterator([], Integer(4))) [1, -1] >>> list(K.selmer_group_iterator([K.prime_above(p) for p in [Integer(11),Integer(13)]],Integer(2))) [1, -1, 13, -13, 11, -11, 143, -143]
- selmer_space(S, p, proof=None)[source]#
Compute the group \(K(S,p)\) as a vector space with maps to and from \(K^*\).
INPUT:
S
– a set of primes ideals ofself
p
– a prime numberproof
– if False, assume the GRH in computing the class group
OUTPUT:
(tuple)
KSp
,KSp_gens
,from_KSp
,to_KSp
whereKSp
is an abstract vector space over \(GF(p)\) isomorphic to \(K(S,p)\);KSp_gens
is a list of elements of \(K^*\) generating \(K(S,p)\);from_KSp
is a function fromKSp
to \(K^*\) implementing the isomorphism from the abstract \(K(S,p)\) to \(K(S,p)\) as a subgroup of \(K^*/(K^*)^p\);to_KSP
is a partial function from \(K^*\) toKSp
, defined on elements \(a\) whose image in \(K^*/(K^*)^p\) lies in \(K(S,p)\), mapping them via the inverse isomorphism to the abstract vector spaceKSp
.
The group \(K(S,p)\) is the finite subgroup of \(K^*/(K^*)^p\) consisting of elements whose valuation at all primes not in \(S\) is a multiple of \(p\). It contains the subgroup of those \(a\in K^*\) such that \(K(\sqrt[p]{a})/K\) is unramified at all primes of \(K\) outside of \(S\), but may contain it properly when not all primes dividing \(p\) are in \(S\).
EXAMPLES:
A real quadratic field with class number 2, where the fundamental unit is a generator, and the class group provides another generator when \(p=2\):
sage: K.<a> = QuadraticField(-5) sage: K.class_number() 2 sage: P2 = K.ideal(2, -a + 1) sage: P3 = K.ideal(3, a + 1) sage: P5 = K.ideal(a) sage: KS2, gens, fromKS2, toKS2 = K.selmer_space([P2, P3, P5], 2) sage: KS2 Vector space of dimension 4 over Finite Field of size 2 sage: gens [a + 1, a, 2, -1]
>>> from sage.all import * >>> K = QuadraticField(-Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> K.class_number() 2 >>> P2 = K.ideal(Integer(2), -a + Integer(1)) >>> P3 = K.ideal(Integer(3), a + Integer(1)) >>> P5 = K.ideal(a) >>> KS2, gens, fromKS2, toKS2 = K.selmer_space([P2, P3, P5], Integer(2)) >>> KS2 Vector space of dimension 4 over Finite Field of size 2 >>> gens [a + 1, a, 2, -1]
Each generator must have even valuation at primes not in \(S\):
sage: [K.ideal(g).factor() for g in gens] [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)), Fractional ideal (a), (Fractional ideal (2, a + 1))^2, 1] sage: toKS2(10) (0, 0, 1, 1) sage: fromKS2([0,0,1,1]) -2 sage: K(10/(-2)).is_square() True sage: KS3, gens, fromKS3, toKS3 = K.selmer_space([P2, P3, P5], 3) sage: KS3 Vector space of dimension 3 over Finite Field of size 3 sage: gens [1/2, 1/4*a + 1/4, a]
>>> from sage.all import * >>> [K.ideal(g).factor() for g in gens] [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)), Fractional ideal (a), (Fractional ideal (2, a + 1))^2, 1] >>> toKS2(Integer(10)) (0, 0, 1, 1) >>> fromKS2([Integer(0),Integer(0),Integer(1),Integer(1)]) -2 >>> K(Integer(10)/(-Integer(2))).is_square() True >>> KS3, gens, fromKS3, toKS3 = K.selmer_space([P2, P3, P5], Integer(3)) >>> KS3 Vector space of dimension 3 over Finite Field of size 3 >>> gens [1/2, 1/4*a + 1/4, a]
An example to show that the group \(K(S,2)\) may be strictly larger than the group of elements giving extensions unramified outside \(S\). In this case, with \(K\) of class number \(2\) and \(S\) empty, there is only one quadratic extension of \(K\) unramified outside \(S\), the Hilbert Class Field \(K(\sqrt{-1})\):
sage: K.<a> = QuadraticField(-5) sage: KS2, gens, fromKS2, toKS2 = K.selmer_space([], 2) sage: KS2 Vector space of dimension 2 over Finite Field of size 2 sage: gens [2, -1] sage: x = polygen(ZZ, 'x') sage: for v in KS2: ....: if not v: ....: continue ....: a = fromKS2(v) ....: print((a, K.extension(x^2 - a, 'roota').relative_discriminant().factor())) (2, (Fractional ideal (2, a + 1))^4) (-1, 1) (-2, (Fractional ideal (2, a + 1))^4) sage: K.hilbert_class_field('b') Number Field in b with defining polynomial x^2 + 1 over its base field
>>> from sage.all import * >>> K = QuadraticField(-Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> KS2, gens, fromKS2, toKS2 = K.selmer_space([], Integer(2)) >>> KS2 Vector space of dimension 2 over Finite Field of size 2 >>> gens [2, -1] >>> x = polygen(ZZ, 'x') >>> for v in KS2: ... if not v: ... continue ... a = fromKS2(v) ... print((a, K.extension(x**Integer(2) - a, 'roota').relative_discriminant().factor())) (2, (Fractional ideal (2, a + 1))^4) (-1, 1) (-2, (Fractional ideal (2, a + 1))^4) >>> K.hilbert_class_field('b') Number Field in b with defining polynomial x^2 + 1 over its base field
- signature()[source]#
Return \((r_1, r_2)\), where \(r_1\) and \(r_2\) are the number of real embeddings and pairs of complex embeddings of this field, respectively.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: NumberField(x^2 + 1, 'a').signature() (0, 1) sage: NumberField(x^3 - 2, 'a').signature() (1, 1)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) + Integer(1), 'a').signature() (0, 1) >>> NumberField(x**Integer(3) - Integer(2), 'a').signature() (1, 1)
- solve_CRT(reslist, Ilist, check=True)[source]#
Solve a Chinese remainder problem over this number field.
INPUT:
reslist
– a list of residues, i.e. integral number field elementsIlist
– a list of integral ideals, assumed pairwise coprimecheck
– (boolean, defaultTrue
) ifTrue
, result is checked
OUTPUT:
An integral element \(x\) such that
x - reslist[i]
is inIlist[i]
for all \(i\).Note
The current implementation requires the ideals to be pairwise coprime. A more general version would be possible.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^2 - 10) sage: Ilist = [K.primes_above(p)[0] for p in prime_range(10)] sage: b = K.solve_CRT([1,2,3,4], Ilist, True) sage: all(b - i - 1 in Ilist[i] for i in range(4)) True sage: Ilist = [K.ideal(a), K.ideal(2)] sage: K.solve_CRT([0,1], Ilist, True) Traceback (most recent call last): ... ArithmeticError: ideals in solve_CRT() must be pairwise coprime sage: Ilist[0] + Ilist[1] Fractional ideal (2, a)
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) - Integer(10), names=('a',)); (a,) = K._first_ngens(1) >>> Ilist = [K.primes_above(p)[Integer(0)] for p in prime_range(Integer(10))] >>> b = K.solve_CRT([Integer(1),Integer(2),Integer(3),Integer(4)], Ilist, True) >>> all(b - i - Integer(1) in Ilist[i] for i in range(Integer(4))) True >>> Ilist = [K.ideal(a), K.ideal(Integer(2))] >>> K.solve_CRT([Integer(0),Integer(1)], Ilist, True) Traceback (most recent call last): ... ArithmeticError: ideals in solve_CRT() must be pairwise coprime >>> Ilist[Integer(0)] + Ilist[Integer(1)] Fractional ideal (2, a)
- some_elements()[source]#
Return a list of elements in the given number field.
EXAMPLES:
sage: R.<t> = QQ[] sage: K.<a> = QQ.extension(t^2 - 2); K Number Field in a with defining polynomial t^2 - 2 sage: K.some_elements() [1, a, 2*a, 3*a - 4, 1/2, 1/3*a, 1/6*a, 0, 1/2*a, 2, ..., 12, -12*a + 18] sage: T.<u> = K[] sage: M.<b> = K.extension(t^3 - 5); M Number Field in b with defining polynomial t^3 - 5 over its base field sage: M.some_elements() [1, b, 1/2*a*b, ..., 2/5*b^2 + 2/5, 1/6*b^2 + 5/6*b + 13/6, 2]
>>> from sage.all import * >>> R = QQ['t']; (t,) = R._first_ngens(1) >>> K = QQ.extension(t**Integer(2) - Integer(2), names=('a',)); (a,) = K._first_ngens(1); K Number Field in a with defining polynomial t^2 - 2 >>> K.some_elements() [1, a, 2*a, 3*a - 4, 1/2, 1/3*a, 1/6*a, 0, 1/2*a, 2, ..., 12, -12*a + 18] >>> T = K['u']; (u,) = T._first_ngens(1) >>> M = K.extension(t**Integer(3) - Integer(5), names=('b',)); (b,) = M._first_ngens(1); M Number Field in b with defining polynomial t^3 - 5 over its base field >>> M.some_elements() [1, b, 1/2*a*b, ..., 2/5*b^2 + 2/5, 1/6*b^2 + 5/6*b + 13/6, 2]
- specified_complex_embedding()[source]#
Return the embedding of this field into the complex numbers which has been specified.
Fields created with the
QuadraticField()
orCyclotomicField()
constructors come with an implicit embedding. To get one of these fields without the embedding, use the genericNumberField
constructor.EXAMPLES:
sage: QuadraticField(-1, 'I').specified_complex_embedding() Generic morphism: From: Number Field in I with defining polynomial x^2 + 1 with I = 1*I To: Complex Lazy Field Defn: I -> 1*I
>>> from sage.all import * >>> QuadraticField(-Integer(1), 'I').specified_complex_embedding() Generic morphism: From: Number Field in I with defining polynomial x^2 + 1 with I = 1*I To: Complex Lazy Field Defn: I -> 1*I
sage: QuadraticField(3, 'a').specified_complex_embedding() Generic morphism: From: Number Field in a with defining polynomial x^2 - 3 with a = 1.732050807568878? To: Real Lazy Field Defn: a -> 1.732050807568878?
>>> from sage.all import * >>> QuadraticField(Integer(3), 'a').specified_complex_embedding() Generic morphism: From: Number Field in a with defining polynomial x^2 - 3 with a = 1.732050807568878? To: Real Lazy Field Defn: a -> 1.732050807568878?
sage: CyclotomicField(13).specified_complex_embedding() Generic morphism: From: Cyclotomic Field of order 13 and degree 12 To: Complex Lazy Field Defn: zeta13 -> 0.885456025653210? + 0.464723172043769?*I
>>> from sage.all import * >>> CyclotomicField(Integer(13)).specified_complex_embedding() Generic morphism: From: Cyclotomic Field of order 13 and degree 12 To: Complex Lazy Field Defn: zeta13 -> 0.885456025653210? + 0.464723172043769?*I
Most fields don’t implicitly have embeddings unless explicitly specified:
sage: x = polygen(QQ, 'x') sage: NumberField(x^2 - 2, 'a').specified_complex_embedding() is None True sage: NumberField(x^3 - x + 5, 'a').specified_complex_embedding() is None True sage: NumberField(x^3 - x + 5, 'a', embedding=2).specified_complex_embedding() Generic morphism: From: Number Field in a with defining polynomial x^3 - x + 5 with a = -1.904160859134921? To: Real Lazy Field Defn: a -> -1.904160859134921? sage: NumberField(x^3 - x + 5, 'a', embedding=CDF.0).specified_complex_embedding() Generic morphism: From: Number Field in a with defining polynomial x^3 - x + 5 with a = 0.952080429567461? + 1.311248044077123?*I To: Complex Lazy Field Defn: a -> 0.952080429567461? + 1.311248044077123?*I
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> NumberField(x**Integer(2) - Integer(2), 'a').specified_complex_embedding() is None True >>> NumberField(x**Integer(3) - x + Integer(5), 'a').specified_complex_embedding() is None True >>> NumberField(x**Integer(3) - x + Integer(5), 'a', embedding=Integer(2)).specified_complex_embedding() Generic morphism: From: Number Field in a with defining polynomial x^3 - x + 5 with a = -1.904160859134921? To: Real Lazy Field Defn: a -> -1.904160859134921? >>> NumberField(x**Integer(3) - x + Integer(5), 'a', embedding=CDF.gen(0)).specified_complex_embedding() Generic morphism: From: Number Field in a with defining polynomial x^3 - x + 5 with a = 0.952080429567461? + 1.311248044077123?*I To: Complex Lazy Field Defn: a -> 0.952080429567461? + 1.311248044077123?*I
This function only returns complex embeddings:
sage: # needs sage.rings.padics sage: K.<a> = NumberField(x^2 - 2, embedding=Qp(7)(2).sqrt()) sage: K.specified_complex_embedding() is None True sage: K.gen_embedding() 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 + 6*7^9 + 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 + 7^17 + 4*7^18 + 6*7^19 + O(7^20) sage: K.coerce_embedding() Generic morphism: From: Number Field in a with defining polynomial x^2 - 2 with a = 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 + 6*7^9 + 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 + 7^17 + 4*7^18 + 6*7^19 + O(7^20) To: 7-adic Field with capped relative precision 20 Defn: a -> 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 + 6*7^9 + 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 + 7^17 + 4*7^18 + 6*7^19 + O(7^20)
>>> from sage.all import * >>> # needs sage.rings.padics >>> K = NumberField(x**Integer(2) - Integer(2), embedding=Qp(Integer(7))(Integer(2)).sqrt(), names=('a',)); (a,) = K._first_ngens(1) >>> K.specified_complex_embedding() is None True >>> K.gen_embedding() 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 + 6*7^9 + 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 + 7^17 + 4*7^18 + 6*7^19 + O(7^20) >>> K.coerce_embedding() Generic morphism: From: Number Field in a with defining polynomial x^2 - 2 with a = 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 + 6*7^9 + 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 + 7^17 + 4*7^18 + 6*7^19 + O(7^20) To: 7-adic Field with capped relative precision 20 Defn: a -> 3 + 7 + 2*7^2 + 6*7^3 + 7^4 + 2*7^5 + 7^6 + 2*7^7 + 4*7^8 + 6*7^9 + 6*7^10 + 2*7^11 + 7^12 + 7^13 + 2*7^15 + 7^16 + 7^17 + 4*7^18 + 6*7^19 + O(7^20)
- structure()[source]#
Return fixed isomorphism or embedding structure on
self
.This is used to record various isomorphisms or embeddings that arise naturally in other constructions.
EXAMPLES:
sage: x = polygen(ZZ, 'x') 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() (Isomorphism given by variable name change map: From: Number Field in a with defining polynomial x^2 + 3 To: Number Field in z with defining polynomial x^2 + 3, Isomorphism given by variable name change map: From: Number Field in z with defining polynomial x^2 + 3 To: Number Field in a with defining polynomial x^2 + 3) sage: K.<a> = QuadraticField(-3) sage: R.<y> = K[] sage: D.<x0> = K.extension(y) sage: D_abs.<y0> = D.absolute_field() sage: D_abs.structure()[0](y0) -a
>>> from sage.all import * >>> x = polygen(ZZ, 'x') >>> K = NumberField(x**Integer(2) + Integer(3), names=('z',)); (z,) = K._first_ngens(1) >>> L = K.absolute_field(names=('a',)); (a,) = L._first_ngens(1); L Number Field in a with defining polynomial x^2 + 3 >>> L.structure() (Isomorphism given by variable name change map: From: Number Field in a with defining polynomial x^2 + 3 To: Number Field in z with defining polynomial x^2 + 3, Isomorphism given by variable name change map: From: Number Field in z with defining polynomial x^2 + 3 To: Number Field in a with defining polynomial x^2 + 3) >>> K = QuadraticField(-Integer(3), names=('a',)); (a,) = K._first_ngens(1) >>> R = K['y']; (y,) = R._first_ngens(1) >>> D = K.extension(y, names=('x0',)); (x0,) = D._first_ngens(1) >>> D_abs = D.absolute_field(names=('y0',)); (y0,) = D_abs._first_ngens(1) >>> D_abs.structure()[Integer(0)](y0) -a
- subfield(alpha, name=None, names=None)[source]#
Return a number field \(K\) isomorphic to \(\QQ(\alpha)\) (if this is an absolute number field) or \(L(\alpha)\) (if this is a relative extension \(M/L\)) and a map from \(K\) to
self
that sends the generator of \(K\) toalpha
.INPUT:
alpha
– an element ofself
, or something that coerces to an element ofself
.
OUTPUT:
K
– a number fieldfrom_K
– a homomorphism from \(K\) toself
that sends the generator of \(K\) toalpha
.
EXAMPLES:
sage: x = polygen(ZZ, 'x') sage: K.<a> = NumberField(x^4 - 3); K Number Field in a with defining polynomial x^4 - 3 sage: H.<b>, from_H = K.subfield(a^2) sage: H Number Field in b with defining polynomial x^2 - 3 with b = a^2 sage: from_H(b) a^2 sage: from_H Ring morphism: From: Number Field in b with defining polynomial x^2 - 3 with b = a^2 To: Number Field in a with defining polynomial x^4 - 3 Defn: b |--> a^2
>>> from sage.all import * >>> x = polygen(ZZ, 'x') >>> K = NumberField(x**Integer(4) - Integer(3), names=('a',)); (a,) = K._first_ngens(1); K Number Field in a with defining polynomial x^4 - 3 >>> H, from_H = K.subfield(a**Integer(2), names=('b',)); (b,) = H._first_ngens(1) >>> H Number Field in b with defining polynomial x^2 - 3 with b = a^2 >>> from_H(b) a^2 >>> from_H Ring morphism: From: Number Field in b with defining polynomial x^2 - 3 with b = a^2 To: Number Field in a with defining polynomial x^4 - 3 Defn: b |--> a^2
A relative example. Note that the result returned is the subfield generated by \(\alpha\) over
self.base_field()
, not over \(\QQ\) (see Issue #5392):sage: L.<a> = NumberField(x^2 - 3) sage: M.<b> = L.extension(x^4 + 1) sage: K, phi = M.subfield(b^2) sage: K.base_field() is L True
>>> from sage.all import * >>> L = NumberField(x**Integer(2) - Integer(3), names=('a',)); (a,) = L._first_ngens(1) >>> M = L.extension(x**Integer(4) + Integer(1), names=('b',)); (b,) = M._first_ngens(1) >>> K, phi = M.subfield(b**Integer(2)) >>> K.base_field() is L True
Subfields inherit embeddings:
sage: K.<z> = CyclotomicField(5) sage: L, K_from_L = K.subfield(z - z^2 - z^3 + z^4) sage: L Number Field in z0 with defining polynomial x^2 - 5 with z0 = 2.236067977499790? sage: CLF_from_K = K.coerce_embedding(); CLF_from_K Generic morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Lazy Field Defn: z -> 0.309016994374948? + 0.951056516295154?*I sage: CLF_from_L = L.coerce_embedding(); CLF_from_L Generic morphism: From: Number Field in z0 with defining polynomial x^2 - 5 with z0 = 2.236067977499790? To: Complex Lazy Field Defn: z0 -> 2.236067977499790?
>>> from sage.all import * >>> K = CyclotomicField(Integer(5), names=('z',)); (z,) = K._first_ngens(1) >>> L, K_from_L = K.subfield(z - z**Integer(2) - z**Integer(3) + z**Integer(4)) >>> L Number Field in z0 with defining polynomial x^2 - 5 with z0 = 2.236067977499790? >>> CLF_from_K = K.coerce_embedding(); CLF_from_K Generic morphism: From: Cyclotomic Field of order 5 and degree 4 To: Complex Lazy Field Defn: z -> 0.309016994374948? + 0.951056516295154?*I >>> CLF_from_L = L.coerce_embedding(); CLF_from_L Generic morphism: From: Number Field in z0 with defining polynomial x^2 - 5 with z0 = 2.236067977499790? To: Complex Lazy Field Defn: z0 -> 2.236067977499790?
Check transitivity:
sage: CLF_from_L(L.gen()) 2.236067977499790? sage: CLF_from_K(K_from_L(L.gen())) 2.23606797749979? + 0.?e-14*I
>>> from sage.all import * >>> CLF_from_L(L.gen()) 2.236067977499790? >>> CLF_from_K(K_from_L(L.gen())) 2.23606797749979? + 0.?e-14*I
If
self
has no specified embedding, then \(K\) comes with an embedding inself
:sage: K.<a> = NumberField(x^6 - 6*x^4 + 8*x^2 - 1) sage: L.<b>, from_L = K.subfield(a^2) sage: L Number Field in b with defining polynomial x^3 - 6*x^2 + 8*x - 1 with b = a^2 sage: L.gen_embedding() a^2
>>> from sage.all import * >>> K = NumberField(x**Integer(6) - Integer(6)*x**Integer(4) + Integer(8)*x**Integer(2) - Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> L, from_L = K.subfield(a**Integer(2), names=('b',)); (b,) = L._first_ngens(1) >>> L Number Field in b with defining polynomial x^3 - 6*x^2 + 8*x - 1 with b = a^2 >>> L.gen_embedding() a^2
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
change_generator()
, which gives isomorphisms in both directions.
- subfield_from_elements(alpha, name=None, polred=True, threshold=None)[source]#
Return the subfield generated by the elements
alpha
.If the generated subfield by the elements
alpha
is either the rational field or the complete number field, the field returned is respectivelyQQ
orself
.INPUT:
alpha
– list of elements in this number fieldname
– a name for the generator of the new number fieldpolred
– (boolean, defaultTrue
); whether to optimize the generator of the newly created fieldthreshold
– (positive number, defaultNone
) threshold to be passed to thedo_polred
function
OUTPUT: a triple
(field, beta, hom)
wherefield
– a subfield of this number fieldbeta
– a list of elements offield
corresponding toalpha
hom
– inclusion homomorphism fromfield
toself
EXAMPLES:
sage: x = polygen(QQ) sage: poly = x^4 - 4*x^2 + 1 sage: emb = AA.polynomial_root(poly, RIF(0.51, 0.52)) sage: K.<a> = NumberField(poly, embedding=emb) sage: sqrt2 = -a^3 + 3*a sage: sqrt3 = -a^2 + 2 sage: assert sqrt2 ** 2 == 2 and sqrt3 ** 2 == 3 sage: L, elts, phi = K.subfield_from_elements([sqrt2, 1 - sqrt2/3]) sage: L Number Field in a0 with defining polynomial x^2 - 2 with a0 = 1.414213562373095? sage: elts [a0, -1/3*a0 + 1] sage: phi Ring morphism: From: Number Field in a0 with defining polynomial x^2 - 2 with a0 = 1.414213562373095? To: Number Field in a with defining polynomial x^4 - 4*x^2 + 1 with a = 0.5176380902050415? Defn: a0 |--> -a^3 + 3*a sage: assert phi(elts[0]) == sqrt2 sage: assert phi(elts[1]) == 1 - sqrt2/3 sage: L, elts, phi = K.subfield_from_elements([1, sqrt3]) sage: assert phi(elts[0]) == 1 sage: assert phi(elts[1]) == sqrt3 sage: L, elts, phi = K.subfield_from_elements([sqrt2, sqrt3]) sage: phi Identity endomorphism of Number Field in a with defining polynomial x^4 - 4*x^2 + 1 with a = 0.5176380902050415?
>>> from sage.all import * >>> x = polygen(QQ) >>> poly = x**Integer(4) - Integer(4)*x**Integer(2) + Integer(1) >>> emb = AA.polynomial_root(poly, RIF(RealNumber('0.51'), RealNumber('0.52'))) >>> K = NumberField(poly, embedding=emb, names=('a',)); (a,) = K._first_ngens(1) >>> sqrt2 = -a**Integer(3) + Integer(3)*a >>> sqrt3 = -a**Integer(2) + Integer(2) >>> assert sqrt2 ** Integer(2) == Integer(2) and sqrt3 ** Integer(2) == Integer(3) >>> L, elts, phi = K.subfield_from_elements([sqrt2, Integer(1) - sqrt2/Integer(3)]) >>> L Number Field in a0 with defining polynomial x^2 - 2 with a0 = 1.414213562373095? >>> elts [a0, -1/3*a0 + 1] >>> phi Ring morphism: From: Number Field in a0 with defining polynomial x^2 - 2 with a0 = 1.414213562373095? To: Number Field in a with defining polynomial x^4 - 4*x^2 + 1 with a = 0.5176380902050415? Defn: a0 |--> -a^3 + 3*a >>> assert phi(elts[Integer(0)]) == sqrt2 >>> assert phi(elts[Integer(1)]) == Integer(1) - sqrt2/Integer(3) >>> L, elts, phi = K.subfield_from_elements([Integer(1), sqrt3]) >>> assert phi(elts[Integer(0)]) == Integer(1) >>> assert phi(elts[Integer(1)]) == sqrt3 >>> L, elts, phi = K.subfield_from_elements([sqrt2, sqrt3]) >>> phi Identity endomorphism of Number Field in a with defining polynomial x^4 - 4*x^2 + 1 with a = 0.5176380902050415?
- trace_dual_basis(b)[source]#
Compute the dual basis of a basis of
self
with respect to the trace pairing.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^3 + x + 1) sage: b = [1, 2*a, 3*a^2] sage: T = K.trace_dual_basis(b); T [4/31*a^2 - 6/31*a + 13/31, -9/62*a^2 - 1/31*a - 3/31, 2/31*a^2 - 3/31*a + 4/93] sage: [(b[i]*T[j]).trace() for i in range(3) for j in range(3)] [1, 0, 0, 0, 1, 0, 0, 0, 1]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) + x + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> b = [Integer(1), Integer(2)*a, Integer(3)*a**Integer(2)] >>> T = K.trace_dual_basis(b); T [4/31*a^2 - 6/31*a + 13/31, -9/62*a^2 - 1/31*a - 3/31, 2/31*a^2 - 3/31*a + 4/93] >>> [(b[i]*T[j]).trace() for i in range(Integer(3)) for j in range(Integer(3))] [1, 0, 0, 0, 1, 0, 0, 0, 1]
- trace_pairing(v)[source]#
Return the matrix of the trace pairing on the elements of the list
v
.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<zeta3> = NumberField(x^2 + 3) sage: K.trace_pairing([1, zeta3]) [ 2 0] [ 0 -6]
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(3), names=('zeta3',)); (zeta3,) = K._first_ngens(1) >>> K.trace_pairing([Integer(1), zeta3]) [ 2 0] [ 0 -6]
- uniformizer(P, others='positive')[source]#
Return an element of
self
with valuation 1 at the prime ideal \(P\).INPUT:
self
– a number fieldP
– a prime ideal ofself
others
– either"positive"
(default), in which case the element will have non-negative valuation at all other primes ofself
, or"negative"
, in which case the element will have non-positive valuation at all other primes ofself
.
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\)!EXAMPLES:
sage: x = polygen(QQ, 'x') 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))
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(5), names=('a',)); (a,) = K._first_ngens(1); K Number Field in a with defining polynomial x^2 + 5 >>> P, Q = K.ideal(Integer(3)).prime_factors() >>> P Fractional ideal (3, a + 1) >>> pi = K.uniformizer(P); pi a + 1 >>> K.ideal(pi).factor() (Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)) >>> pi = K.uniformizer(P,'negative'); pi 1/2*a + 1/2 >>> 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]
>>> from sage.all import * >>> K = CyclotomicField(Integer(9)) >>> Plist = K.ideal(Integer(17)).prime_factors() >>> pilist = [K.uniformizer(P) for P in Plist] >>> [pi.is_integral() for pi in pilist] [True, True, True] >>> [pi.valuation(P) for pi, P in zip(pilist, Plist)] [1, 1, 1] >>> [ pilist[i] in Plist[i] for i in range(len(Plist)) ] [True, True, True]
sage: K.<t> = NumberField(x^4 - x^3 - 3*x^2 - x + 1) sage: [K.uniformizer(P) for P,e in factor(K.ideal(2))] [2] sage: [K.uniformizer(P) for P,e in factor(K.ideal(3))] [t - 1] sage: [K.uniformizer(P) for P,e in factor(K.ideal(5))] [t^2 - t + 1, t + 2, t - 2] sage: [K.uniformizer(P) for P,e in factor(K.ideal(7))] # representation varies, not tested [t^2 + 3*t + 1] sage: [K.uniformizer(P) for P,e in factor(K.ideal(67))] [t + 23, t + 26, t - 32, t - 18]
>>> from sage.all import * >>> K = NumberField(x**Integer(4) - x**Integer(3) - Integer(3)*x**Integer(2) - x + Integer(1), names=('t',)); (t,) = K._first_ngens(1) >>> [K.uniformizer(P) for P,e in factor(K.ideal(Integer(2)))] [2] >>> [K.uniformizer(P) for P,e in factor(K.ideal(Integer(3)))] [t - 1] >>> [K.uniformizer(P) for P,e in factor(K.ideal(Integer(5)))] [t^2 - t + 1, t + 2, t - 2] >>> [K.uniformizer(P) for P,e in factor(K.ideal(Integer(7)))] # representation varies, not tested [t^2 + 3*t + 1] >>> [K.uniformizer(P) for P,e in factor(K.ideal(Integer(67)))] [t + 23, t + 26, t - 32, t - 18]
ALGORITHM:
Use PARI. More precisely, use the second component of pari:idealprimedec in the “positive” case. Use pari:idealappr with exponent of \(-1\) and invert the result in the “negative” case.
- unit_group(proof=None)[source]#
Return the unit group (including torsion) of this number field.
ALGORITHM: Uses PARI’s pari:bnfinit command.
INPUT:
proof
(bool, defaultTrue
) flag passed to PARI.
Note
The group is cached.
See also
EXAMPLES:
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: U = K.unit_group(); U Unit group with structure C10 x Z of Number Field in a with defining polynomial x^4 - 10*x^3 + 100*x^2 - 375*x + 1375 sage: U.gens() (u0, u1) sage: U.gens_values() # random [-1/275*a^3 + 7/55*a^2 - 6/11*a + 4, 1/275*a^3 + 4/55*a^2 - 5/11*a + 3] sage: U.invariants() (10, 0) sage: [u.multiplicative_order() for u in U.gens()] [10, +Infinity]
>>> from sage.all import * >>> x = QQ['x'].gen(0) >>> A = x**Integer(4) - Integer(10)*x**Integer(3) + Integer(20)*Integer(5)*x**Integer(2) - Integer(15)*Integer(5)**Integer(2)*x + Integer(11)*Integer(5)**Integer(3) >>> K = NumberField(A, 'a') >>> U = K.unit_group(); U Unit group with structure C10 x Z of Number Field in a with defining polynomial x^4 - 10*x^3 + 100*x^2 - 375*x + 1375 >>> U.gens() (u0, u1) >>> U.gens_values() # random [-1/275*a^3 + 7/55*a^2 - 6/11*a + 4, 1/275*a^3 + 4/55*a^2 - 5/11*a + 3] >>> U.invariants() (10, 0) >>> [u.multiplicative_order() for u in U.gens()] [10, +Infinity]
For big number fields, provably computing the unit group can take a very long time. In this case, one can ask for the conjectural unit group (correct if the Generalized Riemann Hypothesis is true):
sage: K = NumberField(x^17 + 3, 'a') sage: K.unit_group(proof=True) # takes forever, not tested ... sage: U = K.unit_group(proof=False) sage: U Unit group with structure C2 x Z x Z x Z x Z x Z x Z x Z x Z of Number Field in a with defining polynomial x^17 + 3 sage: U.gens() (u0, u1, u2, u3, u4, u5, u6, u7, u8) sage: U.gens_values() # result not independently verified [-1, -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, 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, -a^16 - a^15 - a^14 - a^13 - a^12 - a^11 - a^10 - a^9 - a^8 - a^7 - a^6 - a^5 - a^4 - a^3 - a^2 + 2, -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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
>>> from sage.all import * >>> K = NumberField(x**Integer(17) + Integer(3), 'a') >>> K.unit_group(proof=True) # takes forever, not tested ... >>> U = K.unit_group(proof=False) >>> U Unit group with structure C2 x Z x Z x Z x Z x Z x Z x Z x Z of Number Field in a with defining polynomial x^17 + 3 >>> U.gens() (u0, u1, u2, u3, u4, u5, u6, u7, u8) >>> U.gens_values() # result not independently verified [-1, -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, 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, -a^16 - a^15 - a^14 - a^13 - a^12 - a^11 - a^10 - a^9 - a^8 - a^7 - a^6 - a^5 - a^4 - a^3 - a^2 + 2, -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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
- units(proof=None)[source]#
Return generators for the unit group modulo torsion.
ALGORITHM: Uses PARI’s pari:bnfinit command.
INPUT:
proof
(bool, defaultTrue
) flag passed to PARI.
Note
For more functionality see
unit_group()
.See also
EXAMPLES:
sage: x = polygen(QQ) 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() (-1/275*a^3 - 4/55*a^2 + 5/11*a - 3,)
>>> from sage.all import * >>> x = polygen(QQ) >>> A = x**Integer(4) - Integer(10)*x**Integer(3) + Integer(20)*Integer(5)*x**Integer(2) - Integer(15)*Integer(5)**Integer(2)*x + Integer(11)*Integer(5)**Integer(3) >>> K = NumberField(A, 'a') >>> K.units() (-1/275*a^3 - 4/55*a^2 + 5/11*a - 3,)
For big number fields, provably computing the unit group can take a very long time. In this case, one can ask for the conjectural unit group (correct if the Generalized Riemann Hypothesis is true):
sage: K = NumberField(x^17 + 3, 'a') sage: K.units(proof=True) # takes forever, not tested ... sage: K.units(proof=False) # result not independently verified (-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, 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, -a^16 - a^15 - a^14 - a^13 - a^12 - a^11 - a^10 - a^9 - a^8 - a^7 - a^6 - a^5 - a^4 - a^3 - a^2 + 2, -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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
>>> from sage.all import * >>> K = NumberField(x**Integer(17) + Integer(3), 'a') >>> K.units(proof=True) # takes forever, not tested ... >>> K.units(proof=False) # result not independently verified (-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, 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, -a^16 - a^15 - a^14 - a^13 - a^12 - a^11 - a^10 - a^9 - a^8 - a^7 - a^6 - a^5 - a^4 - a^3 - a^2 + 2, -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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
- valuation(prime)[source]#
Return the valuation on this field defined by
prime
.INPUT:
prime
– a prime that does not split, a discrete (pseudo-)valuation or a fractional ideal
EXAMPLES:
The valuation can be specified with an integer
prime
that is completely ramified inR
:sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^2 + 1) sage: K.valuation(2) # needs sage.rings.padics 2-adic valuation
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('a',)); (a,) = K._first_ngens(1) >>> K.valuation(Integer(2)) # needs sage.rings.padics 2-adic valuation
It can also be unramified in
R
:sage: K.valuation(3) # needs sage.rings.padics 3-adic valuation
>>> from sage.all import * >>> K.valuation(Integer(3)) # needs sage.rings.padics 3-adic valuation
A
prime
that factors into pairwise distinct factors, results in an error:sage: K.valuation(5) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: The valuation Gauss valuation induced by 5-adic valuation does not approximate a unique extension of 5-adic valuation with respect to x^2 + 1
>>> from sage.all import * >>> K.valuation(Integer(5)) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: The valuation Gauss valuation induced by 5-adic valuation does not approximate a unique extension of 5-adic valuation with respect to x^2 + 1
The valuation can also be selected by giving a valuation on the base ring that extends uniquely:
sage: CyclotomicField(5).valuation(ZZ.valuation(5)) # needs sage.rings.padics 5-adic valuation
>>> from sage.all import * >>> CyclotomicField(Integer(5)).valuation(ZZ.valuation(Integer(5))) # needs sage.rings.padics 5-adic valuation
When the extension is not unique, this does not work:
sage: K.valuation(ZZ.valuation(5)) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: The valuation Gauss valuation induced by 5-adic valuation does not approximate a unique extension of 5-adic valuation with respect to x^2 + 1
>>> from sage.all import * >>> K.valuation(ZZ.valuation(Integer(5))) # needs sage.rings.padics Traceback (most recent call last): ... ValueError: The valuation Gauss valuation induced by 5-adic valuation does not approximate a unique extension of 5-adic valuation with respect to x^2 + 1
For a number field which is of the form \(K[x]/(G)\), you can specify a valuation by providing a discrete pseudo-valuation on \(K[x]\) which sends \(G\) to infinity. This lets us specify which extension of the 5-adic valuation we care about in the above example:
sage: # needs sage.rings.padics sage: R.<x> = QQ[] sage: G5 = GaussValuation(R, QQ.valuation(5)) sage: v = K.valuation(G5.augmentation(x + 2, infinity)) sage: w = K.valuation(G5.augmentation(x + 1/2, infinity)) sage: v == w False
>>> from sage.all import * >>> # needs sage.rings.padics >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> G5 = GaussValuation(R, QQ.valuation(Integer(5))) >>> v = K.valuation(G5.augmentation(x + Integer(2), infinity)) >>> w = K.valuation(G5.augmentation(x + Integer(1)/Integer(2), infinity)) >>> v == w False
Note that you get the same valuation, even if you write down the pseudo-valuation differently:
sage: # needs sage.rings.padics sage: ww = K.valuation(G5.augmentation(x + 3, infinity)) sage: w is ww True
>>> from sage.all import * >>> # needs sage.rings.padics >>> ww = K.valuation(G5.augmentation(x + Integer(3), infinity)) >>> w is ww True
The valuation
prime
does not need to send the defining polynomial \(G\) to infinity. It is sufficient if it singles out one of the valuations on the number field. This is important if the prime only factors over the completion, i.e., if it is not possible to write down one of the factors within the number field:sage: # needs sage.rings.padics sage: v = G5.augmentation(x + 3, 1) sage: K.valuation(v) [ 5-adic valuation, v(x + 3) = 1 ]-adic valuation
>>> from sage.all import * >>> # needs sage.rings.padics >>> v = G5.augmentation(x + Integer(3), Integer(1)) >>> K.valuation(v) [ 5-adic valuation, v(x + 3) = 1 ]-adic valuation
Finally,
prime
can also be a fractional ideal of a number field if it singles out an extension of a \(p\)-adic valuation of the base field:sage: K.valuation(K.fractional_ideal(a + 1)) # needs sage.rings.padics 2-adic valuation
>>> from sage.all import * >>> K.valuation(K.fractional_ideal(a + Integer(1))) # needs sage.rings.padics 2-adic valuation
See also
- zeta(n=2, all=False)[source]#
Return one, or a list of all, primitive \(n\)-th root of unity in this field.
INPUT:
n
– positive integerall
– boolean. IfFalse
(default), return a primitive \(n\)-th root of unity in this field, or raise aValueError
exception if there are none. IfTrue
, return a list of all primitive \(n\)-th roots of unity in this field (possibly empty).
Note
To obtain the maximal order of a root of unity in this field, use
number_of_roots_of_unity()
.Note
We do not create the full unit group since that can be expensive, but we do use it if it is already known.
EXAMPLES:
sage: x = polygen(QQ, 'x') 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): ... ValueError: there are no 4th roots of unity in self
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(3), names=('z',)); (z,) = K._first_ngens(1) >>> K.zeta(Integer(1)) 1 >>> K.zeta(Integer(2)) -1 >>> K.zeta(Integer(2), all=True) [-1] >>> K.zeta(Integer(3)) -1/2*z - 1/2 >>> K.zeta(Integer(3), all=True) [-1/2*z - 1/2, 1/2*z - 1/2] >>> K.zeta(Integer(4)) Traceback (most recent call last): ... ValueError: there are no 4th 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): ... ValueError: there are no 3rd roots of unity in self sage: K.zeta(3, all=True) []
>>> from sage.all import * >>> r = QQ['x']; (x,) = r._first_ngens(1) >>> K = NumberField(x**Integer(2) + Integer(1), names=('b',)); (b,) = K._first_ngens(1) >>> K.zeta(Integer(4)) b >>> K.zeta(Integer(4),all=True) [b, -b] >>> K.zeta(Integer(3)) Traceback (most recent call last): ... ValueError: there are no 3rd roots of unity in self >>> K.zeta(Integer(3), all=True) []
Number fields defined by non-monic and non-integral polynomials are supported (Issue #252):
sage: K.<a> = NumberField(1/2*x^2 + 1/6) sage: K.zeta(3) -3/2*a - 1/2
>>> from sage.all import * >>> K = NumberField(Integer(1)/Integer(2)*x**Integer(2) + Integer(1)/Integer(6), names=('a',)); (a,) = K._first_ngens(1) >>> K.zeta(Integer(3)) -3/2*a - 1/2
- zeta_coefficients(n)[source]#
Compute the first \(n\) coefficients of the Dedekind zeta function of this field as a Dirichlet series.
EXAMPLES:
sage: x = QQ['x'].0 sage: NumberField(x^2 + 1, 'a').zeta_coefficients(10) [1, 1, 0, 1, 2, 0, 0, 1, 1, 2]
>>> from sage.all import * >>> x = QQ['x'].gen(0) >>> NumberField(x**Integer(2) + Integer(1), 'a').zeta_coefficients(Integer(10)) [1, 1, 0, 1, 2, 0, 0, 1, 1, 2]
- zeta_order()[source]#
Return the number of roots of unity in this field.
Note
We do not create the full unit group since that can be expensive, but we do use it if it is already known.
EXAMPLES:
sage: x = polygen(QQ, 'x') sage: F.<alpha> = NumberField(x^22 + 3) sage: F.zeta_order() 6 sage: F.<alpha> = NumberField(x^2 - 7) sage: F.zeta_order() 2
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> F = NumberField(x**Integer(22) + Integer(3), names=('alpha',)); (alpha,) = F._first_ngens(1) >>> F.zeta_order() 6 >>> F = NumberField(x**Integer(2) - Integer(7), names=('alpha',)); (alpha,) = F._first_ngens(1) >>> F.zeta_order() 2
- sage.rings.number_field.number_field.NumberField_generic_v1(poly, name, latex_name, canonical_embedding=None)[source]#
Used for unpickling old pickles.
EXAMPLES:
sage: from sage.rings.number_field.number_field import NumberField_absolute_v1 sage: R.<x> = QQ[] sage: NumberField_absolute_v1(x^2 + 1, 'i', 'i') Number Field in i with defining polynomial x^2 + 1
>>> from sage.all import * >>> from sage.rings.number_field.number_field import NumberField_absolute_v1 >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> NumberField_absolute_v1(x**Integer(2) + Integer(1), 'i', 'i') Number Field in i with defining polynomial x^2 + 1
- class sage.rings.number_field.number_field.NumberField_quadratic(polynomial, name=None, latex_name=None, check=True, embedding=None, assume_disc_small=False, maximize_at_primes=None, structure=None)[source]#
Bases:
NumberField_absolute
,NumberField_quadratic
Create a quadratic extension of the rational field.
The command
QuadraticField(a)
creates the field \(\QQ(\sqrt{a})\).EXAMPLES:
sage: QuadraticField(3, 'a') Number Field in a with defining polynomial x^2 - 3 with a = 1.732050807568878? sage: QuadraticField(-4, 'b') Number Field in b with defining polynomial x^2 + 4 with b = 2*I
>>> from sage.all import * >>> QuadraticField(Integer(3), 'a') Number Field in a with defining polynomial x^2 - 3 with a = 1.732050807568878? >>> QuadraticField(-Integer(4), 'b') Number Field in b with defining polynomial x^2 + 4 with b = 2*I
- class_number(proof=None)[source]#
Return the size of the class group of
self
.INPUT:
proof
– boolean (default:True
, unless you calledproof.number_field()
and set it otherwise). Ifproof
isFalse
(not the default!), and the discriminant of the field is negative, then the following warning from the PARI manual applies:
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.
EXAMPLES:
sage: QuadraticField(-23,'a').class_number() 3
>>> from sage.all import * >>> QuadraticField(-Integer(23),'a').class_number() 3
These are all the primes so that the class number of \(\QQ(\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]
>>> from sage.all import * >>> [d for d in prime_range(Integer(2),Integer(300)) ... if not is_square(d) and QuadraticField(-d,'a').class_number() == Integer(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 \(\QQ(\sqrt{d})\) has class number \(1\):
sage: len([d for d in range(2,200) ....: if not is_square(d) and QuadraticField(d,'a').class_number() == 1]) 121
>>> from sage.all import * >>> len([d for d in range(Integer(2),Integer(200)) ... if not is_square(d) and QuadraticField(d,'a').class_number() == Integer(1)]) 121
- discriminant(v=None)[source]#
Return 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 listv
.INPUT:
v
– (optional) list of element of this number field
OUTPUT: Integer if
v
is omitted, and Rational otherwise.EXAMPLES:
sage: x = polygen(QQ, 'x') 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
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(1), names=('i',)); (i,) = K._first_ngens(1) >>> K.discriminant() -4 >>> K = NumberField(x**Integer(2) + Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> K.discriminant() -20 >>> K = NumberField(x**Integer(2) - Integer(5), names=('a',)); (a,) = K._first_ngens(1) >>> K.discriminant() 5
- hilbert_class_field(names)[source]#
Return the Hilbert class field of this quadratic field as a relative extension of this field.
Note
For the polynomial that defines this field as a relative extension, see the method
hilbert_class_field_defining_polynomial()
, which is vastly faster than this method, since it doesn’t construct a relative extension.EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^2 + 23) sage: L = K.hilbert_class_field('b'); L Number Field in b with defining polynomial x^3 - x^2 + 1 over its base field sage: L.absolute_field('c') Number Field in c with defining polynomial x^6 - 2*x^5 + 70*x^4 - 90*x^3 + 1631*x^2 - 1196*x + 12743 sage: K.hilbert_class_field_defining_polynomial() x^3 - x^2 + 1
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(2) + Integer(23), names=('a',)); (a,) = K._first_ngens(1) >>> L = K.hilbert_class_field('b'); L Number Field in b with defining polynomial x^3 - x^2 + 1 over its base field >>> L.absolute_field('c') Number Field in c with defining polynomial x^6 - 2*x^5 + 70*x^4 - 90*x^3 + 1631*x^2 - 1196*x + 12743 >>> K.hilbert_class_field_defining_polynomial() x^3 - x^2 + 1
- hilbert_class_field_defining_polynomial(name='x')[source]#
Return a polynomial over \(\QQ\) whose roots generate the Hilbert class field of this quadratic field as an extension of this quadratic field.
Note
Computed using PARI via Schertz’s method. This implementation is quite fast.
EXAMPLES:
sage: K.<b> = QuadraticField(-23) sage: K.hilbert_class_field_defining_polynomial() x^3 - x^2 + 1
>>> from sage.all import * >>> K = QuadraticField(-Integer(23), names=('b',)); (b,) = K._first_ngens(1) >>> K.hilbert_class_field_defining_polynomial() x^3 - x^2 + 1
Note that this polynomial is not the actual Hilbert class polynomial: see
hilbert_class_polynomial
:sage: K.hilbert_class_polynomial() # needs sage.schemes x^3 + 3491750*x^2 - 5151296875*x + 12771880859375
>>> from sage.all import * >>> K.hilbert_class_polynomial() # needs sage.schemes x^3 + 3491750*x^2 - 5151296875*x + 12771880859375
sage: K.<a> = QuadraticField(-431) sage: K.class_number() 21 sage: K.hilbert_class_field_defining_polynomial(name='z') z^21 + 6*z^20 + 9*z^19 - 4*z^18 + 33*z^17 + 140*z^16 + 220*z^15 + 243*z^14 + 297*z^13 + 461*z^12 + 658*z^11 + 743*z^10 + 722*z^9 + 681*z^8 + 619*z^7 + 522*z^6 + 405*z^5 + 261*z^4 + 119*z^3 + 35*z^2 + 7*z + 1
>>> from sage.all import * >>> K = QuadraticField(-Integer(431), names=('a',)); (a,) = K._first_ngens(1) >>> K.class_number() 21 >>> K.hilbert_class_field_defining_polynomial(name='z') z^21 + 6*z^20 + 9*z^19 - 4*z^18 + 33*z^17 + 140*z^16 + 220*z^15 + 243*z^14 + 297*z^13 + 461*z^12 + 658*z^11 + 743*z^10 + 722*z^9 + 681*z^8 + 619*z^7 + 522*z^6 + 405*z^5 + 261*z^4 + 119*z^3 + 35*z^2 + 7*z + 1
- hilbert_class_polynomial(name='x')[source]#
Compute the Hilbert class polynomial of this quadratic field.
Right now, this is only implemented for imaginary quadratic fields.
EXAMPLES:
sage: K.<a> = QuadraticField(-3) sage: K.hilbert_class_polynomial() # needs sage.schemes x sage: K.<a> = QuadraticField(-31) sage: K.hilbert_class_polynomial(name='z') # needs sage.schemes z^3 + 39491307*z^2 - 58682638134*z + 1566028350940383
>>> from sage.all import * >>> K = QuadraticField(-Integer(3), names=('a',)); (a,) = K._first_ngens(1) >>> K.hilbert_class_polynomial() # needs sage.schemes x >>> K = QuadraticField(-Integer(31), names=('a',)); (a,) = K._first_ngens(1) >>> K.hilbert_class_polynomial(name='z') # needs sage.schemes z^3 + 39491307*z^2 - 58682638134*z + 1566028350940383
- is_galois()[source]#
Return
True
since all quadratic fields are automatically Galois.EXAMPLES:
sage: QuadraticField(1234,'d').is_galois() True
>>> from sage.all import * >>> QuadraticField(Integer(1234),'d').is_galois() True
- number_of_roots_of_unity()[source]#
Return the number of roots of unity in this quadratic field.
This is always 2 except when \(d\) is \(-3\) or \(-4\).
EXAMPLES:
sage: QF = QuadraticField sage: [QF(d).number_of_roots_of_unity() for d in range(-7, -2)] [2, 2, 2, 4, 6]
>>> from sage.all import * >>> QF = QuadraticField >>> [QF(d).number_of_roots_of_unity() for d in range(-Integer(7), -Integer(2))] [2, 2, 2, 4, 6]
- order_of_conductor(f)[source]#
Return the unique order with the given conductor in this quadratic field.
EXAMPLES:
sage: K.<t> = QuadraticField(-123) sage: K.order_of_conductor(1) is K.maximal_order() True sage: K.order_of_conductor(2).gens() (1, t) sage: K.order_of_conductor(44).gens() (1, 22*t) sage: K.order_of_conductor(9001).conductor() 9001
>>> from sage.all import * >>> K = QuadraticField(-Integer(123), names=('t',)); (t,) = K._first_ngens(1) >>> K.order_of_conductor(Integer(1)) is K.maximal_order() True >>> K.order_of_conductor(Integer(2)).gens() (1, t) >>> K.order_of_conductor(Integer(44)).gens() (1, 22*t) >>> K.order_of_conductor(Integer(9001)).conductor() 9001
- sage.rings.number_field.number_field.NumberField_quadratic_v1(poly, name, canonical_embedding=None)[source]#
Used for unpickling old pickles.
EXAMPLES:
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
>>> from sage.all import * >>> from sage.rings.number_field.number_field import NumberField_quadratic_v1 >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> NumberField_quadratic_v1(x**Integer(2) - Integer(2), 'd') Number Field in d with defining polynomial x^2 - 2
- sage.rings.number_field.number_field.QuadraticField(D, name='a', check=True, embedding=True, latex_name='sqrt', **args)[source]#
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 numbername
– variable name (default:'a'
)check
– bool (default:True
)embedding
– bool or square root of \(D\) in an ambient field (default:True
)latex_name
– latex variable name (default: \(\sqrt{D}\))
OUTPUT: A number field defined by a quadratic polynomial. Unless otherwise specified, it has an embedding into \(\RR\) or \(\CC\) by sending the generator to the positive or upper-half-plane root.
EXAMPLES:
sage: QuadraticField(3, 'a') Number Field in a with defining polynomial x^2 - 3 with a = 1.732050807568878? sage: K.<theta> = QuadraticField(3); K Number Field in theta with defining polynomial x^2 - 3 with theta = 1.732050807568878? sage: RR(theta) 1.73205080756888 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 with a = 3
>>> from sage.all import * >>> QuadraticField(Integer(3), 'a') Number Field in a with defining polynomial x^2 - 3 with a = 1.732050807568878? >>> K = QuadraticField(Integer(3), names=('theta',)); (theta,) = K._first_ngens(1); K Number Field in theta with defining polynomial x^2 - 3 with theta = 1.732050807568878? >>> RR(theta) 1.73205080756888 >>> QuadraticField(Integer(9), 'a') Traceback (most recent call last): ... ValueError: D must not be a perfect square. >>> QuadraticField(Integer(9), 'a', check=False) Number Field in a with defining polynomial x^2 - 9 with a = 3
Quadratic number fields derive from general number fields.
sage: from sage.rings.number_field.number_field_base import NumberField sage: type(K) <class 'sage.rings.number_field.number_field.NumberField_quadratic_with_category'> sage: isinstance(K, NumberField) True
>>> from sage.all import * >>> from sage.rings.number_field.number_field_base import NumberField >>> type(K) <class 'sage.rings.number_field.number_field.NumberField_quadratic_with_category'> >>> isinstance(K, NumberField) True
Quadratic number fields are cached:
sage: QuadraticField(-11, 'a') is QuadraticField(-11, 'a') True
>>> from sage.all import * >>> QuadraticField(-Integer(11), 'a') is QuadraticField(-Integer(11), 'a') True
By default, quadratic fields come with a nice latex representation:
sage: K.<a> = QuadraticField(-7) sage: latex(K) \Bold{Q}(\sqrt{-7}) sage: latex(a) \sqrt{-7} sage: latex(1/(1+a)) -\frac{1}{8} \sqrt{-7} + \frac{1}{8} sage: list(K.latex_variable_names()) ['\\sqrt{-7}']
>>> from sage.all import * >>> K = QuadraticField(-Integer(7), names=('a',)); (a,) = K._first_ngens(1) >>> latex(K) \Bold{Q}(\sqrt{-7}) >>> latex(a) \sqrt{-7} >>> latex(Integer(1)/(Integer(1)+a)) -\frac{1}{8} \sqrt{-7} + \frac{1}{8} >>> list(K.latex_variable_names()) ['\\sqrt{-7}']
We can provide our own name as well:
sage: K.<a> = QuadraticField(next_prime(10^10), latex_name=r'\sqrt{D}') sage: 1 + a a + 1 sage: latex(1 + a) \sqrt{D} + 1 sage: latex(QuadraticField(-1, 'a', latex_name=None).gen()) a
>>> from sage.all import * >>> K = QuadraticField(next_prime(Integer(10)**Integer(10)), latex_name=r'\sqrt{D}', names=('a',)); (a,) = K._first_ngens(1) >>> Integer(1) + a a + 1 >>> latex(Integer(1) + a) \sqrt{D} + 1 >>> latex(QuadraticField(-Integer(1), 'a', latex_name=None).gen()) a
The name of the generator does not interfere with Sage preparser, see Issue #1135:
sage: K1 = QuadraticField(5, 'x') sage: K2.<x> = QuadraticField(5) sage: K3.<x> = QuadraticField(5, 'x') sage: K1 is K2 True sage: K1 is K3 True sage: K1 Number Field in x with defining polynomial x^2 - 5 with x = 2.236067977499790?
>>> from sage.all import * >>> K1 = QuadraticField(Integer(5), 'x') >>> K2 = QuadraticField(Integer(5), names=('x',)); (x,) = K2._first_ngens(1) >>> K3 = QuadraticField(Integer(5), 'x', names=('x',)); (x,) = K3._first_ngens(1) >>> K1 is K2 True >>> K1 is K3 True >>> K1 Number Field in x with defining polynomial x^2 - 5 with x = 2.236067977499790?
Note that, in presence of two different names for the generator, the name given by the preparser takes precedence:
sage: K4.<y> = QuadraticField(5, 'x'); K4 Number Field in y with defining polynomial x^2 - 5 with y = 2.236067977499790? sage: K1 == K4 False
>>> from sage.all import * >>> K4 = QuadraticField(Integer(5), 'x', names=('y',)); (y,) = K4._first_ngens(1); K4 Number Field in y with defining polynomial x^2 - 5 with y = 2.236067977499790? >>> K1 == K4 False
- sage.rings.number_field.number_field.is_AbsoluteNumberField(x)[source]#
Return
True
ifx
is an absolute number field.EXAMPLES:
sage: from sage.rings.number_field.number_field import is_AbsoluteNumberField sage: x = polygen(ZZ, 'x') sage: is_AbsoluteNumberField(NumberField(x^2 + 1, 'a')) doctest:warning... DeprecationWarning: The function is_AbsoluteNumberField is deprecated; use 'isinstance(..., NumberField_absolute)' instead. See https://github.com/sagemath/sage/issues/38124 for details. True sage: is_AbsoluteNumberField(NumberField([x^3 + 17, x^2 + 1], 'a')) False
>>> from sage.all import * >>> from sage.rings.number_field.number_field import is_AbsoluteNumberField >>> x = polygen(ZZ, 'x') >>> is_AbsoluteNumberField(NumberField(x**Integer(2) + Integer(1), 'a')) doctest:warning... DeprecationWarning: The function is_AbsoluteNumberField is deprecated; use 'isinstance(..., NumberField_absolute)' instead. See https://github.com/sagemath/sage/issues/38124 for details. True >>> is_AbsoluteNumberField(NumberField([x**Integer(3) + Integer(17), x**Integer(2) + Integer(1)], 'a')) False
The rationals are a number field, but they’re not of the absolute number field class.
sage: is_AbsoluteNumberField(QQ) False
>>> from sage.all import * >>> is_AbsoluteNumberField(QQ) False
- sage.rings.number_field.number_field.is_NumberFieldHomsetCodomain(codomain)[source]#
Return whether
codomain
is a valid codomain for a number field homset. This is used by NumberField._Hom_ to determine whether the created homsets should be asage.rings.number_field.homset.NumberFieldHomset
.EXAMPLES:
This currently accepts any parent (CC, RR, …) in
Fields
:sage: from sage.rings.number_field.number_field import is_NumberFieldHomsetCodomain sage: is_NumberFieldHomsetCodomain(QQ) True sage: x = polygen(ZZ, 'x') sage: is_NumberFieldHomsetCodomain(NumberField(x^2 + 1, 'x')) True sage: is_NumberFieldHomsetCodomain(ZZ) False sage: is_NumberFieldHomsetCodomain(3) False sage: is_NumberFieldHomsetCodomain(MatrixSpace(QQ, 2)) False sage: is_NumberFieldHomsetCodomain(InfinityRing) False
>>> from sage.all import * >>> from sage.rings.number_field.number_field import is_NumberFieldHomsetCodomain >>> is_NumberFieldHomsetCodomain(QQ) True >>> x = polygen(ZZ, 'x') >>> is_NumberFieldHomsetCodomain(NumberField(x**Integer(2) + Integer(1), 'x')) True >>> is_NumberFieldHomsetCodomain(ZZ) False >>> is_NumberFieldHomsetCodomain(Integer(3)) False >>> is_NumberFieldHomsetCodomain(MatrixSpace(QQ, Integer(2))) False >>> is_NumberFieldHomsetCodomain(InfinityRing) False
Question: should, for example, QQ-algebras be accepted as well?
Caveat: Gap objects are not (yet) in
Fields
, and therefore not accepted as number field homset codomains:sage: is_NumberFieldHomsetCodomain(gap.Rationals) # needs sage.libs.gap False
>>> from sage.all import * >>> is_NumberFieldHomsetCodomain(gap.Rationals) # needs sage.libs.gap False
- sage.rings.number_field.number_field.is_fundamental_discriminant(D)[source]#
Return
True
if the integer \(D\) is a fundamental discriminant, i.e., if \(D \cong 0,1\pmod{4}\), and \(D\neq 0, 1\) and either (1) \(D\) is square free or (2) we have \(D\cong 0\pmod{4}\) with \(D/4 \cong 2,3\pmod{4}\) and \(D/4\) square free. These are exactly the discriminants of quadratic fields.EXAMPLES:
sage: [D for D in range(-15,15) if is_fundamental_discriminant(D)] ... DeprecationWarning: is_fundamental_discriminant(D) is deprecated; please use D.is_fundamental_discriminant() ... [-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]
>>> from sage.all import * >>> [D for D in range(-Integer(15),Integer(15)) if is_fundamental_discriminant(D)] ... DeprecationWarning: is_fundamental_discriminant(D) is deprecated; please use D.is_fundamental_discriminant() ... [-15, -11, -8, -7, -4, -3, 5, 8, 12, 13] >>> [D for D in range(-Integer(15),Integer(15)) ... if not is_square(D) and QuadraticField(D,'a').disc() == D] [-15, -11, -8, -7, -4, -3, 5, 8, 12, 13]
- sage.rings.number_field.number_field.is_real_place(v)[source]#
Return
True
if \(v\) is real,False
if \(v\) is complexINPUT:
v
– an infinite place ofself
OUTPUT:
A boolean indicating whether a place is real (
True
) or complex (False
).EXAMPLES:
sage: x = polygen(QQ, 'x') sage: K.<xi> = NumberField(x^3 - 3) sage: phi_real = K.places()[0] sage: phi_complex = K.places()[1] sage: v_fin = tuple(K.primes_above(3))[0] sage: is_real_place(phi_real) True sage: is_real_place(phi_complex) False
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) - Integer(3), names=('xi',)); (xi,) = K._first_ngens(1) >>> phi_real = K.places()[Integer(0)] >>> phi_complex = K.places()[Integer(1)] >>> v_fin = tuple(K.primes_above(Integer(3)))[Integer(0)] >>> is_real_place(phi_real) True >>> is_real_place(phi_complex) False
It is an error to put in a finite place
sage: is_real_place(v_fin) Traceback (most recent call last): ... AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
>>> from sage.all import * >>> is_real_place(v_fin) Traceback (most recent call last): ... AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- sage.rings.number_field.number_field.proof_flag(t)[source]#
Used for easily determining the correct proof flag to use.
Return
t
ift
is notNone
, otherwise return the system-wide proof-flag for number fields (default:True
).EXAMPLES:
sage: from sage.rings.number_field.number_field import proof_flag sage: proof_flag(True) True sage: proof_flag(False) False sage: proof_flag(None) True sage: proof_flag("banana") 'banana'
>>> from sage.all import * >>> from sage.rings.number_field.number_field import proof_flag >>> proof_flag(True) True >>> proof_flag(False) False >>> proof_flag(None) True >>> proof_flag("banana") 'banana'
- sage.rings.number_field.number_field.put_natural_embedding_first(v)[source]#
Helper function for embeddings() functions for number fields.
INPUT:
v
– a list of embeddings of a number field
OUTPUT:
None
. The list is altered in-place, so that, if possible, the first embedding has been switched with one of the others, so that if there is an embedding which preserves the generator names then it appears first.EXAMPLES:
sage: K.<a> = CyclotomicField(7) sage: embs = K.embeddings(K) sage: [e(a) for e in embs] # random - there is no natural sort order [a, a^2, a^3, a^4, a^5, -a^5 - a^4 - a^3 - a^2 - a - 1] sage: id = [e for e in embs if e(a) == a][0]; id Ring endomorphism of Cyclotomic Field of order 7 and degree 6 Defn: a |--> a sage: permuted_embs = list(embs); permuted_embs.remove(id); permuted_embs.append(id) sage: [e(a) for e in permuted_embs] # random - but natural map is not first [a^2, a^3, a^4, a^5, -a^5 - a^4 - a^3 - a^2 - a - 1, a] sage: permuted_embs[0] != a True sage: from sage.rings.number_field.number_field import put_natural_embedding_first sage: put_natural_embedding_first(permuted_embs) sage: [e(a) for e in permuted_embs] # random - but natural map is first [a, a^3, a^4, a^5, -a^5 - a^4 - a^3 - a^2 - a - 1, a^2] sage: permuted_embs[0] == id True
>>> from sage.all import * >>> K = CyclotomicField(Integer(7), names=('a',)); (a,) = K._first_ngens(1) >>> embs = K.embeddings(K) >>> [e(a) for e in embs] # random - there is no natural sort order [a, a^2, a^3, a^4, a^5, -a^5 - a^4 - a^3 - a^2 - a - 1] >>> id = [e for e in embs if e(a) == a][Integer(0)]; id Ring endomorphism of Cyclotomic Field of order 7 and degree 6 Defn: a |--> a >>> permuted_embs = list(embs); permuted_embs.remove(id); permuted_embs.append(id) >>> [e(a) for e in permuted_embs] # random - but natural map is not first [a^2, a^3, a^4, a^5, -a^5 - a^4 - a^3 - a^2 - a - 1, a] >>> permuted_embs[Integer(0)] != a True >>> from sage.rings.number_field.number_field import put_natural_embedding_first >>> put_natural_embedding_first(permuted_embs) >>> [e(a) for e in permuted_embs] # random - but natural map is first [a, a^3, a^4, a^5, -a^5 - a^4 - a^3 - a^2 - a - 1, a^2] >>> permuted_embs[Integer(0)] == id True
- sage.rings.number_field.number_field.refine_embedding(e, prec=None)[source]#
Given an embedding from a number field to either \(\RR\) or \(\CC\), return an equivalent embedding with higher precision.
INPUT:
e
– an embedding of a number field into either \(\RR\) or \(\CC\) (with some precision)prec
– (defaultNone
) the desired precision; ifNone
,current precision is doubled; if
Infinity
, the equivalent embedding into eitherQQbar
orAA
is returned.
EXAMPLES:
sage: from sage.rings.number_field.number_field import refine_embedding sage: K = CyclotomicField(3) sage: e10 = K.complex_embedding(10) sage: e10.codomain().precision() 10 sage: e25 = refine_embedding(e10, prec=25) sage: e25.codomain().precision() 25
>>> from sage.all import * >>> from sage.rings.number_field.number_field import refine_embedding >>> K = CyclotomicField(Integer(3)) >>> e10 = K.complex_embedding(Integer(10)) >>> e10.codomain().precision() 10 >>> e25 = refine_embedding(e10, prec=Integer(25)) >>> e25.codomain().precision() 25
An example where we extend a real embedding into
AA
:sage: x = polygen(QQ, 'x') sage: K.<a> = NumberField(x^3 - 2) sage: K.signature() (1, 1) sage: e = K.embeddings(RR)[0]; e Ring morphism: From: Number Field in a with defining polynomial x^3 - 2 To: Real Field with 53 bits of precision Defn: a |--> 1.25992104989487 sage: e = refine_embedding(e, Infinity); e Ring morphism: From: Number Field in a with defining polynomial x^3 - 2 To: Algebraic Real Field Defn: a |--> 1.259921049894873?
>>> from sage.all import * >>> x = polygen(QQ, 'x') >>> K = NumberField(x**Integer(3) - Integer(2), names=('a',)); (a,) = K._first_ngens(1) >>> K.signature() (1, 1) >>> e = K.embeddings(RR)[Integer(0)]; e Ring morphism: From: Number Field in a with defining polynomial x^3 - 2 To: Real Field with 53 bits of precision Defn: a |--> 1.25992104989487 >>> e = refine_embedding(e, Infinity); e Ring morphism: From: Number Field in a with defining polynomial x^3 - 2 To: Algebraic Real Field Defn: a |--> 1.259921049894873?
Now we can obtain arbitrary precision values with no trouble:
sage: RealField(150)(e(a)) 1.2599210498948731647672106072782283505702515 sage: _^3 2.0000000000000000000000000000000000000000000 sage: RealField(200)(e(a^2 - 3*a + 7)) 4.8076379022835799804500738174376232086807389337953290695624
>>> from sage.all import * >>> RealField(Integer(150))(e(a)) 1.2599210498948731647672106072782283505702515 >>> _**Integer(3) 2.0000000000000000000000000000000000000000000 >>> RealField(Integer(200))(e(a**Integer(2) - Integer(3)*a + Integer(7))) 4.8076379022835799804500738174376232086807389337953290695624
Complex embeddings can be extended into
QQbar
:sage: e = K.embeddings(CC)[0]; e 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 sage: e = refine_embedding(e,Infinity); e Ring morphism: From: Number Field in a with defining polynomial x^3 - 2 To: Algebraic Field Defn: a |--> -0.6299605249474365? - 1.091123635971722?*I sage: ComplexField(200)(e(a)) -0.62996052494743658238360530363911417528512573235075399004099 - 1.0911236359717214035600726141898088813258733387403009407036*I sage: e(a)^3 2
>>> from sage.all import * >>> e = K.embeddings(CC)[Integer(0)]; e 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 >>> e = refine_embedding(e,Infinity); e Ring morphism: From: Number Field in a with defining polynomial x^3 - 2 To: Algebraic Field Defn: a |--> -0.6299605249474365? - 1.091123635971722?*I >>> ComplexField(Integer(200))(e(a)) -0.62996052494743658238360530363911417528512573235075399004099 - 1.0911236359717214035600726141898088813258733387403009407036*I >>> e(a)**Integer(3) 2
Embeddings into lazy fields work:
sage: L = CyclotomicField(7) sage: x = L.specified_complex_embedding(); x Generic morphism: From: Cyclotomic Field of order 7 and degree 6 To: Complex Lazy Field Defn: zeta7 -> 0.623489801858734? + 0.781831482468030?*I sage: refine_embedding(x, 300) Ring morphism: From: Cyclotomic Field of order 7 and degree 6 To: Complex Field with 300 bits of precision Defn: zeta7 |--> 0.623489801858733530525004884004239810632274730896402105365549439096853652456487284575942507 + 0.781831482468029808708444526674057750232334518708687528980634958045091731633936441700868007*I sage: refine_embedding(x, infinity) Ring morphism: From: Cyclotomic Field of order 7 and degree 6 To: Algebraic Field Defn: zeta7 |--> 0.6234898018587335? + 0.7818314824680299?*I
>>> from sage.all import * >>> L = CyclotomicField(Integer(7)) >>> x = L.specified_complex_embedding(); x Generic morphism: From: Cyclotomic Field of order 7 and degree 6 To: Complex Lazy Field Defn: zeta7 -> 0.623489801858734? + 0.781831482468030?*I >>> refine_embedding(x, Integer(300)) Ring morphism: From: Cyclotomic Field of order 7 and degree 6 To: Complex Field with 300 bits of precision Defn: zeta7 |--> 0.623489801858733530525004884004239810632274730896402105365549439096853652456487284575942507 + 0.781831482468029808708444526674057750232334518708687528980634958045091731633936441700868007*I >>> refine_embedding(x, infinity) Ring morphism: From: Cyclotomic Field of order 7 and degree 6 To: Algebraic Field Defn: zeta7 |--> 0.6234898018587335? + 0.7818314824680299?*I
When the old embedding is into the real lazy field, then only real embeddings should be considered. See Issue #17495:
sage: R.<x> = QQ[] sage: K.<a> = NumberField(x^3 + x - 1, embedding=0.68) sage: from sage.rings.number_field.number_field import refine_embedding sage: refine_embedding(K.specified_complex_embedding(), 100) Ring morphism: From: Number Field in a with defining polynomial x^3 + x - 1 with a = 0.6823278038280193? To: Real Field with 100 bits of precision Defn: a |--> 0.68232780382801932736948373971 sage: refine_embedding(K.specified_complex_embedding(), Infinity) Ring morphism: From: Number Field in a with defining polynomial x^3 + x - 1 with a = 0.6823278038280193? To: Algebraic Real Field Defn: a |--> 0.6823278038280193?
>>> from sage.all import * >>> R = QQ['x']; (x,) = R._first_ngens(1) >>> K = NumberField(x**Integer(3) + x - Integer(1), embedding=RealNumber('0.68'), names=('a',)); (a,) = K._first_ngens(1) >>> from sage.rings.number_field.number_field import refine_embedding >>> refine_embedding(K.specified_complex_embedding(), Integer(100)) Ring morphism: From: Number Field in a with defining polynomial x^3 + x - 1 with a = 0.6823278038280193? To: Real Field with 100 bits of precision Defn: a |--> 0.68232780382801932736948373971 >>> refine_embedding(K.specified_complex_embedding(), Infinity) Ring morphism: From: Number Field in a with defining polynomial x^3 + x - 1 with a = 0.6823278038280193? To: Algebraic Real Field Defn: a |--> 0.6823278038280193?