diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py index 53d9683279b..173baa3b793 100644 --- a/src/sage/arith/misc.py +++ b/src/sage/arith/misc.py @@ -5599,7 +5599,7 @@ def _key_complex_for_display(a): ai = a.imag() if not ai: return (0, ar) - epsilon = 1e-10 + epsilon = ar.parent()(1e-10) if ar.abs() < epsilon: ar_truncated = 0 elif ar.prec() < 34: diff --git a/src/sage/categories/pushout.py b/src/sage/categories/pushout.py index 2d4eb607f6b..e270892257f 100644 --- a/src/sage/categories/pushout.py +++ b/src/sage/categories/pushout.py @@ -2542,14 +2542,10 @@ def merge(self, other): We check that :trac:`12353` has been resolved:: - sage: RealIntervalField(53)(-1) > RR(1) - False - sage: RealIntervalField(54)(-1) > RR(1) - False - sage: RealIntervalField(54)(1) > RR(-1) - True - sage: RealIntervalField(53)(1) > RR(-1) - True + sage: RIF(1) > RR(1) + Traceback (most recent call last): + ... + TypeError: unsupported operand parent(s) for >: 'Real Interval Field with 53 bits of precision' and 'Real Field with 53 bits of precision' We check that various pushouts work:: diff --git a/src/sage/doctest/parsing.py b/src/sage/doctest/parsing.py index 4e1a6b32e41..0f34efa6480 100644 --- a/src/sage/doctest/parsing.py +++ b/src/sage/doctest/parsing.py @@ -935,17 +935,17 @@ def add_tolerance(self, wantval, want): sage: want_tol = MarkedOutput().update(tol=0.0001) sage: want_abs = MarkedOutput().update(abs_tol=0.0001) sage: want_rel = MarkedOutput().update(rel_tol=0.0001) - sage: OC.add_tolerance(pi.n(64), want_tol).endpoints() + sage: OC.add_tolerance(RIF(pi.n(64)), want_tol).endpoints() (3.14127849432443, 3.14190681285516) - sage: OC.add_tolerance(pi.n(64), want_abs).endpoints() + sage: OC.add_tolerance(RIF(pi.n(64)), want_abs).endpoints() (3.14149265358979, 3.14169265358980) - sage: OC.add_tolerance(pi.n(64), want_rel).endpoints() + sage: OC.add_tolerance(RIF(pi.n(64)), want_rel).endpoints() (3.14127849432443, 3.14190681285516) - sage: OC.add_tolerance(1e1000, want_tol) + sage: OC.add_tolerance(RIF(1e1000), want_tol) 1.000?e1000 - sage: OC.add_tolerance(1e1000, want_abs) + sage: OC.add_tolerance(RIF(1e1000), want_abs) 1.000000000000000?e1000 - sage: OC.add_tolerance(1e1000, want_rel) + sage: OC.add_tolerance(RIF(1e1000), want_rel) 1.000?e1000 sage: OC.add_tolerance(0, want_tol) 0.000? @@ -956,13 +956,13 @@ def add_tolerance(self, wantval, want): """ if want.tol: if wantval == 0: - return want.tol * RIFtol(-1,1) + return RIFtol(want.tol) * RIFtol(-1,1) else: - return wantval * (1 + want.tol * RIFtol(-1,1)) + return wantval * (1 + RIFtol(want.tol) * RIFtol(-1,1)) elif want.abs_tol: - return wantval + want.abs_tol * RIFtol(-1,1) + return wantval + RIFtol(want.abs_tol) * RIFtol(-1,1) elif want.rel_tol: - return wantval * (1 + want.rel_tol * RIFtol(-1,1)) + return wantval * (1 + RIFtol(want.rel_tol) * RIFtol(-1,1)) else: return wantval diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx index a714b8f14fb..1112255a6d9 100644 --- a/src/sage/rings/complex_arb.pyx +++ b/src/sage/rings/complex_arb.pyx @@ -179,6 +179,7 @@ from sage.rings.integer cimport Integer from sage.rings.polynomial.polynomial_complex_arb cimport Polynomial_complex_arb from sage.rings.real_arb cimport mpfi_to_arb, arb_to_mpfi from sage.rings.real_arb import RealBallField +from sage.rings.real_mpfi cimport RealIntervalField_class from sage.rings.real_mpfr cimport RealField_class, RealField, RealNumber from sage.rings.ring import Field from sage.structure.element cimport Element, ModuleElement @@ -187,7 +188,7 @@ from sage.structure.unique_representation import UniqueRepresentation from sage.arith.long cimport is_small_python_int from sage.rings.complex_mpfr import ComplexField -from sage.rings.complex_interval_field import ComplexIntervalField +from sage.rings.complex_interval_field import ComplexIntervalField, ComplexIntervalField_class from sage.rings.integer_ring import ZZ cdef void ComplexIntervalFieldElement_to_acb( @@ -829,9 +830,9 @@ class ComplexBallField(UniqueRepresentation, Field): cdef bint real = False if ring is None: ring = self - elif isinstance(ring, ComplexBallField): + elif isinstance(ring, (ComplexBallField, ComplexIntervalField_class)): pass - elif isinstance(ring, RealBallField): + elif isinstance(ring, (RealBallField, RealIntervalField_class)): real = True elif ring.has_coerce_map_from(self): pass diff --git a/src/sage/rings/complex_interval.pyx b/src/sage/rings/complex_interval.pyx index b3030f0cec1..e732148a9a0 100644 --- a/src/sage/rings/complex_interval.pyx +++ b/src/sage/rings/complex_interval.pyx @@ -96,7 +96,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement): EXAMPLES:: sage: I = CIF.gen() - sage: b = 1.5 + 2.5*I + sage: b = 3/2 + 5/2*I sage: TestSuite(b).run() """ def __cinit__(self, parent, *args): @@ -1677,7 +1677,7 @@ cdef class ComplexIntervalFieldElement(sage.structure.element.FieldElement): 1.570796326794897? sage: (-i).argument() -1.570796326794897? - sage: (RR('-0.001') - i).argument() + sage: (-1/1000 - i).argument() -1.571796326461564? sage: CIF(2).argument() 0 diff --git a/src/sage/rings/complex_interval_field.py b/src/sage/rings/complex_interval_field.py index eb515c0f837..98882f57329 100644 --- a/src/sage/rings/complex_interval_field.py +++ b/src/sage/rings/complex_interval_field.py @@ -477,12 +477,13 @@ def _coerce_map_from_(self, S): - anything that canonically coerces to the real interval field with this precision + - some exact or lazy parents representing subsets of the complex + numbers, such as ``QQbar`` and ``CLF``. + EXAMPLES:: sage: CIF((2,1)) + 2 + I # indirect doctest 4 + 2*I - sage: CIF((2,1)) + RR.pi() - 5.1415926535897932? + 1*I sage: CIF((2,1)) + CC.pi() Traceback (most recent call last): ... @@ -512,21 +513,29 @@ def _coerce_map_from_(self, S): Conversion via _complex_mpfi_ method map: From: Universal Cyclotomic Field To: Complex Interval Field with 53 bits of precision + + TESTS:: + + sage: CIF.has_coerce_map_from(RR) + False + sage: CIF.has_coerce_map_from(RDF) + False + sage: CIF.has_coerce_map_from(float) + False """ # Direct and efficient conversions - if S is ZZ or S is QQ or S is float: - return True - if S is int: + if S is ZZ or S is QQ or S is int: return True if isinstance(S, (ComplexIntervalField_class, RealIntervalField_class)): return S.precision() >= self._prec - # Assume that a _complex_mpfi_ method always defines a - # coercion (as opposed to only a conversion). - f = self._convert_method_map(S) - if f is not None: - return f + # If coercion to CC is possible and there is a _complex_mpfi_ + # method, assume that it defines a coercion to CIF + if self.middle_field().has_coerce_map_from(S): + f = self._convert_method_map(S) + if f is not None: + return f return self._coerce_map_via( (self.real_field(),), S) diff --git a/src/sage/rings/complex_mpfr.pyx b/src/sage/rings/complex_mpfr.pyx index 4513f7c5568..05616f65644 100644 --- a/src/sage/rings/complex_mpfr.pyx +++ b/src/sage/rings/complex_mpfr.pyx @@ -85,6 +85,7 @@ def late_import(): global AlgebraicNumber_base global AlgebraicNumber global AlgebraicReal + global UniversalCyclotomicField global AA, QQbar, SR global CLF, RLF, CDF if NumberFieldElement_quadratic is None: @@ -96,6 +97,7 @@ def late_import(): AlgebraicNumber_base = sage.rings.qqbar.AlgebraicNumber_base AlgebraicNumber = sage.rings.qqbar.AlgebraicNumber AlgebraicReal = sage.rings.qqbar.AlgebraicReal + from sage.rings.universal_cyclotomic_field import UniversalCyclotomicField AA = sage.rings.qqbar.AA QQbar = sage.rings.qqbar.QQbar import sage.symbolic.ring @@ -558,6 +560,13 @@ class ComplexField_class(ring.Field): return None if S in [AA, QQbar, CLF, RLF]: return self._generic_coerce_map(S) + # Needed to discover the correct coerce map. Without this, the maps + # (direct or via QQbar, with slightly different behavior wrt imaginary + # parts of real elements) that get picked for conversion from UCF both + # to CC and to other types of complex fields depend in which order the + # coercions are discovered. + if isinstance(S, UniversalCyclotomicField): + return self._generic_coerce_map(S) return self._coerce_map_via([CLF], S) def _repr_(self): diff --git a/src/sage/rings/polynomial/binary_form_reduce.py b/src/sage/rings/polynomial/binary_form_reduce.py index a96f5a30854..e7e8e4a8359 100644 --- a/src/sage/rings/polynomial/binary_form_reduce.py +++ b/src/sage/rings/polynomial/binary_form_reduce.py @@ -231,13 +231,13 @@ def covariant_z0(F, z0_cov=False, prec=53, emb=None, error_limit=0.000001): w = z v0 = v0 - NJinv*G.subs({u: v0[0], t: v0[1]}) z = v0[1].constant_coefficient() + v0[0].constant_coefficient()*CF.gen(0) - err = z.diameter() # precision - zz = (w - z).abs() # difference in w and z + err = z.diameter() # precision + zz = (w - z).abs().lower() # difference in w and z else: # despite there is no break, this happens if err > error_limit or err.is_NaN(): raise ValueError("accuracy of Newton's root not within tolerance(%s > %s), increase precision" % (err, error_limit)) - if z.imag() <= z.diameter(): + if z.imag().upper() <= z.diameter(): raise ArithmeticError("Newton's method converged to z not in the upper half plane") z = z.center() diff --git a/src/sage/rings/polynomial/complex_roots.py b/src/sage/rings/polynomial/complex_roots.py index 51e5e4112a9..bcb4bbfdcf3 100644 --- a/src/sage/rings/polynomial/complex_roots.py +++ b/src/sage/rings/polynomial/complex_roots.py @@ -181,9 +181,9 @@ def complex_roots(p, skip_squarefree=False, retval='interval', min_prec=0): [(-14.61803398874990?..., 1), (-12.3819660112501...? + 0.?e-27*I, 1)] sage: sorted((v[0][0].real(),v[1][0].real())) [-14.61803398874989?, -12.3819660112501...?] - sage: v[0][0].imag() < 1e25 + sage: v[0][0].imag().upper() < 1e25 True - sage: v[1][0].imag() < 1e25 + sage: v[1][0].imag().upper() < 1e25 True sage: K. = QuadraticField(-1) diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py index 5aee59a518e..f3d3f0e6a83 100644 --- a/src/sage/rings/qqbar.py +++ b/src/sage/rings/qqbar.py @@ -6869,9 +6869,9 @@ def _real_refine_interval(self, interval, prec): newton_lower = not newton_lower if newton_lower: - interval = interval.intersection(l - pl/slope) + interval = interval.intersection(field(l) - pl/slope) else: - interval = interval.intersection(u - pu/slope) + interval = interval.intersection(field(u) - pu/slope) new_diam = interval.diameter() if new_diam == 0: diff --git a/src/sage/rings/real_mpfi.pyx b/src/sage/rings/real_mpfi.pyx index 24c652f9958..63088668638 100644 --- a/src/sage/rings/real_mpfi.pyx +++ b/src/sage/rings/real_mpfi.pyx @@ -115,7 +115,7 @@ satisfying, but we have chosen the latter. sage: a = R(1.25) sage: a.str(style='brackets') '[1.2 .. 1.3]' - sage: a == 1.25 + sage: a == 5/4 True sage: a == 2 False @@ -228,21 +228,17 @@ specified if given a non-interval and an interval:: sage: val.overlaps(ref) # known bug False -TESTS: - -Comparisons with numpy types are right (see :trac:`17758` and :trac:`18076`):: +TESTS:: sage: import numpy - sage: RIF(0,1) < numpy.float('2') - True - sage: RIF(0,1) <= numpy.float('1') - True - sage: RIF(0,1) <= numpy.float('0.5') - False sage: RIF(2) == numpy.int8('2') True sage: numpy.int8('2') == RIF(2) True + sage: RIF(0,1) < numpy.float('2') + Traceback (most recent call last): + ... + TypeError: unsupported operand parent(s) for <: ... """ # **************************************************************************** @@ -269,6 +265,7 @@ from sage.arith.constants cimport LOG_TEN_TWO_PLUS_EPSILON cimport sage.structure.element from sage.structure.element cimport RingElement, Element, ModuleElement +from sage.structure.element cimport have_same_parent from sage.structure.parent cimport Parent from sage.structure.richcmp cimport richcmp @@ -289,6 +286,7 @@ import operator from sage.cpython.string cimport char_to_str, bytes_to_str +from sage.misc.superseded import deprecation import sage.rings.infinity #***************************************************************************** @@ -759,14 +757,11 @@ cdef class RealIntervalField_class(Field): - this mpfi field itself - - any mpfr real field with precision that is as large as this - one - - any other mpfi real field with precision that is as large as this one - - anything that canonically coerces to the mpfr real field - with same precision as ``self``. + - some exact or lazy parents representing subsets of the real + numbers, such as ``ZZ``, ``QQ``, ``AA``, and ``RLF``. Values which can be exactly represented as a floating-point number are coerced to a precise interval, with upper and lower bounds @@ -781,12 +776,13 @@ cdef class RealIntervalField_class(Field): To: Real Interval Field with 53 bits of precision sage: phi(3^100) 5.153775207320114?e47 - sage: phi = RIF.coerce_map_from(float); phi - Coercion map: - From: Set of Python objects of class 'float' + + :: + + sage: phi = RIF.coerce_map_from(AA); phi + Conversion via _real_mpfi_ method map: + From: Algebraic Real Field To: Real Interval Field with 53 bits of precision - sage: phi(math.pi) - 3.1415926535897932? Coercion can decrease precision, but not increase it:: @@ -794,35 +790,29 @@ cdef class RealIntervalField_class(Field): Coercion map: From: Real Interval Field with 100 bits of precision To: Real Interval Field with 53 bits of precision - sage: phi = RIF.coerce_map_from(RealField(100)); phi - Coercion map: - From: Real Field with 100 bits of precision - To: Real Interval Field with 53 bits of precision sage: print(RIF.coerce_map_from(RealIntervalField(20))) None - sage: print(RIF.coerce_map_from(RealField(20))) - None - :: + There are no coercions from plain floating-point numbers to intervals + (otherwise the rounding errors resulting from floating-point operations + could easily lead to incorrect interval results):: - sage: phi = RIF.coerce_map_from(AA); phi - Conversion via _real_mpfi_ method map: - From: Algebraic Real Field - To: Real Interval Field with 53 bits of precision + sage: RIF.has_coerce_map_from(RR) + False + sage: RIF.has_coerce_map_from(RDF) + False + sage: RIF.has_coerce_map_from(float) + False """ prec = self.__prec # Direct and efficient conversions if S is ZZ or S is QQ: return True - if S is float or S is int or S is long: + if S is int or S is long: return True if isinstance(S, RealIntervalField_class): return (S).__prec >= prec - if isinstance(S, RealField_class): - return (S).__prec >= prec - if S is RDF: - return 53 >= prec from .number_field.number_field import NumberField_quadratic if isinstance(S, NumberField_quadratic): return S.discriminant() > 0 @@ -2550,7 +2540,7 @@ cdef class RealIntervalFieldElement(RingElement): sage: I = RIF(e, pi) sage: a, b = I.bisection() - sage: a.intersection(b) == I.center() + sage: a.intersection(b) == RIF(I.center()) True sage: a.union(b).endpoints() == I.endpoints() True @@ -2580,6 +2570,107 @@ cdef class RealIntervalFieldElement(RingElement): # Basic Arithmetic ######################## + def __add__(left, right): + r""" + TESTS:: + + sage: RIF(1) + RR(1) + doctest:...: + DeprecationWarning: automatic conversions from floating-point numbers to intervals are deprecated + See http://trac.sagemath.org/15114 for details. + 2 + sage: import warnings; warnings.resetwarnings() + """ + cdef RealIntervalFieldElement _left = ( left) + if have_same_parent(left, right): + return _left._add_(right) + if (type(right) is RealNumber + and _left._parent.prec() <= right.parent().prec()): + deprecation(15114, "automatic conversions from floating-point " + "numbers to intervals are deprecated") + return left + _left._parent(right) + elif isinstance(left, RealIntervalFieldElement): + return Element.__add__(left, right) + else: + return Element.__radd__(right, left) + + def __sub__(left, right): + r""" + TESTS:: + + sage: RIF(2) - RR(1) + doctest:...: + DeprecationWarning: automatic conversions from floating-point numbers to intervals are deprecated + See http://trac.sagemath.org/15114 for details. + 1 + sage: import warnings; warnings.resetwarnings() + """ + cdef RealIntervalFieldElement _left = ( left) + if have_same_parent(left, right): + return _left._sub_(right) + if (type(right) is RealNumber + and _left._parent.prec() <= right.parent().prec()): + deprecation(15114, "automatic conversions from floating-point " + "numbers to intervals are deprecated") + return left - _left._parent(right) + elif isinstance(left, RealIntervalFieldElement): + return Element.__sub__(left, right) + else: + return Element.__rsub__(right, left) + + def __mul__(left, right): + r""" + TESTS:: + + sage: RIF(1) * RR(1) + doctest:...: + DeprecationWarning: automatic conversions from floating-point numbers to intervals are deprecated + See http://trac.sagemath.org/15114 for details. + 1 + sage: import warnings; warnings.resetwarnings() + """ + cdef RealIntervalFieldElement _left = ( left) + if have_same_parent(left, right): + return _left._mul_(right) + if (type(right) is RealNumber + and _left._parent.prec() <= right.parent().prec()): + deprecation(15114, "automatic conversions from floating-point " + "numbers to intervals are deprecated") + return left * _left._parent(right) + elif isinstance(left, RealIntervalFieldElement): + return Element.__mul__(left, right) + else: + return Element.__rmul__(right, left) + + def __truediv__(left, right): + r""" + TESTS:: + + sage: RIF(1) / RR(1/2) + doctest:...: + DeprecationWarning: automatic conversions from floating-point numbers to intervals are deprecated + See http://trac.sagemath.org/15114 for details. + 2 + sage: import warnings; warnings.resetwarnings() + """ + cdef RealIntervalFieldElement _left = ( left) + if have_same_parent(left, right): + return _left._div_(right) + if (type(right) is RealNumber + and _left._parent.prec() <= right.parent().prec()): + deprecation(15114, "automatic conversions from floating-point " + "numbers to intervals are deprecated") + return left / _left._parent(right) + elif (type(left) is RealNumber + and left.parent().prec() >= right.parent().prec()): + deprecation(15114, "automatic conversions from floating-point " + "numbers to intervals are deprecated") + return right.parent()(left)/right + elif isinstance(left, RealIntervalFieldElement): + return Element.__truediv__(left, right) + else: + return Element.__rtruediv__(right, left) + cpdef _add_(self, other): """ Add two real intervals with the same parent. @@ -4385,7 +4476,7 @@ cdef class RealIntervalFieldElement(RingElement): sage: r = RIF(16.0); r.log10() 1.204119982655925? - sage: r.log() / log(10.0) + sage: r.log() / RIF(10).log() 1.204119982655925? :: @@ -4976,7 +5067,8 @@ cdef class RealIntervalFieldElement(RingElement): -3.54490770181104? sage: gamma(-1/2).n(100) in RIF(-1/2).gamma() True - sage: 0 in (RealField(2000)(-19/3).gamma() - RealIntervalField(1000)(-19/3).gamma()) + sage: RIF1000 = RealIntervalField(1000) + sage: 0 in (RIF1000(RealField(2000)(-19/3).gamma()) - RIF1000(-19/3).gamma()) True sage: gamma(RIF(100)) 9.33262154439442?e155 @@ -5005,7 +5097,7 @@ cdef class RealIntervalFieldElement(RingElement): [-infinity .. +infinity] """ x = self._new() - if self > 1.462: + if self.lower() > 1.462: # increasing mpfr_gamma(&x.value.left, &self.value.left, MPFR_RNDD) mpfr_gamma(&x.value.right, &self.value.right, MPFR_RNDU) @@ -5017,7 +5109,7 @@ cdef class RealIntervalFieldElement(RingElement): elif self.contains_zero(): # [-infinity, infinity] return ~self - elif self < 1.461: + elif self.upper() < 1.461: # 0 < self as well, so decreasing mpfr_gamma(&x.value.left, &self.value.right, MPFR_RNDD) mpfr_gamma(&x.value.right, &self.value.left, MPFR_RNDU) diff --git a/src/sage/rings/real_mpfr.pyx b/src/sage/rings/real_mpfr.pyx index 7f5b64a4f41..c8e60361c3c 100644 --- a/src/sage/rings/real_mpfr.pyx +++ b/src/sage/rings/real_mpfr.pyx @@ -133,6 +133,7 @@ from sage.cpython.string cimport char_to_str, str_to_bytes from sage.misc.superseded import deprecation from sage.structure.element cimport RingElement, Element, ModuleElement +from sage.structure.element cimport have_same_parent from sage.structure.richcmp cimport rich_to_bool_sgn, rich_to_bool cdef bin_op from sage.structure.element import bin_op @@ -2377,6 +2378,90 @@ cdef class RealNumber(sage.structure.element.RingElement): # Basic Arithmetic ######################## + def __add__(left, right): + r""" + TESTS:: + + sage: RR(1) + RIF(1) + doctest:...: + DeprecationWarning: automatic conversions from floating-point numbers to intervals are deprecated + See http://trac.sagemath.org/15114 for details. + 2 + sage: import warnings; warnings.resetwarnings() + """ + if have_same_parent(left, right): + return ( left)._add_(right) + from .real_mpfi import RealIntervalFieldElement + if type(right) is RealIntervalFieldElement: + return right.__add__(left) + elif isinstance(left, RealNumber): + return Element.__add__(left, right) + else: + return Element.__add__(right, left) + + def __sub__(left, right): + r""" + TESTS:: + + sage: RR(2) - RIF(1) + doctest:...: + DeprecationWarning: automatic conversions from floating-point numbers to intervals are deprecated + See http://trac.sagemath.org/15114 for details. + 1 + sage: import warnings; warnings.resetwarnings() + """ + if have_same_parent(left, right): + return ( left)._sub_(right) + from .real_mpfi import RealIntervalFieldElement + if type(right) is RealIntervalFieldElement: + return (-right).__add__(left) + elif isinstance(left, RealNumber): + return Element.__sub__(left, right) + else: + return Element.__rsub__(right, left) + + def __mul__(left, right): + r""" + TESTS:: + + sage: RR(1) * RIF(1) + doctest:...: + DeprecationWarning: automatic conversions from floating-point numbers to intervals are deprecated + See http://trac.sagemath.org/15114 for details. + 1 + sage: import warnings; warnings.resetwarnings() + """ + if have_same_parent(left, right): + return ( left)._mul_(right) + from .real_mpfi import RealIntervalFieldElement + if type(right) is RealIntervalFieldElement: + return right.__mul__(left) + elif isinstance(left, RealNumber): + return Element.__mul__(left, right) + else: + return Element.__rmul__(right, left) + + def __truediv__(left, right): + r""" + TESTS:: + + sage: RR(1) / RIF(1/2) + doctest:...: + DeprecationWarning: automatic conversions from floating-point numbers to intervals are deprecated + See http://trac.sagemath.org/15114 for details. + 2 + sage: import warnings; warnings.resetwarnings() + """ + if have_same_parent(left, right): + return ( left)._div_(right) + from .real_mpfi import RealIntervalFieldElement + if type(right) is RealIntervalFieldElement: + return right.__rtruediv__(left) + elif isinstance(left, RealNumber): + return Element.__truediv__(left, right) + else: + return Element.__rtruediv__(right, left) + cpdef _add_(self, other): """ Add two real numbers with the same parent. diff --git a/src/sage/rings/universal_cyclotomic_field.py b/src/sage/rings/universal_cyclotomic_field.py index 2c7e09e0ed2..9c7ed719378 100644 --- a/src/sage/rings/universal_cyclotomic_field.py +++ b/src/sage/rings/universal_cyclotomic_field.py @@ -256,7 +256,7 @@ class UCFtoQQbar(Morphism): -0.500000000000000? + 0.866025403784439?*I sage: CC(UCF.gen(7,2) + UCF.gen(7,6)) - 0.400968867902419 + 0.193096429713794*I + 0.400968867902419 + 0.193096429713793*I sage: complex(E(7)+E(7,2)) (0.40096886790241915+1.7567593946498534j) diff --git a/src/sage/schemes/elliptic_curves/heegner.py b/src/sage/schemes/elliptic_curves/heegner.py index 859227c23c2..e0f6f9c6b91 100644 --- a/src/sage/schemes/elliptic_curves/heegner.py +++ b/src/sage/schemes/elliptic_curves/heegner.py @@ -6765,7 +6765,7 @@ def _adjust_heegner_index(self, a): EXAMPLES:: sage: E = EllipticCurve('11a1') - sage: a = RIF(sqrt(2))-1.4142135623730951 + sage: a = RIF(sqrt(2))-RIF(1.4142135623730951) sage: E._adjust_heegner_index(a) 1.?e-8 """ diff --git a/src/sage/schemes/elliptic_curves/height.py b/src/sage/schemes/elliptic_curves/height.py index d02885cb935..858946c5bb7 100644 --- a/src/sage/schemes/elliptic_curves/height.py +++ b/src/sage/schemes/elliptic_curves/height.py @@ -1709,7 +1709,7 @@ def complex_intersection_is_empty(self, Bk, v, verbose=False, use_half=True): break else: z = CIF(intersection.innermost_point()) - if all(wp((k+1)*z) < B for k, B in enumerate(bounds)): + if all(wp((k+1)*z).upper() < B for k, B in enumerate(bounds)): return False # Now try to prove a positive result. @@ -1719,6 +1719,7 @@ def complex_intersection_is_empty(self, Bk, v, verbose=False, use_half=True): for B, n in sorted(zip(bounds, ZZ.range(1, k+1))): T = PeriodicRegion(CDF(1), CDF(tau), vals < B, full=not use_half).expand().refine() + B = RIF(B) leaning_right = tau.real() / tau.imag() >= 0 def check_line(z): wpz = wp(z) diff --git a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx index f58258de2b3..f308727efdb 100644 --- a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx +++ b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx @@ -168,7 +168,7 @@ cdef class PeriodicRegion: sage: S = PeriodicRegion(CDF(1), CDF(I), data) sage: S.border() [(1, 1, 0), (2, 1, 0), (1, 1, 1), (1, 2, 1)] - sage: condition = lambda z: z.real().abs()<0.5 + sage: condition = lambda z: z.real().abs()<1/2 sage: S.verify(condition) False sage: condition = lambda z: z.real().abs()<1 diff --git a/src/sage/schemes/elliptic_curves/sha_tate.py b/src/sage/schemes/elliptic_curves/sha_tate.py index 2bc2f07e189..54e59169987 100644 --- a/src/sage/schemes/elliptic_curves/sha_tate.py +++ b/src/sage/schemes/elliptic_curves/sha_tate.py @@ -1023,7 +1023,7 @@ def bound_kolyvagin(self, D=0, regulator=None, hZ = regulator/2 else: hZ = F.regulator(use_database=True)/2 - I = RIF(alpha) * RIF(LE1-err_E, LE1+err_E) * RIF(LF1-err_F, LF1+err_F) / hZ + I = RIF(alpha) * RIF(LE1-err_E, LE1+err_E) * RIF(LF1-err_F, LF1+err_F) / RIF(hZ) else: # E has odd rank @@ -1037,7 +1037,7 @@ def bound_kolyvagin(self, D=0, regulator=None, err_E = max(err_E, MIN_ERR) # I = alpha * LE1 * LF1 / hZ - I = RIF(alpha) * RIF(LE1-err_E, LE1+err_E) * RIF(LF1-err_F, LF1+err_F) / hZ + I = RIF(alpha) * RIF(LE1-err_E, LE1+err_E) * RIF(LF1-err_F, LF1+err_F) / RIF(hZ) verbose('interval = %s' % I) t, n = I.is_int()