From 51c045c8f6de0f16e1bb3d7901cd60d0d3cc7368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Wed, 6 Nov 2024 20:23:24 -0300 Subject: [PATCH 1/4] Fix doctests for pari 2.17 on 32-bit --- src/sage/calculus/calculus.py | 3 +- src/sage/doctest/sources.py | 4 +-- src/sage/interfaces/gp.py | 42 +++++++++----------------- src/sage/interfaces/interface.py | 3 +- src/sage/interfaces/mathematica.py | 3 +- src/sage/interfaces/mathics.py | 3 +- src/sage/interfaces/maxima_abstract.py | 3 +- src/sage/libs/pari/__init__.py | 5 ++- src/sage/libs/pari/tests.py | 11 +++---- src/sage/symbolic/constants.py | 9 ++---- src/sage/symbolic/expression.pyx | 3 +- 11 files changed, 31 insertions(+), 58 deletions(-) diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py index ef4854db676..fc4e92396f0 100644 --- a/src/sage/calculus/calculus.py +++ b/src/sage/calculus/calculus.py @@ -793,8 +793,7 @@ def nintegral(ex, x, a, b, to high precision:: sage: gp.eval('intnum(x=17,42,exp(-x^2)*log(x))') - '2.565728500561051474934096410 E-127' # 32-bit - '2.5657285005610514829176211363206621657 E-127' # 64-bit + '2.5657285005610514829176211363206621657 E-127' sage: old_prec = gp.set_real_precision(50) sage: gp.eval('intnum(x=17,42,exp(-x^2)*log(x))') '2.5657285005610514829173563961304957417746108003917 E-127' diff --git a/src/sage/doctest/sources.py b/src/sage/doctest/sources.py index 7589f62922b..9807c1d5e12 100644 --- a/src/sage/doctest/sources.py +++ b/src/sage/doctest/sources.py @@ -766,11 +766,11 @@ def create_doctests(self, namespace): sage: import sys sage: bitness = '64' if sys.maxsize > (1 << 32) else '32' - sage: gp.get_precision() == 38 # needs sage.libs.pari + sage: sys.maxsize == 2^63 - 1 False # 32-bit True # 64-bit sage: ex = doctests[20].examples[11] - sage: ((bitness == '64' and ex.want == 'True \n') # needs sage.libs.pari + sage: ((bitness == '64' and ex.want == 'True \n') ....: or (bitness == '32' and ex.want == 'False \n')) True diff --git a/src/sage/interfaces/gp.py b/src/sage/interfaces/gp.py index b98c050d889..712a37a6dc6 100644 --- a/src/sage/interfaces/gp.py +++ b/src/sage/interfaces/gp.py @@ -48,11 +48,9 @@ :: sage: gp("a = intnum(x=0,6,sin(x))") - 0.03982971334963397945434770208 # 32-bit - 0.039829713349633979454347702077075594548 # 64-bit + 0.039829713349633979454347702077075594548 sage: gp("a") - 0.03982971334963397945434770208 # 32-bit - 0.039829713349633979454347702077075594548 # 64-bit + 0.039829713349633979454347702077075594548 sage: gp.kill("a") sage: gp("a") a @@ -375,8 +373,7 @@ def get_precision(self): EXAMPLES:: sage: gp.get_precision() - 28 # 32-bit - 38 # 64-bit + 38 """ return self.get_default('realprecision') @@ -396,15 +393,13 @@ def set_precision(self, prec): EXAMPLES:: sage: old_prec = gp.set_precision(53); old_prec - 28 # 32-bit - 38 # 64-bit + 38 sage: gp.get_precision() 57 sage: gp.set_precision(old_prec) 57 sage: gp.get_precision() - 28 # 32-bit - 38 # 64-bit + 38 """ return self.set_default('realprecision', prec) @@ -520,8 +515,7 @@ def set_default(self, var, value): sage: gp.set_default('realprecision', old_prec) 115 sage: gp.get_default('realprecision') - 28 # 32-bit - 38 # 64-bit + 38 """ old = self.get_default(var) self._eval_line('default(%s,%s)' % (var, value)) @@ -547,8 +541,7 @@ def get_default(self, var): sage: gp.get_default('seriesprecision') 16 sage: gp.get_default('realprecision') - 28 # 32-bit - 38 # 64-bit + 38 """ return eval(self._eval_line('default(%s)' % var)) @@ -773,8 +766,7 @@ def _exponent_symbol(self): :: sage: repr(gp(10.^80)).replace(gp._exponent_symbol(), 'e') - '1.0000000000000000000000000000000000000e80' # 64-bit - '1.000000000000000000000000000e80' # 32-bit + '1.0000000000000000000000000000000000000e80' """ return ' E' @@ -800,18 +792,15 @@ def new_with_bits_prec(self, s, precision=0): sage: # needs sage.symbolic sage: pi_def = gp(pi); pi_def - 3.141592653589793238462643383 # 32-bit - 3.1415926535897932384626433832795028842 # 64-bit + 3.1415926535897932384626433832795028842 sage: pi_def.precision() - 28 # 32-bit - 38 # 64-bit + 38 sage: pi_150 = gp.new_with_bits_prec(pi, 150) sage: new_prec = pi_150.precision(); new_prec 48 # 32-bit 57 # 64-bit sage: old_prec = gp.set_precision(new_prec); old_prec - 28 # 32-bit - 38 # 64-bit + 38 sage: pi_150 3.14159265358979323846264338327950288419716939938 # 32-bit 3.14159265358979323846264338327950288419716939937510582098 # 64-bit @@ -819,8 +808,7 @@ def new_with_bits_prec(self, s, precision=0): 48 # 32-bit 57 # 64-bit sage: gp.get_precision() - 28 # 32-bit - 38 # 64-bit + 38 """ if precision: old_prec = self.get_real_precision() @@ -856,11 +844,9 @@ class GpElement(ExpectElement, sage.interfaces.abc.GpElement): sage: loads(dumps(x)) == x False sage: x - 1.047197551196597746154214461 # 32-bit - 1.0471975511965977461542144610931676281 # 64-bit + 1.0471975511965977461542144610931676281 sage: loads(dumps(x)) - 1.047197551196597746154214461 # 32-bit - 1.0471975511965977461542144610931676281 # 64-bit + 1.0471975511965977461542144610931676281 The two elliptic curves look the same, but internally the floating point numbers are slightly different. diff --git a/src/sage/interfaces/interface.py b/src/sage/interfaces/interface.py index 6f2fb118968..4a1884fad02 100644 --- a/src/sage/interfaces/interface.py +++ b/src/sage/interfaces/interface.py @@ -1045,8 +1045,7 @@ def _sage_repr(self): :: sage: gp(10.^80)._sage_repr() - '1.0000000000000000000000000000000000000e80' # 64-bit - '1.000000000000000000000000000e80' # 32-bit + '1.0000000000000000000000000000000000000e80' sage: mathematica('10.^80')._sage_repr() # optional - mathematica '1.e80' diff --git a/src/sage/interfaces/mathematica.py b/src/sage/interfaces/mathematica.py index 39c3aff9dc2..8f3b4a8ba63 100644 --- a/src/sage/interfaces/mathematica.py +++ b/src/sage/interfaces/mathematica.py @@ -187,8 +187,7 @@ Note that this agrees with what the PARI interpreter gp produces:: sage: gp('solve(x=1,2,exp(x)-3*x)') - 1.512134551657842473896739678 # 32-bit - 1.5121345516578424738967396780720387046 # 64-bit + 1.5121345516578424738967396780720387046 Next we find the minimum of a polynomial using the two different ways of accessing Mathematica:: diff --git a/src/sage/interfaces/mathics.py b/src/sage/interfaces/mathics.py index a6d39ad3c14..bd192c8f676 100644 --- a/src/sage/interfaces/mathics.py +++ b/src/sage/interfaces/mathics.py @@ -196,8 +196,7 @@ Note that this agrees with what the PARI interpreter gp produces:: sage: gp('solve(x=1,2,exp(x)-3*x)') - 1.512134551657842473896739678 # 32-bit - 1.5121345516578424738967396780720387046 # 64-bit + 1.5121345516578424738967396780720387046 Next we find the minimum of a polynomial using the two different ways of accessing Mathics:: diff --git a/src/sage/interfaces/maxima_abstract.py b/src/sage/interfaces/maxima_abstract.py index b8df280857c..234e9373fca 100644 --- a/src/sage/interfaces/maxima_abstract.py +++ b/src/sage/interfaces/maxima_abstract.py @@ -1489,8 +1489,7 @@ def nintegral(self, var='x', a=0, b=1, high precision very quickly:: sage: gp('intnum(x=0,1,exp(-sqrt(x)))') - 0.5284822353142307136179049194 # 32-bit - 0.52848223531423071361790491935415653022 # 64-bit + 0.52848223531423071361790491935415653022 sage: _ = gp.set_precision(80) sage: gp('intnum(x=0,1,exp(-sqrt(x)))') 0.52848223531423071361790491935415653021675547587292866196865279321015401702040079 diff --git a/src/sage/libs/pari/__init__.py b/src/sage/libs/pari/__init__.py index ccb18792918..c0f6515685a 100644 --- a/src/sage/libs/pari/__init__.py +++ b/src/sage/libs/pari/__init__.py @@ -165,12 +165,11 @@ sage: e = pari([0,0,0,-82,0]).ellinit() sage: eta1 = e.elleta(precision=50)[0] sage: eta1.sage() - 3.6054636014326520859158205642077267748 # 64-bit - 3.605463601432652085915820564 # 32-bit + 3.6054636014326520859158205642077267748 sage: eta1 = e.elleta(precision=150)[0] sage: eta1.sage() 3.605463601432652085915820564207726774810268996598024745444380641429820491740 # 64-bit - 3.60546360143265208591582056420772677481026899659802474544 # 32-bit + 3.605463601432652085915820564207726774810268996598024745444380641430 # 32-bit """ def _get_pari_instance(): diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py index bd8dc9641d2..38fee89202b 100644 --- a/src/sage/libs/pari/tests.py +++ b/src/sage/libs/pari/tests.py @@ -94,8 +94,7 @@ [4, 2] sage: int(pari(RealField(63)(2^63 - 1))) # needs sage.rings.real_mpfr - 9223372036854775807 # 32-bit - 9223372036854775807 # 64-bit + 9223372036854775807 sage: int(pari(RealField(63)(2^63 + 2))) # needs sage.rings.real_mpfr 9223372036854775810 @@ -1231,8 +1230,7 @@ sage: e.ellheight([1,0]) 0.476711659343740 sage: e.ellheight([1,0], precision=128).sage() - 0.47671165934373953737948605888465305945902294218 # 32-bit - 0.476711659343739537379486058884653059459022942211150879336 # 64-bit + 0.476711659343739537379486058884653059459022942211150879336 sage: e.ellheight([1, 0], [-1, 1]) 0.418188984498861 @@ -1806,12 +1804,11 @@ sage: e = pari([0,0,0,-82,0]).ellinit() sage: eta1 = e.elleta(precision=50)[0] sage: eta1.sage() - 3.6054636014326520859158205642077267748 # 64-bit - 3.605463601432652085915820564 # 32-bit + 3.6054636014326520859158205642077267748 sage: eta1 = e.elleta(precision=150)[0] sage: eta1.sage() 3.605463601432652085915820564207726774810268996598024745444380641429820491740 # 64-bit - 3.60546360143265208591582056420772677481026899659802474544 # 32-bit + 3.605463601432652085915820564207726774810268996598024745444380641430 # 32-bit sage: from cypari2 import Pari sage: pari = Pari() diff --git a/src/sage/symbolic/constants.py b/src/sage/symbolic/constants.py index 20a293fbb7b..dac8c4bc833 100644 --- a/src/sage/symbolic/constants.py +++ b/src/sage/symbolic/constants.py @@ -38,8 +38,7 @@ sage: gap(pi) pi sage: gp(pi) - 3.141592653589793238462643383 # 32-bit - 3.1415926535897932384626433832795028842 # 64-bit + 3.1415926535897932384626433832795028842 sage: pari(pi) 3.14159265358979 sage: kash(pi) # optional - kash @@ -63,8 +62,7 @@ sage: RealField(15)(a) # 15 *bits* of precision 5.316 sage: gp(a) - 5.316218116357029426750873360 # 32-bit - 5.3162181163570294267508733603616328824 # 64-bit + 5.3162181163570294267508733603616328824 sage: print(mathematica(a)) # optional - mathematica 4 E --- + Pi @@ -882,8 +880,7 @@ class Log2(Constant): sage: maxima(log2).float() 0.6931471805599453 sage: gp(log2) - 0.6931471805599453094172321215 # 32-bit - 0.69314718055994530941723212145817656807 # 64-bit + 0.69314718055994530941723212145817656807 sage: RealField(150)(2).log() 0.69314718055994530941723212145817656807550013 """ diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx index 52da8232dc6..f0d888c2a01 100644 --- a/src/sage/symbolic/expression.pyx +++ b/src/sage/symbolic/expression.pyx @@ -9798,8 +9798,7 @@ cdef class Expression(Expression_abc): :: sage: gp('gamma(1+I)') - 0.4980156681183560427136911175 - 0.1549498283018106851249551305*I # 32-bit - 0.49801566811835604271369111746219809195 - 0.15494982830181068512495513048388660520*I # 64-bit + 0.49801566811835604271369111746219809195 - 0.15494982830181068512495513048388660520*I We plot the familiar plot of this log-convex function:: From a4d1efb81a795e7d08b23ce695102adbeff9556f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Wed, 6 Nov 2024 22:43:13 -0300 Subject: [PATCH 2/4] make reduced_basis() deterministic for pari 2.17 --- src/sage/rings/number_field/number_field.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index 3cffd4ce062..ae583e4db6a 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -6514,12 +6514,12 @@ def reduced_basis(self, prec=None): sage: k. = NumberField(x^6 + 2218926655879913714112*x^4 - 32507675650290949030789018433536*x^3 + 4923635504174417014460581055002374467948544*x^2 - 36066074010564497464129951249279114076897746988630016*x + 264187244046129768986806800244258952598300346857154900812365824) sage: new_basis = k.reduced_basis(prec=120) sage: [c.minpoly() for c in new_basis] - [x^2 + x + 1, - x - 1, - x^6 + 3*x^5 - 102*x^4 - 315*x^3 + 10254*x^2 + 80955*x + 198147, - x^6 + 213*x^4 + 12567*x^2 + 198147, - x^6 + 171*x^4 - 1696*x^3 + 29241*x^2 - 145008*x + 719104, - x^6 + 171*x^4 - 1696*x^3 + 29241*x^2 - 145008*x + 719104] + [x - 1, + x^2 + x + 1, + x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657, + x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657, + x^3 - 171*x + 848, + x^6 + 171*x^4 + 1696*x^3 + 29241*x^2 + 145008*x + 719104] sage: R = k.order(new_basis) sage: R.discriminant()==k.discriminant() True @@ -6531,13 +6531,15 @@ def reduced_basis(self, prec=None): # the inner product on the Minkowski embedding, which is # faster than computing all the conjugates, etc ... + # flag to disable FLATTER, which is much more unstable than fplll + flag = 1 if pari.version() >= (2,17) else 0 if self.is_totally_real(): from sage.matrix.constructor import matrix M = matrix(ZZ, d, d, [[(x*y).trace() for x in ZK] for y in ZK]) - T = pari(M).qflllgram() + T = pari(M).qflllgram(flag=flag) else: M = self.minkowski_embedding(ZK, prec=prec) - T = pari(M).qflll() + T = pari(M).qflll(flag=flag) return [sum([ZZ(T[i][j]) * ZK[j] for j in range(d)]) for i in range(d)] From bcb9c3d5ffd682c04040bcff82e7d9c423f18a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Thu, 7 Nov 2024 11:01:11 -0300 Subject: [PATCH 3/4] make pari_bnf() deterministic for pari 2.17 --- src/sage/rings/number_field/number_field.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index ae583e4db6a..9add6e91e3e 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -4440,10 +4440,14 @@ def pari_bnf(self, proof=None, units=True): bnf = self._pari_bnf except AttributeError: f = self.pari_polynomial("y") + _saved_rand = pari.getrand() + # make this deterministic, it affects printing of ideals + pari.setrand(1) if units: self._pari_bnf = f.bnfinit(1) else: self._pari_bnf = f.bnfinit() + pari.setrand(_saved_rand) bnf = self._pari_bnf # Certify if needed if proof and not getattr(self, "_pari_bnf_certified", False): From a5c65e198acd280fc5e25eadf63f189cbb4aa233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Thu, 7 Nov 2024 11:45:05 -0300 Subject: [PATCH 4/4] Fix doctests for 'make pari_bnf() deterministic' --- .../arithmetic_dynamics/berkovich_ds.py | 4 +-- src/sage/rings/finite_rings/residue_field.pyx | 12 +++---- src/sage/rings/integer.pyx | 2 +- src/sage/rings/number_field/S_unit_solver.py | 36 +++++++++---------- src/sage/rings/number_field/class_group.py | 4 +-- src/sage/rings/number_field/number_field.py | 2 +- .../number_field/number_field_element.pyx | 4 +-- .../number_field/number_field_ideal_rel.py | 6 ++-- src/sage/rings/number_field/order.py | 8 ++--- src/sage/rings/number_field/selmer_group.py | 6 ++-- .../polynomial/polynomial_quotient_ring.py | 2 +- src/sage/rings/rational.pyx | 4 +-- src/sage/schemes/berkovich/berkovich_space.py | 2 +- .../schemes/plane_conics/con_number_field.py | 2 +- 14 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py index d3f9c3cdf41..4de0e8f6158 100644 --- a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py @@ -690,10 +690,10 @@ def conjugate(self, M, adjugate=False, new_ideal=None): sage: # needs sage.rings.number_field sage: ideal = A.ideal(5).factor()[1][0]; ideal - Fractional ideal (-a + 2) + Fractional ideal (-2*a - 1) sage: g = f.conjugate(conj, new_ideal=ideal) sage: g.domain().ideal() - Fractional ideal (-a + 2) + Fractional ideal (-2*a - 1) """ if self.domain().is_padic_base(): return DynamicalSystem_Berkovich(self._system.conjugate(M, adjugate=adjugate)) diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx index 4d484603df8..e85444cef11 100644 --- a/src/sage/rings/finite_rings/residue_field.pyx +++ b/src/sage/rings/finite_rings/residue_field.pyx @@ -495,9 +495,9 @@ class ResidueField_generic(Field): sage: # needs sage.rings.number_field sage: I = QQ[i].factor(2)[0][0]; I - Fractional ideal (-I - 1) + Fractional ideal (I - 1) sage: k = I.residue_field(); k - Residue field of Fractional ideal (-I - 1) + Residue field of Fractional ideal (I - 1) sage: type(k) @@ -1007,7 +1007,7 @@ cdef class ReductionMap(Map): sage: cr Partially defined reduction map: From: Number Field in a with defining polynomial x^2 + 1 - To: Residue field of Fractional ideal (-a + 1) + To: Residue field of Fractional ideal (a - 1) sage: cr == r # not implemented True sage: r(2 + a) == cr(2 + a) @@ -1038,7 +1038,7 @@ cdef class ReductionMap(Map): sage: cr Partially defined reduction map: From: Number Field in a with defining polynomial x^2 + 1 - To: Residue field of Fractional ideal (-a + 1) + To: Residue field of Fractional ideal (a - 1) sage: cr == r # not implemented True sage: r(2 + a) == cr(2 + a) @@ -1070,7 +1070,7 @@ cdef class ReductionMap(Map): sage: r = F.reduction_map(); r Partially defined reduction map: From: Number Field in a with defining polynomial x^2 + 1 - To: Residue field of Fractional ideal (-a + 1) + To: Residue field of Fractional ideal (a - 1) We test that calling the function also works after copying:: @@ -1082,7 +1082,7 @@ cdef class ReductionMap(Map): Traceback (most recent call last): ... ZeroDivisionError: Cannot reduce field element 1/2*a - modulo Fractional ideal (-a + 1): it has negative valuation + modulo Fractional ideal (a - 1): it has negative valuation sage: # needs sage.rings.finite_rings sage: R. = GF(2)[]; h = t^5 + t^2 + 1 diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx index 86cbb05c6bf..ffc5ee16e0f 100644 --- a/src/sage/rings/integer.pyx +++ b/src/sage/rings/integer.pyx @@ -5585,7 +5585,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement): sage: 5.is_norm(K) False sage: n.is_norm(K, element=True) - (True, 4*beta + 6) + (True, -4*beta + 6) sage: n.is_norm(K, element=True)[1].norm() 4 sage: n = 5 diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py index 1260650ef77..836edae5464 100644 --- a/src/sage/rings/number_field/S_unit_solver.py +++ b/src/sage/rings/number_field/S_unit_solver.py @@ -1381,7 +1381,7 @@ def defining_polynomial_for_Kp(prime, prec=106): sage: from sage.rings.number_field.S_unit_solver import defining_polynomial_for_Kp sage: K. = QuadraticField(2) sage: p2 = K.prime_above(7); p2 - Fractional ideal (-2*a + 1) + Fractional ideal (2*a - 1) sage: defining_polynomial_for_Kp(p2, 10) x + 266983762 @@ -2170,23 +2170,23 @@ def construct_complement_dictionaries(split_primes_list, SUK, verbose=False): sage: SUK = K.S_unit_group(S=K.primes_above(H)) sage: split_primes_list = [3, 7] sage: actual = construct_complement_dictionaries(split_primes_list, SUK) - sage: expected = {3: {(1, 1, 0): [(1, 0, 0), (1, 1, 0)], - ....: (1, 0, 0): [(1, 0, 0), (1, 1, 0)]}, - ....: 7: {(1, 1, 0): [(1, 0, 0), (1, 4, 4), (1, 2, 2)], - ....: (1, 3, 2): [(1, 0, 0), (1, 4, 4), (1, 2, 2)], - ....: (1, 5, 4): [(1, 0, 0), (1, 4, 4), (1, 2, 2)], - ....: (1, 0, 4): [(1, 2, 4), (1, 4, 0), (1, 0, 2)], - ....: (1, 2, 0): [(1, 2, 4), (1, 4, 0), (1, 0, 2)], - ....: (1, 4, 2): [(1, 2, 4), (1, 4, 0), (1, 0, 2)], - ....: (1, 1, 2): [(1, 1, 2), (1, 3, 4), (1, 5, 0)], - ....: (1, 3, 4): [(1, 1, 2), (1, 3, 4), (1, 5, 0)], - ....: (1, 5, 0): [(1, 1, 2), (1, 3, 4), (1, 5, 0)], - ....: (1, 0, 2): [(1, 0, 4), (1, 4, 2), (1, 2, 0)], - ....: (1, 2, 4): [(1, 0, 4), (1, 4, 2), (1, 2, 0)], - ....: (1, 4, 0): [(1, 0, 4), (1, 4, 2), (1, 2, 0)], - ....: (1, 0, 0): [(1, 5, 4), (1, 3, 2), (1, 1, 0)], - ....: (1, 2, 2): [(1, 5, 4), (1, 3, 2), (1, 1, 0)], - ....: (1, 4, 4): [(1, 5, 4), (1, 3, 2), (1, 1, 0)]}} + sage: expected = {3: {(0, 1, 0): [(0, 1, 0), (1, 0, 0)], + ....: (1, 0, 0): [(0, 1, 0), (1, 0, 0)]}, + ....: 7: {(0, 1, 0): [(1, 0, 0), (1, 2, 2), (1, 4, 4)], + ....: (0, 1, 2): [(0, 1, 2), (0, 3, 4), (0, 5, 0)], + ....: (0, 3, 2): [(1, 0, 0), (1, 2, 2), (1, 4, 4)], + ....: (0, 3, 4): [(0, 1, 2), (0, 3, 4), (0, 5, 0)], + ....: (0, 5, 0): [(0, 1, 2), (0, 3, 4), (0, 5, 0)], + ....: (0, 5, 4): [(1, 0, 0), (1, 2, 2), (1, 4, 4)], + ....: (1, 0, 0): [(0, 1, 0), (0, 3, 2), (0, 5, 4)], + ....: (1, 0, 2): [(1, 0, 4), (1, 2, 0), (1, 4, 2)], + ....: (1, 0, 4): [(1, 0, 2), (1, 2, 4), (1, 4, 0)], + ....: (1, 2, 0): [(1, 0, 2), (1, 2, 4), (1, 4, 0)], + ....: (1, 2, 2): [(0, 1, 0), (0, 3, 2), (0, 5, 4)], + ....: (1, 2, 4): [(1, 0, 4), (1, 2, 0), (1, 4, 2)], + ....: (1, 4, 0): [(1, 0, 4), (1, 2, 0), (1, 4, 2)], + ....: (1, 4, 2): [(1, 0, 2), (1, 2, 4), (1, 4, 0)], + ....: (1, 4, 4): [(0, 1, 0), (0, 3, 2), (0, 5, 4)]}} sage: all(set(actual[p][vec]) == set(expected[p][vec]) ....: for p in [3, 7] for vec in expected[p]) True diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py index 34a48931f8e..046209ad314 100644 --- a/src/sage/rings/number_field/class_group.py +++ b/src/sage/rings/number_field/class_group.py @@ -524,9 +524,9 @@ def gens_ideals(self): Class group of order 68 with structure C34 x C2 of Number Field in a with defining polynomial x^2 + x + 23899 sage: C.gens() - (Fractional ideal class (7, a + 5), Fractional ideal class (5, a + 3)) + (Fractional ideal class (83, a + 21), Fractional ideal class (15, a + 8)) sage: C.gens_ideals() - (Fractional ideal (7, a + 5), Fractional ideal (5, a + 3)) + (Fractional ideal (83, a + 21), Fractional ideal (15, a + 8)) """ return self.gens_values() diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index 9add6e91e3e..57263c839ea 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -7136,7 +7136,7 @@ def units(self, proof=None): sage: K. = NumberField(1/2*x^2 - 1/6) sage: K.units() - (-3*a + 2,) + (3*a + 2,) """ proof = proof_flag(proof) diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx index 1a676ee087b..a22b68e6093 100644 --- a/src/sage/rings/number_field/number_field_element.pyx +++ b/src/sage/rings/number_field/number_field_element.pyx @@ -1954,7 +1954,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + 1) sage: (6*i + 6).factor() - (i) * (-i - 1)^3 * 3 + (i - 1)^3 * 3 In the following example, the class number is 2. If a factorization in prime elements exists, we will find it:: @@ -2043,7 +2043,7 @@ cdef class NumberFieldElement(NumberFieldElement_base): 0 sage: R = K.maximal_order() sage: R(i+1).gcd(2) - i + 1 + i - 1 sage: R = K.order(2*i) sage: R(1).gcd(R(4*i)) 1 diff --git a/src/sage/rings/number_field/number_field_ideal_rel.py b/src/sage/rings/number_field/number_field_ideal_rel.py index eb39f6f4d12..11b59d593ec 100644 --- a/src/sage/rings/number_field/number_field_ideal_rel.py +++ b/src/sage/rings/number_field/number_field_ideal_rel.py @@ -189,7 +189,7 @@ def absolute_ideal(self, names='a'): sage: J.absolute_norm() 2 sage: J.ideal_below() - Fractional ideal (b) + Fractional ideal (-b) sage: J.ideal_below().norm() 2 """ @@ -385,7 +385,7 @@ def relative_norm(self): sage: K. = NumberField(x^2 + 6) sage: L. = K.extension(K['x'].gen()^4 + a) sage: N = L.ideal(b).relative_norm(); N - Fractional ideal (a) + Fractional ideal (-a) sage: N.parent() Monoid of ideals of Number Field in a with defining polynomial x^2 + 6 sage: N.ring() @@ -916,7 +916,7 @@ def is_NumberFieldFractionalIdeal_rel(x): sage: is_NumberFieldFractionalIdeal_rel(I) True sage: N = I.relative_norm(); N - Fractional ideal (a) + Fractional ideal (-a) sage: is_NumberFieldFractionalIdeal_rel(N) False """ diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py index 3c2809f4201..04afae98241 100644 --- a/src/sage/rings/number_field/order.py +++ b/src/sage/rings/number_field/order.py @@ -496,7 +496,7 @@ def fractional_ideal(self, *args, **kwds): sage: K. = NumberField(x^2 + 2) sage: R = K.maximal_order() sage: R.fractional_ideal(2/3 + 7*a, a) - Fractional ideal (-1/3*a) + Fractional ideal (1/3*a) """ return self.number_field().fractional_ideal(*args, **kwds) @@ -570,7 +570,7 @@ def __mul__(self, right): sage: k. = NumberField(x^2 + 5077); G = k.class_group(); G Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077 sage: G.0 ^ -9 - Fractional ideal class (67, a + 45) + Fractional ideal class (43, a + 13) sage: Ok = k.maximal_order(); Ok Maximal Order generated by a in Number Field in a with defining polynomial x^2 + 5077 sage: Ok * (11, a + 7) @@ -2933,7 +2933,7 @@ def GaussianIntegers(names='I', latex_name='i'): sage: ZZI Gaussian Integers generated by I in Number Field in I with defining polynomial x^2 + 1 with I = 1*I sage: factor(3 + I) - (-I) * (I - 2) * (-I + 1) + (-2*I - 1) * (I - 1) sage: CC(I) 1.00000000000000*I sage: I.minpoly() @@ -2964,7 +2964,7 @@ def EisensteinIntegers(names='omega'): with defining polynomial x^2 + x + 1 with omega = -0.50000000000000000? + 0.866025403784439?*I sage: factor(3 + omega) - (omega + 1) * (-2*omega + 1) + (omega) * (-3*omega - 2) sage: CC(omega) -0.500000000000000 + 0.866025403784439*I sage: omega.minpoly() diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py index c6054b6824f..a940c95731d 100644 --- a/src/sage/rings/number_field/selmer_group.py +++ b/src/sage/rings/number_field/selmer_group.py @@ -489,9 +489,9 @@ def pSelmerGroup(K, S, p, proof=None, debug=False): 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] + Fractional ideal (-a), + (Fractional ideal (2, a + 1))^2, + 1] sage: toKS2(10) (0, 0, 1, 1) diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index ae3a4b5254c..3a498a6736c 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -1877,7 +1877,7 @@ def selmer_generators(self, S, m, proof=True): sage: D.selmer_generators([K.ideal(2, -a + 1), ....: K.ideal(3, a + 1), ....: K.ideal(a)], 3) - [2, a + 1, -a] + [2, a + 1, a] """ fields, isos, iso_classes = self._S_decomposition(tuple(S)) n = len(fields) diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx index b1d9e64bae0..dab13ccc48b 100644 --- a/src/sage/rings/rational.pyx +++ b/src/sage/rings/rational.pyx @@ -1446,7 +1446,7 @@ cdef class Rational(sage.structure.element.FieldElement): sage: 0.is_norm(K) True sage: (1/7).is_norm(K, element=True) - (True, -3/7*beta + 5/7) + (True, 1/7*beta + 3/7) sage: (1/10).is_norm(K, element=True) (False, None) sage: (1/691).is_norm(QQ, element=True) @@ -1558,7 +1558,7 @@ cdef class Rational(sage.structure.element.FieldElement): EXAMPLES:: sage: QQ(2)._bnfisnorm(QuadraticField(-1, 'i')) # needs sage.rings.number_field - (-i + 1, 1) + (i - 1, 1) sage: x = polygen(QQ, 'x') sage: 7._bnfisnorm(NumberField(x^3 - 2, 'b')) # needs sage.rings.number_field (1, 7) diff --git a/src/sage/schemes/berkovich/berkovich_space.py b/src/sage/schemes/berkovich/berkovich_space.py index f5455937b43..1330c408f4a 100755 --- a/src/sage/schemes/berkovich/berkovich_space.py +++ b/src/sage/schemes/berkovich/berkovich_space.py @@ -201,7 +201,7 @@ def ideal(self): sage: ideal = A.prime_above(5) sage: B = Berkovich_Cp_Projective(A, ideal) sage: B.ideal() - Fractional ideal (-a - 2) + Fractional ideal (2*a - 1) :: diff --git a/src/sage/schemes/plane_conics/con_number_field.py b/src/sage/schemes/plane_conics/con_number_field.py index 69fe9960c3d..2b084b57dc6 100755 --- a/src/sage/schemes/plane_conics/con_number_field.py +++ b/src/sage/schemes/plane_conics/con_number_field.py @@ -121,7 +121,7 @@ def has_rational_point(self, point=False, obstruction=False, sage: K. = QuadraticField(-1) sage: C = Conic(K, [1, 3, -5]) sage: C.has_rational_point(point=True, obstruction=True) - (False, Fractional ideal (i + 2)) + (False, Fractional ideal (2*i - 1)) sage: C.has_rational_point(algorithm='rnfisnorm') False sage: C.has_rational_point(algorithm='rnfisnorm', obstruction=True,