Skip to content
Merged
5 changes: 3 additions & 2 deletions src/sage/rings/number_field/S_unit_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,11 +982,12 @@ def minimal_vector(A, y, prec=106):
ALLLinv = ALLL.inverse()
ybrace = [ abs(R(a-a.round())) for a in y * ALLLinv if (a-a.round()) != 0]

v = ALLL.rows()[0]
if len(ybrace) == 0:
return (ALLL.rows()[0].norm())**2 / c1
return v.dot_product(v) / c1
else:
sigma = ybrace[len(ybrace)-1]
return ((ALLL.rows()[0].norm())**2 * sigma) / c1
return v.dot_product(v) * sigma / c1


def reduction_step_complex_case(place, B0, list_of_gens, torsion_gen, c13):
Expand Down
8 changes: 7 additions & 1 deletion src/sage/rings/number_field/galois_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ class GaloisGroup_v1(SageObject):

EXAMPLES::

sage: # needs sage.symbolic
sage: from sage.rings.number_field.galois_group import GaloisGroup_v1
sage: K = QQ[2^(1/3)]
sage: G = GaloisGroup_v1(K.absolute_polynomial().galois_group(pari_group=True), K); G
sage: pK = K.absolute_polynomial()
sage: G = GaloisGroup_v1(pK.galois_group(pari_group=True), K); G
...DeprecationWarning: GaloisGroup_v1 is deprecated; please use GaloisGroup_v2
See https://github.com/sagemath/sage/issues/28782 for details.
Galois group PARI group [6, -1, 2, "S3"] of degree 3 of the
Expand Down Expand Up @@ -96,6 +98,8 @@ def __eq__(self, other):
sage: G = GaloisGroup_v1(K.absolute_polynomial().galois_group(pari_group=True), K)
...DeprecationWarning: GaloisGroup_v1 is deprecated; please use GaloisGroup_v2
See https://github.com/sagemath/sage/issues/28782 for details.

sage: # needs sage.symbolic
sage: L = QQ[sqrt(2)]
sage: H = GaloisGroup_v1(L.absolute_polynomial().galois_group(pari_group=True), L)
sage: H == G
Expand Down Expand Up @@ -125,6 +129,8 @@ def __ne__(self, other):
sage: G = GaloisGroup_v1(K.absolute_polynomial().galois_group(pari_group=True), K)
...DeprecationWarning: GaloisGroup_v1 is deprecated; please use GaloisGroup_v2
See https://github.com/sagemath/sage/issues/28782 for details.

sage: # needs sage.symbolic
sage: L = QQ[sqrt(2)]
sage: H = GaloisGroup_v1(L.absolute_polynomial().galois_group(pari_group=True), L)
sage: H != G
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/number_field/homset.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@ def _element_constructor_(self, x, base_map=None, base_hom=None, check=True):
are only approximate::

sage: K.<a> = QuadraticField(-7)
sage: f = K.hom([CC(sqrt(-7))], check=False)
sage: f = K.hom([CC(sqrt(-7))], check=False) # needs sage.symbolic
sage: x = polygen(K)
sage: L.<b> = K.extension(x^2 - a - 5)
sage: L.Hom(CC)(f(a + 5).sqrt(), f, check=False)
sage: L.Hom(CC)(f(a + 5).sqrt(), f, check=False) # needs sage.symbolic
Relative number field morphism:
From: Number Field in b with defining polynomial x^2 - a - 5 over its base field
To: Complex Field with 53 bits of precision
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/number_field/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _repr_type(self):

def is_injective(self):
r"""
EXAMPLES::
EXAMPLES::

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^4 + 3*x + 1)
Expand All @@ -91,7 +91,7 @@ def is_injective(self):

def is_surjective(self):
r"""
EXAMPLES::
EXAMPLES::

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^4 + 3*x + 1)
Expand Down
566 changes: 306 additions & 260 deletions src/sage/rings/number_field/number_field.py

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions src/sage/rings/number_field/number_field_base.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: optional - sage.rings.number_field
# sage.doctest: needs sage.rings.number_field
"""
Base class for all number fields

Expand Down Expand Up @@ -135,13 +135,15 @@ cdef class NumberField(Field):
else:
codomain_other = other

from sage.rings.qqbar import AA
if codomain_self is AA and codomain_other is AA:
return AA

from sage.rings.qqbar import QQbar
if codomain_self in (AA, QQbar) and codomain_other in (AA, QQbar):
return QQbar
try:
from sage.rings.qqbar import AA, QQbar
except ImportError:
pass
else:
if codomain_self is AA and codomain_other is AA:
return AA
if codomain_self in (AA, QQbar) and codomain_other in (AA, QQbar):
return QQbar

def ring_of_integers(self, *args, **kwds):
r"""
Expand Down
144 changes: 73 additions & 71 deletions src/sage/rings/number_field/number_field_element.pyx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/sage/rings/number_field/number_field_element_base.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ cdef class NumberFieldElement_base(FieldElement):
EXAMPLES::

sage: x = polygen(ZZ, 'x')
sage: k.<a> = NumberField(x^3 + x + 1) # optional - sage.rings.number_field
sage: isinstance(a, sage.rings.number_field.number_field_element_base.NumberFieldElement_base) # optional - sage.rings.number_field
sage: k.<a> = NumberField(x^3 + x + 1) # needs sage.rings.number_field
sage: isinstance(a, sage.rings.number_field.number_field_element_base.NumberFieldElement_base) # needs sage.rings.number_field
True

By design, there is a unique direct subclass::
Expand Down
26 changes: 14 additions & 12 deletions src/sage/rings/number_field/number_field_element_quadratic.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
EXAMPLES::

sage: K.<a> = QuadraticField(-1)
sage: (1/3 + a/2)._sympy_() # optional - sympy
sage: (1/3 + a/2)._sympy_() # needs sympy
1/3 + I/2
sage: type(_) # optional - sympy
sage: type(_) # needs sympy
<class 'sympy.core.add.Add'>
"""
a = self.parent().gen()
Expand Down Expand Up @@ -506,10 +506,10 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):

Verify embeddings are respected::

sage: cf6c = CyclotomicField(6, embedding=CDF(exp(-pi*I/3))) ; z6c = cf6c.0
sage: cf3(z6c)
sage: cf6c = CyclotomicField(6, embedding=CDF(exp(-pi*I/3))); z6c = cf6c.0 # needs sage.symbolic
sage: cf3(z6c) # needs sage.symbolic
-zeta3
sage: cf6c(z3)
sage: cf6c(z3) # needs sage.symbolic
-zeta6

AUTHOR:
Expand Down Expand Up @@ -986,9 +986,10 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
sage: (-a-2).sign()
-1

sage: # needs sage.symbolic
sage: x = polygen(ZZ, 'x')
sage: K.<b> = NumberField(x^2 + 2*x + 7, 'b', embedding=CC(-1,-sqrt(6))) # optional - sage.symbolic
sage: b.sign() # optional - sage.symbolic
sage: K.<b> = NumberField(x^2 + 2*x + 7, 'b', embedding=CC(-1,-sqrt(6)))
sage: b.sign()
Traceback (most recent call last):
...
ValueError: a complex number has no sign!
Expand Down Expand Up @@ -1822,6 +1823,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
0
sage: (a + 1/2).real()
1/2
sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^2 + x + 1)
sage: a.real()
-1/2
Expand Down Expand Up @@ -1865,7 +1867,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):
1/2*sqrt3
sage: a.real()
-1/2
sage: SR(a) # optional - sage.symbolic
sage: SR(a) # needs sage.symbolic
1/2*I*sqrt(3) - 1/2
sage: bool(QQbar(I)*QQbar(a.imag()) + QQbar(a.real()) == QQbar(a))
True
Expand Down Expand Up @@ -2214,7 +2216,7 @@ cdef class NumberFieldElement_quadratic(NumberFieldElement_absolute):

sage: x = polygen(ZZ, 'x')
sage: K.<a> = NumberField(x^2 + 1, embedding=CDF.gen())
sage: abs(a+1)
sage: abs(a+1) # needs sage.symbolic
sqrt(2)
"""
if mpz_sgn(self.D.value) == 1:
Expand Down Expand Up @@ -2506,11 +2508,11 @@ cdef class NumberFieldElement_gaussian(NumberFieldElement_quadratic_sqrt):
r"""
EXAMPLES::

sage: SR(1 + 2*i) # optional - sage.symbolic
sage: SR(1 + 2*i) # needs sage.symbolic
2*I + 1

sage: K.<mi> = QuadraticField(-1, embedding=CC(0,-1))
sage: SR(1 + mi) # optional - sage.symbolic
sage: SR(1 + mi) # needs sage.symbolic
-I + 1
"""
from sage.symbolic.constants import I
Expand Down Expand Up @@ -2616,7 +2618,7 @@ cdef class NumberFieldElement_gaussian(NumberFieldElement_quadratic_sqrt):

EXAMPLES::

sage: I.log() # optional - sage.symbolic
sage: I.log() # needs sage.symbolic
1/2*I*pi
"""
from sage.symbolic.ring import SR
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/number_field/number_field_ideal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# sage.doctest: optional - sage.libs.pari
# sage.doctest: needs sage.libs.pari sage.rings.number_field
"""
Number Field Ideals

Expand Down
3 changes: 2 additions & 1 deletion src/sage/rings/number_field/number_field_ideal_rel.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,8 @@ def ramification_index(self):
sage: K.ideal(2).ramification_index()
Traceback (most recent call last):
...
NotImplementedError: For an ideal in a relative number field you must use relative_ramification_index or absolute_ramification_index as appropriate
NotImplementedError: For an ideal in a relative number field you must use
relative_ramification_index or absolute_ramification_index as appropriate
"""
raise NotImplementedError("For an ideal in a relative number field you must use relative_ramification_index or absolute_ramification_index as appropriate")

Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/number_field/number_field_morphisms.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ def root_from_approx(f, a):
sage: root_from_approx(x^2 + 1, CC(0))
-1*I

sage: root_from_approx(x^2 - 2, sqrt(2))
sage: root_from_approx(x^2 - 2, sqrt(2)) # needs sage.symbolic
sqrt(2)
sage: root_from_approx(x^2 - 2, sqrt(3))
sage: root_from_approx(x^2 - 2, sqrt(3)) # needs sage.symbolic
Traceback (most recent call last):
...
ValueError: sqrt(3) is not a root of x^2 - 2
Expand Down
14 changes: 8 additions & 6 deletions src/sage/rings/number_field/number_field_rel.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ def _convert_non_number_field_element(self, x):

Examples from :trac:`4727`::

sage: # needs sage.symbolic
sage: K.<j,b> = QQ[sqrt(-1), sqrt(2)]
sage: j
I
Expand Down Expand Up @@ -912,7 +913,8 @@ def _convert_non_number_field_element(self, x):
sage: L(L)
Traceback (most recent call last):
...
TypeError: unable to convert Number Field in a0 with defining polynomial x^2 + 1 over its base field to Number Field in a0 with defining polynomial x^2 + 1 over its base field
TypeError: unable to convert Number Field in a0 with defining polynomial x^2 + 1 over its base field
to Number Field in a0 with defining polynomial x^2 + 1 over its base field
sage: L in L
False

Expand Down Expand Up @@ -1672,7 +1674,7 @@ def _gen_relative(self):
sage: k.<a> = NumberField(x^2 + 1); k
Number Field in a with defining polynomial x^2 + 1
sage: y = polygen(k)
sage: m.<b> = k.extension(y^2+3); m
sage: m.<b> = k.extension(y^2 + 3); m
Number Field in b with defining polynomial x^2 + 3 over its base field
sage: c = m.gen(); c # indirect doctest
b
Expand Down Expand Up @@ -2455,20 +2457,20 @@ def order(self, *gens, **kwds):

EXAMPLES::

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

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

sage: R.base_ring()
sage: R.base_ring() # needs sage.symbolic
Integer Ring

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

sage: P.order([a, b])
sage: P.order([a, b]) # needs sage.symbolic
Traceback (most recent call last):
...
ValueError: the rank of the span of gens is wrong
Expand Down
16 changes: 8 additions & 8 deletions src/sage/rings/number_field/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -1064,20 +1064,20 @@ def class_number(self, proof=None):

EXAMPLES::

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

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

sage: ZZ[120*sqrt(-23)].class_number()
sage: ZZ[120*sqrt(-23)].class_number() # needs sage.symbolic
288
sage: ZZ[100*sqrt(3)].class_number()
sage: ZZ[100*sqrt(3)].class_number() # needs sage.symbolic
4
sage: ZZ[11*2^(1/3)].class_number()
sage: ZZ[11*2^(1/3)].class_number() # needs sage.symbolic
Traceback (most recent call last):
...
NotImplementedError: computation of class numbers of non-maximal orders
Expand Down Expand Up @@ -1554,7 +1554,7 @@ def _element_constructor_(self, x):
(see :trac:`10017`)::

sage: x = polygen(QQ)
sage: K.<a> = NumberField(x^3-10)
sage: K.<a> = NumberField(x^3 - 10)
sage: ZK = K.ring_of_integers()
sage: ZK.basis()
[1/3*a^2 + 1/3*a + 1/3, a, a^2]
Expand Down Expand Up @@ -1665,7 +1665,7 @@ def _magma_init_(self, magma):

OUTPUT:

a MagmaElement, the magma version of this absolute order
a :class:`MagmaElement`, the magma version of this absolute order

EXAMPLES::

Expand Down
Loading