diff --git a/src/sage/modular/abvar/homspace.py b/src/sage/modular/abvar/homspace.py index 6d96cc0fabe..8e89399d611 100644 --- a/src/sage/modular/abvar/homspace.py +++ b/src/sage/modular/abvar/homspace.py @@ -148,14 +148,15 @@ :: - sage: T = E.image_of_hecke_algebra() # long time - sage: T.gens() # long time + sage: # long time + sage: T = E.image_of_hecke_algebra() + sage: T.gens() (Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, Abelian variety endomorphism of Abelian variety J0(33) of dimension 3, Abelian variety endomorphism of Abelian variety J0(33) of dimension 3) - sage: T.index_in(E) # long time + sage: T.index_in(E) +Infinity - sage: T.index_in_saturation() # long time + sage: T.index_in_saturation() 1 AUTHORS: diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py index 7e8ffa6658c..8d8b580a74e 100644 --- a/src/sage/modular/cusps_nf.py +++ b/src/sage/modular/cusps_nf.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.number_field r""" The set `\mathbb{P}^1(K)` of cusps of a number field `K` @@ -62,7 +63,7 @@ sage: Gamma0_NFCusps(N) [Cusp [0: 1] of Number Field in a with defining polynomial x^2 + 5, - Cusp [1: 3] of Number Field in a with defining polynomial x^2 + 5, + Cusp [1: 3] of Number Field in a with defining polynomial x^2 + 5, ...] """ # **************************************************************************** @@ -859,7 +860,7 @@ def ABmatrix(self): sage: M = alpha.ABmatrix() sage: M # random [-a^2 - a - 1, -3*a - 7, 8, -2*a^2 - 3*a + 4] - sage: M[0] == alpha.numerator() and M[2]==alpha.denominator() + sage: M[0] == alpha.numerator() and M[2] == alpha.denominator() True An AB-matrix associated to a cusp alpha will send Infinity to alpha: @@ -870,7 +871,7 @@ def ABmatrix(self): sage: M = alpha.ABmatrix() sage: (k.ideal(M[1], M[3])*alpha.ideal()).is_principal() True - sage: M[0] == alpha.numerator() and M[2]==alpha.denominator() + sage: M[0] == alpha.numerator() and M[2] == alpha.denominator() True sage: NFCusp(k, oo).apply(M) == alpha True @@ -1249,7 +1250,8 @@ def units_mod_ideal(I): sage: from sage.modular.cusps_nf import units_mod_ideal sage: k. = NumberField(x^3 + 11) sage: k.unit_group() - Unit group with structure C2 x Z of Number Field in a with defining polynomial x^3 + 11 + Unit group with structure C2 x Z of + Number Field in a with defining polynomial x^3 + 11 sage: I = k.ideal(5, a + 1) sage: units_mod_ideal(I) [1, @@ -1261,7 +1263,8 @@ def units_mod_ideal(I): sage: from sage.modular.cusps_nf import units_mod_ideal sage: k. = NumberField(x^4 - x^3 -21*x^2 + 17*x + 133) sage: k.unit_group() - Unit group with structure C6 x Z of Number Field in a with defining polynomial x^4 - x^3 - 21*x^2 + 17*x + 133 + Unit group with structure C6 x Z of + Number Field in a with defining polynomial x^4 - x^3 - 21*x^2 + 17*x + 133 sage: I = k.ideal(3) sage: U = units_mod_ideal(I) sage: all(U[j].is_unit() and (U[j] not in I) for j in range(len(U))) diff --git a/src/sage/modular/modform/element.py b/src/sage/modular/modform/element.py index fba61a0fdd8..6d10fdf47c3 100644 --- a/src/sage/modular/modform/element.py +++ b/src/sage/modular/modform/element.py @@ -2315,13 +2315,14 @@ def minimal_twist(self, p=None): sage: f.twist(chi, level=11) == g True - sage: f = Newforms(575, 2, names='a')[4] # long time - sage: g, chi = f.minimal_twist(5) # long time - sage: g # long time + sage: # long time + sage: f = Newforms(575, 2, names='a')[4] + sage: g, chi = f.minimal_twist(5) + sage: g q + a*q^2 - a*q^3 - 2*q^4 + (1/2*a + 2)*q^5 + O(q^6) - sage: chi # long time + sage: chi Dirichlet character modulo 5 of conductor 5 mapping 2 |--> 1/2*a - sage: f.twist(chi, level=g.level()) == g # long time + sage: f.twist(chi, level=g.level()) == g True """ if p is None: diff --git a/src/sage/modular/modform_hecketriangle/analytic_type.py b/src/sage/modular/modform_hecketriangle/analytic_type.py index 7b2618991df..0c809b3328c 100644 --- a/src/sage/modular/modform_hecketriangle/analytic_type.py +++ b/src/sage/modular/modform_hecketriangle/analytic_type.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.graphs r""" Analytic types of modular forms diff --git a/src/sage/modular/overconvergent/weightspace.py b/src/sage/modular/overconvergent/weightspace.py index 8f0ecc8b8c0..e9478c40a90 100644 --- a/src/sage/modular/overconvergent/weightspace.py +++ b/src/sage/modular/overconvergent/weightspace.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.rings.padics r""" The space of `p`-adic weights @@ -17,7 +17,8 @@ sage: W = pAdicWeightSpace(17) sage: W - Space of 17-adic weight-characters defined over 17-adic Field with capped relative precision 20 + Space of 17-adic weight-characters + defined over 17-adic Field with capped relative precision 20 sage: R. = QQ[] sage: L = Qp(17).extension(x^2 - 17, names='a'); L.rename('L') sage: W.base_extend(L) @@ -101,7 +102,8 @@ def WeightSpace_constructor(p, base_ring=None): EXAMPLES:: sage: pAdicWeightSpace(3) # indirect doctest - Space of 3-adic weight-characters defined over 3-adic Field with capped relative precision 20 + Space of 3-adic weight-characters + defined over 3-adic Field with capped relative precision 20 sage: pAdicWeightSpace(3, QQ) Space of 3-adic weight-characters defined over Rational Field sage: pAdicWeightSpace(10) @@ -248,11 +250,13 @@ def base_extend(self, R): sage: W = pAdicWeightSpace(3, QQ) sage: W.base_extend(Qp(3)) - Space of 3-adic weight-characters defined over 3-adic Field with capped relative precision 20 + Space of 3-adic weight-characters + defined over 3-adic Field with capped relative precision 20 sage: W.base_extend(IntegerModRing(12)) Traceback (most recent call last): ... - TypeError: No coercion map from 'Rational Field' to 'Ring of integers modulo 12' is defined + TypeError: No coercion map from 'Rational Field' + to 'Ring of integers modulo 12' is defined """ if R.has_coerce_map_from(self.base_ring()): return WeightSpace_constructor(self.prime(), R) @@ -356,7 +360,9 @@ def pAdicEisensteinSeries(self, ring, prec=20): sage: kappa = pAdicWeightSpace(3)(3, DirichletGroup(3,QQ).0) sage: kappa.pAdicEisensteinSeries(QQ[['q']], 20) - 1 - 9*q + 27*q^2 - 9*q^3 - 117*q^4 + 216*q^5 + 27*q^6 - 450*q^7 + 459*q^8 - 9*q^9 - 648*q^10 + 1080*q^11 - 117*q^12 - 1530*q^13 + 1350*q^14 + 216*q^15 - 1845*q^16 + 2592*q^17 + 27*q^18 - 3258*q^19 + O(q^20) + 1 - 9*q + 27*q^2 - 9*q^3 - 117*q^4 + 216*q^5 + 27*q^6 - 450*q^7 + 459*q^8 + - 9*q^9 - 648*q^10 + 1080*q^11 - 117*q^12 - 1530*q^13 + 1350*q^14 + 216*q^15 + - 1845*q^16 + 2592*q^17 + 27*q^18 - 3258*q^19 + O(q^20) """ if not self.is_even(): raise ValueError("Eisenstein series not defined for odd weight-characters") @@ -570,7 +576,8 @@ def chi(self): sage: kappa = pAdicWeightSpace(29)(13, DirichletGroup(29, Qp(29)).0^14) sage: kappa.chi() - Dirichlet character modulo 29 of conductor 29 mapping 2 |--> 28 + 28*29 + 28*29^2 + ... + O(29^20) + Dirichlet character modulo 29 of conductor 29 + mapping 2 |--> 28 + 28*29 + 28*29^2 + ... + O(29^20) """ return self._chi @@ -667,7 +674,8 @@ def Lvalue(self): sage: pAdicWeightSpace(7)(5, DirichletGroup(7, Qp(7)).0^4).Lvalue() 0 sage: pAdicWeightSpace(7)(6, DirichletGroup(7, Qp(7)).0^4).Lvalue() - 1 + 2*7 + 7^2 + 3*7^3 + 3*7^5 + 4*7^6 + 2*7^7 + 5*7^8 + 2*7^9 + 3*7^10 + 6*7^11 + 2*7^12 + 3*7^13 + 5*7^14 + 6*7^15 + 5*7^16 + 3*7^17 + 6*7^18 + O(7^19) + 1 + 2*7 + 7^2 + 3*7^3 + 3*7^5 + 4*7^6 + 2*7^7 + 5*7^8 + 2*7^9 + 3*7^10 + 6*7^11 + + 2*7^12 + 3*7^13 + 5*7^14 + 6*7^15 + 5*7^16 + 3*7^17 + 6*7^18 + O(7^19) """ if self._k > 0: return -self._chi.bernoulli(self._k) / self._k diff --git a/src/sage/modular/pollack_stevens/padic_lseries.py b/src/sage/modular/pollack_stevens/padic_lseries.py index 396a96af90e..748b5dc9993 100644 --- a/src/sage/modular/pollack_stevens/padic_lseries.py +++ b/src/sage/modular/pollack_stevens/padic_lseries.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.ring.padics r""" `p`-adic `L`-series attached to overconvergent eigensymbols diff --git a/src/sage/schemes/affine/affine_homset.py b/src/sage/schemes/affine/affine_homset.py index 8c70602ad79..52ea3f83c85 100644 --- a/src/sage/schemes/affine/affine_homset.py +++ b/src/sage/schemes/affine/affine_homset.py @@ -211,8 +211,8 @@ def points(self, **kwds): EXAMPLES: The bug reported at #11526 is fixed:: sage: A2 = AffineSpace(ZZ, 2) - sage: F = GF(3) # optional - sage.rings.finite_rings - sage: A2(F).points() # optional - sage.rings.finite_rings + sage: F = GF(3) + sage: A2(F).points() [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)] :: @@ -228,23 +228,23 @@ def points(self, **kwds): :: sage: u = QQ['u'].0 - sage: K. = NumberField(u^2 + 3) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: len(A(K).points(bound=2)) # optional - sage.rings.number_field + sage: K. = NumberField(u^2 + 3) # needs sage.rings.number_field + sage: A. = AffineSpace(K, 2) # needs sage.rings.number_field + sage: len(A(K).points(bound=2)) # needs sage.rings.number_field 1849 :: sage: A. = AffineSpace(QQ, 2) sage: E = A.subscheme([x^2 + y^2 - 1, y^2 - x^3 + x^2 + x - 1]) - sage: E(A.base_ring()).points() + sage: E(A.base_ring()).points() # needs sage.libs.singular [(-1, 0), (0, -1), (0, 1), (1, 0)] :: - sage: A. = AffineSpace(CC, 2) + sage: A. = AffineSpace(CC, 2) # needs sage.rings.real_mpfr sage: E = A.subscheme([y^3 - x^3 - x^2, x*y]) - sage: E(A.base_ring()).points() + sage: E(A.base_ring()).points() # needs sage.libs.singular sage.rings.real_mpfr verbose 0 (...: affine_homset.py, points) Warning: computations in the numerical fields are inexact;points may be computed partially or incorrectly. @@ -253,9 +253,9 @@ def points(self, **kwds): :: - sage: A. = AffineSpace(CDF, 2) - sage: E = A.subscheme([x1^2 + x2^2 + x1*x2, x1 + x2]) - sage: E(A.base_ring()).points() + sage: A. = AffineSpace(CDF, 2) # needs sage.rings.complex_double + sage: E = A.subscheme([x1^2 + x2^2 + x1*x2, x1 + x2]) # needs sage.libs.singular sage.rings.complex_double + sage: E(A.base_ring()).points() # needs sage.libs.singular sage.rings.complex_double verbose 0 (...: affine_homset.py, points) Warning: computations in the numerical fields are inexact;points may be computed partially or incorrectly. @@ -393,28 +393,29 @@ def numerical_points(self, F=None, **kwds): EXAMPLES:: - sage: K. = QuadraticField(3) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: X = A.subscheme([x^3 - v^2*y, y - v*x^2 + 3]) # optional - sage.rings.number_field - sage: L = X(K).numerical_points(F=RR); L # abs tol 1e-14 # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(3) + sage: A. = AffineSpace(K, 2) + sage: X = A.subscheme([x^3 - v^2*y, y - v*x^2 + 3]) + sage: L = X(K).numerical_points(F=RR); L # abs tol 1e-14 [(-1.18738247880014, -0.558021142104134), (1.57693558184861, 1.30713548084184), (4.80659931965815, 37.0162574656220)] - sage: L[0].codomain() # optional - sage.rings.number_field + sage: L[0].codomain() Affine Space of dimension 2 over Real Field with 53 bits of precision :: sage: A. = AffineSpace(QQ, 2) sage: X = A.subscheme([y^2 - x^2 - 3*x, x^2 - 10*y]) - sage: len(X(QQ).numerical_points(F=ComplexField(100))) + sage: len(X(QQ).numerical_points(F=ComplexField(100))) # needs sage.libs.singular 4 :: sage: A. = AffineSpace(QQ, 2) sage: E = A.subscheme([30*x1^100 + 1000*x2^2 + 2000*x1*x2 + 1, x1 + x2]) - sage: len(E(A.base_ring()).numerical_points(F=CDF, zero_tolerance=1e-9)) + sage: len(E(A.base_ring()).numerical_points(F=CDF, zero_tolerance=1e-9)) # needs sage.libs.singular 100 TESTS:: @@ -430,7 +431,7 @@ def numerical_points(self, F=None, **kwds): sage: A. = AffineSpace(QQ, 2) sage: X = A.subscheme([y^2 - x^2 - 3*x, x^2 - 10*y]) - sage: X(QQ).numerical_points(F=CC, zero_tolerance=-1) + sage: X(QQ).numerical_points(F=CC, zero_tolerance=-1) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: tolerance must be positive diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py index d16d5ec37fc..1fc3f207464 100644 --- a/src/sage/schemes/affine/affine_morphism.py +++ b/src/sage/schemes/affine/affine_morphism.py @@ -156,8 +156,8 @@ def __init__(self, parent, polys, check=True): sage: A. = AffineSpace(QQ, 3) sage: X = A.subscheme([x - y]) sage: H = Hom(X, X) - sage: u,v,w = X.coordinate_ring().gens() - sage: H([u, v, u + v]) + sage: u,v,w = X.coordinate_ring().gens() # needs sage.libs.singular + sage: H([u, v, u + v]) # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: x - y Defn: Defined on coordinates by sending (x, y, z) to (y, y, 2*y) @@ -167,8 +167,8 @@ def __init__(self, parent, polys, check=True): sage: A. = AffineSpace(QQ, 3) sage: X = A.subscheme([x^2 - y^2]) sage: H = Hom(X, X) - sage: u,v,w = X.coordinate_ring().gens() - sage: H([u, v, (u+1)/v]) + sage: u,v,w = X.coordinate_ring().gens() # needs sage.libs.singular + sage: H([u, v, (u+1)/v]) # needs sage.libs.singular Traceback (most recent call last): ... ArithmeticError: Division failed. The numerator is not a multiple of the denominator. @@ -249,13 +249,14 @@ def __call__(self, x, check=True): Defn: Defined on coordinates by sending (u, v) to (u + v, u*v) - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P = T(F)(1, a) # optional - sage.rings.finite_rings - sage: h(P) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P = T(F)(1, a) + sage: h(P) (a + 1, a) - sage: h(P).domain() # optional - sage.rings.finite_rings + sage: h(P).domain() Spectrum of Finite Field in a of size 2^2 - sage: h.change_ring(F)(P) # optional - sage.rings.finite_rings + sage: h.change_ring(F)(P) (a + 1, a) """ from sage.schemes.affine.affine_point import SchemeMorphism_point_affine @@ -298,6 +299,7 @@ def __eq__(self, right): :: + sage: # needs sage.rings.real_mpfr sage: A. = AffineSpace(CC, 3) sage: H = End(A) sage: f = H([x^2 - CC.0*x*y + z*x, 1/z^2 - y^2, 5*x]) @@ -324,6 +326,7 @@ def __ne__(self, right): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: A. = AffineSpace(RR, 2) sage: H = End(A) sage: f = H([x^2 - y, y^2]) @@ -458,6 +461,7 @@ def homogenize(self, n): :: + sage: # needs sage.rings.real_mpfr sage: A. = AffineSpace(CC, 2) sage: H = Hom(A, A) sage: f = H([(x^2-2)/(x*y), y^2 - x]) @@ -473,7 +477,7 @@ def homogenize(self, n): sage: X = A.subscheme([x - y^2]) sage: H = Hom(X, X) sage: f = H([9*y^2, 3*y]) - sage: f.homogenize(2) + sage: f.homogenize(2) # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Projective Space of dimension 2 over Integer Ring defined by: x1^2 - x0*x2 Defn: Defined on coordinates by sending (x0 : x1 : x2) to @@ -503,11 +507,12 @@ def homogenize(self, n): :: - sage: R. = PolynomialRing(QQbar) # optional - sage.rings.number_field - sage: A. = AffineSpace(R, 2) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([QQbar(sqrt(2))*x*y, a*x^2]) # optional - sage.rings.number_field sage.symbolic - sage: f.homogenize(2) # optional - sage.rings.number_field sage.symbolic + sage: # needs sage.rings.number_field + sage: R. = PolynomialRing(QQbar) + sage: A. = AffineSpace(R, 2) + sage: H = End(A) + sage: f = H([QQbar(sqrt(2))*x*y, a*x^2]) # needs sage.symbolic + sage: f.homogenize(2) # needs sage.libs.singular sage.symbolic Scheme endomorphism of Projective Space of dimension 2 over Univariate Polynomial Ring in a over Algebraic Field Defn: Defined on coordinates by sending (x0 : x1 : x2) to @@ -534,10 +539,11 @@ def homogenize(self, n): :: - sage: A. = AffineSpace(QQbar, 1) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([2*z / (z^2 + 2*z + 3)]) # optional - sage.rings.number_field - sage: f.homogenize(1) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: A. = AffineSpace(QQbar, 1) + sage: H = End(A) + sage: f = H([2*z / (z^2 + 2*z + 3)]) + sage: f.homogenize(1) Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x0 : x1) to @@ -545,11 +551,12 @@ def homogenize(self, n): :: - sage: R. = QQbar[] # optional - sage.rings.number_field - sage: A. = AffineSpace(R, 1) # optional - sage.rings.number_field - sage: H = Hom(A, A) # optional - sage.rings.number_field - sage: F = H([d*x^2 + c]) # optional - sage.rings.number_field - sage: F.homogenize(1) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: R. = QQbar[] + sage: A. = AffineSpace(R, 1) + sage: H = Hom(A, A) + sage: F = H([d*x^2 + c]) + sage: F.homogenize(1) Scheme endomorphism of Projective Space of dimension 1 over Multivariate Polynomial Ring in c, d over Algebraic Field Defn: Defined on coordinates by sending (x0 : x1) to @@ -640,7 +647,7 @@ def as_dynamical_system(self): sage: A. = AffineSpace(ZZ, 3) sage: H = End(A) sage: f = H([x^2, y^2, z^2]) - sage: type(f.as_dynamical_system()) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: @@ -648,23 +655,23 @@ def as_dynamical_system(self): sage: A. = AffineSpace(ZZ, 2) sage: H = End(A) sage: f = H([x^2 - y^2, y^2]) - sage: type(f.as_dynamical_system()) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: - sage: A. = AffineSpace(GF(5), 1) # optional - sage.rings.finite_rings - sage: H = End(A) # optional - sage.rings.finite_rings - sage: f = H([x^2]) # optional - sage.rings.finite_rings - sage: type(f.as_dynamical_system()) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(5), 1) + sage: H = End(A) + sage: f = H([x^2]) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: sage: P. = AffineSpace(RR, 2) - sage: f = DynamicalSystem([x^2 + y^2, y^2], P) - sage: g = f.as_dynamical_system() - sage: g is f + sage: f = DynamicalSystem([x^2 + y^2, y^2], P) # needs sage.schemes + sage: g = f.as_dynamical_system() # needs sage.schemes + sage: g is f # needs sage.schemes True """ from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem @@ -699,17 +706,18 @@ def global_height(self, prec=None): sage: A. = AffineSpace(QQ, 1) sage: H = Hom(A, A) sage: f = H([1/1331*x^2 + 4000]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 15.4877354584971 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: k. = NumberField(x^2 + 5) # optional - sage.rings.number_field - sage: A. = AffineSpace(k, 2) # optional - sage.rings.number_field - sage: H = Hom(A, A) # optional - sage.rings.number_field - sage: f = H([13*w*x^2 + 4*y, 1/w*y^2]) # optional - sage.rings.number_field - sage: f.global_height(prec=2) # optional - sage.rings.number_field + sage: k. = NumberField(x^2 + 5) + sage: A. = AffineSpace(k, 2) + sage: H = Hom(A, A) + sage: f = H([13*w*x^2 + 4*y, 1/w*y^2]) + sage: f.global_height(prec=2) 4.0 :: @@ -717,7 +725,7 @@ def global_height(self, prec=None): sage: A. = AffineSpace(ZZ, 1) sage: H = Hom(A, A) sage: f = H([7*x^2 + 1513]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 7.32184971378836 :: @@ -726,7 +734,7 @@ def global_height(self, prec=None): sage: B. = AffineSpace(QQ, 2) sage: H = Hom(A, B) sage: f = H([1/3*x^2 + 10, 7*x^3]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 3.40119738166216 :: @@ -735,7 +743,7 @@ def global_height(self, prec=None): sage: A. = AffineSpace(QQ, 1) sage: H = Hom(P, A) sage: f = H([1/1331*x^2 + 4000*y]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 15.4877354584971 """ return self.homogenize(0).global_height(prec=prec) @@ -761,7 +769,7 @@ def local_height(self, v, prec=None): sage: P. = AffineSpace(QQ, 2) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]) - sage: f.local_height(1331) + sage: f.local_height(1331) # needs sage.rings.real_mpfr 7.19368581839511 :: @@ -769,7 +777,7 @@ def local_height(self, v, prec=None): sage: P. = AffineSpace(QQ, 3) sage: H = Hom(P, P) sage: f = H([4*x^2 + 3/100*y^2, 8/210*x*y, 1/10000*z^2]) - sage: f.local_height(2) + sage: f.local_height(2) # needs sage.rings.real_mpfr 2.77258872223978 :: @@ -777,17 +785,18 @@ def local_height(self, v, prec=None): sage: P. = AffineSpace(QQ, 3) sage: H = Hom(P, P) sage: f = H([4*x^2 + 3/100*y^2, 8/210*x*y, 1/10000*z^2]) - sage: f.local_height(2, prec=2) + sage: f.local_height(2, prec=2) # needs sage.rings.real_mpfr 3.0 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) # optional - sage.rings.number_field - sage: f.local_height(K.ideal(3)) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = AffineSpace(K, 2) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) + sage: f.local_height(K.ideal(3)) 1.09861228866811 """ K = FractionField(self.domain().base_ring()) @@ -816,7 +825,7 @@ def local_height_arch(self, i, prec=None): sage: P. = AffineSpace(QQ, 2) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]); - sage: f.local_height_arch(0) + sage: f.local_height_arch(0) # needs sage.rings.real_mpfr 5.34710753071747 :: @@ -824,17 +833,18 @@ def local_height_arch(self, i, prec=None): sage: P. = AffineSpace(QQ, 2) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]); - sage: f.local_height_arch(0, prec=5) + sage: f.local_height_arch(0, prec=5) # needs sage.rings.real_mpfr 5.2 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) # optional - sage.rings.number_field - sage: f.local_height_arch(1) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = AffineSpace(K, 2) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) + sage: f.local_height_arch(1) 0.6931471805599453094172321214582 """ K = FractionField(self.domain().base_ring()) @@ -861,7 +871,7 @@ def jacobian(self): sage: A. = AffineSpace(QQ, 1) sage: H = End(A) sage: f = H([z^2 - 3/4]) - sage: f.jacobian() + sage: f.jacobian() # needs sage.modules [2*z] :: @@ -869,7 +879,7 @@ def jacobian(self): sage: A. = AffineSpace(QQ, 2) sage: H = End(A) sage: f = H([x^3 - 25*x + 12*y, 5*y^2*x - 53*y + 24]) - sage: f.jacobian() + sage: f.jacobian() # needs sage.modules [ 3*x^2 - 25 12] [ 5*y^2 10*x*y - 53] @@ -878,7 +888,7 @@ def jacobian(self): sage: A. = AffineSpace(ZZ, 2) sage: H = End(A) sage: f = H([(x^2 - x*y)/(1+y), (5+y)/(2+x)]) - sage: f.jacobian() + sage: f.jacobian() # needs sage.modules [ (2*x - y)/(y + 1) (-x^2 - x)/(y^2 + 2*y + 1)] [ (-y - 5)/(x^2 + 4*x + 4) 1/(x + 2)] """ @@ -904,7 +914,7 @@ def _matrix_times_polymap_(self, mat, h): sage: A. = AffineSpace(ZZ, 1) sage: H = Hom(A, A) sage: f = H([x^2 + 1]) - sage: matrix([[1,2], [0,1]]) * f + sage: matrix([[1,2], [0,1]]) * f # needs sage.modules Scheme endomorphism of Affine Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x) to (x^2 + 3) @@ -915,7 +925,7 @@ def _matrix_times_polymap_(self, mat, h): sage: A2 = AffineSpace(ZZ, 2) sage: H = Hom(A1, A2) sage: f = H([x^2 + 1, x^2 - 1]) - sage: matrix([[1,2,3], [0,1,2], [0,0,1]]) * f + sage: matrix([[1,2,3], [0,1,2], [0,0,1]]) * f # needs sage.modules Scheme morphism: From: Affine Space of dimension 1 over Integer Ring To: Affine Space of dimension 2 over Integer Ring @@ -948,7 +958,7 @@ def _polymap_times_matrix_(self, mat, h): sage: A. = AffineSpace(ZZ, 1) sage: H = Hom(A, A) sage: f = H([x^2 + 1]) - sage: f * matrix([[1,2], [0,1]]) + sage: f * matrix([[1,2], [0,1]]) # needs sage.modules Scheme endomorphism of Affine Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x) to (x^2 + 4*x + 5) @@ -959,7 +969,7 @@ def _polymap_times_matrix_(self, mat, h): sage: A2 = AffineSpace(ZZ, 2) sage: H = Hom(A1, A2) sage: f = H([x^2 + 1, x^2 - 1]) - sage: f * matrix([[1,2], [0,1]]) + sage: f * matrix([[1,2], [0,1]]) # needs sage.modules Scheme morphism: From: Affine Space of dimension 1 over Integer Ring To: Affine Space of dimension 2 over Integer Ring @@ -972,8 +982,8 @@ def _polymap_times_matrix_(self, mat, h): sage: P2. = AffineSpace(QQ, 3) sage: H = Hom(P2, P) sage: f = H([u^2 + v^2, w^2]) - sage: m = matrix([[1,1,1], [1,0,1], [0,0,1]]) - sage: m*f + sage: m = matrix([[1,1,1], [1,0,1], [0,0,1]]) # needs sage.modules + sage: m*f # needs sage.modules Scheme morphism: From: Affine Space of dimension 3 over Rational Field To: Affine Space of dimension 2 over Rational Field @@ -1053,25 +1063,27 @@ def weil_restriction(self): EXAMPLES:: - sage: K. = QuadraticField(5) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([x^2 - y^2, y^2]) # optional - sage.rings.number_field - sage: f.weil_restriction() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(5) + sage: A. = AffineSpace(K, 2) + sage: H = End(A) + sage: f = H([x^2 - y^2, y^2]) + sage: f.weil_restriction() Scheme endomorphism of Affine Space of dimension 4 over Rational Field Defn: Defined on coordinates by sending (z0, z1, z2, z3) to (z0^2 + 5*z1^2 - z2^2 - 5*z3^2, 2*z0*z1 - 2*z2*z3, z2^2 + 5*z3^2, 2*z2*z3) :: - sage: K. = QuadraticField(5) # optional - sage.rings.number_field - sage: PS. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = Hom(PS, PS) # optional - sage.rings.number_field - sage: f = H([x, y]) # optional - sage.rings.number_field - sage: F = f.weil_restriction() # optional - sage.rings.number_field - sage: P = PS(2, 1) # optional - sage.rings.number_field - sage: Q = P.weil_restriction() # optional - sage.rings.number_field - sage: f(P).weil_restriction() == F(Q) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(5) + sage: PS. = AffineSpace(K, 2) + sage: H = Hom(PS, PS) + sage: f = H([x, y]) + sage: F = f.weil_restriction() + sage: P = PS(2, 1) + sage: Q = P.weil_restriction() + sage: f(P).weil_restriction() == F(Q) True """ if any(isinstance(f, FractionFieldElement) for f in self): @@ -1099,25 +1111,26 @@ def reduce_base_field(self): EXAMPLES:: - sage: K. = GF(5^4) # optional - sage.rings.finite_rings - sage: A. = AffineSpace(K, 1) # optional - sage.rings.finite_rings - sage: A2. = AffineSpace(K, 2) # optional - sage.rings.finite_rings - sage: H = End(A) # optional - sage.rings.finite_rings - sage: H2 = Hom(A, A2) # optional - sage.rings.finite_rings - sage: H3 = Hom(A2, A) # optional - sage.rings.finite_rings - sage: f = H([x^2 + 2*(t^3 + t^2 + t + 3)]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF(5^4) + sage: A. = AffineSpace(K, 1) + sage: A2. = AffineSpace(K, 2) + sage: H = End(A) + sage: H2 = Hom(A, A2) + sage: H3 = Hom(A2, A) + sage: f = H([x^2 + 2*(t^3 + t^2 + t + 3)]) + sage: f.reduce_base_field() Scheme endomorphism of Affine Space of dimension 1 over Finite Field in t2 of size 5^2 Defn: Defined on coordinates by sending (x) to (x^2 + (2*t2)) - sage: f2 = H2([x^2 + 4, 2*x]) # optional - sage.rings.finite_rings - sage: f2.reduce_base_field() # optional - sage.rings.finite_rings + sage: f2 = H2([x^2 + 4, 2*x]) + sage: f2.reduce_base_field() Scheme morphism: From: Affine Space of dimension 1 over Finite Field of size 5 To: Affine Space of dimension 2 over Finite Field of size 5 Defn: Defined on coordinates by sending (x) to (x^2 - 1, 2*x) - sage: f3 = H3([a^2 + t*b]) # optional - sage.rings.finite_rings - sage: f3.reduce_base_field() # optional - sage.rings.finite_rings + sage: f3 = H3([a^2 + t*b]) + sage: f3.reduce_base_field() Scheme morphism: From: Affine Space of dimension 2 over Finite Field in t of size 5^4 To: Affine Space of dimension 1 over Finite Field in t of size 5^4 @@ -1125,23 +1138,25 @@ def reduce_base_field(self): :: - sage: K. = CyclotomicField(4) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([x^2 + v]) # optional - sage.rings.number_field - sage: g = f.reduce_base_field(); g # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(4) + sage: A. = AffineSpace(K, 1) + sage: H = End(A) + sage: f = H([x^2 + v]) + sage: g = f.reduce_base_field(); g Scheme endomorphism of Affine Space of dimension 1 over Cyclotomic Field of order 4 and degree 2 Defn: Defined on coordinates by sending (x) to (x^2 + v) - sage: g.base_ring() is K # optional - sage.rings.number_field + sage: g.base_ring() is K True :: - sage: A. = AffineSpace(QQbar, 1) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)]) # optional - sage.rings.number_field - sage: f.reduce_base_field() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: A. = AffineSpace(QQbar, 1) + sage: H = End(A) + sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)]) # needs sage.symbolic + sage: f.reduce_base_field() # needs sage.symbolic Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...? Defn: Defined on coordinates by sending (x) to @@ -1149,11 +1164,12 @@ def reduce_base_field(self): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: A. = AffineSpace(QQbar, 1) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([QQbar(3^(1/3))*x^2 + QQbar(sqrt(-2))]) # optional - sage.rings.number_field - sage: f.reduce_base_field() # optional - sage.rings.number_field + sage: A. = AffineSpace(QQbar, 1) + sage: H = End(A) + sage: f = H([QQbar(3^(1/3))*x^2 + QQbar(sqrt(-2))]) # needs sage.symbolic + sage: f.reduce_base_field() # needs sage.symbolic Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^6 + 6*y^4 - 6*y^3 + 12*y^2 + 36*y + 17 with a = 1.442249570307409? + 1.414213562373095?*I @@ -1164,14 +1180,15 @@ def reduce_base_field(self): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^3 - x + 1, # optional - sage.rings.number_field - ....: embedding=(x^3+x+1).roots(ring=CC)[0][0]) - sage: A. = AffineSpace(K, 1) # optional - sage.rings.number_field - sage: A2. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = Hom(A, A2) # optional - sage.rings.number_field - sage: f = H([x^2 + a*x + 3, 5*x]) # optional - sage.rings.number_field - sage: f.reduce_base_field() # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - x + 1, + ....: embedding=(x^3 + x + 1).roots(ring=CC)[0][0]) + sage: A. = AffineSpace(K, 1) + sage: A2. = AffineSpace(K, 2) + sage: H = Hom(A, A2) + sage: f = H([x^2 + a*x + 3, 5*x]) + sage: f.reduce_base_field() Scheme morphism: From: Affine Space of dimension 1 over Number Field in a with defining polynomial x^3 - x + 1 with a = -1.324717957244746? @@ -1181,21 +1198,23 @@ def reduce_base_field(self): :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: f = H([3*x^2 + x + 1]) # optional - sage.rings.number_field - sage: f.reduce_base_field() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: A. = AffineSpace(K, 1) + sage: H = End(A) + sage: f = H([3*x^2 + x + 1]) + sage: f.reduce_base_field() Scheme endomorphism of Affine Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x) to (3*x^2 + x + 1) :: - sage: K. = GF(5^6) # optional - sage.rings.finite_rings - sage: A. = AffineSpace(K, 1) # optional - sage.rings.finite_rings - sage: H = End(A) # optional - sage.rings.finite_rings - sage: f = H([x^2 + x*(t^3 + 2*t^2 + 4*t) + (t^5 + 3*t^4 + t^2 + 4*t)]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF(5^6) + sage: A. = AffineSpace(K, 1) + sage: H = End(A) + sage: f = H([x^2 + x*(t^3 + 2*t^2 + 4*t) + (t^5 + 3*t^4 + t^2 + 4*t)]) + sage: f.reduce_base_field() Scheme endomorphism of Affine Space of dimension 1 over Finite Field in t of size 5^6 Defn: Defined on coordinates by sending (x) to @@ -1229,7 +1248,7 @@ def indeterminacy_locus(self): sage: A. = AffineSpace(QQ, 2) sage: H = End(A) sage: f = H([x - y, x^2 - y^2]) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 1 @@ -1237,7 +1256,7 @@ def indeterminacy_locus(self): sage: A. = AffineSpace(QQ, 2) sage: f = A.hom([x, x/y], A) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: y """ @@ -1262,7 +1281,7 @@ def indeterminacy_points(self, F=None): sage: A. = AffineSpace(QQ, 2) sage: H = End(A) sage: f = H([x - y, x^2 - y^2]) - sage: f.indeterminacy_points() + sage: f.indeterminacy_points() # needs sage.libs.singular [] :: @@ -1270,7 +1289,7 @@ def indeterminacy_points(self, F=None): sage: A2. = AffineSpace(QQ, 2) sage: P2. = ProjectiveSpace(QQ, 2) sage: f = A2.hom([x*y, y, x], P2) - sage: f.indeterminacy_points() + sage: f.indeterminacy_points() # needs sage.libs.singular [(0, 0)] """ @@ -1296,6 +1315,7 @@ def image(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: A1. = AffineSpace(QQ, 1) sage: A2. = AffineSpace(QQ, 2) sage: f = A2.hom([x + y], A1) @@ -1329,18 +1349,18 @@ def _fast_eval(self, x): EXAMPLES:: - sage: P. = AffineSpace(GF(7), 3) # optional - sage.rings.finite_rings - sage: H = Hom(P, P) # optional - sage.rings.finite_rings - sage: f = H([x^2 + y^2,y ^2, z^2 + y*z]) # optional - sage.rings.finite_rings - sage: f._fast_eval([1, 1, 1]) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(7), 3) + sage: H = Hom(P, P) + sage: f = H([x^2 + y^2,y ^2, z^2 + y*z]) + sage: f._fast_eval([1, 1, 1]) [2, 1, 2] :: - sage: P. = AffineSpace(GF(19), 3) # optional - sage.rings.finite_rings - sage: H = Hom(P, P) # optional - sage.rings.finite_rings - sage: f = H([x/(y+1), y, (z^2 + y^2)/(x^2 + 1)]) # optional - sage.rings.finite_rings - sage: f._fast_eval([2, 1, 3]) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(19), 3) + sage: H = Hom(P, P) + sage: f = H([x/(y+1), y, (z^2 + y^2)/(x^2 + 1)]) + sage: f._fast_eval([2, 1, 3]) [1, 1, 2] """ R = self.domain().ambient_space().coordinate_ring() @@ -1376,7 +1396,7 @@ def representatives(self): sage: A2. = AffineSpace(QQ, 2) sage: X = A2.subscheme(0) sage: f = X.hom([x, x/y], A2) - sage: f.representatives() + sage: f.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: 0 @@ -1385,6 +1405,7 @@ def representatives(self): :: + sage: # needs sage.libs.singular sage: A2. = AffineSpace(QQ, 2) sage: A1. = AffineSpace(QQ, 1) sage: X = A2.subscheme([x^2 - y^2 - y]) @@ -1419,7 +1440,7 @@ def representatives(self): sage: P1. = ProjectiveSpace(QQ, 1) sage: X = A2.subscheme([x^2 - y^2 - y]) sage: f = X.hom([x, y], P1) - sage: f.representatives() + sage: f.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y @@ -1465,7 +1486,7 @@ def indeterminacy_locus(self): sage: X = A2.subscheme(0) sage: A1. = AffineSpace(QQ, 1) sage: f = X.hom([x1/x2], A1) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x2 @@ -1475,17 +1496,17 @@ def indeterminacy_locus(self): sage: X = A2.subscheme(0) sage: P1. = ProjectiveSpace(QQ, 1) sage: f = X.hom([x1,x2], P1) - sage: L = f.indeterminacy_locus() - sage: L.rational_points() + sage: L = f.indeterminacy_locus() # needs sage.libs.singular + sage: L.rational_points() # needs sage.libs.singular [(0, 0)] :: sage: A2. = AffineSpace(QQ, 2) sage: X = A2.subscheme([x^2 - y^2 - y]) - sage: A1. = AffineSpace(QQ,1) + sage: A1. = AffineSpace(QQ, 1) sage: f = X.hom([x/y], A1) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: y, x @@ -1496,12 +1517,11 @@ def indeterminacy_locus(self): sage: X = A3.subscheme(x^2 - y*z - x) sage: A2. = AffineSpace(QQ, 2) sage: f = X.hom([y, y/x], A2) - sage: L = f.indeterminacy_locus() - sage: L + sage: L = f.indeterminacy_locus(); L # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: x, y*z - sage: L.dimension() + sage: L.dimension() # needs sage.libs.singular 1 """ @@ -1529,7 +1549,7 @@ def is_morphism(self): sage: P1. = ProjectiveSpace(QQ,1) sage: X = P2.subscheme([x^2 - y^2 - y*z]) sage: f = X.hom([x,y], P1) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular True """ return self.indeterminacy_locus().dimension() < 0 @@ -1546,7 +1566,7 @@ def image(self): sage: A2. = AffineSpace(QQ, 2) sage: X = A2.subscheme(0) sage: f = X.hom([x + y], A1) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 1 over Rational Field defined by: (no polynomials) @@ -1555,7 +1575,7 @@ def image(self): sage: A2. = AffineSpace(QQ, 2) sage: X = A2.subscheme([x*y^2 - y^3 - 1]) sage: f = X.hom([y, y/x], A2) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -x^3*y + x^3 - y """ diff --git a/src/sage/schemes/affine/affine_point.py b/src/sage/schemes/affine/affine_point.py index e0cdab543fe..a665ba6881a 100644 --- a/src/sage/schemes/affine/affine_point.py +++ b/src/sage/schemes/affine/affine_point.py @@ -115,16 +115,16 @@ def _matrix_times_point_(self, mat, dom): sage: P = AffineSpace(QQ,2) sage: Q = P(1,2) - sage: m = matrix(ZZ, 3, 3, [0,1,1,0,0,1,1,1,1]) - sage: m*Q + sage: m = matrix(ZZ, 3, 3, [0,1,1,0,0,1,1,1,1]) # needs sage.modules + sage: m*Q # needs sage.modules (3/4, 1/4) :: sage: P = AffineSpace(QQ,1) sage: Q = P(0) - sage: m = matrix(RR, 2, 2, [0,1,1,0]) - sage: m*Q + sage: m = matrix(RR, 2, 2, [0,1,1,0]) # needs sage.modules + sage: m*Q # needs sage.modules Traceback (most recent call last): ... ValueError: resulting point not affine @@ -133,8 +133,8 @@ def _matrix_times_point_(self, mat, dom): sage: P = AffineSpace(QQ,2) sage: Q = P(1,1) - sage: m = matrix(RR, 2, 2, [0,1,1,0]) - sage: m*Q + sage: m = matrix(RR, 2, 2, [0,1,1,0]) # needs sage.modules + sage: m*Q # needs sage.modules Traceback (most recent call last): ... ValueError: matrix size is incompatible @@ -158,9 +158,9 @@ def __hash__(self): :: - sage: A. = AffineSpace(CC, 3) - sage: pt = A([1, 2, -i]) - sage: hash(pt) == hash(tuple(pt)) + sage: A. = AffineSpace(CC, 3) # needs sage.rings.real_mpfr + sage: pt = A([1, 2, -i]) # needs sage.rings.real_mpfr sage.symbolic + sage: hash(pt) == hash(tuple(pt)) # needs sage.rings.real_mpfr sage.symbolic True """ @@ -183,22 +183,22 @@ def global_height(self, prec=None): sage: P. = AffineSpace(QQ, 2) sage: Q = P(41, 1/12) - sage: Q.global_height() + sage: Q.global_height() # needs sage.rings.real_mpfr 3.71357206670431 :: sage: P = AffineSpace(ZZ, 4, 'x') sage: Q = P(3, 17, -51, 5) - sage: Q.global_height() + sage: Q.global_height() # needs sage.rings.real_mpfr 3.93182563272433 :: sage: R. = PolynomialRing(QQ) - sage: k. = NumberField(x^2 + 5) # optional - sage.rings.number_field - sage: A = AffineSpace(k, 2, 'z') # optional - sage.rings.number_field - sage: A([3, 5*w + 1]).global_height(prec=100) # optional - sage.rings.number_field + sage: k. = NumberField(x^2 + 5) # needs sage.rings.number_field + sage: A = AffineSpace(k, 2, 'z') # needs sage.rings.number_field + sage: A([3, 5*w + 1]).global_height(prec=100) # needs sage.rings.number_field sage.rings.real_mpfr 2.4181409534757389986565376694 .. TODO:: @@ -291,24 +291,26 @@ def weil_restriction(self): EXAMPLES:: - sage: A. = AffineSpace(GF(5^3, 't'), 3) # optional - sage.rings.finite_rings - sage: X = A.subscheme([y^2 - x*z, z^2 + y]) # optional - sage.rings.finite_rings - sage: Y = X.weil_restriction() # optional - sage.rings.finite_rings - sage: P = X([1, -1, 1]) # optional - sage.rings.finite_rings - sage: Q = P.weil_restriction();Q # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular sage.rings.finite_rings + sage: A. = AffineSpace(GF(5^3, 't'), 3) + sage: X = A.subscheme([y^2 - x*z, z^2 + y]) + sage: Y = X.weil_restriction() + sage: P = X([1, -1, 1]) + sage: Q = P.weil_restriction();Q (1, 0, 0, 4, 0, 0, 1, 0, 0) - sage: Q.codomain() == Y # optional - sage.rings.finite_rings + sage: Q.codomain() == Y True :: + sage: # needs sage.libs.singular sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^5 - 2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(x^2 + w) # optional - sage.rings.number_field - sage: A. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: P = A([w^3 - v, 1 + w + w*v]) # optional - sage.rings.number_field - sage: P.weil_restriction() # optional - sage.rings.number_field + sage: K. = NumberField(x^5 - 2) + sage: R. = K[] + sage: L. = K.extension(x^2 + w) + sage: A. = AffineSpace(L, 2) + sage: P = A([w^3 - v, 1 + w + w*v]) + sage: P.weil_restriction() (w^3, -1, w + 1, w) """ L = self.codomain().base_ring() @@ -358,14 +360,15 @@ def intersection_multiplicity(self, X): EXAMPLES:: - sage: A. = AffineSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: X = A.subscheme([y^2 - x^3 + 2*x^2 - x]) # optional - sage.rings.finite_rings - sage: Y = A.subscheme([y - 2*x + 2]) # optional - sage.rings.finite_rings - sage: Q1 = Y([1,0]) # optional - sage.rings.finite_rings - sage: Q1.intersection_multiplicity(X) # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: A. = AffineSpace(GF(17), 2) + sage: X = A.subscheme([y^2 - x^3 + 2*x^2 - x]) + sage: Y = A.subscheme([y - 2*x + 2]) + sage: Q1 = Y([1,0]) + sage: Q1.intersection_multiplicity(X) 2 - sage: Q2 = X([4,6]) # optional - sage.rings.finite_rings - sage: Q2.intersection_multiplicity(Y) # optional - sage.rings.finite_rings + sage: Q2 = X([4,6]) + sage: Q2.intersection_multiplicity(Y) 1 :: @@ -397,10 +400,10 @@ def multiplicity(self): sage: A. = AffineSpace(QQ, 3) sage: X = A.subscheme([y^2 - x^7*z]) sage: Q1 = X([1,1,1]) - sage: Q1.multiplicity() + sage: Q1.multiplicity() # needs sage.libs.singular 1 sage: Q2 = X([0,0,2]) - sage: Q2.multiplicity() + sage: Q2.multiplicity() # needs sage.libs.singular 2 """ from sage.schemes.affine.affine_space import is_AffineSpace @@ -419,27 +422,27 @@ def __hash__(self): EXAMPLES:: - sage: P. = AffineSpace(GF(5), 3) # optional - sage.rings.finite_rings - sage: hash(P(2, 1, 2)) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(5), 3) + sage: hash(P(2, 1, 2)) 57 :: - sage: P. = AffineSpace(GF(7), 3) # optional - sage.rings.finite_rings - sage: X = P.subscheme(x^2 - y^2) # optional - sage.rings.finite_rings - sage: hash(X(1, 1, 2)) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(7), 3) + sage: X = P.subscheme(x^2 - y^2) + sage: hash(X(1, 1, 2)) 106 :: - sage: P. = AffineSpace(GF(13), 2) # optional - sage.rings.finite_rings - sage: hash(P(3, 4)) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(13), 2) + sage: hash(P(3, 4)) 55 :: - sage: P. = AffineSpace(GF(13^3, 't'), 2) # optional - sage.rings.finite_rings - sage: hash(P(3, 4)) # optional - sage.rings.finite_rings + sage: P. = AffineSpace(GF(13^3, 't'), 2) # needs sage.rings.finite_rings + sage: hash(P(3, 4)) # needs sage.rings.finite_rings 8791 """ p = self.codomain().base_ring().order() diff --git a/src/sage/schemes/affine/affine_rational_point.py b/src/sage/schemes/affine/affine_rational_point.py index 91ec84ffeab..739d1795086 100644 --- a/src/sage/schemes/affine/affine_rational_point.py +++ b/src/sage/schemes/affine/affine_rational_point.py @@ -25,8 +25,8 @@ Affine over a finite field:: sage: from sage.schemes.affine.affine_rational_point import enum_affine_finite_field - sage: A. = AffineSpace(4, GF(2)) # optional - sage.rings.finite_rings - sage: enum_affine_finite_field(A(GF(2))) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(4, GF(2)) + sage: enum_affine_finite_field(A(GF(2))) [(0, 0, 0, 0), (0, 0, 0, 1), (0, 0, 1, 0), (0, 0, 1, 1), (0, 1, 0, 0), (0, 1, 0, 1), (0, 1, 1, 0), (0, 1, 1, 1), (1, 0, 0, 0), (1, 0, 0, 1), (1, 0, 1, 0), (1, 0, 1, 1), (1, 1, 0, 0), (1, 1, 0, 1), (1, 1, 1, 0), @@ -94,8 +94,8 @@ def enum_affine_rational_field(X, B): :: sage: A. = AffineSpace(2, QQ) - sage: C = Curve(x^2 + y - x) - sage: enum_affine_rational_field(C, 10) # long time (3 s) + sage: C = Curve(x^2 + y - x) # needs sage.libs.singular + sage: enum_affine_rational_field(C, 10) # long time (3 s) # needs sage.libs.singular [(-2, -6), (-1, -2), (-2/3, -10/9), (-1/2, -3/4), (-1/3, -4/9), (0, 0), (1/3, 2/9), (1/2, 1/4), (2/3, 2/9), (1, 0), (4/3, -4/9), (3/2, -3/4), (5/3, -10/9), (2, -2), (3, -6)] @@ -188,12 +188,13 @@ def enum_affine_number_field(X, **kwds): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.affine.affine_rational_point import enum_affine_number_field sage: u = QQ['u'].0 - sage: K = NumberField(u^2 + 2, 'v') # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 3) # optional - sage.rings.number_field - sage: X = A.subscheme([y^2 - x]) # optional - sage.rings.number_field - sage: enum_affine_number_field(X(K), bound=2**0.5) # optional - sage.rings.number_field + sage: K = NumberField(u^2 + 2, 'v') + sage: A. = AffineSpace(K, 3) + sage: X = A.subscheme([y^2 - x]) + sage: enum_affine_number_field(X(K), bound=2**0.5) [(0, 0, -1), (0, 0, -v), (0, 0, -1/2*v), (0, 0, 0), (0, 0, 1/2*v), (0, 0, v), (0, 0, 1), (1, -1, -1), (1, -1, -v), (1, -1, -1/2*v), (1, -1, 0), (1, -1, 1/2*v), (1, -1, v), (1, -1, 1), (1, 1, -1), @@ -201,12 +202,13 @@ def enum_affine_number_field(X, **kwds): :: + sage: # needs sage.rings.number_field sage: from sage.schemes.affine.affine_rational_point import enum_affine_number_field sage: u = QQ['u'].0 - sage: K = NumberField(u^2 + 3, 'v') # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: X = A.subscheme(x - y) # optional - sage.rings.number_field - sage: enum_affine_number_field(X, bound=3**0.25) # optional - sage.rings.number_field + sage: K = NumberField(u^2 + 3, 'v') + sage: A. = AffineSpace(K, 2) + sage: X = A.subscheme(x - y) + sage: enum_affine_number_field(X, bound=3**0.25) [(-1, -1), (-1/2*v - 1/2, -1/2*v - 1/2), (1/2*v - 1/2, 1/2*v - 1/2), (0, 0), (-1/2*v + 1/2, -1/2*v + 1/2), (1/2*v + 1/2, 1/2*v + 1/2), (1, 1)] """ @@ -250,13 +252,13 @@ def enum_affine_finite_field(X): EXAMPLES:: sage: from sage.schemes.affine.affine_rational_point import enum_affine_finite_field - sage: F = GF(7) # optional - sage.rings.finite_rings - sage: A. = AffineSpace(4, F) # optional - sage.rings.finite_rings - sage: C = A.subscheme([w^2 + x + 4, y*z*x - 6, z*y + w*x]) # optional - sage.rings.finite_rings - sage: enum_affine_finite_field(C(F)) # optional - sage.rings.finite_rings + sage: F = GF(7) + sage: A. = AffineSpace(4, F) + sage: C = A.subscheme([w^2 + x + 4, y*z*x - 6, z*y + w*x]) + sage: enum_affine_finite_field(C(F)) [] - sage: C = A.subscheme([w^2 + x + 4, y*z*x - 6]) # optional - sage.rings.finite_rings - sage: enum_affine_finite_field(C(F)) # optional - sage.rings.finite_rings + sage: C = A.subscheme([w^2 + x + 4, y*z*x - 6]) + sage: enum_affine_finite_field(C(F)) [(0, 3, 1, 2), (0, 3, 2, 1), (0, 3, 3, 3), (0, 3, 4, 4), (0, 3, 5, 6), (0, 3, 6, 5), (1, 2, 1, 3), (1, 2, 2, 5), (1, 2, 3, 1), (1, 2, 4, 6), (1, 2, 5, 2), (1, 2, 6, 4), (2, 6, 1, 1), (2, 6, 2, 4), (2, 6, 3, 5), @@ -269,9 +271,9 @@ def enum_affine_finite_field(X): :: - sage: A. = AffineSpace(3, GF(3)) # optional - sage.rings.finite_rings - sage: S = A.subscheme(x + y) # optional - sage.rings.finite_rings - sage: enum_affine_finite_field(S) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(3, GF(3)) + sage: S = A.subscheme(x + y) + sage: enum_affine_finite_field(S) [(0, 0, 0), (0, 0, 1), (0, 0, 2), (1, 2, 0), (1, 2, 1), (1, 2, 2), (2, 1, 0), (2, 1, 1), (2, 1, 2)] diff --git a/src/sage/schemes/affine/affine_space.py b/src/sage/schemes/affine/affine_space.py index 2c8ebf0f39a..927a065cf60 100644 --- a/src/sage/schemes/affine/affine_space.py +++ b/src/sage/schemes/affine/affine_space.py @@ -49,7 +49,7 @@ def is_AffineSpace(x) -> bool: sage: from sage.schemes.affine.affine_space import is_AffineSpace sage: is_AffineSpace(AffineSpace(5, names='x')) True - sage: is_AffineSpace(AffineSpace(5, GF(9, 'alpha'), names='x')) # optional - sage.rings.finite_rings + sage: is_AffineSpace(AffineSpace(5, GF(9, 'alpha'), names='x')) # needs sage.rings.finite_rings True sage: is_AffineSpace(Spec(ZZ)) False @@ -77,7 +77,7 @@ def AffineSpace(n, R=None, names=None, ambient_projective_space=None, Use the divide operator for base extension:: - sage: AffineSpace(5, names='x')/GF(17) # optional - sage.rings.finite_rings + sage: AffineSpace(5, names='x')/GF(17) Affine Space of dimension 5 over Finite Field of size 17 The default base ring is `\ZZ`:: @@ -87,10 +87,10 @@ def AffineSpace(n, R=None, names=None, ambient_projective_space=None, There is also an affine space associated to each polynomial ring:: - sage: R = GF(7)['x, y, z'] # optional - sage.rings.finite_rings - sage: A = AffineSpace(R); A # optional - sage.rings.finite_rings + sage: R = GF(7)['x, y, z'] + sage: A = AffineSpace(R); A Affine Space of dimension 3 over Finite Field of size 7 - sage: A.coordinate_ring() is R # optional - sage.rings.finite_rings + sage: A.coordinate_ring() is R True TESTS:: @@ -170,10 +170,10 @@ class AffineSpace_generic(AmbientSpace, AffineScheme): sage: AffineSpace(5, PolynomialRing(QQ, 'z'), 'Z') Affine Space of dimension 5 over Univariate Polynomial Ring in z over Rational Field - sage: AffineSpace(RealField(), 3, 'Z') + sage: AffineSpace(RealField(), 3, 'Z') # needs sage.rings.real_mpfr Affine Space of dimension 3 over Real Field with 53 bits of precision - sage: AffineSpace(Qp(7), 2, 'x') # optional - sage.rings.padics + sage: AffineSpace(Qp(7), 2, 'x') # needs sage.rings.padics Affine Space of dimension 2 over 7-adic Field with capped relative precision 20 Even 0-dimensional affine spaces are supported:: @@ -185,7 +185,7 @@ def __init__(self, n, R, names, ambient_projective_space, default_embedding_inde """ EXAMPLES:: - sage: AffineSpace(3, Zp(5), 'y') # optional - sage.rings.padics + sage: AffineSpace(3, Zp(5), 'y') # needs sage.rings.padics Affine Space of dimension 3 over 5-adic Ring with capped relative precision 20 """ AmbientSpace.__init__(self, n, R) @@ -205,15 +205,15 @@ def __iter__(self): EXAMPLES:: - sage: FF = FiniteField(3) # optional - sage.rings.finite_rings - sage: AA = AffineSpace(FF, 0) # optional - sage.rings.finite_rings - sage: [ x for x in AA ] # optional - sage.rings.finite_rings + sage: FF = FiniteField(3) + sage: AA = AffineSpace(FF, 0) + sage: [ x for x in AA ] [()] - sage: AA = AffineSpace(FF, 1, 'Z') # optional - sage.rings.finite_rings - sage: [ x for x in AA ] # optional - sage.rings.finite_rings + sage: AA = AffineSpace(FF, 1, 'Z') + sage: [ x for x in AA ] [(0), (1), (2)] - sage: AA. = AffineSpace(FF, 2) # optional - sage.rings.finite_rings - sage: [ x for x in AA ] # optional - sage.rings.finite_rings + sage: AA. = AffineSpace(FF, 2) + sage: [ x for x in AA ] [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)] AUTHOR: @@ -249,13 +249,13 @@ def rational_points(self, F=None): EXAMPLES:: - sage: A = AffineSpace(1, GF(3)) # optional - sage.rings.finite_rings - sage: A.rational_points() # optional - sage.rings.finite_rings + sage: A = AffineSpace(1, GF(3)) + sage: A.rational_points() [(0), (1), (2)] - sage: A.rational_points(GF(3^2, 'b')) # optional - sage.rings.finite_rings + sage: A.rational_points(GF(3^2, 'b')) # needs sage.rings.finite_rings [(0), (b), (b + 1), (2*b + 1), (2), (2*b), (2*b + 2), (b + 2), (1)] - sage: AffineSpace(2, ZZ).rational_points(GF(2)) # optional - sage.rings.finite_rings + sage: AffineSpace(2, ZZ).rational_points(GF(2)) [(0, 0), (0, 1), (1, 0), (1, 1)] TESTS:: @@ -264,7 +264,7 @@ def rational_points(self, F=None): Traceback (most recent call last): ... TypeError: base ring (= Rational Field) must be a finite field - sage: AffineSpace(1, GF(3)).rational_points(ZZ) # optional - sage.rings.finite_rings + sage: AffineSpace(1, GF(3)).rational_points(ZZ) Traceback (most recent call last): ... TypeError: second argument (= Integer Ring) must be a finite field @@ -333,7 +333,7 @@ def _latex_(self): TESTS:: - sage: AffineSpace(3, Zp(5), 'y')._latex_() # optional - sage.rings.padics + sage: AffineSpace(3, Zp(5), 'y')._latex_() # needs sage.rings.padics '\\mathbf{A}_{\\Bold{Z}_{5}}^3' """ return "\\mathbf{A}_{%s}^%s" % (latex(self.base_ring()), self.dimension_relative()) @@ -434,7 +434,7 @@ def _repr_(self): TESTS:: - sage: AffineSpace(3, Zp(5), 'y')._repr_() # optional - sage.rings.padics + sage: AffineSpace(3, Zp(5), 'y')._repr_() # needs sage.rings.padics 'Affine Space of dimension 3 over 5-adic Ring with capped relative precision 20' """ return "Affine Space of dimension %s over %s" % (self.dimension_relative(), self.base_ring()) @@ -633,14 +633,14 @@ def change_ring(self, R): sage: A. = AffineSpace(3, ZZ) sage: AQ = A.change_ring(QQ); AQ Affine Space of dimension 3 over Rational Field - sage: AQ.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: AQ.change_ring(GF(5)) Affine Space of dimension 3 over Finite Field of size 5 :: - sage: K. = QuadraticField(5) # optional - sage.rings.number_field - sage: A = AffineSpace(K, 2, 't') # optional - sage.rings.number_field - sage: A.change_ring(K.embeddings(CC)[1]) # optional - sage.rings.number_field + sage: K. = QuadraticField(5) # needs sage.rings.number_field + sage: A = AffineSpace(K, 2, 't') # needs sage.rings.number_field + sage: A.change_ring(K.embeddings(CC)[1]) # needs sage.rings.number_field Affine Space of dimension 2 over Complex Field with 53 bits of precision """ if isinstance(R, Map): @@ -654,9 +654,9 @@ def coordinate_ring(self): EXAMPLES:: - sage: R = AffineSpace(2, GF(9,'alpha'), 'z').coordinate_ring(); R # optional - sage.rings.finite_rings + sage: R = AffineSpace(2, GF(9,'alpha'), 'z').coordinate_ring(); R # needs sage.rings.finite_rings Multivariate Polynomial Ring in z0, z1 over Finite Field in alpha of size 3^2 - sage: AffineSpace(3, R, 'x').coordinate_ring() # optional - sage.rings.finite_rings + sage: AffineSpace(3, R, 'x').coordinate_ring() # needs sage.rings.finite_rings Multivariate Polynomial Ring in x0, x1, x2 over Multivariate Polynomial Ring in z0, z1 over Finite Field in alpha of size 3^2 """ @@ -810,6 +810,7 @@ def subscheme(self, X, **kwds): :: + sage: # needs sage.libs.singular sage: X.defining_polynomials () (x, y^2, x*y^2) sage: I = X.defining_ideal(); I @@ -851,7 +852,7 @@ def _an_element_(self): sage: AffineSpace(ZZ, 2, 'x').an_element() (5, 4) - sage: AffineSpace(Qp(5), 2, 'x').an_element() # optional - sage.rings.padics + sage: AffineSpace(Qp(5), 2, 'x').an_element() # needs sage.rings.padics (5^2 + O(5^22), 4*5 + O(5^21)) """ n = self.dimension_relative() @@ -883,21 +884,21 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): EXAMPLES:: sage: A. = AffineSpace(QQ, 1) - sage: A.chebyshev_polynomial(5, 'first') + sage: A.chebyshev_polynomial(5, 'first') # needs sage.schemes Dynamical System of Affine Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x) to (16*x^5 - 20*x^3 + 5*x) :: sage: A. = AffineSpace(QQ, 1) - sage: A.chebyshev_polynomial(3, 'second') + sage: A.chebyshev_polynomial(3, 'second') # needs sage.schemes Dynamical System of Affine Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x) to (8*x^3 - 4*x) :: sage: A. = AffineSpace(QQ, 1) - sage: A.chebyshev_polynomial(3, 2) + sage: A.chebyshev_polynomial(3, 2) # needs sage.schemes Traceback (most recent call last): ... ValueError: keyword 'kind' must have a value of either 'first' or 'second' @@ -921,15 +922,15 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): :: sage: A. = AffineSpace(QQ, 1) - sage: A.chebyshev_polynomial(7, monic=True) + sage: A.chebyshev_polynomial(7, monic=True) # needs sage.schemes Dynamical System of Affine Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x) to (x^7 - 7*x^5 + 14*x^3 - 7*x) :: sage: F. = FunctionField(QQ) - sage: A. = AffineSpace(F,1) - sage: A.chebyshev_polynomial(4, monic=True) + sage: A. = AffineSpace(F, 1) + sage: A.chebyshev_polynomial(4, monic=True) # needs sage.schemes Dynamical System of Affine Space of dimension 1 over Rational function field in t over Rational Field Defn: Defined on coordinates by sending (x) to (x^4 + (-4)*x^2 + 2) @@ -983,9 +984,9 @@ def _point(self, *args, **kwds): TESTS:: - sage: P2. = AffineSpace(3, GF(3)) # optional - sage.rings.finite_rings - sage: point_homset = P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings - sage: P2._point(point_homset, [1, 2, 3]) # optional - sage.rings.finite_rings + sage: P2. = AffineSpace(3, GF(3)) + sage: point_homset = P2._point_homset(Spec(GF(3)), P2) + sage: P2._point(point_homset, [1, 2, 3]) (1, 2, 0) """ return SchemeMorphism_point_affine_field(*args, **kwds) @@ -998,8 +999,8 @@ def _morphism(self, *args, **kwds): TESTS:: - sage: P2. = AffineSpace(3, GF(3)) # optional - sage.rings.finite_rings - sage: P2._morphism(P2.Hom(P2), [x, y, z]) # optional - sage.rings.finite_rings + sage: P2. = AffineSpace(3, GF(3)) + sage: P2._morphism(P2.Hom(P2), [x, y, z]) Scheme endomorphism of Affine Space of dimension 3 over Finite Field of size 3 Defn: Defined on coordinates by sending (x, y, z) to (x, y, z) @@ -1051,8 +1052,8 @@ def points_of_bounded_height(self, **kwds): :: sage: u = QQ['u'].0 - sage: A. = AffineSpace(NumberField(u^2 - 2, 'v'), 2) # optional - sage.rings.number_field - sage: len(list(A.points_of_bounded_height(bound=2, tolerance=0.1))) # optional - sage.rings.number_field + sage: A. = AffineSpace(NumberField(u^2 - 2, 'v'), 2) # needs sage.rings.number_field + sage: len(list(A.points_of_bounded_height(bound=2, tolerance=0.1))) # needs sage.rings.number_field 529 """ if is_RationalField(self.base_ring()): @@ -1105,15 +1106,16 @@ def weil_restriction(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^5 - 2) # optional - sage.rings.number_field - sage: AK. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: AK.weil_restriction() # optional - sage.rings.number_field + sage: K. = NumberField(x^5 - 2) + sage: AK. = AffineSpace(K, 2) + sage: AK.weil_restriction() Affine Space of dimension 10 over Rational Field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(x^2 + 1) # optional - sage.rings.number_field - sage: AL. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: AL.weil_restriction() # optional - sage.rings.number_field + sage: R. = K[] + sage: L. = K.extension(x^2 + 1) + sage: AL. = AffineSpace(L, 2) + sage: AL.weil_restriction() Affine Space of dimension 4 over Number Field in w with defining polynomial x^5 - 2 """ @@ -1147,7 +1149,7 @@ def curve(self, F): EXAMPLES:: sage: A. = AffineSpace(QQ, 3) - sage: A.curve([y - x^4, z - y^5]) + sage: A.curve([y - x^4, z - y^5]) # needs sage.libs.pari Affine Curve over Rational Field defined by -x^4 + y, -y^5 + z """ from sage.schemes.curves.constructor import Curve @@ -1163,13 +1165,13 @@ def line_through(self, p, q): EXAMPLES:: + sage: # needs sage.libs.singular sage.schemes sage: A3. = AffineSpace(3, QQ) sage: p1 = A3(1, 2, 3) sage: p2 = A3(4, 5, 6) - sage: A3.line_through(p1, p2) + sage: L = A3.line_through(p1, p2); L Affine Curve over Rational Field defined by -1/6*x + 1/6*y - 1/6, -1/6*x + 1/6*z - 1/3, -1/6*y + 1/6*z - 1/6, -1/6*x + 1/3*y - 1/6*z - sage: L = _ sage: L(p1) (1, 2, 3) sage: L(p2) @@ -1236,9 +1238,9 @@ def _point(self, *args, **kwds): TESTS:: - sage: P2. = AffineSpace(3, GF(3)) # optional - sage.rings.finite_rings - sage: point_homset = P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings - sage: P2._point(point_homset, [1, 2, 3]) # optional - sage.rings.finite_rings + sage: P2. = AffineSpace(3, GF(3)) + sage: point_homset = P2._point_homset(Spec(GF(3)), P2) + sage: P2._point(point_homset, [1, 2, 3]) (1, 2, 0) """ return SchemeMorphism_point_affine_finite_field(*args, **kwds) @@ -1251,8 +1253,8 @@ def _morphism(self, *args, **kwds): TESTS:: - sage: P2. = AffineSpace(3, GF(3)) # optional - sage.rings.finite_rings - sage: P2._morphism(P2.Hom(P2), [x, y, z]) # optional - sage.rings.finite_rings + sage: P2. = AffineSpace(3, GF(3)) + sage: P2._morphism(P2.Hom(P2), [x, y, z]) Scheme endomorphism of Affine Space of dimension 3 over Finite Field of size 3 Defn: Defined on coordinates by sending (x, y, z) to (x, y, z) diff --git a/src/sage/schemes/affine/affine_subscheme.py b/src/sage/schemes/affine/affine_subscheme.py index a5a1c661c74..ed125a60193 100644 --- a/src/sage/schemes/affine/affine_subscheme.py +++ b/src/sage/schemes/affine/affine_subscheme.py @@ -59,7 +59,7 @@ def __init__(self, A, polynomials, embedding_center=None, EXAMPLES:: sage: A. = AffineSpace(QQ, 3) - sage: A.subscheme([y^2-x*z-x*y]) + sage: A.subscheme([y^2 - x*z - x*y]) Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -x*y + y^2 - x*z """ @@ -98,6 +98,7 @@ def dimension(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: A. = AffineSpace(2, QQ) sage: A.subscheme([]).dimension() 2 @@ -120,7 +121,7 @@ def dimension(self): x^2*y^2 + z^2, z^2 - w^2, 10*x^2 - z^2 + w^2 - sage: X.dimension() + sage: X.dimension() # needs sage.libs.singular 1 """ try: @@ -152,7 +153,7 @@ def projective_embedding(self, i=None, PP=None): sage: A. = AffineSpace(3, ZZ) sage: S = A.subscheme([x*y - z]) - sage: S.projective_embedding() + sage: S.projective_embedding() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Affine Space of dimension 3 over Integer Ring defined by: x*y - z @@ -165,7 +166,7 @@ def projective_embedding(self, i=None, PP=None): sage: A. = AffineSpace(3, ZZ) sage: P = ProjectiveSpace(3, ZZ, 'u') sage: S = A.subscheme([x^2 - y*z]) - sage: S.projective_embedding(1, P) + sage: S.projective_embedding(1, P) # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Affine Space of dimension 3 over Integer Ring defined by: x^2 - y*z @@ -177,7 +178,7 @@ def projective_embedding(self, i=None, PP=None): sage: A. = AffineSpace(QQ, 3) sage: X = A.subscheme([y - x^2, z - x^3]) - sage: X.projective_embedding() + sage: X.projective_embedding() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -x^2 + y, -x^3 + z @@ -189,17 +190,17 @@ def projective_embedding(self, i=None, PP=None): projective embedding, the subscheme inherits the embedding:: sage: A. = AffineSpace(2, QQ, default_embedding_index=1) - sage: X = A.subscheme(u - v) - sage: X.projective_embedding() + sage: X = A.subscheme(u - v) # needs sage.libs.singular + sage: X.projective_embedding() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: u - v To: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x0 - x2 Defn: Defined on coordinates by sending (u, v) to (u : 1 : v) - sage: phi = X.projective_embedding() + sage: phi = X.projective_embedding() # needs sage.libs.singular sage: psi = A.projective_embedding() - sage: phi(X(2, 2)) == psi(A(X(2, 2))) + sage: phi(X(2, 2)) == psi(A(X(2, 2))) # needs sage.libs.singular True """ AA = self.ambient_space() @@ -261,8 +262,9 @@ def projective_closure(self, i=None, PP=None): EXAMPLES:: sage: A. = AffineSpace(QQ, 4) - sage: X = A.subscheme([x^2 - y, x*y - z, y^2 - w, x*z - w, y*z - x*w, z^2 - y*w]) - sage: X.projective_closure() + sage: X = A.subscheme([x^2 - y, x*y - z, y^2 - w, + ....: x*z - w, y*z - x*w, z^2 - y*w]) + sage: X.projective_closure() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: x0^2 - x1*x4, @@ -277,7 +279,7 @@ def projective_closure(self, i=None, PP=None): sage: A. = AffineSpace(QQ, 3) sage: P. = ProjectiveSpace(QQ, 3) sage: X = A.subscheme([z - x^2 - y^2]) - sage: X.projective_closure(1, P).ambient_space() == P + sage: X.projective_closure(1, P).ambient_space() == P # needs sage.libs.singular True """ return self.projective_embedding(i, PP).codomain() @@ -310,11 +312,11 @@ def is_smooth(self, point=None): sage: singular_point = cuspidal_curve.point([0,0]) sage: singular_point in cuspidal_curve True - sage: cuspidal_curve.is_smooth(smooth_point) + sage: cuspidal_curve.is_smooth(smooth_point) # needs sage.libs.singular True - sage: cuspidal_curve.is_smooth(singular_point) + sage: cuspidal_curve.is_smooth(singular_point) # needs sage.libs.singular False - sage: cuspidal_curve.is_smooth() + sage: cuspidal_curve.is_smooth() # needs sage.libs.singular False """ R = self.ambient_space().coordinate_ring() @@ -354,24 +356,25 @@ def intersection_multiplicity(self, X, P): EXAMPLES:: sage: A. = AffineSpace(QQ, 2) - sage: C = Curve([y^2 - x^3 - x^2], A) - sage: D = Curve([y^2 + x^3], A) + sage: C = Curve([y^2 - x^3 - x^2], A) # needs sage.libs.singular + sage: D = Curve([y^2 + x^3], A) # needs sage.libs.singular sage: Q = A([0,0]) - sage: C.intersection_multiplicity(D, Q) + sage: C.intersection_multiplicity(D, Q) # needs sage.libs.singular 4 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^6 - 3*a^5 + 5*a^4 - 5*a^3 + 5*a^2 - 3*a + 1) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 4) # optional - sage.rings.number_field - sage: X = A.subscheme([x*y, y*z + 7, w^3 - x^3]) # optional - sage.rings.number_field - sage: Y = A.subscheme([x - z^3 + z + 1]) # optional - sage.rings.number_field - sage: Q = A([0, # optional - sage.rings.number_field + sage: K. = NumberField(a^6 - 3*a^5 + 5*a^4 - 5*a^3 + 5*a^2 - 3*a + 1) + sage: A. = AffineSpace(K, 4) + sage: X = A.subscheme([x*y, y*z + 7, w^3 - x^3]) + sage: Y = A.subscheme([x - z^3 + z + 1]) + sage: Q = A([0, ....: -7*b^5 + 21*b^4 - 28*b^3 + 21*b^2 - 21*b + 14, ....: -b^5 + 2*b^4 - 3*b^3 + 2*b^2 - 2*b, ....: 0]) - sage: X.intersection_multiplicity(Y, Q) # optional - sage.rings.number_field + sage: X.intersection_multiplicity(Y, Q) 3 :: @@ -380,7 +383,7 @@ def intersection_multiplicity(self, X, P): sage: X = A.subscheme([z^2 - 1]) sage: Y = A.subscheme([z - 1, y - x^2]) sage: Q = A([1,1,1]) - sage: X.intersection_multiplicity(Y, Q) + sage: X.intersection_multiplicity(Y, Q) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: the intersection of this subscheme and (=Closed subscheme of Affine Space of dimension 3 @@ -392,7 +395,7 @@ def intersection_multiplicity(self, X, P): sage: X = A.subscheme([x*y, t^2*w, w^3*z]) sage: Y = A.subscheme([y*w + z]) sage: Q = A([0,0,0,0,0]) - sage: X.intersection_multiplicity(Y, Q) + sage: X.intersection_multiplicity(Y, Q) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: the intersection of this subscheme and (=Closed subscheme of Affine Space of dimension 5 @@ -446,30 +449,31 @@ def multiplicity(self, P): sage: A. = AffineSpace(QQ, 4) sage: X = A.subscheme([z*y - x^7, w - 2*z]) sage: Q1 = A([1,1/3,3,6]) - sage: X.multiplicity(Q1) + sage: X.multiplicity(Q1) # needs sage.libs.singular 1 sage: Q2 = A([0,0,0,0]) - sage: X.multiplicity(Q2) + sage: X.multiplicity(Q2) # needs sage.libs.singular 2 :: - sage: A. = AffineSpace(GF(23), 5) # optional - sage.rings.finite_rings - sage: C = A.curve([x^8 - y, y^7 - z, z^3 - 1, w^5 - v^3]) # optional - sage.rings.finite_rings - sage: Q = A([22,1,1,0,0]) # optional - sage.rings.finite_rings - sage: C.multiplicity(Q) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(23), 5) + sage: C = A.curve([x^8 - y, y^7 - z, z^3 - 1, w^5 - v^3]) # needs sage.libs.singular sage.schemes + sage: Q = A([22,1,1,0,0]) + sage: C.multiplicity(Q) # needs sage.libs.singular sage.schemes 3 :: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 5) # optional - sage.rings.number_field - sage: X = A.subscheme([y^7 - x^2*z^5 + z^3*t^8 - x^2*y^4*z - t^8]) # optional - sage.rings.number_field - sage: Q1 = A([1,1,0,1,-1]) # optional - sage.rings.number_field - sage: X.multiplicity(Q1) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: A. = AffineSpace(K, 5) + sage: X = A.subscheme([y^7 - x^2*z^5 + z^3*t^8 - x^2*y^4*z - t^8]) + sage: Q1 = A([1,1,0,1,-1]) + sage: X.multiplicity(Q1) 1 - sage: Q2 = A([0,0,0,-a,0]) # optional - sage.rings.number_field - sage: X.multiplicity(Q2) # optional - sage.rings.number_field + sage: Q2 = A([0,0,0,-a,0]) + sage: X.multiplicity(Q2) 7 Check that :trac:`27479` is fixed:: @@ -477,7 +481,7 @@ def multiplicity(self, P): sage: A1. = AffineSpace(QQ, 1) sage: X = A1.subscheme([x^1789 + x]) sage: Q = X([0]) - sage: X.multiplicity(Q) + sage: X.multiplicity(Q) # needs sage.libs.singular 1 """ if not self.base_ring() in Fields(): @@ -543,11 +547,11 @@ def tangent_space(self, p): sage: A3. = AffineSpace(3, QQ) sage: X = A3.subscheme(z - x*y) - sage: X.tangent_space(A3.origin()) + sage: X.tangent_space(A3.origin()) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: z - sage: X.tangent_space(X(1,1,1)) + sage: X.tangent_space(X(1,1,1)) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -x - y + z @@ -555,6 +559,7 @@ def tangent_space(self, p): Tangent space at a point may have higher dimension than the dimension of the point. :: + sage: # needs sage.libs.singular sage: C = Curve([x + y + z, x^2 - y^2*z^2 + z^3]) sage: C.singular_points() [(0, 0, 0)] diff --git a/src/sage/schemes/berkovich/berkovich_cp_element.py b/src/sage/schemes/berkovich/berkovich_cp_element.py index 4611d396fce..bc8307f29e5 100644 --- a/src/sage/schemes/berkovich/berkovich_cp_element.py +++ b/src/sage/schemes/berkovich/berkovich_cp_element.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.padics r""" Elements of Berkovich space. @@ -62,13 +63,13 @@ class Berkovich_Element_Cp(Berkovich_Element): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B(2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: B(2) Type I point centered at 2 + O(3^20) :: - sage: B(0, 1) # optional - sage.rings.padics + sage: B(0, 1) Type II point centered at 0 of radius 3^0 """ @@ -78,8 +79,8 @@ def __init__(self, parent, center, radius=None, power=None, prec=20, space_type= EXAMPLES:: - sage: B = Berkovich_Cp_Affine(5) # optional - sage.rings.padics - sage: B(4) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(5) + sage: B(4) Type I point centered at 4 + O(5^20) """ from sage.rings.function_field.element import is_FunctionFieldElement @@ -426,9 +427,9 @@ def _custom_abs(self, x): :: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: Q1 = B(9) # optional - sage.rings.padics - sage: Q1._custom_abs(Q1.center()) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: Q1 = B(9) + sage: Q1._custom_abs(Q1.center()) 1/9 """ if self._base_type == 'padic field': @@ -450,15 +451,15 @@ def center_function(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(5) # optional - sage.rings.padics - sage: L. = PolynomialRing(Qp(5)) # optional - sage.rings.padics - sage: T = FractionField(L) # optional - sage.rings.padics - sage: f = T(1/t) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(5) + sage: L. = PolynomialRing(Qp(5)) + sage: T = FractionField(L) + sage: f = T(1/t) sage: R. = RR[] sage: Y = FractionField(R) - sage: g = (40*pi)/x # optional - sage.symbolic - sage: Q1 = B(f, g) # optional - sage.rings.padics sage.symbolic - sage: Q1.center_function() # optional - sage.rings.padics sage.symbolic + sage: g = (40*pi)/x # needs sage.symbolic + sage: Q1 = B(f, g) # needs sage.symbolic + sage: Q1.center_function() # needs sage.symbolic (1 + O(5^20))/((1 + O(5^20))*t) """ if self.type_of_point() != 4: @@ -478,15 +479,15 @@ def radius_function(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(5) # optional - sage.rings.padics - sage: L. = PolynomialRing(Qp(5)) # optional - sage.rings.padics - sage: T = FractionField(L) # optional - sage.rings.padics - sage: f = T(1/t) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(5) + sage: L. = PolynomialRing(Qp(5)) + sage: T = FractionField(L) + sage: f = T(1/t) sage: R. = RR[] sage: Y = FractionField(R) - sage: g = (40*pi)/x # optional - sage.symbolic - sage: Q1 = B(f, g) # optional - sage.rings.padics sage.symbolic - sage: Q1.radius_function() # optional - sage.rings.padics sage.symbolic + sage: g = (40*pi)/x # needs sage.symbolic + sage: Q1 = B(f, g) # needs sage.symbolic + sage: Q1.radius_function() # needs sage.symbolic 40.0000000000000*pi/x """ if self.type_of_point() != 4: @@ -506,14 +507,14 @@ def precision(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: d = B([2, 2, 2], [1.761, 1.123, 1.112]) # optional - sage.rings.padics - sage: d.precision() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: d = B([2, 2, 2], [1.761, 1.123, 1.112]) + sage: d.precision() 3 TESTS:: - sage: d.precision == d.prec # optional - sage.rings.padics + sage: d.precision == d.prec True """ if self._type in [1, 2, 3]: @@ -537,8 +538,8 @@ def ideal(self): :: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B(0).ideal() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: B(0).ideal() """ return self.parent().ideal() @@ -557,15 +558,15 @@ def power(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1, 9) # optional - sage.rings.padics - sage: Q1.power() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1, 9) + sage: Q1.power() 2 :: - sage: Q2 = B(1, 4) # optional - sage.rings.padics - sage: Q2.power() # optional - sage.rings.padics + sage: Q2 = B(1, 4) + sage: Q2.power() 1.26185950714291 """ if self._type in [1, 4]: @@ -583,15 +584,15 @@ def radius(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1, 2/5) # optional - sage.rings.padics - sage: Q1.radius() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1, 2/5) + sage: Q1.radius() 0.400000000000000 :: - sage: d = B([2, 2, 2], [1.761, 1.123, 1.112]) # optional - sage.rings.padics - sage: d.radius() # optional - sage.rings.padics + sage: d = B([2, 2, 2], [1.761, 1.123, 1.112]) + sage: d.radius() [1.76100000000000, 1.12300000000000, 1.11200000000000] """ if self._type == 4: @@ -618,38 +619,38 @@ def diameter(self, basepoint=Infinity): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(3) # optional - sage.rings.padics - sage: Q1.diameter() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(3) + sage: Q1.diameter() 0 :: - sage: Q2 = B(1/2, 9) # optional - sage.rings.padics - sage: Q2.diameter() # optional - sage.rings.padics + sage: Q2 = B(1/2, 9) + sage: Q2.diameter() 9.00000000000000 The diameter of a type IV point is the limit of the radii:: - sage: R. = PolynomialRing(Qp(3)) # optional - sage.rings.padics - sage: f = R(2) # optional - sage.rings.padics - sage: S. = PolynomialRing(RR) # optional - sage.rings.padics - sage: S = FractionField(S) # optional - sage.rings.padics - sage: g = (y+1)/y # optional - sage.rings.padics - sage: B(f,g).diameter() # optional - sage.rings.padics + sage: R. = PolynomialRing(Qp(3)) + sage: f = R(2) + sage: S. = PolynomialRing(RR) + sage: S = FractionField(S) + sage: g = (y+1)/y + sage: B(f,g).diameter() 1.0 :: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1/81, 1) # optional - sage.rings.padics - sage: Q2 = B(1/3) # optional - sage.rings.padics - sage: Q1.diameter(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1/81, 1) + sage: Q2 = B(1/3) + sage: Q1.diameter(Q2) 0.00137174211248285 :: - sage: Q2.diameter(Q2) # optional - sage.rings.padics + sage: Q2.diameter(Q2) +infinity """ if basepoint == Infinity: @@ -693,21 +694,21 @@ def path_distance_metric(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1/4, 4) # optional - sage.rings.padics - sage: Q2 = B(1/4, 6) # optional - sage.rings.padics - sage: Q1.path_distance_metric(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1/4, 4) + sage: Q2 = B(1/4, 6) + sage: Q1.path_distance_metric(Q2) 0.369070246428542 :: - sage: Q3 = B(1) # optional - sage.rings.padics - sage: Q3.path_distance_metric(Q1) # optional - sage.rings.padics + sage: Q3 = B(1) + sage: Q3.path_distance_metric(Q1) +infinity :: - sage: Q3.path_distance_metric(Q3) # optional - sage.rings.padics + sage: Q3.path_distance_metric(Q3) 0 """ if not isinstance(other, type(self)): @@ -744,20 +745,20 @@ def Hsia_kernel(self, other, basepoint): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(2, 9) # optional - sage.rings.padics - sage: Q2 = B(1/27, 1/27) # optional - sage.rings.padics - sage: Q3 = B(1, 1/3) # optional - sage.rings.padics - sage: Q1.Hsia_kernel(Q2, Q3) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(2, 9) + sage: Q2 = B(1/27, 1/27) + sage: Q3 = B(1, 1/3) + sage: Q1.Hsia_kernel(Q2, Q3) 0.111111111111111 :: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(2, 9) # optional - sage.rings.padics - sage: Q2 = B(1/2) # optional - sage.rings.padics - sage: Q3 = B(1/2) # optional - sage.rings.padics - sage: Q1.Hsia_kernel(Q2, Q3) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(2, 9) + sage: Q2 = B(1/2) + sage: Q3 = B(1/2) + sage: Q1.Hsia_kernel(Q2, Q3) +infinity """ @@ -790,10 +791,10 @@ def small_metric(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1/4, 4) # optional - sage.rings.padics - sage: Q2 = B(1/4, 6) # optional - sage.rings.padics - sage: Q1.small_metric(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1/4, 4) + sage: Q2 = B(1/4, 6) + sage: Q1.small_metric(Q2) 0.0833333333333333 :: @@ -853,20 +854,20 @@ def potential_kernel(self, other, basepoint): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(27, 1) # optional - sage.rings.padics - sage: Q2 = B(1/3, 2) # optional - sage.rings.padics - sage: Q3 = B(1/9, 1/2) # optional - sage.rings.padics - sage: Q3.potential_kernel(Q1, Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(27, 1) + sage: Q2 = B(1/3, 2) + sage: Q3 = B(1/9, 1/2) + sage: Q3.potential_kernel(Q1, Q2) 0.369070246428543 :: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(27, 1) # optional - sage.rings.padics - sage: Q2 = B(1/3, 2) # optional - sage.rings.padics - sage: Q3 = B(1/9, 1/2) # optional - sage.rings.padics - sage: Q3.potential_kernel(Q1, Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(27, 1) + sage: Q2 = B(1/3, 2) + sage: Q3 = B(1/9, 1/2) + sage: Q3.potential_kernel(Q1, Q2) 0.369070246428543 """ if not isinstance(other, type(self)): @@ -895,16 +896,16 @@ def spherical_kernel(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(2, 2) # optional - sage.rings.padics - sage: Q2 = B(1/9, 1) # optional - sage.rings.padics - sage: Q1.spherical_kernel(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(2, 2) + sage: Q2 = B(1/9, 1) + sage: Q1.spherical_kernel(Q2) 0.500000000000000 :: - sage: Q3 = B(2) # optional - sage.rings.padics - sage: Q3.spherical_kernel(Q3) # optional - sage.rings.padics + sage: Q3 = B(2) + sage: Q3.spherical_kernel(Q3) 0 """ if not isinstance(other, type(self)): @@ -933,21 +934,22 @@ def Hsia_kernel_infinity(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: Q1 = B(1/4, 4) # optional - sage.rings.padics - sage: Q2 = B(1/4, 6) # optional - sage.rings.padics - sage: Q1.Hsia_kernel_infinity(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: Q1 = B(1/4, 4) + sage: Q2 = B(1/4, 6) + sage: Q1.Hsia_kernel_infinity(Q2) 6.00000000000000 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.ideal(-1/2*a^2 + a - 3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: Q1 = B(4) # optional - sage.rings.number_field - sage: Q2 = B(0, 1.5) # optional - sage.rings.number_field - sage: Q1.Hsia_kernel_infinity(Q2) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.ideal(-1/2*a^2 + a - 3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: Q1 = B(4) + sage: Q2 = B(0, 1.5) + sage: Q1.Hsia_kernel_infinity(Q2) 1.50000000000000 """ return self.join(other).diameter() @@ -961,23 +963,24 @@ def center(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B(3, 1).center() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: B(3, 1).center() 3 + O(3^21) :: - sage: C = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: C(3, 1).center() # optional - sage.rings.padics + sage: C = Berkovich_Cp_Projective(3) + sage: C(3, 1).center() (3 + O(3^21) : 1 + O(3^20)) :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.ideal(-1/2*a^2 + a - 3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: B(a^2 + 4).center() # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.ideal(-1/2*a^2 + a - 3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: B(a^2 + 4).center() (a^2 + 4 : 1) """ if self._type == 4: @@ -992,13 +995,13 @@ def type_of_point(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B(1).type_of_point() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: B(1).type_of_point() 1 :: - sage: B(0, 1).type_of_point() # optional - sage.rings.padics + sage: B(0, 1).type_of_point() 2 """ return ZZ(self._type) @@ -1011,8 +1014,8 @@ def prime(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B(1).prime() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: B(1).prime() 3 """ return ZZ(self._p) @@ -1023,10 +1026,11 @@ def __ne__(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(3, 3**(1/2)) # optional - sage.rings.padics sage.symbolic - sage: Q2 = B(3, RR(3**(1/2))) # optional - sage.rings.padics sage.symbolic - sage: Q1 != Q2 # optional - sage.rings.padics sage.symbolic + sage: # needs sage.symbolic + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(3, 3**(1/2)) + sage: Q2 = B(3, RR(3**(1/2))) + sage: Q1 != Q2 False """ return not (self == other) @@ -1037,8 +1041,8 @@ def _repr_(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B(2, 1) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: B(2, 1) Type II point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 3^0 """ if self._type == 1: @@ -1067,8 +1071,8 @@ def _latex_(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: latex(B(2, 1)) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: latex(B(2, 1)) \text{type 2 Point of } \text{Projective Berkovich line over } \Bold{C}_{3} \text{equivalent to the disk centered at (2 + O(3^20) : 1 + O(3^20)) of radius 1.00000000000000 in } \Bold{C}_3 @@ -1132,122 +1136,113 @@ class Berkovich_Element_Cp_Affine(Berkovich_Element_Cp): Type I points can be created by specifying the corresponding point of ``Cp``:: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: B(4) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: B(4) Type I point centered at 1 + 3 + O(3^20) The center of a point can be an element of a finite extension of ``Qp``:: - sage: A. = Qq(27) # optional - sage.rings.padics - sage: B(1 + t) # optional - sage.rings.padics + sage: A. = Qq(27) + sage: B(1 + t) Type I point centered at (t + 1) + O(3^20) Type II and III points can be created by specifying a center and a radius:: - sage: B(2, 3**(1/2)) # optional - sage.rings.padics sage.symbolic + sage: B(2, 3**(1/2)) # needs sage.symbolic Type II point centered at 2 + O(3^20) of radius 3^1/2 :: - sage: B(2, 1.6) # optional - sage.rings.padics + sage: B(2, 1.6) Type III point centered at 2 + O(3^20) of radius 1.60000000000000 Some type II points may be mistaken for type III points:: - sage: B(3, 3**0.5) #not tested # optional - sage.rings.padics + sage: B(3, 3**0.5) # not tested Type III point centered at 3 + O(3^21) of radius 1.73205080756888 To avoid these errors, specify the power instead of the radius:: - sage: B(3, power=RR(1/100000)) # optional - sage.rings.padics + sage: B(3, power=RR(1/100000)) Type II point centered at 3 + O(3^21) of radius 3^1/100000 Type IV points can be constructed in a number of ways, the first being from a list of centers and radii used to approximate the point:: - sage: B([Qp(3)(2), Qp(3)(2), Qp(3)(2)], [1.761, 1.123, 1.112]) # optional - sage.rings.padics + sage: B([Qp(3)(2), Qp(3)(2), Qp(3)(2)], [1.761, 1.123, 1.112]) Type IV point of precision 3, approximated by disks centered at [2 + O(3^20), 2 + O(3^20)] ... with radii [1.76100000000000, 1.12300000000000] ... Type IV points can be constructed from univariate functions, with arbitrary precision:: - sage: A. = Qq(27) # optional - sage.rings.padics - sage: R. = PolynomialRing(A) # optional - sage.rings.padics - sage: f = (1 + t)^2*x # optional - sage.rings.padics - sage: S. = PolynomialRing(RR) # optional - sage.rings.padics - sage: S = FractionField(S) # optional - sage.rings.padics - sage: g = (y + 1)/y # optional - sage.rings.padics - sage: d = B(f, g, prec=100); d # optional - sage.rings.padics + sage: A. = Qq(27) + sage: R. = PolynomialRing(A) + sage: f = (1 + t)^2*x + sage: S. = PolynomialRing(RR) + sage: S = FractionField(S) + sage: g = (y + 1)/y + sage: d = B(f, g, prec=100); d Type IV point of precision 100 with centers given by ((t^2 + 2*t + 1) + O(3^20))*x and radii given by (y + 1.00000000000000)/y For increased performance, ``error_check`` can be set to ``False``. WARNING: with error check set to ``False``, any error in the input will lead to incorrect results:: - sage: B(f, g, prec=100, error_check=False) # optional - sage.rings.padics + sage: B(f, g, prec=100, error_check=False) Type IV point of precision 100 with centers given by ((t^2 + 2*t + 1) + O(3^20))*x and radii given by (y + 1.00000000000000)/y When creating a Berkovich space backed by a number field, points can be created similarly:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: Q1 = B(a); Q1 # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.prime_above(3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: Q1 = B(a); Q1 Type I point centered at (a : 1) :: - sage: B(a + 1, 3) # optional - sage.rings.number_field + sage: B(a + 1, 3) # needs sage.rings.number_field Type II point centered at (a + 1 : 1) of radius 3^1 TESTS:: - sage: A = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = A(3, 1); Q1 # optional - sage.rings.padics + sage: A = Berkovich_Cp_Affine(3) + sage: Q1 = A(3, 1); Q1 Type II point centered at 3 + O(3^21) of radius 3^0 - - sage: Q2 = A(2.5, 1); Q2 # optional - sage.rings.padics + sage: Q2 = A(2.5, 1); Q2 Type II point centered at 1 + 2*3 + 3^2 + 3^3 + 3^4 + 3^5 + 3^6 + 3^7 + 3^8 + 3^9 + 3^10 + 3^11 + 3^12 + 3^13 + 3^14 + 3^15 + 3^16 + 3^17 + 3^18 + 3^19 + O(3^20) of radius 3^0 - - sage: Q5 = A(3, 0); Q5 # optional - sage.rings.padics + sage: Q5 = A(3, 0); Q5 Type I point centered at 3 + O(3^21) - - sage: A(Zp(3)(2), 2).center().parent() == A(Qp(3)(2), 2).center().parent() # optional - sage.rings.padics + sage: A(Zp(3)(2), 2).center().parent() == A(Qp(3)(2), 2).center().parent() True - - sage: Q1 == Q2 # optional - sage.rings.padics + sage: Q1 == Q2 True - - sage: Q1 == Q5 # optional - sage.rings.padics + sage: Q1 == Q5 False - - sage: Q3 = A(Qp(3)(3), power=0, error_check=False); Q3 # optional - sage.rings.padics + sage: Q3 = A(Qp(3)(3), power=0, error_check=False); Q3 Type II point centered at 3 + O(3^21) of radius 3^0 - - sage: Q4 = A(3, 3**0); Q4 # optional - sage.rings.padics + sage: Q4 = A(3, 3**0); Q4 Type II point centered at 3 + O(3^21) of radius 3^0 - - sage: Q5 = A(3, power=1/2); Q5 # optional - sage.rings.padics + sage: Q5 = A(3, power=1/2); Q5 Type II point centered at 3 + O(3^21) of radius 3^1/2 - - sage: Q6 = A(3, RR(3**(1/2))); Q6 # optional - sage.rings.padics sage.symbolic + sage: Q6 = A(3, RR(3**(1/2))); Q6 # needs sage.symbolic Type III point centered at 3 + O(3^21) of radius 1.73205080756888 - - sage: Q5 == Q6 # optional - sage.rings.padics sage.symbolic + sage: Q5 == Q6 # needs sage.symbolic True - sage: k = Qp(5) # optional - sage.rings.padics - sage: R. = k[] # optional - sage.rings.padics - sage: l. = k.extension(x^2 - 5) # optional - sage.rings.padics - sage: B = Berkovich_Cp_Affine(5) # optional - sage.rings.padics - sage: B(w, power=1) # optional - sage.rings.padics + sage: k = Qp(5) + sage: R. = k[] + sage: l. = k.extension(x^2 - 5) + sage: B = Berkovich_Cp_Affine(5) + sage: B(w, power=1) Type II point centered at w + O(w^41) of radius 5^1 - sage: TestSuite(Q5).run() # optional - sage.rings.padics + sage: TestSuite(Q5).run() """ def __init__(self, parent, center, radius=None, power=None, prec=20, error_check=True): @@ -1256,8 +1251,8 @@ def __init__(self, parent, center, radius=None, power=None, prec=20, error_check EXAMPLES:: - sage: A = Berkovich_Cp_Affine(17) # optional - sage.rings.padics - sage: A(5, 1) # optional - sage.rings.padics + sage: A = Berkovich_Cp_Affine(17) + sage: A(5, 1) Type II point centered at 5 + O(17^20) of radius 17^0 """ # we call Berkovich_Element_Cp constructor which is shared with projective Berkovich space @@ -1283,25 +1278,25 @@ def as_projective_point(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(5) # optional - sage.rings.padics - sage: B(5).as_projective_point() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(5) + sage: B(5).as_projective_point() Type I point centered at (5 + O(5^21) : 1 + O(5^20)) :: - sage: B(0, 1).as_projective_point() # optional - sage.rings.padics + sage: B(0, 1).as_projective_point() Type II point centered at (0 : 1 + O(5^20)) of radius 5^0 :: - sage: L. = PolynomialRing(Qp(5)) # optional - sage.rings.padics - sage: T = FractionField(L) # optional - sage.rings.padics - sage: f = T(1/t) # optional - sage.rings.padics - sage: R. = RR[] # optional - sage.rings.padics - sage: Y = FractionField(R) # optional - sage.rings.padics - sage: g = (40*pi)/x # optional - sage.rings.padics sage.symbolic - sage: Q2 = B(f, g) # optional - sage.rings.padics sage.symbolic - sage: Q2.as_projective_point() # optional - sage.rings.padics sage.symbolic + sage: L. = PolynomialRing(Qp(5)) + sage: T = FractionField(L) + sage: f = T(1/t) + sage: R. = RR[] + sage: Y = FractionField(R) + sage: g = (40*pi)/x # needs sage.symbolic + sage: Q2 = B(f, g) # needs sage.symbolic + sage: Q2.as_projective_point() # needs sage.symbolic Type IV point of precision 20 with centers given by (1 + O(5^20))/((1 + O(5^20))*t) and radii given by 40.0000000000000*pi/x """ @@ -1329,28 +1324,28 @@ def __eq__(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(1, RR(3**(1/2))) # optional - sage.rings.padics sage.symbolic - sage: Q2 = B(1, 3**(1/2)) # optional - sage.rings.padics sage.symbolic - sage: Q1 == Q2 # optional - sage.rings.padics sage.symbolic + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(1, RR(3**(1/2))) # needs sage.symbolic + sage: Q2 = B(1, 3**(1/2)) # needs sage.symbolic + sage: Q1 == Q2 # needs sage.symbolic True :: - sage: Q3 = B(1) # optional - sage.rings.padics - sage: Q4 = B(4) # optional - sage.rings.padics - sage: Q3 == Q4 # optional - sage.rings.padics + sage: Q3 = B(1) + sage: Q4 = B(4) + sage: Q3 == Q4 False :: - sage: Q5 = B(1, 4) # optional - sage.rings.padics - sage: Q1 == Q5 # optional - sage.rings.padics sage.symbolic + sage: Q5 = B(1, 4) + sage: Q1 == Q5 # needs sage.symbolic False :: - sage: Q1 == Q3 # optional - sage.rings.padics sage.symbolic + sage: Q1 == Q3 # needs sage.symbolic False """ if other is self: @@ -1379,21 +1374,22 @@ def __hash__(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1, RR(3**(1/2))) # optional - sage.rings.padics sage.symbolic - sage: Q2 = B(1, 3**(1/2)) # optional - sage.rings.padics sage.symbolic - sage: hash(Q1) == hash(Q2) # optional - sage.rings.padics sage.symbolic + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1, RR(3**(1/2))) # needs sage.symbolic + sage: Q2 = B(1, 3**(1/2)) # needs sage.symbolic + sage: hash(Q1) == hash(Q2) # needs sage.symbolic True :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.ideal(-1/2*a^2 + a - 3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: Q1 = B(a^2 + 1, 2) # optional - sage.rings.number_field - sage: Q2 = B(0, 2) # optional - sage.rings.number_field - sage: hash(Q1) == hash(Q2) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.ideal(-1/2*a^2 + a - 3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: Q1 = B(a^2 + 1, 2) + sage: Q2 = B(0, 2) + sage: hash(Q1) == hash(Q2) True """ if self.type_of_point() == 1: @@ -1425,40 +1421,40 @@ def lt(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(5, 0.5) # optional - sage.rings.padics - sage: Q2 = B(5, 1) # optional - sage.rings.padics - sage: Q1.lt(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(5, 0.5) + sage: Q2 = B(5, 1) + sage: Q1.lt(Q2) True :: - sage: Q3 = B(1) # optional - sage.rings.padics - sage: Q1.lt(Q3) # optional - sage.rings.padics + sage: Q3 = B(1) + sage: Q1.lt(Q3) False TESTS:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(5) # optional - sage.rings.padics - sage: Q1.lt(Q1) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(5) + sage: Q1.lt(Q1) False :: - sage: Q2 = B([4, 1/3], [5, 1]) # optional - sage.rings.padics - sage: Q1.lt(Q2) # optional - sage.rings.padics + sage: Q2 = B([4, 1/3], [5, 1]) + sage: Q1.lt(Q2) False :: - sage: Q4 = B(0, 1) # optional - sage.rings.padics - sage: Q1.lt(Q4) # optional - sage.rings.padics + sage: Q4 = B(0, 1) + sage: Q1.lt(Q4) True :: - sage: Q2.lt(Q4) # optional - sage.rings.padics + sage: Q2.lt(Q4) False """ if not isinstance(other, Berkovich_Element_Cp_Affine): @@ -1569,40 +1565,40 @@ def join(self, other, basepoint=Infinity): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(2, 1) # optional - sage.rings.padics - sage: Q2 = B(2, 2) # optional - sage.rings.padics - sage: Q1.join(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(2, 1) + sage: Q2 = B(2, 2) + sage: Q1.join(Q2) Type III point centered at 2 + O(3^20) of radius 2.00000000000000 :: - sage: Q3 = B(5) # optional - sage.rings.padics - sage: Q3.join(Q1) # optional - sage.rings.padics + sage: Q3 = B(5) + sage: Q3.join(Q1) Type II point centered at 2 + 3 + O(3^20) of radius 3^0 :: - sage: Q3.join(Q1, basepoint=Q2) # optional - sage.rings.padics + sage: Q3.join(Q1, basepoint=Q2) Type II point centered at 2 + O(3^20) of radius 3^0 TESTS:: - sage: Q4 = B(1/3**8 + 2, 1) # optional - sage.rings.padics - sage: Q2.join(Q4, basepoint=Q1) # optional - sage.rings.padics + sage: Q4 = B(1/3**8 + 2, 1) + sage: Q2.join(Q4, basepoint=Q1) Type III point centered at 2 + O(3^20) of radius 2.00000000000000 :: - sage: Q5 = B(2, 1/9) # optional - sage.rings.padics - sage: Q6 = B(1, 1/27) # optional - sage.rings.padics - sage: Q4.join(Q5, basepoint=Q6) # optional - sage.rings.padics + sage: Q5 = B(2, 1/9) + sage: Q6 = B(1, 1/27) + sage: Q4.join(Q5, basepoint=Q6) Type II point centered at 1 + O(3^20) of radius 3^0 :: - sage: Q7 = B(1/27, 1/27) # optional - sage.rings.padics - sage: Q1.join(Q7, Q2) # optional - sage.rings.padics + sage: Q7 = B(1/27, 1/27) + sage: Q1.join(Q7, Q2) Type III point centered at 2 + O(3^20) of radius 2.00000000000000 """ # we error check and then pass to projective space to do the join @@ -1648,46 +1644,46 @@ def involution_map(self): The involution map is 1/z on type I points:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: Q1 = B(1/2) # optional - sage.rings.padics - sage: Q1.involution_map() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: Q1 = B(1/2) + sage: Q1.involution_map() Type I point centered at 2 + O(3^20) :: - sage: Q2 = B(0, 1/3) # optional - sage.rings.padics - sage: Q2.involution_map() # optional - sage.rings.padics + sage: Q2 = B(0, 1/3) + sage: Q2.involution_map() Type II point centered at 0 of radius 3^1 :: - sage: Q3 = B(1/3, 1/3) # optional - sage.rings.padics - sage: Q3.involution_map() # optional - sage.rings.padics + sage: Q3 = B(1/3, 1/3) + sage: Q3.involution_map() Type II point centered at 3 + O(3^21) of radius 3^-3 TESTS:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B(0).involution_map() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: B(0).involution_map() Traceback (most recent call last): ... ValueError: involution map not defined on affine type I point centered at 0 :: - sage: B(1/81, 1.5).involution_map() # optional - sage.rings.padics + sage: B(1/81, 1.5).involution_map() Type III point centered at 3^4 + O(3^24) of radius 0.000228623685413809 :: - sage: B([1, 2], [3, 1]).involution_map() # optional - sage.rings.padics + sage: B([1, 2], [3, 1]).involution_map() Traceback (most recent call last): ... ValueError: precision of type IV is not high enough to define image :: - sage: B([1/81, 10/81], [10, 9]).involution_map() # optional - sage.rings.padics + sage: B([1/81, 10/81], [10, 9]).involution_map() Type IV point of precision 2, approximated by disks centered at [3^4 + O(3^24), 3^4 + 2*3^6 + 2*3^7 + 2*3^10 + 2*3^11 + 2*3^14 + 2*3^15 + 2*3^18 + 2*3^19 + 2*3^22 + 2*3^23 + O(3^24)] ... with radii [0.00152415790275873, 0.00137174211248285] ... @@ -1741,17 +1737,17 @@ def contained_in_interval(self, start, end): EXAMPLES:: - sage: B = Berkovich_Cp_Projective((3)) # optional - sage.rings.padics - sage: Q1 = B(2, 1) # optional - sage.rings.padics - sage: Q2 = B(2, 4) # optional - sage.rings.padics - sage: Q3 = B(1/3) # optional - sage.rings.padics - sage: Q2.contained_in_interval(Q1, Q3.join(Q1)) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective((3)) + sage: Q1 = B(2, 1) + sage: Q2 = B(2, 4) + sage: Q3 = B(1/3) + sage: Q2.contained_in_interval(Q1, Q3.join(Q1)) False :: - sage: Q4 = B(1/81, 1) # optional - sage.rings.padics - sage: Q2.contained_in_interval(Q1, Q4.join(Q1)) # optional - sage.rings.padics + sage: Q4 = B(1/81, 1) + sage: Q2.contained_in_interval(Q1, Q4.join(Q1)) True """ if not isinstance(start, Berkovich_Element_Cp_Affine): @@ -1821,39 +1817,39 @@ class Berkovich_Element_Cp_Projective(Berkovich_Element_Cp): Type I points can be created by specifying the corresponding point of `P^1(\CC_p)`:: - sage: S = ProjectiveSpace(Qp(5), 1) # optional - sage.rings.padics - sage: P = Berkovich_Cp_Projective(S); P # optional - sage.rings.padics + sage: S = ProjectiveSpace(Qp(5), 1) + sage: P = Berkovich_Cp_Projective(S); P Projective Berkovich line over Cp(5) of precision 20 :: - sage: a = S(0, 1) # optional - sage.rings.padics - sage: Q1 = P(a); Q1 # optional - sage.rings.padics + sage: a = S(0, 1) + sage: Q1 = P(a); Q1 Type I point centered at (0 : 1 + O(5^20)) :: - sage: Q2 = P((1,0)); Q2 # optional - sage.rings.padics + sage: Q2 = P((1,0)); Q2 Type I point centered at (1 + O(5^20) : 0) Type II and III points can be created by specifying a center and a radius:: - sage: Q3 = P((0,5), 5**(3/2)); Q3 # optional - sage.rings.padics sage.symbolic + sage: Q3 = P((0,5), 5**(3/2)); Q3 # needs sage.symbolic Type II point centered at (0 : 1 + O(5^20)) of radius 5^3/2 :: - sage: Q4 = P(0, 3**(3/2)); Q4 # optional - sage.rings.padics sage.symbolic + sage: Q4 = P(0, 3**(3/2)); Q4 # needs sage.symbolic Type III point centered at (0 : 1 + O(5^20)) of radius 5.19615242270663 Type IV points can be created from lists of centers and radii:: - sage: b = S((3,2)) # create centers # optional - sage.rings.padics - sage: c = S((4,3)) # optional - sage.rings.padics - sage: d = S((2,3)) # optional - sage.rings.padics - sage: L = [b, c, d] # optional - sage.rings.padics - sage: R = [1.761, 1.123, 1.112] # optional - sage.rings.padics - sage: Q5 = P(L, R); Q5 # optional - sage.rings.padics + sage: b = S((3,2)) # create centers + sage: c = S((4,3)) + sage: d = S((2,3)) + sage: L = [b, c, d] + sage: R = [1.761, 1.123, 1.112] + sage: Q5 = P(L, R); Q5 Type IV point of precision 3, approximated by disks centered at [(4 + 2*5 + 2*5^2 + 2*5^3 + 2*5^4 + 2*5^5 + 2*5^6 + 2*5^7 + 2*5^8 + 2*5^9 + 2*5^10 + 2*5^11 + 2*5^12 + 2*5^13 + 2*5^14 + 2*5^15 + 2*5^16 + 2*5^17 + 2*5^18 + 2*5^19 + O(5^20) : @@ -1865,26 +1861,26 @@ class Berkovich_Element_Cp_Projective(Berkovich_Element_Cp): the sequence of disks can not be the point at infinity in `P^1(\CC_p)`, only functions into `\CC_p` are supported:: - sage: L. = PolynomialRing(Qp(5)) # optional - sage.rings.padics - sage: T = FractionField(L) # optional - sage.rings.padics - sage: f = T(1/t) # optional - sage.rings.padics + sage: L. = PolynomialRing(Qp(5)) + sage: T = FractionField(L) + sage: f = T(1/t) sage: R. = RR[] sage: Y = FractionField(R) - sage: g = (40*pi)/x # optional - sage.rings.padics sage.symbolic - sage: Q6 = P(f, g); Q6 # optional - sage.rings.padics sage.symbolic + sage: g = (40*pi)/x # needs sage.symbolic + sage: Q6 = P(f, g); Q6 # needs sage.symbolic Type IV point of precision 20 with centers given by (1 + O(5^20))/((1 + O(5^20))*t) and radii given by 40.0000000000000*pi/x TESTS:: - sage: P((1,0), 3) # optional - sage.rings.padics + sage: P((1,0), 3) Traceback (most recent call last): ... ValueError: type II and III points can not be centered at infinity - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(3) # optional - sage.rings.padics - sage: TestSuite(Q1).run() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(3) + sage: TestSuite(Q1).run() """ def __init__(self, parent, center, radius=None, power=None, prec=20, error_check=True): @@ -1893,9 +1889,9 @@ def __init__(self, parent, center, radius=None, power=None, prec=20, error_check EXAMPLES:: - sage: S = ProjectiveSpace(Qp(7), 1) # optional - sage.rings.padics - sage: P = Berkovich_Cp_Projective(S) # optional - sage.rings.padics - sage: P(0,1) # optional - sage.rings.padics + sage: S = ProjectiveSpace(Qp(7), 1) + sage: P = Berkovich_Cp_Projective(S) + sage: P(0,1) Type II point centered at (0 : 1 + O(7^20)) of radius 7^0 """ # if we are given a point of Affine Berkovich Space, we do the conversion @@ -1921,27 +1917,27 @@ def as_affine_point(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(5) # optional - sage.rings.padics - sage: B(5).as_affine_point() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(5) + sage: B(5).as_affine_point() Type I point centered at 5 + O(5^21) :: - sage: Q = B(0, 1).as_affine_point(); Q # optional - sage.rings.padics + sage: Q = B(0, 1).as_affine_point(); Q Type II point centered at 0 of radius 5^0 - sage: Q.parent() # optional - sage.rings.padics + sage: Q.parent() Affine Berkovich line over Cp(5) of precision 20 :: - sage: L. = PolynomialRing(Qp(5)) # optional - sage.rings.padics - sage: T = FractionField(L) # optional - sage.rings.padics - sage: f = T(1/t) # optional - sage.rings.padics + sage: L. = PolynomialRing(Qp(5)) + sage: T = FractionField(L) + sage: f = T(1/t) sage: R. = RR[] sage: Y = FractionField(R) - sage: g = (40*pi)/x # optional - sage.rings.padics sage.symbolic - sage: Q2 = B(f, g) # optional - sage.rings.padics sage.symbolic - sage: Q2.as_affine_point() # optional - sage.rings.padics sage.symbolic + sage: g = (40*pi)/x # needs sage.symbolic + sage: Q2 = B(f, g) # needs sage.symbolic + sage: Q2.as_affine_point() # needs sage.symbolic Type IV point of precision 20 with centers given by (1 + O(5^20))/((1 + O(5^20))*t) and radii given by 40.0000000000000*pi/x """ @@ -1973,28 +1969,28 @@ def __eq__(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B([2, 2], RR(3**(1/2))) # optional - sage.rings.padics sage.symbolic - sage: Q2 = B([1, 1], 3**(1/2)) # optional - sage.rings.padics sage.symbolic - sage: Q1 == Q2 # optional - sage.rings.padics sage.symbolic + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B([2, 2], RR(3**(1/2))) # needs sage.symbolic + sage: Q2 = B([1, 1], 3**(1/2)) # needs sage.symbolic + sage: Q1 == Q2 # needs sage.symbolic True :: - sage: Q3 = B(1) # optional - sage.rings.padics - sage: Q4 = B(4) # optional - sage.rings.padics - sage: Q3 == Q4 # optional - sage.rings.padics + sage: Q3 = B(1) + sage: Q4 = B(4) + sage: Q3 == Q4 False :: - sage: Q5 = B(1, 4) # optional - sage.rings.padics - sage: Q1 == Q5 # optional - sage.rings.padics sage.symbolic + sage: Q5 = B(1, 4) + sage: Q1 == Q5 # needs sage.symbolic False :: - sage: Q1 == Q3 # optional - sage.rings.padics sage.symbolic + sage: Q1 == Q3 # needs sage.symbolic False """ if other is self: @@ -2025,22 +2021,23 @@ def __hash__(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: P = ProjectiveSpace(B.base_ring(), 1) # optional - sage.rings.padics - sage: Q1 = B(P.point([2, 2], False), RR(3**(1/2))) # optional - sage.rings.padics sage.symbolic - sage: Q2 = B([1, 1], 3**(1/2)) # optional - sage.rings.padics sage.symbolic - sage: hash(Q1) == hash(Q2) # optional - sage.rings.padics sage.symbolic + sage: B = Berkovich_Cp_Projective(3) + sage: P = ProjectiveSpace(B.base_ring(), 1) + sage: Q1 = B(P.point([2, 2], False), RR(3**(1/2))) # needs sage.symbolic + sage: Q2 = B([1, 1], 3**(1/2)) # needs sage.symbolic + sage: hash(Q1) == hash(Q2) # needs sage.symbolic True :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.ideal(-1/2*a^2 + a - 3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: Q1 = B(a^2 + 1, 2) # optional - sage.rings.number_field - sage: Q2 = B(0, 2) # optional - sage.rings.number_field - sage: hash(Q1) == hash(Q2) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.ideal(-1/2*a^2 + a - 3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: Q1 = B(a^2 + 1, 2) + sage: Q2 = B(0, 2) + sage: hash(Q1) == hash(Q2) True """ if self.type_of_point() == 1: @@ -2072,51 +2069,51 @@ def lt(self, other): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(5, 0.5) # optional - sage.rings.padics - sage: Q2 = B(5, 1) # optional - sage.rings.padics - sage: Q1.lt(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(5, 0.5) + sage: Q2 = B(5, 1) + sage: Q1.lt(Q2) True :: - sage: Q3 = B(1) # optional - sage.rings.padics - sage: Q1.lt(Q3) # optional - sage.rings.padics + sage: Q3 = B(1) + sage: Q1.lt(Q3) False TESTS:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(5) # optional - sage.rings.padics - sage: Q1.lt(Q1) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(5) + sage: Q1.lt(Q1) False :: - sage: Q2 = B([4, 1/3], [5, 1]) # optional - sage.rings.padics - sage: Q1.lt(Q2) # optional - sage.rings.padics + sage: Q2 = B([4, 1/3], [5, 1]) + sage: Q1.lt(Q2) False :: - sage: Q3 = B((1,0)) # optional - sage.rings.padics - sage: Q4 = B(0, 1) # optional - sage.rings.padics - sage: Q3.lt(Q4) # optional - sage.rings.padics + sage: Q3 = B((1,0)) + sage: Q4 = B(0, 1) + sage: Q3.lt(Q4) False :: - sage: Q4.lt(Q3) # optional - sage.rings.padics + sage: Q4.lt(Q3) True :: - sage: Q1.lt(Q4) # optional - sage.rings.padics + sage: Q1.lt(Q4) True :: - sage: Q2.lt(Q4) # optional - sage.rings.padics + sage: Q2.lt(Q4) False """ if not isinstance(other, Berkovich_Element_Cp_Projective): @@ -2251,58 +2248,54 @@ def join(self, other, basepoint=Infinity): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(2, 1) # optional - sage.rings.padics - sage: Q2 = B(2, 2) # optional - sage.rings.padics - sage: Q1.join(Q2) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(2, 1) + sage: Q2 = B(2, 2) + sage: Q1.join(Q2) Type III point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 2.00000000000000 :: - sage: Q3 = B(5) # optional - sage.rings.padics - sage: Q3.join(Q1) # optional - sage.rings.padics + sage: Q3 = B(5) + sage: Q3.join(Q1) Type II point centered at (2 + 3 + O(3^20) : 1 + O(3^20)) of radius 3^0 :: - sage: Q3.join(Q1, basepoint=Q2) # optional - sage.rings.padics + sage: Q3.join(Q1, basepoint=Q2) Type II point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 3^0 TESTS:: - sage: Q4 = B(1/3**8 + 2, 1) # optional - sage.rings.padics - sage: Q2.join(Q4, basepoint=Q1) # optional - sage.rings.padics + sage: Q4 = B(1/3**8 + 2, 1) + sage: Q2.join(Q4, basepoint=Q1) Type III point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 2.00000000000000 - - sage: Q5 = B(2, 1/9) # optional - sage.rings.padics - sage: Q6 = B(1, 1/27) # optional - sage.rings.padics - sage: Q4.join(Q5, basepoint=Q6) # optional - sage.rings.padics + sage: Q5 = B(2, 1/9) + sage: Q6 = B(1, 1/27) + sage: Q4.join(Q5, basepoint=Q6) Type II point centered at (1 + O(3^20) : 1 + O(3^20)) of radius 3^0 - - sage: Q7 = B(1/27, 1/27) # optional - sage.rings.padics - sage: Q1.join(Q7, Q2) # optional - sage.rings.padics + sage: Q7 = B(1/27, 1/27) + sage: Q1.join(Q7, Q2) Type III point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 2.00000000000000 - - sage: Q1.join(Q2, Q7) # optional - sage.rings.padics + sage: Q1.join(Q2, Q7) Type III point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 2.00000000000000 - - sage: Q8 = B(0, power=1/3) # optional - sage.rings.padics - sage: Q9 = B(0, power=1/2) # optional - sage.rings.padics - sage: Q8.join(Q9) # optional - sage.rings.padics + sage: Q8 = B(0, power=1/3) + sage: Q9 = B(0, power=1/2) + sage: Q8.join(Q9) Type II point centered at (0 : 1 + O(3^20)) of radius 3^1/2 + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: C = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: Q10 = C(a, 1/9) # optional - sage.rings.number_field - sage: Q10.join(Q9) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.prime_above(3) + sage: C = Berkovich_Cp_Projective(A, ideal) + sage: Q10 = C(a, 1/9) + sage: Q10.join(Q9) Traceback (most recent call last): ... ValueError: other must be a point of the same projective Berkovich line - - sage: Q11 = C(0, 1/3) # optional - sage.rings.number_field - sage: Q11.join(Q10) # optional - sage.rings.number_field + sage: Q11 = C(0, 1/3) + sage: Q11.join(Q10) Type II point centered at (0 : 1) of radius 3^0 """ if not isinstance(other, Berkovich_Element_Cp_Projective): @@ -2415,49 +2408,49 @@ def involution_map(self): The involution map is 1/z on type I points:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(1/2) # optional - sage.rings.padics - sage: Q1.involution_map() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(1/2) + sage: Q1.involution_map() Type I point centered at (2 + O(3^20) : 1 + O(3^20)) :: - sage: Q2 = B(0, 1/3) # optional - sage.rings.padics - sage: Q2.involution_map() # optional - sage.rings.padics + sage: Q2 = B(0, 1/3) + sage: Q2.involution_map() Type II point centered at (0 : 1 + O(3^20)) of radius 3^1 :: - sage: Q3 = B(1/3, 1/3) # optional - sage.rings.padics - sage: Q3.involution_map() # optional - sage.rings.padics + sage: Q3 = B(1/3, 1/3) + sage: Q3.involution_map() Type II point centered at (3 + O(3^21) : 1 + O(3^20)) of radius 3^-3 TESTS:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B((1,0)).involution_map() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: B((1,0)).involution_map() Type I point centered at (0 : 1 + O(3^20)) :: - sage: B(0).involution_map() # optional - sage.rings.padics + sage: B(0).involution_map() Type I point centered at (1 + O(3^20) : 0) :: - sage: B(1/81, 1.5).involution_map() # optional - sage.rings.padics + sage: B(1/81, 1.5).involution_map() Type III point centered at (3^4 + O(3^24) : 1 + O(3^20)) of radius 0.000228623685413809 :: - sage: B([1, 2], [3, 1]).involution_map() # optional - sage.rings.padics + sage: B([1, 2], [3, 1]).involution_map() Traceback (most recent call last): ... ValueError: precision of type IV is not high enough to define image :: - sage: B([1/81, 10/81], [10, 9]).involution_map() # optional - sage.rings.padics + sage: B([1/81, 10/81], [10, 9]).involution_map() Type IV point of precision 2, approximated by disks centered at [(3^4 + O(3^24) : 1 + O(3^20)), (3^4 + 2*3^6 + 2*3^7 + 2*3^10 + 2*3^11 + 2*3^14 + 2*3^15 + 2*3^18 + 2*3^19 + 2*3^22 + 2*3^23 + O(3^24) : 1 + O(3^20))] @@ -2514,48 +2507,48 @@ def contained_in_interval(self, start, end): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: Q1 = B(2, 1) # optional - sage.rings.padics - sage: Q2 = B(2, 4) # optional - sage.rings.padics - sage: Q3 = B(1/3) # optional - sage.rings.padics - sage: Q2.contained_in_interval(Q1, Q3.join(Q1)) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: Q1 = B(2, 1) + sage: Q2 = B(2, 4) + sage: Q3 = B(1/3) + sage: Q2.contained_in_interval(Q1, Q3.join(Q1)) False :: - sage: Q4 = B(1/81, 1) # optional - sage.rings.padics - sage: Q2.contained_in_interval(Q1, Q4.join(Q1)) # optional - sage.rings.padics + sage: Q4 = B(1/81, 1) + sage: Q2.contained_in_interval(Q1, Q4.join(Q1)) True TESTS:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: infty = B((1, 0)) # optional - sage.rings.padics - sage: zero = B(0) # optional - sage.rings.padics - sage: gauss = B(0, 1) # optional - sage.rings.padics - sage: infty.contained_in_interval(zero, gauss) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: infty = B((1, 0)) + sage: zero = B(0) + sage: gauss = B(0, 1) + sage: infty.contained_in_interval(zero, gauss) False :: - sage: Q1 = B(1, 3) # optional - sage.rings.padics - sage: infty.contained_in_interval(gauss, Q1) # optional - sage.rings.padics + sage: Q1 = B(1, 3) + sage: infty.contained_in_interval(gauss, Q1) False :: - sage: zero.contained_in_interval(infty, gauss) # optional - sage.rings.padics + sage: zero.contained_in_interval(infty, gauss) False :: - sage: gauss.contained_in_interval(zero, infty) # optional - sage.rings.padics + sage: gauss.contained_in_interval(zero, infty) True :: - sage: Q2 = B(81, 1/3) # optional - sage.rings.padics - sage: gauss.contained_in_interval(infty, Q2) # optional - sage.rings.padics + sage: Q2 = B(81, 1/3) + sage: gauss.contained_in_interval(infty, Q2) True """ if not isinstance(start, Berkovich_Element_Cp_Projective): diff --git a/src/sage/schemes/berkovich/berkovich_space.py b/src/sage/schemes/berkovich/berkovich_space.py index 9e04a0bb61d..100c2807b9d 100644 --- a/src/sage/schemes/berkovich/berkovich_space.py +++ b/src/sage/schemes/berkovich/berkovich_space.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.padics r""" Berkovich Space over `\CC_p` @@ -56,9 +57,9 @@ def is_Berkovich(space) -> bool: EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) sage: from sage.schemes.berkovich.berkovich_space import is_Berkovich - sage: is_Berkovich(B) # optional - sage.rings.padics + sage: is_Berkovich(B) True """ return isinstance(space, Berkovich) @@ -75,9 +76,9 @@ def is_Berkovich_Cp(space) -> bool: EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) sage: from sage.schemes.berkovich.berkovich_space import is_Berkovich - sage: is_Berkovich(B) # optional - sage.rings.padics + sage: is_Berkovich(B) True """ return isinstance(space, Berkovich_Cp) @@ -101,17 +102,18 @@ def residue_characteristic(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B.prime() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: B.prime() 3 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.ideal(-1/2*a^2 + a - 3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Affine(A, ideal) # optional - sage.rings.number_field - sage: B.residue_characteristic() # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.ideal(-1/2*a^2 + a - 3) + sage: B = Berkovich_Cp_Affine(A, ideal) + sage: B.residue_characteristic() 7 """ return self._p @@ -129,8 +131,8 @@ def is_padic_base(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: B.is_padic_base() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: B.is_padic_base() True :: @@ -152,8 +154,8 @@ def is_number_field_base(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(Qp(3)) # optional - sage.rings.padics - sage: B.is_number_field_base() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)) + sage: B.is_number_field_base() False :: @@ -181,11 +183,12 @@ def ideal(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) # optional - sage.rings.number_field - sage: ideal = A.prime_above(5) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: B.ideal() # optional - sage.rings.number_field + sage: A. = NumberField(z^2 + 1) + sage: ideal = A.prime_above(5) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: B.ideal() Fractional ideal (-a - 2) :: @@ -196,8 +199,8 @@ def ideal(self): :: - sage: B = Berkovich_Cp_Projective(Qp(3)) # optional - sage.rings.padics - sage: B.ideal() is None # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(Qp(3)) + sage: B.ideal() is None True """ return self._ideal @@ -208,36 +211,37 @@ def __eq__(self, right): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: A. = Qq(27) # optional - sage.rings.padics - sage: C = Berkovich_Cp_Affine(A) # optional - sage.rings.padics - sage: B == C # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: A. = Qq(27) + sage: C = Berkovich_Cp_Affine(A) + sage: B == C True :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: A_ideal = A.prime_above(2) # optional - sage.rings.number_field - sage: B. = NumberField(x^4 + 1) # optional - sage.rings.number_field - sage: B_ideal = B.prime_above(2) # optional - sage.rings.number_field - sage: C = Berkovich_Cp_Projective(A, A_ideal) # optional - sage.rings.number_field - sage: D = Berkovich_Cp_Projective(B, B_ideal) # optional - sage.rings.number_field - sage: C == D # optional - sage.rings.number_field + sage: A. = NumberField(x^2 + 1) + sage: A_ideal = A.prime_above(2) + sage: B. = NumberField(x^4 + 1) + sage: B_ideal = B.prime_above(2) + sage: C = Berkovich_Cp_Projective(A, A_ideal) + sage: D = Berkovich_Cp_Projective(B, B_ideal) + sage: C == D False :: - sage: C = Berkovich_Cp_Affine(A, A_ideal) # optional - sage.rings.number_field - sage: D = Berkovich_Cp_Affine(B, B_ideal) # optional - sage.rings.number_field - sage: C == D # optional - sage.rings.number_field + sage: C = Berkovich_Cp_Affine(A, A_ideal) # needs sage.rings.number_field + sage: D = Berkovich_Cp_Affine(B, B_ideal) # needs sage.rings.number_field + sage: C == D # needs sage.rings.number_field False :: - sage: A_ideal_2 = A.prime_above(5) # optional - sage.rings.number_field - sage: E = Berkovich_Cp_Affine(A, A_ideal_2) # optional - sage.rings.number_field - sage: C == E + sage: A_ideal_2 = A.prime_above(5) # needs sage.rings.number_field + sage: E = Berkovich_Cp_Affine(A, A_ideal_2) # needs sage.rings.number_field + sage: C == E # needs sage.rings.number_field False """ if not isinstance(right, Berkovich_Cp): @@ -255,10 +259,10 @@ def __ne__(self, right): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(5) # optional - sage.rings.padics - sage: A. = Qq(25) # optional - sage.rings.padics - sage: C = Berkovich_Cp_Affine(A) # optional - sage.rings.padics - sage: B != C # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(5) + sage: A. = Qq(25) + sage: C = Berkovich_Cp_Affine(A) + sage: B != C False """ return not (self == right) @@ -269,16 +273,17 @@ def __hash__(self): EXAMPLES:: - sage: hash(Berkovich_Cp_Projective(3)) # optional - sage.rings.padics + sage: hash(Berkovich_Cp_Projective(3)) 3 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, A.primes_above(5)[0]) # optional - sage.rings.number_field - sage: C = Berkovich_Cp_Projective(A, A.primes_above(5)[1]) # optional - sage.rings.number_field - sage: hash(B) != hash(C) # optional - sage.rings.number_field + sage: A. = NumberField(z^2 + 1) + sage: B = Berkovich_Cp_Projective(A, A.primes_above(5)[0]) + sage: C = Berkovich_Cp_Projective(A, A.primes_above(5)[1]) + sage: hash(B) != hash(C) True """ if self._base_type == 'padic field': @@ -319,57 +324,57 @@ class Berkovich_Cp_Affine(Berkovich_Cp): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3); B Affine Berkovich line over Cp(3) of precision 20 We can create elements:: - sage: B(-2) # optional - sage.rings.padics + sage: B(-2) Type I point centered at 1 + 2*3 + 2*3^2 + 2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + 2*3^7 + 2*3^8 + 2*3^9 + 2*3^10 + 2*3^11 + 2*3^12 + 2*3^13 + 2*3^14 + 2*3^15 + 2*3^16 + 2*3^17 + 2*3^18 + 2*3^19 + O(3^20) :: - sage: B(1, 2) # optional - sage.rings.padics + sage: B(1, 2) Type III point centered at 1 + O(3^20) of radius 2.00000000000000 For details on element creation, see the documentation of :class:`Berkovich_Element_Cp_Affine`. Initializing by passing in `\QQ_p` looks the same:: - sage: B = Berkovich_Cp_Affine(Qp(3)); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3)); B Affine Berkovich line over Cp(3) of precision 20 However, this method allows for more control over behind-the-scenes conversion:: - sage: B = Berkovich_Cp_Affine(Qp(3, 1)); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3, 1)); B Affine Berkovich line over Cp(3) of precision 1 - sage: B(1/2) # optional - sage.rings.padics + sage: B(1/2) Type I point centered at 2 + O(3) Note that this point has very low precision, as ``B`` was initialized with a p-adic field of capped-relative precision one. For high precision, pass in a high precision p-adic field:: - sage: B = Berkovich_Cp_Affine(Qp(3, 1000)); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(Qp(3, 1000)); B Affine Berkovich line over Cp(3) of precision 1000 Points of Berkovich space can be created from points of extensions of `\QQ_p`:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: A. = Qp(3).extension(x^3 - 3) # optional - sage.rings.padics - sage: B(a) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: A. = Qp(3).extension(x^3 - 3) + sage: B(a) Type I point centered at a + O(a^61) For exact computation, a number field can be used:: sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Affine(A, ideal); B # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) # needs sage.rings.number_field + sage: ideal = A.prime_above(3) # needs sage.rings.number_field + sage: B = Berkovich_Cp_Affine(A, ideal); B # needs sage.rings.number_field Affine Berkovich line over Cp(3), with base Number Field in a with defining polynomial x^3 + 20 @@ -386,12 +391,13 @@ class Berkovich_Cp_Affine(Berkovich_Cp): field, any point of a Berkovich space backed by a number field must be centered at a point of that number field:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Affine(A, ideal) # optional - sage.rings.number_field - sage: C. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: B(c) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.prime_above(3) + sage: B = Berkovich_Cp_Affine(A, ideal) + sage: C. = NumberField(x^2 + 1) + sage: B(c) Traceback (most recent call last): ... ValueError: could not convert c to Number Field in a @@ -399,14 +405,14 @@ class Berkovich_Cp_Affine(Berkovich_Cp): TESTS:: - sage: A. = AffineSpace(Qp(3), 1) # optional - sage.rings.padics - sage: Berkovich_Cp_Affine(A) # optional - sage.rings.padics + sage: A. = AffineSpace(Qp(3), 1) + sage: Berkovich_Cp_Affine(A) Affine Berkovich line over Cp(3) of precision 20 :: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: TestSuite(B).run() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: TestSuite(B).run() """ Element = Berkovich_Element_Cp_Affine @@ -417,7 +423,7 @@ def __init__(self, base, ideal=None): EXAMPLES:: - sage: Berkovich_Cp_Affine(3) # optional - sage.rings.padics + sage: Berkovich_Cp_Affine(3) Affine Berkovich line over Cp(3) of precision 20 """ if base in ZZ: @@ -463,16 +469,15 @@ def _repr_(self): EXAMPLES:: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3); B Affine Berkovich line over Cp(3) of precision 20 :: sage: R. = QQ[] - sage: A. = NumberField(z^2 + 1) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: Berkovich_Cp_Affine(A, ideal) # optional - sage.rings.number_field + sage: A. = NumberField(z^2 + 1) # needs sage.rings.number_field + sage: ideal = A.prime_above(3) # needs sage.rings.number_field + sage: Berkovich_Cp_Affine(A, ideal) # needs sage.rings.number_field Affine Berkovich line over Cp(3), with base Number Field in a with defining polynomial z^2 + 1 """ @@ -489,8 +494,8 @@ def _latex_(self): EXAMPLES: - sage: B = Berkovich_Cp_Affine(3) # optional - sage.rings.padics - sage: latex(B) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Affine(3) + sage: latex(B) \text{Affine Berkovich line over } \Bold{C}_{3} """ return r"\text{Affine Berkovich line over } \Bold{C}_{%s}" % (self.prime()) @@ -529,36 +534,36 @@ class Berkovich_Cp_Projective(Berkovich_Cp): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3); B Projective Berkovich line over Cp(3) of precision 20 Elements can be constructed:: - sage: B(1/2) # optional - sage.rings.padics + sage: B(1/2) Type I point centered at (2 + 3 + 3^2 + 3^3 + 3^4 + 3^5 + 3^6 + 3^7 + 3^8 + 3^9 + 3^10 + 3^11 + 3^12 + 3^13 + 3^14 + 3^15 + 3^16 + 3^17 + 3^18 + 3^19 + O(3^20) : 1 + O(3^20)) :: - sage: B(2, 1) # optional - sage.rings.padics + sage: B(2, 1) Type II point centered at (2 + O(3^20) : 1 + O(3^20)) of radius 3^0 For details about element construction, see the documentation of :class:`Berkovich_Element_Cp_Projective`. Initializing a Berkovich projective line by passing in a p-adic space looks the same:: - sage: B = Berkovich_Cp_Projective(Qp(3)); B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(Qp(3)); B Projective Berkovich line over Cp(3) of precision 20 However, this method allows for more control over behind-the-scenes conversion:: - sage: S = Qp(3, 1) # optional - sage.rings.padics - sage: B = Berkovich_Cp_Projective(S); B # optional - sage.rings.padics + sage: S = Qp(3, 1) + sage: B = Berkovich_Cp_Projective(S); B Projective Berkovich line over Cp(3) of precision 1 - sage: Q1 = B(1/2); Q1 # optional - sage.rings.padics + sage: Q1 = B(1/2); Q1 Type I point centered at (2 + O(3) : 1 + O(3)) Note that this point has very low precision, as S has low @@ -566,9 +571,9 @@ class Berkovich_Cp_Projective(Berkovich_Cp): a number field, as long as an ideal is specified:: sage: R. = QQ[] - sage: A. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: ideal = A.prime_above(2) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal); B # optional - sage.rings.number_field + sage: A. = NumberField(x^2 + 1) # needs sage.rings.number_field + sage: ideal = A.prime_above(2) # needs sage.rings.number_field + sage: B = Berkovich_Cp_Projective(A, ideal); B # needs sage.rings.number_field Projective Berkovich line over Cp(2), with base Number Field in a with defining polynomial x^2 + 1 @@ -587,12 +592,13 @@ class Berkovich_Cp_Projective(Berkovich_Cp): field, any point of a Berkovich space backed by a number field must be centered at a point of that number field:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: B = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: C. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: B(c) # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.prime_above(3) + sage: B = Berkovich_Cp_Projective(A, ideal) + sage: C. = NumberField(x^2 + 1) + sage: B(c) Traceback (most recent call last): ... TypeError: could not convert c to Projective Space @@ -600,8 +606,8 @@ class Berkovich_Cp_Projective(Berkovich_Cp): TESTS:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: TestSuite(B).run() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: TestSuite(B).run() """ Element = Berkovich_Element_Cp_Projective @@ -612,7 +618,7 @@ def __init__(self, base, ideal=None): EXAMPLES:: - sage: Berkovich_Cp_Projective(3) # optional - sage.rings.padics + sage: Berkovich_Cp_Projective(3) Projective Berkovich line over Cp(3) of precision 20 """ if base in ZZ: @@ -669,23 +675,24 @@ def base_ring(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B.base_ring() # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: B.base_ring() 3-adic Field with capped relative precision 20 :: - sage: C = Berkovich_Cp_Projective(ProjectiveSpace(Qp(3, 1), 1)) # optional - sage.rings.padics - sage: C.base_ring() # optional - sage.rings.padics + sage: C = Berkovich_Cp_Projective(ProjectiveSpace(Qp(3, 1), 1)) + sage: C.base_ring() 3-adic Field with capped relative precision 1 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(x^3 + 20) # optional - sage.rings.number_field - sage: ideal = A.prime_above(3) # optional - sage.rings.number_field - sage: D = Berkovich_Cp_Projective(A, ideal) # optional - sage.rings.number_field - sage: D.base_ring() # optional - sage.rings.number_field + sage: A. = NumberField(x^3 + 20) + sage: ideal = A.prime_above(3) + sage: D = Berkovich_Cp_Projective(A, ideal) + sage: D.base_ring() Number Field in a with defining polynomial x^3 + 20 """ return self.base().base_ring() @@ -696,16 +703,15 @@ def _repr_(self): EXAMPLES:: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: B # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3); B Projective Berkovich line over Cp(3) of precision 20 :: sage: R. = QQ[] - sage: A. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: v = A.ideal(a + 1) # optional - sage.rings.number_field - sage: Berkovich_Cp_Projective(A, v) # optional - sage.rings.number_field + sage: A. = NumberField(x^2 + 1) # needs sage.rings.number_field + sage: v = A.ideal(a + 1) # needs sage.rings.number_field + sage: Berkovich_Cp_Projective(A, v) # needs sage.rings.number_field Projective Berkovich line over Cp(2), with base Number Field in a with defining polynomial x^2 + 1 """ @@ -722,8 +728,8 @@ def _latex_(self): EXAMPLES: - sage: B = Berkovich_Cp_Projective(3) # optional - sage.rings.padics - sage: latex(B) # optional - sage.rings.padics + sage: B = Berkovich_Cp_Projective(3) + sage: latex(B) \text{Projective Berkovich line over } \Bold{C}_{3} """ return r"\text{Projective Berkovich line over } \Bold{C}_{%s}" % (self.prime()) diff --git a/src/sage/schemes/curves/closed_point.py b/src/sage/schemes/curves/closed_point.py index 84cd5e84cc5..0b5952559c1 100644 --- a/src/sage/schemes/curves/closed_point.py +++ b/src/sage/schemes/curves/closed_point.py @@ -9,30 +9,30 @@ EXAMPLES:: - sage: F. = GF(2) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: C.closed_points() # optional - sage.rings.finite_rings + sage: F. = GF(2) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: C.closed_points() [Point (x, y), Point (x, y + 1)] - sage: C.closed_points(2) # optional - sage.rings.finite_rings + sage: C.closed_points(2) [Point (y^2 + y + 1, x + 1), Point (y^2 + y + 1, x + y), Point (y^2 + y + 1, x + y + 1)] - sage: C.closed_points(3) # optional - sage.rings.finite_rings + sage: C.closed_points(3) [Point (x^2 + x + y, x*y + 1, y^2 + x + 1), Point (x^2 + x + y + 1, x*y + x + 1, y^2 + x)] Closed points of projective curves are represented by homogeneous maximal ideals:: - sage: F. = GF(2) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^3*y + y^3*z + x*z^3) # optional - sage.rings.finite_rings - sage: C.closed_points() # optional - sage.rings.finite_rings + sage: F. = GF(2) + sage: P. = ProjectiveSpace(F, 2) + sage: C = Curve(x^3*y + y^3*z + x*z^3) + sage: C.closed_points() [Point (x, z), Point (x, y), Point (y, z)] - sage: C.closed_points(2) # optional - sage.rings.finite_rings + sage: C.closed_points(2) [Point (y^2 + y*z + z^2, x + y + z)] - sage: C.closed_points(3) # optional - sage.rings.finite_rings + sage: C.closed_points(3) [Point (y^3 + y^2*z + z^3, x + y), Point (y^3 + y*z^2 + z^3, x + z), Point (x^2 + x*z + y*z + z^2, x*y + x*z + z^2, y^2 + x*z), @@ -44,19 +44,19 @@ Rational points are easily converted to closed points and vice versa if the closed point is of degree one:: - sage: F. = GF(2) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^3*y + y^3*z + x*z^3) # optional - sage.rings.finite_rings - sage: p1, p2, p3 = C.closed_points() # optional - sage.rings.finite_rings - sage: p1.rational_point() # optional - sage.rings.finite_rings + sage: F. = GF(2) + sage: P. = ProjectiveSpace(F, 2) + sage: C = Curve(x^3*y + y^3*z + x*z^3) + sage: p1, p2, p3 = C.closed_points() + sage: p1.rational_point() (0 : 1 : 0) - sage: p2.rational_point() # optional - sage.rings.finite_rings + sage: p2.rational_point() (0 : 0 : 1) - sage: p3.rational_point() # optional - sage.rings.finite_rings + sage: p3.rational_point() (1 : 0 : 0) - sage: _.closed_point() # optional - sage.rings.finite_rings + sage: _.closed_point() Point (y, z) - sage: _ == p3 # optional - sage.rings.finite_rings + sage: _ == p3 True AUTHORS: @@ -99,10 +99,11 @@ class IntegralCurveClosedPoint(CurveClosedPoint): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: C.closed_points() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: C.closed_points() [Point (x, y), Point (x, y + 1), Point (x + a, y + a), @@ -118,12 +119,13 @@ def __init__(self, curve, prime_ideal, degree): TESTS:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: p = C([0,0]); p # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: p = C([0,0]); p (0, 0) - sage: loads(dumps(p)) == p # optional - sage.rings.finite_rings + sage: loads(dumps(p)) == p True """ super().__init__(curve.ambient_space(), prime_ideal) @@ -137,12 +139,13 @@ def __hash__(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: p = pts[0] # optional - sage.rings.finite_rings - sage: {p: 1} # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: p = pts[0] + sage: {p: 1} {Point (x, y): 1} """ return hash((self.parent(), self.prime_ideal())) @@ -159,11 +162,12 @@ def _richcmp_(self, other, op): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: pts[0] == pts[1] # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: pts[0] == pts[1] False """ return richcmp((self._curve, self.prime_ideal()), (other._curve, other.prime_ideal()), op) @@ -174,11 +178,12 @@ def _repr_(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: pts[0] # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: pts[0] Point (x, y) """ return "Point ({})".format(', '.join(repr(g) for g in self.prime_ideal().gens())) @@ -189,12 +194,13 @@ def curve(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: p = pts[0] # optional - sage.rings.finite_rings - sage: p.curve() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: p = pts[0] + sage: p.curve() Affine Plane Curve over Finite Field in a of size 2^2 defined by x^3 + y^2 + y """ return self._curve @@ -205,12 +211,13 @@ def degree(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: p = pts[0] # optional - sage.rings.finite_rings - sage: p.degree() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: p = pts[0] + sage: p.degree() 1 """ return self._degree @@ -221,12 +228,13 @@ def places(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: p = pts[0] # optional - sage.rings.finite_rings - sage: p.places() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: p = pts[0] + sage: p.places() [Place (x, y)] """ return self._curve.places_on(self) @@ -239,12 +247,13 @@ def place(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3) # optional - sage.rings.finite_rings - sage: pts = C.closed_points() # optional - sage.rings.finite_rings - sage: p = pts[0] # optional - sage.rings.finite_rings - sage: p.place() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3) + sage: pts = C.closed_points() + sage: p = pts[0] + sage: p.place() Place (x, y) """ return self._curve.places_on(self)[0] @@ -260,9 +269,10 @@ def rational_point(self): EXAMPLES:: - sage: A. = AffineSpace(GF(3^2), 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^5 - x^4 - 2*x^3 - 2*x - 2) # optional - sage.rings.finite_rings - sage: C.closed_points() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: A. = AffineSpace(GF(3^2), 2) + sage: C = Curve(y^2 - x^5 - x^4 - 2*x^3 - 2*x - 2) + sage: C.closed_points() [Point (x, y + (z2 + 1)), Point (x, y + (-z2 - 1)), Point (x + (z2 + 1), y + (z2 - 1)), @@ -273,7 +283,7 @@ def rational_point(self): Point (x + (-z2 - 1), y + (-z2)), Point (x + 1, y + 1), Point (x + 1, y - 1)] - sage: [p.rational_point() for p in _] # optional - sage.rings.finite_rings + sage: [p.rational_point() for p in _] [(0, 2*z2 + 2), (0, z2 + 1), (2*z2 + 2, 2*z2 + 1), @@ -284,7 +294,7 @@ def rational_point(self): (z2 + 1, z2), (2, 2), (2, 1)] - sage: set(_) == set(C.rational_points()) # optional - sage.rings.finite_rings + sage: set(_) == set(C.rational_points()) True """ if self.degree() != 1: @@ -305,21 +315,21 @@ def projective(self, i=0): EXAMPLES:: - sage: F. = GF(2) # optional - sage.rings.finite_rings - sage: A. = AffineSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + y - x^3, A) # optional - sage.rings.finite_rings - sage: p1, p2 = C.closed_points() # optional - sage.rings.finite_rings - sage: p1 # optional - sage.rings.finite_rings + sage: F. = GF(2) + sage: A. = AffineSpace(F, 2) + sage: C = Curve(y^2 + y - x^3, A) + sage: p1, p2 = C.closed_points() + sage: p1 Point (x, y) - sage: p2 # optional - sage.rings.finite_rings + sage: p2 Point (x, y + 1) - sage: p1.projective() # optional - sage.rings.finite_rings + sage: p1.projective() Point (x1, x2) - sage: p2.projective(0) # optional - sage.rings.finite_rings + sage: p2.projective(0) Point (x1, x0 + x2) - sage: p2.projective(1) # optional - sage.rings.finite_rings + sage: p2.projective(1) Point (x0, x1 + x2) - sage: p2.projective(2) # optional - sage.rings.finite_rings + sage: p2.projective(2) Point (x0, x1 + x2) """ C = self.curve() @@ -349,18 +359,19 @@ def rational_point(self): EXAMPLES:: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^3*y + y^3*z + x*z^3) # optional - sage.rings.finite_rings - sage: C.closed_points() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P. = ProjectiveSpace(F, 2) + sage: C = Curve(x^3*y + y^3*z + x*z^3) + sage: C.closed_points() [Point (x, z), Point (x, y), Point (y, z), Point (x + a*z, y + (a + 1)*z), Point (x + (a + 1)*z, y + a*z)] - sage: [p.rational_point() for p in _] # optional - sage.rings.finite_rings + sage: [p.rational_point() for p in _] [(0 : 1 : 0), (0 : 0 : 1), (1 : 0 : 0), (a : a + 1 : 1), (a + 1 : a : 1)] - sage: set(_) == set(C.rational_points()) # optional - sage.rings.finite_rings + sage: set(_) == set(C.rational_points()) True """ if self.degree() != 1: @@ -385,19 +396,19 @@ def affine(self, i=None): EXAMPLES:: - sage: F. = GF(2) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^3*y + y^3*z + x*z^3) # optional - sage.rings.finite_rings - sage: p1, p2, p3 = C.closed_points() # optional - sage.rings.finite_rings - sage: p1.affine() # optional - sage.rings.finite_rings + sage: F. = GF(2) + sage: P. = ProjectiveSpace(F, 2) + sage: C = Curve(x^3*y + y^3*z + x*z^3) + sage: p1, p2, p3 = C.closed_points() + sage: p1.affine() Point (x, z) - sage: p2.affine() # optional - sage.rings.finite_rings + sage: p2.affine() Point (x, y) - sage: p3.affine() # optional - sage.rings.finite_rings + sage: p3.affine() Point (y, z) - sage: p3.affine(0) # optional - sage.rings.finite_rings + sage: p3.affine(0) Point (y, z) - sage: p3.affine(1) # optional - sage.rings.finite_rings + sage: p3.affine(1) Traceback (most recent call last): ... ValueError: not in the affine patch diff --git a/src/sage/schemes/curves/constructor.py b/src/sage/schemes/curves/constructor.py index cb77c914047..6fe15a2efc2 100644 --- a/src/sage/schemes/curves/constructor.py +++ b/src/sage/schemes/curves/constructor.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.singular """ Curve constructor @@ -12,8 +13,8 @@ :: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: Curve(y^2*z^7 - x^9 - x*z^8) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: Curve(y^2*z^7 - x^9 - x*z^8) Projective Plane Curve over Finite Field of size 5 defined by -x^9 + y^2*z^7 - x*z^8 @@ -126,10 +127,10 @@ def Curve(F, A=None): Affine plane curves. :: - sage: x,y = GF(7)['x,y'].gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2 + x^3 + x^10); C # optional - sage.rings.finite_rings + sage: x,y = GF(7)['x,y'].gens() + sage: C = Curve(y^2 + x^3 + x^10); C Affine Plane Curve over Finite Field of size 7 defined by x^10 + x^3 + y^2 - sage: C.genus() # optional - sage.rings.finite_rings + sage: C.genus() 0 sage: x, y = QQ['x,y'].gens() sage: Curve(x^3 + y^3 + 1) @@ -207,11 +208,11 @@ def Curve(F, A=None): The defining polynomial must be nonzero unless the ambient space itself is of dimension 1. :: - sage: P1. = ProjectiveSpace(1, GF(5)) # optional - sage.rings.finite_rings - sage: S = P1.coordinate_ring() # optional - sage.rings.finite_rings - sage: Curve(S(0), P1) # optional - sage.rings.finite_rings + sage: P1. = ProjectiveSpace(1, GF(5)) + sage: S = P1.coordinate_ring() + sage: Curve(S(0), P1) Projective Line over Finite Field of size 5 - sage: Curve(P1) # optional - sage.rings.finite_rings + sage: Curve(P1) Projective Line over Finite Field of size 5 :: diff --git a/src/sage/schemes/curves/curve.py b/src/sage/schemes/curves/curve.py index eaab8e97067..0af6fff803b 100644 --- a/src/sage/schemes/curves/curve.py +++ b/src/sage/schemes/curves/curve.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.singular """ Base class of curves @@ -216,29 +217,29 @@ def geometric_genus(self): Examples of projective curves. :: - sage: P2 = ProjectiveSpace(2, GF(5), names=['x','y','z']) # optional - sage.rings.finite_rings - sage: x, y, z = P2.coordinate_ring().gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: P2 = ProjectiveSpace(2, GF(5), names=['x','y','z']) + sage: x, y, z = P2.coordinate_ring().gens() + sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2) + sage: C.geometric_genus() 1 - sage: C = Curve(y^2*z - x^3) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: C = Curve(y^2*z - x^3) + sage: C.geometric_genus() 0 - sage: C = Curve(x^10 + y^7*z^3 + z^10) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: C = Curve(x^10 + y^7*z^3 + z^10) + sage: C.geometric_genus() 3 Examples of affine curves. :: - sage: x, y = PolynomialRing(GF(5), 2, 'xy').gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^3 - 17*x + y) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: x, y = PolynomialRing(GF(5), 2, 'xy').gens() + sage: C = Curve(y^2 - x^3 - 17*x + y) + sage: C.geometric_genus() 1 - sage: C = Curve(y^2 - x^3) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: C = Curve(y^2 - x^3) + sage: C.geometric_genus() 0 - sage: C = Curve(x^10 + y^7 + 1) # optional - sage.rings.finite_rings - sage: C.geometric_genus() # optional - sage.rings.finite_rings + sage: C = Curve(x^10 + y^7 + 1) + sage: C.geometric_genus() 3 """ @@ -323,13 +324,14 @@ def singular_points(self, F=None): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^8 - a^4 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQ, 2) # optional - sage.rings.number_field - sage: C = Curve([359/12*x*y^2*z^2 + 2*y*z^4 + 187/12*y^3*z^2 + x*z^4 # optional - sage.rings.number_field + sage: K. = NumberField(a^8 - a^4 + 1) + sage: P. = ProjectiveSpace(QQ, 2) + sage: C = Curve([359/12*x*y^2*z^2 + 2*y*z^4 + 187/12*y^3*z^2 + x*z^4 ....: + 67/3*x^2*y*z^2 + 117/4*y^5 + 9*x^5 + 6*x^3*z^2 ....: + 393/4*x*y^4 + 145*x^2*y^3 + 115*x^3*y^2 + 49*x^4*y], P) - sage: sorted(C.singular_points(K), key=str) # optional - sage.rings.number_field + sage: sorted(C.singular_points(K), key=str) [(-1/2*b^5 - 1/2*b^3 + 1/2*b - 1 : 1 : 0), (-2/3*b^4 + 1/3 : 0 : 1), (-b^6 : b^6 : 1), @@ -373,10 +375,10 @@ def is_singular(self, P=None): :: - sage: A. = AffineSpace(GF(11), 3) # optional - sage.rings.finite_rings - sage: C = A.curve([y^3 - z^5, x^5 - y + 1]) # optional - sage.rings.finite_rings - sage: Q = A([7,0,0]) # optional - sage.rings.finite_rings - sage: C.is_singular(Q) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(11), 3) + sage: C = A.curve([y^3 - z^5, x^5 - y + 1]) + sage: Q = A([7,0,0]) + sage: C.is_singular(Q) True """ return not self.is_smooth(P) @@ -406,14 +408,14 @@ def intersects_at(self, C, P): :: - sage: A. = AffineSpace(GF(13), 2) # optional - sage.rings.finite_rings - sage: C = Curve([y + 12*x^5 + 3*x^3 + 7], A) # optional - sage.rings.finite_rings - sage: D = Curve([y^2 + 7*x^2 + 8], A) # optional - sage.rings.finite_rings - sage: Q1 = A([9,6]) # optional - sage.rings.finite_rings - sage: C.intersects_at(D, Q1) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(13), 2) + sage: C = Curve([y + 12*x^5 + 3*x^3 + 7], A) + sage: D = Curve([y^2 + 7*x^2 + 8], A) + sage: Q1 = A([9,6]) + sage: C.intersects_at(D, Q1) True - sage: Q2 = A([3,7]) # optional - sage.rings.finite_rings - sage: C.intersects_at(D, Q2) # optional - sage.rings.finite_rings + sage: Q2 = A([3,7]) + sage: C.intersects_at(D, Q2) False """ if C.ambient_space() != self.ambient_space(): @@ -451,21 +453,22 @@ def intersection_points(self, C, F=None): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^2 + a + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQ, 3) # optional - sage.rings.number_field - sage: C = Curve([y^2 - w*z, w^3 - y^3], P) # optional - sage.rings.number_field - sage: D = Curve([x*y - w*z, z^3 - y^3], P) # optional - sage.rings.number_field - sage: C.intersection_points(D, F=K) # optional - sage.rings.number_field + sage: K. = NumberField(a^2 + a + 1) + sage: P. = ProjectiveSpace(QQ, 3) + sage: C = Curve([y^2 - w*z, w^3 - y^3], P) + sage: D = Curve([x*y - w*z, z^3 - y^3], P) + sage: C.intersection_points(D, F=K) [(-b - 1 : -b - 1 : b : 1), (b : b : -b - 1 : 1), (1 : 0 : 0 : 0), (1 : 1 : 1 : 1)] :: - sage: A. = AffineSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: C = Curve([y^3 - x^3], A) # optional - sage.rings.finite_rings - sage: D = Curve([-x*y^3 + y^4 - 2*x^3 + 2*x^2*y], A) # optional - sage.rings.finite_rings - sage: C.intersection_points(D) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(7), 2) + sage: C = Curve([y^3 - x^3], A) + sage: D = Curve([-x*y^3 + y^4 - 2*x^3 + 2*x^2*y], A) + sage: C.intersection_points(D) [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 3), (5, 5), (5, 6), (6, 6)] :: @@ -506,19 +509,20 @@ def change_ring(self, R): sage: P. = ProjectiveSpace(QQ, 3) sage: C = Curve([x^2 - y^2, z*y - 4/5*w^2], P) - sage: C.change_ring(QuadraticField(-1)) # optional - sage.rings.number_field + sage: C.change_ring(QuadraticField(-1)) # needs sage.rings.number_field Projective Curve over Number Field in a with defining polynomial x^2 + 1 with a = 1*I defined by x^2 - y^2, y*z - 4/5*w^2 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^3 + a^2 - 1) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: C = Curve([K.0*x^2 - x + y^3 - 11], A) # optional - sage.rings.number_field - sage: L = K.embeddings(QQbar) # optional - sage.rings.number_field + sage: K. = NumberField(a^3 + a^2 - 1) + sage: A. = AffineSpace(K, 2) + sage: C = Curve([K.0*x^2 - x + y^3 - 11], A) + sage: L = K.embeddings(QQbar) sage: set_verbose(-1) # suppress warnings for slow computation - sage: C.change_ring(L[0]) # optional - sage.rings.number_field + sage: C.change_ring(L[0]) Affine Plane Curve over Algebraic Field defined by y^3 + (-0.8774388331233464? - 0.744861766619745?*I)*x^2 - x - 11 @@ -526,7 +530,7 @@ def change_ring(self, R): sage: P. = ProjectiveSpace(QQ, 2) sage: C = P.curve([y*x - 18*x^2 + 17*z^2]) - sage: C.change_ring(GF(17)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(17)) Projective Plane Curve over Finite Field of size 17 defined by -x^2 + x*y """ new_AS = self.ambient_space().change_ring(R) diff --git a/src/sage/schemes/curves/point.py b/src/sage/schemes/curves/point.py index 0bfaeae3139..dcc78724497 100644 --- a/src/sage/schemes/curves/point.py +++ b/src/sage/schemes/curves/point.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.singular """ Rational points of curves @@ -12,10 +13,10 @@ or on affine curves:: - sage: A. = AffineSpace(GF(23), 2) # optional - sage.rings.finite_rings - sage: C = Curve([y - y^4 + 17*x^2 - 2*x + 22], A) # optional - sage.rings.finite_rings - sage: Q = C([22,21]) # optional - sage.rings.finite_rings - sage: Q.parent() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(23), 2) + sage: C = Curve([y - y^4 + 17*x^2 - 2*x + 22], A) + sage: Q = C([22,21]) + sage: Q.parent() Set of rational points of Affine Plane Curve over Finite Field of size 23 defined by -y^4 - 6*x^2 - 2*x + y - 1 @@ -71,10 +72,10 @@ def multiplicity(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: C = Curve([y^3*z - 16*x^4], P) # optional - sage.rings.finite_rings - sage: Q = C([0,0,1]) # optional - sage.rings.finite_rings - sage: Q.multiplicity() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 2) + sage: C = Curve([y^3*z - 16*x^4], P) + sage: Q = C([0,0,1]) + sage: Q.multiplicity() 3 """ return self.codomain().multiplicity(self) @@ -113,15 +114,16 @@ def is_ordinary_singularity(self): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^2 - 3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: C = P.curve([x^2*y^3*z^4 - y^6*z^3 - 4*x^2*y^4*z^3 - # optional - sage.rings.number_field + sage: K. = NumberField(a^2 - 3) + sage: P. = ProjectiveSpace(K, 2) + sage: C = P.curve([x^2*y^3*z^4 - y^6*z^3 - 4*x^2*y^4*z^3 - ....: 4*x^4*y^2*z^3 + 3*y^7*z^2 + 10*x^2*y^5*z^2 + 9*x^4*y^3*z^2 + ....: 5*x^6*y*z^2 - 3*y^8*z - 9*x^2*y^6*z - 11*x^4*y^4*z - 7*x^6*y^2*z - ....: 2*x^8*z + y^9 + 2*x^2*y^7 + 3*x^4*y^5 + 4*x^6*y^3 + 2*x^8*y]) - sage: Q = C([-1/2, 1/2, 1]) # optional - sage.rings.number_field - sage: Q.is_ordinary_singularity() # optional - sage.rings.number_field + sage: Q = C([-1/2, 1/2, 1]) + sage: Q.is_ordinary_singularity() True """ return self.codomain().is_ordinary_singularity(self) @@ -146,11 +148,11 @@ def is_transverse(self, D): :: - sage: P. = ProjectiveSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: C = Curve([x^4 - 16*y^3*z], P) # optional - sage.rings.finite_rings - sage: D = Curve([y^2 - z*x], P) # optional - sage.rings.finite_rings - sage: Q = C([0,0,1]) # optional - sage.rings.finite_rings - sage: Q.is_transverse(D) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 2) + sage: C = Curve([x^4 - 16*y^3*z], P) + sage: D = Curve([y^2 - z*x], P) + sage: Q = C([0,0,1]) + sage: Q.is_transverse(D) False """ return self.codomain().is_transverse(D, self) @@ -171,12 +173,12 @@ def closed_point(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: C = Curve([x^4 - 16*y^3*z], P) # optional - sage.rings.finite_rings - sage: C.singular_points() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 2) + sage: C = Curve([x^4 - 16*y^3*z], P) + sage: C.singular_points() [(0 : 0 : 1)] - sage: p = _[0] # optional - sage.rings.finite_rings - sage: p.closed_point() # optional - sage.rings.finite_rings + sage: p = _[0] + sage: p.closed_point() Point (x, y) """ curve = self.codomain() @@ -199,12 +201,12 @@ def places(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: C = Curve([x^4 - 16*y^3*z], P) # optional - sage.rings.finite_rings - sage: C.singular_points() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 2) + sage: C = Curve([x^4 - 16*y^3*z], P) + sage: C.singular_points() [(0 : 0 : 1)] - sage: p = _[0] # optional - sage.rings.finite_rings - sage: p.places() # optional - sage.rings.finite_rings + sage: p = _[0] + sage: p.places() [Place (y)] """ return self.closed_point().places() @@ -215,12 +217,12 @@ def place(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(17), 2) # optional - sage.rings.finite_rings - sage: C = Curve([x^4 - 16*y^3*z], P) # optional - sage.rings.finite_rings - sage: C.singular_points() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 2) + sage: C = Curve([x^4 - 16*y^3*z], P) + sage: C.singular_points() [(0 : 0 : 1)] - sage: p = _[0] # optional - sage.rings.finite_rings - sage: p.place() # optional - sage.rings.finite_rings + sage: p = _[0] + sage: p.place() Place (y) """ return self.closed_point().place() @@ -255,14 +257,15 @@ def is_singular(self): EXAMPLES:: - sage: K = QuadraticField(-1) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 3) # optional - sage.rings.number_field - sage: C = Curve([(x^4 + 2*z + 2)*y, z - y + 1]) # optional - sage.rings.number_field - sage: Q1 = C([0,0,-1]) # optional - sage.rings.number_field - sage: Q1.is_singular() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(-1) + sage: A. = AffineSpace(K, 3) + sage: C = Curve([(x^4 + 2*z + 2)*y, z - y + 1]) + sage: Q1 = C([0,0,-1]) + sage: Q1.is_singular() True - sage: Q2 = C([-K.gen(),0,-1]) # optional - sage.rings.number_field - sage: Q2.is_singular() # optional - sage.rings.number_field + sage: Q2 = C([-K.gen(),0,-1]) + sage: Q2.is_singular() False """ return self.codomain().is_singular(self) @@ -326,10 +329,10 @@ def is_ordinary_singularity(self): :: - sage: A. = AffineSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: C = A.curve([y^2 - x^7 - 6*x^3]) # optional - sage.rings.finite_rings - sage: Q = C([0,0]) # optional - sage.rings.finite_rings - sage: Q.is_ordinary_singularity() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(7), 2) + sage: C = A.curve([y^2 - x^7 - 6*x^3]) + sage: Q = C([0,0]) + sage: Q.is_ordinary_singularity() False """ return self.codomain().is_ordinary_singularity(self) @@ -354,13 +357,14 @@ def is_transverse(self, D): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^2 - 2) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: C = Curve([y^2 + x^2 - 1], A) # optional - sage.rings.number_field - sage: D = Curve([y - x], A) # optional - sage.rings.number_field - sage: Q = C([-1/2*b, -1/2*b]) # optional - sage.rings.number_field - sage: Q.is_transverse(D) # optional - sage.rings.number_field + sage: K. = NumberField(a^2 - 2) + sage: A. = AffineSpace(K, 2) + sage: C = Curve([y^2 + x^2 - 1], A) + sage: D = Curve([y - x], A) + sage: Q = C([-1/2*b, -1/2*b]) + sage: Q.is_transverse(D) True """ return self.codomain().is_transverse(D, self) @@ -383,10 +387,11 @@ def closed_point(self): EXAMPLES:: - sage: A. = AffineSpace(GF(8), 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^5 + y^5 + x*y + 1) # optional - sage.rings.finite_rings - sage: p = C([1,1]) # optional - sage.rings.finite_rings - sage: p.closed_point() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: A. = AffineSpace(GF(8), 2) + sage: C = Curve(x^5 + y^5 + x*y + 1) + sage: p = C([1,1]) + sage: p.closed_point() Point (x + 1, y + 1) """ curve = self.codomain() @@ -402,14 +407,14 @@ def places(self): EXAMPLES:: - sage: A. = AffineSpace(GF(2), 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^5 + y^5 + x*y + 1) # optional - sage.rings.finite_rings - sage: p = C(-1,-1) # optional - sage.rings.finite_rings - sage: p # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(2), 2) + sage: C = Curve(x^5 + y^5 + x*y + 1) + sage: p = C(-1,-1) + sage: p (1, 1) - sage: p.closed_point() # optional - sage.rings.finite_rings + sage: p.closed_point() Point (x + 1, y + 1) - sage: _.places() # optional - sage.rings.finite_rings + sage: _.places() [Place (x + 1, (1/(x^5 + 1))*y^4 + ((x^5 + x^4 + 1)/(x^5 + 1))*y^3 + ((x^5 + x^3 + 1)/(x^5 + 1))*y^2 + (x^2/(x^5 + 1))*y), Place (x + 1, (1/(x^5 + 1))*y^4 + ((x^5 + x^4 + 1)/(x^5 + 1))*y^3 @@ -423,14 +428,14 @@ def place(self): EXAMPLES:: - sage: A. = AffineSpace(GF(2), 2) # optional - sage.rings.finite_rings - sage: C = Curve(x^5 + y^5 + x*y + 1) # optional - sage.rings.finite_rings - sage: p = C(-1,-1) # optional - sage.rings.finite_rings - sage: p # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(2), 2) + sage: C = Curve(x^5 + y^5 + x*y + 1) + sage: p = C(-1,-1) + sage: p (1, 1) - sage: p.closed_point() # optional - sage.rings.finite_rings + sage: p.closed_point() Point (x + 1, y + 1) - sage: _.place() # optional - sage.rings.finite_rings + sage: _.place() Place (x + 1, (1/(x^5 + 1))*y^4 + ((x^5 + x^4 + 1)/(x^5 + 1))*y^3 + ((x^5 + x^3 + 1)/(x^5 + 1))*y^2 + (x^2/(x^5 + 1))*y) """ diff --git a/src/sage/schemes/cyclic_covers/charpoly_frobenius.py b/src/sage/schemes/cyclic_covers/charpoly_frobenius.py index fc5cc3b1c3e..e28289e1d84 100644 --- a/src/sage/schemes/cyclic_covers/charpoly_frobenius.py +++ b/src/sage/schemes/cyclic_covers/charpoly_frobenius.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.padics r""" Computation of the Frobenius polynomial using Newton's identities """ diff --git a/src/sage/schemes/cyclic_covers/constructor.py b/src/sage/schemes/cyclic_covers/constructor.py index d2975336301..99250257121 100644 --- a/src/sage/schemes/cyclic_covers/constructor.py +++ b/src/sage/schemes/cyclic_covers/constructor.py @@ -64,11 +64,11 @@ def CyclicCover(r, f, names=None, check_smooth=True): sage: CyclicCover(15, x^9 + x + 1) Cyclic Cover of P^1 over Rational Field defined by y^15 = x^9 + x + 1 - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: CyclicCover(5, x^9 + x + 1) # optional - sage.rings.finite_rings + sage: k. = GF(9); R. = k[] # needs sage.rings.finite_rings + sage: CyclicCover(5, x^9 + x + 1) # needs sage.rings.finite_rings Cyclic Cover of P^1 over Finite Field in a of size 3^2 defined by y^5 = x^9 + x + 1 - sage: CyclicCover(15, x^9 + x + 1) # optional - sage.rings.finite_rings + sage: CyclicCover(15, x^9 + x + 1) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: As the characteristic divides the order of the cover, @@ -76,20 +76,20 @@ def CyclicCover(r, f, names=None, check_smooth=True): We can change the names of the variables in the output:: - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: CyclicCover(5, x^9 + x + 1, names=["A","B"]) # optional - sage.rings.finite_rings + sage: k. = GF(9); R. = k[] # needs sage.rings.finite_rings + sage: CyclicCover(5, x^9 + x + 1, names=["A","B"]) # needs sage.rings.finite_rings Cyclic Cover of P^1 over Finite Field in a of size 3^2 defined by B^5 = A^9 + A + 1 Double roots:: - sage: P. = GF(7)[] # optional - sage.rings.finite_rings - sage: CyclicCover(2, (x^3-x+2)^2*(x^6-1)) # optional - sage.rings.finite_rings + sage: P. = GF(7)[] + sage: CyclicCover(2, (x^3-x+2)^2*(x^6-1)) Traceback (most recent call last): ... ValueError: Not a smooth Cyclic Cover of P^1: singularity in the provided affine patch. - sage: CyclicCover(2, (x^3-x+2)^2*(x^6-1), check_smooth=False) # optional - sage.rings.finite_rings + sage: CyclicCover(2, (x^3-x+2)^2*(x^6-1), check_smooth=False) # needs sage.rings.finite_rings Cyclic Cover of P^1 over Finite Field of size 7 defined by y^2 = x^12 - 2*x^10 - 3*x^9 + x^8 + 3*x^7 + 3*x^6 + 2*x^4 + 3*x^3 - x^2 - 3*x + 3 diff --git a/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py b/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py index a3104af8175..82583c14cfc 100644 --- a/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py +++ b/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Cyclic covers over a finite field diff --git a/src/sage/schemes/cyclic_covers/cycliccover_generic.py b/src/sage/schemes/cyclic_covers/cycliccover_generic.py index ec852541ad3..9bca8814dad 100644 --- a/src/sage/schemes/cyclic_covers/cycliccover_generic.py +++ b/src/sage/schemes/cyclic_covers/cycliccover_generic.py @@ -12,18 +12,18 @@ Projective Plane Curve over Integer Ring defined by x0^5 + x0^4*x1 + x1^5 - x2^5 sage: D.change_ring(QQ).genus() 6 - sage: C.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(5)) Traceback (most recent call last): ... ValueError: As the characteristic divides the order of the cover, this model is not smooth. - sage: GF7x. = GF(7)[] # optional - sage.rings.finite_rings - sage: C = CyclicCover(3, x^9 + x + 1) # optional - sage.rings.finite_rings - sage: C # optional - sage.rings.finite_rings + sage: GF7x. = GF(7)[] + sage: C = CyclicCover(3, x^9 + x + 1) + sage: C Cyclic Cover of P^1 over Finite Field of size 7 defined by y^3 = x^9 + x + 1 - sage: C.genus() # optional - sage.rings.finite_rings + sage: C.genus() 7 - sage: C.projective_closure() # optional - sage.rings.finite_rings + sage: C.projective_closure() Traceback (most recent call last): ... NotImplementedError: Weighted Projective Space is not implemented @@ -71,20 +71,20 @@ def __init__(self, AA, r, f, names=None): Projective Plane Curve over Integer Ring defined by x0^5 + x0^4*x1 + x1^5 - x2^5 sage: D.change_ring(QQ).genus() 6 - sage: C.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(5)) Traceback (most recent call last): ... ValueError: As the characteristic divides the order of the cover, this model is not smooth. - sage: GF7x. = GF(7)[] # optional - sage.rings.finite_rings - sage: C = CyclicCover(3, x^9 + x + 1) # optional - sage.rings.finite_rings - sage: C # optional - sage.rings.finite_rings + sage: GF7x. = GF(7)[] + sage: C = CyclicCover(3, x^9 + x + 1) + sage: C Cyclic Cover of P^1 over Finite Field of size 7 defined by y^3 = x^9 + x + 1 - sage: C.genus() # optional - sage.rings.finite_rings + sage: C.genus() 7 - sage: C.projective_closure() # optional - sage.rings.finite_rings + sage: C.projective_closure() Traceback (most recent call last): ... NotImplementedError: Weighted Projective Space is not implemented @@ -115,17 +115,17 @@ def change_ring(self, R): sage: ZZx. = ZZ[] sage: C = CyclicCover(5, x^5 + x + 1) - sage: C.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(5)) Traceback (most recent call last): ... ValueError: As the characteristic divides the order of the cover, this model is not smooth. - sage: C.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(3)) Traceback (most recent call last): ... ValueError: Not a smooth Cyclic Cover of P^1: singularity in the provided affine patch. - sage: C.change_ring(GF(17)) # optional - sage.rings.finite_rings + sage: C.change_ring(GF(17)) Cyclic Cover of P^1 over Finite Field of size 17 defined by y^5 = x^5 + x + 1 """ from .constructor import CyclicCover @@ -241,8 +241,8 @@ def projective_closure(self, **kwds): EXAMPLES:: - sage: GF7x. = GF(7)[] # optional - sage.rings.finite_rings - sage: CyclicCover(3, x^9 + x + 1).projective_closure() # optional - sage.rings.finite_rings + sage: GF7x. = GF(7)[] + sage: CyclicCover(3, x^9 + x + 1).projective_closure() Traceback (most recent call last): ... NotImplementedError: Weighted Projective Space is not implemented diff --git a/src/sage/schemes/elliptic_curves/Qcurves.py b/src/sage/schemes/elliptic_curves/Qcurves.py index df577822cc2..45fb5c51293 100644 --- a/src/sage/schemes/elliptic_curves/Qcurves.py +++ b/src/sage/schemes/elliptic_curves/Qcurves.py @@ -130,10 +130,10 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): sage: from sage.schemes.elliptic_curves.Qcurves import is_Q_curve sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(R([3, 0, -5, 0, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([-3,-4,1,1]), K([4,-1,-1,0]), K([-2,0,1,0]), # optional - sage.rings.number_field + sage: K. = NumberField(R([3, 0, -5, 0, 1])) # needs sage.rings.number_field + sage: E = EllipticCurve([K([-3,-4,1,1]), K([4,-1,-1,0]), K([-2,0,1,0]), # needs sage.rings.number_field ....: K([-621,778,138,-178]), K([9509,2046,-24728,10380])]) - sage: is_Q_curve(E, certificate=True, verbose=True) # optional - sage.rings.number_field + sage: is_Q_curve(E, certificate=True, verbose=True) # needs sage.rings.number_field Checking whether Elliptic Curve defined by y^2 + (a^3+a^2-4*a-3)*x*y + (a^2-2)*y = x^3 + (-a^2-a+4)*x^2 + (-178*a^3+138*a^2+778*a-621)*x + (10380*a^3-24728*a^2+2046*a+9509) over Number Field in a with defining polynomial x^4 - 5*x^2 + 3 is a Q-curve No: inconsistency at the 2 primes dividing 3 - potentially multiplicative: [True, False] @@ -143,10 +143,10 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): primes is consistent, but the local test at good primes above `13` is not:: - sage: K. = NumberField(R([-10, 0, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([0,1]), K([-1,-1]), K([0,0]), # optional - sage.rings.number_field + sage: K. = NumberField(R([-10, 0, 1])) # needs sage.rings.number_field + sage: E = EllipticCurve([K([0,1]), K([-1,-1]), K([0,0]), # needs sage.rings.number_field ....: K([-236,40]), K([-1840,464])]) - sage: is_Q_curve(E, certificate=True, verbose=True) # optional - sage.rings.number_field + sage: is_Q_curve(E, certificate=True, verbose=True) # needs sage.rings.number_field Checking whether Elliptic Curve defined by y^2 + a*x*y = x^3 + (-a-1)*x^2 + (40*a-236)*x + (464*a-1840) over Number Field in a with defining polynomial x^2 - 10 is a Q-curve Applying local tests at good primes above p<=100 No: inconsistency at the 2 ordinary primes dividing 13 @@ -158,9 +158,9 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): sage: from sage.schemes.elliptic_curves.Qcurves import is_Q_curve sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(R([-1, -1, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([1,0]), K([-1,0]), K([0,1]), K([0,-2]), K([0,1])]) - sage: is_Q_curve(E, certificate=True, verbose=True) # optional - sage.rings.number_field + sage: K. = NumberField(R([-1, -1, 1])) # needs sage.rings.number_field + sage: E = EllipticCurve([K([1,0]), K([-1,0]), K([0,1]), K([0,-2]), K([0,1])]) # needs sage.rings.number_field + sage: is_Q_curve(E, certificate=True, verbose=True) # needs sage.rings.number_field Checking whether Elliptic Curve defined by y^2 + x*y + a*y = x^3 + (-1)*x^2 + (-2*a)*x + a over Number Field in a with defining polynomial x^2 - x - 1 is a Q-curve Yes: E is CM (discriminant -15) (True, {'CM': -15}) @@ -170,14 +170,15 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): in fact there is an isogenous curve with rational `j`, so we have a so-called rational `\QQ`-curve:: - sage: K. = NumberField(R([1, 0, -4, 0, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([-2,-4,1,1]), K([0,1,0,0]), K([0,1,0,0]), # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(R([1, 0, -4, 0, 1])) + sage: E = EllipticCurve([K([-2,-4,1,1]), K([0,1,0,0]), K([0,1,0,0]), ....: K([-4780,9170,1265,-2463]), ....: K([163923,-316598,-43876,84852])]) - sage: flag, cert = is_Q_curve(E, certificate=True) # optional - sage.rings.number_field - sage: flag # optional - sage.rings.number_field + sage: flag, cert = is_Q_curve(E, certificate=True) + sage: flag True - sage: cert # optional - sage.rings.number_field + sage: cert {'CM': 0, 'N': 1, 'core_degs': [1], 'core_poly': x - 85184/3, 'r': 0, 'rho': 0} Over the same field, a so-called strict `\QQ`-curve which is not @@ -187,12 +188,13 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): quadratic conjugate `j`-invariants in `\QQ(\sqrt{3})` (but which are not base-changes from the quadratic subfield):: - sage: E = EllipticCurve([K([0,-3,0,1]), K([1,4,0,-1]), K([0,0,0,0]), # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve([K([0,-3,0,1]), K([1,4,0,-1]), K([0,0,0,0]), ....: K([-2,-16,0,4]), K([-19,-32,4,8])]) - sage: flag, cert = is_Q_curve(E, certificate=True) # optional - sage.rings.number_field - sage: flag # optional - sage.rings.number_field + sage: flag, cert = is_Q_curve(E, certificate=True) + sage: flag True - sage: cert # optional - sage.rings.number_field + sage: cert {'CM': 0, 'N': 2, 'core_degs': [1, 2], @@ -202,8 +204,8 @@ def is_Q_curve(E, maxp=100, certificate=False, verbose=False): TESTS:: - sage: E = EllipticCurve([GF(5)(t) for t in [2,3,5,7,11]]) # optional - sage.rings.finite_rings - sage: is_Q_curve(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(5)(t) for t in [2,3,5,7,11]]) + sage: is_Q_curve(E) Traceback (most recent call last): ... TypeError: Elliptic Curve defined by ... must be an elliptic curve @@ -431,10 +433,10 @@ def Step4Test(E, B, oldB=0, verbose=False): sage: from sage.schemes.elliptic_curves.Qcurves import Step4Test sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(R([3, 0, -5, 0, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([-3,-4,1,1]), K([4,-1,-1,0]), K([-2,0,1,0]), # optional - sage.rings.number_field + sage: K. = NumberField(R([3, 0, -5, 0, 1])) # needs sage.rings.number_field + sage: E = EllipticCurve([K([-3,-4,1,1]), K([4,-1,-1,0]), K([-2,0,1,0]), # needs sage.rings.number_field ....: K([-621,778,138,-178]), K([9509,2046,-24728,10380])]) - sage: Step4Test(E, 100, verbose=True) # optional - sage.rings.number_field + sage: Step4Test(E, 100, verbose=True) # needs sage.rings.number_field No: inconsistency at the 2 ordinary primes dividing 13 - Frobenius discriminants mod squares: [-3, -1] (False, 13) @@ -444,11 +446,11 @@ def Step4Test(E, B, oldB=0, verbose=False): sage: from sage.schemes.elliptic_curves.Qcurves import Step4Test sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(R([-3, 0, 9, 0, -6, 0, 1])) # optional - sage.rings.number_field - sage: E = EllipticCurve([K([1,-3,0,1,0,0]), K([5,-3,-6,1,1,0]), + sage: K. = NumberField(R([-3, 0, 9, 0, -6, 0, 1])) # needs sage.rings.number_field + sage: E = EllipticCurve([K([1,-3,0,1,0,0]), K([5,-3,-6,1,1,0]), # needs sage.rings.number_field ....: K([1,-3,0,1,0,0]), K([-139,-129,331,277,-76,-63]), ....: K([2466,1898,-5916,-4582,1361,1055])]) - sage: Step4Test(E, 100, verbose=True) + sage: Step4Test(E, 100, verbose=True) # needs sage.rings.number_field (True, 0) """ from sage.arith.misc import primes @@ -506,32 +508,33 @@ def conjugacy_test(jlist, verbose=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.Qcurves import conjugacy_test sage: conjugacy_test([3]) [x - 3] - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: conjugacy_test([K(3), a]) # optional - sage.rings.number_field + sage: K. = QuadraticField(2) + sage: conjugacy_test([K(3), a]) [x - 3] - sage: conjugacy_test([K(3), 3 + a]) # optional - sage.rings.number_field + sage: conjugacy_test([K(3), 3 + a]) [x - 3] - sage: conjugacy_test([3 + a]) # optional - sage.rings.number_field + sage: conjugacy_test([3 + a]) [] - sage: conjugacy_test([3 + a, 3 - a]) # optional - sage.rings.number_field + sage: conjugacy_test([3 + a, 3 - a]) [x^2 - 6*x + 7] - sage: x = polygen(QQ) # optional - sage.rings.number_field + sage: x = polygen(QQ) sage: f = x^3 - 3 - sage: K. = f.splitting_field() # optional - sage.rings.number_field - sage: js = f.roots(K, multiplicities=False) # optional - sage.rings.number_field - sage: conjugacy_test(js) # optional - sage.rings.number_field + sage: K. = f.splitting_field() + sage: js = f.roots(K, multiplicities=False) + sage: conjugacy_test(js) [] - sage: f = x^4 - 3 # optional - sage.rings.number_field - sage: K. = NumberField(f) # optional - sage.rings.number_field - sage: js = f.roots(K, multiplicities=False) # optional - sage.rings.number_field - sage: conjugacy_test(js) # optional - sage.rings.number_field + sage: f = x^4 - 3 + sage: K. = NumberField(f) + sage: js = f.roots(K, multiplicities=False) + sage: conjugacy_test(js) [] - sage: K. = f.splitting_field() # optional - sage.rings.number_field - sage: js = f.roots(K, multiplicities=False) # optional - sage.rings.number_field - sage: conjugacy_test(js) # optional - sage.rings.number_field + sage: K. = f.splitting_field() + sage: js = f.roots(K, multiplicities=False) + sage: conjugacy_test(js) [x^4 - 3] """ from sage.sets.set import Set diff --git a/src/sage/schemes/elliptic_curves/cardinality.py b/src/sage/schemes/elliptic_curves/cardinality.py index 2a73de71a50..d871355c20a 100644 --- a/src/sage/schemes/elliptic_curves/cardinality.py +++ b/src/sage/schemes/elliptic_curves/cardinality.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings """ Specific algorithms to compute cardinality of elliptic curves over a finite field diff --git a/src/sage/schemes/elliptic_curves/cm.py b/src/sage/schemes/elliptic_curves/cm.py index f70f20a69d7..ddfc6bb1d3c 100644 --- a/src/sage/schemes/elliptic_curves/cm.py +++ b/src/sage/schemes/elliptic_curves/cm.py @@ -82,6 +82,7 @@ def hilbert_class_polynomial(D, algorithm=None): EXAMPLES:: + sage: # needs sage.libs.flint sage: hilbert_class_polynomial(-4) x - 1728 sage: hilbert_class_polynomial(-7) @@ -204,8 +205,10 @@ def is_HCP(f, check_monic_irreducible=True): sage: from sage.schemes.elliptic_curves.cm import is_HCP sage: D = -1856563 - sage: D.class_number() + sage: D.class_number() # needs sage.libs.pari 100 + + sage: # needs sage.libs.flint sage: H = hilbert_class_polynomial(D) sage: H.degree() 100 @@ -216,16 +219,19 @@ def is_HCP(f, check_monic_irreducible=True): Testing polynomials which are not HCPs is faster:: - sage: is_HCP(H+1) + sage: is_HCP(H+1) # needs sage.libs.flint 0 TESTS:: + sage: # needs sage.libs.flint sage: from sage.schemes.elliptic_curves.cm import is_HCP - sage: all(is_HCP(hilbert_class_polynomial(D))==D for D in srange(-4,-100,-1) if D.is_discriminant()) + sage: all(is_HCP(hilbert_class_polynomial(D)) == D + ....: for D in srange(-4,-100,-1) if D.is_discriminant()) True - sage: all(not is_HCP(hilbert_class_polynomial(D)+1) for D in srange(-4,-100,-1) if D.is_discriminant()) + sage: all(not is_HCP(hilbert_class_polynomial(D) + 1) + ....: for D in srange(-4,-100,-1) if D.is_discriminant()) True """ zero = ZZ(0) @@ -300,6 +306,7 @@ def OrderClassNumber(D0,h0,f): EXAMPLES:: + sage: # needs sage.libs.pari sage: from sage.schemes.elliptic_curves.cm import OrderClassNumber sage: D0 = -4 sage: h = D0.class_number() @@ -350,25 +357,26 @@ def cm_j_invariants(K, proof=None): Over imaginary quadratic fields there are no more than over `QQ`:: - sage: cm_j_invariants(QuadraticField(-1, 'i')) # optional - sage.rings.number_field + sage: cm_j_invariants(QuadraticField(-1, 'i')) # needs sage.rings.number_field [-262537412640768000, -147197952000, -884736000, -12288000, -884736, -32768, -3375, 0, 1728, 8000, 54000, 287496, 16581375] Over real quadratic fields there may be more, for example:: - sage: len(cm_j_invariants(QuadraticField(5, 'a'))) # optional - sage.rings.number_field + sage: len(cm_j_invariants(QuadraticField(5, 'a'))) # needs sage.rings.number_field 31 Over number fields K of many higher degrees this also works:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: cm_j_invariants(K) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: cm_j_invariants(K) [-262537412640768000, -147197952000, -884736000, -884736, -32768, 8000, -3375, 16581375, 1728, 287496, 0, 54000, -12288000, 31710790944000*a^2 + 39953093016000*a + 50337742902000] - sage: K. = NumberField(x^4 - 2) # optional - sage.rings.number_field - sage: len(cm_j_invariants(K)) # optional - sage.rings.number_field + sage: K. = NumberField(x^4 - 2) + sage: len(cm_j_invariants(K)) 23 """ return sorted(j for D, f, j in cm_j_invariants_and_orders(K, proof=proof)) @@ -400,7 +408,7 @@ def cm_j_invariants_and_orders(K, proof=None): Over an imaginary quadratic field there are no more than over `QQ`:: - sage: cm_j_invariants_and_orders(QuadraticField(-1, 'i')) # optional - sage.rings.number_field + sage: cm_j_invariants_and_orders(QuadraticField(-1, 'i')) # needs sage.rings.number_field [(-163, 1, -262537412640768000), (-67, 1, -147197952000), (-43, 1, -884736000), (-19, 1, -884736), (-11, 1, -32768), (-8, 1, 8000), (-7, 1, -3375), (-7, 2, 16581375), (-4, 1, 1728), @@ -408,9 +416,9 @@ def cm_j_invariants_and_orders(K, proof=None): Over real quadratic fields there may be more:: - sage: v = cm_j_invariants_and_orders(QuadraticField(5,'a')); len(v) # optional - sage.rings.number_field + sage: v = cm_j_invariants_and_orders(QuadraticField(5,'a')); len(v) # needs sage.rings.number_field 31 - sage: [(D, f) for D, f, j in v if j not in QQ] # optional - sage.rings.number_field + sage: [(D, f) for D, f, j in v if j not in QQ] # needs sage.rings.number_field [(-235, 1), (-235, 1), (-115, 1), (-115, 1), (-40, 1), (-40, 1), (-35, 1), (-35, 1), (-20, 1), (-20, 1), (-15, 1), (-15, 1), (-15, 2), (-15, 2), (-4, 5), (-4, 5), (-3, 5), (-3, 5)] @@ -418,8 +426,8 @@ def cm_j_invariants_and_orders(K, proof=None): Over number fields K of many higher degrees this also works:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: cm_j_invariants_and_orders(K) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: cm_j_invariants_and_orders(K) # needs sage.rings.number_field [(-163, 1, -262537412640768000), (-67, 1, -147197952000), (-43, 1, -884736000), (-19, 1, -884736), (-11, 1, -32768), (-8, 1, 8000), (-7, 1, -3375), (-7, 2, 16581375), (-4, 1, 1728), @@ -479,6 +487,7 @@ def cm_orders(h, proof=None): (-11, 1), (-19, 1), (-43, 1), (-67, 1), (-163, 1)] sage: type(v[0][0]), type(v[0][1]) (<... 'sage.rings.integer.Integer'>, <... 'sage.rings.integer.Integer'>) + sage: # needs sage.libs.pari sage: v = cm_orders(2); v [(-3, 4), (-3, 5), (-3, 7), (-4, 3), (-4, 4), (-4, 5), (-7, 4), (-8, 2), (-8, 3), (-11, 3), (-15, 1), (-15, 2), (-20, 1), (-24, 1), (-35, 1), @@ -491,6 +500,7 @@ def cm_orders(h, proof=None): Any degree up to 100 is implemented, but may be slow:: + sage: # needs sage.libs.pari sage: cm_orders(3) [(-3, 6), (-3, 9), (-11, 2), (-19, 2), (-23, 1), (-23, 2), (-31, 1), (-31, 2), (-43, 2), (-59, 1), (-67, 2), (-83, 1), (-107, 1), (-139, 1), (-163, 2), @@ -738,6 +748,7 @@ def discriminants_with_bounded_class_number(hmax, B=None, proof=None): EXAMPLES:: + sage: # needs sage.libs.pari sage: from sage.schemes.elliptic_curves.cm import discriminants_with_bounded_class_number sage: v = discriminants_with_bounded_class_number(3) sage: sorted(v) @@ -920,23 +931,24 @@ def is_cm_j_invariant(j, algorithm='CremonaSutherland', method=None): sage: is_cm_j_invariant(8000) (True, (-8, 1)) - sage: K. = QuadraticField(5) # optional - sage.rings.number_field - sage: is_cm_j_invariant(282880*a + 632000) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(5) + sage: is_cm_j_invariant(282880*a + 632000) (True, (-20, 1)) sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: is_cm_j_invariant(31710790944000*a^2 + 39953093016000*a + 50337742902000) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: is_cm_j_invariant(31710790944000*a^2 + 39953093016000*a + 50337742902000) (True, (-3, 6)) An example of large degree. This is only possible using the default algorithm:: sage: from sage.schemes.elliptic_curves.cm import is_cm_j_invariant sage: D = -1856563 - sage: H = hilbert_class_polynomial(D) - sage: H.degree() + sage: H = hilbert_class_polynomial(D) # needs sage.libs.flint + sage: H.degree() # needs sage.libs.flint 100 - sage: K. = NumberField(H) - sage: is_cm_j_invariant(j) + sage: K. = NumberField(H) # needs sage.libs.flint sage.rings.number_field + sage: is_cm_j_invariant(j) # needs sage.libs.flint sage.rings.number_field (True, (-1856563, 1)) TESTS:: diff --git a/src/sage/schemes/elliptic_curves/constructor.py b/src/sage/schemes/elliptic_curves/constructor.py index ca210ca6e2b..e7a1767cecb 100644 --- a/src/sage/schemes/elliptic_curves/constructor.py +++ b/src/sage/schemes/elliptic_curves/constructor.py @@ -115,9 +115,9 @@ class EllipticCurveFactory(UniqueFactory): We create curves over a finite field as follows:: - sage: EllipticCurve([GF(5)(0),0,1,-1,0]) # optional - sage.rings.finite_rings + sage: EllipticCurve([GF(5)(0),0,1,-1,0]) Elliptic Curve defined by y^2 + y = x^3 + 4*x over Finite Field of size 5 - sage: EllipticCurve(GF(5), [0, 0,1,-1,0]) # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(5), [0, 0,1,-1,0]) Elliptic Curve defined by y^2 + y = x^3 + 4*x over Finite Field of size 5 Elliptic curves over `\ZZ/N\ZZ` with `N` prime are of type @@ -159,8 +159,8 @@ class EllipticCurveFactory(UniqueFactory): sage: EllipticCurve(y^2 + y - ( x^3 + x - 9 )) Elliptic Curve defined by y^2 + y = x^3 + x - 9 over Rational Field - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: EllipticCurve(x^3 + x^2 + 2 - y^2 - y*x) # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: EllipticCurve(x^3 + x^2 + 2 - y^2 - y*x) Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + 2 over Finite Field of size 5 We can also create elliptic curves by giving a smooth plane cubic with a rational point:: @@ -178,13 +178,13 @@ class EllipticCurveFactory(UniqueFactory): 1728 '32a2' - sage: E = EllipticCurve(j=GF(5)(2)); E; E.j_invariant() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(5)(2)); E; E.j_invariant() Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 5 2 See :trac:`6657` :: - sage: EllipticCurve(GF(144169), j=1728) # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(144169), j=1728) # needs sage.rings.finite_rings Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 144169 Elliptic curves over the same ring with the same Weierstrass @@ -231,10 +231,10 @@ class EllipticCurveFactory(UniqueFactory): We create a curve and a point over ``QQbar`` (see :trac:`6879`):: - sage: E = EllipticCurve(QQbar, [0,1]) # optional - sage.rings.number_field - sage: E(0) # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [0,1]) # needs sage.rings.number_field + sage: E(0) # needs sage.rings.number_field (0 : 1 : 0) - sage: E.base_field() # optional - sage.rings.number_field + sage: E.base_field() # needs sage.rings.number_field Algebraic Field sage: E = EllipticCurve(RR, [1,2]); E; E.base_field() @@ -245,7 +245,7 @@ class EllipticCurveFactory(UniqueFactory): Elliptic Curve defined by y^2 = x^3 + 3.00000000000000*x + 4.00000000000000 over Complex Field with 53 bits of precision Complex Field with 53 bits of precision - sage: E = EllipticCurve(QQbar, [5,6]); E; E.base_field() # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [5,6]); E; E.base_field() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + 5*x + 6 over Algebraic Field Algebraic Field @@ -256,7 +256,7 @@ class EllipticCurveFactory(UniqueFactory): ... ValueError: First parameter (if present) must be a ring when j is specified - sage: EllipticCurve(GF(5), j=3/5) # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(5), j=3/5) Traceback (most recent call last): ... ValueError: First parameter must be a ring containing 3/5 @@ -265,9 +265,9 @@ class EllipticCurveFactory(UniqueFactory): constructed has type :class:`EllipticCurve_field`. Otherwise it is :class:`EllipticCurve_generic`. See :trac:`9816` :: - sage: E = EllipticCurve([QQbar(1), 3]); E # optional - sage.rings.number_field + sage: E = EllipticCurve([QQbar(1), 3]); E # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + x + 3 over Algebraic Field - sage: type(E) # optional - sage.rings.number_field + sage: type(E) # needs sage.rings.number_field sage: E = EllipticCurve([RR(1), 3]); E @@ -276,13 +276,14 @@ class EllipticCurveFactory(UniqueFactory): sage: type(E) - sage: E = EllipticCurve([SR(i),i]); E # optional - sage.symbolic + sage: # needs sage.symbolic + sage: E = EllipticCurve([SR(i),i]); E Elliptic Curve defined by y^2 = x^3 + I*x + I over Symbolic Ring - sage: type(E) # optional - sage.symbolic + sage: type(E) - sage: E.category() # optional - sage.symbolic + sage: E.category() Category of schemes over Symbolic Ring - sage: SR in Fields() # optional - sage.symbolic + sage: SR in Fields() True sage: F = FractionField(PolynomialRing(QQ,'t')) @@ -389,6 +390,7 @@ def create_key_and_extra_args(self, x=None, y=None, j=None, minimal_twist=True, TESTS:: + sage: # needs sage.symbolic sage: var('x', 'y', 'v', 'w') (x, y, v, w) sage: EllipticCurve(y^2 + y > x^3 + x - 9) @@ -461,8 +463,8 @@ def create_object(self, version, key, **kwds): EXAMPLES:: - sage: E = EllipticCurve.create_object(0, (GF(3), (1, 2, 0, 1, 2))) # optional - sage.rings.finite_rings - sage: type(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve.create_object(0, (GF(3), (1, 2, 0, 1, 2))) + sage: type(E) .. NOTE:: @@ -1019,10 +1021,10 @@ def EllipticCurve_from_cubic(F, P=None, morphism=True): An example over a finite field, using a flex:: - sage: K = GF(17) # optional - sage.rings.finite_rings - sage: R. = K[] # optional - sage.rings.finite_rings - sage: cubic = 2*x^3 + 3*y^3 + 4*z^3 # optional - sage.rings.finite_rings - sage: EllipticCurve_from_cubic(cubic, [0,3,1]) # optional - sage.rings.finite_rings + sage: K = GF(17) + sage: R. = K[] + sage: cubic = 2*x^3 + 3*y^3 + 4*z^3 + sage: EllipticCurve_from_cubic(cubic, [0,3,1]) Scheme morphism: From: Projective Plane Curve over Finite Field of size 17 defined by 2*x^3 + 3*y^3 + 4*z^3 @@ -1032,10 +1034,10 @@ def EllipticCurve_from_cubic(F, P=None, morphism=True): An example in characteristic 3:: - sage: K = GF(3) # optional - sage.rings.finite_rings - sage: R. = K[] # optional - sage.rings.finite_rings - sage: cubic = x^3 + y^3 + z^3 + x*y*z # optional - sage.rings.finite_rings - sage: EllipticCurve_from_cubic(cubic, [0,1,-1]) # optional - sage.rings.finite_rings + sage: K = GF(3) + sage: R. = K[] + sage: cubic = x^3 + y^3 + z^3 + x*y*z + sage: EllipticCurve_from_cubic(cubic, [0,1,-1]) Scheme morphism: From: Projective Plane Curve over Finite Field of size 3 defined by x^3 + y^3 + x*y*z + z^3 @@ -1045,10 +1047,11 @@ def EllipticCurve_from_cubic(F, P=None, morphism=True): An example over a number field, using a non-flex and where there are no rational flexes:: - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: cubic = 2*x^3 + 3*y^3 + 5*z^3 # optional - sage.rings.number_field - sage: EllipticCurve_from_cubic(cubic, [1,1,-1]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-3) + sage: R. = K[] + sage: cubic = 2*x^3 + 3*y^3 + 5*z^3 + sage: EllipticCurve_from_cubic(cubic, [1,1,-1]) Scheme morphism: From: Projective Plane Curve over Number Field in a with defining polynomial x^2 + 3 with a = 1.732050807568878?*I @@ -1068,7 +1071,7 @@ def EllipticCurve_from_cubic(F, P=None, morphism=True): sage: K. = FunctionField(QQ) sage: R. = K[] sage: cubic = x^3 + t*y^3 + (1+t)*z^3 - sage: EllipticCurve_from_cubic(cubic, [1,1,-1], morphism=False) + sage: EllipticCurve_from_cubic(cubic, [1,1,-1], morphism=False) # needs sage.libs.singular Elliptic Curve defined by y^2 + ((162*t^6+486*t^5+810*t^4+810*t^3+486*t^2+162*t)/(t^6+12*t^5-3*t^4-20*t^3-3*t^2+12*t+1))*x*y + ((314928*t^14+4094064*t^13+23462136*t^12+78102144*t^11+167561379*t^10+243026001*t^9+243026001*t^8+167561379*t^7+78102144*t^6+23462136*t^5+4094064*t^4+314928*t^3)/(t^14+40*t^13+577*t^12+3524*t^11+8075*t^10+5288*t^9-8661*t^8-17688*t^7-8661*t^6+5288*t^5+8075*t^4+3524*t^3+577*t^2+40*t+1))*y = x^3 + ((2187*t^12+13122*t^11-17496*t^10-207765*t^9-516132*t^8-673596*t^7-516132*t^6-207765*t^5-17496*t^4+13122*t^3+2187*t^2)/(t^12+24*t^11+138*t^10-112*t^9-477*t^8+72*t^7+708*t^6+72*t^5-477*t^4-112*t^3+138*t^2+24*t+1))*x^2 over Rational function field in t over Rational Field @@ -1370,8 +1373,8 @@ def projective_point(p): sage: from sage.schemes.elliptic_curves.constructor import projective_point sage: projective_point([4/5, 6/5, 8/5]) [2, 3, 4] - sage: F = GF(11) # optional - sage.rings.finite_rings - sage: projective_point([F(4), F(8), F(2)]) # optional - sage.rings.finite_rings + sage: F = GF(11) + sage: projective_point([F(4), F(8), F(2)]) [4, 8, 2] """ from sage.rings.integer import GCD_list @@ -1461,13 +1464,14 @@ def EllipticCurves_with_good_reduction_outside_S(S=[], proof=None, verbose=False sage: ', '.join(e.label() for e in elist) # long time '11a1, 11a2, 11a3, 121a1, 121a2, 121b1, 121b2, 121c1, 121c2, 121d1, 121d2, 121d3' + sage: # long time sage: elist = EllipticCurves_with_good_reduction_outside_S([2,3]) # long time (26s on sage.math, 2011) - sage: len(elist) # long time + sage: len(elist) 752 - sage: conds = sorted(set([e.conductor() for e in elist])) # long time - sage: max(conds) # long time + sage: conds = sorted(set([e.conductor() for e in elist])) + sage: max(conds) 62208 - sage: [N.factor() for N in conds] # long time + sage: [N.factor() for N in conds] [2^3 * 3, 3^3, 2^5, diff --git a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx index 5fc182c8954..458ce65a61d 100644 --- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx +++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx @@ -1151,14 +1151,16 @@ def two_descent_by_two_isogeny(E, sage: n1, n2, n1_prime, n2_prime = two_descent_by_two_isogeny(E) sage: log(n1,2) + log(n1_prime,2) - 2 # the rank 1 + + sage: # needs sage.symbolic sage: x,y = var('x,y') sage: E = EllipticCurve(y^2 == x^3 + x^2 - 25*x + 39) sage: n1, n2, n1_prime, n2_prime = two_descent_by_two_isogeny(E) - sage: log(n1,2) + log(n1_prime,2) - 2 # the rank + sage: log(n1,2) + log(n1_prime,2) - 2 # the rank 2 sage: E = EllipticCurve(y^2 + x*y + y == x^3 - 131*x + 558) sage: n1, n2, n1_prime, n2_prime = two_descent_by_two_isogeny(E) - sage: log(n1,2) + log(n1_prime,2) - 2 # the rank + sage: log(n1,2) + log(n1_prime,2) - 2 # the rank 3 Using the verbosity option:: diff --git a/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py b/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py index e5e35f2a139..5c3f4c58d14 100644 --- a/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py +++ b/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py @@ -13,21 +13,21 @@ The usual way to create and work with isogenies is illustrated with the following example:: - sage: k = GF(11) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,1]) # optional - sage.rings.finite_rings - sage: Q = E(6,5) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(Q) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: k = GF(11) + sage: E = EllipticCurve(k, [1,1]) + sage: Q = E(6,5) + sage: phi = E.isogeny(Q) + sage: phi Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 11 to Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 11 - sage: P = E(4,5) # optional - sage.rings.finite_rings - sage: phi(P) # optional - sage.rings.finite_rings + sage: P = E(4,5) + sage: phi(P) (10 : 0 : 1) - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 11 - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^7 + 4*x^6 - 3*x^5 - 2*x^4 - 3*x^3 + 3*x^2 + x - 2)/(x^6 + 4*x^5 - 4*x^4 - 5*x^3 + 5*x^2), (x^9*y - 5*x^8*y - x^7*y + x^5*y - x^4*y @@ -127,32 +127,32 @@ def _isogeny_determine_algorithm(E, kernel): This helper function will be implicitly called by the following examples:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(5), [0,0,0,1,0]) # indirect doctest # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: E = EllipticCurve(GF(5), [0,0,0,1,0]) # indirect doctest We can construct the same isogeny from a kernel polynomial:: - sage: phi = EllipticCurveIsogeny(E, x + 3) # indirect doctest # optional - sage.rings.finite_rings + sage: phi = EllipticCurveIsogeny(E, x + 3) # indirect doctest or from a list of coefficients of a kernel polynomial:: - sage: phi == EllipticCurveIsogeny(E, [3,1]) # indirect doctest # optional - sage.rings.finite_rings + sage: phi == EllipticCurveIsogeny(E, [3,1]) # indirect doctest True or from a rational point which generates the kernel:: - sage: phi == EllipticCurveIsogeny(E, E((2,0))) # indirect doctest # optional - sage.rings.finite_rings + sage: phi == EllipticCurveIsogeny(E, E((2,0))) # indirect doctest True In the first two cases, Kohel's algorithm will be used, while in the third case it is Vélu:: sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import _isogeny_determine_algorithm - sage: _isogeny_determine_algorithm(E, x + 3) # optional - sage.rings.finite_rings + sage: _isogeny_determine_algorithm(E, x + 3) 'kohel' - sage: _isogeny_determine_algorithm(E, [3, 1]) # optional - sage.rings.finite_rings + sage: _isogeny_determine_algorithm(E, [3, 1]) 'kohel' - sage: _isogeny_determine_algorithm(E, E((2,0))) # optional - sage.rings.finite_rings + sage: _isogeny_determine_algorithm(E, E((2,0))) 'velu' """ kernel_is_list = isinstance(kernel, list) @@ -194,24 +194,24 @@ def isogeny_codomain_from_kernel(E, kernel, degree=None): EXAMPLES:: sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogeny_codomain_from_kernel - sage: E = EllipticCurve(GF(7), [1,0,1,0,1]) # optional - sage.rings.finite_rings - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: isogeny_codomain_from_kernel(E, [4,1]) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [1,0,1,0,1]) + sage: R. = GF(7)[] + sage: isogeny_codomain_from_kernel(E, [4,1]) Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + 6 over Finite Field of size 7 - sage: (EllipticCurveIsogeny(E, [4,1]).codomain() # optional - sage.rings.finite_rings + sage: (EllipticCurveIsogeny(E, [4,1]).codomain() ....: == isogeny_codomain_from_kernel(E, [4,1])) True - sage: isogeny_codomain_from_kernel(E, x^3 + x^2 + 4*x + 3) # optional - sage.rings.finite_rings + sage: isogeny_codomain_from_kernel(E, x^3 + x^2 + 4*x + 3) Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + 6 over Finite Field of size 7 - sage: isogeny_codomain_from_kernel(E, x^3 + 2*x^2 + 4*x + 3) # optional - sage.rings.finite_rings + sage: isogeny_codomain_from_kernel(E, x^3 + 2*x^2 + 4*x + 3) Elliptic Curve defined by y^2 + x*y + y = x^3 + 5*x + 2 over Finite Field of size 7 - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: kernel_list = [E((15,10)), E((10,3)), E((6,5))] # optional - sage.rings.finite_rings - sage: isogeny_codomain_from_kernel(E, kernel_list) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: kernel_list = [E((15,10)), E((10,3)), E((6,5))] + sage: isogeny_codomain_from_kernel(E, kernel_list) Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 3*x + 15 over Finite Field of size 19 @@ -219,7 +219,7 @@ def isogeny_codomain_from_kernel(E, kernel, degree=None): Test deprecation warning for obsolete argument:: - sage: isogeny_codomain_from_kernel(E, kernel_list, degree=4) # optional - sage.rings.finite_rings + sage: isogeny_codomain_from_kernel(E, kernel_list, degree=4) doctest:warning ... DeprecationWarning: The "degree" argument to isogeny_codomain_from_kernel() does nothing and will be removed. @@ -265,15 +265,15 @@ def compute_codomain_formula(E, v, w): This formula is used by every invocation of the :class:`EllipticCurveIsogeny` constructor:: - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((1,2)) ) # optional - sage.rings.finite_rings - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: phi = EllipticCurveIsogeny(E, E((1,2)) ) + sage: phi.codomain() Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 9*x + 13 over Finite Field of size 19 sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_codomain_formula - sage: v = phi._EllipticCurveIsogeny__v # optional - sage.rings.finite_rings - sage: w = phi._EllipticCurveIsogeny__w # optional - sage.rings.finite_rings - sage: compute_codomain_formula(E, v, w) == phi.codomain() # optional - sage.rings.finite_rings + sage: v = phi._EllipticCurveIsogeny__v + sage: w = phi._EllipticCurveIsogeny__w + sage: compute_codomain_formula(E, v, w) == phi.codomain() True """ a1, a2, a3, a4, a6 = E.a_invariants() @@ -302,18 +302,18 @@ def compute_vw_kohel_even_deg1(x0, y0, a1, a2, a4): This function will be implicitly called by the following example:: - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [9,1]); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: phi = EllipticCurveIsogeny(E, [9,1]); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 19 to Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 9*x + 8 over Finite Field of size 19 sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_vw_kohel_even_deg1 - sage: a1,a2,a3,a4,a6 = E.a_invariants() # optional - sage.rings.finite_rings - sage: x0 = -9 # optional - sage.rings.finite_rings - sage: y0 = -(a1*x0 + a3)/2 # optional - sage.rings.finite_rings - sage: compute_vw_kohel_even_deg1(x0, y0, a1, a2, a4) # optional - sage.rings.finite_rings + sage: a1,a2,a3,a4,a6 = E.a_invariants() + sage: x0 = -9 + sage: y0 = -(a1*x0 + a3)/2 + sage: compute_vw_kohel_even_deg1(x0, y0, a1, a2, a4) (18, 9) """ v = 3*x0**2 + 2*a2*x0 + a4 - a1*y0 @@ -340,18 +340,18 @@ def compute_vw_kohel_even_deg3(b2, b4, s1, s2, s3): This function will be implicitly called by the following example:: - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: R. = GF(19)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x^3 + 7*x^2 + 15*x + 12); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: R. = GF(19)[] + sage: phi = EllipticCurveIsogeny(E, x^3 + 7*x^2 + 15*x + 12); phi Isogeny of degree 4 from Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 19 to Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 3*x + 15 over Finite Field of size 19 sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_vw_kohel_even_deg3 - sage: b2,b4 = E.b2(), E.b4() # optional - sage.rings.finite_rings - sage: s1, s2, s3 = -7, 15, -12 # optional - sage.rings.finite_rings - sage: compute_vw_kohel_even_deg3(b2, b4, s1, s2, s3) # optional - sage.rings.finite_rings + sage: b2,b4 = E.b2(), E.b4() + sage: s1, s2, s3 = -7, 15, -12 + sage: compute_vw_kohel_even_deg3(b2, b4, s1, s2, s3) (4, 7) """ temp1 = s1**2 - 2*s2 @@ -381,18 +381,18 @@ def compute_vw_kohel_odd(b2, b4, b6, s1, s2, s3, n): This function will be implicitly called by the following example:: - sage: E = EllipticCurve(GF(19), [18,17,16,15,14]) # optional - sage.rings.finite_rings - sage: R. = GF(19)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x^3 + 14*x^2 + 3*x + 11); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [18,17,16,15,14]) + sage: R. = GF(19)[] + sage: phi = EllipticCurveIsogeny(E, x^3 + 14*x^2 + 3*x + 11); phi Isogeny of degree 7 from Elliptic Curve defined by y^2 + 18*x*y + 16*y = x^3 + 17*x^2 + 15*x + 14 over Finite Field of size 19 to Elliptic Curve defined by y^2 + 18*x*y + 16*y = x^3 + 17*x^2 + 18*x + 18 over Finite Field of size 19 sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_vw_kohel_odd - sage: b2,b4,b6 = E.b2(), E.b4(), E.b6() # optional - sage.rings.finite_rings - sage: s1,s2,s3 = -14,3,-11 # optional - sage.rings.finite_rings - sage: compute_vw_kohel_odd(b2,b4,b6,s1,s2,s3,3) # optional - sage.rings.finite_rings + sage: b2,b4,b6 = E.b2(), E.b4(), E.b6() + sage: s1,s2,s3 = -14,3,-11 + sage: compute_vw_kohel_odd(b2,b4,b6,s1,s2,s3,3) (7, 1) """ v = 6*(s1**2 - 2*s2) + b2*s1 + n*b4 @@ -419,26 +419,26 @@ def compute_codomain_kohel(E, kernel): EXAMPLES:: sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_codomain_kohel - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [9,1]) # optional - sage.rings.finite_rings - sage: phi.codomain() == isogeny_codomain_from_kernel(E, [9,1]) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: phi = EllipticCurveIsogeny(E, [9,1]) + sage: phi.codomain() == isogeny_codomain_from_kernel(E, [9,1]) True - sage: compute_codomain_kohel(E, [9,1]) # optional - sage.rings.finite_rings + sage: compute_codomain_kohel(E, [9,1]) Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 9*x + 8 over Finite Field of size 19 - sage: R. = GF(19)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(19), [18,17,16,15,14]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x^3 + 14*x^2 + 3*x + 11) # optional - sage.rings.finite_rings - sage: phi.codomain() == isogeny_codomain_from_kernel(E, x^3 + 14*x^2 + 3*x + 11) # optional - sage.rings.finite_rings + sage: R. = GF(19)[] + sage: E = EllipticCurve(GF(19), [18,17,16,15,14]) + sage: phi = EllipticCurveIsogeny(E, x^3 + 14*x^2 + 3*x + 11) + sage: phi.codomain() == isogeny_codomain_from_kernel(E, x^3 + 14*x^2 + 3*x + 11) True - sage: compute_codomain_kohel(E, x^3 + 14*x^2 + 3*x + 11) # optional - sage.rings.finite_rings + sage: compute_codomain_kohel(E, x^3 + 14*x^2 + 3*x + 11) Elliptic Curve defined by y^2 + 18*x*y + 16*y = x^3 + 17*x^2 + 18*x + 18 over Finite Field of size 19 - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x^3 + 7*x^2 + 15*x + 12) # optional - sage.rings.finite_rings - sage: isogeny_codomain_from_kernel(E, x^3 + 7*x^2 + 15*x + 12) == phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: phi = EllipticCurveIsogeny(E, x^3 + 7*x^2 + 15*x + 12) + sage: isogeny_codomain_from_kernel(E, x^3 + 7*x^2 + 15*x + 12) == phi.codomain() True - sage: compute_codomain_kohel(E, x^3 + 7*x^2 + 15*x + 12) # optional - sage.rings.finite_rings + sage: compute_codomain_kohel(E, x^3 + 7*x^2 + 15*x + 12) Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 3*x + 15 over Finite Field of size 19 @@ -529,13 +529,13 @@ def two_torsion_part(E, psi): Every function that computes the kernel polynomial via Kohel's formulas will call this function:: - sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: R. = GF(19)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x + 13) # optional - sage.rings.finite_rings - sage: isogeny_codomain_from_kernel(E, x + 13) == phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) + sage: R. = GF(19)[] + sage: phi = EllipticCurveIsogeny(E, x + 13) + sage: isogeny_codomain_from_kernel(E, x + 13) == phi.codomain() True sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import two_torsion_part - sage: two_torsion_part(E, x + 13) # optional - sage.rings.finite_rings + sage: two_torsion_part(E, x + 13) x + 13 """ x = psi.parent().gen() # NB psi is univariate but could be constant @@ -612,105 +612,107 @@ class EllipticCurveIsogeny(EllipticCurveHom): A simple example of creating an isogeny of a field of small characteristic:: - sage: E = EllipticCurve(GF(7), [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0)) ); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,1,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0)) ); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 7 - sage: phi.degree() == 2 # optional - sage.rings.finite_rings + sage: phi.degree() == 2 True - sage: phi.kernel_polynomial() # optional - sage.rings.finite_rings + sage: phi.kernel_polynomial() x - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^2 + 1)/x, (x^2*y - y)/x^2) - sage: phi == loads(dumps(phi)) # known bug # optional - sage.rings.finite_rings + sage: phi == loads(dumps(phi)) # known bug True A more complicated example of a characteristic-2 field:: - sage: E = EllipticCurve(GF(2^4,'alpha'), [0,0,1,0,1]) # optional - sage.rings.finite_rings - sage: P = E((1,1)) # optional - sage.rings.finite_rings - sage: phi_v = EllipticCurveIsogeny(E, P); phi_v # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(2^4,'alpha'), [0,0,1,0,1]) + sage: P = E((1,1)) + sage: phi_v = EllipticCurveIsogeny(E, P); phi_v Isogeny of degree 3 from Elliptic Curve defined by y^2 + y = x^3 + 1 over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + y = x^3 over Finite Field in alpha of size 2^4 - sage: phi_ker_poly = phi_v.kernel_polynomial() # optional - sage.rings.finite_rings - sage: phi_ker_poly # optional - sage.rings.finite_rings + sage: phi_ker_poly = phi_v.kernel_polynomial() + sage: phi_ker_poly x + 1 - sage: phi_k = EllipticCurveIsogeny(E, phi_ker_poly) # optional - sage.rings.finite_rings - sage: phi_k == phi_v # optional - sage.rings.finite_rings + sage: phi_k = EllipticCurveIsogeny(E, phi_ker_poly) + sage: phi_k == phi_v True - sage: phi_k.rational_maps() # optional - sage.rings.finite_rings + sage: phi_k.rational_maps() ((x^3 + x + 1)/(x^2 + 1), (x^3*y + x^2*y + x*y + x + y)/(x^3 + x^2 + x + 1)) - sage: phi_v.rational_maps() # optional - sage.rings.finite_rings + sage: phi_v.rational_maps() ((x^3 + x + 1)/(x^2 + 1), (x^3*y + x^2*y + x*y + x + y)/(x^3 + x^2 + x + 1)) - sage: phi_k.degree() == phi_v.degree() == 3 # optional - sage.rings.finite_rings + sage: phi_k.degree() == phi_v.degree() == 3 True - sage: phi_k.is_separable() # optional - sage.rings.finite_rings + sage: phi_k.is_separable() True - sage: phi_v(E(0)) # optional - sage.rings.finite_rings + sage: phi_v(E(0)) (0 : 1 : 0) - sage: alpha = E.base_field().gen() # optional - sage.rings.finite_rings - sage: Q = E((0, alpha*(alpha + 1))) # optional - sage.rings.finite_rings - sage: phi_v(Q) # optional - sage.rings.finite_rings + sage: alpha = E.base_field().gen() + sage: Q = E((0, alpha*(alpha + 1))) + sage: phi_v(Q) (1 : alpha^2 + alpha : 1) - sage: phi_v(P) == phi_k(P) # optional - sage.rings.finite_rings + sage: phi_v(P) == phi_k(P) True - sage: phi_k(P) == phi_v.codomain()(0) # optional - sage.rings.finite_rings + sage: phi_k(P) == phi_v.codomain()(0) True We can create an isogeny whose kernel equals the full 2-torsion:: - sage: E = EllipticCurve(GF((3,2)), [0,0,0,1,1]) # optional - sage.rings.finite_rings - sage: ker_poly = E.division_polynomial(2) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, ker_poly); phi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF((3,2)), [0,0,0,1,1]) + sage: ker_poly = E.division_polynomial(2) + sage: phi = EllipticCurveIsogeny(E, ker_poly); phi Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field in z2 of size 3^2 to Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field in z2 of size 3^2 - sage: P1,P2,P3 = filter(bool, E(0).division_points(2)) # optional - sage.rings.finite_rings - sage: phi(P1) # optional - sage.rings.finite_rings + sage: P1,P2,P3 = filter(bool, E(0).division_points(2)) + sage: phi(P1) (0 : 1 : 0) - sage: phi(P2) # optional - sage.rings.finite_rings + sage: phi(P2) (0 : 1 : 0) - sage: phi(P3) # optional - sage.rings.finite_rings + sage: phi(P3) (0 : 1 : 0) - sage: phi.degree() # optional - sage.rings.finite_rings + sage: phi.degree() 4 We can also create trivial isogenies with the trivial kernel:: - sage: E = EllipticCurve(GF(17), [11, 11, 4, 12, 10]) # optional - sage.rings.finite_rings - sage: phi_v = EllipticCurveIsogeny(E, E(0)) # optional - sage.rings.finite_rings - sage: phi_v.degree() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [11, 11, 4, 12, 10]) + sage: phi_v = EllipticCurveIsogeny(E, E(0)) + sage: phi_v.degree() 1 - sage: phi_v.rational_maps() # optional - sage.rings.finite_rings + sage: phi_v.rational_maps() (x, y) - sage: E == phi_v.codomain() # optional - sage.rings.finite_rings + sage: E == phi_v.codomain() True - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: phi_v(P) == P # optional - sage.rings.finite_rings + sage: P = E.random_point() + sage: phi_v(P) == P True - sage: E = EllipticCurve(GF(31), [23, 1, 22, 7, 18]) # optional - sage.rings.finite_rings - sage: phi_k = EllipticCurveIsogeny(E, [1]); phi_k # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [23, 1, 22, 7, 18]) + sage: phi_k = EllipticCurveIsogeny(E, [1]); phi_k Isogeny of degree 1 from Elliptic Curve defined by y^2 + 23*x*y + 22*y = x^3 + x^2 + 7*x + 18 over Finite Field of size 31 to Elliptic Curve defined by y^2 + 23*x*y + 22*y = x^3 + x^2 + 7*x + 18 over Finite Field of size 31 - sage: phi_k.degree() # optional - sage.rings.finite_rings + sage: phi_k.degree() 1 - sage: phi_k.rational_maps() # optional - sage.rings.finite_rings + sage: phi_k.rational_maps() (x, y) - sage: phi_k.codomain() == E # optional - sage.rings.finite_rings + sage: phi_k.codomain() == E True - sage: phi_k.kernel_polynomial() # optional - sage.rings.finite_rings + sage: phi_k.kernel_polynomial() 1 - sage: P = E.random_point(); P == phi_k(P) # optional - sage.rings.finite_rings + sage: P = E.random_point(); P == phi_k(P) True Vélu and Kohel also work in characteristic `0`:: @@ -767,39 +769,40 @@ class EllipticCurveIsogeny(EllipticCurveHom): We can also do this same example over the number field defined by the irreducible two-torsion polynomial of `E`:: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('11a1') sage: P_list = E.torsion_points() sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2* x^2 - 40*x - 158) # optional - sage.rings.number_field - sage: EK = E.change_ring(K) # optional - sage.rings.number_field - sage: P_list = [EK(P) for P in P_list] # optional - sage.rings.number_field - sage: phi_v = EllipticCurveIsogeny(EK, P_list); phi_v # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2* x^2 - 40*x - 158) + sage: EK = E.change_ring(K) + sage: P_list = [EK(P) for P in P_list] + sage: phi_v = EllipticCurveIsogeny(EK, P_list); phi_v Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 to Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-7820)*x + (-263580) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 - sage: P = EK((alpha/2,-1/2)) # optional - sage.rings.number_field - sage: phi_v(P) # optional - sage.rings.number_field + sage: P = EK((alpha/2,-1/2)) + sage: phi_v(P) (122/121*alpha^2 + 1633/242*alpha - 3920/121 : -1/2 : 1) - sage: ker_poly = phi_v.kernel_polynomial() # optional - sage.rings.number_field - sage: ker_poly # optional - sage.rings.number_field + sage: ker_poly = phi_v.kernel_polynomial() + sage: ker_poly x^2 - 21*x + 80 - sage: phi_k = EllipticCurveIsogeny(EK, ker_poly); phi_k # optional - sage.rings.number_field + sage: phi_k = EllipticCurveIsogeny(EK, ker_poly); phi_k Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 to Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-7820)*x + (-263580) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 - sage: phi_v == phi_k # optional - sage.rings.number_field + sage: phi_v == phi_k True - sage: phi_k(P) == phi_v(P) # optional - sage.rings.number_field + sage: phi_k(P) == phi_v(P) True - sage: phi_k == phi_v # optional - sage.rings.number_field + sage: phi_k == phi_v True - sage: phi_k.degree() # optional - sage.rings.number_field + sage: phi_k.degree() 5 - sage: phi_v.is_separable() # optional - sage.rings.number_field + sage: phi_v.is_separable() True The following example shows how to specify an isogeny from domain @@ -844,16 +847,17 @@ class EllipticCurveIsogeny(EllipticCurveHom): Here an example of a construction of a endomorphisms with cyclic kernel on a CM-curve:: - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [1,0]) # optional - sage.rings.number_field - sage: RK. = K[] # optional - sage.rings.number_field - sage: f = X^2 - 2/5*i + 1/5 # optional - sage.rings.number_field - sage: phi= E.isogeny(f) # optional - sage.rings.number_field - sage: isom = phi.codomain().isomorphism_to(E) # optional - sage.rings.number_field - sage: phi = isom * phi # optional - sage.rings.number_field - sage: phi.codomain() == phi.domain() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [1,0]) + sage: RK. = K[] + sage: f = X^2 - 2/5*i + 1/5 + sage: phi= E.isogeny(f) + sage: isom = phi.codomain().isomorphism_to(E) + sage: phi = isom * phi + sage: phi.codomain() == phi.domain() True - sage: phi.rational_maps() # optional - sage.rings.number_field + sage: phi.rational_maps() (((4/25*i + 3/25)*x^5 + (4/5*i - 2/5)*x^3 - x)/(x^4 + (-4/5*i + 2/5)*x^2 + (-4/25*i - 3/25)), ((11/125*i + 2/125)*x^6*y + (-23/125*i + 64/125)*x^4*y + (141/125*i + 162/125)*x^2*y + (3/25*i - 4/25)*y)/(x^6 + (-6/5*i + 3/5)*x^4 + (-12/25*i - 9/25)*x^2 + (2/125*i - 11/125))) @@ -868,38 +872,39 @@ class EllipticCurveIsogeny(EllipticCurveHom): sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 - 4*x over Rational Field - sage: E = EllipticCurve(GF(31), [1,0,0,1,2]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [17, 1]) # optional - sage.rings.finite_rings - sage: phi.domain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [1,0,0,1,2]) + sage: phi = EllipticCurveIsogeny(E, [17, 1]) + sage: phi.domain() Elliptic Curve defined by y^2 + x*y = x^3 + x + 2 over Finite Field of size 31 - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: phi.codomain() Elliptic Curve defined by y^2 + x*y = x^3 + 24*x + 6 over Finite Field of size 31 Composition tests (see :trac:`16245`, cf. :trac:`34410`):: - sage: E = EllipticCurve(j=GF(7)(0)) # optional - sage.rings.finite_rings - sage: phi = E.isogeny([E(0), E((0,1)), E((0,-1))]); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(0)) + sage: phi = E.isogeny([E(0), E((0,1)), E((0,-1))]); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 - sage: phi2 = phi * phi; phi2 # optional - sage.rings.finite_rings + sage: phi2 = phi * phi; phi2 Composite morphism of degree 9 = 3^2: From: Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 To: Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 Examples over relative number fields used not to work (see :trac:`16779`):: + sage: # long time, needs sage.rings.number_field sage: pol26 = hilbert_class_polynomial(-4*26) - sage: F = NumberField(pol26,'a') # long time # optional - sage.rings.number_field - sage: pol = F.optimized_representation()[0].polynomial() # long time # optional - sage.rings.number_field - sage: K. = NumberField(pol) # long time # optional - sage.rings.number_field - sage: j = pol26.roots(K)[0][0] # long time # optional - sage.rings.number_field - sage: E = EllipticCurve(j=j) # long time # optional - sage.rings.number_field - sage: L. = K.extension(x^2 + 26) # long time # optional - sage.rings.number_field - sage: EL = E.change_ring(L) # long time # optional - sage.rings.number_field - sage: iso2 = EL.isogenies_prime_degree(2); len(iso2) # long time # optional - sage.rings.number_field + sage: F = NumberField(pol26,'a') + sage: pol = F.optimized_representation()[0].polynomial() + sage: K. = NumberField(pol) + sage: j = pol26.roots(K)[0][0] + sage: E = EllipticCurve(j=j) + sage: L. = K.extension(x^2 + 26) + sage: EL = E.change_ring(L) + sage: iso2 = EL.isogenies_prime_degree(2); len(iso2) 1 - sage: iso3 = EL.isogenies_prime_degree(3); len(iso3) # long time # optional - sage.rings.number_field + sage: iso3 = EL.isogenies_prime_degree(3); len(iso3) 2 Examples over function fields used not to work (see :trac:`11327`):: @@ -1015,15 +1020,15 @@ def __init__(self, E, kernel, codomain=None, degree=None, model=None, check=True EXAMPLES:: - sage: E = EllipticCurve(GF(2), [0,0,1,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [1,1]); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(2), [0,0,1,0,1]) + sage: phi = EllipticCurveIsogeny(E, [1,1]); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 + y = x^3 + 1 over Finite Field of size 2 to Elliptic Curve defined by y^2 + y = x^3 over Finite Field of size 2 - sage: E = EllipticCurve(GF(31), [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: P = E((2,17)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [0,0,0,1,0]) + sage: P = E((2,17)) + sage: phi = EllipticCurveIsogeny(E, P); phi Isogeny of degree 8 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 31 to Elliptic Curve defined by y^2 = x^3 + 10*x + 28 over Finite Field of size 31 @@ -1124,8 +1129,8 @@ def _eval(self, P): sage: E = EllipticCurve([1,0]); E Elliptic Curve defined by y^2 = x^3 + x over Rational Field sage: phi = E.isogeny(E(0,0)) - sage: P = E.change_ring(QQbar).lift_x(QQbar.random_element()) # optional - sage.rings.number_field - sage: phi._eval(P).curve() # optional - sage.rings.number_field + sage: P = E.change_ring(QQbar).lift_x(QQbar.random_element()) # needs sage.rings.number_field + sage: phi._eval(P).curve() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + (-4)*x over Algebraic Field :: @@ -1133,8 +1138,8 @@ def _eval(self, P): sage: E = EllipticCurve(j=Mod(0,419)) sage: K = next(filter(bool, E(0).division_points(5))) sage: psi = E.isogeny(K) - sage: Ps = E.change_ring(GF(419**2))(0).division_points(5) # optional - sage.rings.number_field - sage: {psi._eval(P).curve() for P in Ps} # optional - sage.rings.number_field + sage: Ps = E.change_ring(GF(419**2))(0).division_points(5) # needs sage.rings.number_field + sage: {psi._eval(P).curve() for P in Ps} # needs sage.rings.number_field {Elliptic Curve defined by y^2 = x^3 + 140*x + 214 over Finite Field in z2 of size 419^2} """ if self._domain.defining_polynomial()(*P): @@ -1174,67 +1179,69 @@ def _call_(self, P): EXAMPLES:: - sage: E = EllipticCurve(GF(17), [1, 9, 5, 4, 3]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [6,13,1]) # optional - sage.rings.finite_rings - sage: phi(E((1,0))) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [1, 9, 5, 4, 3]) + sage: phi = EllipticCurveIsogeny(E, [6,13,1]) + sage: phi(E((1,0))) (15 : 13 : 1) - sage: E = EllipticCurve(GF(23), [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi(E((1,5))) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(23), [0,0,0,1,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi(E((1,5))) (2 : 0 : 1) - sage: E = EllipticCurve(QQ, [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: P = E((1,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [0,1]) # optional - sage.rings.finite_rings - sage: phi(P) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(QQ, [0,0,0,3,0]) + sage: P = E((1,2)) + sage: phi = EllipticCurveIsogeny(E, [0,1]) + sage: phi(P) (4 : -4 : 1) - sage: phi(-P) # optional - sage.rings.finite_rings + sage: phi(-P) (4 : 4 : 1) - sage: E = EllipticCurve(GF(17), [0,-1,0,-3,-1]) # optional - sage.rings.finite_rings - sage: Q = E((16,0)) # optional - sage.rings.finite_rings - sage: tau = E.isogeny([Q], E) # optional - sage.rings.finite_rings - sage: tau(Q) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,-1,0,-3,-1]) + sage: Q = E((16,0)) + sage: tau = E.isogeny([Q], E) + sage: tau(Q) (0 : 1 : 0) TESTS: Tests for :trac:`10888`:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 3) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [7,0]) # optional - sage.rings.number_field - sage: phi = E.isogeny(E(0,0)) # optional - sage.rings.number_field - sage: P = E(-3,4*th) # optional - sage.rings.number_field - sage: phi(P) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 3) + sage: E = EllipticCurve(K, [7,0]) + sage: phi = E.isogeny(E(0,0)) + sage: P = E(-3,4*th) + sage: phi(P) (-16/3 : 8/9*th : 1) - sage: Q = phi(P) # optional - sage.rings.number_field - sage: phihat = phi.dual() # optional - sage.rings.number_field - sage: phihat(Q) # optional - sage.rings.number_field + sage: Q = phi(P) + sage: phihat = phi.dual() + sage: phihat(Q) (-1/48 : 127/576*th : 1) Call a composed isogeny (added for :trac:`16238`):: - sage: E = EllipticCurve(j=GF(7)(0)) # optional - sage.rings.finite_rings - sage: phi = E.isogeny([E(0), E((0,1)), E((0,-1))]) # optional - sage.rings.finite_rings - sage: phi(E.points()[0]) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(0)) + sage: phi = E.isogeny([E(0), E((0,1)), E((0,-1))]) + sage: phi(E.points()[0]) (0 : 1 : 0) - sage: phi2 = phi * phi # optional - sage.rings.finite_rings - sage: phi2(E.points()[0]) # optional - sage.rings.finite_rings + sage: phi2 = phi * phi + sage: phi2(E.points()[0]) (0 : 1 : 0) Coercion works fine with :meth:`_call_` (added for :trac:`16238`):: - sage: K. = NumberField(x^2 + 3) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [7,0]) # optional - sage.rings.number_field - sage: E2 = EllipticCurve(K, [5,0]) # optional - sage.rings.number_field - sage: phi = E.isogeny(E(0)) # optional - sage.rings.number_field - sage: phi(E2(0)) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 3) + sage: E = EllipticCurve(K, [7,0]) + sage: E2 = EllipticCurve(K, [5,0]) + sage: phi = E.isogeny(E(0)) + sage: phi(E2(0)) (0 : 1 : 0) - sage: E2(20,90) # optional - sage.rings.number_field + sage: E2(20,90) (20 : 90 : 1) - sage: phi(E2(20,90)) # optional - sage.rings.number_field + sage: phi(E2(20,90)) Traceback (most recent call last): ... TypeError: (20 : 90 : 1) fails to convert into the map's domain @@ -1243,24 +1250,25 @@ def _call_(self, P): Check that copying the order over works:: - sage: E = EllipticCurve(GF(431), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: Q = 2^99*P; Q.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(431), [1,0]) + sage: P, = E.gens() + sage: Q = 2^99*P; Q.order() 27 - sage: phi = E.isogeny(3^99*P) # optional - sage.rings.finite_rings - sage: phi(Q)._order # optional - sage.rings.finite_rings + sage: phi = E.isogeny(3^99*P) + sage: phi(Q)._order 27 Test for :trac:`35983`:: - sage: E = EllipticCurve([1,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E([1,0]) # optional - sage.rings.finite_rings - sage: P.order() # optional - sage.rings.finite_rings + sage: E = EllipticCurve([1,0,0,-1,0]) + sage: P = E([1,0]) + sage: P.order() +Infinity - sage: phi = E.isogenies_prime_degree(2)[0] # optional - sage.rings.finite_rings - sage: Q = phi(P); Q # optional - sage.rings.finite_rings + sage: phi = E.isogenies_prime_degree(2)[0] + sage: Q = phi(P); Q (0 : 1 : 1) - sage: Q.order() # optional - sage.rings.finite_rings + sage: Q.order() +Infinity """ @@ -1326,11 +1334,11 @@ def __getitem__(self, i): sage: phi[1] y - sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi[0] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi[0] (x^2 + 3)/x - sage: phi[1] # optional - sage.rings.finite_rings + sage: phi[1] (x^2*y - 3*y)/x^2 """ return self.rational_maps()[i] @@ -1347,9 +1355,9 @@ def __iter__(self): x y - sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: for c in phi: print(c) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: for c in phi: print(c) (x^2 + 3)/x (x^2*y - 3*y)/x^2 """ @@ -1365,19 +1373,19 @@ def __neg__(self): The following examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(17)(0)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((-1,0)) ) # optional - sage.rings.finite_rings - sage: negphi = -phi # optional - sage.rings.finite_rings - sage: phi(E((0,1))) + negphi(E((0,1))) == 0 # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(17)(0)) + sage: phi = EllipticCurveIsogeny(E, E((-1,0)) ) + sage: negphi = -phi + sage: phi(E((0,1))) + negphi(E((0,1))) == 0 True - sage: E = EllipticCurve(j=GF(19)(1728)) # optional - sage.rings.finite_rings - sage: R. = GF(19)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x) # optional - sage.rings.finite_rings - sage: negphi = -phi # optional - sage.rings.finite_rings - sage: phi(E((3,7))) + negphi(E((3,12))) == phi(2*E((3,7))) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(19)(1728)) + sage: R. = GF(19)[] + sage: phi = EllipticCurveIsogeny(E, x) + sage: negphi = -phi + sage: phi(E((3,7))) + negphi(E((3,12))) == phi(2*E((3,7))) True - sage: negphi(E((18,6))) # optional - sage.rings.finite_rings + sage: negphi(E((18,6))) (17 : 0 : 1) sage: R. = QQ[] @@ -1392,31 +1400,30 @@ def __neg__(self): sage: phi(P) + negphi(P) == 0 True - sage: E = EllipticCurve(GF(23), [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: f = E.torsion_polynomial(3)/3 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f, E) # optional - sage.rings.finite_rings - sage: phi.rational_maps() == E.multiplication_by_m(3) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(23), [0,0,0,1,0]) + sage: f = E.torsion_polynomial(3)/3 + sage: phi = EllipticCurveIsogeny(E, f, E) + sage: phi.rational_maps() == E.multiplication_by_m(3) False - sage: negphi = -phi # optional - sage.rings.finite_rings - sage: negphi.rational_maps() == E.multiplication_by_m(3) # optional - sage.rings.finite_rings + sage: negphi = -phi + sage: negphi.rational_maps() == E.multiplication_by_m(3) True - sage: E = EllipticCurve(GF(17), [-2, 3, -5, 7, -11]) # optional - sage.rings.finite_rings - sage: R. = GF(17)[] # optional - sage.rings.finite_rings - sage: f = x+6 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [-2, 3, -5, 7, -11]) + sage: R. = GF(17)[] + sage: f = x+6 + sage: phi = EllipticCurveIsogeny(E, f); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 7*x + 6 over Finite Field of size 17 to Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 4*x + 8 over Finite Field of size 17 - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^2 + 6*x + 4)/(x + 6), (x^2*y - 5*x*y + 8*x - 2*y)/(x^2 - 5*x + 2)) - sage: negphi = -phi # optional - sage.rings.finite_rings - sage: negphi # optional - sage.rings.finite_rings + sage: negphi = -phi + sage: negphi Isogeny of degree 2 from Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 7*x + 6 over Finite Field of size 17 to Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 4*x + 8 over Finite Field of size 17 - sage: negphi.rational_maps() # optional - sage.rings.finite_rings + sage: negphi.rational_maps() ((x^2 + 6*x + 4)/(x + 6), (2*x^3 - x^2*y - 5*x^2 + 5*x*y - 4*x + 2*y + 7)/(x^2 - 5*x + 2)) @@ -1432,14 +1439,15 @@ def __neg__(self): sage: ymap1 == -ymap2 - E.a1()*xmap2 - E.a3() True - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: phi = EllipticCurveIsogeny(E, x - a) # optional - sage.rings.number_field - sage: phi.rational_maps() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: R. = K[] + sage: phi = EllipticCurveIsogeny(E, x - a) + sage: phi.rational_maps() ((x^2 + (-a)*x - 2)/(x + (-a)), (x^2*y + (-2*a)*x*y + y)/(x^2 + (-2*a)*x - 1)) - sage: negphi = -phi # optional - sage.rings.number_field - sage: negphi.rational_maps() # optional - sage.rings.number_field + sage: negphi = -phi + sage: negphi.rational_maps() ((x^2 + (-a)*x - 2)/(x + (-a)), (-x^2*y + (2*a)*x*y - y)/(x^2 + (-2*a)*x - 1)) """ output = copy(self) @@ -1456,9 +1464,9 @@ def _repr_(self): EXAMPLES:: - sage: E = EllipticCurve(GF(31), [1,0,1,1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0)) ) # optional - sage.rings.finite_rings - sage: phi._repr_() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [1,0,1,1,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0)) ) + sage: phi._repr_() 'Isogeny of degree 17 from Elliptic Curve defined by y^2 + x*y + y = x^3 + x over Finite Field of size 31 to Elliptic Curve defined by y^2 + x*y + y = x^3 + 14*x + 9 over Finite Field of size 31' sage: E = EllipticCurve(QQ, [1,0,0,1,9]) @@ -1482,10 +1490,10 @@ def _latex_(self): sage: phi._latex_() '\\left( x , y \\right)' - sage: E = EllipticCurve(GF(17), [0,0,0,1,-1]) # optional - sage.rings.finite_rings - sage: R. = GF(17)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, X + 11) # optional - sage.rings.finite_rings - sage: phi._latex_() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,1,-1]) + sage: R. = GF(17)[] + sage: phi = EllipticCurveIsogeny(E, X + 11) + sage: phi._latex_() '\\left( \\frac{x^{2} + 11 x + 7}{x + 11} , \\frac{x^{2} y + 5 x y + 12 y}{x^{2} + 5 x + 2} \\right)' """ fx,fy = self.rational_maps() @@ -1513,17 +1521,17 @@ def __clear_cached_values(self): sage: old_ratl_maps[1] == -phi.rational_maps()[1] True - sage: F = GF(127); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=F(1728)) # optional - sage.rings.finite_rings - sage: f = x^5 + 43*x^4 + 97*x^3 + 81*x^2 + 42*x + 82 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: old_ratl_maps = phi.rational_maps() # optional - sage.rings.finite_rings + sage: F = GF(127); R. = F[] + sage: E = EllipticCurve(j=F(1728)) + sage: f = x^5 + 43*x^4 + 97*x^3 + 81*x^2 + 42*x + 82 + sage: phi = EllipticCurveIsogeny(E, f) + sage: old_ratl_maps = phi.rational_maps() sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: phi._set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), # optional - sage.rings.finite_rings + sage: phi._set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), ....: (-13,13,-13,13))) - sage: old_ratl_maps == phi.rational_maps() # optional - sage.rings.finite_rings + sage: old_ratl_maps == phi.rational_maps() False - sage: phi._EllipticCurveIsogeny__clear_cached_values() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__clear_cached_values() """ self.__ratl_maps = None self.__dual = None @@ -1538,17 +1546,17 @@ def __perform_inheritance_housekeeping(self): The following examples will implicitly exercise this function:: - sage: E = EllipticCurve(GF(43), [2,3,5,7,11]) # optional - sage.rings.finite_rings - sage: R. = GF(43)[]; f = x + 42 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__perform_inheritance_housekeeping() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(43), [2,3,5,7,11]) + sage: R. = GF(43)[]; f = x + 42 + sage: phi = EllipticCurveIsogeny(E, f) + sage: phi._EllipticCurveIsogeny__perform_inheritance_housekeeping() sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: post_isom = WeierstrassIsomorphism(E2, (41, 37, 31, 29)) # optional - sage.rings.finite_rings - sage: phi._set_post_isomorphism(post_isom) # optional - sage.rings.finite_rings - sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain() # optional - sage.rings.finite_rings - sage: pre_isom = E1pr.isomorphism_to(E) # optional - sage.rings.finite_rings - sage: phi._set_pre_isomorphism(pre_isom) # optional - sage.rings.finite_rings + sage: E2 = phi.codomain() + sage: post_isom = WeierstrassIsomorphism(E2, (41, 37, 31, 29)) + sage: phi._set_post_isomorphism(post_isom) + sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain() + sage: pre_isom = E1pr.isomorphism_to(E) + sage: phi._set_pre_isomorphism(pre_isom) """ EllipticCurveHom.__init__(self, self._domain, self._codomain) @@ -1559,31 +1567,31 @@ def __init_algebraic_structs(self, E): EXAMPLES:: - sage: E = EllipticCurve(j=GF(17)(0)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((-1,0))) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(17)(0)) + sage: phi = EllipticCurveIsogeny(E, E((-1,0))) The constructor calls this function itself, so the fields it sets are already defined:: - sage: phi._domain # optional - sage.rings.finite_rings + sage: phi._domain Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__base_field # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__base_field Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__poly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__poly_ring Univariate Polynomial Ring in x over Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__mpoly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__mpoly_ring Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Finite Field of size 17 Now, calling the initialization function does nothing more:: - sage: phi._EllipticCurveIsogeny__init_algebraic_structs(E) # optional - sage.rings.finite_rings - sage: phi._domain # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_algebraic_structs(E) + sage: phi._domain Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__base_field # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__base_field Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__poly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__poly_ring Univariate Polynomial Ring in x over Finite Field of size 17 - sage: phi._EllipticCurveIsogeny__mpoly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__mpoly_ring Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Finite Field of size 17 sage: E = EllipticCurve(QQ, [0,0,0,1,0]) @@ -1598,17 +1606,17 @@ def __init_algebraic_structs(self, E): sage: phi._EllipticCurveIsogeny__mpoly_ring Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Rational Field - sage: F = GF(19); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=GF(19)(0)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_algebraic_structs(E) # optional - sage.rings.finite_rings - sage: phi._domain # optional - sage.rings.finite_rings + sage: F = GF(19); R. = F[] + sage: E = EllipticCurve(j=GF(19)(0)) + sage: phi = EllipticCurveIsogeny(E, x) + sage: phi._EllipticCurveIsogeny__init_algebraic_structs(E) + sage: phi._domain Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 19 - sage: phi._EllipticCurveIsogeny__base_field # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__base_field Finite Field of size 19 - sage: phi._EllipticCurveIsogeny__poly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__poly_ring Univariate Polynomial Ring in x over Finite Field of size 19 - sage: phi._EllipticCurveIsogeny__mpoly_ring # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__mpoly_ring Univariate Polynomial Ring in y over Univariate Polynomial Ring in x over Finite Field of size 19 """ self._domain = E @@ -1628,17 +1636,17 @@ def __compute_codomain(self): These examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(7)(1728)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(1728)) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__compute_codomain() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_codomain() - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x) # optional - sage.rings.finite_rings - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi = EllipticCurveIsogeny(E, x) + sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__compute_codomain() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_codomain() """ if self.__algorithm == 'velu': self._codomain = self.__compute_codomain_via_velu() @@ -1661,14 +1669,14 @@ def __initialize_rational_maps(self, precomputed_maps=None): The following examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(7)(1728)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # implicit doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(1728)) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.rational_maps() # implicit doctest ((x^2 + 1)/x, (x^2*y - y)/x^2) - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # implicit doctest # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi = EllipticCurveIsogeny(E, x) + sage: phi.rational_maps() # implicit doctest ((x^2 + 1)/x, (x^2*y - y)/x^2) sage: E = EllipticCurve([1,2,3,4,5]) @@ -1717,9 +1725,9 @@ def __init_kernel_polynomial(self): The following examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(7)(1728)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.kernel_polynomial() # implicit doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(1728)) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.kernel_polynomial() # implicit doctest x """ if self.__kernel_polynomial is None: @@ -1735,16 +1743,16 @@ def __set_pre_isomorphism(self, domain, isomorphism): EXAMPLES:: - sage: E = EllipticCurve(GF(43), [2,3,5,7,11]) # optional - sage.rings.finite_rings - sage: R. = GF(43)[]; f = x + 42 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__perform_inheritance_housekeeping() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(43), [2,3,5,7,11]) + sage: R. = GF(43)[]; f = x + 42 + sage: phi = EllipticCurveIsogeny(E, f) + sage: phi._EllipticCurveIsogeny__perform_inheritance_housekeeping() sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain() # optional - sage.rings.finite_rings - sage: pre_isom = E1pr.isomorphism_to(E) # optional - sage.rings.finite_rings - sage: phi._set_pre_isomorphism(pre_isom) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__set_pre_isomorphism(E, WeierstrassIsomorphism(E, (-1, 3, -3, 4))) # optional - sage.rings.finite_rings - sage: E == phi.domain() # optional - sage.rings.finite_rings + sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain() + sage: pre_isom = E1pr.isomorphism_to(E) + sage: phi._set_pre_isomorphism(pre_isom) + sage: phi._EllipticCurveIsogeny__set_pre_isomorphism(E, WeierstrassIsomorphism(E, (-1, 3, -3, 4))) + sage: E == phi.domain() True """ self._domain = domain @@ -1779,14 +1787,14 @@ def __set_post_isomorphism(self, codomain, isomorphism): The following examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(7)(1728)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(1728)) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: isom = WeierstrassIsomorphism(E2, (-1,2,-3,4)) # optional - sage.rings.finite_rings - sage: phi._set_post_isomorphism(isom) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__set_post_isomorphism(E2, WeierstrassIsomorphism(phi.codomain(), (1,-2,3,-4))) # optional - sage.rings.finite_rings - sage: E2 == phi.codomain() # optional - sage.rings.finite_rings + sage: E2 = phi.codomain() + sage: isom = WeierstrassIsomorphism(E2, (-1,2,-3,4)) + sage: phi._set_post_isomorphism(isom) + sage: phi._EllipticCurveIsogeny__set_post_isomorphism(E2, WeierstrassIsomorphism(phi.codomain(), (1,-2,3,-4))) + sage: E2 == phi.codomain() True """ self._codomain = codomain @@ -1815,20 +1823,20 @@ def __setup_post_isomorphism(self, codomain, model): The following examples inherently exercise this function:: - sage: E = EllipticCurve(j=GF(7)(1728)) # optional - sage.rings.finite_rings - sage: E2 = EllipticCurve(GF(7), [0,0,0,5,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0)), E2); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(1728)) + sage: E2 = EllipticCurve(GF(7), [0,0,0,5,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0)), E2); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 7 - sage: E3 = EllipticCurve(GF(7), [0,0,0,6,0]) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__setup_post_isomorphism(E3, None) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: E3 = EllipticCurve(GF(7), [0,0,0,6,0]) + sage: phi._EllipticCurveIsogeny__setup_post_isomorphism(E3, None) + sage: phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 - sage: EllipticCurveIsogeny(E, E(0,0), model='montgomery') # optional - sage.rings.finite_rings + sage: EllipticCurveIsogeny(E, E(0,0), model='montgomery') Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + x^2 + x over Finite Field of size 7 @@ -1887,22 +1895,23 @@ def __init_from_kernel_list(self, kernel_gens): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__init_from_kernel_list([E(0), E((0,0))]) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_from_kernel_list([E(0), E((0,0))]) The following example demonstrates the necessity of avoiding any calls to P.order(), since such calls involve factoring the group order which could take a long time. :: - sage: p = 12 * next_prime(2^180) * next_prime(2^194) - 1 # optional - sage.rings.finite_rings - sage: F = FiniteField(p, proof=False) # optional - sage.rings.finite_rings - sage: E = EllipticCurve([F(1), F(0)]) # optional - sage.rings.finite_rings - sage: P = E(0).division_points(3)[1] # optional - sage.rings.finite_rings - sage: EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: p = 12 * next_prime(2^180) * next_prime(2^194) - 1 + sage: F = FiniteField(p, proof=False) + sage: E = EllipticCurve([F(1), F(0)]) + sage: P = E(0).division_points(3)[1] + sage: EllipticCurveIsogeny(E, P) Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 461742260113997803268895001173557974278278194575766957660028841364655249961609425998827452443620996655395008156411 @@ -1949,13 +1958,13 @@ def __sort_kernel_list(self): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P); phi Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__sort_kernel_list() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__sort_kernel_list() """ a1, a2, a3, a4, _ = self._domain.a_invariants() @@ -2001,12 +2010,12 @@ def __compute_codomain_via_velu(self): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__compute_codomain_via_velu() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_codomain_via_velu() Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 7 """ return compute_codomain_formula(self._domain, self.__v, self.__w) @@ -2021,22 +2030,22 @@ def __velu_sum_helper(xQ, Qvalues, a1, a3, x, y): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: Q = E((0,0)); phi(Q) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: Q = E((0,0)); phi(Q) (0 : 0 : 1) - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) - sage: F = GF(7) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0)) ) # optional - sage.rings.finite_rings - sage: Qvals = phi._EllipticCurveIsogeny__kernel_mod_sign[0] # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__velu_sum_helper(0, Qvals, 0, 0, F(5), F(5)) # optional - sage.rings.finite_rings + sage: F = GF(7) + sage: E = EllipticCurve(F, [0,0,0,1,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0)) ) + sage: Qvals = phi._EllipticCurveIsogeny__kernel_mod_sign[0] + sage: phi._EllipticCurveIsogeny__velu_sum_helper(0, Qvals, 0, 0, F(5), F(5)) (3, 3) - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__velu_sum_helper(0, Qvals, 0, 0, x, y) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi._EllipticCurveIsogeny__velu_sum_helper(0, Qvals, 0, 0, x, y) (1/x, y/x^2) """ yQ, gxQ, gyQ, vQ, uQ = Qvalues @@ -2069,17 +2078,17 @@ def __compute_via_velu_numeric(self, xP, yP): The following example inherently exercises this function:: - sage: F = GF(7) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: Q = E((0,0)); phi(Q) # optional - sage.rings.finite_rings + sage: F = GF(7) + sage: E = EllipticCurve(F, [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: Q = E((0,0)); phi(Q) (0 : 0 : 1) - sage: Q = E((-1,0)); phi(Q) # optional - sage.rings.finite_rings + sage: Q = E((-1,0)); phi(Q) (0 : 0 : 1) - sage: phi._EllipticCurveIsogeny__compute_via_velu_numeric(F(0), F(0)) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_velu_numeric(F(0), F(0)) (0, 0) - sage: phi._EllipticCurveIsogeny__compute_via_velu_numeric(F(-1), F(0)) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_velu_numeric(F(-1), F(0)) (0, 0) """ # first check if the point is in the kernel @@ -2096,18 +2105,18 @@ def __compute_via_velu(self, xP, yP): The following example inherently exercises this function:: - sage: F = GF(7) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: Q = E((0,0)); phi(Q) # optional - sage.rings.finite_rings + sage: F = GF(7) + sage: E = EllipticCurve(F, [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: Q = E((0,0)); phi(Q) (0 : 0 : 1) - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) - sage: phi._EllipticCurveIsogeny__compute_via_velu(F(0), F(0)) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_velu(F(0), F(0)) (0, 0) - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__compute_via_velu(x, y) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi._EllipticCurveIsogeny__compute_via_velu(x, y) ((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) @@ -2115,24 +2124,26 @@ def __compute_via_velu(self, xP, yP): Check for :trac:`33214`:: - sage: z2 = GF(71^2).gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(71^2), [5,5]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E.lift_x(0)) # optional - sage.rings.finite_rings - sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism # optional - sage.rings.finite_rings - sage: pre = WeierstrassIsomorphism(None, (z2,7,8,9), E) # optional - sage.rings.finite_rings - sage: phi = phi * pre # optional - sage.rings.finite_rings - sage: P = phi.domain()(1, 46*z2+49) # optional - sage.rings.finite_rings - sage: phi(P) # indirect doctest # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: z2 = GF(71^2).gen() + sage: E = EllipticCurve(GF(71^2), [5,5]) + sage: phi = E.isogeny(E.lift_x(0)) + sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism + sage: pre = WeierstrassIsomorphism(None, (z2,7,8,9), E) + sage: phi = phi * pre + sage: P = phi.domain()(1, 46*z2+49) + sage: phi(P) # indirect doctest (33 : 61*z2 + 10 : 1) The rational maps are also computed via this code path; check that they are plausible (this failed prior to :trac:`33214`):: - sage: fx,fy = phi.rational_maps() # indirect doctest # optional - sage.rings.finite_rings - sage: R. = GF(71^2)[] # optional - sage.rings.finite_rings - sage: E0, E2 = phi.domain(), phi.codomain() # optional - sage.rings.finite_rings - sage: eqs = [EE.defining_polynomial()(x,y,1) for EE in (E0,E2)] # optional - sage.rings.finite_rings - sage: eqs[1](fx,fy).numerator() % eqs[0] # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: fx,fy = phi.rational_maps() # indirect doctest + sage: R. = GF(71^2)[] + sage: E0, E2 = phi.domain(), phi.codomain() + sage: eqs = [EE.defining_polynomial()(x,y,1) for EE in (E0,E2)] + sage: eqs[1](fx,fy).numerator() % eqs[0] 0 """ if self.__pre_isomorphism is None: @@ -2162,12 +2173,12 @@ def __initialize_rational_maps_via_velu(self): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: phi.rational_maps() ((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) - sage: phi._EllipticCurveIsogeny__initialize_rational_maps_via_velu() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__initialize_rational_maps_via_velu() ((x^4 + 5*x^3 + x^2 + 4*x)/(x^3 + 5*x^2 + 3*x + 5), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) """ x = self.__poly_ring.gen() @@ -2183,10 +2194,10 @@ def __init_kernel_polynomial_velu(self): The following example inherently exercises this function:: - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: P = E((4,2)) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings - sage: phi.kernel_polynomial() # implicit doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: P = E((4,2)) + sage: phi = EllipticCurveIsogeny(E, P) + sage: phi.kernel_polynomial() # implicit doctest x^2 + 2*x + 4 """ poly_ring, x = self.__poly_ring.objgen() @@ -2216,22 +2227,22 @@ def __init_from_kernel_polynomial(self, kernel_polynomial): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x);phi # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) + sage: phi = EllipticCurveIsogeny(E, x);phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__init_from_kernel_polynomial(x) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_from_kernel_polynomial(x) - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__init_from_kernel_polynomial(x+6) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_from_kernel_polynomial(x+6) """ poly_ring = self.__poly_ring E = self._domain @@ -2317,39 +2328,39 @@ def __init_even_kernel_polynomial(self, E, psi_G): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [-1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x); phi # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [-1,0]) + sage: phi = EllipticCurveIsogeny(E, x); phi Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 7 sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import two_torsion_part - sage: psig = two_torsion_part(E,x) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) # optional - sage.rings.finite_rings + sage: psig = two_torsion_part(E,x) + sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) (x^3 + 6*x, (x^3 + x)*y, 6, 0, 1, 2) - sage: F = GF(2^4, 'alpha'); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1,0,1,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x); phi # optional - sage.rings.finite_rings + sage: F = GF(2^4, 'alpha'); R. = F[] # needs sage.rings.finite_rings + sage: E = EllipticCurve(F, [1,1,0,1,0]) # needs sage.rings.finite_rings + sage: phi = EllipticCurveIsogeny(E, x); phi # needs sage.rings.finite_rings Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + x over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + 1 over Finite Field in alpha of size 2^4 - sage: psig = two_torsion_part(E,x) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) # optional - sage.rings.finite_rings + sage: psig = two_torsion_part(E,x) # needs sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) # needs sage.rings.finite_rings (x^3 + x, (x^3 + x)*y + x^2, 1, 0, 1, 2) - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: f = x^3 + 6*x^2 + 1 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: R. = GF(7)[] + sage: f = x^3 + 6*x^2 + 1 + sage: phi = EllipticCurveIsogeny(E, f); phi Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 2*x + 5 over Finite Field of size 7 - sage: psig = two_torsion_part(E,f) # optional - sage.rings.finite_rings - sage: psig = two_torsion_part(E,f) # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) # optional - sage.rings.finite_rings + sage: psig = two_torsion_part(E,f) + sage: psig = two_torsion_part(E,f) + sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) (x^7 + 5*x^6 + 2*x^5 + 6*x^4 + 3*x^3 + 5*x^2 + 6*x + 3, (x^9 + 4*x^8 + 2*x^7 + 4*x^3 + 2*x^2 + x + 6)*y, 1, 6, 3, 4) """ # check if the polynomial really divides the two_torsion_polynomial @@ -2434,36 +2445,37 @@ def __init_odd_kernel_polynomial(self, E, psi): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_odd_kernel_polynomial(E, x+6) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi._EllipticCurveIsogeny__init_odd_kernel_polynomial(E, x+6) (x^3 + 5*x^2 + 3*x + 2, (x^3 + 4*x^2 + x)*y, 2, 6, 1, 3) - sage: F = GF(2^4, 'alpha'); R. = F[] # optional - sage.rings.finite_rings - sage: alpha = F.gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,1,F.gen(),F.gen()^2+1,1]) # optional - sage.rings.finite_rings - sage: f = x + alpha^2 + 1 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f); phi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(2^4, 'alpha'); R. = F[] + sage: alpha = F.gen() + sage: E = EllipticCurve(F, [1,1,F.gen(),F.gen()^2+1,1]) + sage: f = x + alpha^2 + 1 + sage: phi = EllipticCurveIsogeny(E, f); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + (alpha^2+1)*x + 1 over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + alpha*x + alpha^3 over Finite Field in alpha of size 2^4 - sage: R. = F[] # optional - sage.rings.finite_rings - sage: f = x + alpha^2 + 1 # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__init_odd_kernel_polynomial(E, f) # optional - sage.rings.finite_rings + sage: R. = F[] # needs sage.rings.finite_rings + sage: f = x + alpha^2 + 1 # needs sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__init_odd_kernel_polynomial(E, f) # needs sage.rings.finite_rings (x^3 + (alpha^2 + 1)*x + alpha^3 + alpha^2 + alpha, (x^3 + (alpha^2 + 1)*x^2 + (alpha^2 + 1)*x + alpha)*y + (alpha^2 + alpha + 1)*x^2 + (alpha^2 + alpha)*x + alpha, alpha^2 + alpha + 1, alpha^3 + alpha^2 + alpha, 1, 3) - sage: E = EllipticCurve(j=-262537412640768000) # optional - sage.rings.finite_rings - sage: f = E.isogenies_prime_degree()[0].kernel_polynomial() # optional - sage.rings.finite_rings - sage: f.degree() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=-262537412640768000) + sage: f = E.isogenies_prime_degree()[0].kernel_polynomial() + sage: f.degree() 81 - sage: E.isogeny(kernel=f, check=False) # optional - sage.rings.finite_rings + sage: E.isogeny(kernel=f, check=False) Isogeny of degree 163 from Elliptic Curve defined by y^2 + y = x^3 - 2174420*x + 1234136692 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 57772164980*x - 5344733777551611 over Rational Field @@ -2536,19 +2548,19 @@ def __compute_omega_fast(self, E, psi, psi_pr, phi, phi_pr): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: psi = phi._EllipticCurveIsogeny__psi # optional - sage.rings.finite_rings - sage: psi_pr = psi.derivative() # optional - sage.rings.finite_rings - sage: fi = phi._EllipticCurveIsogeny__phi # optional - sage.rings.finite_rings - sage: fi_pr = fi.derivative() # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__compute_omega_fast(E, psi, psi_pr, fi, fi_pr) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: psi = phi._EllipticCurveIsogeny__psi + sage: psi_pr = psi.derivative() + sage: fi = phi._EllipticCurveIsogeny__phi + sage: fi_pr = fi.derivative() + sage: phi._EllipticCurveIsogeny__compute_omega_fast(E, psi, psi_pr, fi, fi_pr) (x^3 + 4*x^2 + x)*y """ a1 = E.a1() @@ -2586,32 +2598,35 @@ def __compute_omega_general(self, E, psi, psi_pr, phi, phi_pr): These examples inherently exercise this private function:: - sage: F = GF(2^4, 'alpha'); R. = F[] # optional - sage.rings.finite_rings - sage: alpha = F.gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1, 1, F.gen(), F.gen()^2+1, 1]) # optional - sage.rings.finite_rings - sage: f = x + alpha^2 + 1 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f); phi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(2^4, 'alpha'); R. = F[] + sage: alpha = F.gen() + sage: E = EllipticCurve(F, [1, 1, F.gen(), F.gen()^2+1, 1]) + sage: f = x + alpha^2 + 1 + sage: phi = EllipticCurveIsogeny(E, f); phi Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + (alpha^2+1)*x + 1 over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + alpha*x + alpha^3 over Finite Field in alpha of size 2^4 - sage: R. = F[] # optional - sage.rings.finite_rings - sage: psi = phi._EllipticCurveIsogeny__psi # optional - sage.rings.finite_rings - sage: psi_pr = psi.derivative() # optional - sage.rings.finite_rings - sage: fi = phi._EllipticCurveIsogeny__phi # optional - sage.rings.finite_rings - sage: fi_pr = fi.derivative() # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__compute_omega_general(E, psi, psi_pr, fi, fi_pr) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = F[] + sage: psi = phi._EllipticCurveIsogeny__psi + sage: psi_pr = psi.derivative() + sage: fi = phi._EllipticCurveIsogeny__phi + sage: fi_pr = fi.derivative() + sage: phi._EllipticCurveIsogeny__compute_omega_general(E, psi, psi_pr, fi, fi_pr) (x^3 + (alpha^2 + 1)*x^2 + (alpha^2 + 1)*x + alpha)*y + (alpha^2 + alpha + 1)*x^2 + (alpha^2 + alpha)*x + alpha A bug fixed in :trac:`7907`:: - sage: F = GF(128,'a') # optional - sage.rings.finite_rings - sage: a = F.gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve([1,0,0,0,(a**6+a**4+a**2+a)]) # optional - sage.rings.finite_rings - sage: x = polygen(F) # optional - sage.rings.finite_rings - sage: ker = (x^6 + (a^6 + a^5 + a^4 + a^3 + a^2 + a)*x^5 + (a^6 + a^5 + a^2 + 1)*x^4 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(128,'a') + sage: a = F.gen() + sage: E = EllipticCurve([1,0,0,0,(a**6+a**4+a**2+a)]) + sage: x = polygen(F) + sage: ker = (x^6 + (a^6 + a^5 + a^4 + a^3 + a^2 + a)*x^5 + (a^6 + a^5 + a^2 + 1)*x^4 ....: + (a^6 + a^5 + a^4 + a^3 + a^2 + 1)*x^3 + (a^6 + a^3 + a)*x^2 + (a^4 + a^3 + 1)*x + a^5 + a^4 + a) - sage: E.isogeny(ker) # optional - sage.rings.finite_rings + sage: E.isogeny(ker) Isogeny of degree 13 from Elliptic Curve defined by y^2 + x*y = x^3 + (a^6+a^4+a^2+a) over Finite Field in a of size 2^7 to Elliptic Curve defined by y^2 + x*y = x^3 + (a^6+a^5+a^4+a^3+a^2+a)*x + (a^5+a^3) over Finite Field in a of size 2^7 @@ -2668,16 +2683,16 @@ def __compute_via_kohel_numeric(self, xP, yP): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) # optional - sage.rings.finite_rings - sage: P = E((0,1)); phi(P) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) + sage: P = E((0,1)); phi(P) (2 : 0 : 1) - sage: P = E((1,1)); phi(P) # optional - sage.rings.finite_rings + sage: P = E((1,1)); phi(P) (0 : 1 : 0) - sage: phi._EllipticCurveIsogeny__compute_via_kohel_numeric(0, 1) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_kohel_numeric(0, 1) (2, 0) - sage: phi._EllipticCurveIsogeny__compute_via_kohel_numeric(1, 1) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_kohel_numeric(1, 1) () """ # first check if the point is in the kernel @@ -2694,17 +2709,17 @@ def __compute_via_kohel(self, xP, yP): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) # optional - sage.rings.finite_rings - sage: P = E((0,1)); phi(P) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) + sage: P = E((0,1)); phi(P) (2 : 0 : 1) - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: phi.rational_maps() ((x^3 - 2*x^2 + 3*x + 2)/(x^2 - 2*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) - sage: phi._EllipticCurveIsogeny__compute_via_kohel(0,1) # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_via_kohel(0,1) (2, 0) - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: phi._EllipticCurveIsogeny__compute_via_kohel(x,y) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: phi._EllipticCurveIsogeny__compute_via_kohel(x,y) ((x^3 - 2*x^2 + 3*x + 2)/(x^2 - 2*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) """ a = self.__phi(xP) @@ -2723,12 +2738,12 @@ def __initialize_rational_maps_via_kohel(self): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) + sage: phi.rational_maps() ((x^3 - 2*x^2 + 3*x + 2)/(x^2 - 2*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) - sage: phi._EllipticCurveIsogeny__initialize_rational_maps_via_kohel() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__initialize_rational_maps_via_kohel() ((x^3 + 5*x^2 + 3*x + 2)/(x^2 + 5*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) """ x = self.__poly_ring.gen() @@ -2747,12 +2762,12 @@ def __compute_codomain_via_kohel(self): These examples inherently exercise this private function:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) # optional - sage.rings.finite_rings - sage: phi.codomain() # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) + sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) + sage: phi.codomain() Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 - sage: phi._EllipticCurveIsogeny__compute_codomain_via_kohel() # optional - sage.rings.finite_rings + sage: phi._EllipticCurveIsogeny__compute_codomain_via_kohel() Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 """ return compute_codomain_formula(self._domain, self.__v, self.__w) @@ -2780,9 +2795,9 @@ def rational_maps(self): sage: phi.rational_maps() (x, y) - sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.rational_maps() ((x^2 + 3)/x, (x^2*y - 3*y)/x^2) """ self.__initialize_rational_maps() @@ -2807,9 +2822,9 @@ def x_rational_map(self): sage: phi.x_rational_map() x - sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.x_rational_map() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.x_rational_map() (x^2 + 3)/x """ self.__initialize_rational_maps() @@ -2828,13 +2843,14 @@ def scaling_factor(self): EXAMPLES:: - sage: E = EllipticCurve(GF(257^2), [0,1]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E.lift_x(240)) # optional - sage.rings.finite_rings - sage: phi.degree() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(257^2), [0,1]) + sage: phi = E.isogeny(E.lift_x(240)) + sage: phi.degree() 43 - sage: phi.scaling_factor() # optional - sage.rings.finite_rings + sage: phi.scaling_factor() 1 - sage: phi.dual().scaling_factor() # optional - sage.rings.finite_rings + sage: phi.dual().scaling_factor() 43 ALGORITHM: The "inner" isogeny is normalized by construction, @@ -2864,14 +2880,14 @@ def kernel_polynomial(self): sage: phi.kernel_polynomial() x^2 - 21*x + 80 - sage: E = EllipticCurve(GF(17), [1,-1,1,-1,1]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [1]) # optional - sage.rings.finite_rings - sage: phi.kernel_polynomial() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [1,-1,1,-1,1]) + sage: phi = EllipticCurveIsogeny(E, [1]) + sage: phi.kernel_polynomial() 1 - sage: E = EllipticCurve(GF(31), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, [0,3,0,1]) # optional - sage.rings.finite_rings - sage: phi.kernel_polynomial() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, [0,3,0,1]) + sage: phi.kernel_polynomial() x^3 + 3*x """ if self.__kernel_polynomial is None: @@ -2887,9 +2903,9 @@ def is_separable(self): EXAMPLES:: - sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, E((0,0))) # optional - sage.rings.finite_rings - sage: phi.is_separable() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) + sage: phi = EllipticCurveIsogeny(E, E((0,0))) + sage: phi.is_separable() True :: @@ -2910,45 +2926,45 @@ def _set_pre_isomorphism(self, preWI): TESTS:: - sage: E = EllipticCurve(GF(31), [1,1,0,1,-1]) # optional - sage.rings.finite_rings - sage: R. = GF(31)[] # optional - sage.rings.finite_rings - sage: f = x^3 + 9*x^2 + x + 30 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: Epr = E.short_weierstrass_model() # optional - sage.rings.finite_rings - sage: isom = Epr.isomorphism_to(E) # optional - sage.rings.finite_rings - sage: phi._set_pre_isomorphism(isom) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [1,1,0,1,-1]) + sage: R. = GF(31)[] + sage: f = x^3 + 9*x^2 + x + 30 + sage: phi = EllipticCurveIsogeny(E, f) + sage: Epr = E.short_weierstrass_model() + sage: isom = Epr.isomorphism_to(E) + sage: phi._set_pre_isomorphism(isom) + sage: phi.rational_maps() ((-6*x^4 - 3*x^3 + 12*x^2 + 10*x - 1)/(x^3 + x - 12), (3*x^7 + x^6*y - 14*x^6 - 3*x^5 + 5*x^4*y + 7*x^4 + 8*x^3*y - 8*x^3 - 5*x^2*y + 5*x^2 - 14*x*y + 14*x - 6*y - 6)/(x^6 + 2*x^4 + 7*x^3 + x^2 + 7*x - 11)) - sage: phi(Epr((0,22))) # optional - sage.rings.finite_rings + sage: phi(Epr((0,22))) (13 : 21 : 1) - sage: phi(Epr((3,7))) # optional - sage.rings.finite_rings + sage: phi(Epr((3,7))) (14 : 17 : 1) - sage: E = EllipticCurve(GF(29), [0,0,0,1,0]) # optional - sage.rings.finite_rings - sage: R. = GF(29)[] # optional - sage.rings.finite_rings - sage: f = x^2 + 5 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(29), [0,0,0,1,0]) + sage: R. = GF(29)[] + sage: f = x^2 + 5 + sage: phi = EllipticCurveIsogeny(E, f) + sage: phi Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 20*x over Finite Field of size 29 sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: inv_isom = WeierstrassIsomorphism(E, (1,-2,5,10)) # optional - sage.rings.finite_rings - sage: Epr = inv_isom.codomain() # optional - sage.rings.finite_rings - sage: isom = Epr.isomorphism_to(E) # optional - sage.rings.finite_rings - sage: phi._set_pre_isomorphism(isom) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: inv_isom = WeierstrassIsomorphism(E, (1,-2,5,10)) + sage: Epr = inv_isom.codomain() + sage: isom = Epr.isomorphism_to(E) + sage: phi._set_pre_isomorphism(isom) + sage: phi Isogeny of degree 5 from Elliptic Curve defined by y^2 + 10*x*y + 20*y = x^3 + 27*x^2 + 6 over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 20*x over Finite Field of size 29 - sage: phi(Epr((12,1))) # optional - sage.rings.finite_rings + sage: phi(Epr((12,1))) (26 : 0 : 1) - sage: phi(Epr((2,9))) # optional - sage.rings.finite_rings + sage: phi(Epr((2,9))) (0 : 0 : 1) - sage: phi(Epr((21,12))) # optional - sage.rings.finite_rings + sage: phi(Epr((21,12))) (3 : 0 : 1) - sage: phi.rational_maps()[0] # optional - sage.rings.finite_rings + sage: phi.rational_maps()[0] (x^5 - 10*x^4 - 6*x^3 - 7*x^2 - x + 3)/(x^4 - 8*x^3 + 5*x^2 - 14*x - 6) sage: E = EllipticCurve('11a1') @@ -2998,26 +3014,26 @@ def _set_post_isomorphism(self, postWI): TESTS:: - sage: E = EllipticCurve(j=GF(31)(0)) # optional - sage.rings.finite_rings - sage: R. = GF(31)[] # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, x+18) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(31)(0)) + sage: R. = GF(31)[] + sage: phi = EllipticCurveIsogeny(E, x+18) sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: phi._set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (6,8,10,12))) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: phi._set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (6,8,10,12))) + sage: phi Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 31 to Elliptic Curve defined by y^2 + 24*x*y + 7*y = x^3 + 22*x^2 + 16*x + 20 over Finite Field of size 31 - sage: E = EllipticCurve(j=GF(47)(0)) # optional - sage.rings.finite_rings - sage: f = E.torsion_polynomial(3)/3 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: post_isom = E2.isomorphism_to(E) # optional - sage.rings.finite_rings - sage: phi._set_post_isomorphism(post_isom) # optional - sage.rings.finite_rings - sage: phi.rational_maps() == E.multiplication_by_m(3) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(47)(0)) + sage: f = E.torsion_polynomial(3)/3 + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: post_isom = E2.isomorphism_to(E) + sage: phi._set_post_isomorphism(post_isom) + sage: phi.rational_maps() == E.multiplication_by_m(3) False - sage: phi = -phi # optional - sage.rings.finite_rings - sage: phi.rational_maps() == E.multiplication_by_m(3) # optional - sage.rings.finite_rings + sage: phi = -phi + sage: phi.rational_maps() == E.multiplication_by_m(3) True sage: R. = QQ[] @@ -3083,49 +3099,50 @@ def dual(self): sage: (Xm, Ym) == E.multiplication_by_m(5) True - sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) # optional - sage.rings.finite_rings - sage: R. = GF(37)[] # optional - sage.rings.finite_rings - sage: f = x^3 + x^2 + 28*x + 33 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi_hat = phi.dual() # optional - sage.rings.finite_rings - sage: phi_hat.codomain() == phi.domain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) + sage: R. = GF(37)[] + sage: f = x^3 + x^2 + 28*x + 33 + sage: phi = EllipticCurveIsogeny(E, f) + sage: phi_hat = phi.dual() + sage: phi_hat.codomain() == phi.domain() True - sage: phi_hat.domain() == phi.codomain() # optional - sage.rings.finite_rings + sage: phi_hat.domain() == phi.codomain() True - sage: (X, Y) = phi.rational_maps() # optional - sage.rings.finite_rings - sage: (Xhat, Yhat) = phi_hat.rational_maps() # optional - sage.rings.finite_rings - sage: Xm = Xhat.subs(x=X, y=Y) # optional - sage.rings.finite_rings - sage: Ym = Yhat.subs(x=X, y=Y) # optional - sage.rings.finite_rings - sage: (Xm, Ym) == E.multiplication_by_m(7) # optional - sage.rings.finite_rings + sage: (X, Y) = phi.rational_maps() + sage: (Xhat, Yhat) = phi_hat.rational_maps() + sage: Xm = Xhat.subs(x=X, y=Y) + sage: Ym = Yhat.subs(x=X, y=Y) + sage: (Xm, Ym) == E.multiplication_by_m(7) True - sage: E = EllipticCurve(GF(31), [0,0,0,1,8]) # optional - sage.rings.finite_rings - sage: R. = GF(31)[] # optional - sage.rings.finite_rings - sage: f = x^2 + 17*x + 29 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: phi_hat = phi.dual() # optional - sage.rings.finite_rings - sage: phi_hat.codomain() == phi.domain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [0,0,0,1,8]) + sage: R. = GF(31)[] + sage: f = x^2 + 17*x + 29 + sage: phi = EllipticCurveIsogeny(E, f) + sage: phi_hat = phi.dual() + sage: phi_hat.codomain() == phi.domain() True - sage: phi_hat.domain() == phi.codomain() # optional - sage.rings.finite_rings + sage: phi_hat.domain() == phi.codomain() True - sage: (X, Y) = phi.rational_maps() # optional - sage.rings.finite_rings - sage: (Xhat, Yhat) = phi_hat.rational_maps() # optional - sage.rings.finite_rings - sage: Xm = Xhat.subs(x=X, y=Y) # optional - sage.rings.finite_rings - sage: Ym = Yhat.subs(x=X, y=Y) # optional - sage.rings.finite_rings - sage: (Xm, Ym) == E.multiplication_by_m(5) # optional - sage.rings.finite_rings + sage: (X, Y) = phi.rational_maps() + sage: (Xhat, Yhat) = phi_hat.rational_maps() + sage: Xm = Xhat.subs(x=X, y=Y) + sage: Ym = Yhat.subs(x=X, y=Y) + sage: (Xm, Ym) == E.multiplication_by_m(5) True Inseparable duals should be computed correctly:: - sage: z2 = GF(71^2).gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=57*z2+51) # optional - sage.rings.finite_rings - sage: E.isogeny(3*E.lift_x(0)).dual() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: z2 = GF(71^2).gen() + sage: E = EllipticCurve(j=57*z2+51) + sage: E.isogeny(3*E.lift_x(0)).dual() Composite morphism of degree 71 = 71*1^2: From: Elliptic Curve defined by y^2 = x^3 + (32*z2+67)*x + (24*z2+37) over Finite Field in z2 of size 71^2 To: Elliptic Curve defined by y^2 = x^3 + (41*z2+56)*x + (18*z2+42) over Finite Field in z2 of size 71^2 - sage: E.isogeny(E.lift_x(0)).dual() # optional - sage.rings.finite_rings + sage: E.isogeny(E.lift_x(0)).dual() Composite morphism of degree 213 = 71*3: From: Elliptic Curve defined by y^2 = x^3 + (58*z2+31)*x + (34*z2+58) over Finite Field in z2 of size 71^2 @@ -3134,12 +3151,13 @@ def dual(self): ...even if pre- or post-isomorphisms are present:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: phi = E.isogeny(E.lift_x(0)) # optional - sage.rings.finite_rings - sage: pre = ~WeierstrassIsomorphism(phi.domain(), (z2,2,3,4)) # optional - sage.rings.finite_rings - sage: post = WeierstrassIsomorphism(phi.codomain(), (5,6,7,8)) # optional - sage.rings.finite_rings - sage: phi = post * phi * pre # optional - sage.rings.finite_rings - sage: phi.dual() # optional - sage.rings.finite_rings + sage: phi = E.isogeny(E.lift_x(0)) + sage: pre = ~WeierstrassIsomorphism(phi.domain(), (z2,2,3,4)) + sage: post = WeierstrassIsomorphism(phi.codomain(), (5,6,7,8)) + sage: phi = post * phi * pre + sage: phi.dual() Composite morphism of degree 213 = 71*3: From: Elliptic Curve defined by y^2 + 17*x*y + 45*y = x^3 + 30*x^2 + (6*z2+64)*x + (48*z2+65) @@ -3153,9 +3171,9 @@ def dual(self): Test for :trac:`23928`:: - sage: E = EllipticCurve(j=GF(431**2)(4)) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E.lift_x(0)) # optional - sage.rings.finite_rings - sage: phi.dual() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(431**2)(4)) # needs sage.rings.finite_rings + sage: phi = E.isogeny(E.lift_x(0)) # needs sage.rings.finite_rings + sage: phi.dual() # needs sage.rings.finite_rings Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 427*x over Finite Field in z2 of size 431^2 to Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 431^2 @@ -3167,34 +3185,35 @@ def dual(self): sage: phi.dual().dual() == phi True - sage: k = GF(103) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k,[11,11]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E(4,4)) # optional - sage.rings.finite_rings - sage: phi # optional - sage.rings.finite_rings + sage: k = GF(103) + sage: E = EllipticCurve(k,[11,11]) + sage: phi = E.isogeny(E(4,4)) + sage: phi Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 11*x + 11 over Finite Field of size 103 to Elliptic Curve defined by y^2 = x^3 + 25*x + 80 over Finite Field of size 103 sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: phi = WeierstrassIsomorphism(phi.codomain(),(5,0,1,2)) * phi # optional - sage.rings.finite_rings - sage: phi.dual().dual() == phi # optional - sage.rings.finite_rings + sage: phi = WeierstrassIsomorphism(phi.codomain(),(5,0,1,2)) * phi + sage: phi.dual().dual() == phi True - sage: E = EllipticCurve(GF(103),[1,0,0,1,-1]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E(60,85)) # optional - sage.rings.finite_rings - sage: phi.dual() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(103),[1,0,0,1,-1]) + sage: phi = E.isogeny(E(60,85)) + sage: phi.dual() Isogeny of degree 7 from Elliptic Curve defined by y^2 + x*y = x^3 + 84*x + 34 over Finite Field of size 103 to Elliptic Curve defined by y^2 + x*y = x^3 + x + 102 over Finite Field of size 103 Check that :trac:`17293` is fixed:: - sage: k. = QuadraticField(2) # optional - sage.rings.number_field - sage: E = EllipticCurve(k, [-3*s*(4 + 5*s), 2*s*(2 + 14*s + 11*s^2)]) # optional - sage.rings.number_field - sage: phi = E.isogenies_prime_degree(3)[0] # optional - sage.rings.number_field - sage: (-phi).dual() == -phi.dual() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: k. = QuadraticField(2) + sage: E = EllipticCurve(k, [-3*s*(4 + 5*s), 2*s*(2 + 14*s + 11*s^2)]) + sage: phi = E.isogenies_prime_degree(3)[0] + sage: (-phi).dual() == -phi.dual() True - sage: phi._EllipticCurveIsogeny__clear_cached_values() # forget the dual # optional - sage.rings.number_field - sage: -phi.dual() == (-phi).dual() # optional - sage.rings.number_field + sage: phi._EllipticCurveIsogeny__clear_cached_values() # forget the dual + sage: -phi.dual() == (-phi).dual() True """ if self.__base_field.characteristic() in (2, 3): @@ -3286,19 +3305,19 @@ def _composition_impl(left, right): EXAMPLES:: - sage: E = EllipticCurve(GF(127), [5,2]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E.lift_x(47)); E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: iso1 = E.change_weierstrass_model(1,1,1,1).isomorphism_to(E) # optional - sage.rings.finite_rings - sage: iso2 = E2.isomorphism_to(E2.change_weierstrass_model(39,0,0,0)) # optional - sage.rings.finite_rings - sage: phi * iso1 # indirect doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(127), [5,2]) + sage: phi = E.isogeny(E.lift_x(47)); E2 = phi.codomain() + sage: iso1 = E.change_weierstrass_model(1,1,1,1).isomorphism_to(E) + sage: iso2 = E2.isomorphism_to(E2.change_weierstrass_model(39,0,0,0)) + sage: phi * iso1 # indirect doctest Isogeny of degree 11 from Elliptic Curve defined by y^2 + 2*x*y + 2*y = x^3 + 2*x^2 + 6*x + 7 over Finite Field of size 127 to Elliptic Curve defined by y^2 = x^3 + 37*x + 85 over Finite Field of size 127 - sage: iso2 * phi # indirect doctest # optional - sage.rings.finite_rings + sage: iso2 * phi # indirect doctest Isogeny of degree 11 from Elliptic Curve defined by y^2 = x^3 + 5*x + 2 over Finite Field of size 127 to Elliptic Curve defined by y^2 = x^3 + 117*x + 58 over Finite Field of size 127 - sage: iso2 * phi * iso1 # indirect doctest # optional - sage.rings.finite_rings + sage: iso2 * phi * iso1 # indirect doctest Isogeny of degree 11 from Elliptic Curve defined by y^2 + 2*x*y + 2*y = x^3 + 2*x^2 + 6*x + 7 over Finite Field of size 127 to Elliptic Curve defined by y^2 = x^3 + 117*x + 58 over Finite Field of size 127 @@ -3308,7 +3327,7 @@ def _composition_impl(left, right): We should return ``NotImplemented`` when passed a combination of elliptic-curve morphism types that we don't handle here:: - sage: phi._composition_impl(iso1, iso1**-1) # optional - sage.rings.finite_rings + sage: phi._composition_impl(iso1, iso1**-1) NotImplemented """ if isinstance(left, WeierstrassIsomorphism) and isinstance(right, EllipticCurveIsogeny): @@ -3363,22 +3382,22 @@ def compute_isogeny_stark(E1, E2, ell): sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_isogeny_stark, compute_sequence_of_maps - sage: E = EllipticCurve(GF(97), [1,0,1,1,0]) # optional - sage.rings.finite_rings - sage: R. = GF(97)[]; f = x^5 + 27*x^4 + 61*x^3 + 58*x^2 + 28*x + 21 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: isom1, isom2, E1pr, E2pr, ker_poly = compute_sequence_of_maps(E, E2, 11) # optional - sage.rings.finite_rings - sage: compute_isogeny_stark(E1pr, E2pr, 11) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(97), [1,0,1,1,0]) + sage: R. = GF(97)[]; f = x^5 + 27*x^4 + 61*x^3 + 58*x^2 + 28*x + 21 + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: isom1, isom2, E1pr, E2pr, ker_poly = compute_sequence_of_maps(E, E2, 11) + sage: compute_isogeny_stark(E1pr, E2pr, 11) x^10 + 37*x^9 + 53*x^8 + 66*x^7 + 66*x^6 + 17*x^5 + 57*x^4 + 6*x^3 + 89*x^2 + 53*x + 8 - sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) # optional - sage.rings.finite_rings - sage: R. = GF(37)[] # optional - sage.rings.finite_rings - sage: f = (x + 14) * (x + 30) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: compute_isogeny_stark(E, E2, 5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) + sage: R. = GF(37)[] + sage: f = (x + 14) * (x + 30) + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: compute_isogeny_stark(E, E2, 5) x^4 + 14*x^3 + x^2 + 34*x + 21 - sage: f**2 # optional - sage.rings.finite_rings + sage: f**2 x^4 + 14*x^3 + x^2 + 34*x + 21 sage: E = EllipticCurve(QQ, [0,0,0,1,0]) @@ -3459,12 +3478,13 @@ def split_kernel_polynomial(poly): Check that this behaves identically to ``.radical()``:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import split_kernel_polynomial - sage: q = next_prime(randrange(3,10^3)) # optional - sage.rings.finite_rings - sage: e = randrange(1,5) # optional - sage.rings.finite_rings - sage: R = GF(q^e,'a')['x'] # optional - sage.rings.finite_rings - sage: f = R.random_element(randrange(10,100)).monic() # optional - sage.rings.finite_rings - sage: split_kernel_polynomial(f) == f.radical() # optional - sage.rings.finite_rings + sage: q = next_prime(randrange(3,10^3)) + sage: e = randrange(1,5) + sage: R = GF(q^e,'a')['x'] + sage: f = R.random_element(randrange(10,100)).monic() + sage: split_kernel_polynomial(f) == f.radical() doctest:warning ... DeprecationWarning: ... True @@ -3504,40 +3524,41 @@ def compute_isogeny_kernel_polynomial(E1, E2, ell, algorithm="stark"): sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_isogeny_kernel_polynomial - sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) # optional - sage.rings.finite_rings - sage: R. = GF(37)[] # optional - sage.rings.finite_rings - sage: f = (x + 14) * (x + 30) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: compute_isogeny_kernel_polynomial(E, E2, 5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) + sage: R. = GF(37)[] + sage: f = (x + 14) * (x + 30) + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: compute_isogeny_kernel_polynomial(E, E2, 5) x^2 + 7*x + 13 - sage: f # optional - sage.rings.finite_rings + sage: f x^2 + 7*x + 13 + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: E2 = EllipticCurve(K, [0,0,0,16,0]) # optional - sage.rings.number_field - sage: compute_isogeny_kernel_polynomial(E, E2, 4) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: E2 = EllipticCurve(K, [0,0,0,16,0]) + sage: compute_isogeny_kernel_polynomial(E, E2, 4) x^3 + x TESTS: Check that :meth:`Polynomial.radical` is doing the right thing for us:: - sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) # optional - sage.rings.finite_rings - sage: R. = GF(37)[] # optional - sage.rings.finite_rings - sage: f = (x + 10) * (x + 12) * (x + 16) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) + sage: R. = GF(37)[] + sage: f = (x + 10) * (x + 12) * (x + 16) + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_isogeny_stark - sage: ker_poly = compute_isogeny_stark(E, E2, 7); ker_poly # optional - sage.rings.finite_rings + sage: ker_poly = compute_isogeny_stark(E, E2, 7); ker_poly x^6 + 2*x^5 + 20*x^4 + 11*x^3 + 36*x^2 + 35*x + 16 - sage: ker_poly.factor() # optional - sage.rings.finite_rings + sage: ker_poly.factor() (x + 10)^2 * (x + 12)^2 * (x + 16)^2 - sage: poly = ker_poly.radical(); poly # optional - sage.rings.finite_rings + sage: poly = ker_poly.radical(); poly x^3 + x^2 + 28*x + 33 - sage: poly.factor() # optional - sage.rings.finite_rings + sage: poly.factor() (x + 10) * (x + 12) * (x + 16) """ if algorithm == 'starks': @@ -3585,11 +3606,11 @@ def compute_intermediate_curves(E1, E2): EXAMPLES:: sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_intermediate_curves - sage: E = EllipticCurve(GF(83), [1,0,1,1,0]) # optional - sage.rings.finite_rings - sage: R. = GF(83)[]; f = x + 24 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: compute_intermediate_curves(E, E2) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(83), [1,0,1,1,0]) + sage: R. = GF(83)[]; f = x + 24 + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: compute_intermediate_curves(E, E2) (Elliptic Curve defined by y^2 = x^3 + 62*x + 74 over Finite Field of size 83, Elliptic Curve defined by y^2 = x^3 + 65*x + 69 over Finite Field of size 83, Elliptic-curve morphism: @@ -3605,11 +3626,12 @@ def compute_intermediate_curves(E1, E2): over Finite Field of size 83 Via: (u,r,s,t) = (1, 7, 42, 42)) + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: E2 = EllipticCurve(K, [0,0,0,16,0]) # optional - sage.rings.number_field - sage: compute_intermediate_curves(E, E2) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: E2 = EllipticCurve(K, [0,0,0,16,0]) + sage: compute_intermediate_curves(E, E2) (Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1, Elliptic Curve defined by y^2 = x^3 + 16*x @@ -3696,10 +3718,11 @@ def compute_sequence_of_maps(E1, E2, ell): Elliptic Curve defined by y^2 = x^3 - 23461/3*x - 28748141/108 over Rational Field, x^2 - 61/3*x + 658/9) - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: E2 = EllipticCurve(K, [0,0,0,16,0]) # optional - sage.rings.number_field - sage: compute_sequence_of_maps(E, E2, 4) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: E2 = EllipticCurve(K, [0,0,0,16,0]) + sage: compute_sequence_of_maps(E, E2, 4) (Elliptic-curve endomorphism of Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 Via: (u,r,s,t) = (1, 0, 0, 0), @@ -3712,11 +3735,11 @@ def compute_sequence_of_maps(E1, E2, ell): over Number Field in i with defining polynomial x^2 + 1, x^3 + x) - sage: E = EllipticCurve(GF(97), [1,0,1,1,0]) # optional - sage.rings.finite_rings - sage: R. = GF(97)[]; f = x^5 + 27*x^4 + 61*x^3 + 58*x^2 + 28*x + 21 # optional - sage.rings.finite_rings - sage: phi = EllipticCurveIsogeny(E, f) # optional - sage.rings.finite_rings - sage: E2 = phi.codomain() # optional - sage.rings.finite_rings - sage: compute_sequence_of_maps(E, E2, 11) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(97), [1,0,1,1,0]) + sage: R. = GF(97)[]; f = x^5 + 27*x^4 + 61*x^3 + 58*x^2 + 28*x + 21 + sage: phi = EllipticCurveIsogeny(E, f) + sage: E2 = phi.codomain() + sage: compute_sequence_of_maps(E, E2, 11) (Elliptic-curve morphism: From: Elliptic Curve defined by y^2 + x*y + y = x^3 + x over Finite Field of size 97 diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py index 3c359e3de03..e793237b8bc 100644 --- a/src/sage/schemes/elliptic_curves/ell_field.py +++ b/src/sage/schemes/elliptic_curves/ell_field.py @@ -48,8 +48,8 @@ def genus(self): EXAMPLES:: - sage: E = EllipticCurve(GF(3), [0, -1, 0, -346, 2652]) # optional - sage.rings.finite_rings - sage: E.genus() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(3), [0, -1, 0, -346, 2652]) + sage: E.genus() 1 sage: R = FractionField(QQ['z']) @@ -98,52 +98,55 @@ def quadratic_twist(self, D=None): EXAMPLES:: - sage: E = EllipticCurve([GF(1103)(1), 0, 0, 107, 340]); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve([GF(1103)(1), 0, 0, 107, 340]); E Elliptic Curve defined by y^2 + x*y = x^3 + 107*x + 340 over Finite Field of size 1103 - sage: F = E.quadratic_twist(-1); F # optional - sage.rings.finite_rings + sage: F = E.quadratic_twist(-1); F Elliptic Curve defined by y^2 = x^3 + 1102*x^2 + 609*x + 300 over Finite Field of size 1103 - sage: E.is_isomorphic(F) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(F) False - sage: E.is_isomorphic(F, GF(1103^2,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(F, GF(1103^2,'a')) True A characteristic 2 example:: - sage: E = EllipticCurve(GF(2), [1,0,1,1,1]) # optional - sage.rings.finite_rings - sage: E1 = E.quadratic_twist(1) # optional - sage.rings.finite_rings - sage: E.is_isomorphic(E1) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(2), [1,0,1,1,1]) + sage: E1 = E.quadratic_twist(1) + sage: E.is_isomorphic(E1) False - sage: E.is_isomorphic(E1, GF(4,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(4,'a')) True Over finite fields, the twisting parameter may be omitted:: - sage: k. = GF(2^10) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [a^2,a,1,a+1,1]) # optional - sage.rings.finite_rings - sage: Et = E.quadratic_twist() # optional - sage.rings.finite_rings - sage: Et # random (only determined up to isomorphism) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF(2^10) + sage: E = EllipticCurve(k, [a^2,a,1,a+1,1]) + sage: Et = E.quadratic_twist() + sage: Et # random (only determined up to isomorphism) Elliptic Curve defined by y^2 + x*y = x^3 + (a^7+a^4+a^3+a^2+a+1)*x^2 + (a^8+a^6+a^4+1) over Finite Field in a of size 2^10 - sage: E.is_isomorphic(Et) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(Et) False - sage: E.j_invariant() == Et.j_invariant() # optional - sage.rings.finite_rings + sage: E.j_invariant() == Et.j_invariant() True - sage: p = next_prime(10^10) # optional - sage.rings.finite_rings - sage: k = GF(p) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: Et = E.quadratic_twist() # optional - sage.rings.finite_rings - sage: Et # random (only determined up to isomorphism) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: p = next_prime(10^10) + sage: k = GF(p) + sage: E = EllipticCurve(k, [1,2,3,4,5]) + sage: Et = E.quadratic_twist() + sage: Et # random (only determined up to isomorphism) Elliptic Curve defined by y^2 = x^3 + 7860088097*x^2 + 9495240877*x + 3048660957 over Finite Field of size 10000000019 - sage: E.is_isomorphic(Et) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(Et) False - sage: k2 = GF(p^2,'a') # optional - sage.rings.finite_rings - sage: E.change_ring(k2).is_isomorphic(Et.change_ring(k2)) # optional - sage.rings.finite_rings + sage: k2 = GF(p^2,'a') + sage: E.change_ring(k2).is_isomorphic(Et.change_ring(k2)) True """ K = self.base_ring() @@ -210,8 +213,8 @@ def two_torsion_rank(self): sage: E = EllipticCurve('11a1') sage: E.two_torsion_rank() 0 - sage: K. = QQ.extension(E.division_polynomial(2).monic()) # optional - sage.rings.number_field - sage: E.base_extend(K).two_torsion_rank() # optional - sage.rings.number_field + sage: K. = QQ.extension(E.division_polynomial(2).monic()) # needs sage.rings.number_field + sage: E.base_extend(K).two_torsion_rank() # needs sage.rings.number_field 1 sage: E.reduction(53).two_torsion_rank() 2 @@ -222,8 +225,8 @@ def two_torsion_rank(self): sage: E.two_torsion_rank() 1 sage: f = E.division_polynomial(2).monic().factor()[1][0] - sage: K. = QQ.extension(f) # optional - sage.rings.number_field - sage: E.base_extend(K).two_torsion_rank() # optional - sage.rings.number_field + sage: K. = QQ.extension(f) # needs sage.rings.number_field + sage: E.base_extend(K).two_torsion_rank() # needs sage.rings.number_field 2 :: @@ -249,15 +252,16 @@ def quartic_twist(self, D): EXAMPLES:: - sage: E = EllipticCurve_from_j(GF(13)(1728)); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(13)(1728)); E Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 13 - sage: E1 = E.quartic_twist(2); E1 # optional - sage.rings.finite_rings + sage: E1 = E.quartic_twist(2); E1 Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 13 - sage: E.is_isomorphic(E1) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1) False - sage: E.is_isomorphic(E1, GF(13^2,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(13^2,'a')) False - sage: E.is_isomorphic(E1, GF(13^4,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(13^4,'a')) True """ K = self.base_ring() @@ -292,17 +296,18 @@ def sextic_twist(self, D): EXAMPLES:: - sage: E = EllipticCurve_from_j(GF(13)(0)); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(13)(0)); E Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 13 - sage: E1 = E.sextic_twist(2); E1 # optional - sage.rings.finite_rings + sage: E1 = E.sextic_twist(2); E1 Elliptic Curve defined by y^2 = x^3 + 11 over Finite Field of size 13 - sage: E.is_isomorphic(E1) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1) False - sage: E.is_isomorphic(E1, GF(13^2,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(13^2,'a')) False - sage: E.is_isomorphic(E1, GF(13^4,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(13^4,'a')) False - sage: E.is_isomorphic(E1, GF(13^6,'a')) # optional - sage.rings.finite_rings + sage: E.is_isomorphic(E1, GF(13^6,'a')) True """ K = self.base_ring() @@ -329,7 +334,7 @@ def is_quadratic_twist(self, other): INPUT: - - ``other`` -- an elliptic curves with the same base field as self. + - ``other`` -- an elliptic curve with the same base field as ``self``. OUTPUT: @@ -360,7 +365,7 @@ def is_quadratic_twist(self, other): 2 sage: E1.is_quadratic_twist(E1) 1 - sage: type(E1.is_quadratic_twist(E1)) == type(E1.is_quadratic_twist(E2)) #trac 6574 + sage: type(E1.is_quadratic_twist(E1)) == type(E1.is_quadratic_twist(E2)) # Issue #6574 True :: @@ -377,40 +382,43 @@ def is_quadratic_twist(self, other): :: - sage: F = GF(101) # optional - sage.rings.finite_rings - sage: E1 = EllipticCurve(F, [4,7]) # optional - sage.rings.finite_rings - sage: E2 = E1.quadratic_twist() # optional - sage.rings.finite_rings - sage: D = E1.is_quadratic_twist(E2); D != 0 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(101) + sage: E1 = EllipticCurve(F, [4,7]) + sage: E2 = E1.quadratic_twist() + sage: D = E1.is_quadratic_twist(E2); D != 0 True - sage: F = GF(101) # optional - sage.rings.finite_rings - sage: E1 = EllipticCurve(F, [4,7]) # optional - sage.rings.finite_rings - sage: E2 = E1.quadratic_twist() # optional - sage.rings.finite_rings - sage: D = E1.is_quadratic_twist(E2) # optional - sage.rings.finite_rings - sage: E1.quadratic_twist(D).is_isomorphic(E2) # optional - sage.rings.finite_rings + sage: F = GF(101) + sage: E1 = EllipticCurve(F, [4,7]) + sage: E2 = E1.quadratic_twist() + sage: D = E1.is_quadratic_twist(E2) + sage: E1.quadratic_twist(D).is_isomorphic(E2) True - sage: E1.is_isomorphic(E2) # optional - sage.rings.finite_rings + sage: E1.is_isomorphic(E2) False - sage: F2 = GF(101^2,'a') # optional - sage.rings.finite_rings - sage: E1.change_ring(F2).is_isomorphic(E2.change_ring(F2)) # optional - sage.rings.finite_rings + sage: F2 = GF(101^2,'a') + sage: E1.change_ring(F2).is_isomorphic(E2.change_ring(F2)) True A characteristic 3 example:: - sage: F = GF(3^5,'a') # optional - sage.rings.finite_rings - sage: E1 = EllipticCurve_from_j(F(1)) # optional - sage.rings.finite_rings - sage: E2 = E1.quadratic_twist(-1) # optional - sage.rings.finite_rings - sage: D = E1.is_quadratic_twist(E2); D != 0 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(3^5,'a') + sage: E1 = EllipticCurve_from_j(F(1)) + sage: E2 = E1.quadratic_twist(-1) + sage: D = E1.is_quadratic_twist(E2); D != 0 True - sage: E1.quadratic_twist(D).is_isomorphic(E2) # optional - sage.rings.finite_rings + sage: E1.quadratic_twist(D).is_isomorphic(E2) True :: - sage: E1 = EllipticCurve_from_j(F(0)) # optional - sage.rings.finite_rings - sage: E2 = E1.quadratic_twist() # optional - sage.rings.finite_rings - sage: D = E1.is_quadratic_twist(E2); D # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E1 = EllipticCurve_from_j(F(0)) + sage: E2 = E1.quadratic_twist() + sage: D = E1.is_quadratic_twist(E2); D 1 - sage: E1.is_isomorphic(E2) # optional - sage.rings.finite_rings + sage: E1.is_isomorphic(E2) True """ from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve @@ -496,11 +504,11 @@ def is_quartic_twist(self, other): EXAMPLES:: - sage: E = EllipticCurve_from_j(GF(13)(1728)) # optional - sage.rings.finite_rings - sage: E1 = E.quartic_twist(2) # optional - sage.rings.finite_rings - sage: D = E.is_quartic_twist(E1); D!=0 # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(13)(1728)) + sage: E1 = E.quartic_twist(2) + sage: D = E.is_quartic_twist(E1); D!=0 True - sage: E.quartic_twist(D).is_isomorphic(E1) # optional - sage.rings.finite_rings + sage: E.quartic_twist(D).is_isomorphic(E1) True :: @@ -565,11 +573,11 @@ def is_sextic_twist(self, other): EXAMPLES:: - sage: E = EllipticCurve_from_j(GF(13)(0)) # optional - sage.rings.finite_rings - sage: E1 = E.sextic_twist(2) # optional - sage.rings.finite_rings - sage: D = E.is_sextic_twist(E1); D != 0 # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(13)(0)) + sage: E1 = E.sextic_twist(2) + sage: D = E.is_sextic_twist(E1); D != 0 True - sage: E.sextic_twist(D).is_isomorphic(E1) # optional - sage.rings.finite_rings + sage: E.sextic_twist(D).is_isomorphic(E1) True :: @@ -650,51 +658,54 @@ def descend_to(self, K, f=None): :: - sage: F. = QuadraticField(23) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: F. = QuadraticField(23) sage: x = polygen(ZZ, 'x') - sage: G. = F.extension(x^3 + 5) # optional - sage.rings.number_field - sage: E = EllipticCurve(j=1728*b).change_ring(G) # optional - sage.rings.number_field - sage: EF = E.descend_to(F); EF # optional - sage.rings.number_field + sage: G. = F.extension(x^3 + 5) + sage: E = EllipticCurve(j=1728*b).change_ring(G) + sage: EF = E.descend_to(F); EF [Elliptic Curve defined by y^2 = x^3 + (27*b-621)*x + (-1296*b+2484) over Number Field in b with defining polynomial x^2 - 23 with b = 4.795831523312720?] - sage: all(Ei.change_ring(G).is_isomorphic(E) for Ei in EF) # optional - sage.rings.number_field + sage: all(Ei.change_ring(G).is_isomorphic(E) for Ei in EF) True :: - sage: L. = NumberField(x^4 - 7) # optional - sage.rings.number_field - sage: K. = NumberField(x^2 - 7, embedding=a^2) # optional - sage.rings.number_field - sage: E = EllipticCurve([a^6, 0]) # optional - sage.rings.number_field - sage: EK = E.descend_to(K); EK # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: L. = NumberField(x^4 - 7) + sage: K. = NumberField(x^2 - 7, embedding=a^2) + sage: E = EllipticCurve([a^6, 0]) + sage: EK = E.descend_to(K); EK [Elliptic Curve defined by y^2 = x^3 + b*x over Number Field in b with defining polynomial x^2 - 7 with b = a^2, Elliptic Curve defined by y^2 = x^3 + 7*b*x over Number Field in b with defining polynomial x^2 - 7 with b = a^2] - sage: all(Ei.change_ring(L).is_isomorphic(E) for Ei in EK) # optional - sage.rings.number_field + sage: all(Ei.change_ring(L).is_isomorphic(E) for Ei in EK) True :: - sage: K. = QuadraticField(17) # optional - sage.rings.number_field - sage: E = EllipticCurve(j=2*a) # optional - sage.rings.number_field - sage: E.descend_to(QQ) # optional - sage.rings.number_field + sage: K. = QuadraticField(17) # needs sage.rings.number_field + sage: E = EllipticCurve(j=2*a) # needs sage.rings.number_field + sage: E.descend_to(QQ) # needs sage.rings.number_field [] TESTS: Check that :trac:`16456` is fixed:: - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve('11a1').quadratic_twist(2) # optional - sage.rings.number_field - sage: EK = E.change_ring(K) # optional - sage.rings.number_field - sage: EK2 = EK.change_weierstrass_model((a,a,a,a+1)) # optional - sage.rings.number_field - sage: EK2.descend_to(QQ) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve('11a1').quadratic_twist(2) + sage: EK = E.change_ring(K) + sage: EK2 = EK.change_weierstrass_model((a,a,a,a+1)) + sage: EK2.descend_to(QQ) [Elliptic Curve defined by y^2 = x^3 + x^2 - 41*x - 199 over Rational Field] - sage: k. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(k,[0,0,0,1,0]) # optional - sage.rings.number_field - sage: E.descend_to(QQ) # optional - sage.rings.number_field + sage: k. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve(k,[0,0,0,1,0]) # needs sage.rings.number_field + sage: E.descend_to(QQ) # needs sage.rings.number_field [Elliptic Curve defined by y^2 = x^3 + x over Rational Field, Elliptic Curve defined by y^2 = x^3 - 4*x over Rational Field] """ @@ -819,17 +830,18 @@ def division_field(self, l, names='t', map=False, **kwds): The 2-division field is the same as the splitting field of the 2-division polynomial (therefore, it has degree 1, 2, 3 or 6):: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('15a1') - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x sage: E = EllipticCurve('14a1') - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x^2 + 5*x + 92 sage: E = EllipticCurve('196b1') - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x^3 + x^2 - 114*x - 127 sage: E = EllipticCurve('19a1') - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x^6 + 10*x^5 + 24*x^4 - 212*x^3 + 1364*x^2 + 24072*x + 104292 @@ -837,11 +849,12 @@ def division_field(self, l, names='t', map=False, **kwds): field of the `\ell`-division polynomial, or a quadratic extension of it. :: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('50a1') - sage: F. = E.division_polynomial(3).splitting_field(simplify_all=True); F # optional - sage.rings.number_field + sage: F. = E.division_polynomial(3).splitting_field(simplify_all=True); F Number Field in a with defining polynomial x^6 - 3*x^5 + 4*x^4 - 3*x^3 - 2*x^2 + 3*x + 3 - sage: K. = E.division_field(3, simplify_all=True); K # optional - sage.rings.number_field + sage: K. = E.division_field(3, simplify_all=True); K Number Field in b with defining polynomial x^6 - 3*x^5 + 4*x^4 - 3*x^3 - 2*x^2 + 3*x + 3 @@ -849,75 +862,80 @@ def division_field(self, l, names='t', map=False, **kwds): 3-division polynomial remains the same, but the 3-division field becomes a quadratic extension:: - sage: E = E.quadratic_twist(5) # 50b3 # optional - sage.rings.number_field - sage: F. = E.division_polynomial(3).splitting_field(simplify_all=True); F # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = E.quadratic_twist(5) # 50b3 + sage: F. = E.division_polynomial(3).splitting_field(simplify_all=True); F Number Field in a with defining polynomial x^6 - 3*x^5 + 4*x^4 - 3*x^3 - 2*x^2 + 3*x + 3 - sage: K. = E.division_field(3, simplify_all=True); K # optional - sage.rings.number_field + sage: K. = E.division_field(3, simplify_all=True); K Number Field in b with defining polynomial x^12 - 3*x^11 + 8*x^10 - 15*x^9 + 30*x^8 - 63*x^7 + 109*x^6 - 144*x^5 + 150*x^4 - 120*x^3 + 68*x^2 - 24*x + 4 Try another quadratic twist, this time over a subfield of `F`:: - sage: G.,_,_ = F.subfields(3)[0] # optional - sage.rings.number_field - sage: E = E.base_extend(G).quadratic_twist(c); E # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: G.,_,_ = F.subfields(3)[0] + sage: E = E.base_extend(G).quadratic_twist(c); E Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9 - sage: K. = E.division_field(3, simplify_all=True); K # optional - sage.rings.number_field + sage: K. = E.division_field(3, simplify_all=True); K Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025 Some higher-degree examples:: - sage: E = EllipticCurve('11a1') # optional - sage.rings.number_field - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve('11a1') + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x^6 + 2*x^5 - 48*x^4 - 436*x^3 + 1668*x^2 + 28792*x + 73844 - sage: K. = E.division_field(3); K # long time (3s on sage.math, 2014) # optional - sage.rings.number_field + sage: K. = E.division_field(3); K # long time Number Field in b with defining polynomial x^48 ... - sage: K. = E.division_field(5); K # optional - sage.rings.number_field + sage: K. = E.division_field(5); K Number Field in b with defining polynomial x^4 - x^3 + x^2 - x + 1 - sage: E.division_field(5, 'b', simplify=False) # optional - sage.rings.number_field + sage: E.division_field(5, 'b', simplify=False) Number Field in b with defining polynomial x^4 + x^3 + 11*x^2 + 41*x + 101 - sage: E.base_extend(K).torsion_subgroup() # long time (2s on sage.math, 2014) # optional - sage.rings.number_field + sage: E.base_extend(K).torsion_subgroup() # long time Torsion Subgroup isomorphic to Z/5 + Z/5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in b with defining polynomial x^4 - x^3 + x^2 - x + 1 - sage: E = EllipticCurve('27a1') # optional - sage.rings.number_field - sage: K. = E.division_field(3); K # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve('27a1') + sage: K. = E.division_field(3); K Number Field in b with defining polynomial x^2 + 3*x + 9 - sage: K. = E.division_field(2); K # optional - sage.rings.number_field + sage: K. = E.division_field(2); K Number Field in b with defining polynomial x^6 + 6*x^5 + 24*x^4 - 52*x^3 - 228*x^2 + 744*x + 3844 - sage: K. = E.division_field(2, simplify_all=True); K # optional - sage.rings.number_field + sage: K. = E.division_field(2, simplify_all=True); K Number Field in b with defining polynomial x^6 - 3*x^5 + 5*x^3 - 3*x + 1 - sage: K. = E.division_field(5); K # long time (4s on sage.math, 2014) # optional - sage.rings.number_field + sage: K. = E.division_field(5); K # long time Number Field in b with defining polynomial x^48 ... - sage: K. = E.division_field(7); K # long time (8s on sage.math, 2014) # optional - sage.rings.number_field + sage: K. = E.division_field(7); K # long time Number Field in b with defining polynomial x^72 ... Over a number field:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,i]) # optional - sage.rings.number_field - sage: L. = E.division_field(2); L # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve([0,0,0,0,i]) + sage: L. = E.division_field(2); L Number Field in b with defining polynomial x^4 - x^2 + 1 - sage: L., phi = E.division_field(2, map=True); phi # optional - sage.rings.number_field + sage: L., phi = E.division_field(2, map=True); phi Ring morphism: From: Number Field in i with defining polynomial x^2 + 1 To: Number Field in b with defining polynomial x^4 - x^2 + 1 Defn: i |--> -b^3 - sage: L., phi = E.division_field(3, map=True) # optional - sage.rings.number_field - sage: L # optional - sage.rings.number_field + sage: L., phi = E.division_field(3, map=True) + sage: L Number Field in b with defining polynomial x^24 - 6*x^22 - 12*x^21 - 21*x^20 + 216*x^19 + 48*x^18 + 804*x^17 + 1194*x^16 - 13488*x^15 + 21222*x^14 + 44196*x^13 - 47977*x^12 - 102888*x^11 + 173424*x^10 - 172308*x^9 + 302046*x^8 + 252864*x^7 - 931182*x^6 + 180300*x^5 + 879567*x^4 - 415896*x^3 + 1941012*x^2 + 650220*x + 443089 - sage: phi # optional - sage.rings.number_field + sage: phi Ring morphism: From: Number Field in i with defining polynomial x^2 + 1 To: Number Field in b with defining polynomial x^24 ... @@ -925,8 +943,8 @@ def division_field(self, l, names='t', map=False, **kwds): Over a finite field:: - sage: E = EllipticCurve(GF(431^2), [1,0]) # optional - sage.rings.finite_rings - sage: E.division_field(5, map=True) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(431^2), [1,0]) # needs sage.rings.finite_rings + sage: E.division_field(5, map=True) # needs sage.rings.finite_rings (Finite Field in t of size 431^4, Ring morphism: From: Finite Field in z2 of size 431^2 @@ -935,8 +953,8 @@ def division_field(self, l, names='t', map=False, **kwds): :: - sage: E = EllipticCurve(GF(433^2), [1,0]) # optional - sage.rings.finite_rings - sage: K. = E.division_field(7); K # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(433^2), [1,0]) # needs sage.rings.finite_rings + sage: K. = E.division_field(7); K # needs sage.rings.finite_rings Finite Field in v of size 433^16 .. SEEALSO:: @@ -951,6 +969,7 @@ def division_field(self, l, names='t', map=False, **kwds): Some random testing:: + sage: # needs sage.rings.finite_rings sage: def check(E, l, K): ....: EE = E.change_ring(K) ....: cof = EE.order().prime_to_m_part(l) @@ -974,20 +993,20 @@ def division_field(self, l, names='t', map=False, **kwds): ....: assert False ....: deg = lcm(el.minpoly().degree() for el in sum(map(list,Ps),[])) ....: assert max(deg, E.base_field().degree()) == K.degree() - sage: q = next_prime_power(randrange(1, 10^9)) # optional - sage.rings.finite_rings - sage: F. = GF(q) # optional - sage.rings.finite_rings - sage: while True: # optional - sage.rings.finite_rings + sage: q = next_prime_power(randrange(1, 10^9)) + sage: F. = GF(q) + sage: while True: ....: try: ....: E = EllipticCurve([F.random_element() for _ in range(5)]) ....: except ArithmeticError: ....: continue ....: break - sage: l = random_prime(8) # optional - sage.rings.finite_rings - sage: K = E.division_field(l) # optional - sage.rings.finite_rings - sage: n = E.cardinality(extension_degree=K.degree()//F.degree()) # optional - sage.rings.finite_rings - sage: (l^2 if q%l else 0 + E.is_ordinary()).divides(n) # optional - sage.rings.finite_rings + sage: l = random_prime(8) + sage: K = E.division_field(l) + sage: n = E.cardinality(extension_degree=K.degree()//F.degree()) + sage: (l^2 if q%l else 0 + E.is_ordinary()).divides(n) True - sage: check(E, l, K) # long time # optional - sage.rings.finite_rings + sage: check(E, l, K) # long time AUTHORS: @@ -1161,11 +1180,12 @@ def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True, al EXAMPLES:: - sage: F = GF(2^5, 'alpha'); alpha = F.gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,0,1,1,1]) # optional - sage.rings.finite_rings - sage: R. = F[] # optional - sage.rings.finite_rings - sage: phi = E.isogeny(x + 1) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(2^5, 'alpha'); alpha = F.gen() + sage: E = EllipticCurve(F, [1,0,1,1,1]) + sage: R. = F[] + sage: phi = E.isogeny(x + 1) + sage: phi.rational_maps() ((x^2 + x + 1)/(x + 1), (x^2*y + x)/(x^2 + 1)) :: @@ -1181,22 +1201,22 @@ def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True, al :: - sage: E = EllipticCurve(GF(19),[1,1]) # optional - sage.rings.finite_rings - sage: P = E(15,3); Q = E(2,12) # optional - sage.rings.finite_rings - sage: (P.order(), Q.order()) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19),[1,1]) + sage: P = E(15,3); Q = E(2,12) + sage: (P.order(), Q.order()) (7, 3) - sage: phi = E.isogeny([P,Q]); phi # optional - sage.rings.finite_rings + sage: phi = E.isogeny([P,Q]); phi Isogeny of degree 21 from Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 19 to Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 19 - sage: phi(E.random_point()) # all points defined over GF(19) are in the kernel # optional - sage.rings.finite_rings + sage: phi(E.random_point()) # all points defined over GF(19) are in the kernel (0 : 1 : 0) :: - sage: E = EllipticCurve(GF(2^32 - 5), [170246996, 2036646110]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(2) # optional - sage.rings.finite_rings - sage: E.isogeny(P, algorithm="factored") # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(2^32 - 5), [170246996, 2036646110]) # needs sage.rings.finite_rings + sage: P = E.lift_x(2) # needs sage.rings.finite_rings + sage: E.isogeny(P, algorithm="factored") # needs sage.rings.finite_rings Composite morphism of degree 1073721825 = 3^4*5^2*11*19*43*59: From: Elliptic Curve defined by y^2 = x^3 + 170246996*x + 2036646110 over Finite Field of size 4294967291 @@ -1205,8 +1225,8 @@ def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True, al Not all polynomials define a finite subgroup (:trac:`6384`):: - sage: E = EllipticCurve(GF(31), [1,0,0,1,2]) # optional - sage.rings.finite_rings - sage: phi = E.isogeny([14,27,4,1]) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31), [1,0,0,1,2]) + sage: phi = E.isogeny([14,27,4,1]) Traceback (most recent call last): ... ValueError: the polynomial x^3 + 4*x^2 + 27*x + 14 does not define a finite @@ -1225,11 +1245,12 @@ def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True, al :trac:`23222`, the following raised no error but returned an invalid morphism. See also :trac:`11578`:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 - x - 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [-13392, -1080432]) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: phi = E.isogeny( (x-564)*(x - 396/5*a + 348/5) ) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 1) + sage: E = EllipticCurve(K, [-13392, -1080432]) + sage: R. = K[] + sage: phi = E.isogeny( (x-564)*(x - 396/5*a + 348/5) ) Traceback (most recent call last): ... ValueError: the polynomial x^2 + (-396/5*a - 2472/5)*x + 223344/5*a - 196272/5 does not @@ -1238,10 +1259,11 @@ def isogeny(self, kernel, codomain=None, degree=None, model=None, check=True, al We check that the cached order is correctly copied over:: - sage: E = EllipticCurve(GF(2^127-1), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: E.set_order(170141183460469231746191640949390434666) # optional - sage.rings.finite_rings - sage: phi = E.isogeny(E.lift_x(77347718128277853096420969229987528666)) # optional - sage.rings.finite_rings - sage: phi.codomain()._order # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(2^127 - 1), [1,2,3,4,5]) + sage: E.set_order(170141183460469231746191640949390434666) + sage: phi = E.isogeny(E.lift_x(77347718128277853096420969229987528666)) + sage: phi.codomain()._order 170141183460469231746191640949390434666 """ if algorithm is not None and degree is not None: @@ -1283,15 +1305,16 @@ def isogeny_codomain(self, kernel, degree=None): We check that the cached order is correctly copied over:: - sage: E = EllipticCurve(GF(2^127 - 1), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: E.set_order(170141183460469231746191640949390434666) # optional - sage.rings.finite_rings - sage: E2 = E.isogeny_codomain(E.lift_x(77347718128277853096420969229987528666)) # optional - sage.rings.finite_rings - sage: E2._order # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(2^127 - 1), [1,2,3,4,5]) + sage: E.set_order(170141183460469231746191640949390434666) + sage: E2 = E.isogeny_codomain(E.lift_x(77347718128277853096420969229987528666)) + sage: E2._order 170141183460469231746191640949390434666 Test deprecation warning for obsolete argument:: - sage: E.isogeny_codomain(E.lift_x(77347718128277853096420969229987528666), degree=11) # optional - sage.rings.finite_rings + sage: E.isogeny_codomain(E.lift_x(77347718128277853096420969229987528666), degree=11) # needs sage.rings.finite_rings doctest:warning ... DeprecationWarning: The "degree" argument to .isogeny_codomain() does nothing and will be removed. @@ -1336,8 +1359,9 @@ def isogenies_prime_degree(self, l=None, max_l=31): Examples over finite fields:: - sage: E = EllipticCurve(GF(next_prime(1000000)), [7,8]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(2) # optional - sage.rings.finite_rings + sage: # needs sage.libs.pari + sage: E = EllipticCurve(GF(next_prime(1000000)), [7,8]) + sage: E.isogenies_prime_degree(2) [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, @@ -1347,22 +1371,22 @@ def isogenies_prime_degree(self, l=None, max_l=31): Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 999960*x + 78 over Finite Field of size 1000003] - sage: E.isogenies_prime_degree(3) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(3) [] - sage: E.isogenies_prime_degree(5) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(5) [] - sage: E.isogenies_prime_degree(7) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(7) [] - sage: E.isogenies_prime_degree(11) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(11) [] - sage: E.isogenies_prime_degree(13) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(13) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 878063*x + 845666 over Finite Field of size 1000003, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 375648*x + 342776 over Finite Field of size 1000003] - sage: E.isogenies_prime_degree(max_l=13) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(max_l=13) [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, @@ -1378,7 +1402,7 @@ def isogenies_prime_degree(self, l=None, max_l=31): Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 375648*x + 342776 over Finite Field of size 1000003] - sage: E.isogenies_prime_degree() # Default limit of 31 # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree() # Default limit of 31 [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 970389*x + 794257 over Finite Field of size 1000003, @@ -1404,10 +1428,10 @@ def isogenies_prime_degree(self, l=None, max_l=31): from Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 1000003 to Elliptic Curve defined by y^2 = x^3 + 390065*x + 605596 over Finite Field of size 1000003] - sage: E = EllipticCurve(GF(17), [2,0]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(3) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [2,0]) + sage: E.isogenies_prime_degree(3) [] - sage: E.isogenies_prime_degree(2) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(2) [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 17 to Elliptic Curve defined by y^2 = x^3 + 9*x over Finite Field of size 17, @@ -1421,16 +1445,18 @@ def isogenies_prime_degree(self, l=None, max_l=31): The base field matters, over a field extension we find more isogenies:: - sage: E = EllipticCurve(GF(13), [2,8]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(max_l=3) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13), [2,8]) + sage: E.isogenies_prime_degree(max_l=3) [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 7*x + 4 over Finite Field of size 13, Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 9*x + 11 over Finite Field of size 13] - sage: E = EllipticCurve(GF(13^6), [2,8]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(max_l=3) # optional - sage.rings.finite_rings + + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(13^6), [2,8]) + sage: E.isogenies_prime_degree(max_l=3) [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field in z6 of size 13^6 to Elliptic Curve defined by y^2 = x^3 + 7*x + 4 over Finite Field in z6 of size 13^6, @@ -1456,19 +1482,21 @@ def isogenies_prime_degree(self, l=None, max_l=31): If the degree equals the characteristic, we find only separable isogenies:: - sage: E = EllipticCurve(GF(13), [2,8]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(13) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13), [2,8]) + sage: E.isogenies_prime_degree(13) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 2*x + 8 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 6*x + 5 over Finite Field of size 13] - sage: E = EllipticCurve(GF(5), [1,1]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(5), [1,1]) + sage: E.isogenies_prime_degree(5) [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 5 to Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 5] - sage: k. = GF(3^4) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [0,1,0,0,a]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(3) # optional - sage.rings.finite_rings + + sage: # needs sage.rings.finite_rings + sage: k. = GF(3^4) + sage: E = EllipticCurve(k, [0,1,0,0,a]) + sage: E.isogenies_prime_degree(3) [Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + x^2 + a over Finite Field in a of size 3^4 @@ -1478,16 +1506,16 @@ def isogenies_prime_degree(self, l=None, max_l=31): In the supersingular case, there are no separable isogenies of degree equal to the characteristic:: - sage: E = EllipticCurve(GF(5), [0,1]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(5), [0,1]) + sage: E.isogenies_prime_degree(5) [] An example over a rational function field:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: K = R.fraction_field() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [1, t^5]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(5) # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: K = R.fraction_field() + sage: E = EllipticCurve(K, [1, t^5]) + sage: E.isogenies_prime_degree(5) [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x + t^5 over Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 5 @@ -1496,10 +1524,11 @@ def isogenies_prime_degree(self, l=None, max_l=31): Examples over number fields (other than QQ):: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: QQroot2. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve(QQroot2, j=8000) # optional - sage.rings.number_field - sage: E.isogenies_prime_degree() # optional - sage.rings.number_field + sage: QQroot2. = NumberField(x^2 - 2) + sage: E = EllipticCurve(QQroot2, j=8000) + sage: E.isogenies_prime_degree() [Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + (-150528000)*x + (-629407744000) over Number Field in e with defining polynomial x^2 - 2 @@ -1515,17 +1544,16 @@ def isogenies_prime_degree(self, l=None, max_l=31): over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 = x^3 + (-220500*e-257250)*x + (-54022500*e-88837000) over Number Field in e with defining polynomial x^2 - 2] - - sage: E = EllipticCurve(QQroot2, [1,0,1,4, -6]); E # optional - sage.rings.number_field + sage: E = EllipticCurve(QQroot2, [1,0,1,4, -6]); E Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 - sage: E.isogenies_prime_degree(2) # optional - sage.rings.number_field + sage: E.isogenies_prime_degree(2) [Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 to Elliptic Curve defined by y^2 + x*y + y = x^3 + (-36)*x + (-70) over Number Field in e with defining polynomial x^2 - 2] - sage: E.isogenies_prime_degree(3) # optional - sage.rings.number_field + sage: E.isogenies_prime_degree(3) [Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + (-6) over Number Field in e with defining polynomial x^2 - 2 @@ -1539,9 +1567,9 @@ def isogenies_prime_degree(self, l=None, max_l=31): These are not implemented yet:: - sage: E = EllipticCurve(QQbar, [1,18]); E # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [1,18]); E # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + x + 18 over Algebraic Field - sage: E.isogenies_prime_degree() # optional - sage.rings.number_field + sage: E.isogenies_prime_degree() # needs sage.rings.number_field Traceback (most recent call last): ... NotImplementedError: This code could be implemented for QQbar, but has not been yet. @@ -1721,18 +1749,19 @@ def hasse_invariant(self): Some examples over larger fields:: - sage: EllipticCurve(GF(101), [0,0,0,0,1]).hasse_invariant() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: EllipticCurve(GF(101), [0,0,0,0,1]).hasse_invariant() 0 - sage: EllipticCurve(GF(101), [0,0,0,1,1]).hasse_invariant() # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(101), [0,0,0,1,1]).hasse_invariant() 98 - sage: EllipticCurve(GF(103), [0,0,0,0,1]).hasse_invariant() # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(103), [0,0,0,0,1]).hasse_invariant() 20 - sage: EllipticCurve(GF(103), [0,0,0,1,1]).hasse_invariant() # optional - sage.rings.finite_rings + sage: EllipticCurve(GF(103), [0,0,0,1,1]).hasse_invariant() 17 - sage: F. = GF(107^2) # optional - sage.rings.finite_rings - sage: EllipticCurve(F, [0,0,0,a,1]).hasse_invariant() # optional - sage.rings.finite_rings + sage: F. = GF(107^2) + sage: EllipticCurve(F, [0,0,0,a,1]).hasse_invariant() 62*a + 75 - sage: EllipticCurve(F, [0,0,0,0,a]).hasse_invariant() # optional - sage.rings.finite_rings + sage: EllipticCurve(F, [0,0,0,0,a]).hasse_invariant() 0 Over fields of characteristic zero, the Hasse invariant is @@ -1792,17 +1821,17 @@ class of curves. If the j-invariant is not unique in the isogeny Ordinary curve over finite extension field of degree 2:: + sage: # needs sage.graphs sage.rings.finite_rings sage: x = polygen(ZZ, 'x') - sage: E = EllipticCurve(GF(59^2, "i", x^2 + 1), j=5) # optional - sage.rings.finite_rings - sage: G = E.isogeny_ell_graph(5, directed=False, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: G # optional - sage.graphs sage.rings.finite_rings + sage: E = EllipticCurve(GF(59^2, "i", x^2 + 1), j=5) + sage: G = E.isogeny_ell_graph(5, directed=False, label_by_j=True); G Graph on 20 vertices - sage: G.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G.vertices(sort=True) ['1', '12', ... 'i + 55'] - sage: G.edges(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G.edges(sort=True) [('1', '28*i + 11', None), ('1', '31*i + 11', None), ... @@ -1810,26 +1839,25 @@ class of curves. If the j-invariant is not unique in the isogeny Supersingular curve over prime field:: - sage: E = EllipticCurve(GF(419), j=1728) # optional - sage.rings.finite_rings - sage: G3 = E.isogeny_ell_graph(3, directed=False, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: G3 # optional - sage.graphs sage.rings.finite_rings + sage: # needs sage.graphs sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), j=1728) + sage: G3 = E.isogeny_ell_graph(3, directed=False, label_by_j=True); G3 Graph on 27 vertices - sage: G3.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G3.vertices(sort=True) ['0', '0*', ... '98*'] - sage: G3.edges(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G3.edges(sort=True) [('0', '0*', None), ('0', '13', None), ... ('48*', '98*', None)] - sage: G5 = E.isogeny_ell_graph(5, directed=False, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: G5 # optional - sage.graphs sage.rings.finite_rings + sage: G5 = E.isogeny_ell_graph(5, directed=False, label_by_j=True); G5 Graph on 9 vertices - sage: G5.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G5.vertices(sort=True) ['13', '13*', '407', '407*', '52', '62', '62*', '98', '98*'] - sage: G5.edges(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G5.edges(sort=True) [('13', '52', None), ('13', '98', None), ... @@ -1837,32 +1865,31 @@ class of curves. If the j-invariant is not unique in the isogeny Supersingular curve over finite extension field of degree 2:: - sage: K = GF(431^2, "i", x^2 + 1) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, j=0) # optional - sage.rings.finite_rings - sage: E.is_supersingular() # optional - sage.rings.finite_rings + sage: # needs sage.graphs sage.rings.finite_rings + sage: K = GF(431^2, "i", x^2 + 1) + sage: E = EllipticCurve(K, j=0) + sage: E.is_supersingular() True - sage: G = E.isogeny_ell_graph(2, directed=True, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: G # optional - sage.graphs sage.rings.finite_rings + sage: G = E.isogeny_ell_graph(2, directed=True, label_by_j=True); G Looped multi-digraph on 37 vertices - sage: G.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G.vertices(sort=True) ['0', '102', ... '87*i + 190'] - sage: G.edges(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G.edges(sort=True) [('0', '125', None), ('0', '125', None), ... '81*i + 65', None)] - sage: H = E.isogeny_ell_graph(2, directed=False, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: H # optional - sage.graphs sage.rings.finite_rings + sage: H = E.isogeny_ell_graph(2, directed=False, label_by_j=True); H Looped multi-graph on 37 vertices - sage: H.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: H.vertices(sort=True) ['0', '102', ... '87*i + 190'] - sage: H.edges(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: H.edges(sort=True) [('0', '125', None), ('102', '125', None), ... @@ -1870,27 +1897,28 @@ class of curves. If the j-invariant is not unique in the isogeny Curve over a quadratic number field:: - sage: K. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [1, 0, 1, 4, -6]) # optional - sage.rings.number_field - sage: G2 = E.isogeny_ell_graph(2, directed=False) # optional - sage.graphs sage.rings.number_field - sage: G2.vertices(sort=True) # optional - sage.graphs sage.rings.number_field + sage: # needs sage.graphs sage.rings.finite_rings sage.rings.number_field + sage: K. = NumberField(x^2 - 2) + sage: E = EllipticCurve(K, [1, 0, 1, 4, -6]) + sage: G2 = E.isogeny_ell_graph(2, directed=False) + sage: G2.vertices(sort=True) ['y^2 + x*y + y = x^3 + (-130*e-356)*x + (-2000*e-2038)', 'y^2 + x*y + y = x^3 + (-36)*x + (-70)', 'y^2 + x*y + y = x^3 + (130*e-356)*x + (2000*e-2038)', 'y^2 + x*y + y = x^3 + 4*x + (-6)'] - sage: G2.edges(sort=True) # optional - sage.graphs sage.rings.number_field + sage: G2.edges(sort=True) [('y^2 + x*y + y = x^3 + (-130*e-356)*x + (-2000*e-2038)', 'y^2 + x*y + y = x^3 + (-36)*x + (-70)', None), ('y^2 + x*y + y = x^3 + (-36)*x + (-70)', 'y^2 + x*y + y = x^3 + (130*e-356)*x + (2000*e-2038)', None), ('y^2 + x*y + y = x^3 + (-36)*x + (-70)', 'y^2 + x*y + y = x^3 + 4*x + (-6)', None)] - sage: G3 = E.isogeny_ell_graph(3, directed=False) # optional - sage.graphs sage.rings.number_field - sage: G3.vertices(sort=True) # optional - sage.graphs sage.rings.number_field + sage: G3 = E.isogeny_ell_graph(3, directed=False) + sage: G3.vertices(sort=True) ['y^2 + x*y + y = x^3 + (-1)*x', 'y^2 + x*y + y = x^3 + (-171)*x + (-874)', 'y^2 + x*y + y = x^3 + 4*x + (-6)'] - sage: G3.edges(sort=True) # optional - sage.graphs sage.rings.number_field + sage: G3.edges(sort=True) [('y^2 + x*y + y = x^3 + (-1)*x', 'y^2 + x*y + y = x^3 + 4*x + (-6)', None), ('y^2 + x*y + y = x^3 + (-171)*x + (-874)', @@ -1898,21 +1926,21 @@ class of curves. If the j-invariant is not unique in the isogeny TESTS:: - sage: E = EllipticCurve(GF(11), j=0) # optional - sage.rings.finite_rings - sage: G0 = E.isogeny_ell_graph(2, directed=False) # optional - sage.graphs sage.rings.finite_rings - sage: G0.is_directed() # optional - sage.graphs sage.rings.finite_rings + sage: E = EllipticCurve(GF(11), j=0) + sage: G0 = E.isogeny_ell_graph(2, directed=False) + sage: G0.is_directed() False - sage: G1 = E.isogeny_ell_graph(2, directed=True) # optional - sage.graphs sage.rings.finite_rings - sage: G1.is_directed() # optional - sage.graphs sage.rings.finite_rings + sage: G1 = E.isogeny_ell_graph(2, directed=True) + sage: G1.is_directed() True - sage: G2 = E.isogeny_ell_graph(2, label_by_j=False) # optional - sage.graphs sage.rings.finite_rings - sage: G2.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G2 = E.isogeny_ell_graph(2, label_by_j=False) + sage: G2.vertices(sort=True) ['y^2 = x^3 + 1', 'y^2 = x^3 + 2', 'y^2 = x^3 + 5*x', 'y^2 = x^3 + 7*x'] - sage: G3 = E.isogeny_ell_graph(2, label_by_j=True) # optional - sage.graphs sage.rings.finite_rings - sage: G3.vertices(sort=True) # optional - sage.graphs sage.rings.finite_rings + sage: G3 = E.isogeny_ell_graph(2, label_by_j=True) + sage: G3.vertices(sort=True) ['0', '0*', '1', '1*'] """ diff --git a/src/sage/schemes/elliptic_curves/ell_finite_field.py b/src/sage/schemes/elliptic_curves/ell_finite_field.py index a46d722fb51..af71b5a72f1 100644 --- a/src/sage/schemes/elliptic_curves/ell_finite_field.py +++ b/src/sage/schemes/elliptic_curves/ell_finite_field.py @@ -55,6 +55,7 @@ class EllipticCurve_finite_field(EllipticCurve_field, HyperellipticCurve_finite_ sage: EllipticCurve(GF(101),[2,3]) Elliptic Curve defined by y^2 = x^3 + 2*x + 3 over Finite Field of size 101 + sage: # needs sage.rings.finite_rings sage: F = GF(101^2, 'a') sage: EllipticCurve([F(2),F(3)]) Elliptic Curve defined by y^2 = x^3 + 2*x + 3 over Finite Field in a of size 101^2 @@ -99,7 +100,7 @@ def plot(self, *args, **kwds): EXAMPLES:: sage: E = EllipticCurve(FiniteField(17), [0,1]) - sage: P = plot(E, rgbcolor=(0,0,1)) + sage: P = plot(E, rgbcolor=(0,0,1)) # needs sage.plot """ R = self.base_ring() if not R.is_prime_field(): @@ -135,6 +136,7 @@ def _points_via_group_structure(self): :: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(4,'a'),[0, 0, 1, 0, 1]) sage: E.points() [(0 : 1 : 0), (0 : a : 1), (0 : a + 1 : 1), (1 : 0 : 1), (1 : 1 : 1), (a : 0 : 1), (a : 1 : 1), (a + 1 : 0 : 1), (a + 1 : 1 : 1)] @@ -184,6 +186,7 @@ def points(self): :: + sage: # needs sage.rings.finite_rings sage: K = GF((p, 2),'a') sage: E = E.change_ring(K) sage: len(E.points()) @@ -195,7 +198,7 @@ def points(self): Note that the returned list is an immutable sorted Sequence:: - sage: w[0] = 9 + sage: w[0] = 9 # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: object is immutable; please change a copy instead. @@ -245,6 +248,7 @@ def count_points(self, n=1): :: + sage: # needs sage.rings.finite_rings sage: F. = GF(p^2) sage: E = EllipticCurve(F, [a,a]) sage: E.cardinality() @@ -309,6 +313,7 @@ def random_element(self): :: + sage: # needs sage.rings.finite_rings sage: k. = GF(7^5) sage: E = EllipticCurve(k,[2,4]) sage: P = E.random_element(); P # random @@ -320,9 +325,10 @@ def random_element(self): :: + sage: # needs sage.rings.finite_rings sage: k. = GF(2^5) sage: E = EllipticCurve(k,[a^2,a,1,a+1,1]) - sage: P = E.random_element();P # random + sage: P = E.random_element(); P # random (a^4 + a : a^4 + a^3 + a^2 : 1) sage: type(P) @@ -352,6 +358,7 @@ def random_element(self): sage: E.cardinality() 1 + sage: # needs sage.rings.finite_rings sage: F. = GF(4) sage: E = EllipticCurve(F, [0, 0, 1, 0, a]) sage: E.random_point() @@ -390,14 +397,14 @@ def trace_of_frobenius(self): sage: E = EllipticCurve(GF(101),[2,3]) sage: E.trace_of_frobenius() 6 - sage: E = EllipticCurve(GF(11^5,'a'),[2,5]) - sage: E.trace_of_frobenius() + sage: E = EllipticCurve(GF(11^5,'a'),[2,5]) # needs sage.rings.finite_rings + sage: E.trace_of_frobenius() # needs sage.rings.finite_rings 802 The following shows that the issue from :trac:`2849` is fixed:: - sage: E = EllipticCurve(GF(3^5,'a'),[-1,-1]) - sage: E.trace_of_frobenius() + sage: E = EllipticCurve(GF(3^5,'a'),[-1,-1]) # needs sage.rings.finite_rings + sage: E.trace_of_frobenius() # needs sage.rings.finite_rings -27 """ return 1 + self.base_field().order() - self.cardinality() @@ -437,6 +444,7 @@ def cardinality(self, algorithm=None, extension_degree=1): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: EllipticCurve(GF(4, 'a'), [1,2,3,4,5]).cardinality() 8 sage: k. = GF(3^3) @@ -446,12 +454,14 @@ def cardinality(self, algorithm=None, extension_degree=1): :: + sage: # needs sage.rings.finite_rings sage: l = [1, 1, 0, 2, 0] sage: EllipticCurve(k, l).cardinality() 38 An even bigger extension (which we check against Magma):: + sage: # needs sage.rings.finite_rings sage: EllipticCurve(GF(3^100, 'a'), [1,2,3,4,5]).cardinality() 515377520732011331036459693969645888996929981504 sage: magma.eval("Order(EllipticCurve([GF(3^100)|1,2,3,4,5]))") # optional - magma @@ -468,6 +478,7 @@ def cardinality(self, algorithm=None, extension_degree=1): The cardinality is cached:: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(3^100, 'a'), [1,2,3,4,5]) sage: E.cardinality() is E.cardinality() True @@ -475,6 +486,7 @@ def cardinality(self, algorithm=None, extension_degree=1): The following is very fast since the curve is actually defined over the prime field:: + sage: # needs sage.rings.finite_rings sage: k. = GF(11^100) sage: E1 = EllipticCurve(k, [3,3]) sage: N1 = E1.cardinality(algorithm="subfield"); N1 @@ -491,17 +503,20 @@ def cardinality(self, algorithm=None, extension_degree=1): We can count points over curves defined as a reduction:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ) sage: K. = NumberField(x^2 + x + 1) sage: EK = EllipticCurve(K, [0, 0, w, 2, 1]) sage: E = EK.base_extend(K.residue_field(2)) sage: E - Elliptic Curve defined by y^2 + wbar*y = x^3 + 1 over Residue field in wbar of Fractional ideal (2) + Elliptic Curve defined by y^2 + wbar*y = x^3 + 1 + over Residue field in wbar of Fractional ideal (2) sage: E.cardinality() 7 sage: E = EK.base_extend(K.residue_field(w - 1)) sage: E.abelian_group() - Trivial group embedded in Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 + 2*x + 1 over Residue field of Fractional ideal (w - 1) + Trivial group embedded in Abelian group of points on Elliptic Curve defined + by y^2 + y = x^3 + 2*x + 1 over Residue field of Fractional ideal (w - 1) :: @@ -510,7 +525,9 @@ def cardinality(self, algorithm=None, extension_degree=1): sage: k. = R.residue_field(pol) sage: E = EllipticCurve(R, [1, x]).base_extend(k) sage: E - Elliptic Curve defined by y^2 = x^3 + x + a over Residue field in a of Principal ideal (x^5 + x + 14) of Univariate Polynomial Ring in x over Finite Field of size 17 + Elliptic Curve defined by y^2 = x^3 + x + a + over Residue field in a of Principal ideal (x^5 + x + 14) + of Univariate Polynomial Ring in x over Finite Field of size 17 sage: E.cardinality() 1421004 @@ -532,6 +549,7 @@ def cardinality(self, algorithm=None, extension_degree=1): Check that a bug noted at :trac:`15667` is fixed:: + sage: # needs sage.rings.finite_rings sage: F. = GF(3^6) sage: EllipticCurve([a^5 + 2*a^3 + 2*a^2 + 2*a, a^4 + a^3 + 2*a + 1]).cardinality() 784 @@ -614,6 +632,7 @@ def frobenius_polynomial(self): For some supersingular curves, Frobenius is in Z and the polynomial is a square:: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(25,'a'),[0,0,0,0,1]) sage: E.frobenius_polynomial().factor() (x + 5)^2 @@ -640,6 +659,7 @@ def frobenius_order(self): For some supersingular curves, Frobenius is in Z and the Frobenius order is Z:: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(25,'a'),[0,0,0,0,1]) sage: R = E.frobenius_order() sage: R @@ -671,6 +691,7 @@ def frobenius(self): For some supersingular curves, Frobenius is in Z:: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(25,'a'),[0,0,0,0,1]) sage: E.frobenius() -5 @@ -688,6 +709,7 @@ def frobenius_endomorphism(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F. = GF(11^4) sage: E = EllipticCurve([t,t]) sage: E.frobenius_endomorphism() @@ -709,6 +731,7 @@ def frobenius_discriminant(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: F. = GF(11^4) sage: E = EllipticCurve([t,t]) sage: E.frobenius_discriminant() @@ -736,6 +759,7 @@ def cardinality_pari(self): Since :trac:`16931`, this now works over finite fields which are not prime fields:: + sage: # needs sage.rings.finite_rings sage: k. = GF(7^3) sage: E = EllipticCurve_from_j(a) sage: E.cardinality_pari() @@ -747,7 +771,7 @@ def cardinality_pari(self): TESTS:: - sage: E.cardinality_pari().parent() + sage: E.cardinality_pari().parent() # needs sage.rings.finite_rings Integer Ring """ return Integer(self.__pari__().ellcard()) @@ -800,7 +824,9 @@ def gens(self): instead:: sage: E.abelian_group() - Additive abelian group isomorphic to Z/22 + Z/2 embedded in Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 2*x + 5 over Finite Field of size 41 + Additive abelian group isomorphic to Z/22 + Z/2 + embedded in Abelian group of points on Elliptic Curve + defined by y^2 = x^3 + 2*x + 5 over Finite Field of size 41 sage: ab_gens = E.abelian_group().gens() sage: ab_gens == E.gens() True @@ -811,6 +837,7 @@ def gens(self): Examples with 1 and 0 generators:: + sage: # needs sage.rings.finite_rings sage: F. = GF(3^6) sage: E = EllipticCurve([a, a+1]) sage: pts = E.gens() @@ -818,6 +845,7 @@ def gens(self): 1 sage: pts[0].order() == E.cardinality() True + sage: E = EllipticCurve(GF(2), [0,0,1,1,1]) sage: E.gens() () @@ -825,6 +853,7 @@ def gens(self): This works over larger finite fields where :meth:`abelian_group` may be too expensive:: + sage: # needs sage.rings.finite_rings sage: k. = GF(5^60) sage: E = EllipticCurve([a, a]) sage: len(E.gens()) @@ -951,6 +980,7 @@ def abelian_group(self): :: + sage: # needs sage.rings.finite_rings sage: F. = GF(3^6,'a') sage: E = EllipticCurve([a^4 + a^3 + 2*a^2 + 2*a, 2*a^5 + 2*a^3 + 2*a^2 + 1]) sage: E.abelian_group() @@ -958,6 +988,7 @@ def abelian_group(self): :: + sage: # needs sage.rings.finite_rings sage: F. = GF(101^3,'a') sage: E = EllipticCurve([2*a^2 + 48*a + 27, 89*a^2 + 76*a + 24]) sage: E.abelian_group() @@ -987,6 +1018,7 @@ def abelian_group(self): This tests that the bug reported in :trac:`3926` has been fixed:: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(-1) sage: OK = K.ring_of_integers() sage: P = K.factor(10007)[0][0] @@ -1038,6 +1070,7 @@ def torsion_basis(self, n): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: E = EllipticCurve(GF(62207^2), [1,0]) sage: E.abelian_group() Additive abelian group isomorphic to Z/62208 + Z/62208 embedded in @@ -1121,6 +1154,7 @@ def is_isogenous(self, other, field=None, proof=True): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: E1 = EllipticCurve(GF(11^2,'a'),[2,7]); E1 Elliptic Curve defined by y^2 = x^3 + 2*x + 7 over Finite Field in a of size 11^2 sage: E1.is_isogenous(5) @@ -1130,6 +1164,7 @@ def is_isogenous(self, other, field=None, proof=True): sage: E1.is_isogenous(E1) True + sage: # needs sage.rings.finite_rings sage: E2 = EllipticCurve(GF(7^3,'b'),[3,1]); E2 Elliptic Curve defined by y^2 = x^3 + 3*x + 1 over Finite Field in b of size 7^3 sage: E1.is_isogenous(E2) @@ -1137,16 +1172,19 @@ def is_isogenous(self, other, field=None, proof=True): ... ValueError: The base fields must have the same characteristic. + sage: # needs sage.rings.finite_rings sage: E3 = EllipticCurve(GF(11^2,'c'),[4,3]); E3 Elliptic Curve defined by y^2 = x^3 + 4*x + 3 over Finite Field in c of size 11^2 sage: E1.is_isogenous(E3) False + sage: # needs sage.rings.finite_rings sage: E4 = EllipticCurve(GF(11^6,'d'),[6,5]); E4 Elliptic Curve defined by y^2 = x^3 + 6*x + 5 over Finite Field in d of size 11^6 sage: E1.is_isogenous(E4) True + sage: # needs sage.rings.finite_rings sage: E5 = EllipticCurve(GF(11^7,'e'),[4,2]); E5 Elliptic Curve defined by y^2 = x^3 + 4*x + 2 over Finite Field in e of size 11^7 sage: E1.is_isogenous(E5) @@ -1156,6 +1194,7 @@ def is_isogenous(self, other, field=None, proof=True): When the field is given:: + sage: # needs sage.rings.finite_rings sage: E1 = EllipticCurve(GF(13^2,'a'),[2,7]); E1 Elliptic Curve defined by y^2 = x^3 + 2*x + 7 over Finite Field in a of size 13^2 sage: E1.is_isogenous(5,GF(13^6,'f')) @@ -1664,10 +1703,12 @@ def twists(self): `j=0=1728`, when there are either 4 or 6 depending on whether the field has odd or even degree over `\GF{3}`:: + sage: # needs sage.rings.finite_rings sage: K = GF(3**5) sage: [E.ainvs() for E in EllipticCurve(j=K(1)).twists()] [(0, 1, 0, 0, 2), (0, z5, 0, 0, 2*z5^3)] + sage: # needs sage.rings.finite_rings sage: K = GF(3**5) sage: [E.ainvs() for E in EllipticCurve(j=K(0)).twists()] # random [(0, 0, 0, 1, 0), @@ -1675,10 +1716,12 @@ def twists(self): (0, 0, 0, 2, z5^4 + z5^3 + z5^2), (0, 0, 0, 2, 2*z5^4 + 2*z5^3 + 2*z5^2)] + sage: # needs sage.rings.finite_rings sage: K = GF(3**4) sage: [E.ainvs() for E in EllipticCurve(j=K(1)).twists()] [(0, 1, 0, 0, 2), (0, z4, 0, 0, 2*z4^3)] + sage: # needs sage.rings.finite_rings sage: K = GF(3**4) sage: [E.ainvs() for E in EllipticCurve(j=K(0)).twists()] # random [(0, 0, 0, 1, 0), @@ -1692,18 +1735,22 @@ def twists(self): `j=0=1728`, when there are either 3 or 7 depending on whether the field has odd or even degree over `\GF{2}`:: + sage: # needs sage.rings.finite_rings sage: K = GF(2**7) sage: [E.ainvs() for E in EllipticCurve(j=K(1)).twists()] [(1, 0, 0, 0, 1), (1, 1, 0, 0, 1)] + sage: # needs sage.rings.finite_rings sage: K = GF(2**7) sage: [E.ainvs() for E in EllipticCurve(j=K(0)).twists()] [(0, 0, 1, 0, 0), (0, 0, 1, 1, 0), (0, 0, 1, 1, 1)] + sage: # needs sage.rings.finite_rings sage: K = GF(2**8) sage: [E.ainvs() for E in EllipticCurve(j=K(1)).twists()] # random [(1, 0, 0, 0, 1), (1, z8^7 + z8^6 + z8^5 + z8^4 + z8^2 + z8, 0, 0, 1)] + sage: # needs sage.rings.finite_rings sage: K = GF(2**8) sage: [E.ainvs() for E in EllipticCurve(j=K(0)).twists()] # random [(0, 0, 1, 0, 0), @@ -1718,6 +1765,7 @@ def twists(self): Randomized check that we find all twists and there are no duplicates:: + sage: # needs sage.rings.finite_rings sage: p = next_prime(randrange(2,100)) sage: e = randrange(1,10) sage: F. = GF((p,e)) @@ -1799,7 +1847,7 @@ def curves_with_j_0(K): Elliptic Curve defined by y^2 = x^3 + 4 over Finite Field of size 7, Elliptic Curve defined by y^2 = x^3 + 5 over Finite Field of size 7, Elliptic Curve defined by y^2 = x^3 + 6 over Finite Field of size 7] - sage: curves_with_j_0(GF(25)) + sage: curves_with_j_0(GF(25)) # needs sage.rings.finite_rings [Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in z2 of size 5^2, Elliptic Curve defined by y^2 = x^3 + z2 over Finite Field in z2 of size 5^2, Elliptic Curve defined by y^2 = x^3 + (z2+3) over Finite Field in z2 of size 5^2, @@ -1858,7 +1906,7 @@ def curves_with_j_1728(K): Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 5, Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 5, Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 5] - sage: curves_with_j_1728(GF(49)) + sage: curves_with_j_1728(GF(49)) # needs sage.rings.finite_rings [Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 7^2, Elliptic Curve defined by y^2 = x^3 + z2*x over Finite Field in z2 of size 7^2, Elliptic Curve defined by y^2 = x^3 + (z2+4)*x over Finite Field in z2 of size 7^2, @@ -1908,6 +1956,7 @@ def curves_with_j_0_char2(K): In odd degree, there are three isomorphism classes all with representatives defined over `\GF{2}`:: sage: from sage.schemes.elliptic_curves.ell_finite_field import curves_with_j_0_char2 + sage: # needs sage.rings.finite_rings sage: K = GF(2**7) sage: curves = curves_with_j_0_char2(K) sage: len(curves) @@ -1917,17 +1966,19 @@ def curves_with_j_0_char2(K): Check that the curves are mutually non-isomorphic:: - sage: all((e1 == e2 or not e1.is_isomorphic(e2)) for e1 in curves for e2 in curves) + sage: all((e1 == e2 or not e1.is_isomorphic(e2)) # needs sage.rings.finite_rings + ....: for e1 in curves for e2 in curves) True Check that the weight formula holds:: - sage: sum(1/len(E.automorphisms()) for E in curves) == 1 + sage: sum(1/len(E.automorphisms()) for E in curves) == 1 # needs sage.rings.finite_rings True In even degree there are seven isomorphism classes:: sage: from sage.schemes.elliptic_curves.ell_finite_field import curves_with_j_0_char2 + sage: # needs sage.rings.finite_rings sage: K = GF(2**8) sage: curves = EllipticCurve(j=K(0)).twists() sage: len(curves) @@ -1943,12 +1994,13 @@ def curves_with_j_0_char2(K): Check that the twists are mutually non-isomorphic:: - sage: all((e1 == e2 or not e1.is_isomorphic(e2)) for e1 in curves for e2 in curves) + sage: all((e1 == e2 or not e1.is_isomorphic(e2)) # needs sage.rings.finite_rings + ....: for e1 in curves for e2 in curves) True Check that the weight formula holds:: - sage: sum(1/len(E.automorphisms()) for E in curves) == 1 + sage: sum(1/len(E.automorphisms()) for E in curves) == 1 # needs sage.rings.finite_rings True """ if not K.is_finite() or K.characteristic() != 2: @@ -1997,6 +2049,7 @@ def curves_with_j_0_char3(K): In odd degree, there are four isomorphism classes:: sage: from sage.schemes.elliptic_curves.ell_finite_field import curves_with_j_0_char3 + sage: # needs sage.rings.finite_rings sage: K = GF(3**5) sage: curves = curves_with_j_0_char3(K) sage: len(curves) @@ -2009,17 +2062,19 @@ def curves_with_j_0_char3(K): Check that the twists are mutually non-isomorphic:: - sage: all((e1 == e2 or not e1.is_isomorphic(e2)) for e1 in curves for e2 in curves) + sage: all((e1 == e2 or not e1.is_isomorphic(e2)) # needs sage.rings.finite_rings + ....: for e1 in curves for e2 in curves) True Check that the weight formula holds:: - sage: sum(1/len(E.automorphisms()) for E in curves) == 1 + sage: sum(1/len(E.automorphisms()) for E in curves) == 1 # needs sage.rings.finite_rings True In even degree, there are six isomorphism classes:: sage: from sage.schemes.elliptic_curves.ell_finite_field import curves_with_j_0_char3 + sage: # needs sage.rings.finite_rings sage: K = GF(3**4) sage: curves = EllipticCurve(j=K(0)).twists() sage: len(curves) @@ -2034,12 +2089,13 @@ def curves_with_j_0_char3(K): Check that the twists are mutually non-isomorphic:: - sage: all((e1 == e2 or not e1.is_isomorphic(e2)) for e1 in curves for e2 in curves) + sage: all((e1 == e2 or not e1.is_isomorphic(e2)) # needs sage.rings.finite_rings + ....: for e1 in curves for e2 in curves) True Check that the weight formula holds:: - sage: sum(1/len(E.automorphisms()) for E in curves) == 1 + sage: sum(1/len(E.automorphisms()) for E in curves) == 1 # needs sage.rings.finite_rings True """ if not K.is_finite() or K.characteristic() != 3: @@ -2258,7 +2314,8 @@ def is_j_supersingular(j, proof=True): sage: from sage.schemes.elliptic_curves.ell_finite_field import is_j_supersingular, supersingular_j_polynomials sage: [(p,[j for j in GF(p) if is_j_supersingular(j)]) for p in prime_range(30)] - [(2, [0]), (3, [0]), (5, [0]), (7, [6]), (11, [0, 1]), (13, [5]), (17, [0, 8]), (19, [7, 18]), (23, [0, 3, 19]), (29, [0, 2, 25])] + [(2, [0]), (3, [0]), (5, [0]), (7, [6]), (11, [0, 1]), (13, [5]), + (17, [0, 8]), (19, [7, 18]), (23, [0, 3, 19]), (29, [0, 2, 25])] sage: [j for j in GF(109) if is_j_supersingular(j)] [17, 41, 43] diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py index c7a4bb94e73..8e7fb204892 100644 --- a/src/sage/schemes/elliptic_curves/ell_generic.py +++ b/src/sage/schemes/elliptic_curves/ell_generic.py @@ -19,13 +19,13 @@ We construct an elliptic curve over an elaborate base ring:: sage: p, a, b = 97, 1, 3 - sage: R. = GF(p)[] # optional - sage.rings.finite_rings - sage: S. = R[] # optional - sage.rings.finite_rings - sage: T = S.fraction_field() # optional - sage.rings.finite_rings - sage: E = EllipticCurve(T, [a, b]); E # optional - sage.rings.finite_rings + sage: R. = GF(p)[] + sage: S. = R[] + sage: T = S.fraction_field() + sage: E = EllipticCurve(T, [a, b]); E Elliptic Curve defined by y^2 = x^3 + x + 3 over Fraction Field of Univariate Polynomial Ring in v over Univariate Polynomial Ring in u over Finite Field of size 97 - sage: latex(E) # optional - sage.rings.finite_rings + sage: latex(E) y^2 = x^{3} + x + 3 AUTHORS: @@ -143,7 +143,7 @@ def __init__(self, K, ainvs): sage: E = EllipticCurve([1,2,3,4,5]); E Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field - sage: E = EllipticCurve(GF(7), [1,2,3,4,5]); E # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [1,2,3,4,5]); E Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 7 @@ -253,8 +253,8 @@ def _repr_(self): :: sage: R. = QQ['x'] - sage: K. = NumberField(x^3 - 17) # optional - sage.rings.number_field - sage: EllipticCurve([a^2 - 3, -2/3*a + 3]) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 17) # needs sage.rings.number_field + sage: EllipticCurve([a^2 - 3, -2/3*a + 3]) # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + (a^2-3)*x + (-2/3*a+3) over Number Field in a with defining polynomial x^3 - 17 @@ -283,9 +283,9 @@ def _latex_(self): Check that :trac:`12524` is solved:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - x - 1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, phi, 27*phi - 43, -80*phi + 128]) # optional - sage.rings.number_field - sage: E._latex_() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 1) # needs sage.rings.number_field + sage: E = EllipticCurve([0, 0, phi, 27*phi - 43, -80*phi + 128]) # needs sage.rings.number_field + sage: E._latex_() # needs sage.rings.number_field 'y^2 + \\phi y = x^{3} + \\left(27 \\phi - 43\\right) x - 80 \\phi + 128 ' """ from sage.rings.polynomial.polynomial_ring import polygen @@ -321,19 +321,20 @@ def _magma_init_(self, magma): EXAMPLES:: + sage: # optional - magma sage: E = EllipticCurve(QQ, [1,1]) - sage: E._magma_init_(magma) # optional - magma + sage: E._magma_init_(magma) 'EllipticCurve([_sage_ref...|0/1,0/1,0/1,1/1,1/1])' - sage: E = EllipticCurve(GF(41), [2,5]) # optional - sage.rings.finite_rings - sage: E._magma_init_(magma) # optional - magma # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(41), [2,5]) + sage: E._magma_init_(magma) 'EllipticCurve([_sage_ref...|GF(41)!0,GF(41)!0,GF(41)!0,GF(41)!2,GF(41)!5])' - sage: E = EllipticCurve(GF(25,'a'), [0,0,1,4,0]) # optional - sage.rings.finite_rings - sage: magma(E) # optional - magma # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(25,'a'), [0,0,1,4,0]) # needs sage.rings.finite_rings + sage: magma(E) # needs sage.rings.finite_rings Elliptic Curve defined by y^2 + y = x^3 + 4*x over GF(5^2) - sage: magma(EllipticCurve([1/2,2/3,-4/5,6/7,8/9])) # optional - magma + sage: magma(EllipticCurve([1/2,2/3,-4/5,6/7,8/9])) Elliptic Curve defined by y^2 + 1/2*x*y - 4/5*y = x^3 + 2/3*x^2 + 6/7*x + 8/9 over Rational Field sage: R. = Frac(QQ['x']) - sage: magma(EllipticCurve([x, 1 + x])) # optional - magma + sage: magma(EllipticCurve([x, 1 + x])) Elliptic Curve defined by y^2 = x^3 + x*x + (x + 1) over Univariate rational function field over Rational Field """ @@ -351,29 +352,29 @@ def _symbolic_(self, SR): :: sage: E = EllipticCurve('11a') - sage: E._symbolic_(SR) # optional - sage.symbolic + sage: E._symbolic_(SR) # needs sage.symbolic y^2 + y == x^3 - x^2 - 10*x - 20 - sage: E.torsion_subgroup().gens() # optional - sage.symbolic + sage: E.torsion_subgroup().gens() # needs sage.symbolic ((5 : 5 : 1),) We find the corresponding symbolic equality:: - sage: eqn = symbolic_expression(E); eqn # optional - sage.symbolic + sage: eqn = symbolic_expression(E); eqn # needs sage.symbolic y^2 + y == x^3 - x^2 - 10*x - 20 We verify that the given point is on the curve:: - sage: eqn(x=5, y=5) # optional - sage.symbolic + sage: eqn(x=5, y=5) # needs sage.symbolic 30 == 30 - sage: bool(eqn(x=5, y=5)) # optional - sage.symbolic + sage: bool(eqn(x=5, y=5)) # needs sage.symbolic True We create a single expression:: - sage: F = eqn.lhs() - eqn.rhs(); F # optional - sage.symbolic + sage: F = eqn.lhs() - eqn.rhs(); F # needs sage.symbolic -x^3 + x^2 + y^2 + 10*x + y + 20 - sage: y = var('y') # optional - sage.symbolic - sage: F.solve(y) # optional - sage.symbolic + sage: y = var('y') # needs sage.symbolic + sage: F.solve(y) # needs sage.symbolic [y == -1/2*sqrt(4*x^3 - 4*x^2 - 40*x - 79) - 1/2, y == 1/2*sqrt(4*x^3 - 4*x^2 - 40*x - 79) - 1/2] @@ -381,44 +382,46 @@ def _symbolic_(self, SR): horrendous. Continuing with the above example, we can explicitly find points over random fields by substituting in values for x:: - sage: v = F.solve(y)[0].rhs(); v # optional - sage.symbolic + sage: # needs sage.symbolic + sage: v = F.solve(y)[0].rhs(); v -1/2*sqrt(4*x^3 - 4*x^2 - 40*x - 79) - 1/2 - sage: v = v.function(x) # optional - sage.symbolic - sage: v(3) # optional - sage.symbolic + sage: v = v.function(x) + sage: v(3) -1/2*sqrt(-127) - 1/2 - sage: v(7) # optional - sage.symbolic + sage: v(7) -1/2*sqrt(817) - 1/2 - sage: v(-7) # optional - sage.symbolic + sage: v(-7) -1/2*sqrt(-1367) - 1/2 - sage: v(sqrt(2)) # optional - sage.symbolic + sage: v(sqrt(2)) -1/2*sqrt(-32*sqrt(2) - 87) - 1/2 We can even do arithmetic with them, as follows:: - sage: E2 = E.change_ring(SR); E2 # optional - sage.symbolic + sage: # needs sage.symbolic + sage: E2 = E.change_ring(SR); E2 Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Symbolic Ring - sage: P = E2.point((3, v(3), 1), check=False) # the check=False option doesn't verify that y^2 = f(x) # optional - sage.symbolic - sage: P # optional - sage.symbolic + sage: P = E2.point((3, v(3), 1), check=False) # the check=False option doesn't verify that y^2 = f(x) + sage: P (3 : -1/2*sqrt(-127) - 1/2 : 1) - sage: P + P # optional - sage.symbolic + sage: P + P (-756/127 : 41143/32258*sqrt(-127) - 1/2 : 1) We can even throw in a transcendental:: - sage: w = E2.point((pi,v(pi),1), check=False); w # optional - sage.symbolic + sage: w = E2.point((pi,v(pi),1), check=False); w # needs sage.symbolic (pi : -1/2*sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) - 1/2 : 1) - sage: x, y, z = w; ((y^2 + y) - (x^3 - x^2 - 10*x - 20)).expand() # optional - sage.symbolic + sage: x, y, z = w; ((y^2 + y) - (x^3 - x^2 - 10*x - 20)).expand() # needs sage.symbolic 0 - sage: 2*w # optional - sage.symbolic + sage: 2*w # needs sage.symbolic (-2*pi - (2*pi - 3*pi^2 + 10)^2/(40*pi - 4*pi^3 + 4*pi^2 + 79) + 1 : (3*pi + (2*pi - 3*pi^2 + 10)^2/(40*pi - 4*pi^3 + 4*pi^2 + 79) - 1)*(2*pi - 3*pi^2 + 10)/sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) + 1/2*sqrt(-40*pi + 4*pi^3 - 4*pi^2 - 79) - 1/2 : 1) - sage: x, y, z = 2*w; temp = ((y^2 + y) - (x^3 - x^2 - 10*x - 20)) # optional - sage.symbolic + sage: x, y, z = 2*w; temp = ((y^2 + y) - (x^3 - x^2 - 10*x - 20)) # needs sage.symbolic This is a point on the curve:: - sage: bool(temp == 0) # optional - sage.symbolic + sage: bool(temp == 0) # needs sage.symbolic True """ a = [SR(x) for x in self.a_invariants()] @@ -438,15 +441,15 @@ def __contains__(self, P): True sage: (1,3) in E False - sage: E = EllipticCurve([GF(7)(0), 1]) # optional - sage.rings.finite_rings - sage: [0,0] in E # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(0), 1]) + sage: [0,0] in E False - sage: [0,8] in E # optional - sage.rings.finite_rings + sage: [0,8] in E True - sage: P = E(0,8) # optional - sage.rings.finite_rings - sage: P # optional - sage.rings.finite_rings + sage: P = E(0,8) + sage: P (0 : 1 : 1) - sage: P in E # optional - sage.rings.finite_rings + sage: P in E True """ if not isinstance(P, ell_point.EllipticCurvePoint): @@ -496,10 +499,10 @@ def __call__(self, *args, **kwds): We create points on an elliptic curve over a prime finite field:: - sage: E = EllipticCurve([GF(7)(0), 1]) # optional - sage.rings.finite_rings - sage: E([2,3]) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(0), 1]) + sage: E([2,3]) (2 : 3 : 1) - sage: E([0,0]) # optional - sage.rings.finite_rings + sage: E([0,0]) Traceback (most recent call last): ... TypeError: Coordinates [0, 0, 1] do not define a point @@ -507,20 +510,21 @@ def __call__(self, *args, **kwds): We create a point on an elliptic curve over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(RationalField()) - sage: K = NumberField(x**3 + x + 1, 'a'); a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve([a, a]) # optional - sage.rings.number_field - sage: E # optional - sage.rings.number_field + sage: K = NumberField(x**3 + x + 1, 'a'); a = K.gen() + sage: E = EllipticCurve([a, a]) + sage: E Elliptic Curve defined by y^2 = x^3 + a*x + a over Number Field in a with defining polynomial x^3 + x + 1 - sage: E = EllipticCurve([K(1), 1]) # optional - sage.rings.number_field - sage: E # optional - sage.rings.number_field + sage: E = EllipticCurve([K(1), 1]) + sage: E Elliptic Curve defined by y^2 = x^3 + x + 1 over Number Field in a with defining polynomial x^3 + x + 1 - sage: P = E([a,0,1]) # optional - sage.rings.number_field - sage: P # optional - sage.rings.number_field + sage: P = E([a,0,1]) + sage: P (a : 0 : 1) - sage: P + P # optional - sage.rings.number_field + sage: P + P (0 : 1 : 0) Another example involving p-adics:: @@ -528,12 +532,12 @@ def __call__(self, *args, **kwds): sage: E = EllipticCurve('37a1') sage: P = E([0,0]); P (0 : 0 : 1) - sage: R = pAdicField(3, 20) # optional - sage.rings.padics - sage: Ep = E.base_extend(R); Ep # optional - sage.rings.padics + sage: R = pAdicField(3, 20) # needs sage.rings.padics + sage: Ep = E.base_extend(R); Ep # needs sage.rings.padics Elliptic Curve defined by y^2 + (1+O(3^20))*y = x^3 + (2+2*3+2*3^2+2*3^3+2*3^4+2*3^5+2*3^6+2*3^7+2*3^8+2*3^9+2*3^10+2*3^11+2*3^12+2*3^13+2*3^14+2*3^15+2*3^16+2*3^17+2*3^18+2*3^19+O(3^20))*x over 3-adic Field with capped relative precision 20 - sage: Ep(P) + sage: Ep(P) # needs sage.rings.padics (0 : 0 : 1 + O(3^20)) Constructing points from the torsion subgroup (which is an abstract @@ -622,14 +626,14 @@ def _reduce_point(self, R, p): point at infinity on the same curve but reduced modulo 11. The reduce function tells us this:: - sage: E11 = E.change_ring(GF(11)) # optional - sage.rings.finite_rings - sage: S = E11._reduce_point(R, 11) # optional - sage.rings.finite_rings - sage: E11(S) # optional - sage.rings.finite_rings + sage: E11 = E.change_ring(GF(11)) + sage: S = E11._reduce_point(R, 11) + sage: E11(S) (0 : 1 : 0) The 0 point reduces as expected:: - sage: E11._reduce_point(E(0), 11) # optional - sage.rings.finite_rings + sage: E11._reduce_point(E(0), 11) (0 : 1 : 0) Note that one need not explicitly call @@ -690,9 +694,9 @@ def is_x_coord(self, x): :: - sage: F = GF(32,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F,[1,0,0,0,1]) # optional - sage.rings.finite_rings - sage: set(P[0] for P in E.points() if P!=E(0)) == set(x for x in F if E.is_x_coord(x)) # optional - sage.rings.finite_rings + sage: F = GF(32,'a') # needs sage.rings.finite_rings + sage: E = EllipticCurve(F,[1,0,0,0,1]) # needs sage.rings.finite_rings + sage: set(P[0] for P in E.points() if P!=E(0)) == set(x for x in F if E.is_x_coord(x)) # needs sage.rings.finite_rings True """ K = self.base_ring() @@ -772,9 +776,9 @@ def lift_x(self, x, all=False, extend=False): point is a point on a new curve object, the result of changing the base ring to the parent of `x`:: - sage: P = E.lift_x(3, extend=True); P # optional - sage.rings.number_field + sage: P = E.lift_x(3, extend=True); P # needs sage.rings.number_field (3 : -y - 1 : 1) - sage: P.curve() # optional - sage.rings.number_field + sage: P.curve() # needs sage.rings.number_field Elliptic Curve defined by y^2 + y = x^3 + (-1)*x over Number Field in y with defining polynomial y^2 + y - 24 @@ -798,19 +802,19 @@ def lift_x(self, x, all=False, extend=False): sage: E = EllipticCurve([0,0,0,0,2]); E Elliptic Curve defined by y^2 = x^3 + 2 over Rational Field - sage: P = E.lift_x(0, extend=True); P # optional - sage.rings.number_field + sage: P = E.lift_x(0, extend=True); P # needs sage.rings.number_field (0 : -y : 1) - sage: P.curve() # optional - sage.rings.number_field + sage: P.curve() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + 2 over Number Field in y with defining polynomial y^2 - 2 We can perform these operations over finite fields too:: - sage: E = EllipticCurve('37a').change_ring(GF(17)); E # optional - sage.rings.finite_rings + sage: E = EllipticCurve('37a').change_ring(GF(17)); E Elliptic Curve defined by y^2 + y = x^3 + 16*x over Finite Field of size 17 - sage: E.lift_x(7) # optional - sage.rings.finite_rings + sage: E.lift_x(7) (7 : 5 : 1) - sage: E.lift_x(3) # optional - sage.rings.finite_rings + sage: E.lift_x(3) Traceback (most recent call last): ... ValueError: No point with x-coordinate 3 on @@ -819,7 +823,7 @@ def lift_x(self, x, all=False, extend=False): Note that there is only one lift with `x`-coordinate 10 in `E(\GF{17})`:: - sage: E.lift_x(10, all=True) # optional - sage.rings.finite_rings + sage: E.lift_x(10, all=True) [(10 : 8 : 1)] We can lift over more exotic rings too. If the supplied x @@ -827,19 +831,19 @@ def lift_x(self, x, all=False, extend=False): returned is on the base-extended curve:: sage: E = EllipticCurve('37a') - sage: P = E.lift_x(pAdicField(17, 5)(6)); P # optional - sage.rings.padics + sage: P = E.lift_x(pAdicField(17, 5)(6)); P # needs sage.rings.padics (6 + O(17^5) : 14 + O(17^5) : 1 + O(17^5)) - sage: P.curve() # optional - sage.rings.padics + sage: P.curve() # needs sage.rings.padics Elliptic Curve defined by y^2 + (1+O(17^5))*y = x^3 + (16+16*17+16*17^2+16*17^3+16*17^4+O(17^5))*x over 17-adic Field with capped relative precision 5 sage: K. = PowerSeriesRing(QQ, 't', 5) sage: P = E.lift_x(1 + t); P (1 + t : -1 - 2*t + t^2 - 5*t^3 + 21*t^4 + O(t^5) : 1) - sage: K. = GF(16) # optional - sage.rings.finite_rings - sage: P = E.change_ring(K).lift_x(a^3); P # optional - sage.rings.finite_rings + sage: K. = GF(16) # needs sage.rings.finite_rings + sage: P = E.change_ring(K).lift_x(a^3); P # needs sage.rings.finite_rings (a^3 : a^3 + a : 1) - sage: P.curve() # optional - sage.rings.finite_rings + sage: P.curve() # needs sage.rings.finite_rings Elliptic Curve defined by y^2 + y = x^3 + x over Finite Field in a of size 2^4 We can extend the base field to include the associated `y` value(s):: @@ -864,9 +868,9 @@ def lift_x(self, x, all=False, extend=False): Check that :trac:`30297` is fixed:: - sage: K = Qp(5) # optional - sage.rings.padics - sage: E = EllipticCurve([K(0), K(1)]) # optional - sage.rings.padics - sage: E.lift_x(1, extend=True) # optional - sage.rings.padics + sage: K = Qp(5) # needs sage.rings.padics + sage: E = EllipticCurve([K(0), K(1)]) # needs sage.rings.padics + sage: E.lift_x(1, extend=True) # needs sage.rings.padics (1 + O(5^20) : y + O(5^20) : 1 + O(5^20)) AUTHORS: @@ -876,10 +880,10 @@ def lift_x(self, x, all=False, extend=False): TESTS:: - sage: E = EllipticCurve('37a').short_weierstrass_model().change_ring(GF(17)) # optional - sage.rings.finite_rings - sage: E.lift_x(3, all=True) # optional - sage.rings.finite_rings + sage: E = EllipticCurve('37a').short_weierstrass_model().change_ring(GF(17)) + sage: E.lift_x(3, all=True) [] - sage: E.lift_x(7, all=True) # optional - sage.rings.finite_rings + sage: E.lift_x(7, all=True) [(7 : 3 : 1), (7 : 14 : 1)] Check determinism:: @@ -972,8 +976,8 @@ def _point_homset(self, *args, **kwds): EXAMPLES:: - sage: E = EllipticCurve(GF(5),[1,1]) # optional - sage.rings.finite_rings - sage: E._point_homset(Spec(GF(5^10,'a'), GF(5)), E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(5),[1,1]) + sage: E._point_homset(Spec(GF(5^10,'a'), GF(5)), E) # needs sage.rings.finite_rings Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field in a of size 5^10 @@ -1018,8 +1022,8 @@ def __is_over_RationalField(self): sage: E = EllipticCurve(QQ,[1,1]) sage: E._EllipticCurve_generic__is_over_RationalField() True - sage: E = EllipticCurve(GF(5),[1,1]) # optional - sage.rings.finite_rings - sage: E._EllipticCurve_generic__is_over_RationalField() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(5),[1,1]) + sage: E._EllipticCurve_generic__is_over_RationalField() False """ return isinstance(self.base_ring(), RationalField) @@ -1062,8 +1066,8 @@ def a_invariants(self): sage: E.a_invariants() (0, 0, 0, 0, 1) - sage: E = EllipticCurve([GF(7)(3),5]) # optional - sage.rings.finite_rings - sage: E.a_invariants() # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(3),5]) + sage: E.a_invariants() (0, 0, 0, 3, 5) TESTS:: @@ -1308,8 +1312,8 @@ def discriminant(self): sage: E.discriminant() -161051 - sage: E = EllipticCurve([GF(7)(2),1]) # optional - sage.rings.finite_rings - sage: E.discriminant() # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(2),1]) + sage: E.discriminant() 1 """ b2, b4, b6, b8 = self.b_invariants() @@ -1336,8 +1340,8 @@ def j_invariant(self): sage: E.j_invariant() 1728 - sage: E = EllipticCurve([GF(7)(2),1]) # optional - sage.rings.finite_rings - sage: E.j_invariant() # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(2),1]) + sage: E.j_invariant() 1 """ c4, _ = self.c_invariants() @@ -1360,9 +1364,9 @@ def base_extend(self, R): EXAMPLES:: - sage: E = EllipticCurve(GF(5), [1,1]); E # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(5), [1,1]); E Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 5 - sage: E1 = E.base_extend(GF(125,'a')); E1 # optional - sage.rings.finite_rings + sage: E1 = E.base_extend(GF(125,'a')); E1 # needs sage.rings.finite_rings Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field in a of size 5^3 TESTS: @@ -1370,24 +1374,25 @@ def base_extend(self, R): Check that we are correctly keeping track of known cardinalities when extending the base field:: - sage: E = EllipticCurve(j=GF(7)(5)) # optional - sage.rings.finite_rings - sage: E.cardinality() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(j=GF(7)(5)) + sage: E.cardinality() 10 - sage: EE = E.base_extend(GF(7^2)) # optional - sage.rings.finite_rings - sage: EE._order # optional - sage.rings.finite_rings + sage: EE = E.base_extend(GF(7^2)) + sage: EE._order 60 Changing to a smaller field should not cache orders:: - sage: EE = EllipticCurve(j=GF(7^3)(6)) # optional - sage.rings.finite_rings - sage: hasattr(EE.change_ring(GF(7)), '_order') # optional - sage.rings.finite_rings + sage: EE = EllipticCurve(j=GF(7^3)(6)) # needs sage.rings.finite_rings + sage: hasattr(EE.change_ring(GF(7)), '_order') # needs sage.rings.finite_rings False Changing to a field of different characteristic should not cache orders:: - sage: Elift = E.change_ring(QQ) # optional - sage.rings.finite_rings - sage: hasattr(Elift, '_order') # optional - sage.rings.finite_rings + sage: Elift = E.change_ring(QQ) # needs sage.rings.finite_rings + sage: hasattr(Elift, '_order') # needs sage.rings.finite_rings False """ E = constructor.EllipticCurve([R(a) for a in self.a_invariants()]) @@ -1408,14 +1413,15 @@ def change_ring(self, R): EXAMPLES:: - sage: F2 = GF(5^2,'a'); a = F2.gen() # optional - sage.rings.finite_rings - sage: F4 = GF(5^4,'b'); b = F4.gen() # optional - sage.rings.finite_rings - sage: roots = a.charpoly().roots(ring=F4, multiplicities=False) # optional - sage.rings.finite_rings - sage: h = F2.hom([roots[0]], F4) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F2, [1,a]); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F2 = GF(5^2,'a'); a = F2.gen() + sage: F4 = GF(5^4,'b'); b = F4.gen() + sage: roots = a.charpoly().roots(ring=F4, multiplicities=False) + sage: h = F2.hom([roots[0]], F4) + sage: E = EllipticCurve(F2, [1,a]); E Elliptic Curve defined by y^2 = x^3 + x + a over Finite Field in a of size 5^2 - sage: E.change_ring(h) # optional - sage.rings.finite_rings + sage: E.change_ring(h) Elliptic Curve defined by y^2 = x^3 + x + (4*b^3+4*b^2+4*b+3) over Finite Field in b of size 5^4 """ @@ -1427,8 +1433,8 @@ def base_ring(self): EXAMPLES:: - sage: E = EllipticCurve(GF(49, 'a'), [3,5]) # optional - sage.rings.finite_rings - sage: E.base_ring() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(49, 'a'), [3,5]) # needs sage.rings.finite_rings + sage: E.base_ring() # needs sage.rings.finite_rings Finite Field in a of size 7^2 :: @@ -1660,12 +1666,12 @@ def division_polynomial_0(self, n, x=None): An example to illustrate the relationship with torsion points:: - sage: F = GF(11) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0, 2]); E # optional - sage.rings.finite_rings + sage: F = GF(11) + sage: E = EllipticCurve(F, [0, 2]); E Elliptic Curve defined by y^2 = x^3 + 2 over Finite Field of size 11 - sage: f = E.division_polynomial_0(5); f # optional - sage.rings.finite_rings + sage: f = E.division_polynomial_0(5); f 5*x^12 + x^9 + 8*x^6 + 4*x^3 + 7 - sage: f.factor() # optional - sage.rings.finite_rings + sage: f.factor() (5) * (x^2 + 5) * (x^2 + 2*x + 5) * (x^2 + 5*x + 7) * (x^2 + 7*x + 7) * (x^2 + 9*x + 5) * (x^2 + 10*x + 7) @@ -1673,10 +1679,11 @@ def division_polynomial_0(self, n, x=None): `E` are in `\GF{11^2}`, and therefore the `y`-coordinates are in `\GF{11^4}`:: - sage: K = GF(11^4, 'a') # optional - sage.rings.finite_rings - sage: X = E.change_ring(K) # optional - sage.rings.finite_rings - sage: f = X.division_polynomial_0(5) # optional - sage.rings.finite_rings - sage: x_coords = f.roots(multiplicities=False); x_coords # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(11^4, 'a') + sage: X = E.change_ring(K) + sage: f = X.division_polynomial_0(5) + sage: x_coords = f.roots(multiplicities=False); x_coords [10*a^3 + 4*a^2 + 5*a + 6, 9*a^3 + 8*a^2 + 10*a + 8, 8*a^3 + a^2 + 4*a + 10, @@ -1693,7 +1700,7 @@ def division_polynomial_0(self, n, x=None): Now we check that these are exactly the `x`-coordinates of the 5-torsion points of `E`:: - sage: for x in x_coords: # optional - sage.rings.finite_rings + sage: for x in x_coords: # needs sage.rings.finite_rings ....: assert X.lift_x(x).order() == 5 The roots of the polynomial are the `x`-coordinates of the points `P` @@ -1783,10 +1790,10 @@ def two_division_polynomial(self, x=None): sage: E = EllipticCurve('5077a1') sage: E.two_division_polynomial() 4*x^3 - 28*x + 25 - sage: E = EllipticCurve(GF(3^2,'a'), [1,1,1,1,1]) # optional - sage.rings.finite_rings - sage: E.two_division_polynomial() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(3^2,'a'), [1,1,1,1,1]) # needs sage.rings.finite_rings + sage: E.two_division_polynomial() # needs sage.rings.finite_rings x^3 + 2*x^2 + 2 - sage: E.two_division_polynomial().roots() # optional - sage.rings.finite_rings + sage: E.two_division_polynomial().roots() # needs sage.rings.finite_rings [(2, 1), (2*a, 1), (a + 2, 1)] """ return self.division_polynomial_0(-1,x) @@ -2096,11 +2103,12 @@ def _multiple_x_numerator(self, n, x=None): Check for :trac:`33156`:: - sage: E = EllipticCurve(GF(65537), [5,5]) # optional - sage.rings.finite_rings - sage: R. = E.base_field()[] # optional - sage.rings.finite_rings - sage: E._multiple_x_numerator(5, x=R.quotient(x^2).gen()) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [5,5]) + sage: R. = E.base_field()[] + sage: E._multiple_x_numerator(5, x=R.quotient(x^2).gen()) 10220*xbar + 42539 - sage: E._multiple_x_numerator(5) # optional - sage.rings.finite_rings + sage: E._multiple_x_numerator(5) x^25 + 65037*x^23 + 55137*x^22 + ... + 813*x^2 + 10220*x + 42539 """ n = Integer(n).abs() @@ -2192,11 +2200,12 @@ def _multiple_x_denominator(self, n, x=None): Check for :trac:`33156`:: - sage: E = EllipticCurve(GF(65537), [5,5]) # optional - sage.rings.finite_rings - sage: R. = E.base_field()[] # optional - sage.rings.finite_rings - sage: E._multiple_x_denominator(5, x=R.quotient(x^2).gen()) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [5,5]) + sage: R. = E.base_field()[] + sage: E._multiple_x_denominator(5, x=R.quotient(x^2).gen()) 52039*xbar + 56726 - sage: E._multiple_x_denominator(5) # optional - sage.rings.finite_rings + sage: E._multiple_x_denominator(5) 25*x^24 + 3100*x^22 + 19000*x^21 + ... + 24111*x^2 + 52039*x + 56726 """ n = Integer(n).abs() @@ -2315,14 +2324,15 @@ def multiplication_by_m(self, m, x_only=False): The following test shows that :trac:`4364` is indeed fixed:: - sage: p = next_prime(2^30-41) # optional - sage.rings.finite_rings - sage: a = GF(p)(1) # optional - sage.rings.finite_rings - sage: b = GF(p)(1) # optional - sage.rings.finite_rings - sage: E = EllipticCurve([a, b]) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: my_eval = lambda f,P: [fi(P[0],P[1]) for fi in f] # optional - sage.rings.finite_rings - sage: f = E.multiplication_by_m(2) # optional - sage.rings.finite_rings - sage: assert(E(eval(f,P)) == 2*P) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: p = next_prime(2^30 - 41) + sage: a = GF(p)(1) + sage: b = GF(p)(1) + sage: E = EllipticCurve([a, b]) + sage: P = E.random_point() + sage: my_eval = lambda f,P: [fi(P[0],P[1]) for fi in f] + sage: f = E.multiplication_by_m(2) + sage: assert(E(eval(f,P)) == 2*P) """ # Coerce the input m to be an integer m = Integer(m) @@ -2407,15 +2417,15 @@ def multiplication_by_m_isogeny(self, m): Tests for :trac:`32490`:: - sage: E = EllipticCurve(QQbar, [1,0]) # optional - sage.rings.number_field - sage: E.multiplication_by_m_isogeny(1).rational_maps() # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [1,0]) # needs sage.rings.number_field + sage: E.multiplication_by_m_isogeny(1).rational_maps() # needs sage.rings.number_field (x, y) :: - sage: E = EllipticCurve_from_j(GF(31337).random_element()) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: [E.multiplication_by_m_isogeny(m)(P) == m*P for m in (1,2,3,5,7,9)] # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(31337).random_element()) # needs sage.rings.finite_rings + sage: P = E.random_point() # needs sage.rings.finite_rings + sage: [E.multiplication_by_m_isogeny(m)(P) == m*P for m in (1,2,3,5,7,9)] # needs sage.rings.finite_rings [True, True, True, True, True, True] :: @@ -2501,15 +2511,16 @@ def frobenius_isogeny(self, n=1): EXAMPLES:: - sage: z3, = GF(13^3).gens() # optional - sage.rings.finite_rings - sage: E = EllipticCurve([z3, z3^2]) # optional - sage.rings.finite_rings - sage: E.frobenius_isogeny() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: z3, = GF(13^3).gens() + sage: E = EllipticCurve([z3, z3^2]) + sage: E.frobenius_isogeny() Frobenius isogeny of degree 13: From: Elliptic Curve defined by y^2 = x^3 + z3*x + z3^2 over Finite Field in z3 of size 13^3 To: Elliptic Curve defined by y^2 = x^3 + (5*z3^2+7*z3+11)*x + (5*z3^2+12*z3+1) over Finite Field in z3 of size 13^3 - sage: E.frobenius_isogeny(3) # optional - sage.rings.finite_rings + sage: E.frobenius_isogeny(3) Frobenius endomorphism of degree 2197 = 13^3: From: Elliptic Curve defined by y^2 = x^3 + z3*x + z3^2 over Finite Field in z3 of size 13^3 @@ -2562,8 +2573,8 @@ def isomorphism_to(self, other): We can also handle injections to different base rings:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 7) # optional - sage.rings.number_field - sage: E.isomorphism_to(E.change_ring(K)) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 7) # needs sage.rings.number_field + sage: E.isomorphism_to(E.change_ring(K)) # needs sage.rings.number_field Elliptic-curve morphism: From: Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field To: Elliptic Curve defined by y^2 + y = x^3 + (-1)*x @@ -2605,8 +2616,8 @@ def automorphisms(self, field=None): We can also find automorphisms defined over extension fields:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 3) # adjoin roots of unity # optional - sage.rings.number_field - sage: E.automorphisms(K) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 3) # adjoin roots of unity # needs sage.rings.number_field + sage: E.automorphisms(K) # needs sage.rings.number_field [Elliptic-curve endomorphism of Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^2 + 3 Via: (u,r,s,t) = (1, 0, 0, 0), @@ -2628,7 +2639,7 @@ def automorphisms(self, field=None): :: - sage: [len(EllipticCurve_from_j(GF(q,'a')(0)).automorphisms()) # optional - sage.rings.finite_rings + sage: [len(EllipticCurve_from_j(GF(q,'a')(0)).automorphisms()) # needs sage.rings.finite_rings ....: for q in [2,4,3,9,5,25,7,49]] [2, 24, 2, 12, 2, 6, 6, 6] @@ -2636,21 +2647,22 @@ def automorphisms(self, field=None): Random testing:: + sage: # needs sage.rings.finite_rings sage: p = random_prime(100) sage: k = randrange(1,30) - sage: F. = GF((p,k)) # optional - sage.rings.finite_rings - sage: while True: # optional - sage.rings.finite_rings + sage: F. = GF((p,k)) + sage: while True: ....: try: ....: E = EllipticCurve(list((F^5).random_element())) ....: except ArithmeticError: ....: continue ....: break - sage: Aut = E.automorphisms() # optional - sage.rings.finite_rings - sage: Aut[0] == E.scalar_multiplication(1) # optional - sage.rings.finite_rings + sage: Aut = E.automorphisms() + sage: Aut[0] == E.scalar_multiplication(1) True - sage: Aut[1] == E.scalar_multiplication(-1) # optional - sage.rings.finite_rings + sage: Aut[1] == E.scalar_multiplication(-1) True - sage: sorted(Aut) == Aut # optional - sage.rings.finite_rings + sage: sorted(Aut) == Aut True """ if field is not None: @@ -2689,11 +2701,12 @@ def isomorphisms(self, other, field=None): We can also find isomorphisms defined over extension fields:: - sage: E = EllipticCurve(GF(7), [0,0,0,1,1]) # optional - sage.rings.finite_rings - sage: F = EllipticCurve(GF(7), [0,0,0,1,-1]) # optional - sage.rings.finite_rings - sage: E.isomorphisms(F) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,1,1]) + sage: F = EllipticCurve(GF(7), [0,0,0,1,-1]) + sage: E.isomorphisms(F) [] - sage: E.isomorphisms(F, GF(49,'a')) # optional - sage.rings.finite_rings + sage: E.isomorphisms(F, GF(49,'a')) [Elliptic-curve morphism: From: Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field in a of size 7^2 @@ -2821,28 +2834,28 @@ def short_weierstrass_model(self, complete_cube=True): :: - sage: E = EllipticCurve(GF(3), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: E.short_weierstrass_model(complete_cube=False) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(3), [1,2,3,4,5]) + sage: E.short_weierstrass_model(complete_cube=False) Elliptic Curve defined by y^2 = x^3 + x + 2 over Finite Field of size 3 This used to be different see :trac:`3973`:: - sage: E.short_weierstrass_model() # optional - sage.rings.finite_rings + sage: E.short_weierstrass_model() Elliptic Curve defined by y^2 = x^3 + x + 2 over Finite Field of size 3 More tests in characteristic 3:: - sage: E = EllipticCurve(GF(3), [0,2,1,2,1]) # optional - sage.rings.finite_rings - sage: E.short_weierstrass_model() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(3), [0,2,1,2,1]) + sage: E.short_weierstrass_model() Traceback (most recent call last): ... ValueError: short_weierstrass_model(): no short model for Elliptic Curve defined by y^2 + y = x^3 + 2*x^2 + 2*x + 1 over Finite Field of size 3 (characteristic is 3) - sage: E.short_weierstrass_model(complete_cube=False) # optional - sage.rings.finite_rings + sage: E.short_weierstrass_model(complete_cube=False) Elliptic Curve defined by y^2 = x^3 + 2*x^2 + 2*x + 2 over Finite Field of size 3 - sage: E.short_weierstrass_model(complete_cube=False).is_isomorphic(E) # optional - sage.rings.finite_rings + sage: E.short_weierstrass_model(complete_cube=False).is_isomorphic(E) True """ from . import constructor @@ -2915,22 +2928,22 @@ def montgomery_model(self, twisted=False, morphism=False): EXAMPLES:: - sage: E = EllipticCurve(QQbar, '11a1') # optional - sage.rings.number_field - sage: E.montgomery_model() # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, '11a1') # needs sage.rings.number_field + sage: E.montgomery_model() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + (-1.953522420987248?)*x^2 + x over Algebraic Field :: - sage: E = EllipticCurve(GF(431^2), [7,7]) # optional - sage.rings.finite_rings - sage: E.montgomery_model() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(431^2), [7,7]) # needs sage.rings.finite_rings + sage: E.montgomery_model() # needs sage.rings.finite_rings Elliptic Curve defined by y^2 = x^3 + (51*z2+190)*x^2 + x over Finite Field in z2 of size 431^2 An isomorphism between the Montgomery and Weierstrass form can be obtained using the ``morphism`` parameter:: - sage: E.montgomery_model(morphism=True) # optional - sage.rings.finite_rings + sage: E.montgomery_model(morphism=True) # needs sage.rings.finite_rings (Elliptic Curve defined by y^2 = x^3 + (51*z2+190)*x^2 + x over Finite Field in z2 of size 431^2, Elliptic-curve morphism: @@ -2943,8 +2956,8 @@ def montgomery_model(self, twisted=False, morphism=False): Not all elliptic curves have a Montgomery model over their field of definition:: - sage: E = EllipticCurve(GF(257), [1,1]) # optional - sage.rings.finite_rings - sage: E.montgomery_model() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(257), [1,1]) + sage: E.montgomery_model() Traceback (most recent call last): ... ValueError: Elliptic Curve defined by y^2 = x^3 + x + 1 @@ -2952,8 +2965,8 @@ def montgomery_model(self, twisted=False, morphism=False): :: - sage: E = EllipticCurve(GF(257), [10,10]) # optional - sage.rings.finite_rings - sage: E.montgomery_model() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(257), [10,10]) + sage: E.montgomery_model() Traceback (most recent call last): ... ValueError: Elliptic Curve defined by y^2 = x^3 + 10*x + 10 @@ -2963,7 +2976,7 @@ def montgomery_model(self, twisted=False, morphism=False): admit a *twisted* Montgomery model, which can be computed by passing ``twisted=True``:: - sage: E.montgomery_model(twisted=True) # optional - sage.rings.finite_rings + sage: E.montgomery_model(twisted=True) Projective Plane Curve over Finite Field of size 257 defined by -x^3 + 8*x^2*z - 127*y^2*z - x*z^2 @@ -2977,8 +2990,8 @@ def montgomery_model(self, twisted=False, morphism=False): but can easily be emulated by mapping back and forth to the corresponding Weierstrass curve:: - sage: C, f = E.montgomery_model(twisted=True, morphism=True) # optional - sage.rings.finite_rings - sage: f # optional - sage.rings.finite_rings + sage: C, f = E.montgomery_model(twisted=True, morphism=True) + sage: f Scheme morphism: From: Elliptic Curve defined by y^2 = x^3 + 10*x + 10 over Finite Field of size 257 @@ -2986,7 +2999,7 @@ def montgomery_model(self, twisted=False, morphism=False): defined by -x^3 + 8*x^2*z - 127*y^2*z - x*z^2 Defn: Defined on coordinates by sending (x : y : z) to (x + 116*z : -y : -85*z) - sage: g = f.inverse(); g # optional - sage.rings.finite_rings + sage: g = f.inverse(); g Scheme morphism: From: Projective Plane Curve over Finite Field of size 257 defined by -x^3 + 8*x^2*z - 127*y^2*z - x*z^2 @@ -2994,39 +3007,40 @@ def montgomery_model(self, twisted=False, morphism=False): over Finite Field of size 257 Defn: Defined on coordinates by sending (x : y : z) to (-85*x - 116*z : 85*y : z) - sage: P = C(70, 8) # optional - sage.rings.finite_rings - sage: Q = C(17, 17) # optional - sage.rings.finite_rings - sage: P + Q # this doesn't work... # optional - sage.rings.finite_rings + sage: P = C(70, 8) + sage: Q = C(17, 17) + sage: P + Q # this doesn't work... Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for +: ... - sage: f(g(P) + g(Q)) # ...but this does # optional - sage.rings.finite_rings + sage: f(g(P) + g(Q)) # ...but this does (107 : 168 : 1) Using the fact that the Weil pairing satisfies `e(\psi(P),\psi(Q)) = e(P,Q)^{\deg\psi}`, even pairings can be emulated in this way (note that isomorphisms have degree `1`):: - sage: F. = GF(257^2) # optional - sage.rings.finite_rings - sage: C_ = C.change_ring(F) # optional - sage.rings.finite_rings - sage: g_ = g.change_ring(F) # optional - sage.rings.finite_rings - sage: g_(P).order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(257^2) + sage: C_ = C.change_ring(F) + sage: g_ = g.change_ring(F) + sage: g_(P).order() 12 - sage: T = C_(-7 * z2 - 57, 31 * z2 - 52, 1) # optional - sage.rings.finite_rings - sage: g_(T).order() # optional - sage.rings.finite_rings + sage: T = C_(-7 * z2 - 57, 31 * z2 - 52, 1) + sage: g_(T).order() 12 - sage: g_(P).weil_pairing(g_(T), 12) # optional - sage.rings.finite_rings + sage: g_(P).weil_pairing(g_(T), 12) 15*z2 + 204 Another alternative is to simply extend the base field enough for the curve to have an untwisted Montgomery model:: - sage: C_ = E.change_ring(F).montgomery_model(); C_ # optional - sage.rings.finite_rings + sage: C_ = E.change_ring(F).montgomery_model(); C_ # needs sage.rings.finite_rings Elliptic Curve defined by y^2 = x^3 + 249*x^2 + x over Finite Field in z2 of size 257^2 - sage: h = C.defining_polynomial().change_ring(F); h # optional - sage.rings.finite_rings + sage: h = C.defining_polynomial().change_ring(F); h # needs sage.rings.finite_rings -x^3 + 8*x^2*z - 127*y^2*z - x*z^2 - sage: C_.is_isomorphic(EllipticCurve_from_cubic(h).codomain()) # optional - sage.rings.finite_rings + sage: C_.is_isomorphic(EllipticCurve_from_cubic(h).codomain()) # needs sage.rings.finite_rings True .. SEEALSO:: @@ -3137,28 +3151,28 @@ def plot(self, xmin=None, xmax=None, components='both', **args): EXAMPLES:: sage: E = EllipticCurve([0, -1]) - sage: plot(E, rgbcolor=hue(0.7)) # optional - sage.plot + sage: plot(E, rgbcolor=hue(0.7)) # needs sage.plot Graphics object consisting of 1 graphics primitive sage: E = EllipticCurve('37a') - sage: plot(E) # optional - sage.plot + sage: plot(E) # needs sage.plot Graphics object consisting of 2 graphics primitives - sage: plot(E, xmin=25, xmax=26) # optional - sage.plot + sage: plot(E, xmin=25, xmax=26) # needs sage.plot Graphics object consisting of 2 graphics primitives With :trac:`12766` we added the components keyword:: sage: E.real_components() 2 - sage: E.plot(components='bounded') # optional - sage.plot + sage: E.plot(components='bounded') # needs sage.plot Graphics object consisting of 1 graphics primitive - sage: E.plot(components='unbounded') # optional - sage.plot + sage: E.plot(components='unbounded') # needs sage.plot Graphics object consisting of 1 graphics primitive If there is only one component then specifying components='bounded' raises a ValueError:: sage: E = EllipticCurve('9990be2') - sage: E.plot(components='bounded') # optional - sage.plot + sage: E.plot(components='bounded') # needs sage.plot Traceback (most recent call last): ... ValueError: no bounded component for this curve @@ -3166,7 +3180,7 @@ def plot(self, xmin=None, xmax=None, components='both', **args): An elliptic curve defined over the Complex Field can not be plotted:: sage: E = EllipticCurve(CC, [0,0,1,-1,0]) - sage: E.plot() # optional - sage.plot + sage: E.plot() # needs sage.plot Traceback (most recent call last): ... NotImplementedError: plotting of curves over Complex Field @@ -3350,18 +3364,20 @@ def _p_primary_torsion_basis(self, p, m=None): sage: E = EllipticCurve('11a1') sage: E._p_primary_torsion_basis(5) [[(5 : -6 : 1), 1]] + + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^4 + x^3 + 11*x^2 + 41*x + 101) # optional - sage.rings.number_field - sage: EK = E.base_extend(K) # optional - sage.rings.number_field - sage: EK._p_primary_torsion_basis(5) # long time (2s on sage.math, 2011) # optional - sage.rings.number_field + sage: K. = NumberField(x^4 + x^3 + 11*x^2 + 41*x + 101) + sage: EK = E.base_extend(K) + sage: EK._p_primary_torsion_basis(5) # long time [[(16 : 60 : 1), 1], [(t : 1/11*t^3 + 6/11*t^2 + 19/11*t + 48/11 : 1), 1]] - sage: EF = E.change_ring(GF(101)) # optional - sage.rings.finite_rings - sage: EF._p_primary_torsion_basis(5) # optional - sage.rings.finite_rings + sage: EF = E.change_ring(GF(101)) # needs sage.rings.finite_rings + sage: EF._p_primary_torsion_basis(5) # needs sage.rings.finite_rings [[(0 : 13 : 1), 1], [(5 : 5 : 1), 1]] - sage: F. = CyclotomicField(21) # optional - sage.rings.number_field - sage: E = EllipticCurve([2, -z^7, -z^7, 0, 0]) # optional - sage.rings.number_field - sage: E._p_primary_torsion_basis(7,2) # long time (8s on sage.math, 2011) # optional - sage.rings.number_field + sage: F. = CyclotomicField(21) # needs sage.rings.number_field + sage: E = EllipticCurve([2, -z^7, -z^7, 0, 0]) # needs sage.rings.number_field + sage: E._p_primary_torsion_basis(7,2) # long time # needs sage.rings.number_field [[(0 : z^7 : 1), 1], [(z^7 - z^6 + z^4 - z^3 + z^2 - 1 : z^8 - 2*z^7 + z^6 + 2*z^5 - 3*z^4 + 2*z^3 - 2*z + 2 : 1), 1]] @@ -3372,8 +3388,8 @@ def _p_primary_torsion_basis(self, p, m=None): sage: a = 804515977734860566494239770982282063895480484302363715494873 sage: b = 584772221603632866665682322899297141793188252000674256662071 - sage: E = EllipticCurve(GF(10^60+3201), [0,a,0,b,0]) # optional - sage.rings.finite_rings - sage: [t[1] for t in E._p_primary_torsion_basis(2)] # long time (3s on sage.math, 2011) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(10^60 + 3201), [0,a,0,b,0]) # needs sage.rings.finite_rings + sage: [t[1] for t in E._p_primary_torsion_basis(2)] # long time, needs sage.rings.finite_rings [16, 1] """ p = Integer(p) @@ -3526,18 +3542,19 @@ def pari_curve(self): EXAMPLES:: + sage: # needs sage.libs.pari sage: E = EllipticCurve([RR(0), RR(0), RR(1), RR(-1), RR(0)]) - sage: e = E.pari_curve() # optional - sage.libs.pari - sage: type(e) # optional - sage.libs.pari + sage: e = E.pari_curve() + sage: type(e) <... 'cypari2.gen.Gen'> - sage: e.type() # optional - sage.libs.pari + sage: e.type() 't_VEC' - sage: e.disc() # optional - sage.libs.pari + sage: e.disc() 37.0000000000000 Over a finite field:: - sage: EllipticCurve(GF(41), [2,5]).pari_curve() # optional - sage.libs.pari sage.rings.finite_rings + sage: EllipticCurve(GF(41), [2,5]).pari_curve() # needs sage.libs.pari [Mod(0, 41), Mod(0, 41), Mod(0, 41), Mod(2, 41), Mod(5, 41), Mod(0, 41), Mod(4, 41), Mod(20, 41), Mod(37, 41), Mod(27, 41), Mod(26, 41), Mod(4, 41), Mod(11, 41), @@ -3546,19 +3563,20 @@ def pari_curve(self): Over a `p`-adic field:: - sage: Qp = pAdicField(5, prec=3) # optional - sage.libs.pari sage.rings.padics - sage: E = EllipticCurve(Qp, [3, 4]) # optional - sage.libs.pari sage.rings.padics - sage: E.pari_curve() # optional - sage.libs.pari sage.rings.padics + sage: # needs sage.libs.pari sage.rings.padics + sage: Qp = pAdicField(5, prec=3) + sage: E = EllipticCurve(Qp, [3, 4]) + sage: E.pari_curve() [0, 0, 0, 3, 4, 0, 6, 16, -9, -144, -3456, -8640, 1728/5, Vecsmall([2]), [O(5^3)], [0, 0]] - sage: E.j_invariant() # optional - sage.libs.pari sage.rings.padics + sage: E.j_invariant() 3*5^-1 + O(5) Over a number field:: - sage: K. = QuadraticField(2) # optional - sage.libs.pari sage.rings.number_field - sage: E = EllipticCurve([1,a]) # optional - sage.libs.pari sage.rings.number_field - sage: E.pari_curve() # optional - sage.libs.pari sage.rings.number_field + sage: K. = QuadraticField(2) # needs sage.libs.pari sage.rings.number_field + sage: E = EllipticCurve([1,a]) # needs sage.libs.pari sage.rings.number_field + sage: E.pari_curve() # needs sage.libs.pari sage.rings.number_field [0, 0, 0, Mod(1, y^2 - 2), Mod(y, y^2 - 2), 0, Mod(2, y^2 - 2), Mod(4*y, y^2 - 2), Mod(-1, y^2 - 2), Mod(-48, y^2 - 2), Mod(-864*y, y^2 - 2), @@ -3572,10 +3590,10 @@ def pari_curve(self): PARI no longer requires that the `j`-invariant has negative `p`-adic valuation:: - sage: E = EllipticCurve(Qp,[1, 1]) # optional - sage.libs.pari sage.rings.padics - sage: E.j_invariant() # the j-invariant is a p-adic integer # optional - sage.libs.pari sage.rings.padics + sage: E = EllipticCurve(Qp,[1, 1]) # needs sage.libs.pari sage.rings.padics + sage: E.j_invariant() # the j-invariant is a p-adic integer # needs sage.libs.pari sage.rings.padics 2 + 4*5^2 + O(5^3) - sage: E.pari_curve() # optional - sage.libs.pari sage.rings.padics + sage: E.pari_curve() # needs sage.libs.pari sage.rings.padics [0, 0, 0, 1, 1, 0, 2, 4, -1, -48, -864, -496, 6912/31, Vecsmall([2]), [O(5^3)], [0, 0]] """ @@ -3596,12 +3614,12 @@ def __pari__(self): EXAMPLES:: sage: E = EllipticCurve('11a1') - sage: pari(E) # optional - sage.libs.pari + sage: pari(E) # needs sage.libs.pari [0, -1, 1, -10, -20, -4, -20, -79, -21, 496, 20008, -161051, -122023936/161051, Vecsmall([1]), [Vecsmall([64, -1])], [0, 0, 0, 0, 0, 0, 0, 0]] Over a finite field:: - sage: EllipticCurve(GF(2), [0,0,1,1,1]).__pari__() # optional - sage.libs.pari sage.rings.finite_rings + sage: EllipticCurve(GF(2), [0,0,1,1,1]).__pari__() # needs sage.libs.pari [0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, Vecsmall([4]), [1, [[Vecsmall([0, 1]), Vecsmall([0, 1]), Vecsmall([0, 1])], Vecsmall([0, 1]), [Vecsmall([0, 1]), Vecsmall([0]), Vecsmall([0]), Vecsmall([0])]]], [0, 0, 0, 0]] """ return self.pari_curve() diff --git a/src/sage/schemes/elliptic_curves/ell_local_data.py b/src/sage/schemes/elliptic_curves/ell_local_data.py index 2b9bd9d2ab4..11a0e9db661 100644 --- a/src/sage/schemes/elliptic_curves/ell_local_data.py +++ b/src/sage/schemes/elliptic_curves/ell_local_data.py @@ -16,6 +16,7 @@ EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + 1) sage: E = EllipticCurve([(2+i)^2, (2+i)^7]) @@ -45,6 +46,7 @@ Kodaira Symbol: II Tamagawa Number: 1 + sage: # needs sage.rings.number_field sage: EK = E.base_extend(K) sage: EK.local_data(1+i) Local data at Fractional ideal (i + 1): @@ -61,6 +63,8 @@ sage: E = EllipticCurve([0,8]) sage: E.is_minimal() True + + sage: # needs sage.rings.number_field sage: EK = E.base_extend(K) sage: da = EK.local_data(1+i) sage: da.minimal_model() @@ -120,7 +124,7 @@ class EllipticCurveLocalData(SageObject): - ``P`` -- a prime ideal of the field, or a prime integer if the field is `\QQ`. - - ``proof`` (bool)-- if True, only use provably correct + - ``proof`` (bool) -- if ``True``, only use provably correct methods (default controlled by global proof module). Note that the proof module is number_field, not elliptic_curves, since the functions that actually need the flag are in @@ -332,6 +336,7 @@ def minimal_model(self, reduce=True): To demonstrate the behaviour of the parameter ``reduce``:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 + x + 1) sage: E = EllipticCurve(K, [0, 0, a, 0, 1]) @@ -356,6 +361,7 @@ def minimal_model(self, reduce=True): :trac:`14476`:: + sage: # needs sage.rings.number_field sage: t = QQ['t'].0 sage: K. = NumberField(t^4 - t^3-3*t^2 - t +1) sage: E = EllipticCurve([-2*g^3 + 10/3*g^2 + 3*g - 2/3, @@ -517,6 +523,7 @@ def bad_reduction_type(self): sage: [(p,E.local_data(p).bad_reduction_type()) for p in prime_range(15)] [(2, -1), (3, None), (5, None), (7, 1), (11, None), (13, None)] + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -536,6 +543,7 @@ def has_good_reduction(self): sage: [(p,E.local_data(p).has_good_reduction()) for p in prime_range(15)] [(2, False), (3, True), (5, True), (7, False), (11, True), (13, True)] + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -558,6 +566,7 @@ def has_bad_reduction(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -585,6 +594,7 @@ def has_multiplicative_reduction(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -607,6 +617,7 @@ def has_split_multiplicative_reduction(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -631,6 +642,7 @@ def has_nonsplit_multiplicative_reduction(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -653,6 +665,7 @@ def has_additive_reduction(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: P17a, P17b = [P for P,e in K.factor(17)] @@ -695,16 +708,14 @@ def _tate(self, proof=None, globally=False): EXAMPLES (this raised a type error in sage prior to 4.4.4, see :trac:`7930`) :: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('99d1') - sage: R. = QQ[] sage: K. = NumberField(X^3 + X^2 - 2*X - 1) sage: L. = NumberField(X^3 + X^2 - 36*X - 4) - sage: EK = E.base_extend(K) sage: toK = EK.torsion_order() sage: da = EK.local_data() # indirect doctest - sage: EL = E.base_extend(L) sage: da = EL.local_data() # indirect doctest @@ -712,6 +723,7 @@ def _tate(self, proof=None, globally=False): The following example shows that the bug at :trac:`9324` is fixed:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - x + 6) sage: E = EllipticCurve([0,0,0,-53160*a-43995,-5067640*a+19402006]) @@ -720,14 +732,16 @@ def _tate(self, proof=None, globally=False): The following example shows that the bug at :trac:`9417` is fixed:: - sage: K. = NumberField(x^2+18*x+1) + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 18*x + 1) sage: E = EllipticCurve(K, [0, -36, 0, 320, 0]) sage: E.tamagawa_number(K.ideal(2)) 4 This is to show that the bug :trac:`11630` is fixed. (The computation of the class group would produce a warning):: - sage: K. = NumberField(x^7-2*x+177) + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^7 - 2*x + 177) sage: E = EllipticCurve([0,1,0,t,t]) sage: P = K.ideal(2,t^3 + t + 1) sage: E.local_data(P).kodaira_symbol() @@ -1141,6 +1155,8 @@ def check_prime(K, P): 3 sage: check_prime(QQ,ZZ.ideal(31)) 31 + + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 5) sage: check_prime(K, a) diff --git a/src/sage/schemes/elliptic_curves/ell_modular_symbols.py b/src/sage/schemes/elliptic_curves/ell_modular_symbols.py index 11c0bc4b978..243df1d23f0 100644 --- a/src/sage/schemes/elliptic_curves/ell_modular_symbols.py +++ b/src/sage/schemes/elliptic_curves/ell_modular_symbols.py @@ -129,8 +129,8 @@ def modular_symbol_space(E, sign, base_ring, bound=None): sage: from sage.schemes.elliptic_curves.ell_modular_symbols import modular_symbol_space sage: E = EllipticCurve('11a1') - sage: M = modular_symbol_space(E, -1, GF(37)) # optional - sage.rings.finite_rings - sage: M # optional - sage.rings.finite_rings + sage: M = modular_symbol_space(E, -1, GF(37)) + sage: M Modular Symbols space of dimension 1 for Gamma_0(11) of weight 2 with sign -1 over Finite Field of size 37 """ diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py index e01d7436d94..54777488572 100644 --- a/src/sage/schemes/elliptic_curves/ell_number_field.py +++ b/src/sage/schemes/elliptic_curves/ell_number_field.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.number_field +# sage.doctest: needs sage.rings.number_field r""" Elliptic curves over number fields diff --git a/src/sage/schemes/elliptic_curves/ell_padic_field.py b/src/sage/schemes/elliptic_curves/ell_padic_field.py index 2ac42b1b7e7..ba796d1b75b 100644 --- a/src/sage/schemes/elliptic_curves/ell_padic_field.py +++ b/src/sage/schemes/elliptic_curves/ell_padic_field.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.padics """ Elliptic curves over padic fields """ @@ -33,9 +34,10 @@ class EllipticCurve_padic_field(EllipticCurve_field, HyperellipticCurve_padic_fi EXAMPLES:: - sage: Qp=pAdicField(17) - sage: E=EllipticCurve(Qp,[2,3]); E - Elliptic Curve defined by y^2 = x^3 + (2+O(17^20))*x + (3+O(17^20)) over 17-adic Field with capped relative precision 20 + sage: Qp = pAdicField(17) + sage: E = EllipticCurve(Qp,[2,3]); E + Elliptic Curve defined by y^2 = x^3 + (2+O(17^20))*x + (3+O(17^20)) + over 17-adic Field with capped relative precision 20 sage: E == loads(dumps(E)) True """ diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py index 0b6d93a117a..c6f5c509d5d 100644 --- a/src/sage/schemes/elliptic_curves/ell_point.py +++ b/src/sage/schemes/elliptic_curves/ell_point.py @@ -32,36 +32,39 @@ An example over a number field:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [1,0,0,0,-1]) # optional - sage.rings.number_field - sage: P = E(0,i); P # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve(K, [1,0,0,0,-1]) + sage: P = E(0,i); P (0 : i : 1) - sage: P.order() # optional - sage.rings.number_field + sage: P.order() +Infinity - sage: 101*P - 100*P == P # optional - sage.rings.number_field + sage: 101*P - 100*P == P True An example over a finite field:: - sage: K. = GF((101,3)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [1,0,0,0,-1]) # optional - sage.rings.finite_rings - sage: P = E(40*a^2 + 69*a + 84 , 58*a^2 + 73*a + 45) # optional - sage.rings.finite_rings - sage: P.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF((101,3)) + sage: E = EllipticCurve(K, [1,0,0,0,-1]) + sage: P = E(40*a^2 + 69*a + 84 , 58*a^2 + 73*a + 45) + sage: P.order() 1032210 - sage: E.cardinality() # optional - sage.rings.finite_rings + sage: E.cardinality() 1032210 Arithmetic with a point over an extension of a finite field:: - sage: k. = GF((5,2)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k,[1,0]); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF((5,2)) + sage: E = EllipticCurve(k,[1,0]); E Elliptic Curve defined by y^2 = x^3 + x over Finite Field in a of size 5^2 - sage: P = E([a,2*a+4]) # optional - sage.rings.finite_rings - sage: 5*P # optional - sage.rings.finite_rings + sage: P = E([a,2*a+4]) + sage: 5*P (2*a + 3 : 2*a : 1) - sage: P*5 # optional - sage.rings.finite_rings + sage: P*5 (2*a + 3 : 2*a : 1) - sage: P + P + P + P + P # optional - sage.rings.finite_rings + sage: P + P + P + P + P (2*a + 3 : 2*a : 1) :: @@ -169,7 +172,7 @@ class EllipticCurvePoint_field(SchemeMorphism_point_abelian_variety_field): (0 : 0 : 1) sage: E(0,0) # brackets are optional (0 : 0 : 1) - sage: E([GF(5)(0), 0]) # entries are coerced # optional - sage.rings.finite_rings + sage: E([GF(5)(0), 0]) # entries are coerced (0 : 0 : 1) sage: E(0.000, 0) @@ -188,14 +191,15 @@ class EllipticCurvePoint_field(SchemeMorphism_point_abelian_variety_field): Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1,0,-160,308]) # optional - sage.rings.number_field - sage: P = E(26, -120) # optional - sage.rings.number_field - sage: Q = E(2+12*i, -36+48*i) # optional - sage.rings.number_field - sage: P.order() == Q.order() == 4 # long time (3s) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,1,0,-160,308]) + sage: P = E(26, -120) + sage: Q = E(2+12*i, -36+48*i) + sage: P.order() == Q.order() == 4 # long time True - sage: 2*P == 2*Q # optional - sage.rings.number_field + sage: 2*P == 2*Q False :: @@ -231,14 +235,14 @@ class EllipticCurvePoint_field(SchemeMorphism_point_abelian_variety_field): sage: P = E(0,1) sage: P.domain() Spectrum of Rational Field - sage: K. = NumberField(x^2 - 3, 'a') # optional - sage.rings.number_field - sage: P = E.base_extend(K)(1,a) # optional - sage.rings.number_field - sage: P.domain() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 3, 'a') # needs sage.rings.number_field + sage: P = E.base_extend(K)(1,a) # needs sage.rings.number_field + sage: P.domain() # needs sage.rings.number_field Spectrum of Number Field in a with defining polynomial x^2 - 3 - sage: P.codomain() # optional - sage.rings.number_field + sage: P.codomain() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + x + 1 over Number Field in a with defining polynomial x^2 - 3 - sage: P.codomain() == P.curve() # optional - sage.rings.number_field + sage: P.codomain() == P.curve() # needs sage.rings.number_field True """ def __init__(self, curve, v, check=True): @@ -414,18 +418,18 @@ def __pari__(self): Try the same over a finite field:: - sage: E = EllipticCurve(GF(11), [0,0,0,3,0]) # optional - sage.rings.finite_rings - sage: O = E(0) # optional - sage.rings.finite_rings - sage: P = E.point([1,2]) # optional - sage.rings.finite_rings - sage: O.__pari__() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(11), [0,0,0,3,0]) + sage: O = E(0) + sage: P = E.point([1,2]) + sage: O.__pari__() [0] - sage: P.__pari__() # optional - sage.rings.finite_rings + sage: P.__pari__() [Mod(1, 11), Mod(2, 11)] We no longer need to explicitly call ``pari(O)`` and ``pari(P)`` after :trac:`11868`:: - sage: pari(E).elladd(O, P) # optional - sage.rings.finite_rings + sage: pari(E).elladd(O, P) [Mod(1, 11), Mod(2, 11)] """ if self[2]: @@ -448,9 +452,9 @@ def scheme(self): sage: P.scheme() == P.curve() True sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - 3,'a') # optional - sage.rings.number_field - sage: P = E.base_extend(K)(1, a) # optional - sage.rings.number_field - sage: P.scheme() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 3,'a') # needs sage.rings.number_field + sage: P = E.base_extend(K)(1, a) # needs sage.rings.number_field + sage: P.scheme() # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + x + 1 over Number Field in a with defining polynomial x^2 - 3 """ @@ -606,7 +610,7 @@ def plot(self, **args): sage: E = EllipticCurve('389a') sage: P = E([-1,1]) - sage: P.plot(pointsize=30, rgbcolor=(1,0,0)) # optional - sage.plot + sage: P.plot(pointsize=30, rgbcolor=(1,0,0)) # needs sage.plot Graphics object consisting of 1 graphics primitive """ from sage.plot.point import point @@ -807,43 +811,45 @@ def is_divisible_by(self, m): A finite field example:: - sage: E = EllipticCurve(GF(101), [23,34]) # optional - sage.rings.finite_rings - sage: E.cardinality().factor() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(101), [23,34]) + sage: E.cardinality().factor() 2 * 53 - sage: Set([T.order() for T in E.points()]) # optional - sage.rings.finite_rings + sage: Set([T.order() for T in E.points()]) {1, 106, 2, 53} - sage: len([T for T in E.points() if T.is_divisible_by(2)]) # optional - sage.rings.finite_rings + sage: len([T for T in E.points() if T.is_divisible_by(2)]) 53 - sage: len([T for T in E.points() if T.is_divisible_by(3)]) # optional - sage.rings.finite_rings + sage: len([T for T in E.points() if T.is_divisible_by(3)]) 106 TESTS: This shows that the bug reported at :trac:`10076` is fixed:: - sage: K = QuadraticField(8,'a') # optional - sage.rings.number_field - sage: E = EllipticCurve([K(0),0,0,-1,0]) # optional - sage.rings.number_field - sage: P = E([-1,0]) # optional - sage.rings.number_field - sage: P.is_divisible_by(2) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(8,'a') + sage: E = EllipticCurve([K(0),0,0,-1,0]) + sage: P = E([-1,0]) + sage: P.is_divisible_by(2) False - sage: P.division_points(2) # optional - sage.rings.number_field + sage: P.division_points(2) [] Note that it is not sufficient to test that ``self.division_points(m,poly_only=True)`` has roots:: - sage: P.division_points(2, poly_only=True).roots() # optional - sage.rings.number_field + sage: P.division_points(2, poly_only=True).roots() # needs sage.rings.number_field [(1/2*a - 1, 1), (-1/2*a - 1, 1)] - sage: tor = E.torsion_points(); len(tor) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: tor = E.torsion_points(); len(tor) 8 - sage: [T.order() for T in tor] # optional - sage.rings.number_field + sage: [T.order() for T in tor] [2, 4, 4, 2, 1, 2, 4, 4] - sage: all(T.is_divisible_by(3) for T in tor) # optional - sage.rings.number_field + sage: all(T.is_divisible_by(3) for T in tor) True - sage: sorted(T for T in tor if T.is_divisible_by(2)) # optional - sage.rings.number_field + sage: sorted(T for T in tor if T.is_divisible_by(2)) [(0 : 1 : 0), (1 : 0 : 1)] - sage: sorted(Set([2*T for T in tor])) # optional - sage.rings.number_field + sage: sorted(Set([2*T for T in tor])) [(0 : 1 : 0), (1 : 0 : 1)] """ # Coerce the input m to an integer @@ -938,64 +944,68 @@ def division_points(self, m, poly_only=False): We create a curve over a non-prime finite field with group of order `18`:: - sage: k. = GF((5,2)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,2+a,3,4*a,2]) # optional - sage.rings.finite_rings - sage: P = E([3, 3*a+4]) # optional - sage.rings.finite_rings - sage: factor(E.order()) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF((5,2)) + sage: E = EllipticCurve(k, [1,2+a,3,4*a,2]) + sage: P = E([3, 3*a+4]) + sage: factor(E.order()) 2 * 3^2 - sage: P.order() # optional - sage.rings.finite_rings + sage: P.order() 9 We find the `1`-division points as a consistency check -- there is just one, of course:: - sage: P.division_points(1) # optional - sage.rings.finite_rings + sage: P.division_points(1) # needs sage.rings.finite_rings [(3 : 3*a + 4 : 1)] The point `P` has order coprime to 2 but divisible by 3, so:: - sage: P.division_points(2) # optional - sage.rings.finite_rings + sage: P.division_points(2) # needs sage.rings.finite_rings [(2*a + 1 : 3*a + 4 : 1), (3*a + 1 : a : 1)] We check that each of the 2-division points works as claimed:: - sage: [2*Q for Q in P.division_points(2)] # optional - sage.rings.finite_rings + sage: [2*Q for Q in P.division_points(2)] # needs sage.rings.finite_rings [(3 : 3*a + 4 : 1), (3 : 3*a + 4 : 1)] Some other checks:: - sage: P.division_points(3) # optional - sage.rings.finite_rings + sage: P.division_points(3) # needs sage.rings.finite_rings [] - sage: P.division_points(4) # optional - sage.rings.finite_rings + sage: P.division_points(4) # needs sage.rings.finite_rings [(0 : 3*a + 2 : 1), (1 : 0 : 1)] - sage: P.division_points(5) # optional - sage.rings.finite_rings + sage: P.division_points(5) # needs sage.rings.finite_rings [(1 : 1 : 1)] An example over a number field (see :trac:`3383`):: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('19a1') - sage: K. = NumberField(x^9 - 3*x^8 - 4*x^7 + 16*x^6 - 3*x^5 # optional - sage.rings.number_field + sage: x = polygen(ZZ, 'x') + sage: K. = NumberField(x^9 - 3*x^8 - 4*x^7 + 16*x^6 - 3*x^5 ....: - 21*x^4 + 5*x^3 + 7*x^2 - 7*x + 1) - sage: EK = E.base_extend(K) # optional - sage.rings.number_field - sage: E(0).division_points(3) # optional - sage.rings.number_field + sage: EK = E.base_extend(K) + sage: E(0).division_points(3) [(0 : 1 : 0), (5 : -10 : 1), (5 : 9 : 1)] - sage: EK(0).division_points(3) # optional - sage.rings.number_field + sage: EK(0).division_points(3) [(0 : 1 : 0), (5 : 9 : 1), (5 : -10 : 1)] - sage: E(0).division_points(9) # optional - sage.rings.number_field + sage: E(0).division_points(9) [(0 : 1 : 0), (5 : -10 : 1), (5 : 9 : 1)] - sage: EK(0).division_points(9) # optional - sage.rings.number_field + sage: EK(0).division_points(9) [(0 : 1 : 0), (5 : 9 : 1), (5 : -10 : 1), (-150/121*t^8 + 414/121*t^7 + 1481/242*t^6 - 2382/121*t^5 - 103/242*t^4 + 629/22*t^3 - 367/242*t^2 - 1307/121*t + 625/121 : 35/484*t^8 - 133/242*t^7 + 445/242*t^6 - 799/242*t^5 + 373/484*t^4 + 113/22*t^3 - 2355/484*t^2 - 753/242*t + 1165/484 : 1), (-150/121*t^8 + 414/121*t^7 + 1481/242*t^6 - 2382/121*t^5 - 103/242*t^4 + 629/22*t^3 - 367/242*t^2 - 1307/121*t + 625/121 : -35/484*t^8 + 133/242*t^7 - 445/242*t^6 + 799/242*t^5 - 373/484*t^4 - 113/22*t^3 + 2355/484*t^2 + 753/242*t - 1649/484 : 1), (-1383/484*t^8 + 970/121*t^7 + 3159/242*t^6 - 5211/121*t^5 + 37/484*t^4 + 654/11*t^3 - 909/484*t^2 - 4831/242*t + 6791/484 : 927/121*t^8 - 5209/242*t^7 - 8187/242*t^6 + 27975/242*t^5 - 1147/242*t^4 - 1729/11*t^3 + 1566/121*t^2 + 12873/242*t - 10871/242 : 1), (-1383/484*t^8 + 970/121*t^7 + 3159/242*t^6 - 5211/121*t^5 + 37/484*t^4 + 654/11*t^3 - 909/484*t^2 - 4831/242*t + 6791/484 : -927/121*t^8 + 5209/242*t^7 + 8187/242*t^6 - 27975/242*t^5 + 1147/242*t^4 + 1729/11*t^3 - 1566/121*t^2 - 12873/242*t + 10629/242 : 1), (-4793/484*t^8 + 6791/242*t^7 + 10727/242*t^6 - 18301/121*t^5 + 2347/484*t^4 + 2293/11*t^3 - 7311/484*t^2 - 17239/242*t + 26767/484 : 30847/484*t^8 - 21789/121*t^7 - 34605/121*t^6 + 117164/121*t^5 - 10633/484*t^4 - 29437/22*t^3 + 39725/484*t^2 + 55428/121*t - 176909/484 : 1), (-4793/484*t^8 + 6791/242*t^7 + 10727/242*t^6 - 18301/121*t^5 + 2347/484*t^4 + 2293/11*t^3 - 7311/484*t^2 - 17239/242*t + 26767/484 : -30847/484*t^8 + 21789/121*t^7 + 34605/121*t^6 - 117164/121*t^5 + 10633/484*t^4 + 29437/22*t^3 - 39725/484*t^2 - 55428/121*t + 176425/484 : 1)] TESTS: Check that :trac:`24844` is fixed:: - sage: p = next_prime(1000000) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(GF(p), 123, 456) # optional - sage.rings.finite_rings - sage: pts = E(0).division_points(3) # optional - sage.rings.finite_rings - sage: P = pts[1]; P # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: p = next_prime(1000000) + sage: E = EllipticCurve(GF(p), 123, 456) + sage: pts = E(0).division_points(3) + sage: P = pts[1]; P (389063 : 124244 : 1) - sage: P._order # optional - sage.rings.finite_rings + sage: P._order 3 When we successfully divide a point known to have infinite @@ -1215,14 +1225,14 @@ def set_order(self, value=None, *, multiple=None, check=True): :: - sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 # optional - sage.rings.finite_rings - sage: G = E(5, 0) # optional - sage.rings.finite_rings - sage: G.set_order(2) # optional - sage.rings.finite_rings - sage: 2*G # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 + sage: G = E(5, 0) + sage: G.set_order(2) + sage: 2*G (0 : 1 : 0) - sage: G = E(0, 6) # optional - sage.rings.finite_rings - sage: G.set_order(multiple=12) # optional - sage.rings.finite_rings - sage: G._order # optional - sage.rings.finite_rings + sage: G = E(0, 6) + sage: G.set_order(multiple=12) + sage: G._order 3 We now give a more interesting case, the NIST-P521 curve. Its @@ -1231,17 +1241,18 @@ def set_order(self, value=None, *, multiple=None, check=True): :: + sage: # needs sage.rings.finite_rings sage: p = 2^521 - 1 sage: prev_proof_state = proof.arithmetic() sage: proof.arithmetic(False) # turn off primality checking - sage: F = GF(p) # optional - sage.rings.finite_rings + sage: F = GF(p) sage: A = p - 3 sage: B = 1093849038073734274511112390766805569936207598951683748994586394495953116150735016013708737573759623248592132296706313309438452531591012912142327488478985984 sage: q = 6864797660130609714981900799081393217269435300143305409394463459185543183397655394245057746333217197532963996371363321113864768612440380340372808892707005449 - sage: E = EllipticCurve([F(A), F(B)]) # optional - sage.rings.finite_rings - sage: G = E.random_point() # optional - sage.rings.finite_rings - sage: G.set_order(q) # optional - sage.rings.finite_rings - sage: G.order() * G # This takes practically no time. # optional - sage.rings.finite_rings + sage: E = EllipticCurve([F(A), F(B)]) + sage: G = E.random_point() + sage: G.set_order(q) + sage: G.order() * G # This takes practically no time. (0 : 1 : 0) sage: proof.arithmetic(prev_proof_state) # restore state @@ -1271,13 +1282,14 @@ def set_order(self, value=None, *, multiple=None, check=True): It is an error to pass a ``value`` equal to `0`:: - sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 # optional - sage.rings.finite_rings - sage: G = E.random_point() # optional - sage.rings.finite_rings - sage: G.set_order(0) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 + sage: G = E.random_point() + sage: G.set_order(0) Traceback (most recent call last): ... ValueError: Value 0 illegal for point order - sage: G.set_order(1000) # optional - sage.rings.finite_rings + sage: G.set_order(1000) Traceback (most recent call last): ... ValueError: Value 1000 illegal: outside max Hasse bound @@ -1286,9 +1298,9 @@ def set_order(self, value=None, *, multiple=None, check=True): order of this point. How unlikely is determined by the factorization of the actual order, and the actual group structure:: - sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 # optional - sage.rings.finite_rings - sage: G = E(5, 0) # G has order 2 # optional - sage.rings.finite_rings - sage: G.set_order(11) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 + sage: G = E(5, 0) # G has order 2 + sage: G.set_order(11) Traceback (most recent call last): ... ValueError: Value 11 illegal: 11 * (5 : 0 : 1) is not the identity @@ -1296,10 +1308,10 @@ def set_order(self, value=None, *, multiple=None, check=True): However, ``set_order`` can be fooled. For instance, the order can be set to a multiple the actual order:: - sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 # optional - sage.rings.finite_rings - sage: G = E(5, 0) # G has order 2 # optional - sage.rings.finite_rings - sage: G.set_order(8) # optional - sage.rings.finite_rings - sage: G.order() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0, 1]) # This curve has order 12 + sage: G = E(5, 0) # G has order 2 + sage: G.set_order(8) + sage: G.order() 8 TESTS: @@ -1375,27 +1387,28 @@ def _line_(self, R, Q): EXAMPLES:: - sage: F. = GF((2,5)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F,[0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: P = E(a^4 + 1, a^3) # optional - sage.rings.finite_rings - sage: Q = E(a^4, a^4 + a^3) # optional - sage.rings.finite_rings - sage: O = E(0) # optional - sage.rings.finite_rings - sage: P._line_(P,-2*P) == 0 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF((2,5)) + sage: E = EllipticCurve(F,[0,0,1,1,1]) + sage: P = E(a^4 + 1, a^3) + sage: Q = E(a^4, a^4 + a^3) + sage: O = E(0) + sage: P._line_(P,-2*P) == 0 True - sage: P._line_(Q,-(P+Q)) == 0 # optional - sage.rings.finite_rings + sage: P._line_(Q,-(P+Q)) == 0 True - sage: O._line_(O,Q) == F(1) # optional - sage.rings.finite_rings + sage: O._line_(O,Q) == F(1) True - sage: P._line_(O,Q) == a^4 - a^4 + 1 # optional - sage.rings.finite_rings + sage: P._line_(O,Q) == a^4 - a^4 + 1 True - sage: P._line_(13*P,Q) == a^4 # optional - sage.rings.finite_rings + sage: P._line_(13*P,Q) == a^4 True - sage: P._line_(P,Q) == a^4 + a^3 + a^2 + 1 # optional - sage.rings.finite_rings + sage: P._line_(P,Q) == a^4 + a^3 + a^2 + 1 True See :trac:`7116`:: - sage: P._line_ (Q,O) # optional - sage.rings.finite_rings + sage: P._line_ (Q,O) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: Q must be nonzero. @@ -1453,120 +1466,124 @@ def _miller_(self, Q, n): EXAMPLES:: - sage: F. = GF((2,5)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: P = E(a^4 + 1, a^3) # optional - sage.rings.finite_rings - sage: Fx. = GF((2,(4*5))) # optional - sage.rings.finite_rings - sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: phi = Hom(F,Fx)(F.gen().minpoly().roots(Fx)[0][0]) # optional - sage.rings.finite_rings - sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) # optional - sage.rings.finite_rings - sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF((2,5)) + sage: E = EllipticCurve(F, [0,0,1,1,1]) + sage: P = E(a^4 + 1, a^3) + sage: Fx. = GF((2,(4*5))) + sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) + sage: phi = Hom(F,Fx)(F.gen().minpoly().roots(Fx)[0][0]) + sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) + sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, ....: b^18 + b^13 + b^10 + b^8 + b^5 + b^4 + b^3 + b) - sage: Px._miller_(Qx,41) == b^17 + b^13 + b^12 + b^9 + b^8 + b^6 + b^4 + 1 # optional - sage.rings.finite_rings + sage: Px._miller_(Qx,41) == b^17 + b^13 + b^12 + b^9 + b^8 + b^6 + b^4 + 1 True - sage: Qx._miller_(Px,41) == b^13 + b^10 + b^8 + b^7 + b^6 + b^5 # optional - sage.rings.finite_rings + sage: Qx._miller_(Px,41) == b^13 + b^10 + b^8 + b^7 + b^6 + b^5 True - sage: P._miller_(E(0),41) # optional - sage.rings.finite_rings + sage: P._miller_(E(0),41) Traceback (most recent call last): ... ValueError: Q must be nonzero. An example of even order:: - sage: F. = GF((19,4)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [-1,0]) # optional - sage.rings.finite_rings - sage: P = E(15*a^3 + 17*a^2 + 14*a + 13,16*a^3 + 7*a^2 + a + 18) # optional - sage.rings.finite_rings - sage: Q = E(10*a^3 + 16*a^2 + 4*a + 2, 6*a^3 + 4*a^2 + 3*a + 2) # optional - sage.rings.finite_rings - sage: x = P.weil_pairing(Q, 360) # optional - sage.rings.finite_rings - sage: x^360 == F(1) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF((19,4)) + sage: E = EllipticCurve(F, [-1,0]) + sage: P = E(15*a^3 + 17*a^2 + 14*a + 13,16*a^3 + 7*a^2 + a + 18) + sage: Q = E(10*a^3 + 16*a^2 + 4*a + 2, 6*a^3 + 4*a^2 + 3*a + 2) + sage: x = P.weil_pairing(Q, 360) + sage: x^360 == F(1) True You can use the _miller_ function on linearly dependent points, but with the risk of a dividing with zero:: - sage: Px._miller_(2*Px, 41) # optional - sage.rings.finite_rings + sage: Px._miller_(2*Px, 41) # needs sage.rings.finite_rings Traceback (most recent call last): ... ZeroDivisionError: division by zero in finite field A small example of embedding degree 6:: - sage: q = 401; F = GF(q); a = 146; b = 400; k = 6 # optional - sage.rings.finite_rings - sage: E = EllipticCurve([F(a), F(b)]) # optional - sage.rings.finite_rings - sage: R. = F[] # optional - sage.rings.finite_rings - sage: K. = GF(q^k, modulus=x^6 + 4*x^4 + 115*x^3 + 81*x^2 + 51*x + 3) # optional - sage.rings.finite_rings - sage: EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = E([F(338), F(227)]) # optional - sage.rings.finite_rings - sage: Q_x = 333*a^5 + 391*a^4 + 160*a^3 + 335*a^2 + 71*a + 93 # optional - sage.rings.finite_rings - sage: Q_y = 343*a^5 + 273*a^4 + 26*a^3 + 342*a^2 + 340*a + 210 # optional - sage.rings.finite_rings - sage: Q = EK([Q_x, Q_y]) # optional - sage.rings.finite_rings - sage: P._miller_(Q, 127) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: q = 401; F = GF(q); a = 146; b = 400; k = 6 + sage: E = EllipticCurve([F(a), F(b)]) + sage: R. = F[] + sage: K. = GF(q^k, modulus=x^6 + 4*x^4 + 115*x^3 + 81*x^2 + 51*x + 3) + sage: EK = E.base_extend(K) + sage: P = E([F(338), F(227)]) + sage: Q_x = 333*a^5 + 391*a^4 + 160*a^3 + 335*a^2 + 71*a + 93 + sage: Q_y = 343*a^5 + 273*a^4 + 26*a^3 + 342*a^2 + 340*a + 210 + sage: Q = EK([Q_x, Q_y]) + sage: P._miller_(Q, 127) 371*a^5 + 39*a^4 + 355*a^3 + 233*a^2 + 20*a + 275 A series of small examples and small torsions. We start with `n=1`, which is trivial: the function is the constant 1:: - sage: E = EllipticCurve([GF(7)(0), 2]) # optional - sage.rings.finite_rings - sage: P = E(5, 1); Q = E(0, 3); I = E(0) # optional - sage.rings.finite_rings - sage: I._miller_(P, 1) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(0), 2]) + sage: P = E(5, 1); Q = E(0, 3); I = E(0) + sage: I._miller_(P, 1) 1 - sage: I._miller_(Q, 1) # optional - sage.rings.finite_rings + sage: I._miller_(Q, 1) 1 A two-torsion example. In this case `f_{n,P}(Q) = x_Q - x_P`:: - sage: E = EllipticCurve([GF(7)(-1), 0]) # optional - sage.rings.finite_rings - sage: P = E(0,0); Q = E(1, 0); # optional - sage.rings.finite_rings - sage: P._miller_(P, 2) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(-1), 0]) + sage: P = E(0,0); Q = E(1, 0); + sage: P._miller_(P, 2) 0 - sage: Q._miller_(Q, 2) # optional - sage.rings.finite_rings + sage: Q._miller_(Q, 2) 0 - sage: P._miller_(Q, 2) # optional - sage.rings.finite_rings + sage: P._miller_(Q, 2) 1 - sage: Q._miller_(P, 2) # optional - sage.rings.finite_rings + sage: Q._miller_(P, 2) 6 A three-torsion example:: - sage: E = EllipticCurve([GF(7)(0), 2]) # optional - sage.rings.finite_rings - sage: P = E(5, 1); Q = E(0, 3); # optional - sage.rings.finite_rings - sage: P._miller_(Q, 3) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(0), 2]) + sage: P = E(5, 1); Q = E(0, 3); + sage: P._miller_(Q, 3) 4 A 4-torsion example:: - sage: E = EllipticCurve([GF(7)(-1), 0]) # optional - sage.rings.finite_rings - sage: P = E(5, 1); Q = E(4, 2) # optional - sage.rings.finite_rings - sage: P._miller_(Q, 4) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(-1), 0]) + sage: P = E(5, 1); Q = E(4, 2) + sage: P._miller_(Q, 4) 3 A 5-torsion example:: - sage: E = EllipticCurve([GF(7)(-1), 4]) # optional - sage.rings.finite_rings - sage: P = E(4, 1); Q = E(6, 5) # optional - sage.rings.finite_rings - sage: P._miller_(Q, 5) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(-1), 4]) + sage: P = E(4, 1); Q = E(6, 5) + sage: P._miller_(Q, 5) 1 A 6-torsion example:: - sage: E = EllipticCurve([GF(7)(3), 1]) # optional - sage.rings.finite_rings - sage: P = E(5, 1); Q = E(3, 3) # optional - sage.rings.finite_rings - sage: P._miller_(Q, 6) # optional - sage.rings.finite_rings + sage: E = EllipticCurve([GF(7)(3), 1]) + sage: P = E(5, 1); Q = E(3, 3) + sage: P._miller_(Q, 6) 5 An example which is part of an ate pairing calculation. The trace of the curve is negative, so it should exercise the `n<0` case in the code:: + sage: # needs sage.rings.finite_rings sage: p = 2017; A = 1; B = 30; r = 29; t = -70; k = 7 - sage: F = GF(p); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve([F(A), F(B)]); P = E(369, 716) # optional - sage.rings.finite_rings - sage: K. = GF(p^k, modulus=x^k+2); EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: Qx = 1226*a^6 + 1778*a^5 + 660*a^4 + 1791*a^3 + 1750*a^2 + 867*a + 770 # optional - sage.rings.finite_rings - sage: Qy = 1764*a^6 + 198*a^5 + 1206*a^4 + 406*a^3 + 1200*a^2 + 273*a + 1712 # optional - sage.rings.finite_rings - sage: Q = EK(Qx, Qy) # optional - sage.rings.finite_rings - sage: Q._miller_(P, t - 1) # optional - sage.rings.finite_rings + sage: F = GF(p); R. = F[] + sage: E = EllipticCurve([F(A), F(B)]); P = E(369, 716) + sage: K. = GF(p^k, modulus=x^k+2); EK = E.base_extend(K) + sage: Qx = 1226*a^6 + 1778*a^5 + 660*a^4 + 1791*a^3 + 1750*a^2 + 867*a + 770 + sage: Qy = 1764*a^6 + 198*a^5 + 1206*a^4 + 406*a^3 + 1200*a^2 + 273*a + 1712 + sage: Q = EK(Qx, Qy) + sage: Q._miller_(P, t - 1) 1311*a^6 + 1362*a^5 + 1177*a^4 + 807*a^3 + 1331*a^2 + 1530*a + 1931 ALGORITHM: @@ -1634,66 +1651,70 @@ def weil_pairing(self, Q, n, algorithm=None): EXAMPLES:: - sage: F. = GF((2,5)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: P = E(a^4 + 1, a^3) # optional - sage.rings.finite_rings - sage: Fx. = GF((2, 4*5)) # optional - sage.rings.finite_rings - sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) # optional - sage.rings.finite_rings - sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) # optional - sage.rings.finite_rings - sage: O = Ex(0) # optional - sage.rings.finite_rings - sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF((2,5)) + sage: E = EllipticCurve(F, [0,0,1,1,1]) + sage: P = E(a^4 + 1, a^3) + sage: Fx. = GF((2, 4*5)) + sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) + sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) + sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) + sage: O = Ex(0) + sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, ....: b^18 + b^13 + b^10 + b^8 + b^5 + b^4 + b^3 + b) - sage: Px.weil_pairing(Qx, 41) == b^19 + b^15 + b^9 + b^8 + b^6 + b^4 + b^3 + b^2 + 1 # optional - sage.rings.finite_rings + sage: Px.weil_pairing(Qx, 41) == b^19 + b^15 + b^9 + b^8 + b^6 + b^4 + b^3 + b^2 + 1 True - sage: Px.weil_pairing(17*Px, 41) == Fx(1) # optional - sage.rings.finite_rings + sage: Px.weil_pairing(17*Px, 41) == Fx(1) True - sage: Px.weil_pairing(O, 41) == Fx(1) # optional - sage.rings.finite_rings + sage: Px.weil_pairing(O, 41) == Fx(1) True An error is raised if either point is not `n`-torsion:: - sage: Px.weil_pairing(O, 40) # optional - sage.rings.finite_rings + sage: Px.weil_pairing(O, 40) # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: points must both be n-torsion A larger example (see :trac:`4964`):: - sage: P, Q = EllipticCurve(GF((19,4),'a'), [-1,0]).gens() # optional - sage.rings.finite_rings - sage: P.order(), Q.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P, Q = EllipticCurve(GF((19,4),'a'), [-1,0]).gens() + sage: P.order(), Q.order() (360, 360) - sage: z = P.weil_pairing(Q, 360) # optional - sage.rings.finite_rings - sage: z.multiplicative_order() # optional - sage.rings.finite_rings + sage: z = P.weil_pairing(Q, 360) + sage: z.multiplicative_order() 360 An example over a number field:: - sage: E = EllipticCurve('11a1').change_ring(CyclotomicField(5)) # optional - sage.rings.number_field - sage: P, Q = E.torsion_subgroup().gens() # optional - sage.rings.number_field - sage: P, Q = (P.element(), Q.element()) # optional - sage.rings.number_field - sage: (P.order(), Q.order()) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve('11a1').change_ring(CyclotomicField(5)) + sage: P, Q = E.torsion_subgroup().gens() + sage: P, Q = (P.element(), Q.element()) + sage: (P.order(), Q.order()) (5, 5) - sage: P.weil_pairing(Q, 5) # optional - sage.rings.number_field + sage: P.weil_pairing(Q, 5) zeta5^2 - sage: Q.weil_pairing(P, 5) # optional - sage.rings.number_field + sage: Q.weil_pairing(P, 5) zeta5^3 TESTS: Check that the original Sage implementation still works:: - sage: GF(65537^2).inject_variables() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: GF(65537^2).inject_variables() Defining z2 - sage: E = EllipticCurve(GF(65537^2), [0,1]) # optional - sage.rings.finite_rings - sage: P = E(22, 28891) # optional - sage.rings.finite_rings - sage: Q = E(-93, 40438*z2 + 31573) # optional - sage.rings.finite_rings - sage: P.weil_pairing(Q, 7282, algorithm='sage') # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537^2), [0,1]) + sage: P = E(22, 28891) + sage: Q = E(-93, 40438*z2 + 31573) + sage: P.weil_pairing(Q, 7282, algorithm='sage') 19937*z2 + 65384 Passing an unknown ``algorithm=`` argument should fail:: - sage: P.weil_pairing(Q, 7282, algorithm='_invalid_') # optional - sage.rings.finite_rings + sage: P.weil_pairing(Q, 7282, algorithm='_invalid_') # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: unknown algorithm @@ -1812,82 +1833,86 @@ def tate_pairing(self, Q, n, k, q=None): A simple example, pairing a point with itself, and pairing a point with another rational point:: - sage: p = 103; A = 1; B = 18; E = EllipticCurve(GF(p), [A, B]) # optional - sage.rings.finite_rings - sage: P = E(33, 91); n = P.order(); n # optional - sage.rings.finite_rings + sage: p = 103; A = 1; B = 18; E = EllipticCurve(GF(p), [A, B]) + sage: P = E(33, 91); n = P.order(); n 19 - sage: k = GF(n)(p).multiplicative_order(); k # optional - sage.rings.finite_rings + sage: k = GF(n)(p).multiplicative_order(); k 6 - sage: P.tate_pairing(P, n, k) # optional - sage.rings.finite_rings + sage: P.tate_pairing(P, n, k) 1 - sage: Q = E(87, 51) # optional - sage.rings.finite_rings - sage: P.tate_pairing(Q, n, k) # optional - sage.rings.finite_rings + sage: Q = E(87, 51) + sage: P.tate_pairing(Q, n, k) 1 sage: set_random_seed(35) - sage: P.tate_pairing(P, n, k) # optional - sage.rings.finite_rings + sage: P.tate_pairing(P, n, k) 1 We now let `Q` be a point on the same curve as above, but defined over the pairing extension field, and we also demonstrate the bilinearity of the pairing:: - sage: K. = GF((p,k)) # optional - sage.rings.finite_rings - sage: EK = E.base_extend(K); P = EK(P) # optional - sage.rings.finite_rings - sage: Qx = 69*a^5 + 96*a^4 + 22*a^3 + 86*a^2 + 6*a + 35 # optional - sage.rings.finite_rings - sage: Qy = 34*a^5 + 24*a^4 + 16*a^3 + 41*a^2 + 4*a + 40 # optional - sage.rings.finite_rings - sage: Q = EK(Qx, Qy); # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF((p,k)) + sage: EK = E.base_extend(K); P = EK(P) + sage: Qx = 69*a^5 + 96*a^4 + 22*a^3 + 86*a^2 + 6*a + 35 + sage: Qy = 34*a^5 + 24*a^4 + 16*a^3 + 41*a^2 + 4*a + 40 + sage: Q = EK(Qx, Qy); Multiply by cofactor so Q has order n:: - sage: h = 551269674; Q = h*Q # optional - sage.rings.finite_rings - sage: P = EK(P); P.tate_pairing(Q, n, k) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: h = 551269674; Q = h*Q + sage: P = EK(P); P.tate_pairing(Q, n, k) 24*a^5 + 34*a^4 + 3*a^3 + 69*a^2 + 86*a + 45 - sage: s = Integer(randrange(1,n)) # optional - sage.rings.finite_rings - sage: ans1 = (s*P).tate_pairing(Q, n, k) # optional - sage.rings.finite_rings - sage: ans2 = P.tate_pairing(s*Q, n, k) # optional - sage.rings.finite_rings - sage: ans3 = P.tate_pairing(Q, n, k)^s # optional - sage.rings.finite_rings - sage: ans1 == ans2 == ans3 # optional - sage.rings.finite_rings + sage: s = Integer(randrange(1,n)) + sage: ans1 = (s*P).tate_pairing(Q, n, k) + sage: ans2 = P.tate_pairing(s*Q, n, k) + sage: ans3 = P.tate_pairing(Q, n, k)^s + sage: ans1 == ans2 == ans3 True - sage: (ans1 != 1) and (ans1^n == 1) # optional - sage.rings.finite_rings + sage: (ans1 != 1) and (ans1^n == 1) True Here is an example of using the Tate pairing to compute the Weil pairing (using the same data as above):: - sage: e = Integer((p^k-1)/n); e # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: e = Integer((p^k-1)/n); e 62844857712 - sage: P.weil_pairing(Q, n)^e # optional - sage.rings.finite_rings + sage: P.weil_pairing(Q, n)^e 94*a^5 + 99*a^4 + 29*a^3 + 45*a^2 + 57*a + 34 - sage: P.tate_pairing(Q, n, k) == P._miller_(Q, n)^e # optional - sage.rings.finite_rings + sage: P.tate_pairing(Q, n, k) == P._miller_(Q, n)^e True - sage: Q.tate_pairing(P, n, k) == Q._miller_(P, n)^e # optional - sage.rings.finite_rings + sage: Q.tate_pairing(P, n, k) == Q._miller_(P, n)^e True - sage: P.tate_pairing(Q, n, k)/Q.tate_pairing(P, n, k) # optional - sage.rings.finite_rings + sage: P.tate_pairing(Q, n, k)/Q.tate_pairing(P, n, k) 94*a^5 + 99*a^4 + 29*a^3 + 45*a^2 + 57*a + 34 An example where we have to pass the base field size (and we again have agreement with the Weil pairing):: - sage: F. = GF((2,5)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: P = E(a^4 + 1, a^3) # optional - sage.rings.finite_rings - sage: Fx. = GF((2,4*5)) # optional - sage.rings.finite_rings - sage: Ex = EllipticCurve(Fx,[0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) # optional - sage.rings.finite_rings - sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) # optional - sage.rings.finite_rings - sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF((2,5)) + sage: E = EllipticCurve(F, [0,0,1,1,1]) + sage: P = E(a^4 + 1, a^3) + sage: Fx. = GF((2,4*5)) + sage: Ex = EllipticCurve(Fx,[0,0,1,1,1]) + sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) + sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) + sage: Qx = Ex(b^19 + b^18 + b^16 + b^12 + b^10 + b^9 + b^8 + b^5 + b^3 + 1, ....: b^18 + b^13 + b^10 + b^8 + b^5 + b^4 + b^3 + b) - sage: Px.tate_pairing(Qx, n=41, k=4) # optional - sage.rings.finite_rings + sage: Px.tate_pairing(Qx, n=41, k=4) Traceback (most recent call last): ... ValueError: Unexpected field degree: set keyword argument q equal to the size of the base field (big field is GF(q^4)). - sage: num = Px.tate_pairing(Qx, n=41, k=4, q=32); num # optional - sage.rings.finite_rings + sage: num = Px.tate_pairing(Qx, n=41, k=4, q=32); num b^19 + b^14 + b^13 + b^12 + b^6 + b^4 + b^3 - sage: den = Qx.tate_pairing(Px, n=41, k=4, q=32); den # optional - sage.rings.finite_rings + sage: den = Qx.tate_pairing(Px, n=41, k=4, q=32); den b^19 + b^17 + b^16 + b^15 + b^14 + b^10 + b^6 + b^2 + 1 - sage: e = Integer((32^4-1)/41); e # optional - sage.rings.finite_rings + sage: e = Integer((32^4-1)/41); e 25575 - sage: Px.weil_pairing(Qx, 41)^e == num/den # optional - sage.rings.finite_rings + sage: Px.weil_pairing(Qx, 41)^e == num/den True .. NOTE:: @@ -1968,64 +1993,68 @@ def ate_pairing(self, Q, n, k, t, q=None): An example with embedding degree 6:: + sage: # needs sage.rings.finite_rings sage: p = 7549; A = 0; B = 1; n = 157; k = 6; t = 14 - sage: F = GF(p); E = EllipticCurve(F, [A, B]) # optional - sage.rings.finite_rings - sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) # optional - sage.rings.finite_rings - sage: EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = EK(3050, 5371); Q = EK(6908*a^4, 3231*a^3) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) # optional - sage.rings.finite_rings + sage: F = GF(p); E = EllipticCurve(F, [A, B]) + sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) + sage: EK = E.base_extend(K) + sage: P = EK(3050, 5371); Q = EK(6908*a^4, 3231*a^3) + sage: P.ate_pairing(Q, n, k, t) 6708*a^5 + 4230*a^4 + 4350*a^3 + 2064*a^2 + 4022*a + 6733 - sage: s = Integer(randrange(1, n)) # optional - sage.rings.finite_rings - sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) # optional - sage.rings.finite_rings + sage: s = Integer(randrange(1, n)) + sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) True - sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s # optional - sage.rings.finite_rings + sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s True Another example with embedding degree 7 and positive trace:: + sage: # needs sage.rings.finite_rings sage: p = 2213; A = 1; B = 49; n = 1093; k = 7; t = 28 - sage: F = GF(p); E = EllipticCurve(F, [A, B]) # optional - sage.rings.finite_rings - sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) # optional - sage.rings.finite_rings - sage: EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = EK(1583, 1734) # optional - sage.rings.finite_rings - sage: Qx = 1729*a^6+1767*a^5+245*a^4+980*a^3+1592*a^2+1883*a+722 # optional - sage.rings.finite_rings - sage: Qy = 1299*a^6+1877*a^5+1030*a^4+1513*a^3+1457*a^2+309*a+1636 # optional - sage.rings.finite_rings - sage: Q = EK(Qx, Qy) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) # optional - sage.rings.finite_rings + sage: F = GF(p); E = EllipticCurve(F, [A, B]) + sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) + sage: EK = E.base_extend(K) + sage: P = EK(1583, 1734) + sage: Qx = 1729*a^6+1767*a^5+245*a^4+980*a^3+1592*a^2+1883*a+722 + sage: Qy = 1299*a^6+1877*a^5+1030*a^4+1513*a^3+1457*a^2+309*a+1636 + sage: Q = EK(Qx, Qy) + sage: P.ate_pairing(Q, n, k, t) 1665*a^6 + 1538*a^5 + 1979*a^4 + 239*a^3 + 2134*a^2 + 2151*a + 654 - sage: s = Integer(randrange(1, n)) # optional - sage.rings.finite_rings - sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) # optional - sage.rings.finite_rings + sage: s = Integer(randrange(1, n)) + sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) True - sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s # optional - sage.rings.finite_rings + sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s True Another example with embedding degree 7 and negative trace:: + sage: # needs sage.rings.finite_rings sage: p = 2017; A = 1; B = 30; n = 29; k = 7; t = -70 - sage: F = GF(p); E = EllipticCurve(F, [A, B]) # optional - sage.rings.finite_rings - sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) # optional - sage.rings.finite_rings - sage: EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = EK(369, 716) # optional - sage.rings.finite_rings - sage: Qx = 1226*a^6+1778*a^5+660*a^4+1791*a^3+1750*a^2+867*a+770 # optional - sage.rings.finite_rings - sage: Qy = 1764*a^6+198*a^5+1206*a^4+406*a^3+1200*a^2+273*a+1712 # optional - sage.rings.finite_rings - sage: Q = EK(Qx, Qy) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) # optional - sage.rings.finite_rings + sage: F = GF(p); E = EllipticCurve(F, [A, B]) + sage: R. = F[]; K. = GF((p,k), modulus=x^k+2) + sage: EK = E.base_extend(K) + sage: P = EK(369, 716) + sage: Qx = 1226*a^6+1778*a^5+660*a^4+1791*a^3+1750*a^2+867*a+770 + sage: Qy = 1764*a^6+198*a^5+1206*a^4+406*a^3+1200*a^2+273*a+1712 + sage: Q = EK(Qx, Qy) + sage: P.ate_pairing(Q, n, k, t) 1794*a^6 + 1161*a^5 + 576*a^4 + 488*a^3 + 1950*a^2 + 1905*a + 1315 - sage: s = Integer(randrange(1, n)) # optional - sage.rings.finite_rings - sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) # optional - sage.rings.finite_rings + sage: s = Integer(randrange(1, n)) + sage: (s*P).ate_pairing(Q, n, k, t) == P.ate_pairing(s*Q, n, k, t) True - sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s # optional - sage.rings.finite_rings + sage: P.ate_pairing(s*Q, n, k, t) == P.ate_pairing(Q, n, k, t)^s True Using the same data, we show that the ate pairing is a power of the Tate pairing (see [HSV2006]_ end of section 3.1):: - sage: c = (k*p^(k-1)).mod(n); T = t - 1 # optional - sage.rings.finite_rings - sage: N = gcd(T^k - 1, p^k - 1) # optional - sage.rings.finite_rings - sage: s = Integer(N/n) # optional - sage.rings.finite_rings - sage: L = Integer((T^k - 1)/N) # optional - sage.rings.finite_rings - sage: M = (L*s*c.inverse_mod(n)).mod(n) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) == Q.tate_pairing(P, n, k)^M # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: c = (k*p^(k-1)).mod(n); T = t - 1 + sage: N = gcd(T^k - 1, p^k - 1) + sage: s = Integer(N/n) + sage: L = Integer((T^k - 1)/N) + sage: M = (L*s*c.inverse_mod(n)).mod(n) + sage: P.ate_pairing(Q, n, k, t) == Q.tate_pairing(P, n, k)^M True An example where we have to pass the base field size (and we again have @@ -2033,59 +2062,62 @@ def ate_pairing(self, Q, n, k, t, q=None): `F`-rational, (it is the homomorphic image of an `F`-rational point) it is nonetheless in `ker(\pi-1)`, and so is a legitimate input:: - sage: q = 2^5; F. = GF(q) # optional - sage.rings.finite_rings - sage: n = 41; k = 4; t = -8 # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F,[0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: P = E(a^4 + 1, a^3) # optional - sage.rings.finite_rings - sage: Fx. = GF(q^k) # optional - sage.rings.finite_rings - sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) # optional - sage.rings.finite_rings - sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) # optional - sage.rings.finite_rings - sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) # optional - sage.rings.finite_rings - sage: Qx = Ex(b^19+b^18+b^16+b^12+b^10+b^9+b^8+b^5+b^3+1, # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: q = 2^5; F. = GF(q) + sage: n = 41; k = 4; t = -8 + sage: E = EllipticCurve(F,[0,0,1,1,1]) + sage: P = E(a^4 + 1, a^3) + sage: Fx. = GF(q^k) + sage: Ex = EllipticCurve(Fx, [0,0,1,1,1]) + sage: phi = Hom(F, Fx)(F.gen().minpoly().roots(Fx)[0][0]) + sage: Px = Ex(phi(P.xy()[0]), phi(P.xy()[1])) + sage: Qx = Ex(b^19+b^18+b^16+b^12+b^10+b^9+b^8+b^5+b^3+1, ....: b^18+b^13+b^10+b^8+b^5+b^4+b^3+b) - sage: Qx = Ex(Qx[0]^q, Qx[1]^q) - Qx # ensure Qx is in ker(pi - q) # optional - sage.rings.finite_rings - sage: Px.ate_pairing(Qx, n, k, t) # optional - sage.rings.finite_rings + sage: Qx = Ex(Qx[0]^q, Qx[1]^q) - Qx # ensure Qx is in ker(pi - q) + sage: Px.ate_pairing(Qx, n, k, t) Traceback (most recent call last): ... ValueError: Unexpected field degree: set keyword argument q equal to the size of the base field (big field is GF(q^4)). - sage: Px.ate_pairing(Qx, n, k, t, q) # optional - sage.rings.finite_rings + sage: Px.ate_pairing(Qx, n, k, t, q) b^19 + b^18 + b^17 + b^16 + b^15 + b^14 + b^13 + b^12 + b^11 + b^9 + b^8 + b^5 + b^4 + b^2 + b + 1 sage: s = Integer(randrange(1, n)) - sage: (s*Px).ate_pairing(Qx, n, k, t, q) == Px.ate_pairing(s*Qx, n, k, t, q) # optional - sage.rings.finite_rings + sage: (s*Px).ate_pairing(Qx, n, k, t, q) == Px.ate_pairing(s*Qx, n, k, t, q) True - sage: Px.ate_pairing(s*Qx, n, k, t, q) == Px.ate_pairing(Qx, n, k, t, q)^s # optional - sage.rings.finite_rings + sage: Px.ate_pairing(s*Qx, n, k, t, q) == Px.ate_pairing(Qx, n, k, t, q)^s True - sage: c = (k*q^(k-1)).mod(n); T = t - 1 # optional - sage.rings.finite_rings - sage: N = gcd(T^k - 1, q^k - 1) # optional - sage.rings.finite_rings - sage: s = Integer(N/n) # optional - sage.rings.finite_rings - sage: L = Integer((T^k - 1)/N) # optional - sage.rings.finite_rings - sage: M = (L*s*c.inverse_mod(n)).mod(n) # optional - sage.rings.finite_rings - sage: Px.ate_pairing(Qx, n, k, t, q) == Qx.tate_pairing(Px, n, k, q)^M # optional - sage.rings.finite_rings + sage: c = (k*q^(k-1)).mod(n); T = t - 1 + sage: N = gcd(T^k - 1, q^k - 1) + sage: s = Integer(N/n) + sage: L = Integer((T^k - 1)/N) + sage: M = (L*s*c.inverse_mod(n)).mod(n) + sage: Px.ate_pairing(Qx, n, k, t, q) == Qx.tate_pairing(Px, n, k, q)^M True It is an error if `Q` is not in the kernel of `\pi - p`, where `\pi` is the Frobenius automorphism:: - sage: p = 29; A = 1; B = 0; n = 5; k = 2; t = 10 # optional - sage.rings.finite_rings - sage: F = GF(p); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [A, B]); # optional - sage.rings.finite_rings - sage: K. = GF((p,k), modulus=x^k+2); EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = EK(13, 8); Q = EK(13, 21) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: p = 29; A = 1; B = 0; n = 5; k = 2; t = 10 + sage: F = GF(p); R. = F[] + sage: E = EllipticCurve(F, [A, B]); + sage: K. = GF((p,k), modulus=x^k+2); EK = E.base_extend(K) + sage: P = EK(13, 8); Q = EK(13, 21) + sage: P.ate_pairing(Q, n, k, t) Traceback (most recent call last): ... ValueError: Point (13 : 21 : 1) not in Ker(pi - q) It is also an error if `P` is not in the kernel os `\pi - 1`:: + sage: # needs sage.rings.finite_rings sage: p = 29; A = 1; B = 0; n = 5; k = 2; t = 10 - sage: F = GF(p); R. = F[] # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [A, B]); # optional - sage.rings.finite_rings - sage: K. = GF((p,k), modulus=x^k+2); EK = E.base_extend(K) # optional - sage.rings.finite_rings - sage: P = EK(14, 10*a); Q = EK(13, 21) # optional - sage.rings.finite_rings - sage: P.ate_pairing(Q, n, k, t) # optional - sage.rings.finite_rings + sage: F = GF(p); R. = F[] + sage: E = EllipticCurve(F, [A, B]); + sage: K. = GF((p,k), modulus=x^k+2); EK = E.base_extend(K) + sage: P = EK(14, 10*a); Q = EK(13, 21) + sage: P.ate_pairing(Q, n, k, t) Traceback (most recent call last): ... ValueError: This point (14 : 10*a : 1) is not in Ker(pi - 1) @@ -2155,7 +2187,7 @@ class EllipticCurvePoint_number_field(EllipticCurvePoint_field): (0 : 0 : 1) sage: E(0,0) # brackets are optional (0 : 0 : 1) - sage: E([GF(5)(0), 0]) # entries are coerced # optional - sage.rings.finite_rings + sage: E([GF(5)(0), 0]) # entries are coerced (0 : 0 : 1) sage: E(0.000, 0) @@ -2340,21 +2372,23 @@ def is_on_identity_component(self, embedding=None): An example over a field with two real embeddings:: - sage: L. = QuadraticField(2) # optional - sage.rings.number_field - sage: E = EllipticCurve(L, [0,1,0,a,a]) # optional - sage.rings.number_field - sage: P = E(-1,0) # optional - sage.rings.number_field - sage: [P.is_on_identity_component(e) for e in L.embeddings(RR)] # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: L. = QuadraticField(2) + sage: E = EllipticCurve(L, [0,1,0,a,a]) + sage: P = E(-1,0) + sage: [P.is_on_identity_component(e) for e in L.embeddings(RR)] [False, True] We can check this as follows:: - sage: [e(E.discriminant()) > 0 for e in L.embeddings(RR)] # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: [e(E.discriminant()) > 0 for e in L.embeddings(RR)] [True, False] - sage: e = L.embeddings(RR)[0] # optional - sage.rings.number_field - sage: E1 = EllipticCurve(RR, [e(ai) for ai in E.ainvs()]) # optional - sage.rings.number_field - sage: e1, e2, e3 = E1.two_division_polynomial().roots(RR, # optional - sage.rings.number_field + sage: e = L.embeddings(RR)[0] + sage: E1 = EllipticCurve(RR, [e(ai) for ai in E.ainvs()]) + sage: e1, e2, e3 = E1.two_division_polynomial().roots(RR, ....: multiplicities=False) - sage: e1 < e2 < e3 and e(P[0]) < e3 # optional - sage.rings.number_field + sage: e1 < e2 < e3 and e(P[0]) < e3 True """ if self.is_zero(): # trivial case @@ -2425,22 +2459,23 @@ def has_good_reduction(self, P=None): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1,0,-160,308]) # optional - sage.rings.number_field - sage: P = E(26, -120) # optional - sage.rings.number_field - sage: E.discriminant().support() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,1,0,-160,308]) + sage: P = E(26, -120) + sage: E.discriminant().support() [Fractional ideal (i + 1), Fractional ideal (-i - 2), Fractional ideal (2*i + 1), Fractional ideal (3)] - sage: [E.tamagawa_exponent(p) for p in E.discriminant().support()] # optional - sage.rings.number_field + sage: [E.tamagawa_exponent(p) for p in E.discriminant().support()] [1, 4, 4, 4] - sage: P.has_good_reduction() # optional - sage.rings.number_field + sage: P.has_good_reduction() False - sage: (2*P).has_good_reduction() # optional - sage.rings.number_field + sage: (2*P).has_good_reduction() False - sage: (4*P).has_good_reduction() # optional - sage.rings.number_field + sage: (4*P).has_good_reduction() True TESTS: @@ -2448,14 +2483,14 @@ def has_good_reduction(self, P=None): An example showing that :trac:`8498` is fixed:: sage: E = EllipticCurve('11a1') - sage: K. = NumberField(x^2 + 47) # optional - sage.rings.number_field - sage: EK = E.base_extend(K) # optional - sage.rings.number_field - sage: T = EK(5, 5) # optional - sage.rings.number_field - sage: P = EK(-2, -1/2*t - 1/2) # optional - sage.rings.number_field - sage: p = K.ideal(11) # optional - sage.rings.number_field - sage: T.has_good_reduction(p) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 47) # needs sage.rings.number_field + sage: EK = E.base_extend(K) # needs sage.rings.number_field + sage: T = EK(5, 5) # needs sage.rings.number_field + sage: P = EK(-2, -1/2*t - 1/2) # needs sage.rings.number_field + sage: p = K.ideal(11) # needs sage.rings.number_field + sage: T.has_good_reduction(p) # needs sage.rings.number_field False - sage: P.has_good_reduction(p) # optional - sage.rings.number_field + sage: P.has_good_reduction(p) # needs sage.rings.number_field True """ if self.is_zero(): # trivial case @@ -2536,23 +2571,25 @@ def reduction(self, p): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: F. = NumberField(x^2 + 5) # optional - sage.rings.number_field - sage: E = EllipticCurve(F, [1,2,3,4,0]) # optional - sage.rings.number_field - sage: Q = E(98, 931) # optional - sage.rings.number_field - sage: Q.reduction(a) # optional - sage.rings.number_field + sage: F. = NumberField(x^2 + 5) + sage: E = EllipticCurve(F, [1,2,3,4,0]) + sage: Q = E(98, 931) + sage: Q.reduction(a) (3 : 1 : 1) - sage: Q.reduction(11) # optional - sage.rings.number_field + sage: Q.reduction(11) (10 : 7 : 1) :: - sage: F. = NumberField(x^3 + x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(F, [a,2]) # optional - sage.rings.number_field - sage: P = E(a, 1) # optional - sage.rings.number_field - sage: P.reduction(F.ideal(5)) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: F. = NumberField(x^3 + x^2 + 1) + sage: E = EllipticCurve(F, [a,2]) + sage: P = E(a, 1) + sage: P.reduction(F.ideal(5)) (abar : 1 : 1) - sage: P.reduction(F.ideal(a^2 - 4*a - 2)) # optional - sage.rings.number_field + sage: P.reduction(F.ideal(a^2 - 4*a - 2)) (abar : 1 : 1) """ P = self @@ -2666,20 +2703,20 @@ def height(self, precision=None, normalised=True, algorithm='pari'): Canonical heights over number fields are implemented as well:: sage: R. = QQ[] - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([a, 4]); E # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: E = EllipticCurve([a, 4]); E # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + a*x + 4 over Number Field in a with defining polynomial x^3 - 2 - sage: P = E((0,2)) # optional - sage.rings.number_field - sage: P.height() # optional - sage.rings.number_field + sage: P = E((0,2)) # needs sage.rings.number_field + sage: P.height() # needs sage.rings.number_field 0.810463096585925 - sage: P.height(precision=100) # optional - sage.rings.number_field + sage: P.height(precision=100) # needs sage.rings.number_field 0.81046309658592536863991810577 - sage: P.height(precision=200) # optional - sage.rings.number_field + sage: P.height(precision=200) # needs sage.rings.number_field 0.81046309658592536863991810576865158896130286417155832378086 - sage: (2*P).height() / P.height() # optional - sage.rings.number_field + sage: (2*P).height() / P.height() # needs sage.rings.number_field 4.00000000000000 - sage: (100*P).height() / P.height() # optional - sage.rings.number_field + sage: (100*P).height() / P.height() # needs sage.rings.number_field 10000.0000000000 Setting ``normalised=False`` multiplies the height by the degree of `K`:: @@ -2690,12 +2727,12 @@ def height(self, precision=None, normalised=True, algorithm='pari'): 0.0511114082399688 sage: P.height(normalised=False) 0.0511114082399688 - sage: K. = CyclotomicField(5) # optional - sage.rings.number_field - sage: EK = E.change_ring(K) # optional - sage.rings.number_field - sage: PK = EK([0,0]) # optional - sage.rings.number_field - sage: PK.height() # optional - sage.rings.number_field + sage: K. = CyclotomicField(5) # needs sage.rings.number_field + sage: EK = E.change_ring(K) # needs sage.rings.number_field + sage: PK = EK([0,0]) # needs sage.rings.number_field + sage: PK.height() # needs sage.rings.number_field 0.0511114082399688 - sage: PK.height(normalised=False) # optional - sage.rings.number_field + sage: PK.height(normalised=False) # needs sage.rings.number_field 0.204445632959875 Some consistency checks:: @@ -2705,31 +2742,32 @@ def height(self, precision=None, normalised=True, algorithm='pari'): sage: P.height() 1.36857250535393 - sage: EK = E.change_ring(QuadraticField(-3,'a')) # optional - sage.rings.number_field - sage: PK = EK([-2,3,1]) # optional - sage.rings.number_field - sage: PK.height() # optional - sage.rings.number_field + sage: EK = E.change_ring(QuadraticField(-3,'a')) # needs sage.rings.number_field + sage: PK = EK([-2,3,1]) # needs sage.rings.number_field + sage: PK.height() # needs sage.rings.number_field 1.36857250535393 - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,4,6*i,0]) # optional - sage.rings.number_field - sage: Q = E.lift_x(-9/4); Q # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,4,6*i,0]) + sage: Q = E.lift_x(-9/4); Q (-9/4 : 27/8*i - 4 : 1) - sage: Q.height() # optional - sage.rings.number_field + sage: Q.height() 2.69518560017909 - sage: (15*Q).height() / Q.height() # optional - sage.rings.number_field + sage: (15*Q).height() / Q.height() 225.000000000000 sage: E = EllipticCurve('37a') sage: P = E([0,-1]) sage: P.height() 0.0511114082399688 - sage: K. = QuadraticField(-7) # optional - sage.rings.number_field - sage: ED = E.quadratic_twist(-7) # optional - sage.rings.number_field - sage: Q = E.isomorphism_to(ED.change_ring(K))(P); Q # optional - sage.rings.number_field + sage: K. = QuadraticField(-7) # needs sage.rings.number_field + sage: ED = E.quadratic_twist(-7) # needs sage.rings.number_field + sage: Q = E.isomorphism_to(ED.change_ring(K))(P); Q # needs sage.rings.number_field (0 : -7/2*a - 1/2 : 1) - sage: Q.height() # optional - sage.rings.number_field + sage: Q.height() # needs sage.rings.number_field 0.0511114082399688 - sage: Q.height(precision=100) # optional - sage.rings.number_field + sage: Q.height(precision=100) # needs sage.rings.number_field 0.051111408239968840235886099757 An example to show that the bug at :trac:`5252` is fixed:: @@ -2763,18 +2801,19 @@ def height(self, precision=None, normalised=True, algorithm='pari'): An example to show that the bug at :trac:`12509` is fixed (precision issues):: + sage: # needs sage.rings.number_field sage: x = polygen(QQ) - sage: K. = NumberField(x^2 - x - 1) # optional - sage.rings.number_field - sage: v = [0, a + 1, 1, 28665*a - 46382, 2797026*a - 4525688] # optional - sage.rings.number_field - sage: E = EllipticCurve(v) # optional - sage.rings.number_field - sage: P = E([72*a - 509/5, -682/25*a - 434/25]) # optional - sage.rings.number_field - sage: P.height() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 1) + sage: v = [0, a + 1, 1, 28665*a - 46382, 2797026*a - 4525688] + sage: E = EllipticCurve(v) + sage: P = E([72*a - 509/5, -682/25*a - 434/25]) + sage: P.height() 1.38877711688727 - sage: (2*P).height()/P.height() # optional - sage.rings.number_field + sage: (2*P).height()/P.height() 4.00000000000000 - sage: (2*P).height(precision=100)/P.height(precision=100) # optional - sage.rings.number_field + sage: (2*P).height(precision=100)/P.height(precision=100) 4.0000000000000000000000000000 - sage: (2*P).height(precision=1000)/P.height(precision=1000) # optional - sage.rings.number_field + sage: (2*P).height(precision=1000)/P.height(precision=1000) 4.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 This shows that the bug reported at :trac:`13951` has been fixed:: @@ -2783,9 +2822,9 @@ def height(self, precision=None, normalised=True, algorithm='pari'): sage: P1 = E(2,5) sage: P1.height() 1.06248137652528 - sage: F = E.change_ring(QuadraticField(-3, 'a')) # optional - sage.rings.number_field - sage: P2 = F([2,5]) # optional - sage.rings.number_field - sage: P2.height() # optional - sage.rings.number_field + sage: F = E.change_ring(QuadraticField(-3, 'a')) # needs sage.rings.number_field + sage: P2 = F([2,5]) # needs sage.rings.number_field + sage: P2.height() # needs sage.rings.number_field 1.06248137652528 """ if self.has_finite_order(): @@ -2860,27 +2899,29 @@ def archimedean_local_height(self, v=None, prec=None, weighted=False): Examples 1, 2, and 3 from [Sil1988]_:: - sage: K. = QuadraticField(-2) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,-1,1,0,0]); E # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-2) + sage: E = EllipticCurve(K, [0,-1,1,0,0]); E Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 over Number Field in a with defining polynomial x^2 + 2 with a = 1.414213562373095?*I - sage: P = E.lift_x(2 + a); P # optional - sage.rings.number_field + sage: P = E.lift_x(2 + a); P (a + 2 : -2*a - 2 : 1) - sage: P.archimedean_local_height(K.places(prec=170)[0]) / 2 # optional - sage.rings.number_field + sage: P.archimedean_local_height(K.places(prec=170)[0]) / 2 0.45754773287523276736211210741423654346576029814695 + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,4,6*i,0]); E # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,4,6*i,0]); E Elliptic Curve defined by y^2 + 4*y = x^3 + 6*i*x over Number Field in i with defining polynomial x^2 + 1 - sage: P = E((0,0)) # optional - sage.rings.number_field - sage: P.archimedean_local_height(K.places()[0]) / 2 # optional - sage.rings.number_field + sage: P = E((0,0)) + sage: P.archimedean_local_height(K.places()[0]) / 2 0.510184995162373 - sage: Q = E.lift_x(-9/4); Q # optional - sage.rings.number_field + sage: Q = E.lift_x(-9/4); Q # needs sage.rings.number_field (-9/4 : 27/8*i - 4 : 1) - sage: Q.archimedean_local_height(K.places()[0]) / 2 # optional - sage.rings.number_field + sage: Q.archimedean_local_height(K.places()[0]) / 2 # needs sage.rings.number_field 0.654445619529600 An example over the rational numbers:: @@ -2893,45 +2934,49 @@ def archimedean_local_height(self, v=None, prec=None, weighted=False): Local heights of torsion points can be non-zero (unlike the global height):: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, K(1), 0]) # optional - sage.rings.number_field - sage: P = E(i, 0) # optional - sage.rings.number_field - sage: P.archimedean_local_height() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, K(1), 0]) + sage: P = E(i, 0) + sage: P.archimedean_local_height() 0.346573590279973 TESTS: See :trac:`12509`:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ) - sage: K. = NumberField(x^2 - x - 1) # optional - sage.rings.number_field - sage: v = [0, a + 1, 1, 28665*a - 46382, 2797026*a - 4525688] # optional - sage.rings.number_field - sage: E = EllipticCurve(v) # optional - sage.rings.number_field - sage: P = E([72*a - 509/5, -682/25*a - 434/25]) # optional - sage.rings.number_field - sage: P.archimedean_local_height() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 1) + sage: v = [0, a + 1, 1, 28665*a - 46382, 2797026*a - 4525688] + sage: E = EllipticCurve(v) + sage: P = E([72*a - 509/5, -682/25*a - 434/25]) + sage: P.archimedean_local_height() -0.220660795546828 See :trac:`19276`:: - sage: K. = NumberField(x^2 - x - 104) # optional - sage.rings.number_field - sage: E = EllipticCurve([1, a - 1, 1, -816765673272*a - 7931030674178, 1478955604013312315*a + 14361086227143654561]) # optional - sage.rings.number_field - sage: P = E(5393511/49*a + 52372721/49 , -33896210324/343*a - 329141996591/343 ) # optional - sage.rings.number_field - sage: P.height() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 - x - 104) + sage: E = EllipticCurve([1, a - 1, 1, -816765673272*a - 7931030674178, 1478955604013312315*a + 14361086227143654561]) + sage: P = E(5393511/49*a + 52372721/49 , -33896210324/343*a - 329141996591/343 ) + sage: P.height() 0.974232017827741 See :trac:`29966`:: - sage: K. = NumberField(x^3 - x^2 - 6*x + 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([1, -a^2 + 2*a + 4, 0, -6056450500590472699700624*a^2 - 11239394326797569935861742*a + 4241549693833829432516231, # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^3 - x^2 - 6*x + 2) + sage: E = EllipticCurve([1, -a^2 + 2*a + 4, 0, -6056450500590472699700624*a^2 - 11239394326797569935861742*a + 4241549693833829432516231, ....: 1904879037869682826729875958079326124520*a^2 + 3535022146945771697732350459284777382011*a - 1334055169621036218710397707677347972626]) - sage: P = E([1033399668533*a^2 + 1917754693229*a - 723726883800 , 12536493059202326563*a^2 + 23264879148900575548*a - 8779756111574815918 , 1]) # optional - sage.rings.number_field - sage: P.height() # optional - sage.rings.number_field + sage: P = E([1033399668533*a^2 + 1917754693229*a - 723726883800 , 12536493059202326563*a^2 + 23264879148900575548*a - 8779756111574815918 , 1]) + sage: P.height() 0.297318833424763 - sage: (2*P).height() / P.height() # optional - sage.rings.number_field + sage: (2*P).height() / P.height() 4.00000000000000 - sage: P.height(200) # optional - sage.rings.number_field + sage: P.height(200) 0.29731883342476341806143743594519935578696537745294661858984 - sage: (2*P).height(200) / P.height(200) # optional - sage.rings.number_field + sage: (2*P).height(200) / P.height(200) 4.0000000000000000000000000000000000000000000000000000000000 """ from sage.rings.number_field.number_field import refine_embedding @@ -3089,28 +3134,30 @@ def non_archimedean_local_height(self, v=None, prec=None, Examples 2 and 3 from [Sil1988]_:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,4,6*i,0]); E # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: E = EllipticCurve(K, [0,0,4,6*i,0]); E Elliptic Curve defined by y^2 + 4*y = x^3 + 6*i*x over Number Field in i with defining polynomial x^2 + 1 - sage: P = E((0,0)) # optional - sage.rings.number_field - sage: P.non_archimedean_local_height(K.ideal(i+1)) # optional - sage.rings.number_field + sage: P = E((0,0)) + sage: P.non_archimedean_local_height(K.ideal(i+1)) -1/2*log(2) - sage: P.non_archimedean_local_height(K.ideal(3)) # optional - sage.rings.number_field + sage: P.non_archimedean_local_height(K.ideal(3)) 0 - sage: P.non_archimedean_local_height(K.ideal(1-2*i)) # optional - sage.rings.number_field + sage: P.non_archimedean_local_height(K.ideal(1-2*i)) 0 - sage: Q = E.lift_x(-9/4); Q # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: Q = E.lift_x(-9/4); Q (-9/4 : 27/8*i - 4 : 1) - sage: Q.non_archimedean_local_height(K.ideal(1+i)) # optional - sage.rings.number_field + sage: Q.non_archimedean_local_height(K.ideal(1+i)) 2*log(2) - sage: Q.non_archimedean_local_height(K.ideal(3)) # optional - sage.rings.number_field + sage: Q.non_archimedean_local_height(K.ideal(3)) 0 - sage: Q.non_archimedean_local_height(K.ideal(1-2*i)) # optional - sage.rings.number_field + sage: Q.non_archimedean_local_height(K.ideal(1-2*i)) 0 - sage: Q.non_archimedean_local_height() # optional - sage.rings.number_field + sage: Q.non_archimedean_local_height() 2*log(2) An example over the rational numbers:: @@ -3123,30 +3170,32 @@ def non_archimedean_local_height(self, v=None, prec=None, Local heights of torsion points can be non-zero (unlike the global height):: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, K(1), 0]) # optional - sage.rings.number_field - sage: P = E(i, 0) # optional - sage.rings.number_field - sage: P.non_archimedean_local_height() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, K(1), 0]) + sage: P = E(i, 0) + sage: P.non_archimedean_local_height() -1/2*log(2) TESTS:: - sage: Q.non_archimedean_local_height(prec=100) # optional - sage.rings.number_field + sage: Q.non_archimedean_local_height(prec=100) # needs sage.rings.number_field 1.3862943611198906188344642429 - sage: (3*Q).non_archimedean_local_height() # optional - sage.rings.number_field + sage: (3*Q).non_archimedean_local_height() # needs sage.rings.number_field 1/2*log(75923153929839865104) - sage: F. = NumberField(x^4 + 2*x^3 + 19*x^2 + 18*x + 288) # optional - sage.rings.number_field - sage: F.ring_of_integers().basis() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: F. = NumberField(x^4 + 2*x^3 + 19*x^2 + 18*x + 288) + sage: F.ring_of_integers().basis() [1, 5/6*a^3 + 1/6*a, 1/6*a^3 + 1/6*a^2, a^3] - sage: F.class_number() # optional - sage.rings.number_field + sage: F.class_number() 12 - sage: E = EllipticCurve('37a').change_ring(F) # optional - sage.rings.number_field - sage: P = E((-a^2/6 - a/6 - 1, a)); P # optional - sage.rings.number_field + sage: E = EllipticCurve('37a').change_ring(F) + sage: P = E((-a^2/6 - a/6 - 1, a)); P (-1/6*a^2 - 1/6*a - 1 : a : 1) - sage: P[0].is_integral() # optional - sage.rings.number_field + sage: P[0].is_integral() True - sage: P.non_archimedean_local_height() # optional - sage.rings.number_field + sage: P.non_archimedean_local_height() 0 This shows that the bug reported at :trac:`13951` has been fixed:: @@ -3333,25 +3382,27 @@ def elliptic_logarithm(self, embedding=None, precision=100, Examples over number fields:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: embs = K.embeddings(CC) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: Ls = [E.period_lattice(e) for e in embs] # optional - sage.rings.number_field - sage: [L.real_flag for L in Ls] # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: embs = K.embeddings(CC) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: Ls = [E.period_lattice(e) for e in embs] + sage: [L.real_flag for L in Ls] [0, 0, -1] - sage: P = E(-1,0) # order 2 # optional - sage.rings.number_field - sage: [L.elliptic_logarithm(P) for L in Ls] # optional - sage.rings.number_field + sage: P = E(-1,0) # order 2 + sage: [L.elliptic_logarithm(P) for L in Ls] [-1.73964256006716 - 1.07861534489191*I, -0.363756518406398 - 1.50699412135253*I, 1.90726488608927] - sage: E = EllipticCurve([-a^2 - a - 1, a^2 + a]) # optional - sage.rings.number_field - sage: Ls = [E.period_lattice(e) for e in embs] # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve([-a^2 - a - 1, a^2 + a]) + sage: Ls = [E.period_lattice(e) for e in embs] sage: pts = [E(2*a^2 - a - 1 , -2*a^2 - 2*a + 6 ), ....: E(-2/3*a^2 - 1/3 , -4/3*a - 2/3 ), ....: E(5/4*a^2 - 1/2*a , -a^2 - 1/4*a + 9/4 ), ....: E(2*a^2 + 3*a + 4 , -7*a^2 - 10*a - 12 )] - sage: [[L.elliptic_logarithm(P) for P in pts] for L in Ls] # optional - sage.rings.number_field + sage: [[L.elliptic_logarithm(P) for P in pts] for L in Ls] [[0.250819591818930 - 0.411963479992219*I, -0.290994550611374 - 1.37239400324105*I, -0.693473752205595 - 2.45028458830342*I, -0.151659609775291 - 1.48985406505459*I], [1.33444787667954 - 1.50889756650544*I, 0.792633734249234 - 0.548467043256610*I, @@ -3361,12 +3412,13 @@ def elliptic_logarithm(self, embedding=None, precision=100, :: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,9*i-10,21-i]) # optional - sage.rings.number_field - sage: emb = K.embeddings(CC)[1] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: P = E(2-i, 4+2*i) # optional - sage.rings.number_field - sage: L.elliptic_logarithm(P, prec=100) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0,0,0,9*i-10,21-i]) + sage: emb = K.embeddings(CC)[1] + sage: L = E.period_lattice(emb) + sage: P = E(2-i, 4+2*i) + sage: L.elliptic_logarithm(P, prec=100) 0.70448375537782208460499649302 - 0.79246725643650979858266018068*I """ from sage.rings.number_field.number_field import refine_embedding @@ -3484,30 +3536,30 @@ def padic_elliptic_logarithm(self, p, absprec=20): EXAMPLES:: sage: E = EllipticCurve([0,1,1,-2,0]) - sage: E(0).padic_elliptic_logarithm(3) # optional - sage.rings.padics + sage: E(0).padic_elliptic_logarithm(3) # needs sage.rings.padics 0 - sage: P = E(0, 0) # optional - sage.rings.padics - sage: P.padic_elliptic_logarithm(3) # optional - sage.rings.padics + sage: P = E(0, 0) # needs sage.rings.padics + sage: P.padic_elliptic_logarithm(3) # needs sage.rings.padics 2 + 2*3 + 3^3 + 2*3^7 + 3^8 + 3^9 + 3^11 + 3^15 + 2*3^17 + 3^18 + O(3^19) - sage: P.padic_elliptic_logarithm(3).lift() # optional - sage.rings.padics + sage: P.padic_elliptic_logarithm(3).lift() # needs sage.rings.padics 660257522 - sage: P = E(-11/9, 28/27) # optional - sage.rings.padics - sage: [(2*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(20)] # long time (3s) # optional - sage.rings.padics + sage: P = E(-11/9, 28/27) # needs sage.rings.padics + sage: [(2*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(20)] # long time, needs sage.rings.padics [2 + O(2^19), 2 + O(3^20), 2 + O(5^19), 2 + O(7^19), 2 + O(11^19), 2 + O(13^19), 2 + O(17^19), 2 + O(19^19)] - sage: [(3*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(12)] # long time (2s) # optional - sage.rings.padics + sage: [(3*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(12)] # long time, needs sage.rings.padics [1 + 2 + O(2^19), 3 + 3^20 + O(3^21), 3 + O(5^19), 3 + O(7^19), 3 + O(11^19)] - sage: [(5*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(12)] # long time (2s) # optional - sage.rings.padics + sage: [(5*P).padic_elliptic_logarithm(p)/P.padic_elliptic_logarithm(p) for p in prime_range(12)] # long time, needs sage.rings.padics [1 + 2^2 + O(2^19), 2 + 3 + O(3^20), 5 + O(5^19), 5 + O(7^19), 5 + O(11^19)] An example which arose during reviewing :trac:`4741`:: sage: E = EllipticCurve('794a1') sage: P = E(-1,2) - sage: P.padic_elliptic_logarithm(2) # default precision=20 # optional - sage.rings.padics + sage: P.padic_elliptic_logarithm(2) # default precision=20 # needs sage.rings.padics 2^4 + 2^5 + 2^6 + 2^8 + 2^9 + 2^13 + 2^14 + 2^15 + O(2^16) - sage: P.padic_elliptic_logarithm(2, absprec=30) # optional - sage.rings.padics + sage: P.padic_elliptic_logarithm(2, absprec=30) # needs sage.rings.padics 2^4 + 2^5 + 2^6 + 2^8 + 2^9 + 2^13 + 2^14 + 2^15 + 2^22 + 2^23 + 2^24 + O(2^26) - sage: P.padic_elliptic_logarithm(2, absprec=40) # optional - sage.rings.padics + sage: P.padic_elliptic_logarithm(2, absprec=40) # needs sage.rings.padics 2^4 + 2^5 + 2^6 + 2^8 + 2^9 + 2^13 + 2^14 + 2^15 + 2^22 + 2^23 + 2^24 + 2^28 + 2^29 + 2^31 + 2^34 + O(2^35) """ @@ -3596,9 +3648,9 @@ def _magma_init_(self, magma): EXAMPLES:: - sage: E = EllipticCurve(GF(17), [1,-1]) # optional - sage.rings.finite_rings - sage: P = E([13, 4]) # optional - sage.rings.finite_rings - sage: P._magma_init_(magma) # optional - magma # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [1,-1]) + sage: P = E([13, 4]) + sage: P._magma_init_(magma) # optional - magma 'EllipticCurve([_sage_ref...|GF(17)!0,GF(17)!0,GF(17)!0,GF(17)!1,GF(17)!16])![13,4]' """ E = self.curve()._magma_init_(magma) @@ -3612,14 +3664,15 @@ def _acted_upon_(self, other, side): EXAMPLES:: - sage: P = EllipticCurve(GF(65537), [2,2]).lift_x(6) # optional - sage.rings.finite_rings - sage: P.order().factor() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P = EllipticCurve(GF(65537), [2,2]).lift_x(6) + sage: P.order().factor() 2^2 * 3 * 37^2 - sage: getattr(74*P, '_order', None) # optional - sage.rings.finite_rings + sage: getattr(74*P, '_order', None) 222 - sage: getattr(P*4070, '_order', None) # optional - sage.rings.finite_rings + sage: getattr(P*4070, '_order', None) 222 - sage: getattr(506*P*37, '_order', None) # optional - sage.rings.finite_rings + sage: getattr(506*P*37, '_order', None) 222 """ k = ZZ(other) @@ -3702,33 +3755,35 @@ def discrete_log(self, Q, ord=None): EXAMPLES:: - sage: F = GF((3,6),'a') # optional - sage.rings.finite_rings - sage: a = F.gen() # optional - sage.rings.finite_rings - sage: E = EllipticCurve([0,1,1,a,a]) # optional - sage.rings.finite_rings - sage: E.cardinality() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF((3,6),'a') + sage: a = F.gen() + sage: E = EllipticCurve([0,1,1,a,a]) + sage: E.cardinality() 762 - sage: P = E.gens()[0] # optional - sage.rings.finite_rings - sage: Q = 400*P # optional - sage.rings.finite_rings - sage: P.discrete_log(Q) # optional - sage.rings.finite_rings + sage: P = E.gens()[0] + sage: Q = 400*P + sage: P.discrete_log(Q) 400 TESTS: Some random testing:: + sage: # needs sage.rings.finite_rings sage: sz = randint(8,32) sage: e = randint(1,3) sage: p = random_prime(ceil(2**(sz/e))) - sage: E = EllipticCurve(j=GF((p,e),'a').random_element()) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: Q = randrange(2**999) * P # optional - sage.rings.finite_rings - sage: x = P.discrete_log(Q) # optional - sage.rings.finite_rings - sage: x*P == Q # optional - sage.rings.finite_rings + sage: E = EllipticCurve(j=GF((p,e),'a').random_element()) + sage: P = E.random_point() + sage: Q = randrange(2**999) * P + sage: x = P.discrete_log(Q) + sage: x*P == Q True Doctest deprecation:: - sage: P.discrete_log(Q, ord=P.order()) # optional - sage.rings.finite_rings + sage: P.discrete_log(Q, ord=P.order()) # needs sage.rings.finite_rings doctest:warning ... DeprecationWarning: The "ord" argument to .discrete_log() is obsolete. ... @@ -3784,27 +3839,29 @@ def padic_elliptic_logarithm(self,Q, p): EXAMPLES:: - sage: p=235322474717419 - sage: b=8856682 - sage: E = EllipticCurve(GF(p), [0, b]) # optional - sage.rings.finite_rings - sage: P = E(200673830421813, 57025307876612) # optional - sage.rings.finite_rings - sage: Q = E(40345734829479, 211738132651297) # optional - sage.rings.finite_rings - sage: x = P.padic_elliptic_logarithm(Q, p) # optional - sage.rings.finite_rings sage.rings.padics - sage: x * P == Q # optional - sage.rings.finite_rings sage.rings.padics + sage: # needs sage.rings.finite_rings + sage: p = 235322474717419 + sage: b = 8856682 + sage: E = EllipticCurve(GF(p), [0, b]) + sage: P = E(200673830421813, 57025307876612) + sage: Q = E(40345734829479, 211738132651297) + sage: x = P.padic_elliptic_logarithm(Q, p) # needs sage.rings.padics + sage: x * P == Q # needs sage.rings.padics True TESTS: Some testing:: + sage: # needs sage.rings.finite_rings sage: a = 49850651047495986645822557378918223 sage: b = 21049438014429831351540675253466229 sage: p = 54283205379427155782089046839411711 - sage: E = EllipticCurve(GF(p), [a, b]) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: Q = randrange(0, p-1) * P # optional - sage.rings.finite_rings - sage: x = P.padic_elliptic_logarithm(Q, p) # optional - sage.rings.finite_rings sage.rings.padics - sage: x*P == Q # optional - sage.rings.finite_rings sage.rings.padics + sage: E = EllipticCurve(GF(p), [a, b]) + sage: P = E.random_point() + sage: Q = randrange(0, p-1) * P + sage: x = P.padic_elliptic_logarithm(Q, p) # needs sage.rings.padics + sage: x*P == Q # needs sage.rings.padics True """ E = self.curve() @@ -3852,9 +3909,9 @@ def has_finite_order(self): EXAMPLES:: - sage: E = EllipticCurve(GF(7), [1,3]) # optional - sage.rings.finite_rings - sage: P = E.points()[3] # optional - sage.rings.finite_rings - sage: P.has_finite_order() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [1,3]) + sage: P = E.points()[3] + sage: P.has_finite_order() True """ return True @@ -3871,68 +3928,73 @@ def order(self): EXAMPLES:: - sage: k. = GF((5,5)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k,[2,4]); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF((5,5)) + sage: E = EllipticCurve(k,[2,4]); E Elliptic Curve defined by y^2 = x^3 + 2*x + 4 over Finite Field in a of size 5^5 - sage: P = E(3*a^4 + 3*a, 2*a + 1) # optional - sage.rings.finite_rings - sage: P.order() # optional - sage.rings.finite_rings + sage: P = E(3*a^4 + 3*a, 2*a + 1) + sage: P.order() 3227 - sage: Q = E(0,2) # optional - sage.rings.finite_rings - sage: Q.order() # optional - sage.rings.finite_rings + sage: Q = E(0,2) + sage: Q.order() 7 - sage: Q.additive_order() # optional - sage.rings.finite_rings + sage: Q.additive_order() 7 :: + sage: # needs sage.rings.finite_rings sage: p = next_prime(2^150) - sage: E = EllipticCurve(GF(p), [1,1]) # optional - sage.rings.finite_rings - sage: P = E(831623307675610677632782670796608848711856078, # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(p), [1,1]) + sage: P = E(831623307675610677632782670796608848711856078, ....: 42295786042873366706573292533588638217232964) - sage: P.order() # optional - sage.rings.finite_rings + sage: P.order() 1427247692705959881058262545272474300628281448 - sage: P.order() == E.cardinality() # optional - sage.rings.finite_rings + sage: P.order() == E.cardinality() True The next example has `j(E)=0`:: + sage: # needs sage.rings.finite_rings sage: p = 33554501 - sage: F. = GF((p,2)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,1]) # optional - sage.rings.finite_rings - sage: E.j_invariant() # optional - sage.rings.finite_rings + sage: F. = GF((p,2)) + sage: E = EllipticCurve(F, [0,1]) + sage: E.j_invariant() 0 - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: P.order() # random # optional - sage.rings.finite_rings + sage: P = E.random_point() + sage: P.order() # random 16777251 Similarly when `j(E)=1728`:: + sage: # needs sage.rings.finite_rings sage: p = 33554473 - sage: F. = GF((p,2)) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [1,0]) # optional - sage.rings.finite_rings - sage: E.j_invariant() # optional - sage.rings.finite_rings + sage: F. = GF((p,2)) + sage: E = EllipticCurve(F, [1,0]) + sage: E.j_invariant() 1728 - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: P.order() # random # optional - sage.rings.finite_rings + sage: P = E.random_point() + sage: P.order() # random 46912611635760 TESTS: Check that the order actually gets cached (:trac:`32786`):: - sage: E = EllipticCurve(GF(31337), [42,1]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(1) # optional - sage.rings.finite_rings - sage: hasattr(P, '_order') # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(31337), [42,1]) + sage: P = E.lift_x(1) + sage: hasattr(P, '_order') False - sage: P.order() # optional - sage.rings.finite_rings + sage: P.order() 15649 - sage: P._order # optional - sage.rings.finite_rings + sage: P._order 15649 The curve order should also get cached as a side effect of computing a point order:: - sage: E._order # optional - sage.rings.finite_rings + sage: E._order # needs sage.rings.finite_rings 31298 """ try: diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py index 765485f0374..4766a720eba 100644 --- a/src/sage/schemes/elliptic_curves/ell_rational_field.py +++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py @@ -4160,22 +4160,22 @@ def reduction(self,p): EXAMPLES:: sage: E = EllipticCurve('389a1') - sage: E.reduction(2) # optional - sage.rings.finite_rings + sage: E.reduction(2) Elliptic Curve defined by y^2 + y = x^3 + x^2 over Finite Field of size 2 - sage: E.reduction(3) # optional - sage.rings.finite_rings + sage: E.reduction(3) Elliptic Curve defined by y^2 + y = x^3 + x^2 + x over Finite Field of size 3 - sage: E.reduction(5) # optional - sage.rings.finite_rings + sage: E.reduction(5) Elliptic Curve defined by y^2 + y = x^3 + x^2 + 3*x over Finite Field of size 5 - sage: E.reduction(38) # optional - sage.rings.finite_rings + sage: E.reduction(38) Traceback (most recent call last): ... AttributeError: p must be prime. - sage: E.reduction(389) # optional - sage.rings.finite_rings + sage: E.reduction(389) Traceback (most recent call last): ... AttributeError: The curve must have good reduction at p. sage: E = EllipticCurve([5^4, 5^6]) - sage: E.reduction(5) # optional - sage.rings.finite_rings + sage: E.reduction(5) Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 5 """ p = Integer(p) @@ -4513,7 +4513,7 @@ def has_rational_cm(self, field=None): If we extend scalars to a field in which the discriminant is a square, the CM becomes rational:: - sage: E.has_rational_cm(QuadraticField(-3)) # optional - sage.rings.number_field + sage: E.has_rational_cm(QuadraticField(-3)) # needs sage.rings.number_field True sage: E = EllipticCurve(j=8000) @@ -4527,7 +4527,7 @@ def has_rational_cm(self, field=None): Again, we may extend scalars to a field in which the discriminant is a square, where the CM becomes rational:: - sage: E.has_rational_cm(QuadraticField(-2)) # optional - sage.rings.number_field + sage: E.has_rational_cm(QuadraticField(-2)) # needs sage.rings.number_field True The field need not be a number field provided that it is an @@ -4541,7 +4541,7 @@ def has_rational_cm(self, field=None): An error is raised if a field is given which is not an extension of `\QQ`, i.e., not of characteristic `0`:: - sage: E.has_rational_cm(GF(2)) # optional - sage.rings.finite_rings + sage: E.has_rational_cm(GF(2)) Traceback (most recent call last): ... ValueError: Error in has_rational_cm: Finite Field of size 2 @@ -5229,7 +5229,7 @@ def isogeny_graph(self, order=None): 6 Elliptic Curve defined by y^2 + x*y = x^3 - 8125*x - 282568 over Rational Field 7 Elliptic Curve defined by y^2 + x*y = x^3 - 7930*x - 296725 over Rational Field 8 Elliptic Curve defined by y^2 + x*y = x^3 - 130000*x - 18051943 over Rational Field - sage: G.plot(edge_labels=True) + sage: G.plot(edge_labels=True) # needs sage.plot Graphics object consisting of 23 graphics primitives """ return self.isogeny_class(order=order).graph() diff --git a/src/sage/schemes/elliptic_curves/ell_torsion.py b/src/sage/schemes/elliptic_curves/ell_torsion.py index f56c3ee0e6f..9a39ead60e5 100644 --- a/src/sage/schemes/elliptic_curves/ell_torsion.py +++ b/src/sage/schemes/elliptic_curves/ell_torsion.py @@ -100,6 +100,7 @@ class EllipticCurveTorsionSubgroup(groups.AdditiveAbelianGroupWrapper): Examples over other Number Fields:: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('11a1') sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + 1) @@ -111,9 +112,9 @@ class EllipticCurveTorsionSubgroup(groups.AdditiveAbelianGroupWrapper): over Number Field in i with defining polynomial x^2 + 1 sage: E = EllipticCurve('11a1') - sage: K. = NumberField(x^2 + 1) - sage: EK = E.change_ring(K) - sage: T = EK.torsion_subgroup() + sage: K. = NumberField(x^2 + 1) # needs sage.rings.number_field + sage: EK = E.change_ring(K) # needs sage.rings.number_field + sage: T = EK.torsion_subgroup() # needs sage.rings.number_field sage: T.ngens() 1 sage: T.gen(0) @@ -121,6 +122,7 @@ class EllipticCurveTorsionSubgroup(groups.AdditiveAbelianGroupWrapper): Note: this class is normally constructed indirectly as follows:: + sage: # needs sage.rings.number_field sage: T = EK.torsion_subgroup(); T Torsion Subgroup isomorphic to Z/5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) @@ -147,20 +149,20 @@ def __init__(self, E): sage: from sage.schemes.elliptic_curves.ell_torsion import EllipticCurveTorsionSubgroup sage: E = EllipticCurve('11a1') sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) - sage: EK = E.change_ring(K) - sage: EllipticCurveTorsionSubgroup(EK) + sage: K. = NumberField(x^2 + 1) # needs sage.rings.number_field + sage: EK = E.change_ring(K) # needs sage.rings.number_field + sage: EllipticCurveTorsionSubgroup(EK) # needs sage.rings.number_field Torsion Subgroup isomorphic to Z/5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in i with defining polynomial x^2 + 1 Note: this class is normally constructed indirectly as follows:: - sage: T = EK.torsion_subgroup(); T + sage: T = EK.torsion_subgroup(); T # needs sage.rings.number_field Torsion Subgroup isomorphic to Z/5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in i with defining polynomial x^2 + 1 - sage: type(T) + sage: type(T) # needs sage.rings.number_field sage: T == loads(dumps(T)) # known bug, see https://github.com/sagemath/sage/issues/11599#comment:7 @@ -219,9 +221,9 @@ def _repr_(self): sage: E = EllipticCurve('11a1') sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + 1) - sage: EK = E.change_ring(K) - sage: T = EK.torsion_subgroup(); T._repr_() + sage: K. = NumberField(x^2 + 1) # needs sage.rings.number_field + sage: EK = E.change_ring(K) # needs sage.rings.number_field + sage: T = EK.torsion_subgroup(); T._repr_() # needs sage.rings.number_field 'Torsion Subgroup isomorphic to Z/5 associated to the Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in i with defining polynomial x^2 + 1' """ return "Torsion Subgroup isomorphic to %s associated to the %s" % (self.short_name(), self.__E) @@ -247,6 +249,7 @@ def curve(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('11a1') sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + 1) @@ -266,6 +269,7 @@ def points(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 + 1) sage: E = EllipticCurve(K, [0,0,0,1,0]) @@ -315,6 +319,7 @@ def torsion_bound(E, number_of_places=20): An example over a relative number field (see :trac:`16011`):: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: F. = QuadraticField(5) sage: K. = F.extension(x^2 - 3) @@ -324,6 +329,7 @@ def torsion_bound(E, number_of_places=20): An example of a base-change curve from `\QQ` to a degree 16 field:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.ell_torsion import torsion_bound sage: f = PolynomialRing(QQ,'x')([5643417737593488384,0, ....: -11114515801179776,0,-455989850911004,0,379781901872, diff --git a/src/sage/schemes/elliptic_curves/ell_wp.py b/src/sage/schemes/elliptic_curves/ell_wp.py index 462899d33f2..8785976dec3 100644 --- a/src/sage/schemes/elliptic_curves/ell_wp.py +++ b/src/sage/schemes/elliptic_curves/ell_wp.py @@ -91,34 +91,34 @@ def weierstrass_p(E, prec=20, algorithm=None): sage: E.weierstrass_p(prec=8, algorithm='quadratic') z^-2 + 31/15*z^2 + 2501/756*z^4 + 961/675*z^6 + O(z^8) - sage: k = GF(11) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,1]) # optional - sage.rings.finite_rings - sage: E.weierstrass_p(prec=6, algorithm='fast') # optional - sage.rings.finite_rings + sage: k = GF(11) + sage: E = EllipticCurve(k, [1,1]) + sage: E.weierstrass_p(prec=6, algorithm='fast') z^-2 + 2*z^2 + 3*z^4 + O(z^6) - sage: E.weierstrass_p(prec=7, algorithm='fast') # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=7, algorithm='fast') Traceback (most recent call last): ... ValueError: for computing the Weierstrass p-function via the fast algorithm, the characteristic (11) of the underlying field must be greater than prec + 4 = 11 - sage: E.weierstrass_p(prec=8) # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=8) z^-2 + 2*z^2 + 3*z^4 + 5*z^6 + O(z^8) - sage: E.weierstrass_p(prec=8, algorithm='quadratic') # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=8, algorithm='quadratic') z^-2 + 2*z^2 + 3*z^4 + 5*z^6 + O(z^8) - sage: E.weierstrass_p(prec=8, algorithm='pari') # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=8, algorithm='pari') z^-2 + 2*z^2 + 3*z^4 + 5*z^6 + O(z^8) - sage: E.weierstrass_p(prec=9) # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=9) Traceback (most recent call last): ... NotImplementedError: currently no algorithms for computing the Weierstrass p-function for that characteristic / precision pair is implemented. Lower the precision below char(k) - 2 - sage: E.weierstrass_p(prec=9, algorithm="quadratic") # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=9, algorithm="quadratic") Traceback (most recent call last): ... ValueError: for computing the Weierstrass p-function via the quadratic algorithm, the characteristic (11) of the underlying field must be greater than prec + 2 = 11 - sage: E.weierstrass_p(prec=9, algorithm='pari') # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=9, algorithm='pari') Traceback (most recent call last): ... ValueError: for computing the Weierstrass p-function via pari, the @@ -126,7 +126,7 @@ def weierstrass_p(E, prec=20, algorithm=None): TESTS:: - sage: E.weierstrass_p(prec=4, algorithm='foo') # optional - sage.rings.finite_rings + sage: E.weierstrass_p(prec=4, algorithm='foo') Traceback (most recent call last): ... ValueError: unknown algorithm for computing the Weierstrass p-function @@ -224,13 +224,13 @@ def compute_wp_quadratic(k, A, B, prec): sage: E.weierstrass_p(prec=10, algorithm='quadratic') z^-2 - 7/5*z^2 + 49/75*z^6 + O(z^10) - sage: E = EllipticCurve(GF(103), [1,2]) # optional - sage.rings.finite_rings - sage: E.weierstrass_p(algorithm='quadratic') # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(103), [1,2]) + sage: E.weierstrass_p(algorithm='quadratic') z^-2 + 41*z^2 + 88*z^4 + 11*z^6 + 57*z^8 + 55*z^10 + 73*z^12 + 11*z^14 + 17*z^16 + 50*z^18 + O(z^20) sage: from sage.schemes.elliptic_curves.ell_wp import compute_wp_quadratic - sage: compute_wp_quadratic(E.base_ring(), E.a4(), E.a6(), prec=10) # optional - sage.rings.finite_rings + sage: compute_wp_quadratic(E.base_ring(), E.a4(), E.a6(), prec=10) z^-2 + 41*z^2 + 88*z^4 + 11*z^6 + 57*z^8 + O(z^10) """ m = (prec + 1)//2 @@ -283,8 +283,8 @@ def compute_wp_fast(k, A, B, m): sage: compute_wp_fast(QQ, 1, 8, 7) z^-2 - 1/5*z^2 - 8/7*z^4 + 1/75*z^6 + O(z^7) - sage: k = GF(37) # optional - sage.rings.finite_rings - sage: compute_wp_fast(k, k(1), k(8), 5) # optional - sage.rings.finite_rings + sage: k = GF(37) + sage: compute_wp_fast(k, k(1), k(8), 5) z^-2 + 22*z^2 + 20*z^4 + O(z^5) """ R = PowerSeriesRing(k,'z',default_prec=m+5) @@ -330,15 +330,15 @@ def solve_linear_differential_system(a, b, c, alpha): EXAMPLES:: sage: from sage.schemes.elliptic_curves.ell_wp import solve_linear_differential_system - sage: k = GF(17) # optional - sage.rings.finite_rings - sage: R. = PowerSeriesRing(k) # optional - sage.rings.finite_rings - sage: a = 1 + x + O(x^7); b = x + O(x^7); c = 1 + x^3 + O(x^7); alpha = k(3) # optional - sage.rings.finite_rings - sage: f = solve_linear_differential_system(a, b, c, alpha) # optional - sage.rings.finite_rings - sage: f # optional - sage.rings.finite_rings + sage: k = GF(17) + sage: R. = PowerSeriesRing(k) + sage: a = 1 + x + O(x^7); b = x + O(x^7); c = 1 + x^3 + O(x^7); alpha = k(3) + sage: f = solve_linear_differential_system(a, b, c, alpha) + sage: f 3 + x + 15*x^2 + x^3 + 10*x^5 + 3*x^6 + 13*x^7 + O(x^8) - sage: a*f.derivative() + b*f - c # optional - sage.rings.finite_rings + sage: a*f.derivative() + b*f - c O(x^7) - sage: f(0) == alpha # optional - sage.rings.finite_rings + sage: f(0) == alpha True """ a_recip = 1 / a diff --git a/src/sage/schemes/elliptic_curves/formal_group.py b/src/sage/schemes/elliptic_curves/formal_group.py index 63ce58c74c6..dbd2db5f778 100644 --- a/src/sage/schemes/elliptic_curves/formal_group.py +++ b/src/sage/schemes/elliptic_curves/formal_group.py @@ -488,26 +488,26 @@ def group_law(self, prec=10): sage: ehat.group_law(5) t1 + t2 - t1*t2 - 2*t1^3*t2 - 3*t1^2*t2^2 - 2*t1*t2^3 + O(t1, t2)^5 - sage: e = EllipticCurve(GF(7), [3, 4]) # optional - sage.rings.finite_rings - sage: ehat = e.formal() # optional - sage.rings.finite_rings - sage: ehat.group_law(3) # optional - sage.rings.finite_rings + sage: e = EllipticCurve(GF(7), [3, 4]) + sage: ehat = e.formal() + sage: ehat.group_law(3) t1 + t2 + O(t1, t2)^3 - sage: F = ehat.group_law(7); F # optional - sage.rings.finite_rings + sage: F = ehat.group_law(7); F t1 + t2 + t1^4*t2 + 2*t1^3*t2^2 + 2*t1^2*t2^3 + t1*t2^4 + O(t1, t2)^7 TESTS:: - sage: R. = GF(7)[[]] # optional - sage.rings.finite_rings - sage: F(x, ehat.inverse()(x)) # optional - sage.rings.finite_rings + sage: R. = GF(7)[[]] + sage: F(x, ehat.inverse()(x)) 0 + O(x, y, z)^7 - sage: F(x, y) == F(y, x) # optional - sage.rings.finite_rings + sage: F(x, y) == F(y, x) True - sage: F(x, F(y, z)) == F(F(x, y), z) # optional - sage.rings.finite_rings + sage: F(x, F(y, z)) == F(F(x, y), z) True Let's ensure caching with changed precision is working:: - sage: e.formal_group().group_law(4) # optional - sage.rings.finite_rings + sage: e.formal_group().group_law(4) t1 + t2 + O(t1, t2)^4 Test for :trac:`9646`:: @@ -625,12 +625,12 @@ def mult_by_n(self, n, prec=10): TESTS:: - sage: F = EllipticCurve(GF(17), [1, 1]).formal_group() # optional - sage.rings.finite_rings - sage: F.mult_by_n(10, 50) # long time (13s on sage.math, 2011) # optional - sage.rings.finite_rings + sage: F = EllipticCurve(GF(17), [1, 1]).formal_group() + sage: F.mult_by_n(10, 50) # long time 10*t + 5*t^5 + 7*t^7 + 13*t^9 + t^11 + 16*t^13 + 13*t^15 + 9*t^17 + 16*t^19 + 15*t^23 + 15*t^25 + 2*t^27 + 10*t^29 + 8*t^31 + 15*t^33 + 6*t^35 + 7*t^37 + 9*t^39 + 10*t^41 + 5*t^43 + 4*t^45 + 6*t^47 + 13*t^49 + O(t^50) - sage: F = EllipticCurve(GF(101), [1, 1]).formal_group() # optional - sage.rings.finite_rings - sage: F.mult_by_n(100, 20) # optional - sage.rings.finite_rings + sage: F = EllipticCurve(GF(101), [1, 1]).formal_group() + sage: F.mult_by_n(100, 20) 100*t + O(t^20) sage: P. = PolynomialRing(ZZ, 5) diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py index 06fa51c9050..e257b511371 100644 --- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py +++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.rings.number_field r""" Galois representations for elliptic curves over number fields diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py index 34418ad1025..198ceed7218 100644 --- a/src/sage/schemes/elliptic_curves/gp_simon.py +++ b/src/sage/schemes/elliptic_curves/gp_simon.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.libs.pari """ Denis Simon's PARI scripts """ @@ -54,37 +55,41 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None, EXAMPLES:: sage: import sage.schemes.elliptic_curves.gp_simon - sage: E=EllipticCurve('389a1') + sage: E = EllipticCurve('389a1') sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E) (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)]) TESTS:: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('37a1').change_ring(QuadraticField(-11,'x')) sage: E.simon_two_descent() (1, 1, [(0 : 0 : 1)]) An example with an elliptic curve defined over a relative number field:: + sage: # needs sage.rings.number_field sage: F. = QuadraticField(29) sage: x = QQ['x'].gen() sage: K. = F.extension(x^2-1/2*a+1/2) - sage: E = EllipticCurve(K,[1, 0, 5/2*a + 27/2, 0, 0]) # long time (about 3 s) + sage: E = EllipticCurve(K,[1, 0, 5/2*a + 27/2, 0, 0]) # long time (about 3 s) sage: E.simon_two_descent(lim1=2, limtriv=3) (1, 1, ...) Check that :trac:`16022` is fixed:: + sage: # needs sage.rings.number_field sage: K. = NumberField(x^4 + x^2 - 7) sage: E = EllipticCurve(K, [1, 0, 5*y^2 + 16, 0, 0]) - sage: E.simon_two_descent(lim1=2, limtriv=3) # long time (about 3 s) + sage: E.simon_two_descent(lim1=2, limtriv=3) # long time (about 3 s) (1, 1, ...) An example that checks that :trac:`9322` is fixed (it should take less than a second to run):: - sage: K. = NumberField(x^2-x-232) - sage: E = EllipticCurve([2-w,18+3*w,209+9*w,2581+175*w,852-55*w]) - sage: E.simon_two_descent() # long time + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 - x - 232) + sage: E = EllipticCurve([2 - w, 18 + 3*w, 209 + 9*w, 2581 + 175*w, 852 - 55*w]) + sage: E.simon_two_descent() # long time (0, 2, []) """ init() diff --git a/src/sage/schemes/elliptic_curves/heegner.py b/src/sage/schemes/elliptic_curves/heegner.py index 75a356289f2..793c1652e53 100644 --- a/src/sage/schemes/elliptic_curves/heegner.py +++ b/src/sage/schemes/elliptic_curves/heegner.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.number_field +# sage.doctest: needs sage.rings.number_field r""" Heegner points on elliptic curves over the rational numbers @@ -2654,9 +2654,9 @@ def plot(self, *args, **kwds): EXAMPLES:: - sage: heegner_points(389,-7,5).plot(pointsize=50, rgbcolor='red') # optional - sage.plot + sage: heegner_points(389,-7,5).plot(pointsize=50, rgbcolor='red') # needs sage.plot Graphics object consisting of 12 graphics primitives - sage: heegner_points(53,-7,15).plot(pointsize=50, rgbcolor='purple') # optional - sage.plot + sage: heegner_points(53,-7,15).plot(pointsize=50, rgbcolor='purple') # needs sage.plot Graphics object consisting of 48 graphics primitives """ return sum(z.plot(*args, **kwds) for z in self) @@ -4285,7 +4285,7 @@ def plot(self, prec=53, *args, **kwds): EXAMPLES:: sage: E = EllipticCurve('37a'); P = E.heegner_point(-11).kolyvagin_point() - sage: P.plot(prec=30, pointsize=50, rgbcolor='red') + E.plot() # optional - sage.plot + sage: P.plot(prec=30, pointsize=50, rgbcolor='red') + E.plot() # needs sage.plot Graphics object consisting of 3 graphics primitives """ if self.conductor() != 1: diff --git a/src/sage/schemes/elliptic_curves/height.py b/src/sage/schemes/elliptic_curves/height.py index 506dc229f1d..97020957574 100644 --- a/src/sage/schemes/elliptic_curves/height.py +++ b/src/sage/schemes/elliptic_curves/height.py @@ -85,7 +85,7 @@ def __init__(self, endpoints): sage: from sage.schemes.elliptic_curves.height import UnionOfIntervals sage: UnionOfIntervals([0, 1]) ([0, 1]) - sage: UnionOfIntervals([-infinity, pi, 17, infinity]) # optional - sage.symbolic + sage: UnionOfIntervals([-infinity, pi, 17, infinity]) # needs sage.symbolic ([-Infinity, pi] U [17, +Infinity]) sage: UnionOfIntervals([]) () @@ -128,7 +128,7 @@ def intervals(self): sage: from sage.schemes.elliptic_curves.height import UnionOfIntervals sage: UnionOfIntervals(list(range(10))).intervals() [(0, 1), (2, 3), (4, 5), (6, 7), (8, 9)] - sage: UnionOfIntervals([-infinity, pi, 17, infinity]).intervals() + sage: UnionOfIntervals([-infinity, pi, 17, infinity]).intervals() # needs sage.symbolic [(-Infinity, pi), (17, +Infinity)] """ return list(zip(self._endpoints[::2], self._endpoints[1::2])) @@ -165,7 +165,7 @@ def __add__(left, right): ([0, 1/2] U [2, +Infinity]) sage: A + 1 ([1, 3/2] U [3, +Infinity]) - sage: pi + A + sage: pi + A # needs sage.symbolic ([pi, pi + 1/2] U [pi + 2, +Infinity]) sage: A + UnionOfIntervals([-infinity, -1]) ([-Infinity, -1] U [0, 1/2] U [2, +Infinity]) @@ -209,7 +209,7 @@ def __rmul__(self, other): sage: from sage.schemes.elliptic_curves.height import UnionOfIntervals sage: A = UnionOfIntervals([0, 1/2, 2, infinity]); A ([0, 1/2] U [2, +Infinity]) - sage: pi * A + sage: pi * A # needs sage.symbolic ([0, 1/2*pi] U [2*pi, +Infinity]) """ return self * other @@ -786,9 +786,9 @@ def __init__(self, E): An example over a number field:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,i,0,i,i]) # optional - sage.rings.number_field - sage: EllipticCurveCanonicalHeight(E) # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve([0,i,0,i,i]) # needs sage.rings.number_field + sage: EllipticCurveCanonicalHeight(E) # needs sage.rings.number_field EllipticCurveCanonicalHeight object associated to Elliptic Curve defined by y^2 = x^3 + i*x^2 + i*x + i over Number Field in i with defining polynomial x^2 + 1 with i = 1*I @@ -798,8 +798,8 @@ def __init__(self, E): The base field must be a number field (or `\QQ`):: sage: from sage.schemes.elliptic_curves.height import EllipticCurveCanonicalHeight - sage: E = EllipticCurve(GF(7), [0,0,0,0,1]) # optional - sage.rings.finite_rings - sage: EllipticCurveCanonicalHeight(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7), [0,0,0,0,1]) + sage: EllipticCurveCanonicalHeight(E) Traceback (most recent call last): ... ValueError: EllipticCurveCanonicalHeight class can only be created @@ -884,12 +884,13 @@ def __call__(self, P): Over a number field other than `\QQ`:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,-27]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.base_field() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve(K, [0,0,0,1,-27]) + sage: H = E.height_function() + sage: H.base_field() Number Field in i with defining polynomial x^2 + 1 with i = 1*I - sage: H((1, 5*i)) # optional - sage.rings.number_field + sage: H((1, 5*i)) 1.22257115164148 """ return self.E(P).height() @@ -913,16 +914,17 @@ def alpha(self, v, tol=0.01): Example 1 from [CPS2006]_:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: alpha = H.alpha(K.places()[0]) # optional - sage.rings.number_field - sage: alpha # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) + sage: H = E.height_function() + sage: alpha = H.alpha(K.places()[0]) + sage: alpha 1.12272013439355 Compare with `\log(\epsilon_v)=0.344562...` in [CPS2006]_:: - sage: 3*alpha.log() # optional - sage.rings.number_field + sage: 3*alpha.log() # needs sage.rings.number_field 0.347263296676126 """ from sage.rings.polynomial.polynomial_ring import polygen @@ -984,29 +986,30 @@ def e_p(self, p): EXAMPLES:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.e_p(K.prime_above(2)) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) + sage: H = E.height_function() + sage: H.e_p(K.prime_above(2)) 2 - sage: H.e_p(K.prime_above(3)) # optional - sage.rings.number_field + sage: H.e_p(K.prime_above(3)) 10 - sage: H.e_p(K.prime_above(5)) # optional - sage.rings.number_field + sage: H.e_p(K.prime_above(5)) 9 - sage: E.conductor().norm().factor() # optional - sage.rings.number_field + sage: E.conductor().norm().factor() 2^10 * 20921 - sage: p1, p2 = K.primes_above(20921) # optional - sage.rings.number_field - sage: E.local_data(p1) # optional - sage.rings.number_field + sage: p1, p2 = K.primes_above(20921) + sage: E.local_data(p1) Local data at Fractional ideal (-40*i + 139): Reduction type: bad split multiplicative ... - sage: H.e_p(p1) # optional - sage.rings.number_field + sage: H.e_p(p1) 20920 - sage: E.local_data(p2) # optional - sage.rings.number_field + sage: E.local_data(p2) Local data at Fractional ideal (40*i + 139): Reduction type: good ... - sage: H.e_p(p2) # optional - sage.rings.number_field + sage: H.e_p(p2) 20815 """ kp = self.K.residue_field(p) @@ -1036,10 +1039,11 @@ def DE(self, n): EXAMPLES:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 1+5*i, 3+i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: [H.DE(n) for n in srange(1,6)] # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 1+5*i, 3+i]) + sage: H = E.height_function() + sage: [H.DE(n) for n in srange(1,6)] [0, 2*log(5) + 2*log(2), 0, 2*log(13) + 2*log(5) + 4*log(2), 0] """ s = 0 @@ -1064,10 +1068,10 @@ def ME(self): EXAMPLES:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 1+5*i, 3+i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.ME() # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve([0, 0, 0, 1+5*i, 3+i]) # needs sage.rings.number_field + sage: H = E.height_function() # needs sage.rings.number_field + sage: H.ME() # needs sage.rings.number_field 1 sage: E = EllipticCurve([0,0,0,0,1]) sage: E.height_function().ME() @@ -1103,13 +1107,13 @@ def B(self, n, mu): Example 10.2 from [Tho2010]_:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 1-i, i, -i, 0]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve([0, 1-i, i, -i, 0]) # needs sage.rings.number_field + sage: H = E.height_function() # needs sage.rings.number_field In [Tho2010]_ the value is given as 0.772:: - sage: RealField(12)( H.B(5, 0.01) ) # optional - sage.rings.number_field + sage: RealField(12)( H.B(5, 0.01) ) # needs sage.rings.number_field 0.777 """ K = self.K @@ -1162,21 +1166,22 @@ def psi(self, xi, v): An example over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: P = E.lift_x(1/3*a^2 + a + 5/3) # optional - sage.rings.number_field - sage: v = K.real_places()[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(v) # optional - sage.rings.number_field - sage: L(P) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: P = E.lift_x(1/3*a^2 + a + 5/3) + sage: v = K.real_places()[0] + sage: L = E.period_lattice(v) + sage: L(P) 3.51086196882538 - sage: L(P) / L.real_period() # optional - sage.rings.number_field + sage: L(P) / L.real_period() 0.867385122699931 - sage: xP = v(P.xy()[0]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.psi(xP, v) # optional - sage.rings.number_field + sage: xP = v(P.xy()[0]) + sage: H = E.height_function() + sage: H.psi(xP, v) 0.867385122699931 - sage: H.psi(1.23, v) # optional - sage.rings.number_field + sage: H.psi(1.23, v) 0.785854718241495 """ if xi > 1e9: @@ -1218,12 +1223,13 @@ def S(self, xi1, xi2, v): An example over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: v = K.real_places()[0] # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.S(9, 10, v) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: v = K.real_places()[0] + sage: H = E.height_function() + sage: H.S(9, 10, v) ([0.078119444725347..., 0.082342373201640...] U [0.91765762679836..., 0.92188055527465...]) """ L = self.E.period_lattice(v) @@ -1270,15 +1276,16 @@ def Sn(self, xi1, xi2, n, v): An example over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: v = K.real_places()[0] # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.S(2, 3, v), H.Sn(2, 3, 1, v) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: v = K.real_places()[0] + sage: H = E.height_function() + sage: H.S(2, 3, v), H.Sn(2, 3, 1, v) (([0.142172065860075, 0.172845716928584] U [0.827154283071416, 0.857827934139925]), ([0.142172065860075, 0.172845716928584] U [0.827154283071416, 0.857827934139925])) - sage: H.Sn(2, 3, 6, v) # optional - sage.rings.number_field + sage: H.Sn(2, 3, 6, v) ([0.0236953443100124, 0.0288076194880974] U [0.137859047178569, 0.142971322356654] U [0.190362010976679, 0.195474286154764] U [0.304525713845236, 0.309637989023321] U [0.357028677643346, 0.362140952821431] U [0.471192380511903, 0.476304655689988] U [0.523695344310012, 0.528807619488097] U [0.637859047178569, 0.642971322356654] U [0.690362010976679, 0.695474286154764] U [0.804525713845236, 0.809637989023321] U [0.857028677643346, 0.862140952821431] U [0.971192380511903, 0.976304655689988]) """ SS = 1/ZZ(n) * self.S(xi1, xi2, v) @@ -1324,20 +1331,21 @@ def real_intersection_is_empty(self, Bk, v): An example over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: v = K.real_places()[0] # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: v = K.real_places()[0] + sage: H = E.height_function() The following two lines prove that the heights of non-torsion points on `E` with everywhere good reduction have canonical height strictly greater than 0.07, but fail to prove the same for 0.08:: - sage: H.real_intersection_is_empty([H.B(n,0.07) for n in srange(1,5)], v) # long time (3.3s) # optional - sage.rings.number_field + sage: H.real_intersection_is_empty([H.B(n,0.07) for n in srange(1,5)], v) # long time, needs sage.rings.number_field True - sage: H.real_intersection_is_empty([H.B(n,0.08) for n in srange(1,5)], v) # optional - sage.rings.number_field + sage: H.real_intersection_is_empty([H.B(n,0.08) for n in srange(1,5)], v) # needs sage.rings.number_field False """ return UnionOfIntervals.intersection([self.Sn(-B, B, k+1, v) for k,B in enumerate(Bk)]).is_empty() @@ -1396,10 +1404,11 @@ def wp_c(self, v): sage: H.wp_c(QQ.places()[0]) 2.68744508779950 - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.wp_c(K.places()[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 1 + 5*i, 3 + i]) + sage: H = E.height_function() + sage: H.wp_c(K.places()[0]) 2.66213425640096 """ # Note that we normalise w1, w2 differently from [Tho2010]_! @@ -1675,11 +1684,12 @@ def complex_intersection_is_empty(self, Bk, v, verbose=False, use_half=True): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: v = K.complex_embeddings()[0] # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: v = K.complex_embeddings()[0] + sage: H = E.height_function() The following two lines prove that the heights of non-torsion points on `E` with everywhere good reduction have canonical @@ -1687,18 +1697,18 @@ def complex_intersection_is_empty(self, Bk, v, verbose=False, use_half=True): for 0.03. For the first proof, using only `n=1,2,3` is not sufficient:: - sage: H.complex_intersection_is_empty([H.B(n,0.02) for n in [1,2,3]], v) # long time (~6s) # optional - sage.rings.number_field + sage: H.complex_intersection_is_empty([H.B(n,0.02) for n in [1,2,3]], v) # long time, needs sage.rings.number_field False - sage: H.complex_intersection_is_empty([H.B(n,0.02) for n in [1,2,3,4]], v) # optional - sage.rings.number_field + sage: H.complex_intersection_is_empty([H.B(n,0.02) for n in [1,2,3,4]], v) # needs sage.rings.number_field True - sage: H.complex_intersection_is_empty([H.B(n,0.03) for n in [1,2,3,4]], v) # long time (4s) # optional - sage.rings.number_field + sage: H.complex_intersection_is_empty([H.B(n,0.03) for n in [1,2,3,4]], v) # long time, needs sage.rings.number_field False Using `n\le6` enables us to prove the lower bound 0.03. Note that it takes longer when the result is ``False`` than when it is ``True``:: - sage: H.complex_intersection_is_empty([H.B(n,0.03) for n in [1..6]], v) # optional - sage.rings.number_field + sage: H.complex_intersection_is_empty([H.B(n,0.03) for n in [1..6]], v) # needs sage.rings.number_field True """ from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion @@ -1795,28 +1805,28 @@ def test_mu(self, mu, N, verbose=True): EXAMPLES:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: E = EllipticCurve([0,0,0,0,a]) # needs sage.rings.number_field + sage: H = E.height_function() # needs sage.rings.number_field This curve does have a point of good reduction whose canonical point is approximately 1.68:: - sage: P = E.gens(lim3=5)[0]; P # optional - sage.rings.number_field + sage: P = E.gens(lim3=5)[0]; P # needs sage.rings.number_field (1/3*a^2 + a + 5/3 : -2*a^2 - 4/3*a - 5/3 : 1) - sage: P.height() # optional - sage.rings.number_field + sage: P.height() # needs sage.rings.number_field 1.68038085233673 - sage: P.has_good_reduction() # optional - sage.rings.number_field + sage: P.has_good_reduction() # needs sage.rings.number_field True Using `N=5` we can prove that 0.1 is a lower bound (in fact we only need `N=2`), but not that 0.2 is:: - sage: H.test_mu(0.1, 5) # optional - sage.rings.number_field + sage: H.test_mu(0.1, 5) # needs sage.rings.number_field B_1(0.100000000000000) = 1.51580969677387 B_2(0.100000000000000) = 0.932072561526720 True - sage: H.test_mu(0.2, 5) # optional - sage.rings.number_field + sage: H.test_mu(0.2, 5) # needs sage.rings.number_field B_1(0.200000000000000) = 2.04612906979932 B_2(0.200000000000000) = 3.09458988474327 B_3(0.200000000000000) = 27.6251108409484 @@ -1828,11 +1838,11 @@ def test_mu(self, mu, N, verbose=True): either primitive or divisible by either 2 or 3. In fact it is primitive:: - sage: (P.height()/0.1).sqrt() # optional - sage.rings.number_field + sage: (P.height()/0.1).sqrt() # needs sage.rings.number_field 4.09924487233530 - sage: P.division_points(2) # optional - sage.rings.number_field + sage: P.division_points(2) # needs sage.rings.number_field [] - sage: P.division_points(3) # optional - sage.rings.number_field + sage: P.division_points(3) # needs sage.rings.number_field [] """ # Compute the list of values `B_n(\mu)` for n in 1..N. If any @@ -1903,46 +1913,50 @@ def min_gr(self, tol, n_max, verbose=False): Example 10.1 from [Tho2010]_ (where a lower bound of 0.18 was given):: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 91 - 26*i, -144 - 323*i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min_gr(0.1, 4) # long time (8.1s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 91 - 26*i, -144 - 323*i]) + sage: H = E.height_function() + sage: H.min_gr(0.1, 4) # long time 0.1621049443313762 Example 10.2 from [Tho2010]_:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 1 - i, i, -i, 0]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min_gr(0.01, 5) # long time # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 1 - i, i, -i, 0]) + sage: H = E.height_function() + sage: H.min_gr(0.01, 5) # long time 0.020153685521979152 In this example the point `P=(0,0)` has height 0.023 so our lower bound is quite good:: - sage: P = E((0,0)) # optional - sage.rings.number_field - sage: P.has_good_reduction() # optional - sage.rings.number_field + sage: P = E((0,0)) # needs sage.rings.number_field + sage: P.has_good_reduction() # needs sage.rings.number_field True - sage: P.height() # optional - sage.rings.number_field + sage: P.height() # needs sage.rings.number_field 0.0230242154471211 Example 10.3 from [Tho2010]_ (where the same bound of 0.25 is given):: - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, -3*a - a^2, a^2]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min_gr(0.1, 5) # long time (7.2s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0, 0, 0, -3*a - a^2, a^2]) + sage: H = E.height_function() + sage: H.min_gr(0.1, 5) # long time 0.25 TESTS: This example from the LMFDB gave problems before the fix in :trac:`8829`:: - sage: K. = NumberField(x^2 - x - 1) # optional - sage.rings.number_field - sage: E = EllipticCurve([phi + 1, -phi + 1, 1, 20*phi - 39, 196*phi + 237]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min_gr(.1, 5, verbose=True) # long time (~22s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 - x - 1) + sage: E = EllipticCurve([phi + 1, -phi + 1, 1, 20*phi - 39, 196*phi + 237]) + sage: H = E.height_function() + sage: H.min_gr(.1, 5, verbose=True) # long time B_1(1) = 1540.199246369678 ... halving mu to 0.25 and increasing n_max to 6 @@ -2024,34 +2038,37 @@ def min(self, tol, n_max, verbose=False): Example 10.1 from [Tho2010]_ (where a lower bound of 0.18 was given):: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, 91 - 26*i, -144 - 323*i]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min(0.1, 4) # long time (8.1s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 0, 0, 91 - 26*i, -144 - 323*i]) + sage: H = E.height_function() + sage: H.min(0.1, 4) # long time 0.1621049443313762 Example 10.2 from [Tho2010]_:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 1 - i, i, -i, 0]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min(0.01, 5) # long time (4s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0, 1 - i, i, -i, 0]) + sage: H = E.height_function() + sage: H.min(0.01, 5) # long time 0.020153685521979152 In this example the point `P=(0,0)` has height 0.023 so our lower bound is quite good:: - sage: P = E((0,0)) # optional - sage.rings.number_field - sage: P.height() # optional - sage.rings.number_field + sage: P = E((0,0)) # needs sage.rings.number_field + sage: P.height() # needs sage.rings.number_field 0.0230242154471211 Example 10.3 from [Tho2010]_ (where the same bound of 0.0625 is given):: - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, 0, 0, -3*a - a^2, a^2]) # optional - sage.rings.number_field - sage: H = E.height_function() # optional - sage.rings.number_field - sage: H.min(0.1, 5) # long time (7s) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0, 0, 0, -3*a - a^2, a^2]) + sage: H = E.height_function() + sage: H.min(0.1, 5) # long time 0.0625 More examples over `\QQ`:: @@ -2065,8 +2082,8 @@ def min(self, tol, n_max, verbose=False): After base change the lower bound can decrease:: - sage: K. = QuadraticField(-5) # optional - sage.rings.number_field - sage: E.change_ring(K).height_function().min(0.5, 10) # long time (8s) # optional - sage.rings.number_field + sage: K. = QuadraticField(-5) # needs sage.rings.number_field + sage: E.change_ring(K).height_function().min(0.5, 10) # long time, needs sage.rings.number_field 0.04419417382415922 sage: E = EllipticCurve('389a') diff --git a/src/sage/schemes/elliptic_curves/hom_composite.py b/src/sage/schemes/elliptic_curves/hom_composite.py index 832fdd036dc..e82cc6d226d 100644 --- a/src/sage/schemes/elliptic_curves/hom_composite.py +++ b/src/sage/schemes/elliptic_curves/hom_composite.py @@ -13,15 +13,16 @@ straightforward :class:`EllipticCurveIsogeny` implementation, but decomposing into prime steps is exponentially faster:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite sage: p = 3 * 2^143 - 1 - sage: GF(p^2).inject_variables() # optional - sage.rings.finite_rings + sage: GF(p^2).inject_variables() Defining z2 - sage: E = EllipticCurve(GF(p^2), [1,0]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(31415926535897932384626433832795028841971 - z2) # optional - sage.rings.finite_rings - sage: P.order().factor() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(p^2), [1,0]) + sage: P = E.lift_x(31415926535897932384626433832795028841971 - z2) + sage: P.order().factor() 2^143 - sage: EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings + sage: EllipticCurveHom_composite(E, P) Composite morphism of degree 11150372599265311570767859136324180752990208 = 2^143: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 33451117797795934712303577408972542258970623^2 @@ -33,40 +34,41 @@ is identical to :class:`EllipticCurveIsogeny` and other instantiations of :class:`EllipticCurveHom`:: - sage: E = EllipticCurve(GF(419), [0,1]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(33); P.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [0,1]) + sage: P = E.lift_x(33); P.order() 35 - sage: psi = EllipticCurveHom_composite(E, P); psi # optional - sage.rings.finite_rings + sage: psi = EllipticCurveHom_composite(E, P); psi Composite morphism of degree 35 = 5*7: From: Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 419 To: Elliptic Curve defined by y^2 = x^3 + 101*x + 285 over Finite Field of size 419 - sage: psi(E.lift_x(11)) # optional - sage.rings.finite_rings + sage: psi(E.lift_x(11)) (352 : 346 : 1) - sage: psi.rational_maps() # optional - sage.rings.finite_rings + sage: psi.rational_maps() ((x^35 + 162*x^34 + 186*x^33 + 92*x^32 - ... + 44*x^3 + 190*x^2 + 80*x - 72)/(x^34 + 162*x^33 - 129*x^32 + 41*x^31 + ... + 66*x^3 - 191*x^2 + 119*x + 21), (x^51*y - 176*x^50*y + 115*x^49*y - 120*x^48*y + ... + 72*x^3*y + 129*x^2*y + 163*x*y + 178*y)/(x^51 - 176*x^50 + 11*x^49 + 26*x^48 - ... - 77*x^3 + 185*x^2 + 169*x - 128)) - sage: psi.kernel_polynomial() # optional - sage.rings.finite_rings + sage: psi.kernel_polynomial() x^17 + 81*x^16 + 7*x^15 + 82*x^14 + 49*x^13 + 68*x^12 + 109*x^11 + 326*x^10 + 117*x^9 + 136*x^8 + 111*x^7 + 292*x^6 + 55*x^5 + 389*x^4 + 175*x^3 + 43*x^2 + 149*x + 373 - sage: psi.dual() # optional - sage.rings.finite_rings + sage: psi.dual() Composite morphism of degree 35 = 7*5: From: Elliptic Curve defined by y^2 = x^3 + 101*x + 285 over Finite Field of size 419 To: Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 419 - sage: psi.formal() # optional - sage.rings.finite_rings + sage: psi.formal() t + 211*t^5 + 417*t^7 + 159*t^9 + 360*t^11 + 259*t^13 + 224*t^15 + 296*t^17 + 139*t^19 + 222*t^21 + O(t^23) Equality is decided correctly (and, in some cases, much faster than comparing :meth:`EllipticCurveHom.rational_maps`) even when distinct factorizations of the same isogeny are compared:: - sage: psi == EllipticCurveIsogeny(E, P) # optional - sage.rings.finite_rings + sage: psi == EllipticCurveIsogeny(E, P) # needs sage.rings.finite_rings True We can easily obtain the individual factors of the composite map:: - sage: psi.factors() # optional - sage.rings.finite_rings + sage: psi.factors() # needs sage.rings.finite_rings (Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 419 to Elliptic Curve defined by y^2 = x^3 + 140*x + 214 over Finite Field of size 419, @@ -100,17 +102,18 @@ def _eval_factored_isogeny(phis, P): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves import hom_composite - sage: E = EllipticCurve(GF(419), [1,0]) # optional - sage.rings.finite_rings - sage: Q = E(21, 8) # optional - sage.rings.finite_rings - sage: phis = [] # optional - sage.rings.finite_rings - sage: while len(phis) < 10: # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [1,0]) + sage: Q = E(21, 8) + sage: phis = [] + sage: while len(phis) < 10: ....: P = list(sorted(E(0).division_points(7)))[1] ....: phis.append(E.isogeny(P)) ....: E = phis[-1].codomain() - sage: R = hom_composite._eval_factored_isogeny(phis, Q); R # optional - sage.rings.finite_rings + sage: R = hom_composite._eval_factored_isogeny(phis, Q); R (290 : 183 : 1) - sage: R in E # optional - sage.rings.finite_rings + sage: R in E True """ for phi in phis: @@ -164,32 +167,34 @@ def _compute_factored_isogeny_prime_power(P, l, n, split=.8): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves import hom_composite - sage: E = EllipticCurve(GF(8191), [1,0]) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: (l,n), = P.order().factor() # optional - sage.rings.finite_rings - sage: phis = hom_composite._compute_factored_isogeny_prime_power(P, l, n) # optional - sage.rings.finite_rings - sage: hom_composite._eval_factored_isogeny(phis, P) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(8191), [1,0]) + sage: P = E.random_point() + sage: (l,n), = P.order().factor() + sage: phis = hom_composite._compute_factored_isogeny_prime_power(P, l, n) + sage: hom_composite._eval_factored_isogeny(phis, P) (0 : 1 : 0) - sage: [phi.degree() for phi in phis] == [l]*n # optional - sage.rings.finite_rings + sage: [phi.degree() for phi in phis] == [l]*n True All choices of ``split`` produce the same result, albeit not equally fast:: - sage: E = EllipticCurve(GF(2^127 - 1), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: (l,n), = P.order().factor() # optional - sage.rings.finite_rings - sage: phis = hom_composite._compute_factored_isogeny_prime_power(P,l,n) # optional - sage.rings.finite_rings - sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(2^127 - 1), [1,0]) + sage: P, = E.gens() + sage: (l,n), = P.order().factor() + sage: phis = hom_composite._compute_factored_isogeny_prime_power(P,l,n) + sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0) True - sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.1) # optional - sage.rings.finite_rings + sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.1) True - sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.5) # optional - sage.rings.finite_rings + sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.5) True - sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.9) # optional - sage.rings.finite_rings + sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=0.9) True - sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=1) # optional - sage.rings.finite_rings + sage: phis == hom_composite._compute_factored_isogeny_prime_power(P,l,n, split=1) True """ def rec(Q, k): @@ -222,13 +227,14 @@ def _compute_factored_isogeny_single_generator(P): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves import hom_composite - sage: E = EllipticCurve(GF(419), [1,0]) # optional - sage.rings.finite_rings - sage: P = E(42, 321) # optional - sage.rings.finite_rings - sage: phis = hom_composite._compute_factored_isogeny_single_generator(P) # optional - sage.rings.finite_rings - sage: list(sorted(phi.degree() for phi in phis)) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [1,0]) + sage: P = E(42, 321) + sage: phis = hom_composite._compute_factored_isogeny_single_generator(P) + sage: list(sorted(phi.degree() for phi in phis)) [2, 2, 3, 5, 7] - sage: hom_composite._eval_factored_isogeny(phis, P) # optional - sage.rings.finite_rings + sage: hom_composite._eval_factored_isogeny(phis, P) (0 : 1 : 0) """ phis = [] @@ -249,13 +255,14 @@ def _compute_factored_isogeny(kernel): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves import hom_composite - sage: E = EllipticCurve(GF(419), [-1,0]) # optional - sage.rings.finite_rings - sage: Ps = [E(41,99), E(41,-99), E(51,14), E(21,21), E(33,17)] # optional - sage.rings.finite_rings - sage: phis = hom_composite._compute_factored_isogeny(Ps) # optional - sage.rings.finite_rings - sage: [phi.degree() for phi in phis] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [-1,0]) + sage: Ps = [E(41,99), E(41,-99), E(51,14), E(21,21), E(33,17)] + sage: phis = hom_composite._compute_factored_isogeny(Ps) + sage: [phi.degree() for phi in phis] [2, 3, 5, 7, 2] - sage: {hom_composite._eval_factored_isogeny(phis, P) for P in Ps} # optional - sage.rings.finite_rings + sage: {hom_composite._eval_factored_isogeny(phis, P) for P in Ps} {(0 : 1 : 0)} """ phis = [] @@ -285,8 +292,8 @@ def __init__(self, E, kernel, codomain=None, model=None): EXAMPLES:: sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(419), [1,0]) # optional - sage.rings.finite_rings - sage: EllipticCurveHom_composite(E, E.lift_x(23)) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [1,0]) # needs sage.rings.finite_rings + sage: EllipticCurveHom_composite(E, E.lift_x(23)) # needs sage.rings.finite_rings Composite morphism of degree 105 = 3*5*7: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 419 @@ -295,14 +302,15 @@ def __init__(self, E, kernel, codomain=None, model=None): The given kernel generators need not be independent:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - x - 5) # optional - sage.rings.number_field - sage: E = EllipticCurve('210.b6').change_ring(K) # optional - sage.rings.number_field - sage: E.torsion_subgroup() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 5) + sage: E = EllipticCurve('210.b6').change_ring(K) + sage: E.torsion_subgroup() Torsion Subgroup isomorphic to Z/12 + Z/2 associated to the Elliptic Curve defined by y^2 + x*y + y = x^3 + (-578)*x + 2756 over Number Field in a with defining polynomial x^2 - x - 5 - sage: EllipticCurveHom_composite(E, E.torsion_points()) # optional - sage.rings.number_field + sage: EllipticCurveHom_composite(E, E.torsion_points()) Composite morphism of degree 24 = 2^3*3: From: Elliptic Curve defined by y^2 + x*y + y = x^3 + (-578)*x + 2756 over Number Field in a with defining polynomial x^2 - x - 5 @@ -312,27 +320,28 @@ def __init__(self, E, kernel, codomain=None, model=None): TESTS:: - sage: E = EllipticCurve(GF(19), [1,0]) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: psi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: psi # random # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(19), [1,0]) + sage: P = E.random_point() + sage: psi = EllipticCurveHom_composite(E, P) + sage: psi # random Composite morphism of degree 10 = 2*5: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 19 To: Elliptic Curve defined by y^2 = x^3 + 14*x over Finite Field of size 19 :: - sage: EllipticCurveHom_composite(E, E.lift_x(3), codomain=E) # optional - sage.rings.finite_rings + sage: EllipticCurveHom_composite(E, E.lift_x(3), codomain=E) Composite morphism of degree 20 = 2^2*5: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 19 To: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 19 :: - sage: E = EllipticCurve(GF((2^127-1)^2), [1,0]) # optional - sage.rings.finite_rings - sage: K = 2^30 * E.random_point() # optional - sage.rings.finite_rings - sage: psi = EllipticCurveHom_composite(E, K, model='montgomery') # optional - sage.rings.finite_rings - sage: psi.codomain().a_invariants() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF((2^127-1)^2), [1,0]) + sage: K = 2^30 * E.random_point() + sage: psi = EllipticCurveHom_composite(E, K, model='montgomery') + sage: psi.codomain().a_invariants() (0, ..., 0, 1, 0) """ if not isinstance(E, EllipticCurve_generic): @@ -416,11 +425,11 @@ def from_factors(cls, maps, E=None, strict=True): EXAMPLES:: sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(43), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: psi = EllipticCurveHom_composite.from_factors(phi.factors()) # optional - sage.rings.finite_rings - sage: psi == phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(43), [1,0]) + sage: P, = E.gens() + sage: phi = EllipticCurveHom_composite(E, P) + sage: psi = EllipticCurveHom_composite.from_factors(phi.factors()) + sage: psi == phi True TESTS:: @@ -431,10 +440,11 @@ def from_factors(cls, maps, E=None, strict=True): :: - sage: E = EllipticCurve(GF(419), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: EllipticCurveHom_composite.from_factors(phi.factors()) == phi # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(419), [1,0]) + sage: P, = E.gens() + sage: phi = EllipticCurveHom_composite(E, P) + sage: EllipticCurveHom_composite.from_factors(phi.factors()) == phi True """ maps = tuple(maps) @@ -467,23 +477,25 @@ def _call_(self, P): TESTS:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 - x - 5) # optional - sage.rings.number_field - sage: E = EllipticCurve('210.b6').change_ring(K) # optional - sage.rings.number_field - sage: psi = EllipticCurveHom_composite(E, E.torsion_points()) # optional - sage.rings.number_field - sage: R = E.lift_x(15/4 * (a+3)) # optional - sage.rings.number_field - sage: psi(R) # indirect doctest # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x - 5) + sage: E = EllipticCurve('210.b6').change_ring(K) + sage: psi = EllipticCurveHom_composite(E, E.torsion_points()) + sage: R = E.lift_x(15/4 * (a+3)) + sage: psi(R) # indirect doctest (1033648757/303450 : -58397496786187/1083316500*a + 54706287407197/2166633000 : 1) Check that copying the order over works:: - sage: E = EllipticCurve(GF(431), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: Q = 2^99*P; Q.order() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(431), [1,0]) + sage: P, = E.gens() + sage: Q = 2^99*P; Q.order() 27 - sage: phi = E.isogeny(3^99*P, algorithm='factored') # optional - sage.rings.finite_rings - sage: phi(Q)._order # optional - sage.rings.finite_rings + sage: phi = E.isogeny(3^99*P, algorithm='factored') + sage: phi(Q)._order 27 """ return _eval_factored_isogeny(self._phis, P) @@ -505,8 +517,8 @@ def _eval(self, P): sage: E = EllipticCurve(j=Mod(1728,419)) sage: K, = E.gens() sage: psi = EllipticCurveHom_composite(E, 4*K) - sage: Ps = E.change_ring(GF(419**2))(0).division_points(5) # optional - sage.rings.finite_rings - sage: {psi._eval(P).curve() for P in Ps} # optional - sage.rings.finite_rings + sage: Ps = E.change_ring(GF(419**2))(0).division_points(5) # needs sage.rings.finite_rings + sage: {psi._eval(P).curve() for P in Ps} # needs sage.rings.finite_rings {Elliptic Curve defined by y^2 = x^3 + 373*x + 126 over Finite Field in z2 of size 419^2} """ if self._domain.defining_polynomial()(*P): @@ -526,14 +538,14 @@ def _repr_(self): TESTS:: sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(43), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi # indirect doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(43), [1,0]) + sage: P, = E.gens() + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi # indirect doctest Composite morphism of degree 44 = 2^2*11: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 43 To: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 43 - sage: phi * phi * phi * phi * phi * phi * phi # indirect doctest # optional - sage.rings.finite_rings + sage: phi * phi * phi * phi * phi * phi * phi # indirect doctest Composite morphism of degree 319277809664 = 2^2*11*2^2*11*2^2*11*2^2*11*2^2*11*2^2*11*2^2*11: From: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 43 To: Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 43 @@ -557,10 +569,10 @@ def factors(self): EXAMPLES:: sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(43), [1,0]) # optional - sage.rings.finite_rings - sage: P, = E.gens() # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi.factors() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(43), [1,0]) + sage: P, = E.gens() + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi.factors() (Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 43 to Elliptic Curve defined by y^2 = x^3 + 39*x over Finite Field of size 43, @@ -584,33 +596,34 @@ def _composition_impl(left, right): TESTS:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve([i + 1, i, 0, -4, -6*i]) # optional - sage.rings.number_field - sage: P,Q = E.lift_x(i - 5), E.lift_x(-4*i) # optional - sage.rings.number_field - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.number_field - sage: psi = phi.codomain().isogeny(phi(Q)) # optional - sage.rings.number_field + sage: E = EllipticCurve([i + 1, i, 0, -4, -6*i]) + sage: P,Q = E.lift_x(i - 5), E.lift_x(-4*i) + sage: phi = EllipticCurveHom_composite(E, P) + sage: psi = phi.codomain().isogeny(phi(Q)) sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: iso1 = WeierstrassIsomorphism(E, (-1, 0, -i - 1, 0)) # optional - sage.rings.number_field - sage: iso2 = psi.codomain().isomorphism_to(E) # optional - sage.rings.number_field - sage: psi * phi # indirect doctest # optional - sage.rings.number_field + sage: iso1 = WeierstrassIsomorphism(E, (-1, 0, -i - 1, 0)) + sage: iso2 = psi.codomain().isomorphism_to(E) + sage: psi * phi # indirect doctest Composite morphism of degree 16 = 2^2*4: From: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-4)*x + (-6*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I To: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-3331/4)*x + (-142593/8*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I - sage: iso2 * EllipticCurveHom_composite.from_factors([phi, psi]) # indirect doctest # optional - sage.rings.number_field + sage: iso2 * EllipticCurveHom_composite.from_factors([phi, psi]) # indirect doctest Composite morphism of degree 16 = 4^2: From: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-4)*x + (-6*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I To: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-4)*x + (-6*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I - sage: phi * iso1 # indirect doctest # optional - sage.rings.number_field + sage: phi * iso1 # indirect doctest Composite morphism of degree 4 = 2^2: From: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-4)*x + (-6*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I To: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (480*I-694)*x + (-7778*I+5556) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I - sage: iso2 * psi * phi * iso1 # indirect doctest # optional - sage.rings.number_field + sage: iso2 * psi * phi * iso1 # indirect doctest Composite morphism of degree 16 = 2^2*4: From: Elliptic Curve defined by y^2 + (I+1)*x*y = x^3 + I*x^2 + (-4)*x + (-6*I) over Number Field in I with defining polynomial x^2 + 1 with I = 1*I @@ -647,26 +660,28 @@ def _comparison_impl(left, right, op): TESTS:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(QuadraticField(-3), [0,16]) # optional - sage.rings.number_field - sage: P,Q = E.lift_x(0), E.lift_x(-4) # optional - sage.rings.number_field - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.number_field - sage: psi = phi.codomain().isogeny(phi(Q)) # optional - sage.rings.number_field - sage: psi = psi.codomain().isomorphism_to(E) * psi # optional - sage.rings.number_field - sage: comp = psi * phi # optional - sage.rings.number_field - sage: mu = E.scalar_multiplication(phi.degree()) # optional - sage.rings.number_field - sage: sum(a*comp == mu for a in E.automorphisms()) # optional - sage.rings.number_field + sage: E = EllipticCurve(QuadraticField(-3), [0,16]) + sage: P,Q = E.lift_x(0), E.lift_x(-4) + sage: phi = EllipticCurveHom_composite(E, P) + sage: psi = phi.codomain().isogeny(phi(Q)) + sage: psi = psi.codomain().isomorphism_to(E) * psi + sage: comp = psi * phi + sage: mu = E.scalar_multiplication(phi.degree()) + sage: sum(a*comp == mu for a in E.automorphisms()) 1 :: - sage: E = EllipticCurve(GF(431**2), [1,0]) # optional - sage.rings.finite_rings - sage: P,Q = E.gens() # optional - sage.rings.finite_rings - sage: phi1 = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi2 = EllipticCurveHom_composite(phi1.codomain(), phi1(Q)) # optional - sage.rings.finite_rings - sage: psi1 = EllipticCurveHom_composite(E, Q) # optional - sage.rings.finite_rings - sage: psi2 = EllipticCurveHom_composite(psi1.codomain(), psi1(P)) # optional - sage.rings.finite_rings - sage: phi2 * phi1 == psi2 * psi1 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(431**2), [1,0]) + sage: P,Q = E.gens() + sage: phi1 = EllipticCurveHom_composite(E, P) # needs sage.rings.number_field + sage: phi2 = EllipticCurveHom_composite(phi1.codomain(), phi1(Q)) # needs sage.rings.number_field + sage: psi1 = EllipticCurveHom_composite(E, Q) # needs sage.rings.number_field + sage: psi2 = EllipticCurveHom_composite(psi1.codomain(), psi1(P)) # needs sage.rings.number_field + sage: phi2 * phi1 == psi2 * psi1 # needs sage.rings.number_field True """ if op != op_EQ: @@ -683,11 +698,12 @@ def rational_maps(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi.rational_maps() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi.rational_maps() ((x^9 + 27463*x^8 + 21204*x^7 - 5750*x^6 + 1610*x^5 + 14440*x^4 + 26605*x^3 - 15569*x^2 - 3341*x + 1267)/(x^8 + 27463*x^7 + 26871*x^6 + 5999*x^5 - 20194*x^4 - 6310*x^3 + 24366*x^2 - 20905*x - 13867), @@ -700,17 +716,17 @@ def rational_maps(self): TESTS:: - sage: f = phi.codomain().defining_polynomial() # optional - sage.rings.finite_rings - sage: g = E.defining_polynomial().subs({2:1}) # optional - sage.rings.finite_rings - sage: f(*phi.rational_maps(), 1) % g # optional - sage.rings.finite_rings + sage: f = phi.codomain().defining_polynomial() # needs sage.rings.finite_rings + sage: g = E.defining_polynomial().subs({2:1}) # needs sage.rings.finite_rings + sage: f(*phi.rational_maps(), 1) % g # needs sage.rings.finite_rings 0 :: - sage: phi.rational_maps()[0].parent() # optional - sage.rings.finite_rings + sage: phi.rational_maps()[0].parent() # needs sage.rings.finite_rings Fraction Field of Multivariate Polynomial Ring in x, y over Finite Field of size 65537 - sage: phi.rational_maps()[1].parent() # optional - sage.rings.finite_rings + sage: phi.rational_maps()[1].parent() # needs sage.rings.finite_rings Fraction Field of Multivariate Polynomial Ring in x, y over Finite Field of size 65537 """ @@ -726,16 +742,17 @@ def x_rational_map(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi.x_rational_map() == phi.rational_maps()[0] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi.x_rational_map() == phi.rational_maps()[0] True TESTS:: - sage: phi.x_rational_map().parent() # optional - sage.rings.finite_rings + sage: phi.x_rational_map().parent() # needs sage.rings.finite_rings Fraction Field of Univariate Polynomial Ring in x over Finite Field of size 65537 """ @@ -750,16 +767,17 @@ def kernel_polynomial(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P); phi Composite morphism of degree 9 = 3^2: From: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 65537 To: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 28339*x + 59518 over Finite Field of size 65537 - sage: phi.kernel_polynomial() # optional - sage.rings.finite_rings + sage: phi.kernel_polynomial() x^4 + 46500*x^3 + 19556*x^2 + 7643*x + 15952 """ # shouldn't there be a better algorithm for this? @@ -772,24 +790,25 @@ def dual(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P); phi Composite morphism of degree 9 = 3^2: From: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 65537 To: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 28339*x + 59518 over Finite Field of size 65537 - sage: psi = phi.dual(); psi # optional - sage.rings.finite_rings + sage: psi = phi.dual(); psi Composite morphism of degree 9 = 3^2: From: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 28339*x + 59518 over Finite Field of size 65537 To: Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 65537 - sage: psi * phi == phi.domain().scalar_multiplication(phi.degree()) # optional - sage.rings.finite_rings + sage: psi * phi == phi.domain().scalar_multiplication(phi.degree()) True - sage: phi * psi == psi.domain().scalar_multiplication(psi.degree()) # optional - sage.rings.finite_rings + sage: phi * psi == psi.domain().scalar_multiplication(psi.degree()) True """ phis = (phi.dual() for phi in self._phis[::-1]) @@ -804,16 +823,17 @@ def is_separable(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(7^2), [3,2]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(1) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P); phi # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(7^2), [3,2]) + sage: P = E.lift_x(1) + sage: phi = EllipticCurveHom_composite(E, P); phi Composite morphism of degree 7 = 7: From: Elliptic Curve defined by y^2 = x^3 + 3*x + 2 over Finite Field in z2 of size 7^2 To: Elliptic Curve defined by y^2 = x^3 + 3*x + 2 over Finite Field in z2 of size 7^2 - sage: phi.is_separable() # optional - sage.rings.finite_rings + sage: phi.is_separable() True """ return all(phi.is_separable() for phi in self._phis) @@ -826,16 +846,17 @@ def formal(self, prec=20): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi.formal() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi.formal() t + 54203*t^5 + 48536*t^6 + 40698*t^7 + 37808*t^8 + 21111*t^9 + 42381*t^10 + 46688*t^11 + 657*t^12 + 38916*t^13 + 62261*t^14 + 59707*t^15 + 30767*t^16 + 7248*t^17 + 60287*t^18 + 50451*t^19 + 38305*t^20 + 12312*t^21 + 31329*t^22 + O(t^23) - sage: (phi.dual() * phi).formal(prec=5) # optional - sage.rings.finite_rings + sage: (phi.dual() * phi).formal(prec=5) 9*t + 65501*t^2 + 65141*t^3 + 59183*t^4 + 21491*t^5 + 8957*t^6 + 999*t^7 + O(t^8) """ @@ -857,18 +878,19 @@ def scaling_factor(self): EXAMPLES:: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.hom_composite import EllipticCurveHom_composite sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.lift_x(7321) # optional - sage.rings.finite_rings - sage: phi = EllipticCurveHom_composite(E, P) # optional - sage.rings.finite_rings - sage: phi = WeierstrassIsomorphism(phi.codomain(), [7,8,9,10]) * phi # optional - sage.rings.finite_rings - sage: phi.formal() # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,2,3,4,5]) + sage: P = E.lift_x(7321) + sage: phi = EllipticCurveHom_composite(E, P) + sage: phi = WeierstrassIsomorphism(phi.codomain(), [7,8,9,10]) * phi + sage: phi.formal() 7*t + 65474*t^2 + 511*t^3 + 61316*t^4 + 20548*t^5 + 45511*t^6 + 37285*t^7 + 48414*t^8 + 9022*t^9 + 24025*t^10 + 35986*t^11 + 55397*t^12 + 25199*t^13 + 18744*t^14 + 46142*t^15 + 9078*t^16 + 18030*t^17 + 47599*t^18 + 12158*t^19 + 50630*t^20 + 56449*t^21 + 43320*t^22 + O(t^23) - sage: phi.scaling_factor() # optional - sage.rings.finite_rings + sage: phi.scaling_factor() 7 ALGORITHM: The scaling factor is multiplicative under @@ -891,15 +913,15 @@ def is_injective(self): sage: phi = EllipticCurveHom_composite(E, E(0,0)) sage: phi.is_injective() False - sage: E = EllipticCurve_from_j(GF(3).algebraic_closure()(0)) # optional - sage.rings.finite_rings - sage: nu = EllipticCurveHom_composite.from_factors(E.automorphisms()) # optional - sage.rings.finite_rings - sage: nu # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(3).algebraic_closure()(0)) + sage: nu = EllipticCurveHom_composite.from_factors(E.automorphisms()) + sage: nu Composite morphism of degree 1 = 1^12: From: Elliptic Curve defined by y^2 = x^3 + x over Algebraic closure of Finite Field of size 3 To: Elliptic Curve defined by y^2 = x^3 + x over Algebraic closure of Finite Field of size 3 - sage: nu.is_injective() # optional - sage.rings.finite_rings + sage: nu.is_injective() True """ return all(phi.is_injective() for phi in self._phis) diff --git a/src/sage/schemes/elliptic_curves/hom_frobenius.py b/src/sage/schemes/elliptic_curves/hom_frobenius.py index b5f2b51d470..fb4496aedbb 100644 --- a/src/sage/schemes/elliptic_curves/hom_frobenius.py +++ b/src/sage/schemes/elliptic_curves/hom_frobenius.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Frobenius isogenies of elliptic curves diff --git a/src/sage/schemes/elliptic_curves/isogeny_class.py b/src/sage/schemes/elliptic_curves/isogeny_class.py index 1588ecbe814..84404c28b76 100644 --- a/src/sage/schemes/elliptic_curves/isogeny_class.py +++ b/src/sage/schemes/elliptic_curves/isogeny_class.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.number_field +# sage.doctest: needs sage.rings.number_field r""" Isogeny class of elliptic curves over number fields diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py index ceda9840aa2..a16539eed1e 100644 --- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py +++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py @@ -751,9 +751,9 @@ def isogenies_2(E, minimal_models=True): Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field sage: [phi.codomain().ainvs() for phi in isogenies_2(E)] [] - sage: E = EllipticCurve(QQbar, [9,8]); E # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [9,8]); E # needs sage.rings.number_field Elliptic Curve defined by y^2 = x^3 + 9*x + 8 over Algebraic Field - sage: isogenies_2(E) # not implemented # optional - sage.rings.number_field + sage: isogenies_2(E) # not implemented # needs sage.rings.number_field """ f2 = E.division_polynomial(2) x2 = sorted(f2.roots(multiplicities=False)) @@ -787,12 +787,12 @@ def isogenies_3(E, minimal_models=True): EXAMPLES:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_3 - sage: E = EllipticCurve(GF(17), [1,1]) # optional - sage.rings.finite_rings - sage: [phi.codomain().ainvs() for phi in isogenies_3(E)] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17), [1,1]) + sage: [phi.codomain().ainvs() for phi in isogenies_3(E)] [(0, 0, 0, 9, 7), (0, 0, 0, 0, 1)] - sage: E = EllipticCurve(GF(17^2,'a'), [1,1]) # optional - sage.rings.finite_rings - sage: [phi.codomain().ainvs() for phi in isogenies_3(E)] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(17^2,'a'), [1,1]) # needs sage.rings.finite_rings + sage: [phi.codomain().ainvs() for phi in isogenies_3(E)] # needs sage.rings.finite_rings [(0, 0, 0, 9, 7), (0, 0, 0, 0, 1), (0, 0, 0, 5*a + 1, a + 13), (0, 0, 0, 12*a + 6, 16*a + 14)] sage: E = EllipticCurve('19a1') @@ -850,8 +850,8 @@ def isogenies_5_0(E, minimal_models=True): sage: isogenies_5_0(E) [] - sage: E = EllipticCurve(GF(13^2,'a'), [0,-3]) # optional - sage.rings.finite_rings - sage: isogenies_5_0(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13^2,'a'), [0,-3]) # needs sage.rings.finite_rings + sage: isogenies_5_0(E) # needs sage.rings.finite_rings [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + (4*a+6)*x + (2*a+10) @@ -878,9 +878,9 @@ def isogenies_5_0(E, minimal_models=True): over Finite Field in a of size 13^2] sage: x = polygen(QQ, 'x') - sage: K. = NumberField(x**6 - 320*x**3 - 320) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,1,0,0]) # optional - sage.rings.number_field - sage: isogenies_5_0(E) # optional - sage.rings.number_field + sage: K. = NumberField(x**6 - 320*x**3 - 320) # needs sage.rings.number_field + sage: E = EllipticCurve(K, [0,0,1,0,0]) # needs sage.rings.number_field + sage: isogenies_5_0(E) # needs sage.rings.number_field [Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^6 - 320*x^3 - 320 @@ -955,8 +955,8 @@ def isogenies_5_1728(E, minimal_models=True): sage: isogenies_5_1728(E) [] - sage: E = EllipticCurve(GF(13), [11,0]) # optional - sage.rings.finite_rings - sage: isogenies_5_1728(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13), [11,0]) + sage: isogenies_5_1728(E) [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 11*x over Finite Field of size 13, @@ -966,9 +966,10 @@ def isogenies_5_1728(E, minimal_models=True): An example of endomorphisms of degree 5:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: isogenies_5_1728(E) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: isogenies_5_1728(E) [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 with i = 1*I @@ -979,7 +980,7 @@ def isogenies_5_1728(E, minimal_models=True): with defining polynomial x^2 + 1 with i = 1*I to Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 with i = 1*I] - sage: _[0].rational_maps() # optional - sage.rings.number_field + sage: _[0].rational_maps() (((4/25*i + 3/25)*x^5 + (4/5*i - 2/5)*x^3 - x)/(x^4 + (-4/5*i + 2/5)*x^2 + (-4/25*i - 3/25)), ((11/125*i + 2/125)*x^6*y + (-23/125*i + 64/125)*x^4*y @@ -989,12 +990,13 @@ def isogenies_5_1728(E, minimal_models=True): An example of 5-isogenies over a number field:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ, 'x') - sage: K. = NumberField(x**4 + 20*x**2 - 80) # optional - sage.rings.number_field - sage: K(5).is_square() # necessary but not sufficient! # optional - sage.rings.number_field + sage: K. = NumberField(x**4 + 20*x**2 - 80) + sage: K(5).is_square() # necessary but not sufficient! True - sage: E = EllipticCurve(K, [0,0,0,1,0]) # optional - sage.rings.number_field - sage: isogenies_5_1728(E) # optional - sage.rings.number_field + sage: E = EllipticCurve(K, [0,0,0,1,0]) + sage: isogenies_5_1728(E) [Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in a with defining polynomial x^4 + 20*x^2 - 80 @@ -1008,14 +1010,15 @@ def isogenies_5_1728(E, minimal_models=True): See :trac:`19840`:: - sage: K. = NumberField(x^4 - 5*x^2 + 5) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^4 - 5*x^2 + 5) sage: E = EllipticCurve([a^2 + a + 1, a^3 + a^2 + a + 1, a^2 + a, ....: 17*a^3 + 34*a^2 - 16*a - 37, ....: 54*a^3 + 105*a^2 - 66*a - 135]) - sage: len(E.isogenies_prime_degree(5)) # optional - sage.rings.number_field + sage: len(E.isogenies_prime_degree(5)) 2 sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_5_1728 - sage: [phi.codomain().j_invariant() for phi in isogenies_5_1728(E)] # optional - sage.rings.number_field + sage: [phi.codomain().j_invariant() for phi in isogenies_5_1728(E)] [19691491018752*a^2 - 27212977933632, 19691491018752*a^2 - 27212977933632] """ F = E.base_field() @@ -1084,9 +1087,9 @@ def isogenies_7_0(E, minimal_models=True): First some examples of endomorphisms:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_7_0 - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1]) # optional - sage.rings.number_field - sage: isogenies_7_0(E) # optional - sage.rings.number_field + sage: K. = QuadraticField(-3) # needs sage.rings.number_field + sage: E = EllipticCurve(K, [0,1]) # needs sage.rings.number_field + sage: isogenies_7_0(E) # needs sage.rings.number_field [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I @@ -1098,8 +1101,8 @@ def isogenies_7_0(E, minimal_models=True): to Elliptic Curve defined by y^2 = x^3 + 1 over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I] - sage: E = EllipticCurve(GF(13^2,'a'), [0,-3]) # optional - sage.rings.finite_rings - sage: isogenies_7_0(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13^2,'a'), [0,-3]) # needs sage.rings.finite_rings + sage: isogenies_7_0(E) # needs sage.rings.finite_rings [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2 to Elliptic Curve defined by y^2 = x^3 + 10 over Finite Field in a of size 13^2, @@ -1109,9 +1112,9 @@ def isogenies_7_0(E, minimal_models=True): Now some examples of 7-isogenies which are not endomorphisms:: - sage: K = GF(101) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [0,1]) # optional - sage.rings.finite_rings - sage: isogenies_7_0(E) # optional - sage.rings.finite_rings + sage: K = GF(101) + sage: E = EllipticCurve(K, [0,1]) + sage: isogenies_7_0(E) [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 101 to Elliptic Curve defined by y^2 = x^3 + 55*x + 100 over Finite Field of size 101, @@ -1122,8 +1125,8 @@ def isogenies_7_0(E, minimal_models=True): Examples over a number field:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_7_0 - sage: E = EllipticCurve('27a1').change_ring(QuadraticField(-3,'r')) # optional - sage.rings.number_field - sage: isogenies_7_0(E) # optional - sage.rings.number_field + sage: E = EllipticCurve('27a1').change_ring(QuadraticField(-3,'r')) # needs sage.rings.number_field + sage: isogenies_7_0(E) # needs sage.rings.number_field [Isogeny of degree 7 from Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I @@ -1135,11 +1138,12 @@ def isogenies_7_0(E, minimal_models=True): to Elliptic Curve defined by y^2 + y = x^3 + (-7) over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I] + sage: # needs sage.rings.number_field sage: x = polygen(QQ, 'x') - sage: K. = NumberField(x^6 + 1512*x^3 - 21168) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1]) # optional - sage.rings.number_field - sage: isogs = isogenies_7_0(E) # optional - sage.rings.number_field - sage: [phi.codomain().a_invariants() for phi in isogs] # optional - sage.rings.number_field + sage: K. = NumberField(x^6 + 1512*x^3 - 21168) + sage: E = EllipticCurve(K, [0,1]) + sage: isogs = isogenies_7_0(E) + sage: [phi.codomain().a_invariants() for phi in isogs] [(0, 0, 0, @@ -1152,7 +1156,7 @@ def isogenies_7_0(E, minimal_models=True): -24485/392*a^5 - 1080/7*a^4 - 2255/7*a^3 - 1340865/14*a^2 - 230040*a - 553500, 1753037/56*a^5 + 8345733/112*a^4 + 374275/2*a^3 + 95377029/2*a^2 + 458385345/4*a + 275241835)] - sage: [phi.codomain().j_invariant() for phi in isogs] # optional - sage.rings.number_field + sage: [phi.codomain().j_invariant() for phi in isogs] [158428486656000/7*a^3 - 313976217600000, -158428486656000/7*a^3 - 34534529335296000] """ @@ -1219,8 +1223,8 @@ def isogenies_7_1728(E, minimal_models=True): EXAMPLES:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_7_1728 - sage: E = EllipticCurve(GF(47), [1, 0]) # optional - sage.rings.finite_rings - sage: isogenies_7_1728(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(47), [1, 0]) + sage: isogenies_7_1728(E) [Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 47 to Elliptic Curve defined by y^2 = x^3 + 26 over Finite Field of size 47, @@ -1230,32 +1234,34 @@ def isogenies_7_1728(E, minimal_models=True): An example in characteristic 53 (for which an earlier implementation did not work):: + sage: # needs sage.rings.finite_rings sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_7_1728 - sage: E = EllipticCurve(GF(53), [1, 0]) # optional - sage.rings.finite_rings - sage: isogenies_7_1728(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(53), [1, 0]) + sage: isogenies_7_1728(E) [] - sage: E = EllipticCurve(GF(53^2,'a'), [1, 0]) # optional - sage.rings.finite_rings - sage: [iso.codomain().ainvs() for iso in isogenies_7_1728(E)] # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(53^2,'a'), [1, 0]) + sage: [iso.codomain().ainvs() for iso in isogenies_7_1728(E)] [(0, 0, 0, 36, 19*a + 15), (0, 0, 0, 36, 34*a + 38), (0, 0, 0, 33, 39*a + 28), (0, 0, 0, 33, 14*a + 25), (0, 0, 0, 19, 45*a + 16), (0, 0, 0, 19, 8*a + 37), (0, 0, 0, 3, 45*a + 16), (0, 0, 0, 3, 8*a + 37)] :: + sage: # needs sage.rings.number_field sage: x = polygen(QQ, 'x') - sage: K. = NumberField(x^8 + 84*x^6 - 1890*x^4 + 644*x^2 - 567) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [1, 0]) # optional - sage.rings.number_field - sage: isogs = isogenies_7_1728(E) # optional - sage.rings.number_field - sage: [phi.codomain().j_invariant() for phi in isogs] # optional - sage.rings.number_field + sage: K. = NumberField(x^8 + 84*x^6 - 1890*x^4 + 644*x^2 - 567) + sage: E = EllipticCurve(K, [1, 0]) + sage: isogs = isogenies_7_1728(E) + sage: [phi.codomain().j_invariant() for phi in isogs] [-526110256146528/53*a^6 + 183649373229024*a^4 - 3333881559996576/53*a^2 + 2910267397643616/53, -526110256146528/53*a^6 + 183649373229024*a^4 - 3333881559996576/53*a^2 + 2910267397643616/53] - sage: E1 = isogs[0].codomain() # optional - sage.rings.number_field - sage: E2 = isogs[1].codomain() # optional - sage.rings.number_field - sage: E1.is_isomorphic(E2) # optional - sage.rings.number_field + sage: E1 = isogs[0].codomain() + sage: E2 = isogs[1].codomain() + sage: E1.is_isomorphic(E2) False - sage: E1.is_quadratic_twist(E2) # optional - sage.rings.number_field + sage: E1.is_quadratic_twist(E2) -1 """ if E.j_invariant() != 1728: @@ -1320,11 +1326,12 @@ def isogenies_13_0(E, minimal_models=True): Endomorphisms of degree 13 will exist when -3 is a square:: - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0, r]); E # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-3) + sage: E = EllipticCurve(K, [0, r]); E Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I - sage: isogenies_13_0(E) # optional - sage.rings.number_field + sage: isogenies_13_0(E) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I @@ -1335,7 +1342,7 @@ def isogenies_13_0(E, minimal_models=True): with defining polynomial x^2 + 3 with r = 1.732050807568878?*I to Elliptic Curve defined by y^2 = x^3 + r over Number Field in r with defining polynomial x^2 + 3 with r = 1.732050807568878?*I] - sage: isogenies_13_0(E)[0].rational_maps() # optional - sage.rings.number_field + sage: isogenies_13_0(E)[0].rational_maps() (((7/338*r + 23/338)*x^13 + (-164/13*r - 420/13)*x^10 + (720/13*r + 3168/13)*x^7 + (3840/13*r - 576/13)*x^4 + (4608/13*r + 2304/13)*x)/(x^12 + (4*r + 36)*x^9 + (1080/13*r + 3816/13)*x^6 @@ -1350,27 +1357,28 @@ def isogenies_13_0(E, minimal_models=True): An example of endomorphisms over a finite field:: - sage: K = GF(19^2,'a') # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=K(0)); E # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(19^2,'a') + sage: E = EllipticCurve(j=K(0)); E Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2 - sage: isogenies_13_0(E) # optional - sage.rings.finite_rings + sage: isogenies_13_0(E) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2, Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field in a of size 19^2] - sage: isogenies_13_0(E)[0].rational_maps() # optional - sage.rings.finite_rings + sage: isogenies_13_0(E)[0].rational_maps() ((6*x^13 - 6*x^10 - 3*x^7 + 6*x^4 + x)/(x^12 - 5*x^9 - 9*x^6 - 7*x^3 + 5), (-8*x^18*y - 9*x^15*y + 9*x^12*y - 5*x^9*y + 5*x^6*y - 7*x^3*y + 7*y)/(x^18 + 2*x^15 + 3*x^12 - x^9 + 8*x^6 - 9*x^3 + 7)) A previous implementation did not work in some characteristics:: - sage: K = GF(29) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=K(0)) # optional - sage.rings.finite_rings - sage: isogenies_13_0(E) # optional - sage.rings.finite_rings + sage: K = GF(29) + sage: E = EllipticCurve(j=K(0)) + sage: isogenies_13_0(E) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 26*x + 12 over Finite Field of size 29, @@ -1380,20 +1388,20 @@ def isogenies_13_0(E, minimal_models=True): :: - sage: K = GF(101) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(j=K(0)); E.ainvs() # optional - sage.rings.finite_rings + sage: K = GF(101) + sage: E = EllipticCurve(j=K(0)); E.ainvs() (0, 0, 0, 0, 1) - sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)] # optional - sage.rings.finite_rings + sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)] [(0, 0, 0, 64, 36), (0, 0, 0, 42, 66)] :: sage: x = polygen(QQ) sage: f = x^12 + 78624*x^9 - 130308048*x^6 + 2270840832*x^3 - 54500179968 - sage: K. = NumberField(f) # optional - sage.rings.number_field - sage: E = EllipticCurve(j=K(0)); E.ainvs() # optional - sage.rings.number_field + sage: K. = NumberField(f) # needs sage.rings.number_field + sage: E = EllipticCurve(j=K(0)); E.ainvs() # needs sage.rings.number_field (0, 0, 0, 0, 1) - sage: len([phi.codomain().ainvs() # long time (4s) # optional - sage.rings.number_field + sage: len([phi.codomain().ainvs() # long time # needs sage.rings.number_field ....: for phi in isogenies_13_0(E)]) 2 """ @@ -1469,10 +1477,10 @@ def isogenies_13_1728(E, minimal_models=True): sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_13_1728 - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,i,0]); E.ainvs() # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve([0,0,0,i,0]); E.ainvs() # needs sage.rings.number_field (0, 0, 0, i, 0) - sage: isogenies_13_1728(E) # optional - sage.rings.number_field + sage: isogenies_13_1728(E) # needs sage.rings.number_field [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + i*x over Number Field in i with defining polynomial x^2 + 1 with i = 1*I @@ -1486,15 +1494,15 @@ def isogenies_13_1728(E, minimal_models=True): :: - sage: K = GF(83) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs() # optional - sage.rings.finite_rings + sage: K = GF(83) + sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs() (0, 0, 0, 5, 0) - sage: isogenies_13_1728(E) # optional - sage.rings.finite_rings + sage: isogenies_13_1728(E) [] - sage: K = GF(89) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs() # optional - sage.rings.finite_rings + sage: K = GF(89) + sage: E = EllipticCurve(K, [0,0,0,5,0]); E.ainvs() (0, 0, 0, 5, 0) - sage: isogenies_13_1728(E) # optional - sage.rings.finite_rings + sage: isogenies_13_1728(E) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89 to Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 89, @@ -1504,9 +1512,9 @@ def isogenies_13_1728(E, minimal_models=True): :: - sage: K = GF(23) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(K, [1,0]) # optional - sage.rings.finite_rings - sage: isogenies_13_1728(E) # optional - sage.rings.finite_rings + sage: K = GF(23) + sage: E = EllipticCurve(K, [1,0]) + sage: isogenies_13_1728(E) [Isogeny of degree 13 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 23 to Elliptic Curve defined by y^2 = x^3 + 16 over Finite Field of size 23, @@ -1519,9 +1527,9 @@ def isogenies_13_1728(E, minimal_models=True): sage: x = polygen(QQ) sage: f = (x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 ....: - 282896640*x^4 - 149879808*x^2 - 349360128) - sage: K. = NumberField(f) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [1,0]) # optional - sage.rings.number_field - sage: [phi.codomain().ainvs() # long time (3s) # optional - sage.rings.number_field + sage: K. = NumberField(f) # needs sage.rings.number_field + sage: E = EllipticCurve(K, [1,0]) # needs sage.rings.number_field + sage: [phi.codomain().ainvs() # long time # needs sage.rings.number_field ....: for phi in isogenies_13_1728(E)] [(0, 0, @@ -1865,10 +1873,11 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field] - sage: K = QuadraticField(-295,'a') # optional - sage.rings.number_field - sage: a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve_from_j(-484650135/16777216*a + 4549855725/16777216) # optional - sage.rings.number_field - sage: isogenies_prime_degree_genus_plus_0(E, 23) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(-295,'a') + sage: a = K.gen() + sage: E = EllipticCurve_from_j(-484650135/16777216*a + 4549855725/16777216) + sage: isogenies_prime_degree_genus_plus_0(E, 23) [Isogeny of degree 23 from Elliptic Curve defined by y^2 = x^3 + (-14460494784192904095/140737488355328*a+270742665778826768325/140737488355328)*x @@ -1881,10 +1890,11 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): over Number Field in a with defining polynomial x^2 + 295 with a = 17.17556403731767?*I] - sage: K = QuadraticField(-199,'a') # optional - sage.rings.number_field - sage: a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve_from_j(94743000*a + 269989875) # optional - sage.rings.number_field - sage: isogenies_prime_degree_genus_plus_0(E, 29) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(-199,'a') + sage: a = K.gen() + sage: E = EllipticCurve_from_j(94743000*a + 269989875) + sage: isogenies_prime_degree_genus_plus_0(E, 29) [Isogeny of degree 29 from Elliptic Curve defined by y^2 = x^3 + (-153477413215038000*a+5140130723072965125)*x @@ -1897,10 +1907,11 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): over Number Field in a with defining polynomial x^2 + 199 with a = 14.106735979665884?*I] - sage: K = QuadraticField(253,'a') # optional - sage.rings.number_field - sage: a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve_from_j(208438034112000*a - 3315409892960000) # optional - sage.rings.number_field - sage: isogenies_prime_degree_genus_plus_0(E, 31) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(253,'a') + sage: a = K.gen() + sage: E = EllipticCurve_from_j(208438034112000*a - 3315409892960000) + sage: isogenies_prime_degree_genus_plus_0(E, 31) [Isogeny of degree 31 from Elliptic Curve defined by y^2 = x^3 + (4146345122185433034677956608000*a-65951656549965037259634800640000)*x @@ -1913,8 +1924,8 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): over Number Field in a with defining polynomial x^2 - 253 with a = 15.905973720586867?] - sage: E = EllipticCurve_from_j(GF(5)(1)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree_genus_plus_0(E, 41) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(5)(1)) + sage: isogenies_prime_degree_genus_plus_0(E, 41) [Isogeny of degree 41 from Elliptic Curve defined by y^2 = x^3 + x + 2 over Finite Field of size 5 to Elliptic Curve defined by y^2 = x^3 + x + 3 over Finite Field of size 5, @@ -1922,11 +1933,12 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): from Elliptic Curve defined by y^2 = x^3 + x + 2 over Finite Field of size 5 to Elliptic Curve defined by y^2 = x^3 + x + 3 over Finite Field of size 5] - sage: K = QuadraticField(5,'a') # optional - sage.rings.number_field - sage: a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve_from_j(184068066743177379840*a # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(5,'a') + sage: a = K.gen() + sage: E = EllipticCurve_from_j(184068066743177379840*a ....: - 411588709724712960000) - sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (2s) # optional - sage.rings.number_field + sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x @@ -1939,9 +1951,9 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?] - sage: K = QuadraticField(-66827,'a') # optional - sage.rings.number_field - sage: a = K.gen() # optional - sage.rings.number_field - sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000) # optional - sage.rings.number_field + sage: K = QuadraticField(-66827,'a') # needs sage.rings.number_field + sage: a = K.gen() # needs sage.rings.number_field + sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000) # needs sage.rings.number_field sage: isogenies_prime_degree_genus_plus_0(E, 59) # long time (5s) [Isogeny of degree 59 from Elliptic Curve defined by @@ -1955,8 +1967,8 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I] - sage: E = EllipticCurve_from_j(GF(13)(5)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree_genus_plus_0(E, 71) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(13)(5)) + sage: isogenies_prime_degree_genus_plus_0(E, 71) [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, @@ -1964,8 +1976,8 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True): from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13] - sage: E = EllipticCurve(GF(13), [0,1,1,1,0]) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree_genus_plus_0(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(13), [0,1,1,1,0]) + sage: isogenies_prime_degree_genus_plus_0(E) [Isogeny of degree 17 from Elliptic Curve defined by y^2 + y = x^3 + x^2 + x over Finite Field of size 13 to Elliptic Curve defined by y^2 + y = x^3 + x^2 + 10*x + 1 over Finite Field of size 13, @@ -2070,9 +2082,9 @@ def isogenies_prime_degree_genus_plus_0_j0(E, l, minimal_models=True): sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree_genus_plus_0_j0 sage: u = polygen(QQ) - sage: K. = NumberField(u^4 + 228*u^3 + 486*u^2 - 540*u + 225) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0, -121/5*a^3 - 20691/5*a^2 - 29403/5*a + 3267]) # optional - sage.rings.number_field - sage: isogenies_prime_degree_genus_plus_0_j0(E, 11) # optional - sage.rings.number_field + sage: K. = NumberField(u^4 + 228*u^3 + 486*u^2 - 540*u + 225) # needs sage.rings.number_field + sage: E = EllipticCurve(K, [0, -121/5*a^3 - 20691/5*a^2 - 29403/5*a + 3267]) # needs sage.rings.number_field + sage: isogenies_prime_degree_genus_plus_0_j0(E, 11) # needs sage.rings.number_field [Isogeny of degree 11 from Elliptic Curve defined by y^2 = x^3 + (-121/5*a^3-20691/5*a^2-29403/5*a+3267) over @@ -2171,13 +2183,14 @@ def isogenies_prime_degree_genus_plus_0_j1728(E, l, minimal_models=True): sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree_genus_plus_0_j1728 + sage: # needs sage.rings.number_field sage: u = polygen(QQ) - sage: K. = NumberField(u^6 - 522*u^5 - 10017*u^4 # optional - sage.rings.number_field + sage: K. = NumberField(u^6 - 522*u^5 - 10017*u^4 ....: + 2484*u^3 - 5265*u^2 + 12150*u - 5103) - sage: E = EllipticCurve(K, [-75295/1335852*a^5 + 13066735/445284*a^4 # optional - sage.rings.number_field + sage: E = EllipticCurve(K, [-75295/1335852*a^5 + 13066735/445284*a^4 ....: + 44903485/74214*a^3 + 17086861/24738*a^2 ....: + 11373021/16492*a - 1246245/2356, 0]) - sage: isogenies_prime_degree_genus_plus_0_j1728(E, 11) # optional - sage.rings.number_field + sage: isogenies_prime_degree_genus_plus_0_j1728(E, 11) [Isogeny of degree 11 from Elliptic Curve defined by y^2 = x^3 + (-75295/1335852*a^5+13066735/445284*a^4+44903485/74214*a^3+17086861/24738*a^2+11373021/16492*a-1246245/2356)*x @@ -2198,9 +2211,9 @@ def isogenies_prime_degree_genus_plus_0_j1728(E, l, minimal_models=True): + (3540460*a^3-30522492*a^2+7043652*a+5031180) over Number Field in a with defining polynomial x^6 - 522*x^5 - 10017*x^4 + 2484*x^3 - 5265*x^2 + 12150*x - 5103] - sage: i = QuadraticField(-1,'i').gen() # optional - sage.rings.number_field - sage: E = EllipticCurve([-1 - 2*i, 0]) # optional - sage.rings.number_field - sage: isogenies_prime_degree_genus_plus_0_j1728(E, 17) # optional - sage.rings.number_field + sage: i = QuadraticField(-1,'i').gen() + sage: E = EllipticCurve([-1 - 2*i, 0]) + sage: isogenies_prime_degree_genus_plus_0_j1728(E, 17) [Isogeny of degree 17 from Elliptic Curve defined by y^2 = x^3 + (-2*i-1)*x over Number Field in i with defining polynomial x^2 + 1 with i = 1*I @@ -2211,8 +2224,8 @@ def isogenies_prime_degree_genus_plus_0_j1728(E, l, minimal_models=True): over Number Field in i with defining polynomial x^2 + 1 with i = 1*I to Elliptic Curve defined by y^2 = x^3 + (-562*i+319)*x over Number Field in i with defining polynomial x^2 + 1 with i = 1*I] - sage: Emin = E.global_minimal_model() # optional - sage.rings.number_field - sage: [(p, len(isogenies_prime_degree_genus_plus_0_j1728(Emin, p))) # optional - sage.rings.number_field + sage: Emin = E.global_minimal_model() + sage: [(p, len(isogenies_prime_degree_genus_plus_0_j1728(Emin, p))) ....: for p in [17, 29, 41]] [(17, 2), (29, 2), (41, 2)] """ @@ -2346,13 +2359,13 @@ def is_kernel_polynomial(E, m, f): into 14 factors each of degree 6, but only two of these is a kernel polynomial for a 13-isogeny:: - sage: F = GF(3) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F, [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: f13 = E.division_polynomial(13) # optional - sage.rings.finite_rings - sage: factors = [f for f, e in f13.factor()] # optional - sage.rings.finite_rings - sage: all(f.degree() == 6 for f in factors) # optional - sage.rings.finite_rings + sage: F = GF(3) + sage: E = EllipticCurve(F, [0,0,0,-1,0]) + sage: f13 = E.division_polynomial(13) + sage: factors = [f for f, e in f13.factor()] + sage: all(f.degree() == 6 for f in factors) True - sage: [is_kernel_polynomial(E, 13, f) for f in factors] # optional - sage.rings.finite_rings + sage: [is_kernel_polynomial(E, 13, f) for f in factors] [True, True, False, @@ -2370,15 +2383,16 @@ def is_kernel_polynomial(E, m, f): See :trac:`22232`:: - sage: K = GF(47^2) # optional - sage.rings.finite_rings - sage: E = EllipticCurve([0, K.gen()]) # optional - sage.rings.finite_rings - sage: psi7 = E.division_polynomial(7) # optional - sage.rings.finite_rings - sage: f = psi7.factor()[4][0] # optional - sage.rings.finite_rings - sage: f # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K = GF(47^2) + sage: E = EllipticCurve([0, K.gen()]) + sage: psi7 = E.division_polynomial(7) + sage: f = psi7.factor()[4][0] + sage: f x^3 + (7*z2 + 11)*x^2 + (25*z2 + 33)*x + 25*z2 - sage: f.divides(psi7) # optional - sage.rings.finite_rings + sage: f.divides(psi7) True - sage: is_kernel_polynomial(E, 7, f) # optional - sage.rings.finite_rings + sage: is_kernel_polynomial(E, 7, f) False """ m2 = m // 2 @@ -2444,15 +2458,15 @@ def isogenies_prime_degree_general(E, l, minimal_models=True): EXAMPLES:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree_general - sage: E = EllipticCurve_from_j(GF(2^6,'a')(1)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree_general(E, 7) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(2^6,'a')(1)) # needs sage.rings.finite_rings + sage: isogenies_prime_degree_general(E, 7) # needs sage.rings.finite_rings [Isogeny of degree 7 from Elliptic Curve defined by y^2 + x*y = x^3 + 1 over Finite Field in a of size 2^6 to Elliptic Curve defined by y^2 + x*y = x^3 + x over Finite Field in a of size 2^6] - sage: E = EllipticCurve_from_j(GF(3^12,'a')(2)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree_general(E, 17) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(3^12,'a')(2)) # needs sage.rings.finite_rings + sage: isogenies_prime_degree_general(E, 17) # needs sage.rings.finite_rings [Isogeny of degree 17 from Elliptic Curve defined by y^2 = x^3 + 2*x^2 + 2 over Finite Field in a of size 3^12 @@ -2503,7 +2517,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True): sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree_general sage: ainvs = (0,1,1,-1,-1) - sage: for l in prime_range(50): # optional - sage.rings.finite_rings + sage: for l in prime_range(50): ....: E = EllipticCurve(GF(l),ainvs) ....: isogenies_prime_degree_general(E,l) [] @@ -2546,26 +2560,26 @@ def isogenies_prime_degree_general(E, l, minimal_models=True): factors of degree 6 each, but only two those are kernel polynomials:: - sage: F3 = GF(3) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(F3, [0,0,0,-1,0]) # optional - sage.rings.finite_rings - sage: Psi13 = E.division_polynomial(13) # optional - sage.rings.finite_rings - sage: len([f for f, e in Psi13.factor() if f.degree() == 6]) # optional - sage.rings.finite_rings + sage: F3 = GF(3) + sage: E = EllipticCurve(F3, [0,0,0,-1,0]) + sage: Psi13 = E.division_polynomial(13) + sage: len([f for f, e in Psi13.factor() if f.degree() == 6]) 14 - sage: len(E.isogenies_prime_degree(13)) # optional - sage.rings.finite_rings + sage: len(E.isogenies_prime_degree(13)) 2 Over GF(9) the other factors of degree 6 split into pairs of cubics which can be rearranged to give the remaining 12 kernel polynomials:: - sage: len(E.change_ring(GF(3^2,'a')).isogenies_prime_degree(13)) # optional - sage.rings.finite_rings + sage: len(E.change_ring(GF(3^2,'a')).isogenies_prime_degree(13)) # needs sage.rings.finite_rings 14 See :trac:`18589`: the following example took 20s before, now only 4s:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K,[0,0,0,1,0]) # optional - sage.rings.number_field - sage: [phi.codomain().ainvs() # long time (6s) # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: E = EllipticCurve(K,[0,0,0,1,0]) # needs sage.rings.number_field + sage: [phi.codomain().ainvs() # long time # needs sage.rings.number_field ....: for phi in E.isogenies_prime_degree(37)] [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)] @@ -2668,15 +2682,15 @@ def isogenies_prime_degree(E, l, minimal_models=True): EXAMPLES:: sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree - sage: E = EllipticCurve_from_j(GF(2^6,'a')(1)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree(E, 7) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(2^6,'a')(1)) # needs sage.rings.finite_rings + sage: isogenies_prime_degree(E, 7) # needs sage.rings.finite_rings [Isogeny of degree 7 from Elliptic Curve defined by y^2 + x*y = x^3 + 1 over Finite Field in a of size 2^6 to Elliptic Curve defined by y^2 + x*y = x^3 + x over Finite Field in a of size 2^6] - sage: E = EllipticCurve_from_j(GF(3^12,'a')(2)) # optional - sage.rings.finite_rings - sage: isogenies_prime_degree(E, 17) # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(3^12,'a')(2)) # needs sage.rings.finite_rings + sage: isogenies_prime_degree(E, 17) # needs sage.rings.finite_rings [Isogeny of degree 17 from Elliptic Curve defined by y^2 = x^3 + 2*x^2 + 2 over Finite Field in a of size 3^12 @@ -2718,7 +2732,7 @@ def isogenies_prime_degree(E, l, minimal_models=True): sage: from sage.schemes.elliptic_curves.isogeny_small_degree import isogenies_prime_degree sage: ainvs = (0,1,1,-1,-1) - sage: for l in prime_range(50): # optional - sage.rings.finite_rings + sage: for l in prime_range(50): ....: E = EllipticCurve(GF(l), ainvs) ....: isogenies_prime_degree(E, l) [] @@ -2770,17 +2784,17 @@ def isogenies_prime_degree(E, l, minimal_models=True): primes (11, 17, 19, 23, 29, 31, 41, 47, 59, 71) than when the generic code must be used:: - sage: E = EllipticCurve(GF(101), [-3440, 77658]) # optional - sage.rings.finite_rings - sage: E.isogenies_prime_degree(71) # fast # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(101), [-3440, 77658]) + sage: E.isogenies_prime_degree(71) # fast [] - sage: E.isogenies_prime_degree(73) # long time (2s) # optional - sage.rings.finite_rings + sage: E.isogenies_prime_degree(73) # long time [] Test that :trac:`32269` is fixed:: - sage: K = QuadraticField(-11) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1,0,-117,-541]) # optional - sage.rings.number_field - sage: E.isogenies_prime_degree(37) # long time (9s) # optional - sage.rings.number_field + sage: K = QuadraticField(-11) # needs sage.rings.number_field + sage: E = EllipticCurve(K, [0,1,0,-117,-541]) # needs sage.rings.number_field + sage: E.isogenies_prime_degree(37) # long time # needs sage.rings.number_field [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 diff --git a/src/sage/schemes/elliptic_curves/kraus.py b/src/sage/schemes/elliptic_curves/kraus.py index 9573dccabac..8565cc5e3be 100644 --- a/src/sage/schemes/elliptic_curves/kraus.py +++ b/src/sage/schemes/elliptic_curves/kraus.py @@ -86,6 +86,7 @@ def c4c6_nonsingular(c4, c6): Over number fields:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: c4c6_nonsingular(-217728*a - 679104, 141460992*a + 409826304) @@ -122,9 +123,10 @@ def c4c6_model(c4, c6, assume_nonsingular=False): sage: from sage.schemes.elliptic_curves.kraus import c4c6_model sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 10) - sage: c4c6_model(-217728*a - 679104, 141460992*a + 409826304) - Elliptic Curve defined by y^2 = x^3 + (4536*a+14148)*x + (-163728*a-474336) over Number Field in a with defining polynomial x^3 - 10 + sage: K. = NumberField(x^3 - 10) # needs sage.rings.number_field + sage: c4c6_model(-217728*a - 679104, 141460992*a + 409826304) # needs sage.rings.number_field + Elliptic Curve defined by y^2 = x^3 + (4536*a+14148)*x + (-163728*a-474336) + over Number Field in a with defining polynomial x^3 - 10 sage: c4, c6 = EllipticCurve('389a1').c_invariants() sage: c4c6_model(c4,c6) @@ -166,6 +168,7 @@ def make_integral(a, P, e): sage: from sage.schemes.elliptic_curves.kraus import make_integral + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: P = K.primes_above(2)[0] @@ -206,6 +209,7 @@ def sqrt_mod_4(x, P): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import sqrt_mod_4 sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -249,6 +253,7 @@ def test_b2_local(c4, c6, P, b2, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: c4 = -60544*a + 385796 @@ -259,28 +264,36 @@ def test_b2_local(c4, c6, P, b2, debug=False): b2=0 works at the first prime but not the second:: sage: b2 = 0 - sage: test_b2_local(c4,c6,P3a,b2) - Elliptic Curve defined by y^2 = x^3 + (3784/3*a-96449/12)*x + (1743740/27*a-32765791/108) over Number Field in a with defining polynomial x^2 - 10 - sage: test_b2_local(c4,c6,P3b,b2) + sage: test_b2_local(c4,c6,P3a,b2) # needs sage.rings.number_field + Elliptic Curve defined by + y^2 = x^3 + (3784/3*a-96449/12)*x + (1743740/27*a-32765791/108) + over Number Field in a with defining polynomial x^2 - 10 + sage: test_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field False b2=-a works at the second prime but not the first:: - sage: b2 = -a - sage: test_b2_local(c4,c6,P3a,b2,debug=True) + sage: b2 = -a # needs sage.rings.number_field + sage: test_b2_local(c4,c6,P3a,b2,debug=True) # needs sage.rings.number_field test_b2_local: not integral at Fractional ideal (3, a + 1) False - sage: test_b2_local(c4,c6,P3b,b2) - Elliptic Curve defined by y^2 = x^3 + (-1/4*a)*x^2 + (3784/3*a-192893/24)*x + (56378369/864*a-32879311/108) over Number Field in a with defining polynomial x^2 - 10 + sage: test_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field + Elliptic Curve defined by + y^2 = x^3 + (-1/4*a)*x^2 + (3784/3*a-192893/24)*x + (56378369/864*a-32879311/108) + over Number Field in a with defining polynomial x^2 - 10 Using CRT we can do both with the same b2:: - sage: b2 = K.solve_CRT([0,-a],[P3a,P3b]); b2 + sage: b2 = K.solve_CRT([0,-a],[P3a,P3b]); b2 # needs sage.rings.number_field a + 1 - sage: test_b2_local(c4,c6,P3a,b2) - Elliptic Curve defined by y^2 = x^3 + (1/4*a+1/4)*x^2 + (10091/8*a-128595/16)*x + (4097171/64*a-19392359/64) over Number Field in a with defining polynomial x^2 - 10 - sage: test_b2_local(c4,c6,P3b,b2) - Elliptic Curve defined by y^2 = x^3 + (1/4*a+1/4)*x^2 + (10091/8*a-128595/16)*x + (4097171/64*a-19392359/64) over Number Field in a with defining polynomial x^2 - 10 + sage: test_b2_local(c4,c6,P3a,b2) # needs sage.rings.number_field + Elliptic Curve defined by + y^2 = x^3 + (1/4*a+1/4)*x^2 + (10091/8*a-128595/16)*x + (4097171/64*a-19392359/64) + over Number Field in a with defining polynomial x^2 - 10 + sage: test_b2_local(c4,c6,P3b,b2) # needs sage.rings.number_field + Elliptic Curve defined + by y^2 = x^3 + (1/4*a+1/4)*x^2 + (10091/8*a-128595/16)*x + (4097171/64*a-19392359/64) + over Number Field in a with defining polynomial x^2 - 10 """ E = c4c6_model(c4,c6).rst_transform(b2/12,0,0) if not (c4,c6) == E.c_invariants(): @@ -312,6 +325,7 @@ def test_b2_global(c4, c6, b2, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: c4 = -60544*a + 385796 @@ -361,6 +375,7 @@ def check_Kraus_local_3(c4, c6, P, assume_nonsingular=False, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import check_Kraus_local_3 sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -374,7 +389,8 @@ def check_Kraus_local_3(c4, c6, P, assume_nonsingular=False, debug=False): An example in a field where 3 is ramified:: - sage: K. = NumberField(x^2-15) + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 - 15) sage: c4 = -60504*a + 386001 sage: c6 = -55346820*a + 261045153 sage: P3 = K.primes_above(3)[0] @@ -430,6 +446,7 @@ def test_a1a3_local(c4, c6, P, a1, a3, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import test_a1a3_local sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -472,6 +489,7 @@ def test_a1a3_global(c4, c6, a1, a3, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import test_a1a3_global sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -513,6 +531,7 @@ def test_rst_global(c4, c6, r, s, t, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import test_rst_global sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2-10) @@ -579,6 +598,7 @@ def check_Kraus_local_2(c4, c6, P, a1=None, assume_nonsingular=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import check_Kraus_local_2 sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -666,6 +686,7 @@ def check_Kraus_local(c4, c6, P, assume_nonsingular=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import check_Kraus_local sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 15) @@ -687,6 +708,7 @@ def check_Kraus_local(c4, c6, P, assume_nonsingular=False): sage: E.is_local_integral_model(P5) and (c4,c6)==E.c_invariants() True + sage: # needs sage.rings.number_field sage: c4 = 123+456*a sage: c6 = 789+101112*a sage: check_Kraus_local(c4,c6,P2) @@ -735,6 +757,7 @@ def check_Kraus_global(c4, c6, assume_nonsingular=False, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.kraus import check_Kraus_global sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) @@ -752,7 +775,8 @@ def check_Kraus_global(c4, c6, assume_nonsingular=False, debug=False): ...and it does! Elliptic Curve defined by y^2 + 3*a*x*y + (-89*a+10)*y = x^3 + (a-89)*x^2 + (1202*a-5225)*x + (34881*a-151813) over Number Field in a with defining polynomial x^2 - 10 - sage: K. = NumberField(x^2-15) + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^2 - 15) sage: E = EllipticCurve([0, 0, 0, 4536*a + 14148, -163728*a - 474336]) sage: c4, c6 = E.c_invariants() sage: check_Kraus_global(c4,c6) @@ -760,16 +784,19 @@ def check_Kraus_global(c4, c6, assume_nonsingular=False, debug=False): TESTS (see :trac:`17295`):: - sage: K. =NumberField(x^3 - 7*x - 5) + sage: # needs sage.rings.number_field + sage: K. = NumberField(x^3 - 7*x - 5) sage: E = EllipticCurve([a, 0, 1, 2*a^2 + 5*a + 3, -a^2 - 3*a - 2]) sage: assert E.conductor().norm() ==8 sage: G = K.galois_group(names='b') sage: def conj_curve(E,sigma): return EllipticCurve([sigma(a) for a in E.ainvs()]) sage: EL = conj_curve(E,G[0]) sage: L = EL.base_field() - sage: assert L.class_number()== 2 - sage: EL.isogeny_class() # long time (~10s) - Isogeny class of Elliptic Curve defined by y^2 + (-1/90*b^4+7/18*b^2-1/2*b-98/45)*x*y + y = x^3 + (1/45*b^5-1/18*b^4-7/9*b^3+41/18*b^2+167/90*b-29/9)*x + (-1/90*b^5+1/30*b^4+7/18*b^3-4/3*b^2-61/90*b+11/5) over Number Field in b with defining polynomial x^6 - 42*x^4 + 441*x^2 - 697 + sage: assert L.class_number() == 2 + sage: EL.isogeny_class() # long time (~10s) + Isogeny class of Elliptic Curve defined by + y^2 + (-1/90*b^4+7/18*b^2-1/2*b-98/45)*x*y + y = x^3 + (1/45*b^5-1/18*b^4-7/9*b^3+41/18*b^2+167/90*b-29/9)*x + (-1/90*b^5+1/30*b^4+7/18*b^3-4/3*b^2-61/90*b+11/5) + over Number Field in b with defining polynomial x^6 - 42*x^4 + 441*x^2 - 697 """ if not assume_nonsingular: if not c4c6_nonsingular(c4,c6): @@ -913,6 +940,7 @@ def semi_global_minimal_model(E, debug=False): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^2 - 10) sage: K.class_number() @@ -932,16 +960,18 @@ def semi_global_minimal_model(E, debug=False): has order 3315. The smallest prime in that ideal class has norm 23567:: - sage: K. = NumberField(x^2-x+31821453) - sage: ainvs = (0, 0, 0, -382586771000351226384*a - 2498023791133552294513515, 358777608829102441023422458989744*a + 1110881475104109582383304709231832166) + sage: # long time, needs sage.rings.number_field + sage: K. = NumberField(x^2 - x + 31821453) + sage: ainvs = (0, 0, 0, -382586771000351226384*a - 2498023791133552294513515, + ....: 358777608829102441023422458989744*a + 1110881475104109582383304709231832166) sage: E = EllipticCurve(ainvs) sage: from sage.schemes.elliptic_curves.kraus import semi_global_minimal_model - sage: Emin, p = semi_global_minimal_model(E) # long time (25s) - sage: p # long time + sage: Emin, p = semi_global_minimal_model(E) # 25s + sage: p Fractional ideal (23567, a + 2270) - sage: p.norm() # long time + sage: p.norm() 23567 - sage: Emin.discriminant().norm().factor() # long time + sage: Emin.discriminant().norm().factor() 23567^12 """ c = E.global_minimality_class() diff --git a/src/sage/schemes/elliptic_curves/lseries_ell.py b/src/sage/schemes/elliptic_curves/lseries_ell.py index 45db560c861..6e1dfa18c52 100644 --- a/src/sage/schemes/elliptic_curves/lseries_ell.py +++ b/src/sage/schemes/elliptic_curves/lseries_ell.py @@ -661,17 +661,18 @@ def deriv_at1(self, k=None, prec=None): EXAMPLES:: sage: E = EllipticCurve('37a') - sage: E.lseries().deriv_at1() + sage: E.lseries().deriv_at1() # needs sage.symbolic (0.3059866, 0.000801045) - sage: E.lseries().deriv_at1(100) + sage: E.lseries().deriv_at1(100) # needs sage.symbolic (0.3059997738340523018204836833216764744526377745903, 1.52493e-45) - sage: E.lseries().deriv_at1(1000) + sage: E.lseries().deriv_at1(1000) # needs sage.symbolic (0.305999773834052301820483683321676474452637774590771998..., 2.75031e-449) With less numerical precision, the error is bounded by numerical accuracy:: - sage: L,err = E.lseries().deriv_at1(100, prec=64) - sage: L,err + sage: # needs sage.symbolic + sage: L, err = E.lseries().deriv_at1(100, prec=64) + sage: L, err (0.305999773834052302, 5.55318e-18) sage: parent(L) Real Field with 64 bits of precision @@ -681,12 +682,12 @@ def deriv_at1(self, k=None, prec=None): Rank 2 and rank 3 elliptic curves:: sage: E = EllipticCurve('389a1') - sage: E.lseries().deriv_at1() + sage: E.lseries().deriv_at1() # needs sage.symbolic (0.0000000, 0.000000) sage: E = EllipticCurve((1, 0, 1, -131, 558)) # curve 59450i1 - sage: E.lseries().deriv_at1() + sage: E.lseries().deriv_at1() # needs sage.symbolic (-0.00010911444, 0.142428) - sage: E.lseries().deriv_at1(4000) + sage: E.lseries().deriv_at1(4000) # needs sage.symbolic (6.990...e-50, 1.31318e-43) """ sqrtN = sqrt(self.__E.conductor()) diff --git a/src/sage/schemes/elliptic_curves/modular_parametrization.py b/src/sage/schemes/elliptic_curves/modular_parametrization.py index 891a9e0142f..501c17cd571 100644 --- a/src/sage/schemes/elliptic_curves/modular_parametrization.py +++ b/src/sage/schemes/elliptic_curves/modular_parametrization.py @@ -153,7 +153,7 @@ def __call__(self, z, prec=None): sage: E = EllipticCurve('37a') sage: phi = E.modular_parametrization() - sage: phi((sqrt(7)*I - 17)/74, 53) + sage: phi((sqrt(7)*I - 17)/74, 53) # needs sage.symbolic (...e-16 - ...e-16*I : ...e-16 + ...e-16*I : 1.00000000000000) Verify that the mapping is invariant under the action of `\Gamma_0(N)` @@ -212,10 +212,11 @@ def map_to_complex_numbers(self, z, prec=None): EXAMPLES:: + sage: # needs sage.symbolic sage: E = EllipticCurve('37a'); phi = E.modular_parametrization() sage: x = polygen(ZZ, 'x') - sage: tau = (sqrt(7)*I - 17)/74 # optional - sage.symbolic - sage: z = phi.map_to_complex_numbers(tau); z # optional - sage.symbolic + sage: tau = (sqrt(7)*I - 17)/74 + sage: z = phi.map_to_complex_numbers(tau); z 0.929592715285395 - 1.22569469099340*I sage: E.elliptic_exponential(z) (...e-16 - ...e-16*I : ...e-16 + ...e-16*I : 1.00000000000000) diff --git a/src/sage/schemes/elliptic_curves/padic_lseries.py b/src/sage/schemes/elliptic_curves/padic_lseries.py index a6ac5c30af5..96177ed417c 100644 --- a/src/sage/schemes/elliptic_curves/padic_lseries.py +++ b/src/sage/schemes/elliptic_curves/padic_lseries.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.rings.padics r""" `p`-adic `L`-functions of elliptic curves diff --git a/src/sage/schemes/elliptic_curves/padics.py b/src/sage/schemes/elliptic_curves/padics.py index 51f7cc3db90..6c4a2050e4f 100644 --- a/src/sage/schemes/elliptic_curves/padics.py +++ b/src/sage/schemes/elliptic_curves/padics.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# sage.doctest: needs sage.rings.padics # # All these methods are imported in EllipticCurve_rational_field, # so there is no reason to add this module to the documentation. @@ -1107,12 +1107,13 @@ def padic_sigma(self, p, N=20, E2=None, check=False, check_hypotheses=True): Test that it returns consistent results over a range of precision:: - sage: max_N = 30 # get up to at least p^2 # long time - sage: E = EllipticCurve([1, 1, 1, 1, 1]) # long time - sage: p = 5 # long time - sage: E2 = E.padic_E2(5, max_N) # long time - sage: max_sigma = E.padic_sigma(p, max_N, E2=E2) # long time - sage: for N in range(3, max_N): # long time + sage: # long time + sage: max_N = 30 # get up to at least p^2 + sage: E = EllipticCurve([1, 1, 1, 1, 1]) + sage: p = 5 + sage: E2 = E.padic_E2(5, max_N) + sage: max_sigma = E.padic_sigma(p, max_N, E2=E2) + sage: for N in range(3, max_N): ....: sigma = E.padic_sigma(p, N, E2=E2) ....: assert sigma == max_sigma """ diff --git a/src/sage/schemes/elliptic_curves/period_lattice.py b/src/sage/schemes/elliptic_curves/period_lattice.py index 66a53cc571a..fe07917abaa 100644 --- a/src/sage/schemes/elliptic_curves/period_lattice.py +++ b/src/sage/schemes/elliptic_curves/period_lattice.py @@ -17,13 +17,13 @@ EXAMPLES:: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: E = EllipticCurve([0,1,0,a,a]) # needs sage.rings.number_field First we try a real embedding:: - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb); L # optional - sage.rings.number_field + sage: emb = K.embeddings(RealField())[0] # needs sage.rings.number_field + sage: L = E.period_lattice(emb); L # needs sage.rings.number_field Period lattice associated to Elliptic Curve defined by y^2 = x^3 + x^2 + a*x + a over Number Field in a with defining polynomial x^3 - 2 with respect to the embedding Ring morphism: @@ -33,22 +33,22 @@ The first basis period is real:: - sage: L.basis() # optional - sage.rings.number_field + sage: L.basis() # needs sage.rings.number_field (3.81452977217855, 1.90726488608927 + 1.34047785962440*I) - sage: L.is_real() # optional - sage.rings.number_field + sage: L.is_real() # needs sage.rings.number_field True For a basis `\omega_1,\omega_2` normalised so that `\omega_1/\omega_2` is in the fundamental region of the upper half-plane, use the function ``normalised_basis()`` instead:: - sage: L.normalised_basis() # optional - sage.rings.number_field + sage: L.normalised_basis() # needs sage.rings.number_field (1.90726488608927 - 1.34047785962440*I, -1.90726488608927 - 1.34047785962440*I) Next a complex embedding:: - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb); L # optional - sage.rings.number_field + sage: emb = K.embeddings(ComplexField())[0] # needs sage.rings.number_field + sage: L = E.period_lattice(emb); L # needs sage.rings.number_field Period lattice associated to Elliptic Curve defined by y^2 = x^3 + x^2 + a*x + a over Number Field in a with defining polynomial x^3 - 2 with respect to the embedding Ring morphism: @@ -60,21 +60,23 @@ that `\tau = \omega_1/\omega_2` is in the fundamental region in the upper half plane:: - sage: w1, w2 = L.basis(); w1, w2 # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: w1, w2 = L.basis(); w1, w2 (-1.37588604166076 - 2.58560946624443*I, -2.10339907847356 + 0.428378776460622*I) - sage: L.is_real() # optional - sage.rings.number_field + sage: L.is_real() False - sage: tau = w1/w2; tau # optional - sage.rings.number_field + sage: tau = w1/w2; tau 0.387694505032876 + 1.30821088214407*I - sage: L.normalised_basis() # optional - sage.rings.number_field + sage: L.normalised_basis() (-1.37588604166076 - 2.58560946624443*I, -2.10339907847356 + 0.428378776460622*I) We test that bug :trac:`8415` (caused by a PARI bug fixed in v2.3.5) is OK:: - sage: E = EllipticCurve('37a') # optional - sage.rings.number_field - sage: K. = QuadraticField(-7) # optional - sage.rings.number_field - sage: EK = E.change_ring(K) # optional - sage.rings.number_field - sage: EK.period_lattice(K.complex_embeddings()[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: E = EllipticCurve('37a') + sage: K. = QuadraticField(-7) + sage: EK = E.change_ring(K) + sage: EK.period_lattice(K.complex_embeddings()[0]) Period lattice associated to Elliptic Curve defined by y^2 + y = x^3 + (-1)*x over Number Field in a with defining polynomial x^2 + 7 with a = 2.645751311064591?*I @@ -180,11 +182,12 @@ def __init__(self, E, embedding=None): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = PeriodLattice_ell(E, emb); L # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = PeriodLattice_ell(E, emb); L Period lattice associated to Elliptic Curve defined by y^2 = x^3 + x^2 + a*x + a over Number Field in a with defining polynomial x^3 - 2 with respect to the embedding Ring morphism: @@ -192,8 +195,8 @@ def __init__(self, E, embedding=None): To: Algebraic Real Field Defn: a |--> 1.259921049894873? - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = PeriodLattice_ell(E, emb); L # optional - sage.rings.number_field + sage: emb = K.embeddings(ComplexField())[0] # needs sage.rings.number_field + sage: L = PeriodLattice_ell(E, emb); L # needs sage.rings.number_field Period lattice associated to Elliptic Curve defined by y^2 = x^3 + x^2 + a*x + a over Number Field in a with defining polynomial x^3 - 2 with respect to the embedding Ring morphism: @@ -203,12 +206,13 @@ def __init__(self, E, embedding=None): TESTS:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.period_lattice import PeriodLattice_ell - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = PeriodLattice_ell(E,emb) # optional - sage.rings.number_field - sage: L == loads(dumps(L)) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = PeriodLattice_ell(E,emb) + sage: L == loads(dumps(L)) True """ # First we cache the elliptic curve with this period lattice: @@ -280,13 +284,14 @@ def __richcmp__(self, other, op): TESTS:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.period_lattice import PeriodLattice_ell sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: embs = K.embeddings(ComplexField()) # optional - sage.rings.number_field - sage: L1, L2, L3 = [PeriodLattice_ell(E, e) for e in embs] # optional - sage.rings.number_field - sage: L1 < L2 < L3 # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: embs = K.embeddings(ComplexField()) + sage: L1, L2, L3 = [PeriodLattice_ell(E, e) for e in embs] + sage: L1 < L2 < L3 True """ if not isinstance(other, PeriodLattice_ell): @@ -312,11 +317,12 @@ def __repr__(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb); L # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb); L Period lattice associated to Elliptic Curve defined by y^2 = x^3 + x^2 + a*x + a over Number Field in a with defining polynomial x^3 - 2 with respect to the embedding Ring morphism: From: Number Field in a with defining polynomial x^3 - 2 @@ -438,21 +444,23 @@ def basis(self, prec=None, algorithm='sage'): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.basis(64) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: L.basis(64) (3.81452977217854509, 1.90726488608927255 + 1.34047785962440202*I) - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: w1, w2 = L.basis(); w1, w2 # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: emb = K.embeddings(ComplexField())[0] + sage: L = E.period_lattice(emb) + sage: w1, w2 = L.basis(); w1, w2 (-1.37588604166076 - 2.58560946624443*I, -2.10339907847356 + 0.428378776460622*I) - sage: L.is_real() # optional - sage.rings.number_field + sage: L.is_real() False - sage: tau = w1/w2; tau # optional - sage.rings.number_field + sage: tau = w1/w2; tau 0.387694505032876 + 1.30821088214407*I """ # We divide into two cases: (1) Q, or a number field with a @@ -540,23 +548,25 @@ def normalised_basis(self, prec=None, algorithm='sage'): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.normalised_basis(64) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: L.normalised_basis(64) (1.90726488608927255 - 1.34047785962440202*I, -1.90726488608927255 - 1.34047785962440202*I) - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: w1, w2 = L.normalised_basis(); w1, w2 # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: emb = K.embeddings(ComplexField())[0] + sage: L = E.period_lattice(emb) + sage: w1, w2 = L.normalised_basis(); w1, w2 (-1.37588604166076 - 2.58560946624443*I, -2.10339907847356 + 0.428378776460622*I) - sage: L.is_real() # optional - sage.rings.number_field + sage: L.is_real() False - sage: tau = w1/w2; tau # optional - sage.rings.number_field + sage: tau = w1/w2; tau 0.387694505032876 + 1.30821088214407*I """ w1, w2 = self.basis(prec=prec, algorithm=algorithm) @@ -594,25 +604,27 @@ def tau(self, prec=None, algorithm='sage'): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: tau = L.tau(); tau # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: tau = L.tau(); tau -0.338718341018919 + 0.940887817679340*I - sage: tau.abs() # optional - sage.rings.number_field + sage: tau.abs() 1.00000000000000 - sage: -0.5 <= tau.real() <= 0.5 # optional - sage.rings.number_field + sage: -0.5 <= tau.real() <= 0.5 True - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: tau = L.tau(); tau # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: emb = K.embeddings(ComplexField())[0] + sage: L = E.period_lattice(emb) + sage: tau = L.tau(); tau 0.387694505032876 + 1.30821088214407*I - sage: tau.abs() # optional - sage.rings.number_field + sage: tau.abs() 1.36444961115933 - sage: -0.5 <= tau.real() <= 0.5 # optional - sage.rings.number_field + sage: -0.5 <= tau.real() <= 0.5 True """ w1, w2 = self.normalised_basis(prec=prec, algorithm=algorithm) @@ -641,17 +653,18 @@ def _compute_periods_real(self, prec=None, algorithm='sage'): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: embs = K.embeddings(CC) # optional - sage.rings.number_field - sage: Ls = [E.period_lattice(e) for e in embs] # optional - sage.rings.number_field - sage: [L.is_real() for L in Ls] # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: embs = K.embeddings(CC) + sage: Ls = [E.period_lattice(e) for e in embs] + sage: [L.is_real() for L in Ls] [False, False, True] - sage: Ls[2]._compute_periods_real(100) # optional - sage.rings.number_field + sage: Ls[2]._compute_periods_real(100) (3.8145297721785450936365098936, 1.9072648860892725468182549468 + 1.3404778596244020196600112394*I) - sage: Ls[2]._compute_periods_real(100, algorithm='pari') # optional - sage.rings.number_field + sage: Ls[2]._compute_periods_real(100, algorithm='pari') (3.8145297721785450936365098936, 1.9072648860892725468182549468 - 1.3404778596244020196600112394*I) """ @@ -712,33 +725,35 @@ def _compute_periods_complex(self, prec=None, normalise=True): EXAMPLES:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: embs = K.embeddings(CC) # optional - sage.rings.number_field - sage: Ls = [E.period_lattice(e) for e in embs] # optional - sage.rings.number_field - sage: [L.is_real() for L in Ls] # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: embs = K.embeddings(CC) + sage: Ls = [E.period_lattice(e) for e in embs] + sage: [L.is_real() for L in Ls] [False, False, True] - sage: L = Ls[0] # optional - sage.rings.number_field - sage: w1,w2 = L._compute_periods_complex(100); w1,w2 # optional - sage.rings.number_field + sage: L = Ls[0] + sage: w1,w2 = L._compute_periods_complex(100); w1,w2 (-1.3758860416607626645495991458 - 2.5856094662444337042877901304*I, -2.1033990784735587243397865076 + 0.42837877646062187766760569686*I) - sage: tau = w1/w2; tau # optional - sage.rings.number_field + sage: tau = w1/w2; tau 0.38769450503287609349437509561 + 1.3082108821440725664008561928*I - sage: tau.real() # optional - sage.rings.number_field + sage: tau.real() 0.38769450503287609349437509561 - sage: tau.abs() # optional - sage.rings.number_field + sage: tau.abs() 1.3644496111593345713923386773 Without normalisation:: - sage: w1,w2 = L._compute_periods_complex(normalise=False); w1,w2 # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: w1,w2 = L._compute_periods_complex(normalise=False); w1,w2 (2.10339907847356 - 0.428378776460622*I, 0.727513036812796 - 3.01398824270506*I) - sage: tau = w1/w2; tau # optional - sage.rings.number_field + sage: tau = w1/w2; tau 0.293483964608883 + 0.627038168678760*I - sage: tau.real() # optional - sage.rings.number_field + sage: tau.real() 0.293483964608883 - sage: tau.abs() # > 1 # optional - sage.rings.number_field + sage: tau.abs() # > 1 0.692321964451917 """ if prec is None: @@ -775,19 +790,20 @@ def is_real(self): :: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,0,i,2*i]) # optional - sage.rings.number_field - sage: emb = K.embeddings(ComplexField())[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.is_real() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve(K, [0,0,0,i,2*i]) + sage: emb = K.embeddings(ComplexField())[0] + sage: L = E.period_lattice(emb) + sage: L.is_real() False :: sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: [E.period_lattice(emb).is_real() for emb in K.embeddings(CC)] # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) # needs sage.rings.number_field + sage: E = EllipticCurve([0,1,0,a,a]) # needs sage.rings.number_field + sage: [E.period_lattice(emb).is_real() for emb in K.embeddings(CC)] # needs sage.rings.number_field [False, False, True] ALGORITHM: @@ -859,12 +875,13 @@ def real_period(self, prec=None, algorithm='sage'): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.real_period(64) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: L.real_period(64) 3.81452977217854509 """ if self.is_real(): @@ -921,12 +938,13 @@ def omega(self, prec=None, bsd_normalise=False): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.omega(64) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: L.omega(64) 3.81452977217854509 A complex example (taken from J.E.Cremona and E.Whitley, @@ -934,14 +952,15 @@ def omega(self, prec=None, bsd_normalise=False): quadratic fields*, Mathematics of Computation 62 No. 205 (1994), 407-429). See :trac:`29645` and :trac:`29782`:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1-i,i,-i,0]) # optional - sage.rings.number_field - sage: L = E.period_lattice(K.embeddings(CC)[0]) # optional - sage.rings.number_field - sage: L.omega() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0,1-i,i,-i,0]) + sage: L = E.period_lattice(K.embeddings(CC)[0]) + sage: L.omega() 8.80694160502647 - sage: L.omega(prec=200) # optional - sage.rings.number_field + sage: L.omega(prec=200) 8.8069416050264741493250743632295462227858630765392114070032 - sage: L.omega(bsd_normalise=True) # optional - sage.rings.number_field + sage: L.omega(bsd_normalise=True) 17.6138832100529 """ if self.is_real(): @@ -979,12 +998,13 @@ def basis_matrix(self, prec=None, normalised=False): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: emb = K.embeddings(RealField())[0] # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: L.basis_matrix(64) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: emb = K.embeddings(RealField())[0] + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(emb) + sage: L.basis_matrix(64) [ 3.81452977217854509 0.000000000000000000] [ 1.90726488608927255 1.34047785962440202] @@ -1037,6 +1057,7 @@ def complex_area(self, prec=None): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') sage: K. = NumberField(x^3 - 2) sage: embs = K.embeddings(ComplexField()) @@ -1104,15 +1125,16 @@ def curve(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(K.embeddings(RealField())[0]) # optional - sage.rings.number_field - sage: L.curve() is E # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(K.embeddings(RealField())[0]) + sage: L.curve() is E True - sage: L = E.period_lattice(K.embeddings(ComplexField())[0]) # optional - sage.rings.number_field - sage: L.curve() is E # optional - sage.rings.number_field + sage: L = E.period_lattice(K.embeddings(ComplexField())[0]) # needs sage.rings.number_field + sage: L.curve() is E # needs sage.rings.number_field True """ return self.E @@ -1134,20 +1156,21 @@ def ei(self): :: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,1,0,a,a]) # optional - sage.rings.number_field - sage: L = E.period_lattice(K.embeddings(RealField())[0]) # optional - sage.rings.number_field - sage: x1,x2,x3 = L.ei() # optional - sage.rings.number_field - sage: abs(x1.real()) + abs(x2.real()) < 1e-14 # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,1,0,a,a]) + sage: L = E.period_lattice(K.embeddings(RealField())[0]) + sage: x1,x2,x3 = L.ei() + sage: abs(x1.real()) + abs(x2.real()) < 1e-14 True - sage: x1.imag(), x2.imag(), x3 # optional - sage.rings.number_field + sage: x1.imag(), x2.imag(), x3 (-1.122462048309373?, 1.122462048309373?, -1.000000000000000?) :: - sage: L = E.period_lattice(K.embeddings(ComplexField())[0]) # optional - sage.rings.number_field - sage: L.ei() # optional - sage.rings.number_field + sage: L = E.period_lattice(K.embeddings(ComplexField())[0]) # needs sage.rings.number_field + sage: L.ei() # needs sage.rings.number_field [-1.000000000000000? + 0.?e-1...*I, -0.9720806486198328? - 0.561231024154687?*I, 0.9720806486198328? + 0.561231024154687?*I] @@ -1350,45 +1373,48 @@ def e_log_RC(self, xP, yP, prec=None, reduce=True): A number field example:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,0,a]) # optional - sage.rings.number_field - sage: v = K.real_places()[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(v) # optional - sage.rings.number_field - sage: P = E.lift_x(1/3*a^2 + a + 5/3) # optional - sage.rings.number_field - sage: L(P) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: E = EllipticCurve([0,0,0,0,a]) + sage: v = K.real_places()[0] + sage: L = E.period_lattice(v) + sage: P = E.lift_x(1/3*a^2 + a + 5/3) + sage: L(P) 3.51086196882538 - sage: xP, yP = [v(c) for c in P.xy()] # optional - sage.rings.number_field - sage: L.e_log_RC(xP, yP) # optional - sage.rings.number_field + sage: xP, yP = [v(c) for c in P.xy()] + sage: L.e_log_RC(xP, yP) 3.51086196882538 Elliptic logs of real points which do not come from algebraic points:: - sage: ER = EllipticCurve([v(ai) for ai in E.a_invariants()]) # optional - sage.rings.number_field - sage: P = ER.lift_x(12.34) # optional - sage.rings.number_field - sage: xP, yP = P.xy() # optional - sage.rings.number_field - sage: xP, yP # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: ER = EllipticCurve([v(ai) for ai in E.a_invariants()]) + sage: P = ER.lift_x(12.34) + sage: xP, yP = P.xy() + sage: xP, yP (12.3400000000000, -43.3628968710567) - sage: L.e_log_RC(xP, yP) # optional - sage.rings.number_field + sage: L.e_log_RC(xP, yP) 0.284656841192041 - sage: xP, yP = ER.lift_x(0).xy() # optional - sage.rings.number_field - sage: L.e_log_RC(xP, yP) # optional - sage.rings.number_field + sage: xP, yP = ER.lift_x(0).xy() + sage: L.e_log_RC(xP, yP) 1.34921304541057 Elliptic logs of complex points:: - sage: v = K.complex_embeddings()[0] # optional - sage.rings.number_field - sage: L = E.period_lattice(v) # optional - sage.rings.number_field - sage: P = E.lift_x(1/3*a^2 + a + 5/3) # optional - sage.rings.number_field - sage: L(P) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: v = K.complex_embeddings()[0] + sage: L = E.period_lattice(v) + sage: P = E.lift_x(1/3*a^2 + a + 5/3) + sage: L(P) 1.68207104397706 - 1.87873661686704*I - sage: xP, yP = [v(c) for c in P.xy()] # optional - sage.rings.number_field - sage: L.e_log_RC(xP, yP) # optional - sage.rings.number_field + sage: xP, yP = [v(c) for c in P.xy()] + sage: L.e_log_RC(xP, yP) 1.68207104397706 - 1.87873661686704*I - sage: EC = EllipticCurve([v(ai) for ai in E.a_invariants()]) # optional - sage.rings.number_field - sage: xP, yP = EC.lift_x(0).xy() # optional - sage.rings.number_field - sage: L.e_log_RC(xP, yP) # optional - sage.rings.number_field + sage: EC = EllipticCurve([v(ai) for ai in E.a_invariants()]) + sage: xP, yP = EC.lift_x(0).xy() + sage: L.e_log_RC(xP, yP) 2.06711431204080 - 1.73451485683471*I """ if prec is None: @@ -1583,22 +1609,23 @@ def elliptic_logarithm(self, P, prec=None, reduce=True): Some complex examples, taken from the paper by Cremona and Thongjunthug:: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: a4 = 9*i - 10 # optional - sage.rings.number_field - sage: a6 = 21 - i # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,a4,a6]) # optional - sage.rings.number_field - sage: e1 = 3 - 2*i; e2 = 1 + i; e3 = -4 + i # optional - sage.rings.number_field - sage: emb = K.embeddings(CC)[1] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: P = E(2 - i, 4 + 2*i) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: a4 = 9*i - 10 + sage: a6 = 21 - i + sage: E = EllipticCurve([0,0,0,a4,a6]) + sage: e1 = 3 - 2*i; e2 = 1 + i; e3 = -4 + i + sage: emb = K.embeddings(CC)[1] + sage: L = E.period_lattice(emb) + sage: P = E(2 - i, 4 + 2*i) By default, the output is reduced with respect to the normalised lattice basis, so that its coordinates with respect to that basis lie in the interval [0,1):: - sage: z = L.elliptic_logarithm(P, prec=100); z # optional - sage.rings.number_field + sage: z = L.elliptic_logarithm(P, prec=100); z # needs sage.rings.number_field 0.70448375537782208460499649302 - 0.79246725643650979858266018068*I - sage: L.coordinates(z) # optional - sage.rings.number_field + sage: L.coordinates(z) # needs sage.rings.number_field (0.46247636364807931766105406092, 0.79497588726808704200760395829) Using ``reduce=False`` this step can be omitted. In this case @@ -1606,76 +1633,78 @@ def elliptic_logarithm(self, P, prec=None, reduce=True): this is not guaranteed. This option is mainly for testing purposes:: - sage: z = L.elliptic_logarithm(P, prec=100, reduce=False); z # optional - sage.rings.number_field + sage: z = L.elliptic_logarithm(P, prec=100, reduce=False); z # needs sage.rings.number_field 0.57002153834710752778063503023 + 0.46476340520469798857457031393*I - sage: L.coordinates(z) # optional - sage.rings.number_field + sage: L.coordinates(z) # needs sage.rings.number_field (0.46247636364807931766105406092, -0.20502411273191295799239604171) The elliptic logs of the 2-torsion points are half-periods:: - sage: L.elliptic_logarithm(E(e1, 0), prec=100) # optional - sage.rings.number_field + sage: L.elliptic_logarithm(E(e1, 0), prec=100) # needs sage.rings.number_field 0.64607575874356525952487867052 + 0.22379609053909448304176885364*I - sage: L.elliptic_logarithm(E(e2, 0), prec=100) # optional - sage.rings.number_field + sage: L.elliptic_logarithm(E(e2, 0), prec=100) # needs sage.rings.number_field 0.71330686725892253793705940192 - 0.40481924028150941053684639367*I - sage: L.elliptic_logarithm(E(e3, 0), prec=100) # optional - sage.rings.number_field + sage: L.elliptic_logarithm(E(e3, 0), prec=100) # needs sage.rings.number_field 0.067231108515357278412180731396 - 0.62861533082060389357861524731*I We check this by doubling and seeing that the resulting coordinates are integers:: - sage: L.coordinates(2*L.elliptic_logarithm(E(e1, 0), prec=100)) # optional - sage.rings.number_field + sage: L.coordinates(2*L.elliptic_logarithm(E(e1, 0), prec=100)) # needs sage.rings.number_field (1.0000000000000000000000000000, 0.00000000000000000000000000000) - sage: L.coordinates(2*L.elliptic_logarithm(E(e2, 0), prec=100)) # optional - sage.rings.number_field + sage: L.coordinates(2*L.elliptic_logarithm(E(e2, 0), prec=100)) # needs sage.rings.number_field (1.0000000000000000000000000000, 1.0000000000000000000000000000) - sage: L.coordinates(2*L.elliptic_logarithm(E(e3, 0), prec=100)) # optional - sage.rings.number_field + sage: L.coordinates(2*L.elliptic_logarithm(E(e3, 0), prec=100)) # needs sage.rings.number_field (0.00000000000000000000000000000, 1.0000000000000000000000000000) :: - sage: a4 = -78*i + 104 # optional - sage.rings.number_field - sage: a6 = -216*i - 312 # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,a4,a6]) # optional - sage.rings.number_field - sage: emb = K.embeddings(CC)[1] # optional - sage.rings.number_field - sage: L = E.period_lattice(emb) # optional - sage.rings.number_field - sage: P = E(3 + 2*i, 14 - 7*i) # optional - sage.rings.number_field - sage: L.elliptic_logarithm(P) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: a4 = -78*i + 104 + sage: a6 = -216*i - 312 + sage: E = EllipticCurve([0,0,0,a4,a6]) + sage: emb = K.embeddings(CC)[1] + sage: L = E.period_lattice(emb) + sage: P = E(3 + 2*i, 14 - 7*i) + sage: L.elliptic_logarithm(P) 0.297147783912228 - 0.546125549639461*I - sage: L.coordinates(L.elliptic_logarithm(P)) # optional - sage.rings.number_field + sage: L.coordinates(L.elliptic_logarithm(P)) (0.628653378040238, 0.371417754610223) - sage: e1 = 1 + 3*i; e2 = -4 - 12*i; e3 = -e1 - e2 # optional - sage.rings.number_field - sage: L.coordinates(L.elliptic_logarithm(E(e1, 0))) # optional - sage.rings.number_field + sage: e1 = 1 + 3*i; e2 = -4 - 12*i; e3 = -e1 - e2 + sage: L.coordinates(L.elliptic_logarithm(E(e1, 0))) (0.500000000000000, 0.500000000000000) - sage: L.coordinates(L.elliptic_logarithm(E(e2, 0))) # optional - sage.rings.number_field + sage: L.coordinates(L.elliptic_logarithm(E(e2, 0))) (1.00000000000000, 0.500000000000000) - sage: L.coordinates(L.elliptic_logarithm(E(e3, 0))) # optional - sage.rings.number_field + sage: L.coordinates(L.elliptic_logarithm(E(e3, 0))) (0.500000000000000, 0.000000000000000) TESTS: See :trac:`10026` and :trac:`11767`:: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: E = EllipticCurve([0, -1, 1, -3*w - 4, 3*w + 4]) # optional - sage.rings.number_field - sage: T = E.simon_two_descent(lim1=20, lim3=5, limtriv=20) # optional - sage.rings.number_field - sage: P, Q = T[2] # optional - sage.rings.number_field - sage: embs = K.embeddings(CC) # optional - sage.rings.number_field - sage: Lambda = E.period_lattice(embs[0]) # optional - sage.rings.number_field - sage: Lambda.elliptic_logarithm(P, 100) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: E = EllipticCurve([0, -1, 1, -3*w - 4, 3*w + 4]) + sage: T = E.simon_two_descent(lim1=20, lim3=5, limtriv=20) + sage: P, Q = T[2] + sage: embs = K.embeddings(CC) + sage: Lambda = E.period_lattice(embs[0]) + sage: Lambda.elliptic_logarithm(P, 100) 4.7100131126199672766973600998 sage: R. = QQ[] - sage: K. = NumberField(x^2 + x + 5) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,0,1,-3,-5]) # optional - sage.rings.number_field - sage: P = E([0,a]) # optional - sage.rings.number_field - sage: Lambda = P.curve().period_lattice(K.embeddings(ComplexField(600))[0]) # optional - sage.rings.number_field - sage: Lambda.elliptic_logarithm(P, prec=600) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + x + 5) + sage: E = EllipticCurve(K, [0,0,1,-3,-5]) + sage: P = E([0,a]) + sage: Lambda = P.curve().period_lattice(K.embeddings(ComplexField(600))[0]) + sage: Lambda.elliptic_logarithm(P, prec=600) -0.842248166487739393375018008381693990800588864069506187033873183845246233548058477561706400464057832396643843146464236956684557207157300006542470428493573195030603817094900751609464 - 0.571366031453267388121279381354098224265947866751130917440598461117775339240176310729173301979590106474259885638797913383502735083088736326391919063211421189027226502851390118943491*I - sage: K. = QuadraticField(-5) # optional - sage.rings.number_field - sage: E = EllipticCurve([1,1,a,a,0]) # optional - sage.rings.number_field - sage: P = E(0, 0) # optional - sage.rings.number_field - sage: L = P.curve().period_lattice(K.embeddings(ComplexField())[0]) # optional - sage.rings.number_field - sage: L.elliptic_logarithm(P, prec=500) # optional - sage.rings.number_field + sage: K. = QuadraticField(-5) + sage: E = EllipticCurve([1,1,a,a,0]) + sage: P = E(0, 0) + sage: L = P.curve().period_lattice(K.embeddings(ComplexField())[0]) + sage: L.elliptic_logarithm(P, prec=500) 1.17058357737548897849026170185581196033579563441850967539191867385734983296504066660506637438866628981886518901958717288150400849746892393771983141354 - 1.13513899565966043682474529757126359416758251309237866586896869548539516543734207347695898664875799307727928332953834601460994992792519799260968053875*I - sage: L.elliptic_logarithm(P, prec=1000) # optional - sage.rings.number_field + sage: L.elliptic_logarithm(P, prec=1000) 1.17058357737548897849026170185581196033579563441850967539191867385734983296504066660506637438866628981886518901958717288150400849746892393771983141354014895386251320571643977497740116710952913769943240797618468987304985625823413440999754037939123032233879499904283600304184828809773650066658885672885 - 1.13513899565966043682474529757126359416758251309237866586896869548539516543734207347695898664875799307727928332953834601460994992792519799260968053875387282656993476491590607092182964878750169490985439873220720963653658829712494879003124071110818175013453207439440032582917366703476398880865439217473*I """ if not P.curve() is self.E: @@ -1748,53 +1777,56 @@ def elliptic_exponential(self, z, to_curve=True): Examples over number fields:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ) - sage: K. = NumberField(x^3 - 2) # optional - sage.rings.number_field - sage: embs = K.embeddings(CC) # optional - sage.rings.number_field - sage: E = EllipticCurve('37a') # optional - sage.rings.number_field - sage: EK = E.change_ring(K) # optional - sage.rings.number_field - sage: Li = [EK.period_lattice(e) for e in embs] # optional - sage.rings.number_field - sage: P = EK(-1, -1) # optional - sage.rings.number_field - sage: Q = EK(a - 1, 1 - a^2) # optional - sage.rings.number_field - sage: zi = [L.elliptic_logarithm(P) for L in Li] # optional - sage.rings.number_field - sage: [c.real() for c in Li[0].elliptic_exponential(zi[0])] # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - 2) + sage: embs = K.embeddings(CC) + sage: E = EllipticCurve('37a') + sage: EK = E.change_ring(K) + sage: Li = [EK.period_lattice(e) for e in embs] + sage: P = EK(-1, -1) + sage: Q = EK(a - 1, 1 - a^2) + sage: zi = [L.elliptic_logarithm(P) for L in Li] + sage: [c.real() for c in Li[0].elliptic_exponential(zi[0])] [-1.00000000000000, -1.00000000000000, 1.00000000000000] - sage: [c.real() for c in Li[0].elliptic_exponential(zi[1])] # optional - sage.rings.number_field + sage: [c.real() for c in Li[0].elliptic_exponential(zi[1])] [-1.00000000000000, -1.00000000000000, 1.00000000000000] - sage: [c.real() for c in Li[0].elliptic_exponential(zi[2])] # optional - sage.rings.number_field + sage: [c.real() for c in Li[0].elliptic_exponential(zi[2])] [-1.00000000000000, -1.00000000000000, 1.00000000000000] - sage: zi = [L.elliptic_logarithm(Q) for L in Li] # optional - sage.rings.number_field - sage: Li[0].elliptic_exponential(zi[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: zi = [L.elliptic_logarithm(Q) for L in Li] + sage: Li[0].elliptic_exponential(zi[0]) (-1.62996052494744 - 1.09112363597172*I : 1.79370052598410 - 1.37472963699860*I : 1.00000000000000) - sage: [embs[0](c) for c in Q] # optional - sage.rings.number_field + sage: [embs[0](c) for c in Q] [-1.62996052494744 - 1.09112363597172*I, 1.79370052598410 - 1.37472963699860*I, 1.00000000000000] - sage: Li[1].elliptic_exponential(zi[1]) # optional - sage.rings.number_field + sage: Li[1].elliptic_exponential(zi[1]) (-1.62996052494744 + 1.09112363597172*I : 1.79370052598410 + 1.37472963699860*I : 1.00000000000000) - sage: [embs[1](c) for c in Q] # optional - sage.rings.number_field + sage: [embs[1](c) for c in Q] [-1.62996052494744 + 1.09112363597172*I, 1.79370052598410 + 1.37472963699860*I, 1.00000000000000] - sage: [c.real() for c in Li[2].elliptic_exponential(zi[2])] # optional - sage.rings.number_field + sage: [c.real() for c in Li[2].elliptic_exponential(zi[2])] [0.259921049894873, -0.587401051968199, 1.00000000000000] - sage: [embs[2](c) for c in Q] # optional - sage.rings.number_field + sage: [embs[2](c) for c in Q] [0.259921049894873, -0.587401051968200, 1.00000000000000] Test to show that :trac:`8820` is fixed:: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('37a') - sage: K. = QuadraticField(-5) # optional - sage.rings.number_field - sage: L = E.change_ring(K).period_lattice(K.places()[0]) # optional - sage.rings.number_field - sage: L.elliptic_exponential(CDF(.1,.1)) # optional - sage.rings.number_field + sage: K. = QuadraticField(-5) + sage: L = E.change_ring(K).period_lattice(K.places()[0]) + sage: L.elliptic_exponential(CDF(.1,.1)) (0.0000142854026029... - 49.9960001066650*I : 249.520141250950 + 250.019855549131*I : 1.00000000000000) - sage: L.elliptic_exponential(CDF(.1,.1), to_curve=False) # optional - sage.rings.number_field + sage: L.elliptic_exponential(CDF(.1,.1), to_curve=False) (0.0000142854026029447 - 49.9960001066650*I, 500.040282501900 + 500.039711098263*I) @@ -1809,22 +1841,24 @@ def elliptic_exponential(self, z, to_curve=True): :: + sage: # needs sage.rings.number_field sage: E = EllipticCurve('37a') - sage: K. = QuadraticField(-5) # optional - sage.rings.number_field - sage: L = E.change_ring(K).period_lattice(K.places()[0]) # optional - sage.rings.number_field - sage: P = L.elliptic_exponential(0); P # optional - sage.rings.number_field + sage: K. = QuadraticField(-5) + sage: L = E.change_ring(K).period_lattice(K.places()[0]) + sage: P = L.elliptic_exponential(0); P (0.000000000000000 : 1.00000000000000 : 0.000000000000000) - sage: P.parent() # optional - sage.rings.number_field + sage: P.parent() Abelian group of points on Elliptic Curve defined by y^2 + 1.00000000000000*y = x^3 + (-1.00000000000000)*x over Complex Field with 53 bits of precision Very small `z` are handled properly (see :trac:`8820`):: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: E = EllipticCurve([0,0,0,a,0]) # optional - sage.rings.number_field - sage: L = E.period_lattice(K.complex_embeddings()[0]) # optional - sage.rings.number_field - sage: L.elliptic_exponential(1e-100) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: E = EllipticCurve([0,0,0,a,0]) + sage: L = E.period_lattice(K.complex_embeddings()[0]) + sage: L.elliptic_exponential(1e-100) (0.000000000000000 : 1.00000000000000 : 0.000000000000000) The elliptic exponential of `z` is returned as (0 : 1 : 0) if @@ -1833,9 +1867,9 @@ def elliptic_exponential(self, z, to_curve=True): sage: (100/log(2.0,10))/0.8 415.241011860920 - sage: L.elliptic_exponential((RealField(415)(1e-100))).is_zero() # optional - sage.rings.number_field + sage: L.elliptic_exponential((RealField(415)(1e-100))).is_zero() # needs sage.rings.number_field True - sage: L.elliptic_exponential((RealField(420)(1e-100))).is_zero() # optional - sage.rings.number_field + sage: L.elliptic_exponential((RealField(420)(1e-100))).is_zero() # needs sage.rings.number_field False """ C = z.parent() @@ -1919,6 +1953,7 @@ def reduce_tau(tau): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage.symbolic sage: from sage.schemes.elliptic_curves.period_lattice import reduce_tau sage: reduce_tau(CC(1.23,3.45)) (0.230000000000000 + 3.45000000000000*I, [1, -1, 0, 1]) @@ -1966,6 +2001,7 @@ def normalise_periods(w1, w2): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage.symbolic sage: from sage.schemes.elliptic_curves.period_lattice import reduce_tau, normalise_periods sage: w1 = CC(1.234, 3.456) sage: w2 = CC(1.234, 3.456000001) @@ -2007,6 +2043,7 @@ def extended_agm_iteration(a, b, c): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage: from sage.schemes.elliptic_curves.period_lattice import extended_agm_iteration sage: extended_agm_iteration(RR(1), RR(2), RR(3)) (1.45679103104691, 1.45679103104691, 3.21245294970054) @@ -2017,7 +2054,7 @@ def extended_agm_iteration(a, b, c): TESTS:: - sage: extended_agm_iteration(1,2,3) + sage: extended_agm_iteration(1,2,3) # needs sage.rings.real_mpfr Traceback (most recent call last): ... ValueError: values must be real or complex numbers diff --git a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx index 0d24651f4c1..b0914d6347a 100644 --- a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx +++ b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.complex_double sage.symbolic r""" Regions in fundamental domains of period lattices @@ -54,12 +55,12 @@ cdef class PeriodicRegion: sage: import numpy as np sage: from sage.schemes.elliptic_curves.period_lattice_region import PeriodicRegion sage: S = PeriodicRegion(CDF(2), CDF(2*I), np.zeros((4, 4))) - sage: S.plot() + sage: S.plot() # needs sage.plot Graphics object consisting of 1 graphics primitive sage: data = np.zeros((4, 4)) sage: data[1,1] = True sage: S = PeriodicRegion(CDF(2), CDF(2*I+1), data) - sage: S.plot() + sage: S.plot() # needs sage.plot Graphics object consisting of 5 graphics primitives """ if data.dtype is not np.int8: @@ -250,16 +251,16 @@ cdef class PeriodicRegion: sage: data = np.zeros((4, 4)) sage: data[1,1] = True sage: S = PeriodicRegion(CDF(1), CDF(I + 1/2), data) - sage: S.plot() + sage: S.plot() # needs sage.plot Graphics object consisting of 5 graphics primitives - sage: S.expand().plot() + sage: S.expand().plot() # needs sage.plot Graphics object consisting of 13 graphics primitives sage: S.expand().data array([[1, 1, 1, 0], [1, 1, 1, 0], [1, 1, 1, 0], [0, 0, 0, 0]], dtype=int8) - sage: S.expand(corners=False).plot() + sage: S.expand(corners=False).plot() # needs sage.plot Graphics object consisting of 13 graphics primitives sage: S.expand(corners=False).data array([[0, 1, 0, 0], @@ -298,9 +299,9 @@ cdef class PeriodicRegion: sage: data = np.zeros((10, 10)) sage: data[1:4,1:4] = True sage: S = PeriodicRegion(CDF(1), CDF(I + 1/2), data) - sage: S.plot() + sage: S.plot() # needs sage.plot Graphics object consisting of 13 graphics primitives - sage: S.contract().plot() + sage: S.contract().plot() # needs sage.plot Graphics object consisting of 5 graphics primitives sage: S.contract().data.sum() 1 @@ -376,11 +377,11 @@ cdef class PeriodicRegion: sage: data[2:6, 2] = True sage: data[3, 3] = True sage: S = PeriodicRegion(CDF(1), CDF(I + 1/2), data) - sage: S.plot() + sage: S.plot() # needs sage.plot Graphics object consisting of 29 graphics primitives - sage: (S / 2).plot() + sage: (S / 2).plot() # needs sage.plot Graphics object consisting of 57 graphics primitives - sage: (S / 3).plot() + sage: (S / 3).plot() # needs sage.plot Graphics object consisting of 109 graphics primitives sage: (S / 2 / 3) == (S / 6) == (S / 3 / 2) True @@ -619,7 +620,7 @@ cdef class PeriodicRegion: sage: S = PeriodicRegion(CDF(1), CDF(I+1/2), data) sage: S.innermost_point() 0.375 + 0.25*I - sage: S.plot() + point(S.innermost_point()) + sage: S.plot() + point(S.innermost_point()) # needs sage.plot Graphics object consisting of 24 graphics primitives """ if self.is_empty(): @@ -646,7 +647,7 @@ cdef class PeriodicRegion: sage: data[2:5, 2] = True sage: data[3, 3] = True sage: S = PeriodicRegion(CDF(1), CDF(I + 1/2), data) - sage: plot(S) + plot(S.expand(), rgbcolor=(1, 0, 1), thickness=2) + sage: plot(S) + plot(S.expand(), rgbcolor=(1, 0, 1), thickness=2) # needs sage.plot Graphics object consisting of 46 graphics primitives """ from sage.plot.line import line diff --git a/src/sage/schemes/elliptic_curves/saturation.py b/src/sage/schemes/elliptic_curves/saturation.py index c75972e7f02..095b5b1be12 100644 --- a/src/sage/schemes/elliptic_curves/saturation.py +++ b/src/sage/schemes/elliptic_curves/saturation.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings sage.rings.number_field +# sage.doctest: needs sage.rings.finite_rings sage.rings.number_field r""" Saturation of Mordell-Weil groups of elliptic curves over number fields diff --git a/src/sage/schemes/elliptic_curves/weierstrass_morphism.py b/src/sage/schemes/elliptic_curves/weierstrass_morphism.py index 16fd424bde6..57ff015a2b2 100644 --- a/src/sage/schemes/elliptic_curves/weierstrass_morphism.py +++ b/src/sage/schemes/elliptic_curves/weierstrass_morphism.py @@ -446,9 +446,9 @@ def __init__(self, E=None, urst=None, F=None): Check for :trac:`33215`:: sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E = EllipticCurve(GF(71^2), [5,5]) # optional - sage.rings.finite_rings - sage: iso = WeierstrassIsomorphism(E, (1,2,3,4)) # optional - sage.rings.finite_rings - sage: ~iso # indirect doctest # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(71^2), [5,5]) # needs sage.rings.finite_rings + sage: iso = WeierstrassIsomorphism(E, (1,2,3,4)) # needs sage.rings.finite_rings + sage: ~iso # indirect doctest # needs sage.rings.finite_rings Elliptic-curve morphism: From: Elliptic Curve defined by y^2 + 6*x*y + 8*y = x^3 + 68*x^2 + 64*x + 7 over Finite Field in z2 of size 71^2 To: Elliptic Curve defined by y^2 = x^3 + 5*x + 5 over Finite Field in z2 of size 71^2 @@ -456,7 +456,7 @@ def __init__(self, E=None, urst=None, F=None): Test for :trac:`33312`:: - sage: type(iso.degree()) # optional - sage.rings.finite_rings + sage: type(iso.degree()) # needs sage.rings.finite_rings """ from .ell_generic import is_EllipticCurve @@ -535,16 +535,16 @@ def _comparison_impl(left, right, op): sage: w1 == w2 False - sage: E = EllipticCurve_from_j(GF(7)(0)) # optional - sage.rings.finite_rings - sage: F = E.change_weierstrass_model(2,3,4,5) # optional - sage.rings.finite_rings - sage: a = E.isomorphisms(F) # optional - sage.rings.finite_rings - sage: b = [w*a[0] for w in F.automorphisms()] # optional - sage.rings.finite_rings - sage: b.sort() # optional - sage.rings.finite_rings - sage: a == b # optional - sage.rings.finite_rings + sage: E = EllipticCurve_from_j(GF(7)(0)) + sage: F = E.change_weierstrass_model(2,3,4,5) + sage: a = E.isomorphisms(F) + sage: b = [w*a[0] for w in F.automorphisms()] + sage: b.sort() + sage: a == b True - sage: c = [a[0]*w for w in E.automorphisms()] # optional - sage.rings.finite_rings - sage: c.sort() # optional - sage.rings.finite_rings - sage: a == c # optional - sage.rings.finite_rings + sage: c = [a[0]*w for w in E.automorphisms()] + sage: c.sort() + sage: a == c True """ if not isinstance(left, WeierstrassIsomorphism) or not isinstance(right, WeierstrassIsomorphism): @@ -589,18 +589,19 @@ def _eval(self, P): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E = EllipticCurve([i, 0]); E # optional - sage.rings.number_field + sage: E = EllipticCurve([i, 0]); E Elliptic Curve defined by y^2 = x^3 + I*x over Number Field in I with defining polynomial x^2 + 1 with I = 1*I - sage: iso = WeierstrassIsomorphism(E, (i,1,2,3)) # optional - sage.rings.number_field - sage: P = E.change_ring(QQbar).lift_x(QQbar.random_element()) # optional - sage.rings.number_field - sage: Q = iso._eval(P) # optional - sage.rings.number_field - sage: Q.curve() # optional - sage.rings.number_field + sage: iso = WeierstrassIsomorphism(E, (i,1,2,3)) + sage: P = E.change_ring(QQbar).lift_x(QQbar.random_element()) + sage: Q = iso._eval(P) + sage: Q.curve() Elliptic Curve defined by y^2 + (-4*I)*x*y + 6*I*y = x^3 + x^2 + (I-9)*x + (-I+8) over Algebraic Field - sage: y = next(filter(bool, iter(QQbar.random_element, None))) # sample until nonzero # optional - sage.rings.number_field - sage: iso._eval((0, y, 0)) == 0 # optional - sage.rings.number_field + sage: y = next(filter(bool, iter(QQbar.random_element, None))) # sample until nonzero + sage: iso._eval((0, y, 0)) == 0 True """ if self._domain.defining_polynomial()(*P): @@ -637,14 +638,15 @@ def __call__(self, P): Check that copying the order over works:: - sage: E = EllipticCurve(GF(431^2), [1,0]) # optional - sage.rings.finite_rings - sage: i = next(a for a in E.automorphisms() if a^2 == -a^24) # optional - sage.rings.finite_rings - sage: P,_ = E.gens() # optional - sage.rings.finite_rings - sage: P._order # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(431^2), [1,0]) + sage: i = next(a for a in E.automorphisms() if a^2 == -a^24) + sage: P,_ = E.gens() + sage: P._order 432 - sage: i(P)._order # optional - sage.rings.finite_rings + sage: i(P)._order 432 - sage: E(i(P))._order # optional - sage.rings.finite_rings + sage: E(i(P))._order 432 """ if P[2] == 0: @@ -768,11 +770,12 @@ def rational_maps(self): :: - sage: E = EllipticCurve(GF(65537), [1,1,1,1,1]) # optional - sage.rings.finite_rings - sage: w = E.isomorphism_to(E.short_weierstrass_model()) # optional - sage.rings.finite_rings - sage: f,g = w.rational_maps() # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: w(P).xy() == (f(P.xy()), g(P.xy())) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF(65537), [1,1,1,1,1]) + sage: w = E.isomorphism_to(E.short_weierstrass_model()) + sage: f,g = w.rational_maps() + sage: P = E.random_point() + sage: w(P).xy() == (f(P.xy()), g(P.xy())) True TESTS: @@ -855,8 +858,8 @@ def is_separable(self): EXAMPLES:: - sage: E = EllipticCurve(GF(31337), [0,1]) # optional - sage.rings.finite_rings - sage: {f.is_separable() for f in E.automorphisms()} # optional - sage.rings.finite_rings + sage: E = EllipticCurve(GF(31337), [0,1]) # needs sage.rings.finite_rings + sage: {f.is_separable() for f in E.automorphisms()} # needs sage.rings.finite_rings {True} """ return True @@ -870,9 +873,9 @@ def dual(self): EXAMPLES:: sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: E = EllipticCurve(QuadraticField(-3), [0,1]) # optional - sage.rings.number_field - sage: w = WeierstrassIsomorphism(E, (CyclotomicField(3).gen(),0,0,0)) # optional - sage.rings.number_field - sage: (w.dual() * w).rational_maps() # optional - sage.rings.number_field + sage: E = EllipticCurve(QuadraticField(-3), [0,1]) # needs sage.rings.number_field + sage: w = WeierstrassIsomorphism(E, (CyclotomicField(3).gen(),0,0,0)) # needs sage.rings.number_field + sage: (w.dual() * w).rational_maps() # needs sage.rings.number_field (x, y) :: @@ -906,23 +909,24 @@ def __neg__(self): :: + sage: # needs sage.rings.number_field sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: E = EllipticCurve(K, [0,1]) # optional - sage.rings.number_field - sage: w = WeierstrassIsomorphism(E, (CyclotomicField(3).gen(),0,0,0)) # optional - sage.rings.number_field - sage: w.tuple() # optional - sage.rings.number_field + sage: K. = QuadraticField(-3) + sage: E = EllipticCurve(K, [0,1]) + sage: w = WeierstrassIsomorphism(E, (CyclotomicField(3).gen(),0,0,0)) + sage: w.tuple() (1/2*a - 1/2, 0, 0, 0) - sage: (-w).tuple() # optional - sage.rings.number_field + sage: (-w).tuple() (-1/2*a + 1/2, 0, 0, 0) - sage: (-w)^3 == -(w^3) # optional - sage.rings.number_field + sage: (-w)^3 == -(w^3) True :: sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism, identity_morphism - sage: E = EllipticCurve(QuadraticField(-1), [1,0]) # optional - sage.rings.number_field - sage: t = WeierstrassIsomorphism(E, (i,0,0,0)) # optional - sage.rings.number_field - sage: -t^2 == identity_morphism(E) # optional - sage.rings.number_field + sage: E = EllipticCurve(QuadraticField(-1), [1,0]) # needs sage.rings.number_field + sage: t = WeierstrassIsomorphism(E, (i,0,0,0)) # needs sage.rings.number_field + sage: -t^2 == identity_morphism(E) # needs sage.rings.number_field True """ a1,_,a3,_,_ = self._domain.a_invariants() @@ -943,8 +947,8 @@ def scaling_factor(self): EXAMPLES:: - sage: E = EllipticCurve(QQbar, [0,1]) # optional - sage.rings.number_field - sage: all(f.scaling_factor() == f.formal()[1] for f in E.automorphisms()) # optional - sage.rings.number_field + sage: E = EllipticCurve(QQbar, [0,1]) # needs sage.rings.number_field + sage: all(f.scaling_factor() == f.formal()[1] for f in E.automorphisms()) # needs sage.rings.number_field True ALGORITHM: The scaling factor equals the `u` component of diff --git a/src/sage/schemes/generic/algebraic_scheme.py b/src/sage/schemes/generic/algebraic_scheme.py index c1434b7c5b4..642578950aa 100644 --- a/src/sage/schemes/generic/algebraic_scheme.py +++ b/src/sage/schemes/generic/algebraic_scheme.py @@ -47,7 +47,7 @@ sage: V = A2.subscheme([x^2 + y^2 - 1]); V Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^2 + y^2 - 1 - sage: V.dimension() + sage: V.dimension() # needs sage.libs.singular 1 Here is a more complicated example in a projective space:: @@ -55,14 +55,14 @@ sage: P3 = ProjectiveSpace(3, QQ, 'x') sage: P3.inject_variables() Defining x0, x1, x2, x3 - sage: Q = matrix([[x0, x1, x2], [x1, x2, x3]]).minors(2); Q + sage: Q = matrix([[x0, x1, x2], [x1, x2, x3]]).minors(2); Q # needs sage.modules [-x1^2 + x0*x2, -x1*x2 + x0*x3, -x2^2 + x1*x3] - sage: twisted_cubic = P3.subscheme(Q); twisted_cubic + sage: twisted_cubic = P3.subscheme(Q); twisted_cubic # needs sage.libs.singular sage.modules Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: -x1^2 + x0*x2, -x1*x2 + x0*x3, -x2^2 + x1*x3 - sage: twisted_cubic.dimension() + sage: twisted_cubic.dimension() # needs sage.libs.singular sage.modules 1 Note that there are 3 equations in the 3-dimensional ambient space, @@ -72,13 +72,12 @@ Let us look at one affine patch, for example the one where `x_0=1` :: - sage: patch = twisted_cubic.affine_patch(0) - sage: patch + sage: patch = twisted_cubic.affine_patch(0); patch # needs sage.libs.singular sage.modules Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -x1^2 + x2, -x1*x2 + x3, -x2^2 + x1*x3 - sage: patch.embedding_morphism() + sage: patch.embedding_morphism() # needs sage.libs.singular sage.modules Scheme morphism: From: Closed subscheme of Affine Space of dimension 3 over Rational Field defined by: -x1^2 + x2, -x1*x2 + x3, -x2^2 + x1*x3 @@ -279,9 +278,9 @@ def is_projective(self): projective spaces. This is why this method returns ``False`` for toric varieties:: - sage: PP. = toric_varieties.P(3) + sage: PP. = toric_varieties.P(3) # needs sage.geometry.polyhedron sage: V = PP.subscheme(x^3 + y^3 + z^3 + w^3) - sage: V.is_projective() + sage: V.is_projective() # needs sage.geometry.polyhedron False """ return self.ambient_space().is_projective() @@ -319,9 +318,9 @@ def ambient_space(self): EXAMPLES:: - sage: A. = AffineSpace(2, GF(5)) # optional - sage.rings.finite_rings - sage: S = A.subscheme([]) # optional - sage.rings.finite_rings - sage: S.ambient_space() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(2, GF(5)) + sage: S = A.subscheme([]) + sage: S.ambient_space() Affine Space of dimension 2 over Finite Field of size 5 sage: P. = ProjectiveSpace(2, ZZ) @@ -381,15 +380,15 @@ def embedding_morphism(self): sage: A2. = AffineSpace(QQ, 2) sage: C = A2.subscheme(x^2 + y^2 - 1) - sage: C.embedding_morphism() + sage: C.embedding_morphism() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^2 + y^2 - 1 To: Affine Space of dimension 2 over Rational Field Defn: Defined on coordinates by sending (x, y) to (x, y) - sage: P1xP1. = toric_varieties.P1xP1() - sage: P1 = P1xP1.subscheme(x - y) - sage: P1.embedding_morphism() + sage: P1xP1. = toric_varieties.P1xP1() # needs sage.geometry.polyhedron + sage: P1 = P1xP1.subscheme(x - y) # needs sage.geometry.polyhedron sage.libs.singular + sage: P1.embedding_morphism() # needs sage.geometry.polyhedron sage.libs.singular Scheme morphism: From: Closed subscheme of 2-d CPR-Fano toric variety covered by 4 affine patches defined by: x - y @@ -402,8 +401,7 @@ def embedding_morphism(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: X = P2.subscheme((x^2-y^2)*z) sage: p = (1,1,0) - sage: nbhd = X.neighborhood(p) - sage: nbhd + sage: nbhd = X.neighborhood(p); nbhd Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -y^2*z - 2*y*z @@ -429,19 +427,18 @@ def embedding_morphism(self): A couple more examples:: - sage: patch1 = P1xP1.affine_patch(1) - sage: patch1 + sage: # needs sage.geometry.polyhedron + sage: patch1 = P1xP1.affine_patch(1); patch1 2-d affine toric variety - sage: patch1.embedding_morphism() + sage: patch1.embedding_morphism() # needs sage.libs.singular Scheme morphism: From: 2-d affine toric variety To: 2-d CPR-Fano toric variety covered by 4 affine patches Defn: Defined on coordinates by sending [y : u] to [1 : y : u : 1] - sage: subpatch = P1.affine_patch(1) - sage: subpatch + sage: subpatch = P1.affine_patch(1); subpatch # needs sage.libs.singular Closed subscheme of 2-d affine toric variety defined by: -y + 1 - sage: subpatch.embedding_morphism() + sage: subpatch.embedding_morphism() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of 2-d affine toric variety defined by: -y + 1 To: Closed subscheme of 2-d CPR-Fano toric variety covered @@ -506,9 +503,9 @@ def ngens(self): EXAMPLES:: - sage: A. = AffineSpace(2, GF(5)) # optional - sage.rings.finite_rings - sage: S = A.subscheme([]) # optional - sage.rings.finite_rings - sage: S.ngens() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(2, GF(5)) + sage: S = A.subscheme([]) + sage: S.ngens() 2 sage: P. = ProjectiveSpace(2, ZZ) sage: S = P.subscheme([x - y, x - z]) @@ -546,6 +543,7 @@ def _homset(self, *args, **kwds): EXAMPLES:: + sage: # needs sage.geometry.polyhedron sage: P1. = toric_varieties.P1() sage: type(P1.Hom(P1)) @@ -555,9 +553,9 @@ def _homset(self, *args, **kwds): :: - sage: P1xP1 = toric_varieties.P1xP1() - sage: P1 = toric_varieties.P1() - sage: P1xP1._homset(P1xP1, P1) + sage: P1xP1 = toric_varieties.P1xP1() # needs sage.geometry.polyhedron + sage: P1 = toric_varieties.P1() # needs sage.geometry.polyhedron + sage: P1xP1._homset(P1xP1, P1) # needs sage.geometry.polyhedron Set of morphisms From: 2-d CPR-Fano toric variety covered by 4 affine patches To: 1-d CPR-Fano toric variety covered by 2 affine patches @@ -778,17 +776,17 @@ def _check_satisfies_equations(self, v): ... TypeError: number of arguments does not match number of variables in parent - sage: A. = AffineSpace(2, GF(7)) # optional - sage.rings.finite_rings - sage: S = A.subscheme([x^2 - y]) # optional - sage.rings.finite_rings - sage: T = A.subscheme([x - y]) # optional - sage.rings.finite_rings - sage: U = T.complement(S) # optional - sage.rings.finite_rings - sage: U._check_satisfies_equations([2, 4]) # optional - sage.rings.finite_rings + sage: A. = AffineSpace(2, GF(7)) + sage: S = A.subscheme([x^2 - y]) + sage: T = A.subscheme([x - y]) + sage: U = T.complement(S) + sage: U._check_satisfies_equations([2, 4]) True - sage: U.point([2,4]) # optional - sage.rings.finite_rings + sage: U.point([2,4]) (2, 4) - sage: U._check_satisfies_equations(_) # optional - sage.rings.finite_rings + sage: U._check_satisfies_equations(_) True - sage: U._check_satisfies_equations([1, 1]) # optional - sage.rings.finite_rings + sage: U._check_satisfies_equations([1, 1]) Traceback (most recent call last): ... TypeError: Coordinates [1, 1] do not define a point on Quasi-affine @@ -797,7 +795,7 @@ def _check_satisfies_equations(self, v): x^2 - y and Y is defined by: x - y - sage: U._check_satisfies_equations([1, 0]) # optional - sage.rings.finite_rings + sage: U._check_satisfies_equations([1, 0]) Traceback (most recent call last): ... TypeError: Coordinates [1, 0] do not define a point on Quasi-affine @@ -845,13 +843,13 @@ def rational_points(self, **kwds): EXAMPLES:: - sage: A. = AffineSpace(2, GF(7)) # optional - sage.rings.finite_rings - sage: S = A.subscheme([x^2 - y]) # optional - sage.rings.finite_rings - sage: T = A.subscheme([x - y]) # optional - sage.rings.finite_rings - sage: U = T.complement(S) # optional - sage.rings.finite_rings - sage: U.rational_points() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(2, GF(7)) + sage: S = A.subscheme([x^2 - y]) + sage: T = A.subscheme([x - y]) + sage: U = T.complement(S) + sage: U.rational_points() [(2, 4), (3, 2), (4, 2), (5, 4), (6, 1)] - sage: U.rational_points(F=GF(7^2, 'b')) # optional - sage.rings.finite_rings + sage: U.rational_points(F=GF(7^2, 'b')) # needs sage.rings.finite_rings [(2, 4), (3, 2), (4, 2), (5, 4), (6, 1), (b, b + 4), (b + 1, 3*b + 5), (b + 2, 5*b + 1), (b + 3, 6), (b + 4, 2*b + 6), (b + 5, 4*b + 1), (b + 6, 6*b + 5), (2*b, 4*b + 2), (2*b + 1, b + 3), (2*b + 2, 5*b + 6), @@ -998,13 +996,13 @@ def base_extend(self, R): EXAMPLES:: - sage: P. = ProjectiveSpace(2, GF(11)) # optional - sage.rings.finite_rings - sage: S = P.subscheme([x^2 - y*z]) # optional - sage.rings.finite_rings - sage: S.base_extend(GF(11^2, 'b')) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(2, GF(11)) + sage: S = P.subscheme([x^2 - y*z]) + sage: S.base_extend(GF(11^2, 'b')) # needs sage.rings.finite_rings Closed subscheme of Projective Space of dimension 2 over Finite Field in b of size 11^2 defined by: x^2 - y*z - sage: S.base_extend(ZZ) # optional - sage.rings.finite_rings + sage: S.base_extend(ZZ) Traceback (most recent call last): ... ValueError: no natural map from the base ring (=Finite Field of size 11) @@ -1021,7 +1019,7 @@ def __richcmp__(self, other, op): sage: X = A.subscheme([x*y, z]) sage: X == A.subscheme([z, x*y]) True - sage: X == A.subscheme([x*y, z^2]) + sage: X == A.subscheme([x*y, z^2]) # needs sage.libs.singular False sage: B. = AffineSpace(3, QQ) sage: X == B.subscheme([u*v, t]) @@ -1040,19 +1038,17 @@ def _latex_(self): EXAMPLES:: - sage: P. = ProjectiveSpace(2, GF(11)) # optional - sage.rings.finite_rings - sage: S = P.subscheme([x^2 - y*z]) # optional - sage.rings.finite_rings - sage: S # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(2, GF(11)) + sage: S = P.subscheme([x^2 - y*z]); S Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: x^2 - y*z - sage: S._latex_() # optional - sage.rings.finite_rings + sage: S._latex_() '\\text{Closed subscheme of } {\\mathbf P}_{\\Bold{F}_{11}}^2 \\text{ defined by } x^{2} - y z' - sage: S = P.subscheme([x^2 - y*z, x^5]) # optional - sage.rings.finite_rings - sage: S # optional - sage.rings.finite_rings + sage: S = P.subscheme([x^2 - y*z, x^5]); S Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: x^2 - y*z, x^5 - sage: S._latex_() # optional - sage.rings.finite_rings + sage: S._latex_() '\\text{Closed subscheme of } {\\mathbf P}_{\\Bold{F}_{11}}^2 \\text{ defined by } x^{2} - y z, x^{5}' """ polynomials = ', '.join(latex(f) for f in self.defining_polynomials()) @@ -1067,19 +1063,17 @@ def _repr_(self): EXAMPLES:: - sage: P. = ProjectiveSpace(2, GF(11)) # optional - sage.rings.finite_rings - sage: S = P.subscheme([x^2 - y*z]) # optional - sage.rings.finite_rings - sage: S # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(2, GF(11)) + sage: S = P.subscheme([x^2 - y*z]); S Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: x^2 - y*z - sage: S._repr_() # optional - sage.rings.finite_rings + sage: S._repr_() 'Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by:\n x^2 - y*z' - sage: S = P.subscheme([x^2 - y*z, x^5]) # optional - sage.rings.finite_rings - sage: S # optional - sage.rings.finite_rings + sage: S = P.subscheme([x^2 - y*z, x^5]); S Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by: x^2 - y*z, x^5 - sage: S._repr_() # optional - sage.rings.finite_rings + sage: S._repr_() 'Closed subscheme of Projective Space of dimension 2 over Finite Field of size 11 defined by:\n x^2 - y*z,\n x^5' """ polynomials = ',\n '.join(str(f) for f in self.defining_polynomials()) @@ -1184,9 +1178,9 @@ def codimension(self): sage: PP. = ProjectiveSpace(4, QQ) sage: V = PP.subscheme(x*y) - sage: V.codimension() + sage: V.codimension() # needs sage.libs.singular 1 - sage: V.dimension() + sage: V.dimension() # needs sage.libs.singular 3 """ return self.ambient_space().dimension() - self.dimension() @@ -1209,8 +1203,8 @@ def irreducible_components(self): `\P^4_{\QQ}` then find the irreducible components:: sage: PP. = ProjectiveSpace(4, QQ) - sage: V = PP.subscheme((x^2 - y^2 - z^2) * (w^5 - 2*v^2*z^3) * w * (v^3 - x^2*z)) - sage: V.irreducible_components() + sage: V = PP.subscheme((x^2 - y^2 - z^2) * (w^5 - 2*v^2*z^3) * w * (v^3 - x^2*z)) + sage: V.irreducible_components() # needs sage.libs.singular [ Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: w, @@ -1230,7 +1224,7 @@ def irreducible_components(self): sage: R = f.parent() sage: I = [f] + [f.derivative(zz) for zz in PP.gens()] sage: V = PP.subscheme(I) - sage: V.irreducible_components() + sage: V.irreducible_components() # needs sage.libs.singular [ ] @@ -1241,7 +1235,7 @@ def irreducible_components(self): sage: AA. = AffineSpace(4, QQ) sage: V = AA.subscheme(I) - sage: V.irreducible_components() + sage: V.irreducible_components() # needs sage.libs.singular [ Closed subscheme of Affine Space of dimension 4 over Rational Field defined by: w, @@ -1281,27 +1275,28 @@ def is_irreducible(self): EXAMPLES:: - sage: K = QuadraticField(-3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 5) # optional - sage.rings.number_field - sage: X = P.subscheme([x*y - z^2 - K.0*t^2, t*w*x + y*z^2 - u^3]) # optional - sage.rings.number_field - sage: X.is_irreducible() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = QuadraticField(-3) + sage: P. = ProjectiveSpace(K, 5) + sage: X = P.subscheme([x*y - z^2 - K.0*t^2, t*w*x + y*z^2 - u^3]) + sage: X.is_irreducible() True :: sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme([(y + x - z)^2]) - sage: X.is_irreducible() + sage: X.is_irreducible() # needs sage.libs.singular False :: - sage: A. = AffineSpace(GF(17), 4) # optional - sage.rings.finite_rings - sage: X = A.subscheme([ # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(17), 4) + sage: X = A.subscheme([ ....: x*y*z^2 - x*y*z*w - z*w^2 + w^3, ....: x^3*y*z*w - x*y^3*z - x^2*y*z*w - x^2*w^3 + y^2*w^2 + x*w^3 ....: ]) - sage: X.is_irreducible() # optional - sage.rings.finite_rings + sage: X.is_irreducible() # needs sage.rings.finite_rings False """ return self.defining_ideal().is_prime() @@ -1318,8 +1313,9 @@ def Jacobian_matrix(self): EXAMPLES:: sage: P3. = ProjectiveSpace(3, QQ) - sage: twisted_cubic = P3.subscheme(matrix([[w, x, y], [x, y, z]]).minors(2)) - sage: twisted_cubic.Jacobian_matrix() + sage: twisted_cubic = P3.subscheme(matrix([[w, x, y], # needs sage.libs.singular + ....: [x, y, z]]).minors(2)) + sage: twisted_cubic.Jacobian_matrix() # needs sage.libs.singular [ y -2*x w 0] [ z -y -x w] [ 0 z -2*y x] @@ -1327,7 +1323,7 @@ def Jacobian_matrix(self): This example addresses issue :trac:`20512`:: sage: X = P3.subscheme([]) - sage: X.Jacobian_matrix().base_ring() == P3.coordinate_ring() + sage: X.Jacobian_matrix().base_ring() == P3.coordinate_ring() # needs sage.libs.singular True """ R = self.ambient_space().coordinate_ring() @@ -1357,20 +1353,21 @@ def Jacobian(self): EXAMPLES:: sage: P3. = ProjectiveSpace(3, QQ) - sage: twisted_cubic = P3.subscheme(matrix([[w, x, y], [x, y, z]]).minors(2)) - sage: twisted_cubic.Jacobian() + sage: twisted_cubic = P3.subscheme(matrix([[w, x, y], # needs sage.libs.singular + ....: [x, y, z]]).minors(2)) + sage: twisted_cubic.Jacobian() # needs sage.libs.singular Ideal (-x^2 + w*y, -x*y + w*z, -y^2 + x*z, x*z, -2*w*z, w*y, 3*w*y, -2*w*x, w^2, y*z, -2*x*z, w*z, 3*w*z, -2*w*y, w*x, z^2, -2*y*z, x*z, 3*x*z, -2*w*z, w*y) of Multivariate Polynomial Ring in w, x, y, z over Rational Field - sage: twisted_cubic.defining_ideal() + sage: twisted_cubic.defining_ideal() # needs sage.libs.singular Ideal (-x^2 + w*y, -x*y + w*z, -y^2 + x*z) of Multivariate Polynomial Ring in w, x, y, z over Rational Field This example addresses issue :trac:`20512`:: sage: X = P3.subscheme([]) - sage: X.Jacobian() == P3.coordinate_ring().unit_ideal() + sage: X.Jacobian() == P3.coordinate_ring().unit_ideal() # needs sage.libs.singular True """ d = self.codimension() @@ -1392,18 +1389,19 @@ def reduce(self): Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^5 - 3*x^4*y + 3*x^3*y^2 - x^2*y^3 - 2*x^4 + 6*x^3*y - 6*x^2*y^2 + 2*x*y^3 + x^3 - 3*x^2*y + 3*x*y^2 - y^3 - sage: X.dimension() + sage: X.dimension() # needs sage.libs.singular 1 Then we compute the corresponding reduced scheme:: - sage: Y = X.reduce(); Y + sage: Y = X.reduce(); Y # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^2 - x*y - x + y Finally, we verify that the reduced scheme `Y` is the union of those two lines:: + sage: # needs sage.libs.singular sage: L1 = A.subscheme([x - 1]); L1 Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x - 1 @@ -1440,28 +1438,28 @@ def union(self, other): sage: I = ideal([x, y])^3 sage: P = A.subscheme(I) sage: L = A.subscheme([y - 1]) - sage: S = L.union(P); S + sage: S = L.union(P); S # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: y^4 - y^3, x*y^3 - x*y^2, x^2*y^2 - x^2*y, x^3*y - x^3 - sage: S.dimension() + sage: S.dimension() # needs sage.libs.singular 1 - sage: S.reduce() + sage: S.reduce() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: y^2 - y, x*y - x We can also use the notation "+" for the union:: - sage: A.subscheme([x]) + A.subscheme([y^2 - (x^3+1)]) + sage: A.subscheme([x]) + A.subscheme([y^2 - (x^3+1)]) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x^4 - x*y^2 + x Saving and loading:: - sage: loads(S.dumps()) == S + sage: loads(S.dumps()) == S # needs sage.libs.singular True """ if not isinstance(other, AlgebraicScheme_subscheme): @@ -1515,8 +1513,8 @@ def __pow__(self, m): -x1*x3 + x0*x4, -x7*x9 + x6*x10 - sage: E = EllipticCurve([0,0,0,0,1]) - sage: E^2 + sage: E = EllipticCurve([0,0,0,0,1]) # needs sage.schemes + sage: E^2 # needs sage.schemes Closed subscheme of Product of projective spaces P^2 x P^2 over Rational Field defined by: -x0^3 + x1^2*x2 - x2^3, @@ -1766,18 +1764,19 @@ def rational_points(self, **kwds): Enumerate over a projective scheme over a number field:: + sage: # needs sage.rings.number_field sage: u = QQ['u'].0 - sage: K. = NumberField(u^2 + 3) # optional - sage.rings.number_field - sage: A. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: X = A.subscheme(x^2 - y^2) # optional - sage.rings.number_field - sage: X.rational_points(bound=3) # optional - sage.rings.number_field + sage: K. = NumberField(u^2 + 3) + sage: A. = ProjectiveSpace(K, 1) + sage: X = A.subscheme(x^2 - y^2) + sage: X.rational_points(bound=3) [(-1 : 1), (1 : 1)] One can enumerate points up to a given bound on a projective scheme over the rationals:: - sage: E = EllipticCurve('37a') - sage: E.rational_points(bound=8) + sage: E = EllipticCurve('37a') # needs sage.schemes + sage: E.rational_points(bound=8) # needs sage.schemes [(-1 : -1 : 1), (-1 : 0 : 1), (0 : -1 : 1), (0 : 0 : 1), (0 : 1 : 0), (1/4 : -5/8 : 1), (1/4 : -3/8 : 1), (1 : -1 : 1), (1 : 0 : 1), (2 : -3 : 1), (2 : 2 : 1)] @@ -1785,36 +1784,38 @@ def rational_points(self, **kwds): For a small finite field, the complete set of points can be enumerated. :: - sage: Etilde = E.base_extend(GF(3)) # optional - sage.rings.finite_rings - sage: Etilde.rational_points() # optional - sage.rings.finite_rings + sage: Etilde = E.base_extend(GF(3)) # needs sage.schemes + sage: Etilde.rational_points() # needs sage.schemes [(0 : 0 : 1), (0 : 1 : 0), (0 : 2 : 1), (1 : 0 : 1), (1 : 2 : 1), (2 : 0 : 1), (2 : 2 : 1)] The class of hyperelliptic curves does not (yet) support desingularization of the places at infinity into two points:: - sage: FF = FiniteField(7) # optional - sage.rings.finite_rings - sage: P. = PolynomialRing(FiniteField(7)) # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(x^8 + x + 1) # optional - sage.rings.finite_rings - sage: C.rational_points() # optional - sage.rings.finite_rings + sage: FF = FiniteField(7) + sage: P. = PolynomialRing(FiniteField(7)) + sage: C = HyperellipticCurve(x^8 + x + 1) # needs sage.schemes + sage: C.rational_points() # needs sage.schemes [(0 : 1 : 0), (0 : 1 : 1), (0 : 6 : 1), (2 : 0 : 1), (4 : 0 : 1), (6 : 1 : 1), (6 : 6 : 1)] :: - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 - v^2*x*z, y*x - v*z^2]) # optional - sage.rings.number_field - sage: X.rational_points(F=CC) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-3) + sage: P. = ProjectiveSpace(K, 2) + sage: X = P.subscheme([x^2 - v^2*x*z, y*x - v*z^2]) + sage: X.rational_points(F=CC) [(-3.00000000000000 : -0.577350269189626*I : 1.00000000000000), (0.000000000000000 : 1.00000000000000 : 0.000000000000000)] :: - sage: K. = QuadraticField(3) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: X = A.subscheme([x^2 - v^2*y, y*x - v]) # optional - sage.rings.number_field - sage: X.rational_points(F=RR) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(3) + sage: A. = AffineSpace(K, 2) + sage: X = A.subscheme([x^2 - v^2*y, y*x - v]) + sage: X.rational_points(F=RR) [(1.73205080756888, 1.00000000000000)] .. TODO:: @@ -1859,31 +1860,33 @@ def change_ring(self, R): sage: P. = ProjectiveSpace(QQ, 1) sage: X = P.subscheme([3*x^2 - y^2]) sage: H = Hom(X, X) - sage: X.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: X.change_ring(GF(3)) Closed subscheme of Projective Space of dimension 1 over Finite Field of size 3 defined by: -y^2 :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(z^3 - 5) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: X = P.subscheme(x - w*y) # optional - sage.rings.number_field - sage: X.change_ring(L) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: R. = K[] + sage: L. = K.extension(z^3 - 5) + sage: P. = ProjectiveSpace(K, 1) + sage: X = P.subscheme(x - w*y) # needs sage.libs.singular + sage: X.change_ring(L) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Number Field in v with defining polynomial z^3 - 5 over its base field defined by: x + (-w)*y :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(z^3 - 5) # optional - sage.rings.number_field - sage: P. = AffineSpace(L, 3) # optional - sage.rings.number_field - sage: X = P.subscheme([x - w*y, z^2 - v*x]) # optional - sage.rings.number_field - sage: emb = L.embeddings(QQbar) # optional - sage.rings.number_field - sage: X.change_ring(emb[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: R. = K[] + sage: L. = K.extension(z^3 - 5) + sage: P. = AffineSpace(L, 3) + sage: X = P.subscheme([x - w*y, z^2 - v*x]) # needs sage.libs.singular + sage: emb = L.embeddings(QQbar) # needs sage.libs.singular + sage: X.change_ring(emb[0]) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Algebraic Field defined by: x + (-1.414213562373095? + 0.?e-16*I)*y, @@ -1891,13 +1894,14 @@ def change_ring(self, R): :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(z^3 - 5) # optional - sage.rings.number_field - sage: P. = AffineSpace(L, 3) # optional - sage.rings.number_field - sage: X = P.subscheme([x - w*y, z^2 - v*x]) # optional - sage.rings.number_field - sage: emb = L.embeddings(QQbar) # optional - sage.rings.number_field - sage: X.change_ring(emb[1]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: R. = K[] + sage: L. = K.extension(z^3 - 5) + sage: P. = AffineSpace(L, 3) + sage: X = P.subscheme([x - w*y, z^2 - v*x]) # needs sage.libs.singular + sage: emb = L.embeddings(QQbar) # needs sage.libs.singular + sage: X.change_ring(emb[1]) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Algebraic Field defined by: x + (-1.414213562373095? + 0.?e-16*I)*y, @@ -1905,48 +1909,52 @@ def change_ring(self, R): :: - sage: K. = QuadraticField(-3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: X = P.subscheme(x - w*y) # optional - sage.rings.number_field - sage: X.change_ring(CC) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-3) + sage: P. = ProjectiveSpace(K, 1) + sage: X = P.subscheme(x - w*y) # needs sage.libs.singular + sage: X.change_ring(CC) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Complex Field with 53 bits of precision defined by: x + (-1.73205080756888*I)*y :: - sage: K. = QuadraticField(3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: X = P.subscheme(x - w*y) # optional - sage.rings.number_field - sage: X.change_ring(RR) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(3) + sage: P. = ProjectiveSpace(K, 1) + sage: X = P.subscheme(x - w*y) # needs sage.libs.singular + sage: X.change_ring(RR) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Real Field with 53 bits of precision defined by: x - 1.73205080756888*y :: - sage: K. = CyclotomicField(7) # optional - sage.rings.number_field - sage: O = K.maximal_order() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(O, 1) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 + O(v)*y^2]) # optional - sage.rings.number_field - sage: X.change_ring(CC) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(7) + sage: O = K.maximal_order() + sage: P. = ProjectiveSpace(O, 1) + sage: X = P.subscheme([x^2 + O(v)*y^2]) # needs sage.libs.singular + sage: X.change_ring(CC) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Complex Field with 53 bits of precision defined by: x^2 + (0.623489801858734 + 0.781831482468030*I)*y^2 - sage: X.change_ring(K).change_ring(K.embeddings(QQbar)[3]) # optional - sage.rings.number_field + sage: X.change_ring(K).change_ring(K.embeddings(QQbar)[3]) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Algebraic Field defined by: x^2 + (-0.9009688679024191? - 0.4338837391175581?*I)*y^2 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: f = x^6 - 2 - sage: L. = NumberField(f, embedding=f.roots(CC)[2][0]) # optional - sage.rings.number_field - sage: A. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: H = Hom(A, A) # optional - sage.rings.number_field - sage: X = A.subscheme([b*x^2, y^2]) # optional - sage.rings.number_field - sage: X.change_ring(CC) # optional - sage.rings.number_field + sage: L. = NumberField(f, embedding=f.roots(CC)[2][0]) + sage: A. = AffineSpace(L, 2) + sage: H = Hom(A, A) + sage: X = A.subscheme([b*x^2, y^2]) # needs sage.libs.singular + sage: X.change_ring(CC) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Complex Field with 53 bits of precision defined by: (-0.561231024154687 - 0.972080648619833*I)*x^2, @@ -1992,25 +2000,26 @@ def weil_restriction(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^5 - 2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: L. = K.extension(x^2 + 1) # optional - sage.rings.number_field - sage: A. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: X = A.subscheme([y^2 - L(w)*x^3 - v]) # optional - sage.rings.number_field - sage: X.weil_restriction() # optional - sage.rings.number_field + sage: K. = NumberField(x^5 - 2) + sage: R. = K[] + sage: L. = K.extension(x^2 + 1) + sage: A. = AffineSpace(L, 2) + sage: X = A.subscheme([y^2 - L(w)*x^3 - v]) # needs sage.libs.singular + sage: X.weil_restriction() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 4 over Number Field in w with defining polynomial x^5 - 2 defined by: (-w)*z0^3 + (3*w)*z0*z1^2 + z2^2 - z3^2, (-3*w)*z0^2*z1 + w*z1^3 + 2*z2*z3 - 1 - sage: X.weil_restriction().ambient_space() is A.weil_restriction() # optional - sage.rings.number_field + sage: X.weil_restriction().ambient_space() is A.weil_restriction() # needs sage.libs.singular True :: - sage: A. = AffineSpace(GF(5^2, 't'), 3) # optional - sage.rings.finite_rings - sage: X = A.subscheme([y^2 - x*z, z^2 + 2*y]) # optional - sage.rings.finite_rings - sage: X.weil_restriction() # optional - sage.rings.finite_rings + sage: A. = AffineSpace(GF(5^2, 't'), 3) # needs sage.rings.finite_rings + sage: X = A.subscheme([y^2 - x*z, z^2 + 2*y]) # needs sage.libs.singular sage.rings.finite_rings + sage: X.weil_restriction() # needs sage.libs.singular sage.rings.finite_rings Closed subscheme of Affine Space of dimension 6 over Finite Field of size 5 defined by: z2^2 - 2*z3^2 - z0*z4 + 2*z1*z5, @@ -2068,8 +2077,9 @@ def specialization(self, D=None, phi=None): sage: P. = AffineSpace(S, 3) sage: X = P.subscheme([x^2 + a*c*y^2 - b*z^2]) sage: from sage.rings.polynomial.flatten import SpecializationMorphism - sage: phi = SpecializationMorphism(P.coordinate_ring(), dict({c: 2, a: 1})) - sage: X.specialization(phi=phi) + sage: phi = SpecializationMorphism(P.coordinate_ring(), + ....: dict({c: 2, a: 1})) + sage: X.specialization(phi=phi) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 3 over Univariate Polynomial Ring in b over Rational Field defined by: x^2 + 2*y^2 + (-b)*z^2 diff --git a/src/sage/schemes/generic/ambient_space.py b/src/sage/schemes/generic/ambient_space.py index 9b7b11feb74..d22ea07d149 100644 --- a/src/sage/schemes/generic/ambient_space.py +++ b/src/sage/schemes/generic/ambient_space.py @@ -148,7 +148,7 @@ def _validate(self, polynomials): sage: from sage.schemes.generic.ambient_space import AmbientSpace sage: A = AmbientSpace(3, ZZ) - sage: A._validate((x + 1, 1)) + sage: A._validate((x + 1, 1)) # needs sage.symbolic Traceback (most recent call last): ... NotImplementedError: ambient spaces must override "_validate" method! @@ -227,7 +227,7 @@ def base_extend(self, R): sage: P. = ProjectiveSpace(2, ZZ) sage: PQ = P.base_extend(QQ); PQ Projective Space of dimension 2 over Rational Field - sage: PQ.base_extend(GF(5)) # optional - sage.rings.finite_rings + sage: PQ.base_extend(GF(5)) Traceback (most recent call last): ... ValueError: no natural map from the base ring (=Rational Field) @@ -257,8 +257,8 @@ def ambient_space(self): sage: P.ambient_space() is P True - sage: A = AffineSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: A.ambient_space() # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(3)) + sage: A.ambient_space() Affine Space of dimension 2 over Finite Field of size 3 """ return self @@ -285,8 +285,8 @@ def identity_morphism(self): EXAMPLES:: - sage: A = AffineSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: A.identity_morphism() # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(3)) + sage: A.identity_morphism() Scheme endomorphism of Affine Space of dimension 2 over Finite Field of size 3 Defn: Identity map @@ -325,8 +325,8 @@ def gens(self): sage: AffineSpace(0, QQ).gens() () - sage: P. = ProjectiveSpace(2, GF(5)) # optional - sage.rings.finite_rings - sage: P.gens() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(2, GF(5)) + sage: P.gens() (x, y, z) """ return self.coordinate_ring().gens() diff --git a/src/sage/schemes/generic/divisor.py b/src/sage/schemes/generic/divisor.py index 9124b3cfb90..6a55c3e8ce7 100644 --- a/src/sage/schemes/generic/divisor.py +++ b/src/sage/schemes/generic/divisor.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.schemes """ Divisors on schemes @@ -13,22 +14,22 @@ EXAMPLES:: - sage: x,y,z = ProjectiveSpace(2, GF(5), names='x,y,z').gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2*z^7 - x^9 - x*z^8) # optional - sage.rings.finite_rings - sage: pts = C.rational_points(); pts # optional - sage.rings.finite_rings + sage: x,y,z = ProjectiveSpace(2, GF(5), names='x,y,z').gens() + sage: C = Curve(y^2*z^7 - x^9 - x*z^8) + sage: pts = C.rational_points(); pts [(0 : 0 : 1), (0 : 1 : 0), (2 : 2 : 1), (2 : 3 : 1), (3 : 1 : 1), (3 : 4 : 1)] - sage: D1 = C.divisor(pts[0])*3 # optional - sage.rings.finite_rings - sage: D2 = C.divisor(pts[1]) # optional - sage.rings.finite_rings - sage: D3 = 10*C.divisor(pts[5]) # optional - sage.rings.finite_rings - sage: D1.parent() is D2.parent() # optional - sage.rings.finite_rings + sage: D1 = C.divisor(pts[0])*3 + sage: D2 = C.divisor(pts[1]) + sage: D3 = 10*C.divisor(pts[5]) + sage: D1.parent() is D2.parent() True - sage: D = D1 - D2 + D3; D # optional - sage.rings.finite_rings + sage: D = D1 - D2 + D3; D 3*(x, y) - (x, z) + 10*(x + 2*z, y + z) - sage: D[1][0] # optional - sage.rings.finite_rings + sage: D[1][0] -1 - sage: D[1][1] # optional - sage.rings.finite_rings + sage: D[1][1] Ideal (x, z) of Multivariate Polynomial Ring in x, y, z over Finite Field of size 5 - sage: C.divisor([(3, pts[0]), (-1, pts[1]), (10, pts[5])]) # optional - sage.rings.finite_rings + sage: C.divisor([(3, pts[0]), (-1, pts[1]), (10, pts[5])]) 3*(x, y) - (x, z) + 10*(x + 2*z, y + z) """ #******************************************************************************* @@ -107,9 +108,9 @@ def is_Divisor(x): EXAMPLES:: sage: from sage.schemes.generic.divisor import is_Divisor - sage: x,y = AffineSpace(2, GF(5), names='xy').gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^9 - x) # optional - sage.rings.finite_rings - sage: is_Divisor(C.divisor([])) # optional - sage.rings.finite_rings + sage: x,y = AffineSpace(2, GF(5), names='xy').gens() + sage: C = Curve(y^2 - x^9 - x) + sage: is_Divisor(C.divisor([])) True sage: is_Divisor("Ceci n'est pas un diviseur") False @@ -223,13 +224,13 @@ def scheme(self): EXAMPLES:: - sage: A. = AffineSpace(2, GF(5)) # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^9 - x) # optional - sage.rings.finite_rings - sage: pts = C.rational_points(); pts # optional - sage.rings.finite_rings + sage: A. = AffineSpace(2, GF(5)) + sage: C = Curve(y^2 - x^9 - x) + sage: pts = C.rational_points(); pts [(0, 0), (2, 2), (2, 3), (3, 1), (3, 4)] - sage: D = C.divisor(pts[0])*3 - C.divisor(pts[1]); D # optional - sage.rings.finite_rings + sage: D = C.divisor(pts[0])*3 - C.divisor(pts[1]); D 3*(x, y) - (x - 2, y - 2) - sage: D.scheme() # optional - sage.rings.finite_rings + sage: D.scheme() Affine Plane Curve over Finite Field of size 5 defined by -x^9 + y^2 - x """ return self.parent().scheme() @@ -369,31 +370,31 @@ def support(self): EXAMPLES:: - sage: x,y = AffineSpace(2, GF(5), names='xy').gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^9 - x) # optional - sage.rings.finite_rings - sage: pts = C.rational_points(); pts # optional - sage.rings.finite_rings + sage: x,y = AffineSpace(2, GF(5), names='xy').gens() + sage: C = Curve(y^2 - x^9 - x) + sage: pts = C.rational_points(); pts [(0, 0), (2, 2), (2, 3), (3, 1), (3, 4)] - sage: D = C.divisor_group()([(3, pts[0]), (-1, pts[1])]); D # optional - sage.rings.finite_rings + sage: D = C.divisor_group()([(3, pts[0]), (-1, pts[1])]); D 3*(x, y) - (x - 2, y - 2) - sage: D.support() # optional - sage.rings.finite_rings + sage: D.support() [(0, 0), (2, 2)] TESTS: This checks that :trac:`10732` is fixed:: - sage: R. = GF(5)[] # optional - sage.rings.finite_rings - sage: C = Curve(x^7 + y^7 + z^7) # optional - sage.rings.finite_rings - sage: pts = C.rational_points() # optional - sage.rings.finite_rings - sage: D = C.divisor([(2, pts[0])]) # optional - sage.rings.finite_rings - sage: D.support() # optional - sage.rings.finite_rings + sage: R. = GF(5)[] + sage: C = Curve(x^7 + y^7 + z^7) + sage: pts = C.rational_points() + sage: D = C.divisor([(2, pts[0])]) + sage: D.support() [(0 : 4 : 1)] - sage: (D + D).support() # optional - sage.rings.finite_rings + sage: (D + D).support() [(0 : 4 : 1)] - sage: E = C.divisor([(-3, pts[1]), (1, pts[2])]) # optional - sage.rings.finite_rings - sage: (D - 2*E).support() # optional - sage.rings.finite_rings + sage: E = C.divisor([(-3, pts[1]), (1, pts[2])]) + sage: (D - 2*E).support() [(0 : 4 : 1), (1 : 2 : 1), (2 : 1 : 1)] - sage: (D - D).support() # optional - sage.rings.finite_rings + sage: (D - D).support() [] """ try: @@ -417,18 +418,18 @@ def coefficient(self, P): EXAMPLES:: - sage: x,y = AffineSpace(2, GF(5), names='xy').gens() # optional - sage.rings.finite_rings - sage: C = Curve(y^2 - x^9 - x) # optional - sage.rings.finite_rings - sage: pts = C.rational_points(); pts # optional - sage.rings.finite_rings + sage: x,y = AffineSpace(2, GF(5), names='xy').gens() + sage: C = Curve(y^2 - x^9 - x) + sage: pts = C.rational_points(); pts [(0, 0), (2, 2), (2, 3), (3, 1), (3, 4)] - sage: D = C.divisor(pts[0]) # optional - sage.rings.finite_rings - sage: D.coefficient(pts[0]) # optional - sage.rings.finite_rings + sage: D = C.divisor(pts[0]) + sage: D.coefficient(pts[0]) 1 - sage: D = C.divisor([(3, pts[0]), (-1, pts[1])]); D # optional - sage.rings.finite_rings + sage: D = C.divisor([(3, pts[0]), (-1, pts[1])]); D 3*(x, y) - (x - 2, y - 2) - sage: D.coefficient(pts[0]) # optional - sage.rings.finite_rings + sage: D.coefficient(pts[0]) 3 - sage: D.coefficient(pts[1]) # optional - sage.rings.finite_rings + sage: D.coefficient(pts[1]) -1 """ P = self.parent().scheme()(P) diff --git a/src/sage/schemes/generic/divisor_group.py b/src/sage/schemes/generic/divisor_group.py index dfcb699d457..5dfd66a1bb9 100644 --- a/src/sage/schemes/generic/divisor_group.py +++ b/src/sage/schemes/generic/divisor_group.py @@ -209,10 +209,10 @@ def _an_element_(self): EXAMPLES:: - sage: A. = AffineSpace(2, CC) - sage: C = Curve(y^2 - x^9 - x) + sage: A. = AffineSpace(2, CC) # needs sage.rings.real_mpfr + sage: C = Curve(y^2 - x^9 - x) # needs sage.rings.real_mpfr sage.schemes sage: from sage.schemes.generic.divisor_group import DivisorGroup - sage: DivisorGroup(C).an_element() # indirect test + sage: DivisorGroup(C).an_element() # indirect test # needs sage.rings.real_mpfr sage.schemes 0 """ return self._scheme.divisor([], base_ring=self.base_ring(), check=False, reduce=False) @@ -224,14 +224,14 @@ def base_extend(self, R): sage: from sage.schemes.generic.divisor_group import DivisorGroup sage: DivisorGroup(Spec(ZZ), ZZ).base_extend(QQ) Group of QQ-Divisors on Spectrum of Integer Ring - sage: DivisorGroup(Spec(ZZ), ZZ).base_extend(GF(7)) # optional - sage.rings.finite_rings + sage: DivisorGroup(Spec(ZZ), ZZ).base_extend(GF(7)) Group of (Finite Field of size 7)-Divisors on Spectrum of Integer Ring Divisor groups are unique:: - sage: A. = AffineSpace(2, CC) - sage: C = Curve(y^2 - x^9 - x) - sage: DivisorGroup(C, ZZ).base_extend(QQ) is DivisorGroup(C, QQ) + sage: A. = AffineSpace(2, CC) # needs sage.rings.real_mpfr + sage: C = Curve(y^2 - x^9 - x) # needs sage.rings.real_mpfr sage.schemes + sage: DivisorGroup(C, ZZ).base_extend(QQ) is DivisorGroup(C, QQ) # needs sage.rings.real_mpfr sage.schemes True """ if self.base_ring().has_coerce_map_from(R): @@ -251,15 +251,16 @@ def _element_constructor_(self, x, check=True, reduce=True): EXAMPLES:: + sage: # needs sage.rings.real_mpfr sage.schemes sage: A. = AffineSpace(2, CC) sage: C = Curve(y^2 - x^9 - x) - sage: DivZZ=C.divisor_group(ZZ) - sage: DivQQ=C.divisor_group(QQ) - sage: DivQQ( DivQQ.an_element() ) # indirect test + sage: DivZZ = C.divisor_group(ZZ) + sage: DivQQ = C.divisor_group(QQ) + sage: DivQQ(DivQQ.an_element()) # indirect test 0 - sage: DivZZ( DivZZ.an_element() ) # indirect test + sage: DivZZ(DivZZ.an_element()) # indirect test 0 - sage: DivQQ( DivZZ.an_element() ) # indirect test + sage: DivQQ(DivZZ.an_element()) # indirect test 0 """ if isinstance(x, Divisor_curve): diff --git a/src/sage/schemes/generic/homset.py b/src/sage/schemes/generic/homset.py index 5e88b3ceef5..5db57860f7d 100644 --- a/src/sage/schemes/generic/homset.py +++ b/src/sage/schemes/generic/homset.py @@ -473,8 +473,8 @@ def _coerce_map_from_(self, other): :: sage: P = ProjectiveSpace(QQ, 1, 'x') - sage: P2 = ProjectiveSpace(CC, 1, 'y') - sage: P2(CC)._coerce_map_from_(P(QQ)) + sage: P2 = ProjectiveSpace(CC, 1, 'y') # needs sage.rings.real_mpfr + sage: P2(CC)._coerce_map_from_(P(QQ)) # needs sage.rings.real_mpfr False :: @@ -484,13 +484,13 @@ def _coerce_map_from_(self, other): sage: L = A.subscheme([z, y + z]) sage: A(QQ)._coerce_map_from_(H(QQ)) True - sage: H(QQ)._coerce_map_from_(L(QQ)) + sage: H(QQ)._coerce_map_from_(L(QQ)) # needs sage.libs.singular True - sage: L(QQ).has_coerce_map_from(H(QQ)) + sage: L(QQ).has_coerce_map_from(H(QQ)) # needs sage.libs.singular False - sage: A(CC)._coerce_map_from_(H(QQ)) + sage: A(CC)._coerce_map_from_(H(QQ)) # needs sage.rings.real_mpfr True - sage: H(CC)._coerce_map_from_(L(RR)) + sage: H(CC)._coerce_map_from_(L(RR)) # needs sage.libs.singular sage.rings.real_mpfr True :: @@ -516,10 +516,10 @@ def _coerce_map_from_(self, other): :: sage: PS = ProjectiveSpace(ZZ, 1, 'x') - sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # optional - sage.rings.padics - sage: PS(ZZ).has_coerce_map_from(PS2(Zp(7))) # optional - sage.rings.padics + sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # needs sage.rings.padics + sage: PS(ZZ).has_coerce_map_from(PS2(Zp(7))) # needs sage.rings.padics False - sage: PS2(Zp(7)).has_coerce_map_from(PS(ZZ)) # optional - sage.rings.padics + sage: PS2(Zp(7)).has_coerce_map_from(PS(ZZ)) # needs sage.rings.padics True :: @@ -536,10 +536,11 @@ def _coerce_map_from_(self, other): :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: A. = AffineSpace(QQ, 3) # optional - sage.rings.number_field - sage: H = A.subscheme(z) # optional - sage.rings.number_field - sage: A(K).has_coerce_map_from(H(QQ)) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: A. = AffineSpace(QQ, 3) + sage: H = A.subscheme(z) + sage: A(K).has_coerce_map_from(H(QQ)) True TESTS:: @@ -552,8 +553,8 @@ def _coerce_map_from_(self, other): :: sage: A = AffineSpace(QQ, 1, 'x') - sage: AC = AffineSpace(CC, 1, 'x') - sage: A(3/2) == AC(3/2) + sage: AC = AffineSpace(CC, 1, 'x') # needs sage.rings.real_mpfr + sage: A(3/2) == AC(3/2) # needs sage.rings.real_mpfr True :: @@ -632,23 +633,24 @@ def _element_constructor_(self, *v, **kwds): EXAMPLES:: sage: A2 = AffineSpace(ZZ, 2) - sage: F = GF(3) # optional - sage.rings.finite_rings - sage: F_points = A2(F); type(F_points) # optional - sage.rings.finite_rings + sage: F = GF(3) + sage: F_points = A2(F); type(F_points) - sage: F_points([2,5]) # optional - sage.rings.finite_rings + sage: F_points([2,5]) (2, 2) - sage: P2 = ProjectiveSpace(GF(3), 2) # optional - sage.rings.finite_rings - sage: F. = GF(9, 'a') # optional - sage.rings.finite_rings - sage: F_points = P2(F) # optional - sage.rings.finite_rings - sage: type(F_points) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P2 = ProjectiveSpace(GF(3), 2) + sage: F. = GF(9, 'a') + sage: F_points = P2(F) + sage: type(F_points) - sage: F_points([4,2*a]) # optional - sage.rings.finite_rings + sage: F_points([4,2*a]) (1 : 2*a : 1) TESTS:: - sage: F_points._element_constructor_([4,2*a]) # optional - sage.rings.finite_rings + sage: F_points._element_constructor_([4,2*a]) # needs sage.rings.finite_rings (1 : 2*a : 1) """ if len(v) == 1: @@ -667,17 +669,16 @@ def extended_codomain(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: P2 = ProjectiveSpace(QQ, 2) sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + x - (3^3-3)) # optional - sage.rings.number_field - sage: K_points = P2(K); K_points # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + x - (3^3-3)) + sage: K_points = P2(K); K_points Set of rational points of Projective Space of dimension 2 over Number Field in a with defining polynomial x^2 + x - 24 - - sage: K_points.codomain() # optional - sage.rings.number_field + sage: K_points.codomain() Projective Space of dimension 2 over Rational Field - - sage: K_points.extended_codomain() # optional - sage.rings.number_field + sage: K_points.extended_codomain() Projective Space of dimension 2 over Number Field in a with defining polynomial x^2 + x - 24 """ @@ -736,11 +737,11 @@ def cardinality(self): EXAMPLES:: - sage: toric_varieties.P2().point_set().cardinality() + sage: toric_varieties.P2().point_set().cardinality() # needs sage.geometry.polyhedron +Infinity - sage: P2 = toric_varieties.P2(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: P2.point_set().cardinality() # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(3)) # needs sage.geometry.polyhedron + sage: P2.point_set().cardinality() # needs sage.geometry.polyhedron 13 """ if hasattr(self, 'is_finite') and not self.is_finite(): @@ -760,8 +761,8 @@ def list(self): EXAMPLES:: - sage: P1 = toric_varieties.P1(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: P1.point_set().list() # optional - sage.rings.finite_rings + sage: P1 = toric_varieties.P1(base_ring=GF(3)) # needs sage.geometry.polyhedron + sage: P1.point_set().list() # needs sage.geometry.polyhedron ([0 : 1], [1 : 0], [1 : 1], [1 : 2]) """ return tuple(self) diff --git a/src/sage/schemes/generic/hypersurface.py b/src/sage/schemes/generic/hypersurface.py index fa2326d43e5..9e3396cbbe8 100644 --- a/src/sage/schemes/generic/hypersurface.py +++ b/src/sage/schemes/generic/hypersurface.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.schemes r""" Hypersurfaces in affine and projective space diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py index 086c2960755..675cbc73f2e 100644 --- a/src/sage/schemes/generic/morphism.py +++ b/src/sage/schemes/generic/morphism.py @@ -513,9 +513,10 @@ def base_ring(self): :: - sage: E = EllipticCurve(GF((17,2)), [1,2,3,4,5]) # optional - sage.rings.finite_rings - sage: P = E.random_point() # optional - sage.rings.finite_rings - sage: P.base_ring() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: E = EllipticCurve(GF((17,2)), [1,2,3,4,5]) + sage: P = E.random_point() + sage: P.base_ring() Finite Field in z2 of size 17^2 """ return self.domain().base_ring() @@ -612,7 +613,7 @@ def glue_along_domains(self, other): OUTPUT: - Assuming that self and other are open immersions with the same + Assuming that ``self`` and ``other`` are open immersions with the same domain, return scheme obtained by gluing along the images. EXAMPLES: @@ -621,6 +622,7 @@ def glue_along_domains(self, other): `\mathrm{Spec}(\QQ)` by gluing two copies of `\mathbb{A}^1` minus a point:: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 2) sage: S. = R.quotient(x*y - 1) sage: Rx = PolynomialRing(QQ, 'x') @@ -634,14 +636,13 @@ def glue_along_domains(self, other): Now f1 and f2 have the same domain, which is a `\mathbb{A}^1` minus a point. We glue along the domain:: - sage: P1 = f1.glue_along_domains(f2) - sage: P1 + sage: # needs sage.libs.singular + sage: P1 = f1.glue_along_domains(f2); P1 Scheme obtained by gluing X and Y along U, where X: Spectrum of Univariate Polynomial Ring in x over Rational Field Y: Spectrum of Univariate Polynomial Ring in y over Rational Field U: Spectrum of Quotient of Multivariate Polynomial Ring in x, y over Rational Field by the ideal (x*y - 1) - sage: a, b = P1.gluing_maps() sage: a Affine Scheme morphism: @@ -972,7 +973,7 @@ class SchemeMorphism_polynomial(SchemeMorphism): Some checks are performed to make sure the given polynomials define a morphism:: - sage: f = H([exp(x),exp(y)]) + sage: f = H([exp(x),exp(y)]) # needs sage.symbolic Traceback (most recent call last): ... TypeError: polys (=[e^x, e^y]) must be elements of Multivariate @@ -1342,27 +1343,29 @@ def change_ring(self, R, check=True): TESTS:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = QuadraticField(2) - sage: K2. = NumberField(t**4 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQ, 1) # optional - sage.rings.number_field - sage: phi = K.embeddings(K2)[0] # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([x**2 + 3*y**2, y**2]) # optional - sage.rings.number_field - sage: f.change_ring(phi) # optional - sage.rings.number_field + sage: K2. = NumberField(t**4 - 2) + sage: P. = ProjectiveSpace(QQ, 1) + sage: phi = K.embeddings(K2)[0] + sage: f = DynamicalSystem_projective([x**2 + 3*y**2, y**2]) + sage: f.change_ring(phi) Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial t^4 - 2 Defn: Defined on coordinates by sending (x : y) to (x^2 + 3*y^2 : y^2) :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: K1. = NumberField(t^4 - 2) # optional - sage.rings.number_field - sage: K2. = NumberField(t^8 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: phi = K1.embeddings(K2)[0] # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2 + 3*y^2, y^2]) # optional - sage.rings.number_field - sage: f.change_ring(phi) # optional - sage.rings.number_field + sage: K. = QuadraticField(2) + sage: K1. = NumberField(t^4 - 2) + sage: K2. = NumberField(t^8 - 2) + sage: P. = ProjectiveSpace(K, 1) + sage: phi = K1.embeddings(K2)[0] + sage: f = DynamicalSystem_projective([x^2 + 3*y^2, y^2]) + sage: f.change_ring(phi) Traceback (most recent call last): ... ValueError: no canonical coercion of base ring of morphism to domain of embedding @@ -1373,7 +1376,7 @@ def change_ring(self, R, check=True): sage: P. = ProjectiveSpace(ZZ, 1) sage: H = Hom(P, P) sage: f = H([3*x^2, y^2]) - sage: f.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: f.change_ring(GF(3)) Scheme endomorphism of Projective Space of dimension 1 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y) to (0 : y^2) @@ -1382,7 +1385,7 @@ def change_ring(self, R, check=True): sage: P. = ProjectiveSpace(QQ, 2) sage: H = Hom(P, P) sage: f = H([5/2*x^3 + 3*x*y^2 - y^3, 3*z^3 + y*x^2, x^3 - z^3]) - sage: f.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: f.change_ring(GF(3)) Scheme endomorphism of Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y : z) to (x^3 - y^3 : x^2*y : x^3 - z^3) @@ -1393,7 +1396,7 @@ def change_ring(self, R, check=True): sage: X = P.subscheme([5*x^2 - y^2]) sage: H = Hom(X, X) sage: f = H([x, y]) - sage: f.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: f.change_ring(GF(3)) Scheme endomorphism of Closed subscheme of Projective Space of dimension 1 over Finite Field of size 3 defined by: -x^2 - y^2 Defn: Defined on coordinates by sending (x : y) to (x : y) @@ -1401,11 +1404,13 @@ def change_ring(self, R, check=True): Check that :trac:`16834` is fixed:: + sage: # needs sage.rings.real_mpfr sage: A. = AffineSpace(RR, 3) sage: h = Hom(A, A) sage: f = h([x^2 + 1.5, y^3, z^5 - 2.0]) sage: f.change_ring(CC) - Scheme endomorphism of Affine Space of dimension 3 over Complex Field with 53 bits of precision + Scheme endomorphism of Affine Space of dimension 3 over + Complex Field with 53 bits of precision Defn: Defined on coordinates by sending (x, y, z) to (x^2 + 1.50000000000000, y^3, z^5 - 2.00000000000000) @@ -1426,7 +1431,7 @@ def change_ring(self, R, check=True): sage: A. = AffineSpace(QQ, 2) sage: H = Hom(A, A) sage: f = H([3*x^2/y, y^2/x]) - sage: f.change_ring(RR) + sage: f.change_ring(RR) # needs sage.rings.real_mpfr Scheme endomorphism of Affine Space of dimension 2 over Real Field with 53 bits of precision Defn: Defined on coordinates by sending (x, y) to @@ -1434,18 +1439,19 @@ def change_ring(self, R, check=True): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^3 - x + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([x^2 + a*x*y + a^2*y^2, y^2]) # optional - sage.rings.number_field - sage: emb = K.embeddings(QQbar) # optional - sage.rings.number_field - sage: f.change_ring(emb[0]) # optional - sage.rings.number_field + sage: K. = NumberField(x^3 - x + 1) + sage: P. = ProjectiveSpace(K, 1) + sage: H = End(P) + sage: f = H([x^2 + a*x*y + a^2*y^2, y^2]) + sage: emb = K.embeddings(QQbar) + sage: f.change_ring(emb[0]) Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to (x^2 + (-1.324717957244746?)*x*y + 1.754877666246693?*y^2 : y^2) - sage: f.change_ring(emb[1]) # optional - sage.rings.number_field + sage: f.change_ring(emb[1]) Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to @@ -1454,11 +1460,12 @@ def change_ring(self, R, check=True): :: - sage: K. = QuadraticField(2, embedding=QQbar(sqrt(2))) # optional - sage.rings.number_field sage.symbolic - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field sage.symbolic - sage: H = End(P) # optional - sage.rings.number_field sage.symbolic - sage: f = H([x^2 + v*y^2, y^2]) # optional - sage.rings.number_field sage.symbolic - sage: f.change_ring(QQbar) # optional - sage.rings.number_field sage.symbolic + sage: # needs sage.rings.number_field sage.symbolic + sage: K. = QuadraticField(2, embedding=QQbar(sqrt(2))) + sage: P. = ProjectiveSpace(K, 1) + sage: H = End(P) + sage: f = H([x^2 + v*y^2, y^2]) + sage: f.change_ring(QQbar) Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to @@ -1466,14 +1473,15 @@ def change_ring(self, R, check=True): :: + sage: # needs sage.rings.number_field sage.symbolic sage: from sage.misc.verbose import set_verbose sage: set_verbose(-1) - sage: K. = QuadraticField(2, embedding=QQbar(-sqrt(2))) # optional - sage.rings.number_field sage.symbolic - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field sage.symbolic - sage: X = P.subscheme(x - y) # optional - sage.rings.number_field sage.symbolic - sage: H = End(X) # optional - sage.rings.number_field sage.symbolic - sage: f = H([6*x^2 + 2*x*y + 16*y^2, -w*x^2 - 4*x*y - 4*y^2]) # optional - sage.rings.number_field sage.symbolic - sage: f.change_ring(QQbar) # optional - sage.rings.number_field sage.symbolic + sage: K. = QuadraticField(2, embedding=QQbar(-sqrt(2))) + sage: P. = ProjectiveSpace(K, 1) + sage: X = P.subscheme(x - y) + sage: H = End(X) + sage: f = H([6*x^2 + 2*x*y + 16*y^2, -w*x^2 - 4*x*y - 4*y^2]) + sage: f.change_ring(QQbar) Scheme endomorphism of Closed subscheme of Projective Space of dimension 1 over Algebraic Field defined by: x - y Defn: Defined on coordinates by sending (x : y) to @@ -1481,25 +1489,27 @@ def change_ring(self, R, check=True): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: f = x^6 - 2 - sage: L. = NumberField(f, embedding=f.roots(QQbar)[1][0]) # optional - sage.rings.number_field - sage: A. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: H = Hom(A, A) # optional - sage.rings.number_field - sage: F = H([b*x/y, 1 + y]) # optional - sage.rings.number_field - sage: F.change_ring(QQbar) # optional - sage.rings.number_field + sage: L. = NumberField(f, embedding=f.roots(QQbar)[1][0]) + sage: A. = AffineSpace(L, 2) + sage: H = Hom(A, A) + sage: F = H([b*x/y, 1 + y]) + sage: F.change_ring(QQbar) Scheme endomorphism of Affine Space of dimension 2 over Algebraic Field Defn: Defined on coordinates by sending (x, y) to (1.122462048309373?*x/y, y + 1) :: - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: A. = AffineSpace(K, 2) # optional - sage.rings.number_field - sage: H = End(A) # optional - sage.rings.number_field - sage: phi = H([x/y, y]) # optional - sage.rings.number_field - sage: emb = K.embeddings(QQbar)[0] # optional - sage.rings.number_field - sage: phi.change_ring(emb) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-1) + sage: A. = AffineSpace(K, 2) + sage: H = End(A) + sage: phi = H([x/y, y]) + sage: emb = K.embeddings(QQbar)[0] + sage: phi.change_ring(emb) Scheme endomorphism of Affine Space of dimension 2 over Algebraic Field Defn: Defined on coordinates by sending (x, y) to (x/y, y) """ @@ -1610,10 +1620,10 @@ def specialization(self, D=None, phi=None, homset=None): sage: R. = QQ[] sage: P. = ProjectiveSpace(R, 1) sage: f = DynamicalSystem_projective([x^2 + c*y^2, y^2], domain=P) - sage: F = f.dynatomic_polynomial(3) + sage: F = f.dynatomic_polynomial(3) # needs sage.libs.pari sage: g = F.specialization({c: 1}); g x^6 + x^5*y + 4*x^4*y^2 + 3*x^3*y^3 + 7*x^2*y^4 + 4*x*y^5 + 5*y^6 - sage: g == f.specialization({c:1}).dynatomic_polynomial(3) + sage: g == f.specialization({c:1}).dynatomic_polynomial(3) # needs sage.libs.pari True :: @@ -1716,15 +1726,16 @@ def _composition_(self, other, homset): Not both defined by polynomials:: + sage: # needs sage.rings.number_field sage: x = polygen(QQ) - sage: K. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: p1, p2 = K.Hom(K) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: q1 = R.Hom(R)(p1) # optional - sage.rings.number_field - sage: A = AffineSpace(R) # optional - sage.rings.number_field - sage: f1 = A.Hom(A)(q1) # optional - sage.rings.number_field - sage: g = A.Hom(A)([x^2 - y, y + 1]) # optional - sage.rings.number_field - sage: g*f1 # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 2) + sage: p1, p2 = K.Hom(K) + sage: R. = K[] + sage: q1 = R.Hom(R)(p1) + sage: A = AffineSpace(R) + sage: f1 = A.Hom(A)(q1) + sage: g = A.Hom(A)([x^2 - y, y + 1]) + sage: g*f1 Composite map: From: Affine Space of dimension 2 over Number Field in a with defining polynomial x^2 - 2 @@ -1764,8 +1775,8 @@ def __init__(self, X): TESTS:: - sage: A = AffineSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: A.identity_morphism().defining_polynomials() # optional - sage.rings.finite_rings + sage: A = AffineSpace(2, GF(3)) + sage: A.identity_morphism().defining_polynomials() (x0, x1) """ super().__init__(X) @@ -1969,29 +1980,30 @@ def change_ring(self, R, check=True): sage: P. = ProjectiveSpace(ZZ, 2) sage: X = P.subscheme(x^2 - y^2) - sage: X(23,23,1).change_ring(GF(13)) # optional - sage.rings.finite_rings + sage: X(23,23,1).change_ring(GF(13)) (10 : 10 : 1) :: sage: P. = ProjectiveSpace(QQ, 1) - sage: P(-2/3,1).change_ring(CC) + sage: P(-2/3,1).change_ring(CC) # needs sage.rings.real_mpfr (-0.666666666666667 : 1.00000000000000) :: sage: P. = ProjectiveSpace(ZZ, 1) - sage: P(152,113).change_ring(Zp(5)) # optional - sage.rings.padics + sage: P(152,113).change_ring(Zp(5)) # needs sage.rings.padics (2 + 5^2 + 5^3 + O(5^20) : 3 + 2*5 + 4*5^2 + O(5^20)) :: - sage: K. = QuadraticField(-7) # optional - sage.rings.number_field - sage: O = K.maximal_order() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(O, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: F = H([x^2 + O(v)*y^2, y^2]) # optional - sage.rings.number_field - sage: F.change_ring(K).change_ring(K.embeddings(QQbar)[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(-7) + sage: O = K.maximal_order() + sage: P. = ProjectiveSpace(O, 1) + sage: H = End(P) + sage: F = H([x^2 + O(v)*y^2, y^2]) + sage: F.change_ring(K).change_ring(K.embeddings(QQbar)[0]) Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to @@ -1999,32 +2011,35 @@ def change_ring(self, R, check=True): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 - x + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: Q = P([a + 1, 1]) # optional - sage.rings.number_field - sage: emb = K.embeddings(QQbar) # optional - sage.rings.number_field - sage: Q.change_ring(emb[0]) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - x + 1) + sage: P. = ProjectiveSpace(K, 1) + sage: Q = P([a + 1, 1]) + sage: emb = K.embeddings(QQbar) + sage: Q.change_ring(emb[0]) (1.5000000000000000? - 0.866025403784439?*I : 1) - sage: Q.change_ring(emb[1]) # optional - sage.rings.number_field + sage: Q.change_ring(emb[1]) (1.5000000000000000? + 0.866025403784439?*I : 1) :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: Q = P([v,1]) # optional - sage.rings.number_field - sage: Q.change_ring(K.embeddings(QQbar)[0]) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(2) + sage: P. = ProjectiveSpace(K, 1) + sage: Q = P([v,1]) + sage: Q.change_ring(K.embeddings(QQbar)[0]) (-1.414213562373095? : 1) :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: f = x^6 - 2 - sage: L. = NumberField(f, embedding=f.roots(QQbar)[1][0]) # optional - sage.rings.number_field - sage: A. = AffineSpace(L, 2) # optional - sage.rings.number_field - sage: P = A([b,1]) # optional - sage.rings.number_field - sage: P.change_ring(QQbar) # optional - sage.rings.number_field + sage: L. = NumberField(f, embedding=f.roots(QQbar)[1][0]) + sage: A. = AffineSpace(L, 2) + sage: P = A([b,1]) + sage: P.change_ring(QQbar) (1.122462048309373?, 1) """ S = self.codomain().change_ring(R) diff --git a/src/sage/schemes/generic/scheme.py b/src/sage/schemes/generic/scheme.py index 3b039697814..fe55bca9117 100644 --- a/src/sage/schemes/generic/scheme.py +++ b/src/sage/schemes/generic/scheme.py @@ -96,7 +96,7 @@ def __init__(self, X=None, category=None): sage: I = (x^2 - y^2)*R sage: RmodI = R.quotient(I) sage: X = Spec(RmodI) - sage: TestSuite(X).run() + sage: TestSuite(X).run() # needs sage.libs.singular """ from sage.schemes.generic.morphism import is_SchemeMorphism @@ -216,17 +216,17 @@ def __call__(self, *args): sage: A(QQ) Set of rational points of Affine Space of dimension 2 over Rational Field - sage: A(RR) + sage: A(RR) # needs sage.rings.real_mpfr Set of rational points of Affine Space of dimension 2 over Real Field with 53 bits of precision Space of dimension 2 over Rational Field:: sage: R. = PolynomialRing(QQ) - sage: A(NumberField(x^2 + 1, 'a')) # optional - sage.rings.number_field + sage: A(NumberField(x^2 + 1, 'a')) # needs sage.rings.number_field Set of rational points of Affine Space of dimension 2 over Number Field in a with defining polynomial x^2 + 1 - sage: A(GF(7)) # optional - sage.rings.finite_rings + sage: A(GF(7)) Traceback (most recent call last): ... ValueError: There must be a natural map S --> R, but @@ -285,14 +285,14 @@ def point_homset(self, S=None): Set of rational points of Projective Space of dimension 3 over Integer Ring sage: P.point_homset(QQ) Set of rational points of Projective Space of dimension 3 over Rational Field - sage: P.point_homset(GF(11)) # optional - sage.rings.finite_rings + sage: P.point_homset(GF(11)) Set of rational points of Projective Space of dimension 3 over Finite Field of size 11 TESTS:: sage: P = ProjectiveSpace(QQ, 3) - sage: P.point_homset(GF(11)) # optional - sage.rings.finite_rings + sage: P.point_homset(GF(11)) Traceback (most recent call last): ... ValueError: There must be a natural map S --> R, but @@ -326,8 +326,8 @@ def point(self, v, check=True): (4, 5) sage: R. = PolynomialRing(QQ) - sage: E = EllipticCurve([t + 1, t, t, 0, 0]) - sage: E.point([0, 0]) + sage: E = EllipticCurve([t + 1, t, t, 0, 0]) # needs sage.schemes + sage: E.point([0, 0]) # needs sage.schemes (0 : 0 : 1) """ # todo: update elliptic curve stuff to take point_homset as argument @@ -386,7 +386,7 @@ def __truediv__(self, Y): Affine Space of dimension 3 over Integer Ring sage: A/QQ Affine Space of dimension 3 over Rational Field - sage: A/GF(7) # optional - sage.rings.finite_rings + sage: A/GF(7) Affine Space of dimension 3 over Finite Field of size 7 """ return self.base_extend(Y) @@ -645,8 +645,8 @@ def _Hom_(self, Y, category=None, check=True): sage: S._Hom_(P).__class__ - sage: E = EllipticCurve('37a1') - sage: Hom(E, E).__class__ + sage: E = EllipticCurve('37a1') # needs sage.schemes + sage: Hom(E, E).__class__ # needs sage.schemes sage: Hom(Spec(ZZ), Spec(ZZ)).__class__ @@ -672,18 +672,19 @@ def count_points(self, n): EXAMPLES:: - sage: P. = PolynomialRing(GF(3)) # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(x^3 + x^2 + 1) # optional - sage.rings.finite_rings - sage: C.count_points(4) # optional - sage.rings.finite_rings + sage: # needs sage.schemes + sage: P. = PolynomialRing(GF(3)) + sage: C = HyperellipticCurve(x^3 + x^2 + 1) + sage: C.count_points(4) [6, 12, 18, 96] - sage: C.base_extend(GF(9,'a')).count_points(2) # optional - sage.rings.finite_rings + sage: C.base_extend(GF(9,'a')).count_points(2) # needs sage.rings.finite_rings [12, 96] :: - sage: P. = ProjectiveSpace(GF(4, 't'), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme([y^2*z - x^3 - z^3]) # optional - sage.rings.finite_rings - sage: X.count_points(2) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(4, 't'), 2) # needs sage.rings.finite_rings + sage: X = P.subscheme([y^2*z - x^3 - z^3]) # needs sage.rings.finite_rings + sage: X.count_points(2) # needs sage.rings.finite_rings [5, 17] """ F = self.base_ring() @@ -706,9 +707,9 @@ def zeta_function(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(4, 't'), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme([y^2*z - x^3 - z^3]) # optional - sage.rings.finite_rings - sage: X.zeta_function() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(4, 't'), 2) # needs sage.rings.finite_rings + sage: X = P.subscheme([y^2*z - x^3 - z^3]) # needs sage.rings.finite_rings + sage: X.zeta_function() # needs sage.rings.finite_rings Traceback (most recent call last): ... NotImplementedError @@ -734,12 +735,12 @@ def zeta_series(self, n, t): EXAMPLES:: - sage: P. = PolynomialRing(GF(3)) # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(x^3 + x^2 + 1) # optional - sage.rings.finite_rings + sage: P. = PolynomialRing(GF(3)) + sage: C = HyperellipticCurve(x^3 + x^2 + 1) # needs sage.schemes sage: R. = PowerSeriesRing(Integers()) - sage: C.zeta_series(4, t) # optional - sage.rings.finite_rings + sage: C.zeta_series(4, t) # needs sage.schemes 1 + 6*t + 24*t^2 + 78*t^3 + 240*t^4 + O(t^5) - sage: (1+2*t+3*t^2)/(1-t)/(1-3*t) + O(t^5) # optional - sage.rings.finite_rings + sage: (1+2*t+3*t^2)/(1-t)/(1-3*t) + O(t^5) 1 + 6*t + 24*t^2 + 78*t^3 + 240*t^4 + O(t^5) If the scheme has a method ``zeta_function``, this is used to @@ -749,23 +750,24 @@ def zeta_series(self, n, t): Nonetheless, since :trac:`15108` and :trac:`15148`, it supports hyperelliptic curves over non-prime fields:: - sage: C.base_extend(GF(9, 'a')).zeta_series(4, t) # optional - sage.rings.finite_rings + sage: C.base_extend(GF(9, 'a')).zeta_series(4, t) # needs sage.rings.finite_rings sage.schemes 1 + 12*t + 120*t^2 + 1092*t^3 + 9840*t^4 + O(t^5) :: - sage: P. = ProjectiveSpace(GF(4, 't'), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme([y^2*z - x^3 - z^3]) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(4, 't'), 2) # needs sage.rings.finite_rings + sage: X = P.subscheme([y^2*z - x^3 - z^3]) # needs sage.rings.finite_rings + sage: R. = PowerSeriesRing(Integers()) - sage: X.zeta_series(2, t) # optional - sage.rings.finite_rings + sage: X.zeta_series(2, t) # needs sage.libs.singular sage.rings.finite_rings 1 + 5*t + 21*t^2 + O(t^3) TESTS:: sage: P. = PolynomialRing(ZZ) - sage: C = HyperellipticCurve(x^3 + x + 1) + sage: C = HyperellipticCurve(x^3 + x + 1) # needs sage.schemes sage: R. = PowerSeriesRing(Integers()) - sage: C.zeta_series(4, t) + sage: C.zeta_series(4, t) # needs sage.schemes Traceback (most recent call last): ... TypeError: zeta functions only defined for schemes @@ -952,8 +954,9 @@ def __call__(self, *args): Point on Spectrum of Integer Ring defined by the Principal ideal (3) of Integer Ring sage: type(P) - sage: S(ZZ.ideal(next_prime(1000000))) - Point on Spectrum of Integer Ring defined by the Principal ideal (1000003) of Integer Ring + sage: S(ZZ.ideal(next_prime(1000000))) # needs sage.libs.pari + Point on Spectrum of Integer Ring + defined by the Principal ideal (1000003) of Integer Ring sage: R. = QQ[] sage: S = Spec(R) @@ -1203,8 +1206,8 @@ def hom(self, x, Y=None): sage: S. = QQ[] sage: A1. = AffineSpace(QQ, 1) - sage: A1_emb = Curve(p - 2) - sage: A1.hom([2, r], A1_emb) + sage: A1_emb = Curve(p - 2) # needs sage.schemes + sage: A1.hom([2, r], A1_emb) # needs sage.schemes Scheme morphism: From: Affine Space of dimension 1 over Rational Field To: Affine Plane Curve over Rational Field defined by p - 2 diff --git a/src/sage/schemes/generic/spec.py b/src/sage/schemes/generic/spec.py index 60f46664e31..c9a07313bb3 100644 --- a/src/sage/schemes/generic/spec.py +++ b/src/sage/schemes/generic/spec.py @@ -42,10 +42,10 @@ def Spec(R, S=None): Spectrum of Univariate Polynomial Ring in x over Rational Field sage: Spec(PolynomialRing(QQ, 'x', 3)) Spectrum of Multivariate Polynomial Ring in x0, x1, x2 over Rational Field - sage: X = Spec(PolynomialRing(GF(49,'a'), 3, 'x')); X # optional - sage.rings.finite_rings + sage: X = Spec(PolynomialRing(GF(49,'a'), 3, 'x')); X # needs sage.rings.finite_rings Spectrum of Multivariate Polynomial Ring in x0, x1, x2 over Finite Field in a of size 7^2 - sage: TestSuite(X).run() # optional - sage.rings.finite_rings + sage: TestSuite(X).run() # needs sage.rings.finite_rings Applying ``Spec`` twice to the same ring gives identical output (see :trac:`17008`):: @@ -60,7 +60,7 @@ def Spec(R, S=None): Traceback (most recent call last): ... TypeError: x (=5) is not in Category of commutative rings - sage: Spec(FreeAlgebra(QQ, 2, 'x')) + sage: Spec(FreeAlgebra(QQ, 2, 'x')) # needs sage.combinat sage.modules Traceback (most recent call last): ... TypeError: x (=Free Algebra on 2 generators (x0, x1) over Rational Field) @@ -152,7 +152,7 @@ def _apply_functor(self, A): sage: from sage.schemes.generic.spec import SpecFunctor sage: F = SpecFunctor() - sage: F(RR) # indirect doctest + sage: F(RR) # indirect doctest # needs sage.rings.real_mpfr Spectrum of Real Field with 53 bits of precision """ # The second argument of AffineScheme defaults to None. @@ -170,11 +170,11 @@ def _apply_functor_to_morphism(self, f): EXAMPLES:: sage: from sage.schemes.generic.spec import SpecFunctor - sage: F = SpecFunctor(GF(7)) # optional - sage.rings.finite_rings - sage: A. = GF(7)[] # optional - sage.rings.finite_rings - sage: B. = GF(7)[] # optional - sage.rings.finite_rings - sage: f = A.hom((t^2, t^3)) # optional - sage.rings.finite_rings - sage: Spec(f) # indirect doctest # optional - sage.rings.finite_rings + sage: F = SpecFunctor(GF(7)) + sage: A. = GF(7)[] + sage: B. = GF(7)[] + sage: f = A.hom((t^2, t^3)) + sage: Spec(f) # indirect doctest Affine Scheme morphism: From: Spectrum of Univariate Polynomial Ring in t over Finite Field of size 7 To: Spectrum of Multivariate Polynomial Ring in x, y over Finite Field of size 7 diff --git a/src/sage/schemes/hyperelliptic_curves/constructor.py b/src/sage/schemes/hyperelliptic_curves/constructor.py index 121da1bf072..de93cc7e371 100644 --- a/src/sage/schemes/hyperelliptic_curves/constructor.py +++ b/src/sage/schemes/hyperelliptic_curves/constructor.py @@ -74,41 +74,40 @@ def HyperellipticCurve(f, h=0, names=None, PP=None, check_squarefree=True): sage: HyperellipticCurve(x^19 + x + 1, x - 2) Hyperelliptic Curve over Rational Field defined by y^2 + (x - 2)*y = x^19 + x + 1 - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^3 + x - 1, x+a) # optional - sage.rings.finite_rings + sage: k. = GF(9); R. = k[] # needs sage.rings.finite_rings + sage: HyperellipticCurve(x^3 + x - 1, x+a) # needs sage.rings.finite_rings Hyperelliptic Curve over Finite Field in a of size 3^2 defined by y^2 + (x + a)*y = x^3 + x + 2 Characteristic two:: - sage: P. = GF(8, 'a')[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^7 + 1, x) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: P. = GF(8, 'a')[] + sage: HyperellipticCurve(x^7 + 1, x) Hyperelliptic Curve over Finite Field in a of size 2^3 defined by y^2 + x*y = x^7 + 1 - sage: HyperellipticCurve(x^8 + x^7 + 1, x^4 + 1) # optional - sage.rings.finite_rings + sage: HyperellipticCurve(x^8 + x^7 + 1, x^4 + 1) Hyperelliptic Curve over Finite Field in a of size 2^3 defined by y^2 + (x^4 + 1)*y = x^8 + x^7 + 1 - - sage: HyperellipticCurve(x^8 + 1, x) # optional - sage.rings.finite_rings + sage: HyperellipticCurve(x^8 + 1, x) Traceback (most recent call last): ... ValueError: Not a hyperelliptic curve: highly singular at infinity. - - sage: HyperellipticCurve(x^8 + x^7 + 1, x^4) # optional - sage.rings.finite_rings + sage: HyperellipticCurve(x^8 + x^7 + 1, x^4) Traceback (most recent call last): ... ValueError: Not a hyperelliptic curve: singularity in the provided affine patch. - sage: F. = PowerSeriesRing(FiniteField(2)) # optional - sage.rings.finite_rings - sage: P. = PolynomialRing(FractionField(F)) # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^5 + t, x) # optional - sage.rings.finite_rings + sage: F. = PowerSeriesRing(FiniteField(2)) + sage: P. = PolynomialRing(FractionField(F)) + sage: HyperellipticCurve(x^5 + t, x) Hyperelliptic Curve over Laurent Series Ring in t over Finite Field of size 2 defined by y^2 + x*y = x^5 + t We can change the names of the variables in the output:: - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^3 + x - 1, x + a, names=['X','Y']) # optional - sage.rings.finite_rings + sage: k. = GF(9); R. = k[] # needs sage.rings.finite_rings + sage: HyperellipticCurve(x^3 + x - 1, x + a, names=['X','Y']) # needs sage.rings.finite_rings Hyperelliptic Curve over Finite Field in a of size 3^2 defined by Y^2 + (X + a)*Y = X^3 + X + 2 @@ -125,13 +124,13 @@ def HyperellipticCurve(f, h=0, names=None, PP=None, check_squarefree=True): Double roots:: - sage: P. = GF(7)[] # optional - sage.rings.finite_rings + sage: P. = GF(7)[] sage: HyperellipticCurve((x^3-x+2)^2*(x^6-1)) Traceback (most recent call last): ... ValueError: Not a hyperelliptic curve: singularity in the provided affine patch. - sage: HyperellipticCurve((x^3-x+2)^2*(x^6-1), check_squarefree=False) # optional - sage.rings.finite_rings + sage: HyperellipticCurve((x^3-x+2)^2*(x^6-1), check_squarefree=False) Hyperelliptic Curve over Finite Field of size 7 defined by y^2 = x^12 + 5*x^10 + 4*x^9 + x^8 + 3*x^7 + 3*x^6 + 2*x^4 + 3*x^3 + 6*x^2 + 4*x + 3 @@ -156,9 +155,9 @@ def HyperellipticCurve(f, h=0, names=None, PP=None, check_squarefree=True): An example with a singularity over an inseparable extension of the base field:: - sage: F. = GF(5)[] # optional - sage.rings.finite_rings - sage: P. = F[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^5 + t) # optional - sage.rings.finite_rings + sage: F. = GF(5)[] + sage: P. = F[] + sage: HyperellipticCurve(x^5 + t) Traceback (most recent call last): ... ValueError: Not a hyperelliptic curve: singularity in the provided affine patch. @@ -182,17 +181,19 @@ def HyperellipticCurve(f, h=0, names=None, PP=None, check_squarefree=True): Check that two curves with the same class name have the same class type:: - sage: R. = PolynomialRing(GF(next_prime(10^9))) # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(t^5 + t + 1) # optional - sage.rings.finite_rings - sage: C2 = HyperellipticCurve(t^5 + 3*t + 1) # optional - sage.rings.finite_rings - sage: type(C2) == type(C) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = PolynomialRing(GF(next_prime(10^9))) + sage: C = HyperellipticCurve(t^5 + t + 1) + sage: C2 = HyperellipticCurve(t^5 + 3*t + 1) + sage: type(C2) == type(C) True Check that the inheritance is correct:: - sage: R. = PolynomialRing(GF(next_prime(10^9))) # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(t^5 + t + 1) # optional - sage.rings.finite_rings - sage: type(C).mro() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = PolynomialRing(GF(next_prime(10^9))) + sage: C = HyperellipticCurve(t^5 + t + 1) + sage: type(C).mro() [, , , diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py index ddb2cd61479..3d4af3e52c7 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Hyperelliptic curves over a finite field diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py index 19d767ea2f3..c9cca66eafc 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_g2.py @@ -95,13 +95,14 @@ def clebsch_invariants(self): TESTS:: - sage: magma(HyperellipticCurve(f)).ClebschInvariants() # optional - magma + sage: # optional - magma + sage: magma(HyperellipticCurve(f)).ClebschInvariants() [ 0, -2048/375, -4096/25, -4881645568/84375 ] - sage: magma(HyperellipticCurve(f(2*x))).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x))).ClebschInvariants() [ 0, -8388608/375, -1073741824/25, -5241627016305836032/84375 ] - sage: magma(HyperellipticCurve(f, x)).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f, x)).ClebschInvariants() [ -8/15, 17504/5625, -23162896/140625, -420832861216768/7119140625 ] - sage: magma(HyperellipticCurve(f(2*x), 2*x)).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x), 2*x)).ClebschInvariants() [ -512/15, 71696384/5625, -6072014209024/140625, -451865844002031331704832/7119140625 ] """ f, h = self.hyperelliptic_polynomials() @@ -131,13 +132,14 @@ def igusa_clebsch_invariants(self): TESTS:: - sage: magma(HyperellipticCurve(f)).IgusaClebschInvariants() # optional - magma + sage: # optional - magma + sage: magma(HyperellipticCurve(f)).IgusaClebschInvariants() [ -640, -20480, 1310720, 52160364544 ] - sage: magma(HyperellipticCurve(f(2*x))).IgusaClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x))).IgusaClebschInvariants() [ -40960, -83886080, 343597383680, 56006764965979488256 ] - sage: magma(HyperellipticCurve(f, x)).IgusaClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f, x)).IgusaClebschInvariants() [ -640, 17920, -1966656, 52409511936 ] - sage: magma(HyperellipticCurve(f(2*x), 2*x)).IgusaClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x), 2*x)).IgusaClebschInvariants() [ -40960, 73400320, -515547070464, 56274284941110411264 ] """ f, h = self.hyperelliptic_polynomials() @@ -203,13 +205,14 @@ def clebsch_invariants(self): TESTS:: - sage: magma(HyperellipticCurve(f)).ClebschInvariants() # optional - magma + sage: # optional - magma + sage: magma(HyperellipticCurve(f)).ClebschInvariants() [ 0, -2048/375, -4096/25, -4881645568/84375 ] - sage: magma(HyperellipticCurve(f(2*x))).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x))).ClebschInvariants() [ 0, -8388608/375, -1073741824/25, -5241627016305836032/84375 ] - sage: magma(HyperellipticCurve(f, x)).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f, x)).ClebschInvariants() [ -8/15, 17504/5625, -23162896/140625, -420832861216768/7119140625 ] - sage: magma(HyperellipticCurve(f(2*x), 2*x)).ClebschInvariants() # optional - magma + sage: magma(HyperellipticCurve(f(2*x), 2*x)).ClebschInvariants() [ -512/15, 71696384/5625, -6072014209024/140625, -451865844002031331704832/7119140625 ] """ f, h = self.hyperelliptic_polynomials() diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py index a56fee001cf..d12cbbc10f6 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py @@ -3,9 +3,9 @@ EXAMPLES:: - sage: P. = GF(5)[] # optional - sage.rings.finite_rings - sage: f = x^5 - 3*x^4 - 2*x^3 + 6*x^2 + 3*x - 1 # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(f); C # optional - sage.rings.finite_rings + sage: P. = GF(5)[] + sage: f = x^5 - 3*x^4 - 2*x^3 + 6*x^2 + 3*x - 1 + sage: C = HyperellipticCurve(f); C Hyperelliptic Curve over Finite Field of size 5 defined by y^2 = x^5 + 2*x^4 + 3*x^3 + x^2 + 3*x + 4 @@ -85,14 +85,14 @@ class HyperellipticCurve_generic(plane_curve.ProjectivePlaneCurve): sage: C0 = HyperellipticCurve(f0) sage: f1 = x^5 - x^3 + x - 22 sage: C1 = HyperellipticCurve(f1) - sage: Q. = GF(5)[] # optional - sage.rings.finite_rings - sage: f2 = y^5 - y^3 + y - 22 # optional - sage.rings.finite_rings - sage: C2 = HyperellipticCurve(f2) # optional - sage.rings.finite_rings + sage: Q. = GF(5)[] + sage: f2 = y^5 - y^3 + y - 22 + sage: C2 = HyperellipticCurve(f2) sage: hash(C0) == hash(C0) True sage: hash(C0) == hash(C1) False - sage: hash(C1) == hash(C2) # optional - sage.rings.finite_rings + sage: hash(C1) == hash(C2) False """ def __init__(self, PP, f, h=None, names=None, genus=None): @@ -126,20 +126,21 @@ def change_ring(self, R): EXAMPLES:: + sage: # needs sage.rings.padics sage: R. = QQ[] sage: H = HyperellipticCurve(x^5 - 10*x + 9) - sage: K = Qp(3, 5) # optional - sage.rings.padics - sage: L. = K.extension(x^30 - 3) # optional - sage.rings.padics - sage: HK = H.change_ring(K) # optional - sage.rings.padics - sage: HL = HK.change_ring(L); HL # optional - sage.rings.padics + sage: K = Qp(3, 5) + sage: L. = K.extension(x^30 - 3) + sage: HK = H.change_ring(K) + sage: HL = HK.change_ring(L); HL Hyperelliptic Curve over 3-adic Eisenstein Extension Field in a defined by x^30 - 3 defined by (1 + O(a^150))*y^2 = (1 + O(a^150))*x^5 + (2 + 2*a^30 + a^60 + 2*a^90 + 2*a^120 + O(a^150))*x + a^60 + O(a^210) - sage: R. = FiniteField(7)[] # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^8 + x + 5) # optional - sage.rings.finite_rings - sage: H.base_extend(FiniteField(7^2, 'a')) # optional - sage.rings.finite_rings + sage: R. = FiniteField(7)[] + sage: H = HyperellipticCurve(x^8 + x + 5) + sage: H.base_extend(FiniteField(7^2, 'a')) # needs sage.rings.finite_rings Hyperelliptic Curve over Finite Field in a of size 7^2 defined by y^2 = x^8 + x + 5 """ @@ -225,23 +226,24 @@ def is_smooth(self): EXAMPLES:: - sage: R. = GF(13)[] # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^8 + 1) # optional - sage.rings.finite_rings - sage: H.is_smooth() # optional - sage.rings.finite_rings + sage: R. = GF(13)[] + sage: H = HyperellipticCurve(x^8 + 1) + sage: H.is_smooth() True A hyperelliptic curve with genus at least 2 always has a singularity at infinity when viewed as a *plane* projective curve. This can be seen in the following example.:: - sage: R. = GF(27, 'a')[] # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^10 + 2) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: R. = GF(27, 'a')[] + sage: H = HyperellipticCurve(x^10 + 2) sage: from sage.misc.verbose import set_verbose sage: set_verbose(-1) - sage: H.is_smooth() # optional - sage.rings.finite_rings + sage: H.is_smooth() True sage: from sage.schemes.curves.projective_curve import ProjectivePlaneCurve - sage: ProjectivePlaneCurve.is_smooth(H) # optional - sage.rings.finite_rings + sage: ProjectivePlaneCurve.is_smooth(H) False """ return True @@ -291,14 +293,14 @@ def odd_degree_model(self): ... ValueError: No odd degree model exists over field of definition - sage: K2 = QuadraticField(-2, 'a') # optional - sage.rings.number_field - sage: Hp2 = H.change_ring(K2).odd_degree_model(); Hp2 # optional - sage.rings.number_field + sage: K2 = QuadraticField(-2, 'a') # needs sage.rings.number_field + sage: Hp2 = H.change_ring(K2).odd_degree_model(); Hp2 # needs sage.rings.number_field Hyperelliptic Curve over Number Field in a with defining polynomial x^2 + 2 with a = 1.414213562373095?*I defined by y^2 = 6*a*x^5 - 29*x^4 - 20*x^2 + 6*a*x + 1 - sage: K3 = QuadraticField(-3, 'b') # optional - sage.rings.number_field - sage: Hp3 = H.change_ring(QuadraticField(-3, 'b')).odd_degree_model(); Hp3 # optional - sage.rings.number_field + sage: K3 = QuadraticField(-3, 'b') # needs sage.rings.number_field + sage: Hp3 = H.change_ring(QuadraticField(-3, 'b')).odd_degree_model(); Hp3 # needs sage.rings.number_field Hyperelliptic Curve over Number Field in b with defining polynomial x^2 + 3 with b = 1.732050807568878?*I defined by y^2 = -4*b*x^5 - 14*x^4 - 20*b*x^3 - 35*x^2 + 6*b*x + 1 @@ -309,22 +311,26 @@ def odd_degree_model(self): points on their reductions. 43 and 67 split completely in the compositum, so when we reduce we find: - sage: P2 = K2.factor(43)[0][0] # optional - sage.rings.number_field - sage: P3 = K3.factor(43)[0][0] # optional - sage.rings.number_field - sage: Hp2.change_ring(K2.residue_field(P2)).frobenius_polynomial() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P2 = K2.factor(43)[0][0] + sage: P3 = K3.factor(43)[0][0] + sage: Hp2.change_ring(K2.residue_field(P2)).frobenius_polynomial() x^4 - 16*x^3 + 134*x^2 - 688*x + 1849 - sage: Hp3.change_ring(K3.residue_field(P3)).frobenius_polynomial() # optional - sage.rings.number_field + sage: Hp3.change_ring(K3.residue_field(P3)).frobenius_polynomial() x^4 - 16*x^3 + 134*x^2 - 688*x + 1849 - sage: H.change_ring(GF(43)).odd_degree_model().frobenius_polynomial() # optional - sage.rings.finite_rings + + sage: H.change_ring(GF(43)).odd_degree_model().frobenius_polynomial() # needs sage.rings.finite_rings x^4 - 16*x^3 + 134*x^2 - 688*x + 1849 - sage: P2 = K2.factor(67)[0][0] # optional - sage.rings.number_field - sage: P3 = K3.factor(67)[0][0] # optional - sage.rings.number_field - sage: Hp2.change_ring(K2.residue_field(P2)).frobenius_polynomial() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P2 = K2.factor(67)[0][0] + sage: P3 = K3.factor(67)[0][0] + sage: Hp2.change_ring(K2.residue_field(P2)).frobenius_polynomial() x^4 - 8*x^3 + 150*x^2 - 536*x + 4489 - sage: Hp3.change_ring(K3.residue_field(P3)).frobenius_polynomial() # optional - sage.rings.number_field + sage: Hp3.change_ring(K3.residue_field(P3)).frobenius_polynomial() x^4 - 8*x^3 + 150*x^2 - 536*x + 4489 - sage: H.change_ring(GF(67)).odd_degree_model().frobenius_polynomial() # optional - sage.rings.finite_rings + + sage: H.change_ring(GF(67)).odd_degree_model().frobenius_polynomial() # needs sage.rings.finite_rings x^4 - 8*x^3 + 150*x^2 - 536*x + 4489 TESTS:: @@ -382,17 +388,18 @@ def _magma_init_(self, magma): EXAMPLES:: + sage: # optional - magma sage: R. = QQ[]; C = HyperellipticCurve(x^3 + x - 1, x); C Hyperelliptic Curve over Rational Field defined by y^2 + x*y = x^3 + x - 1 - sage: magma(C) # optional - magma + sage: magma(C) Hyperelliptic Curve defined by y^2 + x*y = x^3 + x - 1 over Rational Field - sage: R. = GF(9,'a')[]; C = HyperellipticCurve(x^3 + x - 1, x^10); C # optional - sage.rings.finite_rings + sage: R. = GF(9,'a')[]; C = HyperellipticCurve(x^3 + x - 1, x^10); C # needs sage.rings.finite_rings Hyperelliptic Curve over Finite Field in a of size 3^2 defined by y^2 + x^10*y = x^3 + x + 2 - sage: D = magma(C); D # optional - magma # optional - sage.rings.finite_rings + sage: D = magma(C); D # needs sage.rings.finite_rings Hyperelliptic Curve defined by y^2 + (x^10)*y = x^3 + x + 2 over GF(3^2) - sage: D.sage() # optional - magma # optional - sage.rings.finite_rings + sage: D.sage() # needs sage.rings.finite_rings Hyperelliptic Curve over Finite Field in a of size 3^2 defined by y^2 + x^10*y = x^3 + x + 2 """ @@ -655,9 +662,9 @@ def rational_points(self, **kwds): An example over a number field:: - sage: R. = PolynomialRing(QuadraticField(2)) # optional - sage.rings.number_field - sage: C = HyperellipticCurve(R([1, 0, 0, 0, 0, 1])) # optional - sage.rings.number_field - sage: C.rational_points(bound=2) # optional - sage.rings.number_field + sage: R. = PolynomialRing(QuadraticField(2)) # needs sage.rings.number_field + sage: C = HyperellipticCurve(R([1, 0, 0, 0, 0, 1])) # needs sage.rings.number_field + sage: C.rational_points(bound=2) # needs sage.rings.number_field [(-1 : 0 : 1), (0 : -1 : 1), (0 : 1 : 0), diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py index 5111e08faf1..ad7428b1cb9 100644 --- a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py +++ b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.rings.padics """ Hyperelliptic curves over a `p`-adic field """ diff --git a/src/sage/schemes/hyperelliptic_curves/invariants.py b/src/sage/schemes/hyperelliptic_curves/invariants.py index 7db44ac03aa..05bffb5c113 100644 --- a/src/sage/schemes/hyperelliptic_curves/invariants.py +++ b/src/sage/schemes/hyperelliptic_curves/invariants.py @@ -175,8 +175,8 @@ def ubs(f): 'y2': 0, 'y3': 0} - sage: R. = GF(31)[] # optional - sage.rings.finite_rings - sage: ubs(t^6 + 2*t^5 + t^2 + 3*t + 1) # optional - sage.rings.finite_rings + sage: R. = GF(31)[] + sage: ubs(t^6 + 2*t^5 + t^2 + 3*t + 1) {'A': 0, 'B': -12, 'C': -15, @@ -219,11 +219,11 @@ def clebsch_to_igusa(A, B, C, D): sage: igusa_to_clebsch(*clebsch_to_igusa(2, 3, 4, 5)) (2, 3, 4, 5) - sage: Cs = tuple(map(GF(31), (2, 3, 4, 5))); Cs # optional - sage.rings.finite_rings + sage: Cs = tuple(map(GF(31), (2, 3, 4, 5))); Cs (2, 3, 4, 5) - sage: clebsch_to_igusa(*Cs) # optional - sage.rings.finite_rings + sage: clebsch_to_igusa(*Cs) (8, 10, 15, 26) - sage: igusa_to_clebsch(*clebsch_to_igusa(*Cs)) # optional - sage.rings.finite_rings + sage: igusa_to_clebsch(*clebsch_to_igusa(*Cs)) (2, 3, 4, 5) """ I2 = -120*A @@ -245,11 +245,11 @@ def igusa_to_clebsch(I2, I4, I6, I10): sage: clebsch_to_igusa(*igusa_to_clebsch(-2400, 173700, 23112000, -10309890600)) (-2400, 173700, 23112000, -10309890600) - sage: Is = tuple(map(GF(31), (-2400, 173700, 23112000, -10309890600))); Is # optional - sage.rings.finite_rings + sage: Is = tuple(map(GF(31), (-2400, 173700, 23112000, -10309890600))); Is (18, 7, 12, 27) - sage: igusa_to_clebsch(*Is) # optional - sage.rings.finite_rings + sage: igusa_to_clebsch(*Is) (20, 25, 25, 12) - sage: clebsch_to_igusa(*igusa_to_clebsch(*Is)) # optional - sage.rings.finite_rings + sage: clebsch_to_igusa(*igusa_to_clebsch(*Is)) (18, 7, 12, 27) """ A = -(+ I2) / 120 @@ -323,7 +323,7 @@ def igusa_clebsch_invariants(f): sage: igusa_clebsch_invariants(x^5 + a*x^4 + b*x^3 + c*x^2 + d*x + e)[0] 6*b^2 - 16*a*c + 40*d - sage: absolute_igusa_invariants_wamelen(GF(5)['x'](x^6 - 2*x)) # optional - sage.rings.finite_rings + sage: absolute_igusa_invariants_wamelen(GF(5)['x'](x^6 - 2*x)) Traceback (most recent call last): ... NotImplementedError: Invariants of binary sextics/genus 2 hyperelliptic curves @@ -358,7 +358,7 @@ def absolute_igusa_invariants_wamelen(f): TESTS:: - sage: absolute_igusa_invariants_wamelen(GF(3)['x'](x^5 - 2*x)) # optional - sage.rings.finite_rings + sage: absolute_igusa_invariants_wamelen(GF(3)['x'](x^5 - 2*x)) Traceback (most recent call last): ... NotImplementedError: Invariants of binary sextics/genus 2 hyperelliptic curves @@ -397,7 +397,7 @@ def absolute_igusa_invariants_kohel(f): TESTS:: - sage: absolute_igusa_invariants_kohel(GF(2)['x'](x^5 - x)) # optional - sage.rings.finite_rings + sage: absolute_igusa_invariants_kohel(GF(2)['x'](x^5 - x)) Traceback (most recent call last): ... NotImplementedError: Invariants of binary sextics/genus 2 hyperelliptic curves diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_generic.py b/src/sage/schemes/hyperelliptic_curves/jacobian_generic.py index ec04cfd8801..8e2df486769 100644 --- a/src/sage/schemes/hyperelliptic_curves/jacobian_generic.py +++ b/src/sage/schemes/hyperelliptic_curves/jacobian_generic.py @@ -23,21 +23,22 @@ class HyperellipticJacobian_generic(Jacobian_generic): """ EXAMPLES:: - sage: FF = FiniteField(2003) # optional - sage.rings.finite_rings - sage: R. = PolynomialRing(FF) # optional - sage.rings.finite_rings - sage: f = x**5 + 1184*x**3 + 1846*x**2 + 956*x + 560 # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(f) # optional - sage.rings.finite_rings - sage: J = C.jacobian() # optional - sage.rings.finite_rings - sage: a = x**2 + 376*x + 245; b = 1015*x + 1368 # optional - sage.rings.finite_rings - sage: X = J(FF) # optional - sage.rings.finite_rings - sage: D = X([a,b]) # optional - sage.rings.finite_rings - sage: D # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: FF = FiniteField(2003) + sage: R. = PolynomialRing(FF) + sage: f = x**5 + 1184*x**3 + 1846*x**2 + 956*x + 560 + sage: C = HyperellipticCurve(f) + sage: J = C.jacobian() + sage: a = x**2 + 376*x + 245; b = 1015*x + 1368 + sage: X = J(FF) + sage: D = X([a,b]) + sage: D (x^2 + 376*x + 245, y + 988*x + 635) - sage: J(0) # optional - sage.rings.finite_rings + sage: J(0) (1) - sage: D == J([a,b]) # optional - sage.rings.finite_rings + sage: D == J([a,b]) True - sage: D == D + J(0) # optional - sage.rings.finite_rings + sage: D == D + J(0) True An more extended example, demonstrating arithmetic in J(QQ) and @@ -47,19 +48,17 @@ class HyperellipticJacobian_generic(Jacobian_generic): sage: P. = PolynomialRing(QQ) sage: f = x^5 - x + 1; h = x - sage: C = HyperellipticCurve(f,h,'u,v') - sage: C + sage: C = HyperellipticCurve(f,h,'u,v'); C Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 - sage: PP = C.ambient_space() - sage: PP + sage: PP = C.ambient_space(); PP Projective Space of dimension 2 over Rational Field sage: C.defining_polynomial() -x0^5 + x0*x1*x2^3 + x1^2*x2^3 + x0*x2^4 - x2^5 sage: C(QQ) Set of rational points of Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 - sage: K. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: C(K) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 2) # needs sage.rings.number_field + sage: C(K) # needs sage.rings.number_field Set of rational points of Hyperelliptic Curve over Number Field in t with defining polynomial x^2 - 2 defined by v^2 + u*v = u^5 - u + 1 @@ -70,13 +69,15 @@ class HyperellipticJacobian_generic(Jacobian_generic): sage: C(0,1,1).parent() Set of rational points of Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 - sage: P1 = C(K)(P) # optional - sage.rings.number_field - sage: P2 = C(K)([2, 4*t - 1, 1]) # optional - sage.rings.number_field - sage: P3 = C(K)([-1/2, 1/8*(7*t+2), 1]) # optional - sage.rings.number_field - sage: P1, P2, P3 # optional - sage.rings.number_field + + sage: # needs sage.rings.number_field + sage: P1 = C(K)(P) + sage: P2 = C(K)([2, 4*t - 1, 1]) + sage: P3 = C(K)([-1/2, 1/8*(7*t+2), 1]) + sage: P1, P2, P3 ((0 : 1 : 1), (2 : 4*t - 1 : 1), (-1/2 : 7/8*t + 1/4 : 1)) - sage: J = C.jacobian() - sage: J + + sage: J = C.jacobian(); J Jacobian of Hyperelliptic Curve over Rational Field defined by v^2 + u*v = u^5 - u + 1 sage: Q = J(QQ)(P); Q @@ -88,54 +89,57 @@ class HyperellipticJacobian_generic(Jacobian_generic): (u^2, v + 1) (u, v + 1) (1) - sage: Q1 = J(K)(P1); print("%s -> %s"%( P1, Q1 )) # optional - sage.rings.number_field + + sage: # needs sage.rings.number_field + sage: Q1 = J(K)(P1); print("%s -> %s"%( P1, Q1 )) (0 : 1 : 1) -> (u, v - 1) - sage: Q2 = J(K)(P2); print("%s -> %s"%( P2, Q2 )) # optional - sage.rings.number_field + sage: Q2 = J(K)(P2); print("%s -> %s"%( P2, Q2 )) (2 : 4*t - 1 : 1) -> (u - 2, v - 4*t + 1) - sage: Q3 = J(K)(P3); print("%s -> %s"%( P3, Q3 )) # optional - sage.rings.number_field + sage: Q3 = J(K)(P3); print("%s -> %s"%( P3, Q3 )) (-1/2 : 7/8*t + 1/4 : 1) -> (u + 1/2, v - 7/8*t - 1/4) - sage: R. = PolynomialRing(K) # optional - sage.rings.number_field - sage: Q4 = J(K)([x^2 - t, R(1)]) # optional - sage.rings.number_field - sage: for i in range(4): Q4*i # optional - sage.rings.number_field + sage: R. = PolynomialRing(K) + sage: Q4 = J(K)([x^2 - t, R(1)]) + sage: for i in range(4): Q4*i (1) (u^2 - t, v - 1) (u^2 + (-3/4*t - 9/16)*u + 1/2*t + 1/4, v + (-1/32*t - 57/64)*u + 1/2*t + 9/16) (u^2 + (1352416/247009*t - 1636930/247009)*u - 1156544/247009*t + 1900544/247009, v + (-2326345442/122763473*t + 3233153137/122763473)*u + 2439343104/122763473*t - 3350862929/122763473) - sage: R2 = Q2*5; R2 # optional - sage.rings.number_field + sage: R2 = Q2*5; R2 (u^2 - 3789465233/116983808*u - 267915823/58491904, v + (-233827256513849/1789384327168*t + 1/2)*u - 15782925357447/894692163584*t) - sage: R3 = Q3*5; R3 # optional - sage.rings.number_field + sage: R3 = Q3*5; R3 (u^2 + 5663300808399913890623/14426454798950909645952*u - 26531814176395676231273/28852909597901819291904, v + (253155440321645614070860868199103/2450498420175733688903836378159104*t + 1/2)*u + 2427708505064902611513563431764311/4900996840351467377807672756318208*t) - sage: R4 = Q4*5; R4 # optional - sage.rings.number_field + sage: R4 = Q4*5; R4 (u^2 - 3789465233/116983808*u - 267915823/58491904, v + (233827256513849/1789384327168*t + 1/2)*u + 15782925357447/894692163584*t) Thus we find the following identity:: - sage: 5*Q2 + 5*Q4 # optional - sage.rings.number_field + sage: 5*Q2 + 5*Q4 # needs sage.rings.number_field (1) Moreover the following relation holds in the 5-torsion subgroup:: - sage: Q2 + Q4 == 2*Q1 # optional - sage.rings.number_field + sage: Q2 + Q4 == 2*Q1 # needs sage.rings.number_field True TESTS:: - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: J1 = HyperellipticCurve(x^3 + x - 1, x + a).jacobian() # optional - sage.rings.finite_rings - sage: FF = FiniteField(2003) # optional - sage.rings.finite_rings - sage: R. = PolynomialRing(FF) # optional - sage.rings.finite_rings - sage: f = x**5 + 1184*x**3 + 1846*x**2 + 956*x + 560 # optional - sage.rings.finite_rings - sage: J2 = HyperellipticCurve(f).jacobian() # optional - sage.rings.finite_rings - sage: J1 == J1 # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF(9); R. = k[] + sage: J1 = HyperellipticCurve(x^3 + x - 1, x + a).jacobian() + sage: FF = FiniteField(2003) + sage: R. = PolynomialRing(FF) + sage: f = x**5 + 1184*x**3 + 1846*x**2 + 956*x + 560 + sage: J2 = HyperellipticCurve(f).jacobian() + sage: J1 == J1 True - sage: J1 == J2 # optional - sage.rings.finite_rings + sage: J1 == J2 False """ def dimension(self): @@ -148,12 +152,13 @@ def dimension(self): EXAMPLES:: - sage: k. = GF(9); R. = k[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^3 + x - 1, x + a).jacobian().dimension() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: k. = GF(9); R. = k[] + sage: HyperellipticCurve(x^3 + x - 1, x + a).jacobian().dimension() 1 - sage: g = HyperellipticCurve(x^6 + x - 1, x + a).jacobian().dimension(); g # optional - sage.rings.finite_rings + sage: g = HyperellipticCurve(x^6 + x - 1, x + a).jacobian().dimension(); g 2 - sage: type(g) # optional - sage.rings.finite_rings + sage: type(g) <... 'sage.rings.integer.Integer'> """ return Integer(self.curve().genus()) diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py b/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py index f205b79b433..a5f4f63876c 100644 --- a/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py +++ b/src/sage/schemes/hyperelliptic_curves/jacobian_homset.py @@ -22,18 +22,18 @@ :: - sage: F. = GF(3) # optional - sage.rings.finite_rings - sage: R. = F[] # optional - sage.rings.finite_rings - sage: f = x^5 - 1 # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(f) # optional - sage.rings.finite_rings - sage: J = C.jacobian() # optional - sage.rings.finite_rings - sage: X = J(F) # optional - sage.rings.finite_rings - sage: a = x^2 - x + 1; b = -x + 1; c = x - 1; d = 0 # optional - sage.rings.finite_rings - sage: D1 = X([a,b]); D1 # optional - sage.rings.finite_rings + sage: F. = GF(3) + sage: R. = F[] + sage: f = x^5 - 1 + sage: C = HyperellipticCurve(f) + sage: J = C.jacobian() + sage: X = J(F) + sage: a = x^2 - x + 1; b = -x + 1; c = x - 1; d = 0 + sage: D1 = X([a,b]); D1 (x^2 + 2*x + 1, y + x + 2) - sage: D2 = X([c,d]); D2 # optional - sage.rings.finite_rings + sage: D2 = X([c,d]); D2 (x + 2, y) - sage: D1 + D2 # optional - sage.rings.finite_rings + sage: D1 + D2 (x^2 + 2*x + 2, y + 2*x + 1) """ # **************************************************************************** @@ -98,18 +98,18 @@ def __call__(self, P): :: - sage: F. = GF(3) # optional - sage.rings.finite_rings - sage: R. = F[] # optional - sage.rings.finite_rings - sage: f = x^5 - 1 # optional - sage.rings.finite_rings - sage: C = HyperellipticCurve(f) # optional - sage.rings.finite_rings - sage: J = C.jacobian() # optional - sage.rings.finite_rings - sage: X = J(F) # optional - sage.rings.finite_rings - sage: a = x^2 - x + 1; b = -x + 1; c = x - 1; d = 0 # optional - sage.rings.finite_rings - sage: D1 = X([a,b]); D1 # optional - sage.rings.finite_rings + sage: F. = GF(3) + sage: R. = F[] + sage: f = x^5 - 1 + sage: C = HyperellipticCurve(f) + sage: J = C.jacobian() + sage: X = J(F) + sage: a = x^2 - x + 1; b = -x + 1; c = x - 1; d = 0 + sage: D1 = X([a,b]); D1 (x^2 + 2*x + 1, y + x + 2) - sage: D2 = X([c,d]); D2 # optional - sage.rings.finite_rings + sage: D2 = X([c,d]); D2 (x + 2, y) - sage: D1 + D2 # optional - sage.rings.finite_rings + sage: D1 + D2 (x^2 + 2*x + 2, y + 2*x + 1) """ if isinstance(P, (Integer, int)) and P == 0: diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py b/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py index da1f8908a7a..8c94ad5e705 100644 --- a/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py +++ b/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py @@ -36,42 +36,42 @@ :: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x); H # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x); H Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x At this time, Jacobians of hyperelliptic curves are handled differently than elliptic curves:: - sage: J = H.jacobian(); J # optional - sage.rings.finite_rings + sage: J = H.jacobian(); J Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x - sage: J = J(J.base_ring()); J # optional - sage.rings.finite_rings + sage: J = J(J.base_ring()); J Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x Points on the Jacobian are represented by Mumford's polynomials. First we find a couple of points on the curve:: - sage: P1 = H.lift_x(2); P1 # optional - sage.rings.finite_rings + sage: P1 = H.lift_x(2); P1 (2 : 11 : 1) - sage: Q1 = H.lift_x(10); Q1 # optional - sage.rings.finite_rings + sage: Q1 = H.lift_x(10); Q1 (10 : 18 : 1) Observe that 2 and 10 are the roots of the polynomials in x, respectively:: - sage: P = J(P1); P # optional - sage.rings.finite_rings + sage: P = J(P1); P (x + 35, y + 26) - sage: Q = J(Q1); Q # optional - sage.rings.finite_rings + sage: Q = J(Q1); Q (x + 27, y + 19) :: - sage: P + Q # optional - sage.rings.finite_rings + sage: P + Q (x^2 + 25*x + 20, y + 13*x) - sage: (x^2 + 25*x + 20).roots(multiplicities=False) # optional - sage.rings.finite_rings + sage: (x^2 + 25*x + 20).roots(multiplicities=False) [10, 2] Frobenius satisfies @@ -85,24 +85,24 @@ :: - sage: 1904*P # optional - sage.rings.finite_rings + sage: 1904*P (1) - sage: 34*P == 0 # optional - sage.rings.finite_rings + sage: 34*P == 0 True - sage: 35*P == P # optional - sage.rings.finite_rings + sage: 35*P == P True - sage: 33*P == -P # optional - sage.rings.finite_rings + sage: 33*P == -P True :: - sage: Q*1904 # optional - sage.rings.finite_rings + sage: Q*1904 (1) - sage: Q*238 == 0 # optional - sage.rings.finite_rings + sage: Q*238 == 0 True - sage: Q*239 == Q # optional - sage.rings.finite_rings + sage: Q*239 == Q True - sage: Q*237 == -Q # optional - sage.rings.finite_rings + sage: Q*237 == -Q True """ @@ -230,22 +230,23 @@ def cantor_composition_simple(D1,D2,f,genus): :: - sage: F. = NumberField(x^2 - 2, 'a') # optional - sage.rings.number_field - sage: J = H.jacobian()(F); J # optional - sage.rings.number_field + sage: F. = NumberField(x^2 - 2, 'a') # needs sage.rings.number_field + sage: J = H.jacobian()(F); J # needs sage.rings.number_field Set of rational points of Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 - 2 defined by y^2 = x^5 + x :: - sage: P = J(H.lift_x(F(1))); P # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P = J(H.lift_x(F(1))); P (x - 1, y - a) - sage: Q = J(H.lift_x(F(0))); Q # optional - sage.rings.number_field + sage: Q = J(H.lift_x(F(0))); Q (x, y) - sage: 2*P + 2*Q # indirect doctest # optional - sage.rings.number_field + sage: 2*P + 2*Q # indirect doctest (x^2 - 2*x + 1, y - 3/2*a*x + 1/2*a) - sage: 2*(P + Q) # indirect doctest # optional - sage.rings.number_field + sage: 2*(P + Q) # indirect doctest (x^2 - 2*x + 1, y - 3/2*a*x + 1/2*a) - sage: 3*P # indirect doctest # optional - sage.rings.number_field + sage: 3*P # indirect doctest (x^2 - 25/32*x + 49/32, y - 45/256*a*x - 315/256*a) """ a1, b1 = D1 @@ -271,53 +272,55 @@ def cantor_composition(D1,D2,f,h,genus): r""" EXAMPLES:: - sage: F. = GF(7^2, 'a') # optional - sage.rings.finite_rings - sage: x = F['x'].gen() # optional - sage.rings.finite_rings - sage: f = x^7 + x^2 + a # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(f, 2*x); H # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(7^2, 'a') + sage: x = F['x'].gen() + sage: f = x^7 + x^2 + a + sage: H = HyperellipticCurve(f, 2*x); H Hyperelliptic Curve over Finite Field in a of size 7^2 defined by y^2 + 2*x*y = x^7 + x^2 + a - sage: J = H.jacobian()(F); J # optional - sage.rings.finite_rings + sage: J = H.jacobian()(F); J Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field in a of size 7^2 defined by y^2 + 2*x*y = x^7 + x^2 + a :: - sage: Q = J(H.lift_x(F(1))); Q # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(1))); Q # needs sage.rings.finite_rings (x + 6, y + 2*a + 2) - sage: 10*Q # indirect doctest # optional - sage.rings.finite_rings + sage: 10*Q # indirect doctest # needs sage.rings.finite_rings (x^3 + (3*a + 1)*x^2 + (2*a + 5)*x + a + 5, y + (4*a + 5)*x^2 + (a + 1)*x + 6*a + 3) - sage: 7*8297*Q # optional - sage.rings.finite_rings + sage: 7*8297*Q # needs sage.rings.finite_rings (1) :: - sage: Q = J(H.lift_x(F(a+1))); Q # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(a+1))); Q # needs sage.rings.finite_rings (x + 6*a + 6, y + 2*a) - sage: 7*8297*Q # indirect doctest # optional - sage.rings.finite_rings + sage: 7*8297*Q # indirect doctest # needs sage.rings.finite_rings (1) A test over a prime field: - sage: F = GF(next_prime(10^30)) # optional - sage.rings.finite_rings - sage: x = F['x'].gen() # optional - sage.rings.finite_rings - sage: f = x^7 + x^2 + 1 # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(f, 2*x); H # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(next_prime(10^30)) + sage: x = F['x'].gen() + sage: f = x^7 + x^2 + 1 + sage: H = HyperellipticCurve(f, 2*x); H Hyperelliptic Curve over Finite Field of size 1000000000000000000000000000057 defined by y^2 + 2*x*y = x^7 + x^2 + 1 - sage: J = H.jacobian()(F); J # optional - sage.rings.finite_rings + sage: J = H.jacobian()(F); J Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 1000000000000000000000000000057 defined by y^2 + 2*x*y = x^7 + x^2 + 1 - sage: Q = J(H.lift_x(F(1))); Q # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(1))); Q (x + 1000000000000000000000000000056, y + 1000000000000000000000000000056) - sage: 10*Q # indirect doctest # optional - sage.rings.finite_rings + sage: 10*Q # indirect doctest (x^3 + 150296037169838934997145567227*x^2 + 377701248971234560956743242408*x + 509456150352486043408603286615, y + 514451014495791237681619598519*x^2 + 875375621665039398768235387900*x + 861429240012590886251910326876) - sage: 7*8297*Q # optional - sage.rings.finite_rings + sage: 7*8297*Q (x^3 + 35410976139548567549919839063*x^2 + 26230404235226464545886889960*x + 681571430588959705539385624700, y + 999722365017286747841221441793*x^2 @@ -371,22 +374,22 @@ def __init__(self, parent, polys, check=True): EXAMPLES:: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(GF(37)); J # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) + sage: J = H.jacobian()(GF(37)); J Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x :: - sage: P1 = J(H.lift_x(2)); P1 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 = J(H.lift_x(2)); P1 # indirect doctest (x + 35, y + 26) - sage: P1.parent() # optional - sage.rings.finite_rings + sage: P1.parent() Set of rational points of Jacobian of Hyperelliptic Curve over Finite Field of size 37 defined by y^2 = x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x - sage: type(P1) # optional - sage.rings.finite_rings + sage: type(P1) """ SchemeMorphism.__init__(self, parent) @@ -408,15 +411,16 @@ def _printing_polys(self): TESTS:: - sage: F. = GF(7^2, 'a') # optional - sage.rings.finite_rings - sage: x = F['x'].gen() # optional - sage.rings.finite_rings - sage: f = x^7 + x^2 + a # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(f, 2*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(F) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(7^2, 'a') + sage: x = F['x'].gen() + sage: f = x^7 + x^2 + a + sage: H = HyperellipticCurve(f, 2*x) + sage: J = H.jacobian()(F) :: - sage: Q = J(H.lift_x(F(1))); Q # indirect doctest # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(1))); Q # indirect doctest # needs sage.rings.finite_rings (x + 6, y + 2*a + 2) """ a, b = self.__polys @@ -431,19 +435,20 @@ def _repr_(self): EXAMPLES:: - sage: F. = GF(7^2, 'a') # optional - sage.rings.finite_rings - sage: x = F['x'].gen() # optional - sage.rings.finite_rings - sage: f = x^7 + x^2 + a # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(f, 2*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(F) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(7^2, 'a') + sage: x = F['x'].gen() + sage: f = x^7 + x^2 + a + sage: H = HyperellipticCurve(f, 2*x) + sage: J = H.jacobian()(F) :: - sage: Q = J(0); Q # indirect doctest # optional - sage.rings.finite_rings + sage: Q = J(0); Q # indirect doctest # needs sage.rings.finite_rings (1) - sage: Q = J(H.lift_x(F(1))); Q # indirect doctest # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(1))); Q # indirect doctest # needs sage.rings.finite_rings (x + 6, y + 2*a + 2) - sage: Q + Q # indirect doctest # optional - sage.rings.finite_rings + sage: Q + Q # indirect doctest # needs sage.rings.finite_rings (x^2 + 5*x + 1, y + 3*a*x + 6*a + 2) """ if self.is_zero(): @@ -457,22 +462,23 @@ def _latex_(self): EXAMPLES:: - sage: F. = GF(7^2) # optional - sage.rings.finite_rings - sage: x = F['x'].gen() # optional - sage.rings.finite_rings - sage: f = x^7 + x^2 + alpha # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(f, 2*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(F) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(7^2) + sage: x = F['x'].gen() + sage: f = x^7 + x^2 + alpha + sage: H = HyperellipticCurve(f, 2*x) + sage: J = H.jacobian()(F) :: - sage: Q = J(0); print(latex(Q)) # indirect doctest # optional - sage.rings.finite_rings + sage: Q = J(0); print(latex(Q)) # indirect doctest # needs sage.rings.finite_rings \left(1\right) - sage: Q = J(H.lift_x(F(1))); print(latex(Q)) # indirect doctest # optional - sage.rings.finite_rings + sage: Q = J(H.lift_x(F(1))); print(latex(Q)) # indirect doctest # needs sage.rings.finite_rings \left(x + 6, y + 2 \alpha + 2\right) :: - sage: print(latex(Q + Q)) # optional - sage.rings.finite_rings + sage: print(latex(Q + Q)) # needs sage.rings.finite_rings \left(x^{2} + 5 x + 1, y + 3 \alpha x + 6 \alpha + 2\right) """ if self.is_zero(): @@ -497,16 +503,16 @@ def scheme(self): sage: x = QQ['x'].gen() sage: f = x^5 + x sage: H = HyperellipticCurve(f) - sage: F. = NumberField(x^2 - 2, 'a') # optional - sage.rings.number_field - sage: J = H.jacobian()(F); J # optional - sage.rings.number_field + sage: F. = NumberField(x^2 - 2, 'a') # needs sage.rings.number_field + sage: J = H.jacobian()(F); J # needs sage.rings.number_field Set of rational points of Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 - 2 defined by y^2 = x^5 + x :: - sage: P = J(H.lift_x(F(1))) # optional - sage.rings.number_field - sage: P.scheme() # optional - sage.rings.number_field + sage: P = J(H.lift_x(F(1))) # needs sage.rings.number_field + sage: P.scheme() # needs sage.rings.number_field Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^5 + x """ return self.codomain() @@ -521,16 +527,16 @@ def __list__(self): sage: x = QQ['x'].gen() sage: f = x^5 + x sage: H = HyperellipticCurve(f) - sage: F. = NumberField(x^2 - 2, 'a') # optional - sage.rings.number_field - sage: J = H.jacobian()(F); J # optional - sage.rings.number_field + sage: F. = NumberField(x^2 - 2, 'a') # needs sage.rings.number_field + sage: J = H.jacobian()(F); J # needs sage.rings.number_field Set of rational points of Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 - 2 defined by y^2 = x^5 + x :: - sage: P = J(H.lift_x(F(1))) # optional - sage.rings.number_field - sage: list(P) # indirect doctest # optional - sage.rings.number_field + sage: P = J(H.lift_x(F(1))) # needs sage.rings.number_field + sage: list(P) # indirect doctest # needs sage.rings.number_field [x - 1, a] """ return list(self.__polys) @@ -545,16 +551,16 @@ def __tuple__(self): sage: x = QQ['x'].gen() sage: f = x^5 + x sage: H = HyperellipticCurve(f) - sage: F. = NumberField(x^2 - 2, 'a') # optional - sage.rings.number_field - sage: J = H.jacobian()(F); J # optional - sage.rings.number_field + sage: F. = NumberField(x^2 - 2, 'a') # needs sage.rings.number_field + sage: J = H.jacobian()(F); J # needs sage.rings.number_field Set of rational points of Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 - 2 defined by y^2 = x^5 + x :: - sage: P = J(H.lift_x(F(1))) # optional - sage.rings.number_field - sage: tuple(P) # indirect doctest # optional - sage.rings.number_field + sage: P = J(H.lift_x(F(1))) # needs sage.rings.number_field + sage: tuple(P) # indirect doctest # needs sage.rings.number_field (x - 1, a) """ return tuple(self.__polys) @@ -569,22 +575,23 @@ def __getitem__(self, n): sage: x = QQ['x'].gen() sage: f = x^5 + x sage: H = HyperellipticCurve(f) - sage: F. = NumberField(x^2 - 2, 'a') # optional - sage.rings.number_field - sage: J = H.jacobian()(F); J # optional - sage.rings.number_field + sage: F. = NumberField(x^2 - 2, 'a') # needs sage.rings.number_field + sage: J = H.jacobian()(F); J # needs sage.rings.number_field Set of rational points of Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 - 2 defined by y^2 = x^5 + x :: - sage: P = J(H.lift_x(F(1))) # optional - sage.rings.number_field - sage: P[0] # indirect doctest # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P = J(H.lift_x(F(1))) + sage: P[0] # indirect doctest x - 1 - sage: P[1] # indirect doctest # optional - sage.rings.number_field + sage: P[1] # indirect doctest a - sage: P[-1] # indirect doctest # optional - sage.rings.number_field + sage: P[-1] # indirect doctest a - sage: P[:1] # indirect doctest # optional - sage.rings.number_field + sage: P[:1] # indirect doctest [x - 1] """ return list(self.__polys)[n] @@ -653,17 +660,17 @@ def __bool__(self): EXAMPLES:: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(GF(37)) # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) + sage: J = H.jacobian()(GF(37)) :: - sage: P1 = J(H.lift_x(2)); P1 # optional - sage.rings.finite_rings + sage: P1 = J(H.lift_x(2)); P1 (x + 35, y + 26) - sage: P1 == 0 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 == 0 # indirect doctest False - sage: P1 - P1 == 0 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 - P1 == 0 # indirect doctest True """ return self.__polys[0] != 1 @@ -674,43 +681,44 @@ def __neg__(self): EXAMPLES:: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(GF(37)) # optional - sage.rings.finite_rings - sage: P1 = J(H.lift_x(2)); P1 # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) + sage: J = H.jacobian()(GF(37)) + sage: P1 = J(H.lift_x(2)); P1 (x + 35, y + 26) - sage: - P1 # indirect doctest # optional - sage.rings.finite_rings + sage: - P1 # indirect doctest (x + 35, y + 11) - sage: P1 + (-P1) # indirect doctest # optional - sage.rings.finite_rings + sage: P1 + (-P1) # indirect doctest (1) :: - sage: H2 = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x, x) # optional - sage.rings.finite_rings - sage: J2 = H2.jacobian()(GF(37)) # optional - sage.rings.finite_rings - sage: P2 = J2(H2.lift_x(2)); P2 # optional - sage.rings.finite_rings + sage: H2 = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x, x) + sage: J2 = H2.jacobian()(GF(37)) + sage: P2 = J2(H2.lift_x(2)); P2 (x + 35, y + 15) - sage: - P2 # indirect doctest # optional - sage.rings.finite_rings + sage: - P2 # indirect doctest (x + 35, y + 24) - sage: P2 + (-P2) # indirect doctest # optional - sage.rings.finite_rings + sage: P2 + (-P2) # indirect doctest (1) TESTS: The following was fixed in :trac:`14264`:: + sage: # needs sage.rings.number_field sage: P. = QQ[] sage: f = x^5 - x + 1; h = x sage: C = HyperellipticCurve(f, h, 'u,v') sage: J = C.jacobian() - sage: K. = NumberField(x^2 - 2) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: Q = J(K)([x^2 - t, R(1)]) # optional - sage.rings.number_field - sage: Q # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 2) + sage: R. = K[] + sage: Q = J(K)([x^2 - t, R(1)]) + sage: Q (u^2 - t, v - 1) - sage: -Q # optional - sage.rings.number_field + sage: -Q (u^2 - t, v + u + 1) - sage: Q + (-Q) # indirect doctest # optional - sage.rings.number_field + sage: Q + (-Q) # indirect doctest (1) """ @@ -737,15 +745,15 @@ def _add_(self,other): EXAMPLES:: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(GF(37)) # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) + sage: J = H.jacobian()(GF(37)) :: - sage: P1 = J(H.lift_x(2)); P1 # optional - sage.rings.finite_rings + sage: P1 = J(H.lift_x(2)); P1 (x + 35, y + 26) - sage: P1 + P1 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 + P1 # indirect doctest (x^2 + 33*x + 4, y + 13*x) """ X = self.parent() @@ -768,30 +776,30 @@ def _sub_(self, other): EXAMPLES:: - sage: x = GF(37)['x'].gen() # optional - sage.rings.finite_rings - sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) # optional - sage.rings.finite_rings - sage: J = H.jacobian()(GF(37)) # optional - sage.rings.finite_rings + sage: x = GF(37)['x'].gen() + sage: H = HyperellipticCurve(x^5 + 12*x^4 + 13*x^3 + 15*x^2 + 33*x) + sage: J = H.jacobian()(GF(37)) :: - sage: P1 = J(H.lift_x(2)); P1 # optional - sage.rings.finite_rings + sage: P1 = J(H.lift_x(2)); P1 (x + 35, y + 26) - sage: P1 - P1 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 - P1 # indirect doctest (1) :: - sage: P2 = J(H.lift_x(4)); P2 # optional - sage.rings.finite_rings + sage: P2 = J(H.lift_x(4)); P2 (x + 33, y + 34) Observe that the `x`-coordinates are the same but the `y`-coordinates differ:: - sage: P1 - P2 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 - P2 # indirect doctest (x^2 + 31*x + 8, y + 7*x + 12) - sage: P1 + P2 # indirect doctest # optional - sage.rings.finite_rings + sage: P1 + P2 # indirect doctest (x^2 + 31*x + 8, y + 4*x + 18) - sage: (P1 - P2) - (P1 + P2) + 2*P2 # indirect doctest # optional - sage.rings.finite_rings + sage: (P1 - P2) - (P1 + P2) + 2*P2 # indirect doctest (1) """ return self + (-other) diff --git a/src/sage/schemes/hyperelliptic_curves/mestre.py b/src/sage/schemes/hyperelliptic_curves/mestre.py index 166681b32a1..b63b1d3a403 100644 --- a/src/sage/schemes/hyperelliptic_curves/mestre.py +++ b/src/sage/schemes/hyperelliptic_curves/mestre.py @@ -82,17 +82,17 @@ def HyperellipticCurve_from_invariants(i, reduced=True, precision=None, An example over a finite field:: - sage: H = HyperellipticCurve_from_invariants([GF(13)(1), 3, 7, 5]); H # optional - sage.rings.finite_rings + sage: H = HyperellipticCurve_from_invariants([GF(13)(1), 3, 7, 5]); H Hyperelliptic Curve over Finite Field of size 13 defined by ... - sage: H.igusa_clebsch_invariants() # optional - sage.rings.finite_rings + sage: H.igusa_clebsch_invariants() (4, 9, 6, 11) An example over a number field:: - sage: K = QuadraticField(353, 'a') # optional - sage.rings.number_field - sage: H = HyperellipticCurve_from_invariants([21, 225/64, 22941/512, 1], # optional - sage.rings.number_field + sage: K = QuadraticField(353, 'a') # needs sage.rings.number_field + sage: H = HyperellipticCurve_from_invariants([21, 225/64, 22941/512, 1], # needs sage.rings.number_field ....: reduced=false) - sage: f = K['x'](H.hyperelliptic_polynomials()[0]) # optional - sage.rings.number_field + sage: f = K['x'](H.hyperelliptic_polynomials()[0]) # needs sage.rings.number_field If the Mestre Conic defined by the Igusa-Clebsch invariants has no rational points, then there exists no hyperelliptic curve over the base field with @@ -123,13 +123,13 @@ def HyperellipticCurve_from_invariants(i, reduced=True, precision=None, different from 2, 3, and 5, so another algorithm will be needed for fields of those characteristics. See also :trac:`12200`:: - sage: P. = GF(3)[] # optional - sage.rings.finite_rings - sage: HyperellipticCurve(x^6 + x + 1).igusa_clebsch_invariants() # optional - sage.rings.finite_rings + sage: P. = GF(3)[] + sage: HyperellipticCurve(x^6 + x + 1).igusa_clebsch_invariants() Traceback (most recent call last): ... NotImplementedError: Invariants of binary sextics/genus 2 hyperelliptic curves not implemented in characteristics 2, 3, and 5 - sage: HyperellipticCurve_from_invariants([GF(5)(1), 1, 0, 1]) # optional - sage.rings.finite_rings + sage: HyperellipticCurve_from_invariants([GF(5)(1), 1, 0, 1]) Traceback (most recent call last): ... ZeroDivisionError: inverse of Mod(0, 5) does not exist @@ -249,9 +249,9 @@ def Mestre_conic(i, xyz=False, names='u,v,w'): Note that the algorithm works over number fields as well:: sage: x = polygen(ZZ, 'x') - sage: k = NumberField(x^2 - 41, 'a') # optional - sage.rings.number_field - sage: a = k.an_element() # optional - sage.rings.number_field - sage: Mestre_conic([1, 2 + a, a, 4 + a]) # optional - sage.rings.number_field + sage: k = NumberField(x^2 - 41, 'a') # needs sage.rings.number_field + sage: a = k.an_element() # needs sage.rings.number_field + sage: Mestre_conic([1, 2 + a, a, 4 + a]) # needs sage.rings.number_field Projective Conic Curve over Number Field in a with defining polynomial x^2 - 41 defined by (-801900000*a + 343845000)*u^2 + (855360000*a + 15795864000)*u*v + (312292800000*a + 1284808579200)*v^2 + (624585600000*a + 2569617158400)*u*w @@ -259,7 +259,7 @@ def Mestre_conic(i, xyz=False, names='u,v,w'): And over finite fields:: - sage: Mestre_conic([GF(7)(10), GF(7)(1), GF(7)(2), GF(7)(3)]) # optional - sage.rings.finite_rings + sage: Mestre_conic([GF(7)(10), GF(7)(1), GF(7)(2), GF(7)(3)]) Projective Conic Curve over Finite Field of size 7 defined by -2*u*v - v^2 - 2*u*w + 2*v*w - 3*w^2 diff --git a/src/sage/schemes/jacobians/abstract_jacobian.py b/src/sage/schemes/jacobians/abstract_jacobian.py index 08bee459739..17deb70832b 100644 --- a/src/sage/schemes/jacobians/abstract_jacobian.py +++ b/src/sage/schemes/jacobians/abstract_jacobian.py @@ -246,8 +246,8 @@ def base_extend(self, R): sage: Jac = H.jacobian(); Jac Jacobian of Hyperelliptic Curve over Rational Field defined by y^2 = x^3 - 10*x + 9 - sage: F. = QQ.extension(x^2 + 1) # optional - sage.rings.number_field - sage: Jac.base_extend(F) # optional - sage.rings.number_field + sage: F. = QQ.extension(x^2 + 1) # needs sage.rings.number_field + sage: Jac.base_extend(F) # needs sage.rings.number_field Jacobian of Hyperelliptic Curve over Number Field in a with defining polynomial x^2 + 1 defined by y^2 = x^3 - 10*x + 9 """ diff --git a/src/sage/schemes/plane_conics/con_field.py b/src/sage/schemes/plane_conics/con_field.py index fa813565f7a..3b4158f8d67 100644 --- a/src/sage/schemes/plane_conics/con_field.py +++ b/src/sage/schemes/plane_conics/con_field.py @@ -105,10 +105,10 @@ def base_extend(self, S): Projective Conic Curve over Rational Field defined by x^2 + y^2 + z^2 sage: c.has_rational_point() False - sage: d = c.base_extend(QuadraticField(-1, 'i')); d # optional - sage.rings.number_field + sage: d = c.base_extend(QuadraticField(-1, 'i')); d # needs sage.rings.number_field Projective Conic Curve over Number Field in i with defining polynomial x^2 + 1 with i = 1*I defined by x^2 + y^2 + z^2 - sage: d.rational_point(algorithm='rnfisnorm') # optional - sage.rings.number_field + sage: d.rational_point(algorithm='rnfisnorm') # needs sage.rings.number_field (i : 1 : 0) """ if S in _Fields: @@ -160,10 +160,10 @@ def coefficients(self): sage: Conic(QQ, [1,2,3,4,5,6]).coefficients() [1, 2, 3, 4, 5, 6] - sage: P. = GF(13)[] # optional - sage.rings.finite_rings - sage: a = Conic(x^2 + 5*x*y + y^2 + z^2).coefficients(); a # optional - sage.rings.finite_rings + sage: P. = GF(13)[] + sage: a = Conic(x^2 + 5*x*y + y^2 + z^2).coefficients(); a [1, 5, 0, 1, 0, 1] - sage: Conic(a) # optional - sage.rings.finite_rings + sage: Conic(a) Projective Conic Curve over Finite Field of size 13 defined by x^2 + 5*x*y + y^2 + z^2 """ @@ -194,14 +194,14 @@ def derivative_matrix(self): An example in characteristic `2`:: - sage: P. = GF(2)[] # optional - sage.rings.finite_rings - sage: c = Conic([t, 1, t^2, 1, 1, 0]); c # optional - sage.rings.finite_rings + sage: P. = GF(2)[] + sage: c = Conic([t, 1, t^2, 1, 1, 0]); c # needs sage.libs.ntl Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 2 (using GF2X) defined by t*x^2 + x*y + y^2 + (t^2)*x*z + y*z - sage: c.is_smooth() # optional - sage.rings.finite_rings + sage: c.is_smooth() True - sage: c.derivative_matrix() # optional - sage.rings.finite_rings + sage: c.derivative_matrix() [ 0 1 t^2] [ 1 0 1] [t^2 1 0] @@ -231,10 +231,10 @@ def determinant(self): Determinants are only defined in characteristic different from `2`:: - sage: C = Conic(GF(2), [1, 1, 1, 1, 1, 0]) # optional - sage.rings.finite_rings - sage: C.is_smooth() # optional - sage.rings.finite_rings + sage: C = Conic(GF(2), [1, 1, 1, 1, 1, 0]) + sage: C.is_smooth() True - sage: C.determinant() # optional - sage.rings.finite_rings + sage: C.determinant() Traceback (most recent call last): ... ValueError: The conic self (= Projective Conic Curve over Finite Field @@ -270,10 +270,10 @@ def diagonal_matrix(self): :: - sage: c = Conic(GF(4, 'a'), [0, 1, 1, 1, 1, 1]) # optional - sage.rings.finite_rings - sage: c.is_smooth() # optional - sage.rings.finite_rings + sage: c = Conic(GF(4, 'a'), [0, 1, 1, 1, 1, 1]) # needs sage.rings.finite_rings + sage: c.is_smooth() # needs sage.rings.finite_rings True - sage: c.diagonal_matrix() # optional - sage.rings.finite_rings + sage: c.diagonal_matrix() # needs sage.rings.finite_rings Traceback (most recent call last): ... ValueError: The conic self (= Projective Conic Curve over Finite Field @@ -312,7 +312,7 @@ def diagonalization(self, names=None): EXAMPLES:: - sage: Conic(GF(5), [1,0,1,1,0,1]).diagonalization() # optional - sage.rings.finite_rings + sage: Conic(GF(5), [1,0,1,1,0,1]).diagonalization() (Projective Conic Curve over Finite Field of size 5 defined by x^2 + y^2 + 2*z^2, Scheme morphism: @@ -333,7 +333,7 @@ def diagonalization(self, names=None): :: - sage: Conic(GF(2), [1,1,1,1,1,0]).diagonalization() # optional - sage.rings.finite_rings + sage: Conic(GF(2), [1,1,1,1,1,0]).diagonalization() Traceback (most recent call last): ... ValueError: The conic self (= Projective Conic Curve over Finite Field @@ -344,10 +344,10 @@ def diagonalization(self, names=None): :: - sage: K = FractionField(PolynomialRing(GF(7), 't')) # optional - sage.rings.finite_rings - sage: (t,) = K.gens() # optional - sage.rings.finite_rings - sage: C = Conic(K, [t/2,0, 1, 2, 0, 3]) # optional - sage.rings.finite_rings - sage: C.diagonalization() # optional - sage.rings.finite_rings + sage: K = FractionField(PolynomialRing(GF(7), 't')) + sage: (t,) = K.gens() + sage: C = Conic(K, [t/2,0, 1, 2, 0, 3]) + sage: C.diagonalization() (Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 7 defined by (-3*t)*x^2 + 2*y^2 + (3*t + 3)/t*z^2, @@ -394,8 +394,8 @@ def gens(self): :: - sage: C. = Conic(GF(3), [1, 1, 1]) # optional - sage.rings.finite_rings - sage: C # optional - sage.rings.finite_rings + sage: C. = Conic(GF(3), [1, 1, 1]) + sage: C Projective Conic Curve over Finite Field of size 3 defined by a^2 + b^2 + c^2 @@ -460,6 +460,7 @@ def has_rational_point(self, point=False, numbers, one does not. Check that they are both handled correctly by the Magma interface. :: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(-1) sage: K.coerce_embedding() Generic morphism: @@ -469,8 +470,9 @@ def has_rational_point(self, point=False, sage: Conic(K, [1,1,1]).rational_point(algorithm='magma') # optional - magma (-i : 1 : 0) + sage: # needs sage.rings.number_field sage: x = QQ['x'].gen() - sage: L. = NumberField(x^2+1, embedding=None) + sage: L. = NumberField(x^2 + 1, embedding=None) sage: Conic(L, [1,1,1]).rational_point(algorithm='magma') # optional - magma (-i : 1 : 0) sage: L == K @@ -579,11 +581,11 @@ def has_singular_point(self, point=False): sage: c.has_singular_point(point = True) (True, (0 : 1 : 0)) - sage: P. = GF(7)[] # optional - sage.rings.finite_rings - sage: e = Conic((x+y+z)*(x-y+2*z)); e # optional - sage.rings.finite_rings + sage: P. = GF(7)[] + sage: e = Conic((x+y+z)*(x-y+2*z)); e Projective Conic Curve over Finite Field of size 7 defined by x^2 - y^2 + 3*x*z + y*z + 2*z^2 - sage: e.has_singular_point(point = True) # optional - sage.rings.finite_rings + sage: e.has_singular_point(point = True) (True, (2 : 4 : 1)) sage: Conic([1, 1, -1]).has_singular_point() @@ -596,15 +598,15 @@ def has_singular_point(self, point=False): :: - sage: F. = FiniteField(8) # optional - sage.rings.finite_rings - sage: Conic([a, a + 1, 1]).has_singular_point(point=True) # optional - sage.rings.finite_rings + sage: F. = FiniteField(8) # needs sage.rings.finite_rings + sage: Conic([a, a + 1, 1]).has_singular_point(point=True) # needs sage.rings.finite_rings (True, (a + 1 : 0 : 1)) - sage: P. = GF(2)[] # optional - sage.rings.finite_rings - sage: C = Conic(P, [t,t,1]); C # optional - sage.rings.finite_rings + sage: P. = GF(2)[] + sage: C = Conic(P, [t,t,1]); C # needs sage.libs.ntl Projective Conic Curve over Fraction Field of Univariate Polynomial Ring in t over Finite Field of size 2 (using GF2X) defined by t*x^2 + t*y^2 + z^2 - sage: C.has_singular_point(point = False) # optional - sage.rings.finite_rings + sage: C.has_singular_point(point=False) # needs sage.libs.ntl Traceback (most recent call last): ... NotImplementedError: Sorry, find singular point on conics not implemented @@ -755,7 +757,7 @@ def is_smooth(self): sage: Conic([1,-1,0]).is_smooth() False - sage: Conic(GF(2),[1,1,1,1,1,0]).is_smooth() # optional - sage.rings.finite_rings + sage: Conic(GF(2),[1,1,1,1,1,0]).is_smooth() True """ if self.base_ring().characteristic() == 2: @@ -772,30 +774,30 @@ def _magma_init_(self, magma): EXAMPLES:: + sage: # optional - magma sage: C = Conic(QQ, [1,2,3]) - sage: C._magma_init_(magma) # optional - magma + sage: C._magma_init_(magma) 'Conic([_sage_ref...|1/1,2/1,3/1,0/1,0/1,0/1])' - sage: C = Conic(GF(41), [-1,2,5]) # optional - magma # optional - sage.rings.finite_rings - sage: C._magma_init_(magma) # optional - magma # optional - sage.rings.finite_rings + sage: C = Conic(GF(41), [-1,2,5]) + sage: C._magma_init_(magma) 'Conic([_sage_ref...|GF(41)!40,GF(41)!2,GF(41)!5,GF(41)!0,GF(41)!0,GF(41)!0])' - sage: F. = GF(25) # optional - sage.rings.finite_rings - sage: C = Conic([3,0,1,4,a,2]) # optional - sage.rings.finite_rings - sage: C # optional - sage.rings.finite_rings + sage: F. = GF(25) # needs sage.rings.finite_rings + sage: C = Conic([3,0,1,4,a,2]); C # needs sage.rings.finite_rings Projective Conic Curve over Finite Field in a of size 5^2 defined by -2*x^2 - y^2 + x*z + a*y*z + 2*z^2 - sage: magma(C) # optional - magma # optional - sage.rings.finite_rings + sage: magma(C) # needs sage.rings.finite_rings Conic over GF(5^2) defined by 3*X^2 + 4*Y^2 + X*Z + a*Y*Z + 2*Z^2 - sage: magma(Conic([1/2,2/3,-4/5,6/7,8/9,-10/11])) # optional - magma + sage: magma(Conic([1/2,2/3,-4/5,6/7,8/9,-10/11])) Conic over Rational Field defined by 1/2*X^2 + 2/3*X*Y + 6/7*Y^2 - 4/5*X*Z + 8/9*Y*Z - 10/11*Z^2 sage: R. = Frac(QQ['x']) - sage: magma(Conic([x, 1 + x, 1 - x])) # optional - magma + sage: magma(Conic([x, 1 + x, 1 - x])) Conic over Univariate rational function field over Rational Field defined by x*X^2 + (x + 1)*Y^2 + (-x + 1)*Z^2 sage: P. = QQ[] - sage: K. = NumberField(x^3 + x + 1) # optional - sage.rings.number_field - sage: magma(Conic([b,1,2])) # optional - magma # optional - sage.rings.number_field + sage: K. = NumberField(x^3 + x + 1) # needs sage.rings.number_field + sage: magma(Conic([b,1,2])) # needs sage.rings.number_field Conic over Number Field with defining polynomial x^3 + x + 1 over the Rational Field defined by b*X^2 + Y^2 + 2*Z^2 """ @@ -821,9 +823,9 @@ def matrix(self): [1/2 1 0] [ 0 0 1] - sage: R. = GF(2)[] # optional - sage.rings.finite_rings - sage: C = Conic(x^2 + x*y + y^2 + x*z + z^2) # optional - sage.rings.finite_rings - sage: C.matrix() # optional - sage.rings.finite_rings + sage: R. = GF(2)[] + sage: C = Conic(x^2 + x*y + y^2 + x*z + z^2) + sage: C.matrix() [1 1 1] [0 1 0] [0 0 1] @@ -851,8 +853,8 @@ def parametrization(self, point=None, morphism=True): An example over a finite field :: - sage: c = Conic(GF(2), [1,1,1,1,1,0]) # optional - sage.rings.finite_rings - sage: f, g = c.parametrization(); f, g # optional - sage.rings.finite_rings + sage: c = Conic(GF(2), [1,1,1,1,1,0]) + sage: f, g = c.parametrization(); f, g (Scheme morphism: From: Projective Space of dimension 1 over Finite Field of size 2 To: Projective Conic Curve over Finite Field of size 2 @@ -863,40 +865,42 @@ def parametrization(self, point=None, morphism=True): defined by x^2 + x*y + y^2 + x*z + y*z To: Projective Space of dimension 1 over Finite Field of size 2 Defn: Defined on coordinates by sending (x : y : z) to ...) - sage: set(f(p) for p in f.domain()) # optional - sage.rings.finite_rings + sage: set(f(p) for p in f.domain()) {(0 : 0 : 1), (0 : 1 : 1), (1 : 0 : 1)} Verfication of the example :: - sage: h = g*f; h # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: h = g*f; h Scheme endomorphism of Projective Space of dimension 1 over Finite Field of size 2 Defn: Defined on coordinates by sending (x : y) to ... - sage: h[0]/h[1] # optional - sage.rings.finite_rings + sage: h[0]/h[1] x/y - sage: h.is_one() # known bug (see :trac:`31892`) # optional - sage.rings.finite_rings + sage: h.is_one() # known bug (see :trac:`31892`) True - sage: (x,y,z) = c.gens() # optional - sage.rings.finite_rings - sage: x.parent() # optional - sage.rings.finite_rings + sage: (x,y,z) = c.gens() + sage: x.parent() Quotient of Multivariate Polynomial Ring in x, y, z over Finite Field of size 2 by the ideal (x^2 + x*y + y^2 + x*z + y*z) - sage: k = f*g # optional - sage.rings.finite_rings - sage: k[0]*z-k[2]*x # optional - sage.rings.finite_rings + sage: k = f*g + sage: k[0]*z-k[2]*x 0 - sage: k[1]*z-k[2]*y # optional - sage.rings.finite_rings + sage: k[1]*z-k[2]*y 0 The morphisms are mathematically defined in all points, but don't work completely in SageMath (see :trac:`31892`) :: - sage: f, g = c.parametrization([0,0,1]) # optional - sage.rings.finite_rings - sage: g([0,1,1]) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: f, g = c.parametrization([0,0,1]) + sage: g([0,1,1]) (1 : 0) - sage: f([1,0]) # optional - sage.rings.finite_rings + sage: f([1,0]) (0 : 1 : 1) - sage: f([1,1]) # optional - sage.rings.finite_rings + sage: f([1,1]) (0 : 0 : 1) - sage: g([0,0,1]) # optional - sage.rings.finite_rings + sage: g([0,0,1]) (1 : 1) An example with ``morphism = False`` :: @@ -1009,8 +1013,8 @@ def random_rational_point(self, *args1, **args2): EXAMPLES:: - sage: c = Conic(GF(2), [1,1,1,1,1,0]) # optional - sage.rings.finite_rings - sage: [c.random_rational_point() for i in range(10)] # random # optional - sage.rings.finite_rings + sage: c = Conic(GF(2), [1,1,1,1,1,0]) + sage: [c.random_rational_point() for i in range(10)] # random [(1 : 0 : 1), (1 : 0 : 1), (1 : 0 : 1), (0 : 1 : 1), (1 : 0 : 1), (0 : 0 : 1), (1 : 0 : 1), (1 : 0 : 1), (0 : 0 : 1), (1 : 0 : 1)] @@ -1063,7 +1067,7 @@ def rational_point(self, algorithm='default', read_cache=True): x^2 + 2*y^2 + z^2 has no rational points over Rational Field! sage: C = Conic(x^2 + y^2 + 7*z^2) - sage: C.rational_point(algorithm = 'rnfisnorm') + sage: C.rational_point(algorithm='rnfisnorm') Traceback (most recent call last): ... ValueError: Conic Projective Conic Curve over Rational Field defined by @@ -1071,71 +1075,76 @@ def rational_point(self, algorithm='default', read_cache=True): Examples over number fields :: + sage: # needs sage.rings.number_field sage: P. = QQ[] - sage: L. = NumberField(x^3 - 5) # optional - sage.rings.number_field - sage: C = Conic(L, [3, 2, -b]) # optional - sage.rings.number_field - sage: p = C.rational_point(algorithm = 'rnfisnorm') # optional - sage.rings.number_field - sage: p # output is random # optional - sage.rings.number_field + sage: L. = NumberField(x^3 - 5) + sage: C = Conic(L, [3, 2, -b]) + sage: p = C.rational_point(algorithm='rnfisnorm') + sage: p # output is random (1/3*b^2 - 4/3*b + 4/3 : b^2 - 2 : 1) - sage: C.defining_polynomial()(list(p)) # optional - sage.rings.number_field + sage: C.defining_polynomial()(list(p)) 0 - sage: K. = QuadraticField(-1) # optional - sage.rings.number_field - sage: D = Conic(K, [3, 2, 5]) # optional - sage.rings.number_field - sage: D.rational_point(algorithm = 'rnfisnorm') # output is random # optional - sage.rings.number_field + sage: K. = QuadraticField(-1) # needs sage.rings.number_field + sage: D = Conic(K, [3, 2, 5]) # needs sage.rings.number_field + sage: D.rational_point(algorithm='rnfisnorm') # output is random # needs sage.rings.number_field (-3 : 4*i : 1) - sage: L. = QuadraticField(2) # optional - sage.rings.number_field - sage: Conic(QQ, [1, 1, -3]).has_rational_point() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: L. = QuadraticField(2) + sage: Conic(QQ, [1, 1, -3]).has_rational_point() False - sage: E = Conic(L, [1, 1, -3]) # optional - sage.rings.number_field - sage: E.rational_point() # output is random # optional - sage.rings.number_field + sage: E = Conic(L, [1, 1, -3]) + sage: E.rational_point() # output is random (-1 : -s : 1) Currently Magma is better at solving conics over number fields than Sage, so it helps to use the algorithm 'magma' if Magma is installed:: - sage: q = C.rational_point(algorithm='magma', # optional - magma # optional - sage.rings.number_field + sage: # optional - magma, needs sage.rings.number_field + sage: q = C.rational_point(algorithm='magma', ....: read_cache=False) - sage: q # output is random, # optional - magma # optional - sage.rings.number_field + sage: q # output is random (1/5*b^2 : 1/5*b^2 : 1) - sage: C.defining_polynomial()(list(q)) # optional - magma # optional - sage.rings.number_field + sage: C.defining_polynomial()(list(q)) 0 - sage: len(str(p)) > 1.5*len(str(q)) # optional - magma # optional - sage.rings.number_field + sage: len(str(p)) > 1.5*len(str(q)) True - - sage: D.rational_point(algorithm='magma', # random, optional - magma # optional - sage.rings.number_field + sage: D.rational_point(algorithm='magma', # random + ....: read_cache=False) (1 : 2*i : 1) - - sage: E.rational_point(algorithm='magma', # random, optional - magma # optional - sage.rings.number_field + sage: E.rational_point(algorithm='magma', # random ....: read_cache=False) (-s : 1 : 1) - sage: F = Conic([L.gen(), 30, -20]) # optional - sage.rings.number_field - sage: q = F.rational_point(algorithm='magma') # optional - magma # optional - sage.rings.number_field - sage: q # random, optional - magma # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: F = Conic([L.gen(), 30, -20]) + sage: q = F.rational_point(algorithm='magma') # optional - magma + sage: q # random # optional - magma (-10/7*s + 40/7 : 5/7*s - 6/7 : 1) - sage: p = F.rational_point(read_cache=False) # optional - sage.rings.number_field - sage: p # random # optional - sage.rings.number_field + sage: p = F.rational_point(read_cache=False) + sage: p # random (788210*s - 1114700 : -171135*s + 242022 : 1) - sage: len(str(p)) > len(str(q)) # optional - magma # optional - sage.rings.number_field + sage: len(str(p)) > len(str(q)) # optional - magma True - sage: G = Conic([L.gen(), 30, -21]) # optional - sage.rings.number_field - sage: G.has_rational_point(algorithm='magma') # optional - magma # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: G = Conic([L.gen(), 30, -21]) + sage: G.has_rational_point(algorithm='magma') # optional - magma False - sage: G.has_rational_point(read_cache=False) # optional - sage.rings.number_field + sage: G.has_rational_point(read_cache=False) False - sage: G.has_rational_point(algorithm='local', read_cache=False) # optional - sage.rings.number_field + sage: G.has_rational_point(algorithm='local', + ....: read_cache=False) False - sage: G.rational_point(algorithm='magma') # optional - magma # optional - sage.rings.number_field + sage: G.rational_point(algorithm='magma') # optional - magma Traceback (most recent call last): ... ValueError: Conic Projective Conic Curve over Number Field in s with defining polynomial x^2 - 2 with s = 1.414213562373095? defined by s*x^2 + 30*y^2 - 21*z^2 has no rational points over Number Field in s with defining polynomial x^2 - 2 with s = 1.414213562373095?! - sage: G.rational_point(algorithm='magma', # optional - magma # optional - sage.rings.number_field + sage: G.rational_point(algorithm='magma', # optional - magma ....: read_cache=False) Traceback (most recent call last): ... @@ -1146,11 +1155,11 @@ def rational_point(self, algorithm='default', read_cache=True): Examples over finite fields :: - sage: F. = FiniteField(7^20) # optional - sage.rings.finite_rings - sage: C = Conic([1, a, -5]); C # optional - sage.rings.finite_rings + sage: F. = FiniteField(7^20) # needs sage.rings.finite_rings + sage: C = Conic([1, a, -5]); C # needs sage.rings.finite_rings Projective Conic Curve over Finite Field in a of size 7^20 defined by x^2 + a*y^2 + 2*z^2 - sage: C.rational_point() # output is random # optional - sage.rings.finite_rings + sage: C.rational_point() # output is random # needs sage.rings.finite_rings (4*a^19 + 5*a^18 + 4*a^17 + a^16 + 6*a^15 + 3*a^13 + 6*a^11 + a^9 + 3*a^8 + 2*a^7 + 4*a^6 + 3*a^5 + 3*a^4 + a^3 + a + 6 : 5*a^18 + a^17 + a^16 + 6*a^15 + 4*a^14 + a^13 + 5*a^12 + 5*a^10 @@ -1159,10 +1168,10 @@ def rational_point(self, algorithm='default', read_cache=True): Examples over `\RR` and `\CC` :: - sage: Conic(CC, [1, 2, 3]).rational_point() # optional - sage.rings.finite_rings + sage: Conic(CC, [1, 2, 3]).rational_point() (0 : 1.22474487139159*I : 1) - sage: Conic(RR, [1, 1, 1]).rational_point() # optional - sage.rings.finite_rings + sage: Conic(RR, [1, 1, 1]).rational_point() Traceback (most recent call last): ... ValueError: Conic Projective Conic Curve over Real Field @@ -1184,7 +1193,7 @@ def singular_point(self): :: - sage: Conic(GF(2), [1,1,1,1,1,1]).singular_point() # optional - sage.rings.finite_rings + sage: Conic(GF(2), [1,1,1,1,1,1]).singular_point() (1 : 1 : 1) ``ValueError`` is raised if the conic has no rational singular point diff --git a/src/sage/schemes/plane_conics/con_finite_field.py b/src/sage/schemes/plane_conics/con_finite_field.py index 5a6ef94bd7e..e62d8db828f 100644 --- a/src/sage/schemes/plane_conics/con_finite_field.py +++ b/src/sage/schemes/plane_conics/con_finite_field.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.finite_rings +# sage.doctest: needs sage.rings.finite_rings r""" Projective plane conics over finite fields diff --git a/src/sage/schemes/plane_conics/con_number_field.py b/src/sage/schemes/plane_conics/con_number_field.py index 2844329e195..19be6d237a8 100644 --- a/src/sage/schemes/plane_conics/con_number_field.py +++ b/src/sage/schemes/plane_conics/con_number_field.py @@ -1,4 +1,4 @@ -# sage.doctest: optional - sage.rings.number_field +# sage.doctest: needs sage.rings.number_field r""" Projective plane conics over a number field diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py index 8e5bf4669c2..1b3f0ac412a 100644 --- a/src/sage/schemes/plane_conics/con_rational_function_field.py +++ b/src/sage/schemes/plane_conics/con_rational_function_field.py @@ -130,16 +130,19 @@ def has_rational_point(self, point=False, algorithm='default', sage: C = Conic(K, [t^2 - 2, 2*t^3, -2*t^3 - 13*t^2 - 2*t + 18]) sage: C.has_rational_point(point=True) (True, (-3 : (t + 1)/t : 1)) - sage: R. = FiniteField(23)[] # optional - sage.rings.finite_rings - sage: C = Conic([2, t^2 + 1, t^2 + 5]) # optional - sage.rings.finite_rings - sage: C.has_rational_point() # optional - sage.rings.finite_rings + + sage: R. = FiniteField(23)[] + sage: C = Conic([2, t^2 + 1, t^2 + 5]) + sage: C.has_rational_point() True - sage: C.has_rational_point(point=True) # optional - sage.rings.finite_rings + sage: C.has_rational_point(point=True) (True, (5*t : 8 : 1)) - sage: F. = QuadraticField(-1) # optional - sage.rings.number_field - sage: R. = F[] # optional - sage.rings.number_field - sage: C = Conic([1, i*t, -t^2 + 4]) # optional - sage.rings.number_field - sage: C.has_rational_point(point=True) # optional - sage.rings.number_field + + sage: # needs sage.rings.number_field + sage: F. = QuadraticField(-1) + sage: R. = F[] + sage: C = Conic([1, i*t, -t^2 + 4]) + sage: C.has_rational_point(point=True) (True, (-t - 2*i : -2*i : 1)) It works on non-diagonal conics as well:: @@ -183,11 +186,11 @@ def has_rational_point(self, point=False, algorithm='default', sage: P. = QQ[] sage: E = P.fraction_field() sage: Q. = E[] - sage: F. = E.extension(Y^2 - u^3 - 1) # optional - sage.rings.function_field - sage: R. = F[] # optional - sage.rings.function_field - sage: K = R.fraction_field() # optional - sage.rings.function_field - sage: C = Conic(K, [u, v, 1]) # optional - sage.rings.function_field - sage: C.has_rational_point() # optional - sage.rings.function_field + sage: F. = E.extension(Y^2 - u^3 - 1) + sage: R. = F[] + sage: K = R.fraction_field() # needs sage.rings.function_field + sage: C = Conic(K, [u, v, 1]) # needs sage.rings.function_field + sage: C.has_rational_point() # needs sage.rings.function_field Traceback (most recent call last): ... NotImplementedError: has_rational_point not implemented for conics @@ -198,10 +201,10 @@ def has_rational_point(self, point=False, algorithm='default', ``has_rational_point`` fails for some conics over function fields over finite fields, due to :trac:`20003`:: - sage: K. = PolynomialRing(GF(7)) # optional - sage.rings.finite_rings - sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2, # optional - sage.rings.finite_rings + sage: K. = PolynomialRing(GF(7)) + sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2, ....: 5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5]) - sage: C.has_rational_point() # optional - sage.rings.finite_rings + sage: C.has_rational_point() Traceback (most recent call last): ... TypeError: self (=Scheme morphism: @@ -477,6 +480,7 @@ def find_point(self, supports, roots, case, solution=0): Different solubility certificates give different points:: + sage: # needs sage.rings.number_field sage: K. = PolynomialRing(QQ, 't') sage: C = Conic(K, [t^2 - 2, 2*t, -2*t^3 - 13*t^2 - 2*t + 18]) sage: supp = [[t^2 - 2], [t], [t^3 + 13/2*t^2 + t - 9]] diff --git a/src/sage/schemes/plane_conics/constructor.py b/src/sage/schemes/plane_conics/constructor.py index 0a73422519c..20bc5630ac1 100644 --- a/src/sage/schemes/plane_conics/constructor.py +++ b/src/sage/schemes/plane_conics/constructor.py @@ -105,8 +105,8 @@ def Conic(base_field, F=None, names=None, unique=True): sage: X,Y,Z = QQ['X,Y,Z'].gens() sage: Conic(X^2 - X*Y + Y^2 - Z^2) Projective Conic Curve over Rational Field defined by X^2 - X*Y + Y^2 - Z^2 - sage: x,y = GF(7)['x,y'].gens() # optional - sage.rings.finite_rings - sage: Conic(x^2 - x + 2*y^2 - 3, 'U,V,W') # optional - sage.rings.finite_rings + sage: x,y = GF(7)['x,y'].gens() + sage: Conic(x^2 - x + 2*y^2 - 3, 'U,V,W') Projective Conic Curve over Finite Field of size 7 defined by U^2 + 2*V^2 - U*W - 3*W^2 @@ -115,17 +115,17 @@ def Conic(base_field, F=None, names=None, unique=True): sage: Conic(matrix(QQ, [[1, 2, 0], [4, 0, 0], [7, 0, 9]]), 'x,y,z') Projective Conic Curve over Rational Field defined by x^2 + 6*x*y + 7*x*z + 9*z^2 - sage: x,y,z = GF(11)['x,y,z'].gens() # optional - sage.rings.finite_rings - sage: C = Conic(x^2 + y^2 - 2*z^2); C # optional - sage.rings.finite_rings + sage: x,y,z = GF(11)['x,y,z'].gens() + sage: C = Conic(x^2 + y^2 - 2*z^2); C Projective Conic Curve over Finite Field of size 11 defined by x^2 + y^2 - 2*z^2 - sage: Conic(C.symmetric_matrix(), 'x,y,z') # optional - sage.rings.finite_rings + sage: Conic(C.symmetric_matrix(), 'x,y,z') Projective Conic Curve over Finite Field of size 11 defined by x^2 + y^2 - 2*z^2 Conics given by coefficients :: sage: Conic(QQ, [1,2,3]) Projective Conic Curve over Rational Field defined by x^2 + 2*y^2 + 3*z^2 - sage: Conic(GF(7), [1,2,3,4,5,6], 'X') # optional - sage.rings.finite_rings + sage: Conic(GF(7), [1,2,3,4,5,6], 'X') Projective Conic Curve over Finite Field of size 7 defined by X0^2 + 2*X0*X1 - 3*X1^2 + 3*X0*X2 - 2*X1*X2 - X2^2 @@ -139,8 +139,8 @@ def Conic(base_field, F=None, names=None, unique=True): sage: C.point([3,4]) (3 : 4 : 1) - sage: a = AffineSpace(GF(13), 2) # optional - sage.rings.finite_rings - sage: Conic([a([x,x^2]) for x in range(5)]) # optional - sage.rings.finite_rings + sage: a = AffineSpace(GF(13), 2) + sage: Conic([a([x,x^2]) for x in range(5)]) Projective Conic Curve over Finite Field of size 13 defined by x^2 - y*z """ if not (base_field is None or isinstance(base_field, IntegralDomain)): diff --git a/src/sage/schemes/product_projective/homset.py b/src/sage/schemes/product_projective/homset.py index 91af8105def..2b16549fd13 100644 --- a/src/sage/schemes/product_projective/homset.py +++ b/src/sage/schemes/product_projective/homset.py @@ -104,24 +104,24 @@ def points(self, **kwds): sage: P. = ProductProjectiveSpaces([1, 1], QQ) sage: X = P.subscheme([x - y, z^2 - 2*w^2]) - sage: X(P.base_ring()).points() + sage: X(P.base_ring()).points() # needs sage.libs.singular [] :: sage: u = QQ['u'].0 - sage: K = NumberField(u^2 - 2, 'v') # optional - sage.rings.number_field - sage: P. = ProductProjectiveSpaces([1, 1], K) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 - y^2, z^2 - 2*w^2]) # optional - sage.rings.number_field - sage: sorted(X(P.base_ring()).points()) # optional - sage.rings.number_field + sage: K = NumberField(u^2 - 2, 'v') # needs sage.rings.number_field + sage: P. = ProductProjectiveSpaces([1, 1], K) # needs sage.rings.number_field + sage: X = P.subscheme([x^2 - y^2, z^2 - 2*w^2]) + sage: sorted(X(P.base_ring()).points()) # needs sage.libs.singular sage.rings.number_field [(-1 : 1 , -v : 1), (-1 : 1 , v : 1), (1 : 1 , -v : 1), (1 : 1 , v : 1)] :: sage: u = QQ['u'].0 - sage: K = NumberField(u^2 + 1, 'v') # optional - sage.rings.number_field - sage: P. = ProductProjectiveSpaces([1, 1], K) # optional - sage.rings.number_field - sage: P(K).points(bound=1) # optional - sage.rings.number_field + sage: K = NumberField(u^2 + 1, 'v') # needs sage.rings.number_field + sage: P. = ProductProjectiveSpaces([1, 1], K) # needs sage.rings.number_field + sage: P(K).points(bound=1) # needs sage.libs.singular sage.rings.number_field [(-1 : 1 , -1 : 1), (-1 : 1 , -v : 1), (-1 : 1 , 0 : 1), (-1 : 1 , v : 1), (-1 : 1 , 1 : 0), (-1 : 1 , 1 : 1), (-v : 1 , -1 : 1), (-v : 1 , -v : 1), (-v : 1 , 0 : 1), (-v : 1 , v : 1), (-v : 1 , 1 : 0), (-v : 1 , 1 : 1), @@ -134,8 +134,8 @@ def points(self, **kwds): :: - sage: P. = ProductProjectiveSpaces([2, 1], GF(3)) # optional - sage.rings.finite_rings - sage: P(P.base_ring()).points() # optional - sage.rings.finite_rings + sage: P. = ProductProjectiveSpaces([2, 1], GF(3)) + sage: P(P.base_ring()).points() [(0 : 0 : 1 , 0 : 1), (0 : 0 : 1 , 1 : 0), (0 : 0 : 1 , 1 : 1), (0 : 0 : 1 , 2 : 1), (0 : 1 : 0 , 0 : 1), (0 : 1 : 0 , 1 : 0), (0 : 1 : 0 , 1 : 1), (0 : 1 : 0 , 2 : 1), (0 : 1 : 1 , 0 : 1), (0 : 1 : 1 , 1 : 0), (0 : 1 : 1 , 1 : 1), (0 : 1 : 1 , 2 : 1), @@ -154,7 +154,7 @@ def points(self, **kwds): sage: PP. = ProductProjectiveSpaces([2, 1], QQ) sage: X = PP.subscheme([x + y, u*u - v*u]) - sage: X.rational_points(bound=2) + sage: X.rational_points(bound=2) # needs sage.libs.singular [(-2 : 2 : 1 , 0 : 1), (-2 : 2 : 1 , 1 : 1), (-1 : 1 : 0 , 0 : 1), @@ -176,7 +176,7 @@ def points(self, **kwds): sage: PP. = ProductProjectiveSpaces([2, 1, 2], QQ) sage: X = PP.subscheme([x*u^2*a, b*z*u*v, z*v^2*c]) - sage: len(X.rational_points(bound=1, algorithm='enumerate')) + sage: len(X.rational_points(bound=1, algorithm='enumerate')) # needs sage.libs.singular 232 """ B = kwds.pop('bound', 0) diff --git a/src/sage/schemes/product_projective/morphism.py b/src/sage/schemes/product_projective/morphism.py index f28aa84e7ba..4a6bbdbf160 100644 --- a/src/sage/schemes/product_projective/morphism.py +++ b/src/sage/schemes/product_projective/morphism.py @@ -250,11 +250,12 @@ def __eq__(self, right): EXAMPLES:: sage: P1. = ProductProjectiveSpaces([1, 1], QQ) - sage: P2. = ProductProjectiveSpaces([1, 1], CC) - sage: H1 = End(P1); H2 = End(P2) + sage: P2. = ProductProjectiveSpaces([1, 1], CC) # needs sage.rings.real_mpfr + sage: H1 = End(P1) + sage: H2 = End(P2) # needs sage.rings.real_mpfr sage: f = H1([x1*x2, x2^2, x3*x4, x4^2]) - sage: g = H2([y1*y2, y2^2, y3*y4, y4^2]) - sage: f == g + sage: g = H2([y1*y2, y2^2, y3*y4, y4^2]) # needs sage.rings.real_mpfr + sage: f == g # needs sage.rings.real_mpfr False :: @@ -359,7 +360,7 @@ def is_morphism(self): sage: Z. = ProductProjectiveSpaces([1, 2], ZZ) sage: H = End(Z) sage: f = H([a^2, b^2, x*z - y*z, x^2 - y^2, z^2]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular False :: @@ -367,7 +368,7 @@ def is_morphism(self): sage: P. = ProductProjectiveSpaces([2, 2], QQ) sage: H = End(P) sage: f = H([u, v, w, u^2, v^2, w^2]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular True :: @@ -376,7 +377,7 @@ def is_morphism(self): sage: Q. = ProductProjectiveSpaces([1, 2], QQ) sage: H = Hom(P, Q) sage: f = H([x^2, y^2, u^3, w^3, u^3]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular False """ m = 0 @@ -411,7 +412,7 @@ def as_dynamical_system(self): sage: Z. = ProductProjectiveSpaces([1, 2], ZZ) sage: H = End(Z) sage: f = H([a^3, b^3, x^2, y^2, z^2]) - sage: type(f.as_dynamical_system()) + sage: type(f.as_dynamical_system()) # needs sage.schemes """ if not self.is_endomorphism(): @@ -443,18 +444,19 @@ def global_height(self, prec=None): sage: P1xP1. = ProductProjectiveSpaces([1, 1], ZZ) sage: H = End(P1xP1) sage: f = H([x^2*u, 3*y^2*v, 5*x*v^2, y*u^2]) - sage: f.global_height() + sage: f.global_height() # needs sage.rings.real_mpfr 1.60943791243410 :: + sage: # needs sage.rings.number_field sage: u = QQ['u'].0 - sage: R = NumberField(u^2 - 2, 'v') # optional - sage.rings.number_field - sage: PP. = ProductProjectiveSpaces([1, 1], R) # optional - sage.rings.number_field - sage: H = End(PP) # optional - sage.rings.number_field - sage: O = R.maximal_order() # optional - sage.rings.number_field - sage: g = H([3*O(u)*x^2, 13*x*y, 7*a*y, 5*b*x + O(u)*a*y]) # optional - sage.rings.number_field - sage: g.global_height() # optional - sage.rings.number_field + sage: R = NumberField(u^2 - 2, 'v') + sage: PP. = ProductProjectiveSpaces([1, 1], R) + sage: H = End(PP) + sage: O = R.maximal_order() + sage: g = H([3*O(u)*x^2, 13*x*y, 7*a*y, 5*b*x + O(u)*a*y]) + sage: g.global_height() # needs sage.rings.real_mpfr 2.56494935746154 """ K = self.domain().base_ring() @@ -489,17 +491,18 @@ def local_height(self, v, prec=None): sage: T. = ProductProjectiveSpaces([2, 1], QQ) sage: H = T.Hom(T) sage: f = H([4*x^2 + 3/100*y^2, 8/210*x*y, 1/10000*z^2, 20*w^2, 1/384*u*w]) - sage: f.local_height(2) + sage: f.local_height(2) # needs sage.rings.real_mpfr 4.85203026391962 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 5) # optional - sage.rings.number_field - sage: P. = ProductProjectiveSpaces([1, 1], K) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2, a^2, 6*b^2 + 1/9*a*b]) # optional - sage.rings.number_field - sage: f.local_height(K.ideal(3)) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 5) + sage: P. = ProductProjectiveSpaces([1, 1], K) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2, a^2, 6*b^2 + 1/9*a*b]) + sage: f.local_height(K.ideal(3)) # needs sage.rings.real_mpfr 2.19722457733622 """ K = FractionField(self.domain().base_ring()) diff --git a/src/sage/schemes/product_projective/point.py b/src/sage/schemes/product_projective/point.py index 09cd0225209..608e97bf1e0 100644 --- a/src/sage/schemes/product_projective/point.py +++ b/src/sage/schemes/product_projective/point.py @@ -69,15 +69,15 @@ def __init__(self, parent, polys, check=True): :: - sage: T = ProductProjectiveSpaces([2, 2, 2], GF(5), 'x') # optional - sage.rings.finite_rings - sage: T.point([1, 2, 3, 4, 5, 6, 7, 8, 9]) # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([2, 2, 2], GF(5), 'x') + sage: T.point([1, 2, 3, 4, 5, 6, 7, 8, 9]) (2 : 4 : 1 , 4 : 0 : 1 , 3 : 2 : 1) :: - sage: T. = ProductProjectiveSpaces([1, 1], GF(5)) # optional - sage.rings.finite_rings - sage: X = T.subscheme([x - y, z - 2*w]) # optional - sage.rings.finite_rings - sage: X([1, 1, 2, 1]) # optional - sage.rings.finite_rings + sage: T. = ProductProjectiveSpaces([1, 1], GF(5)) + sage: X = T.subscheme([x - y, z - 2*w]) + sage: X([1, 1, 2, 1]) (1 : 1 , 2 : 1) """ polys = copy(polys) @@ -116,13 +116,13 @@ def __getitem__(self, i): EXAMPLES:: - sage: T = ProductProjectiveSpaces([2, 2, 2], GF(5), 'x') # optional - sage.rings.finite_rings - sage: P = T([1, 0, 1, 1, 0, 0, 0, 0, 1]) # optional - sage.rings.finite_rings - sage: P[1] # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([2, 2, 2], GF(5), 'x') + sage: P = T([1, 0, 1, 1, 0, 0, 0, 0, 1]) + sage: P[1] (1 : 0 : 0) - sage: P[1].codomain() # optional - sage.rings.finite_rings + sage: P[1].codomain() Projective Space of dimension 2 over Finite Field of size 5 - sage: P[1][0] # optional - sage.rings.finite_rings + sage: P[1][0] 1 """ return self._points[i] @@ -173,26 +173,26 @@ def _richcmp_(self, right, op): EXAMPLES:: - sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') # optional - sage.rings.finite_rings - sage: P = T([3, 2, 3, 4, 1, 0]) # optional - sage.rings.finite_rings - sage: Q = T([1, 2, 3, 4, 3, 1]) # optional - sage.rings.finite_rings - sage: P > Q # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') + sage: P = T([3, 2, 3, 4, 1, 0]) + sage: Q = T([1, 2, 3, 4, 3, 1]) + sage: P > Q True :: - sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') # optional - sage.rings.finite_rings - sage: P = T([1, 2, 3, 4, 1, 0]) # optional - sage.rings.finite_rings - sage: Q = T([1, 2, 3, 4, 3, 0]) # optional - sage.rings.finite_rings - sage: P == Q # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') + sage: P = T([1, 2, 3, 4, 1, 0]) + sage: Q = T([1, 2, 3, 4, 3, 0]) + sage: P == Q True :: - sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') # optional - sage.rings.finite_rings - sage: P = T([1, 2, 3, 4, 1, 0]) # optional - sage.rings.finite_rings - sage: Q = T([1, 2, 3, 4, 3, 1]) # optional - sage.rings.finite_rings - sage: P < Q # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') + sage: P = T([1, 2, 3, 4, 1, 0]) + sage: Q = T([1, 2, 3, 4, 3, 1]) + sage: P < Q True """ #needed for Digraph @@ -281,10 +281,10 @@ def __hash__(self): :: - sage: PP = ProductProjectiveSpaces(GF(7), [1, 1, 1]) # optional - sage.rings.finite_rings - sage: hash(PP([4, 1, 5, 4, 6, 1])) == hash((4, 1, 5, 4, 6, 1)) # optional - sage.rings.finite_rings + sage: PP = ProductProjectiveSpaces(GF(7), [1, 1, 1]) + sage: hash(PP([4, 1, 5, 4, 6, 1])) == hash((4, 1, 5, 4, 6, 1)) False - sage: hash(PP([4, 1, 5, 4, 6, 1])) == hash((4, 1, 3, 1, 6, 1)) # optional - sage.rings.finite_rings + sage: hash(PP([4, 1, 5, 4, 6, 1])) == hash((4, 1, 3, 1, 6, 1)) True """ R = self.codomain().base_ring() @@ -339,6 +339,7 @@ def dehomogenize(self, L): :: + sage: # needs sage.rings.real_mpfr sage: PP. = ProductProjectiveSpaces([1, 2], CC) sage: X = PP.subscheme([a^2 + b^2]) sage: P = X([2, 2*i, -3, 6*i, 3 - 6*i]) @@ -410,7 +411,7 @@ def change_ring(self, R, **kwds): sage: T. = ProductProjectiveSpaces([1, 1, 1], ZZ) sage: P = T.point([5, 3, 15, 4, 2, 6]) - sage: P.change_ring(GF(3)) # optional - sage.rings.finite_rings + sage: P.change_ring(GF(3)) (1 : 0 , 0 : 1 , 1 : 0) """ check = kwds.get('check', True) @@ -437,30 +438,31 @@ def global_height(self, prec=None): sage: PP = ProductProjectiveSpaces(QQ, [2, 2], 'x') sage: Q = PP([1, 7, 5, 18, 2, 3]) - sage: Q.global_height() + sage: Q.global_height() # needs sage.symbolic 2.89037175789616 :: sage: PP = ProductProjectiveSpaces(ZZ, [1, 1], 'x') sage: A = PP([-30, 2, 1, 6]) - sage: A.global_height() + sage: A.global_height() # needs sage.symbolic 2.70805020110221 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: k. = NumberField(x^2 + 5) # optional - sage.rings.number_field - sage: PP = ProductProjectiveSpaces(k, [1, 2], 'y') # optional - sage.rings.number_field - sage: Q = PP([3, 5*w + 1, 1, 7*w, 10]) # optional - sage.rings.number_field - sage: Q.global_height() # optional - sage.rings.number_field + sage: k. = NumberField(x^2 + 5) + sage: PP = ProductProjectiveSpaces(k, [1, 2], 'y') + sage: Q = PP([3, 5*w + 1, 1, 7*w, 10]) + sage: Q.global_height() 2.75062910527236 :: - sage: PP = ProductProjectiveSpaces(QQbar, [1, 1], 'x') # optional - sage.rings.number_field - sage: Q = PP([1, QQbar(sqrt(2)), QQbar(5^(1/3)), QQbar(3^(1/3))]) # optional - sage.rings.number_field sage.symbolic - sage: Q.global_height() # optional - sage.rings.number_field sage.symbolic + sage: PP = ProductProjectiveSpaces(QQbar, [1, 1], 'x') # needs sage.rings.number_field + sage: Q = PP([1, QQbar(sqrt(2)), QQbar(5^(1/3)), QQbar(3^(1/3))]) # needs sage.rings.number_field sage.symbolic + sage: Q.global_height() # needs sage.rings.number_field sage.symbolic 0.536479304144700 """ K = self.codomain().base_ring() @@ -491,14 +493,14 @@ def local_height(self, v, prec=None): sage: PP = ProductProjectiveSpaces(QQ, [1, 1], 'x') sage: A = PP([11, 5, 10, 2]) - sage: A.local_height(5) + sage: A.local_height(5) # needs sage.rings.real_mpfr 1.60943791243410 :: sage: P = ProductProjectiveSpaces(QQ, [1, 2], 'x') sage: Q = P([1, 4, 1/2, 2, 32]) - sage: Q.local_height(2) + sage: Q.local_height(2) # needs sage.rings.real_mpfr 4.15888308335967 """ K = FractionField(self.domain().base_ring()) @@ -530,7 +532,7 @@ def intersection_multiplicity(self, X): sage: X = PP.subscheme([y^2*z^3*u - x^5*v]) sage: Y = PP.subscheme([u^3 - v^3, x - y]) sage: Q = X([0,0,1,1,1]) - sage: Q.intersection_multiplicity(Y) + sage: Q.intersection_multiplicity(Y) # needs sage.libs.singular 2 """ from sage.schemes.product_projective.space import is_ProductProjectiveSpaces @@ -552,13 +554,13 @@ def multiplicity(self): sage: PP. = ProductProjectiveSpaces(QQ, [3, 2]) sage: X = PP.subscheme([x^8*t - y^8*t + z^5*w^3*v]) sage: Q1 = X([1,1,0,0,-1,-1,1]) - sage: Q1.multiplicity() + sage: Q1.multiplicity() # needs sage.libs.singular 1 sage: Q2 = X([0,0,0,1,0,1,1]) - sage: Q2.multiplicity() + sage: Q2.multiplicity() # needs sage.libs.singular 5 sage: Q3 = X([0,0,0,1,1,0,0]) - sage: Q3.multiplicity() + sage: Q3.multiplicity() # needs sage.libs.singular 6 """ from sage.schemes.product_projective.space import is_ProductProjectiveSpaces diff --git a/src/sage/schemes/product_projective/rational_point.py b/src/sage/schemes/product_projective/rational_point.py index d9cda05b8e2..5375ffb4535 100644 --- a/src/sage/schemes/product_projective/rational_point.py +++ b/src/sage/schemes/product_projective/rational_point.py @@ -27,11 +27,11 @@ Product projective over finite field:: - sage: P1. = ProductProjectiveSpaces([1, 1], GF(7)) # optional - sage.rings.finite_rings - sage: X = P1.subscheme([2*x + 3*y]) # optional - sage.rings.finite_rings + sage: P1. = ProductProjectiveSpaces([1, 1], GF(7)) + sage: X = P1.subscheme([2*x + 3*y]) sage: from sage.schemes.product_projective.rational_point import \ enum_product_projective_finite_field - sage: enum_product_projective_finite_field(X) # optional - sage.rings.finite_rings + sage: enum_product_projective_finite_field(X) [(2 : 1 , 0 : 1), (2 : 1 , 1 : 0), (2 : 1 , 1 : 1), (2 : 1 , 2 : 1), (2 : 1 , 3 : 1), (2 : 1 , 4 : 1), (2 : 1 , 5 : 1), (2 : 1 , 6 : 1)] @@ -207,13 +207,14 @@ def enum_product_projective_number_field(X, **kwds): EXAMPLES:: + sage: # needs sage.rings.number_field sage: u = QQ['u'].0 - sage: K = NumberField(u^2 + 2, 'v') # optional - sage.rings.number_field - sage: PP. = ProductProjectiveSpaces([1, 1], K) # optional - sage.rings.number_field - sage: X = PP.subscheme([x^2 + 2*y^2]) # optional - sage.rings.number_field + sage: K = NumberField(u^2 + 2, 'v') + sage: PP. = ProductProjectiveSpaces([1, 1], K) + sage: X = PP.subscheme([x^2 + 2*y^2]) sage: from sage.schemes.product_projective.rational_point import \ enum_product_projective_number_field - sage: enum_product_projective_number_field(X, bound=1.5) # optional - sage.rings.number_field + sage: enum_product_projective_number_field(X, bound=1.5) [(-v : 1 , -1 : 1), (-v : 1 , -v : 1), (-v : 1 , -1/2*v : 1), (-v : 1 , 0 : 1), (-v : 1 , 1/2*v : 1), (-v : 1 , v : 1), (-v : 1 , 1 : 0), (-v : 1 , 1 : 1), (v : 1 , -1 : 1), @@ -261,10 +262,10 @@ def enum_product_projective_finite_field(X): EXAMPLES:: - sage: PP. = ProductProjectiveSpaces([1, 1], GF(3)) # optional - sage.rings.finite_rings + sage: PP. = ProductProjectiveSpaces([1, 1], GF(3)) sage: from sage.schemes.product_projective.rational_point import \ enum_product_projective_finite_field - sage: enum_product_projective_finite_field(PP) # optional - sage.rings.finite_rings + sage: enum_product_projective_finite_field(PP) [(0 : 1 , 0 : 1), (0 : 1 , 1 : 0), (0 : 1 , 1 : 1), (0 : 1 , 2 : 1), (1 : 0 , 0 : 1), (1 : 0 , 1 : 0), (1 : 0 , 1 : 1), (1 : 0 , 2 : 1), (1 : 1 , 0 : 1), @@ -274,11 +275,11 @@ def enum_product_projective_finite_field(X): :: - sage: PP. = ProductProjectiveSpaces([1, 1], GF(17)) # optional - sage.rings.finite_rings - sage: X = PP.subscheme([x0^2 + 2*x1^2]) # optional - sage.rings.finite_rings + sage: PP. = ProductProjectiveSpaces([1, 1], GF(17)) + sage: X = PP.subscheme([x0^2 + 2*x1^2]) sage: from sage.schemes.product_projective.rational_point import \ enum_product_projective_finite_field - sage: len(enum_product_projective_finite_field(X)) # optional - sage.rings.finite_rings + sage: len(enum_product_projective_finite_field(X)) 36 """ if is_Scheme(X): @@ -336,7 +337,7 @@ def sieve(X, bound): sage: from sage.schemes.product_projective.rational_point import sieve sage: PP. = ProductProjectiveSpaces([2, 1], QQ) sage: X = PP.subscheme([x^2 + y^2 - x*z, u*u - v*u]) - sage: sieve(X, 2) + sage: sieve(X, 2) # needs sage.libs.singular [(0 : 0 : 1 , 0 : 1), (0 : 0 : 1 , 1 : 1), (1/2 : -1/2 : 1 , 0 : 1), (1/2 : -1/2 : 1 , 1 : 1), (1/2 : 1/2 : 1 , 0 : 1), (1/2 : 1/2 : 1 , 1 : 1), (1 : 0 : 1 , 0 : 1), (1 : 0 : 1 , 1 : 1)] diff --git a/src/sage/schemes/product_projective/space.py b/src/sage/schemes/product_projective/space.py index c17524ed163..687feb0112f 100644 --- a/src/sage/schemes/product_projective/space.py +++ b/src/sage/schemes/product_projective/space.py @@ -105,7 +105,7 @@ def ProductProjectiveSpaces(n, R=None, names='x'): :: - sage: ProductProjectiveSpaces([2, 2], GF(7), 'y') # optional - sage.rings.finite_rings + sage: ProductProjectiveSpaces([2, 2], GF(7), 'y') Product of projective spaces P^2 x P^2 over Finite Field of size 7 :: @@ -508,10 +508,10 @@ def dimension_absolute(self): EXAMPLES:: - sage: T. = ProductProjectiveSpaces([2, 2], GF(17)) # optional - sage.rings.finite_rings - sage: T.dimension_absolute() # optional - sage.rings.finite_rings + sage: T. = ProductProjectiveSpaces([2, 2], GF(17)) + sage: T.dimension_absolute() 4 - sage: T.dimension() # optional - sage.rings.finite_rings + sage: T.dimension() 4 """ base = self.base_scheme() @@ -543,10 +543,10 @@ def dimension_absolute_components(self): EXAMPLES:: - sage: T. = ProductProjectiveSpaces([2, 2], GF(17)) # optional - sage.rings.finite_rings - sage: T.dimension_absolute_components() # optional - sage.rings.finite_rings + sage: T. = ProductProjectiveSpaces([2, 2], GF(17)) + sage: T.dimension_absolute_components() [2, 2] - sage: T.dimension_components() # optional - sage.rings.finite_rings + sage: T.dimension_components() [2, 2] """ base = self.base_scheme() @@ -564,8 +564,8 @@ def num_components(self): EXAMPLES:: - sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') # optional - sage.rings.finite_rings - sage: T.num_components() # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') + sage: T.num_components() 3 """ return len(self._components) @@ -581,8 +581,8 @@ def ngens(self): EXAMPLES:: - sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') # optional - sage.rings.finite_rings - sage: T.ngens() # optional - sage.rings.finite_rings + sage: T = ProductProjectiveSpaces([1, 1, 1], GF(5), 'x') + sage: T.ngens() 6 """ return sum([P.ngens() for P in self._components]) @@ -722,9 +722,9 @@ def _validate(self, polynomials): :: - sage: R. = PolynomialRing(GF(5)) # optional - sage.rings.finite_rings - sage: T. = ProductProjectiveSpaces([2, 1], QQ) # optional - sage.rings.finite_rings - sage: T._validate([t, t, t, w^2, u^2]) # optional - sage.rings.finite_rings + sage: R. = PolynomialRing(GF(5)) + sage: T. = ProductProjectiveSpaces([2, 1], QQ) + sage: T._validate([t, t, t, w^2, u^2]) Traceback (most recent call last): ... TypeError: polynomials (=[t, t, t, w^2, u^2]) must be elements of Multivariate @@ -755,9 +755,9 @@ def _check_satisfies_equations(self, v): :: - sage: R. = PolynomialRing(GF(7)) # optional - sage.rings.finite_rings - sage: T. = ProductProjectiveSpaces([2, 1], R) # optional - sage.rings.finite_rings - sage: T._check_satisfies_equations([1 + t, 1, 0, 0, 1]) # optional - sage.rings.finite_rings + sage: R. = PolynomialRing(GF(7)) + sage: T. = ProductProjectiveSpaces([2, 1], R) + sage: T._check_satisfies_equations([1 + t, 1, 0, 0, 1]) True :: @@ -837,24 +837,24 @@ def subscheme(self, X): EXAMPLES:: - sage: P. = ProductProjectiveSpaces([1, 1], GF(5)) # optional - sage.rings.finite_rings - sage: X = P.subscheme([x - y, z - w]); X # optional - sage.rings.finite_rings + sage: P. = ProductProjectiveSpaces([1, 1], GF(5)) + sage: X = P.subscheme([x - y, z - w]); X Closed subscheme of Product of projective spaces P^1 x P^1 over Finite Field of size 5 defined by: x - y, z - w - sage: X.defining_polynomials() # optional - sage.rings.finite_rings + sage: X.defining_polynomials() [x - y, z - w] - sage: I = X.defining_ideal(); I # optional - sage.rings.finite_rings + sage: I = X.defining_ideal(); I Ideal (x - y, z - w) of Multivariate Polynomial Ring in x, y, z, w over Finite Field of size 5 - sage: X.dimension() # optional - sage.rings.finite_rings + sage: X.dimension() # needs sage.libs.singular 0 - sage: X.base_ring() # optional - sage.rings.finite_rings + sage: X.base_ring() Finite Field of size 5 - sage: X.base_scheme() # optional - sage.rings.finite_rings + sage: X.base_scheme() Spectrum of Finite Field of size 5 - sage: X.structure_morphism() # optional - sage.rings.finite_rings + sage: X.structure_morphism() Scheme morphism: From: Closed subscheme of Product of projective spaces P^1 x P^1 over Finite Field of size 5 defined by: x - y, z - w @@ -884,7 +884,7 @@ def change_ring(self, R): EXAMPLES:: sage: T. = ProductProjectiveSpaces([2, 2], QQ) - sage: T.change_ring(GF(17)) # optional - sage.rings.finite_rings + sage: T.change_ring(GF(17)) Product of projective spaces P^2 x P^2 over Finite Field of size 17 """ new_components = [P.change_ring(R) for P in self._components] @@ -977,7 +977,7 @@ def segre_embedding(self, PP=None, var='u'): EXAMPLES:: sage: X. = ProductProjectiveSpaces(ZZ, [2, 2]) - sage: phi = X.segre_embedding(); phi + sage: phi = X.segre_embedding(); phi # needs sage.libs.singular Scheme morphism: From: Product of projective spaces P^2 x P^2 over Integer Ring To: Closed subscheme of Projective Space of dimension 8 over Integer Ring @@ -990,8 +990,8 @@ def segre_embedding(self, PP=None, var='u'): :: - sage: T = ProductProjectiveSpaces([1, 2], CC, 'z') - sage: T.segre_embedding() + sage: T = ProductProjectiveSpaces([1, 2], CC, 'z') # needs sage.rings.real_mpfr + sage: T.segre_embedding() # needs sage.libs.singular sage.rings.real_mpfr Scheme morphism: From: Product of projective spaces P^1 x P^2 over Complex Field with 53 bits of precision @@ -1004,7 +1004,7 @@ def segre_embedding(self, PP=None, var='u'): :: sage: T = ProductProjectiveSpaces([1, 2, 1], QQ, 'z') - sage: T.segre_embedding() + sage: T.segre_embedding() # needs sage.libs.singular Scheme morphism: From: Product of projective spaces P^1 x P^2 x P^1 over Rational Field To: Closed subscheme of Projective Space of dimension 11 @@ -1088,9 +1088,9 @@ def _point(self, *args, **kwds): EXAMPLES:: sage: u = QQ['u'].0 - sage: K = NumberField(u^2 - 2, 'v') # optional - sage.rings.number_field - sage: P = ProductProjectiveSpaces([1, 2], K, 'x') # optional - sage.rings.number_field - sage: P([1, 3, u, 1, 1]) # optional - sage.rings.number_field + sage: K = NumberField(u^2 - 2, 'v') # needs sage.rings.number_field + sage: P = ProductProjectiveSpaces([1, 2], K, 'x') # needs sage.rings.number_field + sage: P([1, 3, u, 1, 1]) # needs sage.rings.number_field (1/3 : 1 , v : 1 : 1) """ return ProductProjectiveSpaces_point_field(*args, **kwds) @@ -1103,8 +1103,8 @@ def _point_homset(self, *args, **kwds): EXAMPLES:: - sage: P. = ProductProjectiveSpaces([1, 1], GF(5)) # optional - sage.rings.finite_rings - sage: P._point_homset(Spec(GF(5)), P) # optional - sage.rings.finite_rings + sage: P. = ProductProjectiveSpaces([1, 1], GF(5)) + sage: P._point_homset(Spec(GF(5)), P) Set of rational points of Product of projective spaces P^1 x P^1 over Finite Field of size 5 """ @@ -1163,8 +1163,8 @@ def points_of_bounded_height(self, **kwds): :: sage: u = QQ['u'].0 - sage: P = ProductProjectiveSpaces([1, 1], NumberField(u^2 - 2, 'v')) # optional - sage.rings.number_field - sage: sorted(list(P.points_of_bounded_height(bound=1.5))) # optional - sage.rings.number_field + sage: P = ProductProjectiveSpaces([1, 1], NumberField(u^2 - 2, 'v')) # needs sage.rings.number_field + sage: sorted(list(P.points_of_bounded_height(bound=1.5))) # needs sage.rings.number_field [(-v : 1 , -v : 1), (-v : 1 , -1 : 1), (-v : 1 , -1/2*v : 1), (-v : 1 , 0 : 1), (-v : 1 , 1/2*v : 1), (-v : 1 , 1 : 0), (-v : 1 , 1 : 1), (-v : 1 , v : 1), (-1 : 1 , -v : 1), (-1 : 1 , -1 : 1), (-1 : 1 , -1/2*v : 1), (-1 : 1 , 0 : 1), @@ -1225,8 +1225,8 @@ def _point(self, *args, **kwds): EXAMPLES:: - sage: P = ProductProjectiveSpaces([1, 2], GF(11)) # optional - sage.rings.finite_rings - sage: P([3, 7, 4, 5, 9]) # optional - sage.rings.finite_rings + sage: P = ProductProjectiveSpaces([1, 2], GF(11)) + sage: P([3, 7, 4, 5, 9]) (2 : 1 , 9 : 3 : 1) """ return ProductProjectiveSpaces_point_finite_field(*args, **kwds) @@ -1237,8 +1237,8 @@ def __iter__(self): EXAMPLES:: - sage: P = ProductProjectiveSpaces([2, 1], GF(3)) # optional - sage.rings.finite_rings - sage: [x for x in P] # optional - sage.rings.finite_rings + sage: P = ProductProjectiveSpaces([2, 1], GF(3)) + sage: [x for x in P] [(0 : 0 : 1 , 0 : 1), (0 : 1 : 1 , 0 : 1), (0 : 2 : 1 , 0 : 1), @@ -1270,8 +1270,8 @@ def rational_points(self, F=None): EXAMPLES:: - sage: P = ProductProjectiveSpaces([1, 1], GF(5)) # optional - sage.rings.finite_rings - sage: P.rational_points() # optional - sage.rings.finite_rings + sage: P = ProductProjectiveSpaces([1, 1], GF(5)) + sage: P.rational_points() [(0 : 1 , 0 : 1), (1 : 1 , 0 : 1), (2 : 1 , 0 : 1), (3 : 1 , 0 : 1), (4 : 1 , 0 : 1), (1 : 0 , 0 : 1), (0 : 1 , 1 : 1), (1 : 1 , 1 : 1), (2 : 1 , 1 : 1), (3 : 1 , 1 : 1), (4 : 1 , 1 : 1), (1 : 0 , 1 : 1), (0 : 1 , 2 : 1), (1 : 1 , 2 : 1), (2 : 1 , 2 : 1), (3 : 1 , 2 : 1), (4 : 1 , 2 : 1), (1 : 0 , 2 : 1), @@ -1281,15 +1281,13 @@ def rational_points(self, F=None): :: - sage: P = ProductProjectiveSpaces([1, 1], GF(2)) # optional - sage.rings.finite_rings - sage: P.rational_points(GF(2^2, 'a')) # optional - sage.rings.finite_rings - [(0 : 1 , 0 : 1), (a : 1 , 0 : 1), (a + 1 : 1 , 0 : 1), (1 : 1 , 0 : 1), - (1 : 0 , 0 : 1), (0 : 1 , a : 1), (a : 1 , a : 1), (a + 1 : 1 , a : 1), - (1 : 1 , a : 1), (1 : 0 , a : 1), (0 : 1 , a + 1 : 1), (a : 1 , a + 1 : 1), - (a + 1 : 1 , a + 1 : 1), (1 : 1 , a + 1 : 1), (1 : 0 , a + 1 : 1), - (0 : 1 , 1 : 1), (a : 1 , 1 : 1), (a + 1 : 1 , 1 : 1), (1 : 1 , 1 : 1), - (1 : 0 , 1 : 1), (0 : 1 , 1 : 0), (a : 1 , 1 : 0), (a + 1 : 1 , 1 : 0), - (1 : 1 , 1 : 0), (1 : 0 , 1 : 0)] + sage: P = ProductProjectiveSpaces([1, 1], GF(2)) + sage: sorted(P.rational_points(GF(2^2, 'a')), key=str) # needs sage.rings.finite_rings + [(0 : 1 , 0 : 1), (0 : 1 , 1 : 0), (0 : 1 , 1 : 1), (0 : 1 , a + 1 : 1), (0 : 1 , a : 1), + (1 : 0 , 0 : 1), (1 : 0 , 1 : 0), (1 : 0 , 1 : 1), (1 : 0 , a + 1 : 1), (1 : 0 , a : 1), + (1 : 1 , 0 : 1), (1 : 1 , 1 : 0), (1 : 1 , 1 : 1), (1 : 1 , a + 1 : 1), (1 : 1 , a : 1), + (a + 1 : 1 , 0 : 1), (a + 1 : 1 , 1 : 0), (a + 1 : 1 , 1 : 1), (a + 1 : 1 , a + 1 : 1), (a + 1 : 1 , a : 1), + (a : 1 , 0 : 1), (a : 1 , 1 : 0), (a : 1 , 1 : 1), (a : 1 , a + 1 : 1), (a : 1 , a : 1)] """ if F is None: return list(self) diff --git a/src/sage/schemes/product_projective/subscheme.py b/src/sage/schemes/product_projective/subscheme.py index 1678ab2f472..084dcfec4d2 100644 --- a/src/sage/schemes/product_projective/subscheme.py +++ b/src/sage/schemes/product_projective/subscheme.py @@ -84,14 +84,14 @@ def segre_embedding(self, PP=None): sage: Q = ((-u*w - v^2)*x^2 + ((-w^2 - u*w + (-u*v - u^2))*y + (-w^2 - u*v)*z)*x ....: + ((-w^2 - u*w - u^2)*y^2 + (-u*w - v^2)*z*y + (-w^2 + (-v - u)*w)*z^2)) sage: W = X.subscheme([L,Q]) - sage: phi = W.segre_embedding(P) - sage: phi.codomain().ambient_space() == P + sage: phi = W.segre_embedding(P) # needs sage.libs.singular + sage: phi.codomain().ambient_space() == P # needs sage.libs.singular True :: - sage: PP. = ProductProjectiveSpaces([1, 1, 1], CC) - sage: PP.subscheme([]).segre_embedding() + sage: PP. = ProductProjectiveSpaces([1, 1, 1], CC) # needs sage.rings.real_mpfr + sage: PP.subscheme([]).segre_embedding() # needs sage.libs.singular sage.rings.real_mpfr Scheme morphism: From: Closed subscheme of Product of projective spaces P^1 x P^1 x P^1 over Complex Field with 53 bits of precision defined by: @@ -107,7 +107,7 @@ def segre_embedding(self, PP=None): :: sage: PP. = ProductProjectiveSpaces([2, 1, 1], ZZ) - sage: PP.subscheme([x^3, u - v, s^2 - t^2]).segre_embedding() + sage: PP.subscheme([x^3, u - v, s^2 - t^2]).segre_embedding() # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Product of projective spaces P^2 x P^1 x P^1 over Integer Ring defined by: @@ -195,33 +195,33 @@ def dimension(self): sage: Q = ((-u*w - v^2)*x^2 + ((-w^2 - u*w + (-u*v - u^2))*y + (-w^2 - u*v)*z)*x ....: + ((-w^2 - u*w - u^2)*y^2 + (-u*w - v^2)*z*y + (-w^2 + (-v - u)*w)*z^2)) sage: W = X.subscheme([L, Q]) - sage: W.dimension() + sage: W.dimension() # needs sage.libs.singular 2 :: sage: PP. = ProductProjectiveSpaces([2, 1, 1], QQ) sage: X = PP.subscheme([x^3, x^5 + y^5, z^6, x*u - v*y, s^2 - t^2]) - sage: X.dimension() + sage: X.dimension() # needs sage.libs.singular -1 :: - sage: PP = ProductProjectiveSpaces([2, 1, 3], CC, 't') - sage: PP.subscheme([]).dimension() + sage: PP = ProductProjectiveSpaces([2, 1, 3], CC, 't') # needs sage.rings.real_mpfr + sage: PP.subscheme([]).dimension() # needs sage.libs.singular sage.rings.real_mpfr 6 :: sage: PP = ProductProjectiveSpaces([1, 3, 1], ZZ, 't') - sage: PP.subscheme([]).dimension() + sage: PP.subscheme([]).dimension() # needs sage.libs.singular 5 :: - sage: PP. = ProductProjectiveSpaces([1,1,1], CC) - sage: X = PP.subscheme([x^2 - y^2, u - v, s^2 - t^2]) - sage: X.dimension() + sage: PP. = ProductProjectiveSpaces([1,1,1], CC) # needs sage.rings.real_mpfr + sage: X = PP.subscheme([x^2 - y^2, u - v, s^2 - t^2]) # needs sage.libs.singular sage.rings.real_mpfr + sage: X.dimension() # needs sage.libs.singular sage.rings.real_mpfr 0 """ try: @@ -356,20 +356,21 @@ def intersection_multiplicity(self, X, P): sage: PP. = ProductProjectiveSpaces(QQ, [1, 1]) sage: G = PP.subscheme([(x^2 + 1/4*y^2)*v - y^2*u]) sage: D = PP.subscheme([x*v - y*u]) - sage: sorted(G.intersection(D).rational_points()) + sage: sorted(G.intersection(D).rational_points()) # needs sage.libs.singular [(1/2 : 1 , 1/2 : 1), (1 : 0 , 1 : 0)] sage: Q = PP([1/2,1,1/2,1]) - sage: G.intersection_multiplicity(D, Q) + sage: G.intersection_multiplicity(D, Q) # needs sage.libs.singular 2 :: - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: PP. = ProductProjectiveSpaces(F, [2, 2]) # optional - sage.rings.finite_rings - sage: X = PP.subscheme([z^5 + 3*x*y^4 + 8*y^5, u^2 - v^2]) # optional - sage.rings.finite_rings - sage: Y = PP.subscheme([x^6 + z^6, w*z - v*y]) # optional - sage.rings.finite_rings - sage: Q = PP([a,a+1,1,a,a,1]) # optional - sage.rings.finite_rings - sage: X.intersection_multiplicity(Y, Q) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: PP. = ProductProjectiveSpaces(F, [2, 2]) + sage: X = PP.subscheme([z^5 + 3*x*y^4 + 8*y^5, u^2 - v^2]) + sage: Y = PP.subscheme([x^6 + z^6, w*z - v*y]) + sage: Q = PP([a,a+1,1,a,a,1]) + sage: X.intersection_multiplicity(Y, Q) # needs sage.libs.singular 16 :: @@ -378,7 +379,7 @@ def intersection_multiplicity(self, X, P): sage: X = PP.subscheme([x^2*u^3 + y*z*u*v^2, x - y]) sage: Y = PP.subscheme([u^3 - w^3, x*v - y*w, z^3*w^2 - y^3*u*v]) sage: Q = PP([0,0,1,0,1,0]) - sage: X.intersection_multiplicity(Y, Q) + sage: X.intersection_multiplicity(Y, Q) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: the intersection of this subscheme and (=Closed subscheme of Affine Space of dimension 4 @@ -424,21 +425,21 @@ def multiplicity(self, P): sage: PP. = ProductProjectiveSpaces(QQ, [1, 1]) sage: X = PP.subscheme([x^4*z^3 - y^4*w^3]) sage: Q1 = PP([1,1,1,1]) - sage: X.multiplicity(Q1) + sage: X.multiplicity(Q1) # needs sage.libs.singular 1 sage: Q2 = PP([0,1,1,0]) - sage: X.multiplicity(Q2) + sage: X.multiplicity(Q2) # needs sage.libs.singular 3 :: - sage: PP. = ProductProjectiveSpaces(GF(11), [1,2]) # optional - sage.rings.finite_rings - sage: X = PP.subscheme([x^7*u - y^7*z, u^6*x^2 - w^3*z^3*x*y - w^6*y^2]) # optional - sage.rings.finite_rings - sage: Q1 = PP([1,0,10,1,0]) # optional - sage.rings.finite_rings - sage: X.multiplicity(Q1) # optional - sage.rings.finite_rings + sage: PP. = ProductProjectiveSpaces(GF(11), [1,2]) + sage: X = PP.subscheme([x^7*u - y^7*z, u^6*x^2 - w^3*z^3*x*y - w^6*y^2]) + sage: Q1 = PP([1,0,10,1,0]) + sage: X.multiplicity(Q1) # needs sage.libs.singular sage.rings.finite_rings 1 - sage: Q2 = PP([1,0,1,0,0]) # optional - sage.rings.finite_rings - sage: X.multiplicity(Q2) # optional - sage.rings.finite_rings + sage: Q2 = PP([1,0,1,0,0]) + sage: X.multiplicity(Q2) # needs sage.libs.singular sage.rings.finite_rings 4 """ PP = self.ambient_space() diff --git a/src/sage/schemes/projective/proj_bdd_height.py b/src/sage/schemes/projective/proj_bdd_height.py index c00bf2f22c3..744313fc77f 100644 --- a/src/sage/schemes/projective/proj_bdd_height.py +++ b/src/sage/schemes/projective/proj_bdd_height.py @@ -172,12 +172,13 @@ def IQ_points_of_bounded_height(PS, K, dim, bound): EXAMPLES: + sage: # needs sage.rings.number_field sage: from sage.schemes.projective.proj_bdd_height import IQ_points_of_bounded_height - sage: CF. = CyclotomicField(3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(CF, 2) # optional - sage.rings.number_field - sage: len(list(IQ_points_of_bounded_height(P, CF, 2, -1))) # optional - sage.rings.number_field + sage: CF. = CyclotomicField(3) + sage: P. = ProjectiveSpace(CF, 2) + sage: len(list(IQ_points_of_bounded_height(P, CF, 2, -1))) 0 - sage: len(list(IQ_points_of_bounded_height(P, CF, 2, 1))) # optional - sage.rings.number_field + sage: len(list(IQ_points_of_bounded_height(P, CF, 2, 1))) 57 """ if bound < 1: @@ -255,15 +256,18 @@ def points_of_bounded_height(PS, K, dim, bound, prec=53): sage: from sage.schemes.projective.proj_bdd_height import points_of_bounded_height sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^3 - 7) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: sorted(list(points_of_bounded_height(P, K, 2, 1))) # optional - sage.rings.number_field + + sage: # needs sage.geometry.polyhedron sage.libs.pari sage.rings.number_field + sage: K. = NumberField(x^3 - 7) + sage: P. = ProjectiveSpace(K, 2) + sage: sorted(list(points_of_bounded_height(P, K, 2, 1))) [(0 : 0 : 1), (0 : 1 : 0), (1 : 0 : 0), (0 : -1 : 1), (0 : 1 : 1), (-1 : 0 : 1), (1 : 0 : 1), (1 : 1 : 0), (-1 : 1 : 0), (-1 : -1 : 1), (-1 : 1 : 1), (1 : -1 : 1), (1 : 1 : 1)] :: + sage: # needs sage.geometry.polyhedron sage.libs.pari sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(3*x^2 + 1) sage: O = K.maximal_order() @@ -273,6 +277,7 @@ def points_of_bounded_height(PS, K, dim, bound, prec=53): :: + sage: # needs sage.geometry.polyhedron sage.libs.pari sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(3*x^2 + 1) sage: O = K.maximal_order() @@ -283,6 +288,7 @@ def points_of_bounded_height(PS, K, dim, bound, prec=53): :: + sage: # needs sage.geometry.polyhedron sage.libs.pari sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(x^2 - 2) sage: R2. = K[] diff --git a/src/sage/schemes/projective/projective_homset.py b/src/sage/schemes/projective/projective_homset.py index c4aa79b9f7a..770c1b0f12e 100644 --- a/src/sage/schemes/projective/projective_homset.py +++ b/src/sage/schemes/projective/projective_homset.py @@ -122,31 +122,32 @@ def points(self, **kwds): :: sage: u = QQ['u'].0 - sage: K. = NumberField(u^2 + 3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: len(P(K).points(bound=1.8)) # optional - sage.rings.number_field + sage: K. = NumberField(u^2 + 3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: len(P(K).points(bound=1.8)) # needs sage.rings.number_field 309 :: - sage: P1 = ProjectiveSpace(GF(2), 1) # optional - sage.rings.finite_rings - sage: F. = GF(4, 'a') # optional - sage.rings.finite_rings - sage: P1(F).points() # optional - sage.rings.finite_rings + sage: P1 = ProjectiveSpace(GF(2), 1) + sage: F. = GF(4, 'a') # needs sage.rings.finite_rings + sage: P1(F).points() # needs sage.libs.singular sage.rings.finite_rings [(0 : 1), (1 : 0), (1 : 1), (a : 1), (a + 1 : 1)] :: sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([(y^3-y*z^2) - (x^3-x*z^2), (y^3-y*z^2) + (x^3-x*z^2)]) - sage: E(P.base_ring()).points() + sage: E(P.base_ring()).points() # needs sage.libs.singular [(-1 : -1 : 1), (-1 : 0 : 1), (-1 : 1 : 1), (0 : -1 : 1), (0 : 0 : 1), (0 : 1 : 1), (1 : -1 : 1), (1 : 0 : 1), (1 : 1 : 1)] :: + sage: # needs sage.rings.real_mpfr sage: P. = ProjectiveSpace(CC, 2) sage: E = P.subscheme([y^3 - x^3 - x*z^2, x*y*z]) - sage: L = E(P.base_ring()).points(); sorted(L, key=str) + sage: L = E(P.base_ring()).points(); sorted(L, key=str) # needs sage.libs.singular verbose 0 (...: projective_homset.py, points) Warning: computations in the numerical fields are inexact;points may be computed partially or incorrectly. [(-0.500000000000000 + 0.866025403784439*I : 1.00000000000000 : 0.000000000000000), @@ -155,14 +156,15 @@ def points(self, **kwds): (0.000000000000000 : 0.000000000000000 : 1.00000000000000), (1.00000000000000 : 1.00000000000000 : 0.000000000000000), (1.00000000000000*I : 0.000000000000000 : 1.00000000000000)] - sage: L[0].codomain() + sage: L[0].codomain() # needs sage.libs.singular Projective Space of dimension 2 over Complex Field with 53 bits of precision :: + sage: # needs sage.rings.complex_double sage: P. = ProjectiveSpace(CDF, 2) sage: E = P.subscheme([y^2 + x^2 + z^2, x*y*z]) - sage: len(E(P.base_ring()).points()) + sage: len(E(P.base_ring()).points()) # needs sage.libs.singular verbose 0 (...: projective_homset.py, points) Warning: computations in the numerical fields are inexact;points may be computed partially or incorrectly. 6 @@ -326,33 +328,33 @@ def numerical_points(self, F=None, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([y^3 - x^3 - x*z^2, x*y*z]) - sage: L = E(QQ).numerical_points(F=RR); L + sage: L = E(QQ).numerical_points(F=RR); L # needs sage.libs.singular [(0.000000000000000 : 0.000000000000000 : 1.00000000000000), (1.00000000000000 : 1.00000000000000 : 0.000000000000000)] - sage: L[0].codomain() + sage: L[0].codomain() # needs sage.libs.singular Projective Space of dimension 2 over Real Field with 53 bits of precision :: sage: S. = QQ[] - sage: K. = NumberField(a^5 - 7, embedding=CC((7)**(1/5))) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 - v^2*z^2, y - v*z]) # optional - sage.rings.number_field - sage: len(X(K).numerical_points(F=CDF)) # optional - sage.rings.number_field + sage: K. = NumberField(a^5 - 7, embedding=CC(7)**(1/5)) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: X = P.subscheme([x^2 - v^2*z^2, y - v*z]) # needs sage.rings.number_field + sage: len(X(K).numerical_points(F=CDF)) # needs sage.libs.singular sage.rings.number_field 2 :: sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([3000*x1^50 + 9875643*x2^2*x3^48 + 12334545*x2^50, x1 + x2]) - sage: len(E(P.base_ring()).numerical_points(F=CDF, zero_tolerance=1e-6)) + sage: len(E(P.base_ring()).numerical_points(F=CDF, zero_tolerance=1e-6)) # needs sage.libs.singular 49 TESTS:: sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([y^3 - x^3 - x*z^2, x*y*z]) - sage: E(QQ).numerical_points(F=CDF, point_tolerance=-1) + sage: E(QQ).numerical_points(F=CDF, point_tolerance=-1) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: tolerance must be positive @@ -361,7 +363,7 @@ def numerical_points(self, F=None, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([y^3 - x^3 - x*z^2, x*y*z]) - sage: E(QQ).numerical_points(F=CC, zero_tolerance=-1) + sage: E(QQ).numerical_points(F=CC, zero_tolerance=-1) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: tolerance must be positive @@ -370,7 +372,7 @@ def numerical_points(self, F=None, **kwds): sage: P. = ProjectiveSpace(QQ, 2) sage: E = P.subscheme([y^3 - x^3 - x*z^2, x*y*z]) - sage: E(QQ).numerical_points(F=QQbar) + sage: E(QQ).numerical_points(F=QQbar) # needs sage.rings.number_field Traceback (most recent call last): ... TypeError: F must be a numerical field @@ -579,34 +581,35 @@ class SchemeHomset_points_abelian_variety_field(SchemeHomset_points_projective_f The bug reported at :trac:`1785` is fixed:: + sage: # needs sage.rings.number_field sage: x = polygen(ZZ, 'x') - sage: K. = NumberField(x^2 + x - (3^3-3)) # optional - sage.rings.number_field - sage: E = EllipticCurve('37a') # optional - sage.rings.number_field - sage: X = E(K) # optional - sage.rings.number_field - sage: X # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + x - (3^3-3)) + sage: E = EllipticCurve('37a') + sage: X = E(K) + sage: X Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 + (-1)*x over Number Field in a with defining polynomial x^2 + x - 24 - sage: P = X([3,a]) # optional - sage.rings.number_field - sage: P # optional - sage.rings.number_field + sage: P = X([3,a]) + sage: P (3 : a : 1) - sage: P in E # optional - sage.rings.number_field + sage: P in E False - sage: P in E.base_extend(K) # optional - sage.rings.number_field + sage: P in E.base_extend(K) True - sage: P in X.codomain() # optional - sage.rings.number_field + sage: P in X.codomain() False - sage: P in X.extended_codomain() # optional - sage.rings.number_field + sage: P in X.extended_codomain() True Check for :trac:`11982`:: sage: P2. = ProjectiveSpace(QQ,2) sage: d = 7 - sage: C = Curve(x^3 + y^3 - d*z^3) - sage: E = EllipticCurve([0,-432*d^2]) - sage: transformation = [(36*d*z-y)/(72*d),(36*d*z+y)/(72*d),x/(12*d)] - sage: phi = E.hom(transformation, C); phi + sage: C = Curve(x^3 + y^3 - d*z^3) # needs sage.schemes + sage: E = EllipticCurve([0,-432*d^2]) # needs sage.schemes + sage: transformation = [(36*d*z-y)/(72*d), (36*d*z+y)/(72*d), x/(12*d)] + sage: phi = E.hom(transformation, C); phi # needs sage.schemes Scheme morphism: From: Elliptic Curve defined by y^2 = x^3 - 21168 over Rational Field To: Projective Plane Curve over Rational Field defined by x^3 + y^3 - 7*z^3 @@ -629,6 +632,7 @@ def _element_constructor_(self, *v, **kwds): EXAMPLES:: + sage: # needs sage.schemes sage: E = EllipticCurve('37a') sage: X = E(QQ) sage: P = X([0,1,0]); P @@ -638,7 +642,7 @@ def _element_constructor_(self, *v, **kwds): TESTS:: - sage: X._element_constructor_([0,1,0]) + sage: X._element_constructor_([0,1,0]) # needs sage.schemes (0 : 1 : 0) """ if len(v) == 1: @@ -655,9 +659,9 @@ def _repr_(self): EXAMPLES:: - sage: E = EllipticCurve('37a') - sage: X = E(QQ) - sage: X._repr_() + sage: E = EllipticCurve('37a') # needs sage.schemes + sage: X = E(QQ) # needs sage.schemes + sage: X._repr_() # needs sage.schemes 'Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field' """ s = 'Abelian group of points on ' + str(self.extended_codomain()) @@ -676,6 +680,7 @@ def base_extend(self, R): EXAMPLES:: + sage: # needs sage.schemes sage: E = EllipticCurve('37a') sage: Hom = E.point_homset(); Hom Abelian group of points on Elliptic Curve defined diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index ddbaa072962..5ba47f00afa 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -110,6 +110,7 @@ class SchemeMorphism_polynomial_projective_space(SchemeMorphism_polynomial): An example of a morphism between projective plane curves (see :trac:`10297`):: + sage: # needs sage.schemes sage: P2. = ProjectiveSpace(QQ, 2) sage: f = x^3 + y^3 + 60*z^3 sage: g = y^2*z - (x^3 - 6400*z^3/3) @@ -151,7 +152,7 @@ class SchemeMorphism_polynomial_projective_space(SchemeMorphism_polynomial): ... ValueError: polys (=[x - 1, x*y + x]) must be homogeneous - sage: H([exp(x), exp(y)]) + sage: H([exp(x), exp(y)]) # needs sage.symbolic Traceback (most recent call last): ... TypeError: polys (=[e^x, e^y]) must be elements of @@ -167,7 +168,7 @@ class SchemeMorphism_polynomial_projective_space(SchemeMorphism_polynomial): sage: H = End(P) sage: f = H([(x-2*y)^2, (x-2*z)^2, x^2]) sage: X = P.subscheme(y-z) - sage: f(f(f(X))) + sage: f(f(f(X))) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: y - z @@ -177,7 +178,7 @@ class SchemeMorphism_polynomial_projective_space(SchemeMorphism_polynomial): sage: P. = ProjectiveSpace(QQ, 3) sage: H = End(P) sage: f = H([(x-2*y)^2, (x-2*z)^2, (x-2*w)^2, x^2]) - sage: f(P.subscheme([x,y,z])) + sage: f(P.subscheme([x,y,z])) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: w, @@ -211,11 +212,12 @@ def __init__(self, parent, polys, check=True): When elements of the quotient ring is used, they are reduced:: + sage: # needs sage.rings.real_mpfr sage: P. = ProjectiveSpace(CC, 2) sage: X = P.subscheme([x - y]) - sage: u,v,w = X.coordinate_ring().gens() + sage: u,v,w = X.coordinate_ring().gens() # needs sage.libs.singular sage: H = End(X) - sage: H([u^2, v^2, w*u]) + sage: H([u^2, v^2, w*u]) # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Projective Space of dimension 2 over Complex Field with 53 bits of precision defined by: x - y Defn: Defined on coordinates by sending (x : y : z) to @@ -329,7 +331,7 @@ def __call__(self, x, check=True): sage: H = End(PS) sage: f = H([y^2, x^2, w^2, z^2]) sage: X = PS.subscheme([z^2 + y*w]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: x*z - w^2 @@ -341,7 +343,7 @@ def __call__(self, x, check=True): sage: H = End(PS) sage: f = H([x^2, y^2, z^2]) sage: X = P1.subscheme([u - v]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: subscheme must be in ambient space of domain of map @@ -352,11 +354,11 @@ def __call__(self, x, check=True): sage: P1. = ProjectiveSpace(ZZ, 1) sage: H = End(P1) sage: f = H([u^2, v^2]) - sage: f([u-v]) + sage: f([u - v]) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Integer Ring defined by: u - v sage: X = PS.subscheme([x - z]) - sage: f([x-z]) + sage: f([x - z]) Traceback (most recent call last): ... TypeError: [x - z] fails to convert into the map's domain Projective Space of @@ -375,13 +377,14 @@ def __call__(self, x, check=True): Defn: Defined on coordinates by sending (u : v) to (u^2 + v^2 : u*v) - sage: F. = GF(4) # optional - sage.rings.finite_rings - sage: P = T(F)(1, a) # optional - sage.rings.finite_rings - sage: h(P) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(4) + sage: P = T(F)(1, a) + sage: h(P) # needs sage.libs.singular (a : a) - sage: h(P).domain() # optional - sage.rings.finite_rings + sage: h(P).domain() Spectrum of Finite Field in a of size 2^2 - sage: h.change_ring(F)(P) # optional - sage.rings.finite_rings + sage: h.change_ring(F)(P) (1 : 1) """ from sage.schemes.projective.projective_point import SchemeMorphism_point_projective_ring @@ -474,6 +477,7 @@ def _fast_eval(self, x): :: + sage: # needs sage.libs.pari sage.rings.real_mpfr sage: T. = PolynomialRing(CC) sage: I = T.ideal(z^3) sage: P. = ProjectiveSpace(T.quotient_ring(I), 1) @@ -485,6 +489,7 @@ def _fast_eval(self, x): :: + sage: # needs sage.rings.real_mpfr sage: T. = LaurentSeriesRing(CC) sage: R. = PolynomialRing(T) sage: P. = ProjectiveSpace(R,1) @@ -521,6 +526,7 @@ def __eq__(self, right): :: + sage: # needs sage.rings.real_mpfr sage: P. = ProjectiveSpace(QQ, 1) sage: P2. = ProjectiveSpace(CC, 1) sage: H = End(P) @@ -565,8 +571,8 @@ def __ne__(self, right): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([x^3 - 2*x^2*y, 5*x*y^2]) - sage: g = f.change_ring(GF(7)) # optional - sage.rings.finite_rings - sage: f != g # optional - sage.rings.finite_rings + sage: g = f.change_ring(GF(7)) + sage: f != g True :: @@ -600,19 +606,20 @@ def _matrix_times_polymap_(self, mat, h): sage: P. = ProjectiveSpace(ZZ, 1) sage: H = Hom(P,P) sage: f = H([x^2 + y^2, y^2]) - sage: matrix([[1,2], [0,1]]) * f + sage: matrix([[1,2], [0,1]]) * f # needs sage.modules Scheme endomorphism of Projective Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x : y) to (x^2 + 3*y^2 : y^2) :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQ, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([1/3*x^2 + 1/2*y^2, y^2]) # optional - sage.rings.number_field - sage: matrix([[i,0], [0,i]]) * f # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: P. = ProjectiveSpace(QQ, 1) + sage: H = Hom(P, P) + sage: f = H([1/3*x^2 + 1/2*y^2, y^2]) + sage: matrix([[i,0], [0,i]]) * f # needs sage.modules Scheme endomorphism of Projective Space of dimension 1 over Number Field in i with defining polynomial x^2 + 1 Defn: Defined on coordinates by sending (x : y) to @@ -644,19 +651,20 @@ def _polymap_times_matrix_(self, mat, h): sage: P. = ProjectiveSpace(ZZ, 1) sage: H = Hom(P, P) sage: f = H([x^2 + y^2, y^2]) - sage: f * matrix([[1,2], [0,1]]) + sage: f * matrix([[1,2], [0,1]]) # needs sage.modules Scheme endomorphism of Projective Space of dimension 1 over Integer Ring Defn: Defined on coordinates by sending (x : y) to (x^2 + 4*x*y + 5*y^2 : y^2) :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQ, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([1/3*x^2 + 1/2*y^2, y^2]) # optional - sage.rings.number_field - sage: f * matrix([[i,0], [0,i]]) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: P. = ProjectiveSpace(QQ, 1) + sage: H = Hom(P, P) + sage: f = H([1/3*x^2 + 1/2*y^2, y^2]) + sage: f * matrix([[i,0], [0,i]]) # needs sage.modules Scheme endomorphism of Projective Space of dimension 1 over Number Field in i with defining polynomial x^2 + 1 Defn: Defined on coordinates by sending (x : y) to @@ -688,31 +696,31 @@ def as_dynamical_system(self): sage: P. = ProjectiveSpace(ZZ, 2) sage: H = End(P) sage: f = H([x^2, y^2, z^2]) - sage: type(f.as_dynamical_system()) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) - sage: f = H([x^2-y^2, y^2]) - sage: type(f.as_dynamical_system()) + sage: f = H([x^2 - y^2, y^2]) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: - sage: P. = ProjectiveSpace(GF(5), 1) # optional - sage.rings.finite_rings - sage: H = End(P) # optional - sage.rings.finite_rings - sage: f = H([x^2, y^2]) # optional - sage.rings.finite_rings - sage: type(f.as_dynamical_system()) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 1) + sage: H = End(P) + sage: f = H([x^2, y^2]) + sage: type(f.as_dynamical_system()) # needs sage.schemes :: sage: P. = ProjectiveSpace(RR, 1) - sage: f = DynamicalSystem([x^2 + y^2, y^2], P) - sage: g = f.as_dynamical_system() - sage: g is f + sage: f = DynamicalSystem([x^2 + y^2, y^2], P) # needs sage.schemes + sage: g = f.as_dynamical_system() # needs sage.schemes + sage: g is f # needs sage.schemes True """ from sage.dynamics.arithmetic_dynamics.generic_ds import DynamicalSystem @@ -768,11 +776,11 @@ def scale_by(self, t): :: - sage: P. = ProjectiveSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme(x^2 - y^2) # optional - sage.rings.finite_rings - sage: H = Hom(X, X) # optional - sage.rings.finite_rings - sage: f = H([x^2, y^2, z^2]) # optional - sage.rings.finite_rings - sage: f.scale_by(x - y); f # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(7), 2) + sage: X = P.subscheme(x^2 - y^2) + sage: H = Hom(X, X) + sage: f = H([x^2, y^2, z^2]) + sage: f.scale_by(x - y); f # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Projective Space of dimension 2 over Finite Field of size 7 defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x : y : z) to @@ -832,11 +840,11 @@ def normalize_coordinates(self, **kwds): :: - sage: P. = ProjectiveSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme(x^2 - y^2) # optional - sage.rings.finite_rings - sage: H = Hom(X, X) # optional - sage.rings.finite_rings - sage: f = H([x^3 + x*y^2, x*y^2, x*z^2]) # optional - sage.rings.finite_rings - sage: f.normalize_coordinates(); f # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(7), 2) + sage: X = P.subscheme(x^2 - y^2) + sage: H = Hom(X, X) + sage: f = H([x^3 + x*y^2, x*y^2, x*z^2]) + sage: f.normalize_coordinates(); f # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Projective Space of dimension 2 over Finite Field of size 7 defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x : y : z) to (2*y^2 : y^2 : z^2) @@ -854,22 +862,24 @@ def normalize_coordinates(self, **kwds): :: - sage: K. = QuadraticField(5) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: f = DynamicalSystem([w*x^2 + (1/5*w)*y^2, w*y^2]) # optional - sage.rings.number_field - sage: f.normalize_coordinates(); f # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(5) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem([w*x^2 + (1/5*w)*y^2, w*y^2]) + sage: f.normalize_coordinates(); f Dynamical System of Projective Space of dimension 1 over Number Field in w with defining polynomial x^2 - 5 with w = 2.236067977499790? Defn: Defined on coordinates by sending (x : y) to (5*x^2 + y^2 : 5*y^2) :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(ZZ) - sage: K. = NumberField(t^3 - 11) # optional - sage.rings.number_field - sage: a = 7/(b - 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([a*y^2 - (a*y - x)^2, y^2]) # optional - sage.rings.number_field - sage: f.normalize_coordinates(); f # optional - sage.rings.number_field + sage: K. = NumberField(t^3 - 11) + sage: a = 7/(b - 1) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([a*y^2 - (a*y - x)^2, y^2]) + sage: f.normalize_coordinates(); f Dynamical System of Projective Space of dimension 1 over Number Field in b with defining polynomial t^3 - 11 Defn: Defined on coordinates by sending (x : y) to @@ -886,13 +896,14 @@ def normalize_coordinates(self, **kwds): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: A. = NumberField(w^2 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(A, 2) # optional - sage.rings.number_field - sage: X = P.subscheme(x^2 - y^2) # optional - sage.rings.number_field - sage: H = Hom(X, X) # optional - sage.rings.number_field - sage: f = H([(a+1)*x^3 + 2*x*y^2, 4*x*y^2, 8*x*z^2]) # optional - sage.rings.number_field - sage: f.normalize_coordinates(ideal=A.prime_above(2)); f # optional - sage.rings.number_field + sage: A. = NumberField(w^2 + 1) + sage: P. = ProjectiveSpace(A, 2) + sage: X = P.subscheme(x^2 - y^2) + sage: H = Hom(X, X) + sage: f = H([(a+1)*x^3 + 2*x*y^2, 4*x*y^2, 8*x*z^2]) + sage: f.normalize_coordinates(ideal=A.prime_above(2)); f Scheme endomorphism of Closed subscheme of Projective Space of dimension 2 over Number Field in a with defining polynomial w^2 + 1 defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x : y : z) to @@ -900,16 +911,16 @@ def normalize_coordinates(self, **kwds): We can pass in a valuation to ``valuation``:: - sage: g = H([(a+1)*x^3 + 2*x*y^2, 4*x*y^2, 8*x*z^2]) # optional - sage.rings.number_field - sage: g.normalize_coordinates(valuation=A.valuation(A.prime_above(2))) # optional - sage.rings.number_field - sage: g == f # optional - sage.rings.number_field + sage: g = H([(a+1)*x^3 + 2*x*y^2, 4*x*y^2, 8*x*z^2]) # needs sage.rings.number_field + sage: g.normalize_coordinates(valuation=A.valuation(A.prime_above(2))) # needs sage.rings.number_field + sage: g == f # needs sage.rings.number_field True :: - sage: P. = ProjectiveSpace(Qp(3), 1) # optional - sage.rings.padics - sage: f = DynamicalSystem_projective([3*x^2 + 6*y^2, 9*x*y]) # optional - sage.rings.padics - sage: f.normalize_coordinates(); f # optional - sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 1) # needs sage.rings.padics + sage: f = DynamicalSystem_projective([3*x^2 + 6*y^2, 9*x*y]) # needs sage.rings.padics + sage: f.normalize_coordinates(); f # needs sage.rings.padics Dynamical System of Projective Space of dimension 1 over 3-adic Field with capped relative precision 20 Defn: Defined on coordinates by sending (x : y) to @@ -917,6 +928,7 @@ def normalize_coordinates(self, **kwds): Check that #35797 is fixed:: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(3*x^2 + 1) sage: P. = ProjectiveSpace(K, 1) @@ -1069,6 +1081,7 @@ def degree(self): :: + sage: # needs sage.rings.real_mpfr sage: P. = ProjectiveSpace(CC, 2) sage: H = Hom(P, P) sage: f = H([x^3 + y^3, y^2*z, z*x*y]) @@ -1160,7 +1173,7 @@ def dehomogenize(self, n): sage: X = P.subscheme(x^2 - y^2) sage: H = Hom(X, X) sage: f = H([x^2, y^2, x*z]) - sage: f.dehomogenize(2) + sage: f.dehomogenize(2) # needs sage.libs.singular Scheme endomorphism of Closed subscheme of Affine Space of dimension 2 over Integer Ring defined by: x^2 - y^2 Defn: Defined on coordinates by sending (x, y) to (x, y^2/x) @@ -1175,12 +1188,13 @@ def dehomogenize(self, n): :: - sage: K. = QuadraticField(3) # optional - sage.rings.number_field - sage: O = K.ring_of_integers() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(O, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([x^2 - O(w)*y^2, y^2]) # optional - sage.rings.number_field - sage: f.dehomogenize(1) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = QuadraticField(3) + sage: O = K.ring_of_integers() + sage: P. = ProjectiveSpace(O, 1) + sage: H = End(P) + sage: f = H([x^2 - O(w)*y^2, y^2]) + sage: f.dehomogenize(1) Scheme endomorphism of Affine Space of dimension 1 over Maximal Order in Number Field in w with defining polynomial x^2 - 3 with w = 1.732050807568878? @@ -1256,7 +1270,7 @@ def is_morphism(self): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([x^2 + y^2, y^2]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular True :: @@ -1264,16 +1278,16 @@ def is_morphism(self): sage: P. = ProjectiveSpace(RR, 2) sage: H = Hom(P, P) sage: f = H([x*z - y*z, x^2 - y^2, z^2]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular False :: - sage: R. = PolynomialRing(GF(5)) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(R, 2) # optional - sage.rings.finite_rings - sage: H = Hom(P, P) # optional - sage.rings.finite_rings - sage: f = H([x*z - t*y^2, x^2 - y^2, t*z^2]) # optional - sage.rings.finite_rings - sage: f.is_morphism() # optional - sage.rings.finite_rings + sage: R. = PolynomialRing(GF(5)) + sage: P. = ProjectiveSpace(R, 2) + sage: H = Hom(P, P) + sage: f = H([x*z - t*y^2, x^2 - y^2, t*z^2]) + sage: f.is_morphism() # needs sage.libs.singular True Map that is not morphism on projective space, but is over a subscheme:: @@ -1282,7 +1296,7 @@ def is_morphism(self): sage: X = P.subscheme([x*y + y*z]) sage: H = Hom(X, X) sage: f = H([x*z - y*z, x^2 - y^2, z^2]) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular True """ @@ -1319,7 +1333,7 @@ def global_height(self, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]); - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 20.8348429892146 :: @@ -1327,7 +1341,7 @@ def global_height(self, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]); - sage: f.global_height(prec=11) + sage: f.global_height(prec=11) # needs sage.symbolic 20.8 :: @@ -1335,27 +1349,29 @@ def global_height(self, prec=None): sage: P. = ProjectiveSpace(ZZ, 2) sage: H = Hom(P, P) sage: f = H([4*x^2 + 100*y^2, 210*x*y, 10000*z^2]); - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 8.51719319141624 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: O = K.maximal_order() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(O, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + 3*O(w)*y^2, O(w)*y^2]) # optional - sage.rings.number_field - sage: f.global_height() # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: O = K.maximal_order() + sage: P. = ProjectiveSpace(O, 1) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + 3*O(w)*y^2, O(w)*y^2]) + sage: f.global_height() 1.09861228866811 :: - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: P2. = ProjectiveSpace(QQbar, 2) # optional - sage.rings.number_field - sage: H = Hom(P, P2) # optional - sage.rings.number_field - sage: f = H([x^2 + QQbar(I)*x*y + 3*y^2, y^2, QQbar(sqrt(5))*x*y]) # optional - sage.rings.number_field - sage: f.global_height() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) + sage: P2. = ProjectiveSpace(QQbar, 2) + sage: H = Hom(P, P2) + sage: f = H([x^2 + QQbar(I)*x*y + 3*y^2, y^2, QQbar(sqrt(5))*x*y]) + sage: f.global_height() 1.09861228866811 :: @@ -1364,25 +1380,25 @@ def global_height(self, prec=None): sage: A. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, A) sage: f = H([1/1331*x^2 + 4000*y*z, y^2]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 15.4877354584971 :: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([1/25*x^2 + 25/3*x*y + y^2, 1*y^2]) - sage: exp(f.global_height()) + sage: exp(f.global_height()) # needs sage.symbolic 625.000000000000 Scaling should not change the result:: sage: P. = ProjectiveSpace(QQ, 1) sage: f = DynamicalSystem([1/25*x^2 + 25/3*x*y + y^2, 1*y^2]) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 6.43775164973640 sage: c = 10000 sage: f.scale_by(c) - sage: f.global_height() + sage: f.global_height() # needs sage.symbolic 6.43775164973640 """ K = self.domain().base_ring() @@ -1422,7 +1438,7 @@ def local_height(self, v, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]) - sage: f.local_height(1331) + sage: f.local_height(1331) # needs sage.rings.real_mpfr 7.19368581839511 :: @@ -1430,7 +1446,7 @@ def local_height(self, v, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]) - sage: f.local_height(1331, prec=2) + sage: f.local_height(1331, prec=2) # needs sage.rings.real_mpfr 8.0 This function does not automatically normalize:: @@ -1438,20 +1454,21 @@ def local_height(self, v, prec=None): sage: P. = ProjectiveSpace(QQ, 2) sage: H = Hom(P, P) sage: f = H([4*x^2 + 3/100*y^2, 8/210*x*y, 1/10000*z^2]) - sage: f.local_height(2) + sage: f.local_height(2) # needs sage.rings.real_mpfr 2.77258872223978 - sage: f.normalize_coordinates() - sage: f.local_height(2) + sage: f.normalize_coordinates() # needs sage.libs.singular + sage: f.local_height(2) # needs sage.libs.singular 0.000000000000000 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) # optional - sage.rings.number_field - sage: f.local_height(K.ideal(3)) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = ProjectiveSpace(K, 1) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) + sage: f.local_height(K.ideal(3)) 1.09861228866811 """ K = FractionField(self.domain().base_ring()) @@ -1480,7 +1497,7 @@ def local_height_arch(self, i, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]) - sage: f.local_height_arch(0) + sage: f.local_height_arch(0) # needs sage.rings.real_mpfr 5.34710753071747 :: @@ -1488,17 +1505,18 @@ def local_height_arch(self, i, prec=None): sage: P. = ProjectiveSpace(QQ, 1) sage: H = Hom(P, P) sage: f = H([1/1331*x^2 + 1/4000*y^2, 210*x*y]) - sage: f.local_height_arch(0, prec=5) + sage: f.local_height_arch(0, prec=5) # needs sage.rings.real_mpfr 5.2 :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) # optional - sage.rings.number_field - sage: f.local_height_arch(1) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = ProjectiveSpace(K, 1) + sage: H = Hom(P, P) + sage: f = H([2*x^2 + w/3*y^2, 1/w*y^2]) + sage: f.local_height_arch(1) 0.6931471805599453094172321214582 """ K = FractionField(self.domain().base_ring()) @@ -1520,20 +1538,22 @@ def wronskian_ideal(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 11) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([x^2 - w*y^2, w*y^2]) # optional - sage.rings.number_field - sage: f.wronskian_ideal() # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 11) + sage: P. = ProjectiveSpace(K, 1) + sage: H = End(P) + sage: f = H([x^2 - w*y^2, w*y^2]) + sage: f.wronskian_ideal() Ideal ((4*w)*x*y) of Multivariate Polynomial Ring in x, y over Number Field in w with defining polynomial x^2 + 11 :: + sage: # needs sage.rings.number_field sage: P. = ProjectiveSpace(QQ, 1) sage: P2. = ProjectiveSpace(K, 2) - sage: H = Hom(P,P2) + sage: H = Hom(P, P2) sage: f = H([x^2 - 2*y^2, y^2, x*y]) sage: f.wronskian_ideal() Ideal (4*x*y, 2*x^2 + 4*y^2, -2*y^2) of @@ -1577,7 +1597,7 @@ def rational_preimages(self, Q, k=1): sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) sage: f = H([16*x^2 - 29*y^2, 16*y^2]) - sage: f.rational_preimages(P(-1, 4)) + sage: f.rational_preimages(P(-1, 4)) # needs sage.libs.singular [(-5/4 : 1), (5/4 : 1)] :: @@ -1587,7 +1607,7 @@ def rational_preimages(self, Q, k=1): sage: f = H([76*x^2 - 180*x*y + 45*y^2 + 14*x*z + 45*y*z - 90*z^2, ....: 67*x^2 - 180*x*y - 157*x*z + 90*y*z, ....: -90*z^2]) - sage: f.rational_preimages(P(-9, -4, 1)) + sage: f.rational_preimages(P(-9, -4, 1)) # needs sage.libs.singular [(0 : 4 : 1)] A non-periodic example :: @@ -1595,7 +1615,7 @@ def rational_preimages(self, Q, k=1): sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) sage: f = H([x^2 + y^2, 2*x*y]) - sage: f.rational_preimages(P(17, 15)) + sage: f.rational_preimages(P(17, 15)) # needs sage.libs.singular [(3/5 : 1), (5/3 : 1)] :: @@ -1605,7 +1625,7 @@ def rational_preimages(self, Q, k=1): sage: f = H([x^2 - 2*y*w - 3*w^2, -2*x^2 + y^2 - 2*x*z + 4*y*w + 3*w^2, ....: x^2 - y^2 + 2*x*z + z^2 - 2*y*w - w^2, ....: w^2]) - sage: f.rational_preimages(P(0, -1, 0, 1)) + sage: f.rational_preimages(P(0, -1, 0, 1)) # needs sage.libs.singular [] :: @@ -1613,30 +1633,32 @@ def rational_preimages(self, Q, k=1): sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) sage: f = H([x^2 + y^2, 2*x*y]) - sage: f.rational_preimages([CC.0, 1]) + sage: f.rational_preimages([CC.0, 1]) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: point must be in codomain of self A number field example :: + sage: # needs sage.rings.number_field sage: z = QQ['z'].0 - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([x^2 + y^2, y^2]) # optional - sage.rings.number_field - sage: f.rational_preimages(P(3, 1)) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = ProjectiveSpace(K, 1) + sage: H = End(P) + sage: f = H([x^2 + y^2, y^2]) + sage: f.rational_preimages(P(3, 1)) # needs sage.libs.singular [(-a : 1), (a : 1)] :: + sage: # needs sage.rings.number_field sage: z = QQ['z'].0 - sage: K. = NumberField(z^2 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 - z^2]) # optional - sage.rings.number_field - sage: H = End(X) # optional - sage.rings.number_field - sage: f= H([x^2 - z^2, a*y^2, z^2 - x^2]) # optional - sage.rings.number_field - sage: f.rational_preimages(X([1, 2, -1])) # optional - sage.rings.number_field + sage: K. = NumberField(z^2 - 2) + sage: P. = ProjectiveSpace(K, 2) + sage: X = P.subscheme([x^2 - z^2]) + sage: H = End(X) + sage: f= H([x^2 - z^2, a*y^2, z^2 - x^2]) + sage: f.rational_preimages(X([1, 2, -1])) # needs sage.libs.singular [] :: @@ -1645,7 +1667,7 @@ def rational_preimages(self, Q, k=1): sage: X = P.subscheme([x^2 - z^2]) sage: H = End(X) sage: f = H([x^2-z^2, y^2, z^2-x^2]) - sage: f.rational_preimages(X([0, 1, 0])) + sage: f.rational_preimages(X([0, 1, 0])) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - z^2, -x^2 + z^2, @@ -1657,7 +1679,7 @@ def rational_preimages(self, Q, k=1): sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) sage: f = H([x^2 - y^2, y^2]) - sage: f.rational_preimages(P.subscheme([x])) + sage: f.rational_preimages(P.subscheme([x])) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: x^2 - y^2 @@ -1666,7 +1688,7 @@ def rational_preimages(self, Q, k=1): sage: P. = ProjectiveSpace(QQ, 1) sage: H = End(P) sage: f = H([x^2 - 29/16*y^2, y^2]) - sage: f.rational_preimages(P(5/4, 1), k=4) + sage: f.rational_preimages(P(5/4, 1), k=4) # needs sage.libs.singular [(-3/4 : 1), (3/4 : 1), (-7/4 : 1), (7/4 : 1)] :: @@ -1675,7 +1697,7 @@ def rational_preimages(self, Q, k=1): sage: P2. = ProjectiveSpace(QQ, 2) sage: H = Hom(P, P2) sage: f = H([x^2, y^2, x^2-y^2]) - sage: f.rational_preimages(P2(1, 1, 0)) + sage: f.rational_preimages(P2(1, 1, 0)) # needs sage.libs.singular [(-1 : 1), (1 : 1)] """ k = ZZ(k) @@ -1727,11 +1749,12 @@ def _number_field_from_algebraics(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([QQbar(3^(1/3))*x^2 + QQbar(sqrt(-2))*y^2, y^2]) # optional - sage.rings.number_field - sage: f._number_field_from_algebraics() # optional - sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) + sage: H = End(P) + sage: f = H([QQbar(3^(1/3))*x^2 + QQbar(sqrt(-2))*y^2, y^2]) # needs sage.symbolic + sage: f._number_field_from_algebraics() # needs sage.symbolic Scheme endomorphism of Projective Space of dimension 1 over Number Field in a with defining polynomial y^6 + 6*y^4 - 6*y^3 + 12*y^2 + 36*y + 17 with a = 1.442249570307409? + 1.414213562373095?*I @@ -1742,11 +1765,12 @@ def _number_field_from_algebraics(self): :: - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: P2. = ProjectiveSpace(QQbar, 2) # optional - sage.rings.number_field - sage: H = Hom(P, P2) # optional - sage.rings.number_field - sage: f = H([x^2 + QQbar(I)*x*y + 3*y^2, y^2, QQbar(sqrt(5))*x*y]) # optional - sage.rings.number_field - sage: f._number_field_from_algebraics() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 1) + sage: P2. = ProjectiveSpace(QQbar, 2) + sage: H = Hom(P, P2) + sage: f = H([x^2 + QQbar(I)*x*y + 3*y^2, y^2, QQbar(sqrt(5))*x*y]) # needs sage.symbolic + sage: f._number_field_from_algebraics() # needs sage.symbolic Scheme morphism: From: Projective Space of dimension 1 over Number Field in a with defining polynomial y^4 + 3*y^2 + 1 @@ -1759,17 +1783,18 @@ def _number_field_from_algebraics(self): The following was fixed in :trac:`23808`:: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: s = (t^3 + t + 1).roots(QQbar)[0][0] # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: H = Hom(P, P) # optional - sage.rings.number_field - sage: f = H([s*x^3 - 13*y^3, y^3 - 15*y^3]) # optional - sage.rings.number_field - sage: f # optional - sage.rings.number_field + sage: s = (t^3 + t + 1).roots(QQbar)[0][0] + sage: P. = ProjectiveSpace(QQbar, 1) + sage: H = Hom(P, P) + sage: f = H([s*x^3 - 13*y^3, y^3 - 15*y^3]) + sage: f Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to ((-0.6823278038280193?)*x^3 + (-13)*y^3 : (-14)*y^3) - sage: f_alg = f._number_field_from_algebraics() # optional - sage.rings.number_field - sage: f_alg.change_ring(QQbar) # Used to fail # optional - sage.rings.number_field + sage: f_alg = f._number_field_from_algebraics() + sage: f_alg.change_ring(QQbar) # Used to fail Scheme endomorphism of Projective Space of dimension 1 over Algebraic Field Defn: Defined on coordinates by sending (x : y) to ((-0.6823278038280193?)*x^3 + (-13)*y^3 : (-14)*y^3) @@ -1856,7 +1881,7 @@ def base_indeterminacy_locus(self): sage: P2. = ProjectiveSpace(RR, 3) sage: H = Hom(P1, P2) sage: h = H([y^3*z^3, x^3*z^3, y^3*z^3, x^2*y^2*z^2]) - sage: h.base_indeterminacy_locus() + sage: h.base_indeterminacy_locus() # needs sage.rings.real_mpfr Closed subscheme of Projective Space of dimension 2 over Real Field with 53 bits of precision defined by: y^3*z^3, @@ -1894,7 +1919,7 @@ def indeterminacy_locus(self): sage: P. = ProjectiveSpace(QQ, 2) sage: H = End(P) sage: f = H([x^2, y^2, z^2]) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular ... DeprecationWarning: The meaning of indeterminacy_locus() has changed. Read the docstring. See https://github.com/sagemath/sage/issues/29145 for details. Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: @@ -1907,7 +1932,7 @@ def indeterminacy_locus(self): sage: P. = ProjectiveSpace(QQ, 2) sage: H = End(P) sage: f = H([x*z - y*z, x^2 - y^2, z^2]) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: z, x^2 - y^2 @@ -1951,7 +1976,7 @@ def indeterminacy_points(self, F=None, base=False): sage: P. = ProjectiveSpace(QQ, 2) sage: H = End(P) sage: f = H([x*z - y*z, x^2 - y^2, z^2]) - sage: f.indeterminacy_points() + sage: f.indeterminacy_points() # needs sage.libs.singular ... DeprecationWarning: The meaning of indeterminacy_locus() has changed. Read the docstring. See https://github.com/sagemath/sage/issues/29145 for details. [(-1 : 1 : 0), (1 : 1 : 0)] @@ -1963,10 +1988,10 @@ def indeterminacy_points(self, F=None, base=False): sage: H = Hom(P1, P2) sage: h = H([x + y, y, z + y, y]) sage: set_verbose(None) - sage: h.indeterminacy_points(base=True) + sage: h.indeterminacy_points(base=True) # needs sage.libs.singular [] sage: g = H([y^3*z^3, x^3*z^3, y^3*z^3, x^2*y^2*z^2]) - sage: g.indeterminacy_points(base=True) + sage: g.indeterminacy_points(base=True) # needs sage.libs.singular Traceback (most recent call last): ... ValueError: indeterminacy scheme is not dimension 0 @@ -1976,14 +2001,15 @@ def indeterminacy_points(self, F=None, base=False): sage: P. = ProjectiveSpace(QQ, 2) sage: H = End(P) sage: f = H([x^2 + y^2, x*z, x^2 + y^2]) - sage: f.indeterminacy_points() + sage: f.indeterminacy_points() # needs sage.libs.singular [(0 : 0 : 1)] + sage: R. = QQ[] - sage: K. = NumberField(t^2 + 1) # optional - sage.rings.number_field - sage: f.indeterminacy_points(F=K) # optional - sage.rings.number_field + sage: K. = NumberField(t^2 + 1) # needs sage.rings.number_field + sage: f.indeterminacy_points(F=K) # needs sage.libs.singular sage.rings.number_field [(-a : 1 : 0), (0 : 0 : 1), (a : 1 : 0)] sage: set_verbose(None) - sage: f.indeterminacy_points(F=QQbar, base=True) # optional - sage.rings.number_field + sage: f.indeterminacy_points(F=QQbar, base=True) # needs sage.libs.singular sage.rings.number_field [(-1*I : 1 : 0), (0 : 0 : 1), (1*I : 1 : 0)] :: @@ -1993,16 +2019,17 @@ def indeterminacy_points(self, F=None, base=False): sage: P. = ProjectiveSpace(K, 2) sage: H = End(P) sage: f = H([x^2 - t^2*y^2, y^2 - z^2, x^2 - t^2*z^2]) - sage: f.indeterminacy_points(base=True) + sage: f.indeterminacy_points(base=True) # needs sage.libs.singular [(-t : -1 : 1), (-t : 1 : 1), (t : -1 : 1), (t : 1 : 1)] :: + sage: # needs sage.rings.padics sage: set_verbose(None) - sage: P. = ProjectiveSpace(Qp(3), 2) # optional - sage.rings.padics - sage: H = End(P) # optional - sage.rings.padics - sage: f = H([x^2 - 7*y^2, y^2 - z^2, x^2 - 7*z^2]) # optional - sage.rings.padics - sage: f.indeterminacy_points(base=True) # optional - sage.rings.padics + sage: P. = ProjectiveSpace(Qp(3), 2) + sage: H = End(P) + sage: f = H([x^2 - 7*y^2, y^2 - z^2, x^2 - 7*z^2]) + sage: f.indeterminacy_points(base=True) # needs sage.libs.singular [(2 + 3 + 3^2 + 2*3^3 + 2*3^5 + 2*3^6 + 3^8 + 3^9 + 2*3^11 + 3^15 + 2*3^16 + 3^18 + O(3^20) : 1 + O(3^20) : 1 + O(3^20)), (2 + 3 + 3^2 + 2*3^3 + 2*3^5 + 2*3^6 + 3^8 + 3^9 + 2*3^11 + 3^15 @@ -2047,25 +2074,26 @@ def reduce_base_field(self): EXAMPLES:: - sage: K. = GF(3^4) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.finite_rings - sage: P2. = ProjectiveSpace(K, 2) # optional - sage.rings.finite_rings - sage: H = End(P) # optional - sage.rings.finite_rings - sage: H2 = Hom(P, P2) # optional - sage.rings.finite_rings - sage: H3 = Hom(P2, P) # optional - sage.rings.finite_rings - sage: f = H([x^2 + (2*t^3 + 2*t^2 + 1)*y^2, y^2]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF(3^4) + sage: P. = ProjectiveSpace(K, 1) + sage: P2. = ProjectiveSpace(K, 2) + sage: H = End(P) + sage: H2 = Hom(P, P2) + sage: H3 = Hom(P2, P) + sage: f = H([x^2 + (2*t^3 + 2*t^2 + 1)*y^2, y^2]) + sage: f.reduce_base_field() Scheme endomorphism of Projective Space of dimension 1 over Finite Field in t2 of size 3^2 Defn: Defined on coordinates by sending (x : y) to (x^2 + t2*y^2 : y^2) - sage: f2 = H2([x^2 + 5*y^2, y^2, 2*x*y]) # optional - sage.rings.finite_rings - sage: f2.reduce_base_field() # optional - sage.rings.finite_rings + sage: f2 = H2([x^2 + 5*y^2, y^2, 2*x*y]) + sage: f2.reduce_base_field() Scheme morphism: From: Projective Space of dimension 1 over Finite Field of size 3 To: Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y) to (x^2 - y^2 : y^2 : -x*y) - sage: f3 = H3([a^2 + t*b^2, c^2]) # optional - sage.rings.finite_rings - sage: f3.reduce_base_field() # optional - sage.rings.finite_rings + sage: f3 = H3([a^2 + t*b^2, c^2]) + sage: f3.reduce_base_field() Scheme morphism: From: Projective Space of dimension 2 over Finite Field in t of size 3^4 To: Projective Space of dimension 1 over Finite Field in t of size 3^4 @@ -2073,28 +2101,30 @@ def reduce_base_field(self): :: - sage: K. = CyclotomicField(4) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: H = End(P) # optional - sage.rings.number_field - sage: f = H([x^2 + 2*y^2, y^2]) # optional - sage.rings.number_field - sage: f.reduce_base_field() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(4) + sage: P. = ProjectiveSpace(K, 1) + sage: H = End(P) + sage: f = H([x^2 + 2*y^2, y^2]) + sage: f.reduce_base_field() Scheme endomorphism of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (x^2 + 2*y^2 : y^2) :: - sage: K. = GF(5) # optional - sage.rings.finite_rings - sage: L = K.algebraic_closure() # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(L, 1) # optional - sage.rings.finite_rings - sage: H = End(P) # optional - sage.rings.finite_rings - sage: f = H([(L.gen(2))*x^2 + L.gen(4)*y^2, x*y]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: K. = GF(5) + sage: L = K.algebraic_closure() + sage: P. = ProjectiveSpace(L, 1) + sage: H = End(P) + sage: f = H([(L.gen(2))*x^2 + L.gen(4)*y^2, x*y]) + sage: f.reduce_base_field() Scheme endomorphism of Projective Space of dimension 1 over Finite Field in z4 of size 5^4 Defn: Defined on coordinates by sending (x : y) to ((z4^3 + z4^2 + z4 - 2)*x^2 + z4*y^2 : x*y) - sage: f = DynamicalSystem_projective([L.gen(3)*x^2 + L.gen(2)*y^2, x*y]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: f = DynamicalSystem_projective([L.gen(3)*x^2 + L.gen(2)*y^2, x*y]) + sage: f.reduce_base_field() Dynamical System of Projective Space of dimension 1 over Finite Field in z6 of size 5^6 Defn: Defined on coordinates by sending (x : y) to @@ -2103,11 +2133,12 @@ def reduce_base_field(self): TESTS:: - sage: F = GF(3).algebraic_closure() # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 1) # optional - sage.rings.finite_rings - sage: H = Hom(P, P) # optional - sage.rings.finite_rings - sage: f = H([x^2 + y^2, y^2]) # optional - sage.rings.finite_rings - sage: f.reduce_base_field() # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(3).algebraic_closure() + sage: P. = ProjectiveSpace(F, 1) + sage: H = Hom(P, P) + sage: f = H([x^2 + y^2, y^2]) + sage: f.reduce_base_field() Scheme endomorphism of Projective Space of dimension 1 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y) to (x^2 + y^2 : y^2) @@ -2219,11 +2250,11 @@ def image(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: f = P2.hom([x0^3, x0^2*x1, x0*x1^2], P2) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x1^2 - x0*x2 sage: f = P2.hom([x0 - x1, x0 - x2, x1 - x2], P2) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x0 - x1 + x2 @@ -2232,7 +2263,7 @@ def image(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: A2. = AffineSpace(QQ, 2) sage: f = P2.hom([1, x0/x1], A2) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: -x + 1 """ @@ -2249,10 +2280,10 @@ def _fast_eval(self, x): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: H = Hom(P, P) # optional - sage.rings.finite_rings - sage: f = H([x^2 + y^2, y^2, z^2 + y*z]) # optional - sage.rings.finite_rings - sage: f._fast_eval([1,1,1]) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(7), 2) + sage: H = Hom(P, P) + sage: f = H([x^2 + y^2, y^2, z^2 + y*z]) + sage: f._fast_eval([1,1,1]) [2, 1, 2] """ if self._is_prime_finite_field: @@ -2279,6 +2310,7 @@ def __call__(self, x): TESTS:: + sage: # needs sage.schemes sage: R. = QQ[] sage: C = Curve(7*x^2 + 2*y*z + z^2) sage: f, g = C.parametrization() @@ -2309,11 +2341,12 @@ def __eq__(self, other): EXAMPLES:: sage: R. = QQ[] - sage: C = Curve(7*x^2 + 2*y*z + z^2) # conic - sage: f, g = C.parametrization() - sage: f*g == C.identity_morphism() + sage: C = Curve(7*x^2 + 2*y*z + z^2) # conic # needs sage.schemes + sage: f, g = C.parametrization() # needs sage.schemes + sage: f*g == C.identity_morphism() # needs sage.schemes True + sage: # needs sage.schemes sage: C = Curve(x^2 + y^2 - z^2) sage: P. = ProjectiveSpace(QQ, 1) sage: f = C.hom([x + z, y], P) @@ -2349,7 +2382,7 @@ def representatives(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: X = P2.subscheme(0) sage: f = X.hom([x^2*y, x^2*z, x*y*z], P2) - sage: f.representatives() + sage: f.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: 0 @@ -2362,7 +2395,7 @@ def representatives(self): sage: P1. = ProjectiveSpace(QQ, 1) sage: X = P2.subscheme([x^2 - y^2 - y*z]) sage: f = X.hom([x, y], P1) - sage: f.representatives() + sage: f.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y*z @@ -2373,8 +2406,8 @@ def representatives(self): over Rational Field defined by: x^2 - y^2 - y*z To: Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y : z) to (x : y)] - sage: g = _[0] - sage: g.representatives() + sage: g = _[0] # needs sage.libs.singular + sage: g.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y*z @@ -2392,7 +2425,7 @@ def representatives(self): sage: X = P2.subscheme([x^2 - y^2 - y*z]) sage: A1. = AffineSpace(QQ, 1) sage: g = X.hom([y/x], A1) - sage: g.representatives() + sage: g.representatives() # needs sage.libs.singular [Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y*z @@ -2403,15 +2436,15 @@ def representatives(self): over Rational Field defined by: x^2 - y^2 - y*z To: Affine Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y : z) to (y/x)] - sage: g0, g1 = _ + sage: g0, g1 = _ # needs sage.libs.singular sage: emb = A1.projective_embedding(0) - sage: emb*g0 + sage: emb*g0 # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y*z To: Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y : z) to (y + z : x) - sage: emb*g1 + sage: emb*g1 # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^2 - y^2 - y*z @@ -2497,8 +2530,8 @@ def indeterminacy_locus(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: X = P2.subscheme(0) sage: f = X.hom([x1,x0], P) - sage: L = f.indeterminacy_locus() - sage: L.rational_points() + sage: L = f.indeterminacy_locus() # needs sage.libs.singular + sage: L.rational_points() # needs sage.libs.singular [(0 : 0 : 1)] :: @@ -2507,7 +2540,7 @@ def indeterminacy_locus(self): sage: P1. = ProjectiveSpace(QQ, 1) sage: X = P2.subscheme([x^2 - y^2 - y*z]) sage: f = X.hom([x,y], P1) - sage: f.indeterminacy_locus() + sage: f.indeterminacy_locus() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: z, y, @@ -2519,12 +2552,12 @@ def indeterminacy_locus(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: X = P3.subscheme(x^2 - w*y - x*z) sage: f = X.hom([x*y, y*z, z*x], P2) - sage: L = f.indeterminacy_locus() - sage: L.dimension() + sage: L = f.indeterminacy_locus() # needs sage.libs.singular + sage: L.dimension() # needs sage.libs.singular 0 - sage: L.degree() + sage: L.degree() # needs sage.libs.singular 2 - sage: L.rational_points() + sage: L.rational_points() # needs sage.libs.singular [(0 : 0 : 0 : 1), (0 : 1 : 0 : 0)] :: @@ -2533,8 +2566,8 @@ def indeterminacy_locus(self): sage: A2. = AffineSpace(QQ, 2) sage: X = P3.subscheme(x^2 - w*y - x*z) sage: f = X.hom([x/z, y/x], A2) - sage: L = f.indeterminacy_locus() - sage: L.rational_points() + sage: L = f.indeterminacy_locus() # needs sage.libs.singular + sage: L.rational_points() # needs sage.libs.singular [(0 : 0 : 0 : 1), (0 : 1 : 0 : 0)] :: @@ -2543,7 +2576,7 @@ def indeterminacy_locus(self): sage: X = P.subscheme(x - y) sage: H = End(X) sage: f = H([x^2 - 4*y^2, y^2 - z^2, 4*z^2 - x^2]) - sage: Z = f.indeterminacy_locus(); Z + sage: Z = f.indeterminacy_locus(); Z # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: z, y, @@ -2589,7 +2622,7 @@ def is_morphism(self): sage: P1. = ProjectiveSpace(QQ, 1) sage: X = P2.subscheme([x^2 - y^2 - y*z]) sage: f = X.hom([x,y], P1) - sage: f.is_morphism() + sage: f.is_morphism() # needs sage.libs.singular True """ return self.indeterminacy_locus().dimension() < 0 @@ -2604,7 +2637,7 @@ def image(self): sage: P2. = ProjectiveSpace(QQ, 2) sage: X = P2.subscheme(0) sage: f = X.hom([x1,x0], P) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: (no polynomials) @@ -2613,7 +2646,7 @@ def image(self): sage: P2. = ProjectiveSpace(QQ,2) sage: X = P2.subscheme([z^3 - x*y^2 + y^3]) sage: f = X.hom([x*z, x*y, x^2 + y*z], P2) - sage: f.image() + sage: f.image() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^6 + 2*x^3*y^3 + x*y^5 + y^6 - x^3*y^2*z - y^5*z """ @@ -2665,11 +2698,11 @@ def graph(self): sage: A1. = AffineSpace(1, QQ) sage: X = A1.subscheme(0) # affine line sage: phi = X.hom([x^2], A1) - sage: mor = phi.homogenize(0) - sage: G = mor.graph(); G + sage: mor = phi.homogenize(0) # needs sage.libs.singular + sage: G = mor.graph(); G # needs sage.libs.singular Closed subscheme of Product of projective spaces P^1 x P^1 over Rational Field defined by: x1^2*x2 - x0^2*x3 - sage: G.affine_patch([0, 0]) + sage: G.affine_patch([0, 0]) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: x0^2 - x1 """ @@ -2717,12 +2750,13 @@ def projective_degrees(self): EXAMPLES:: - sage: k = GF(11) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,1]) # optional - sage.rings.finite_rings - sage: Q = E(6, 5) # optional - sage.rings.finite_rings - sage: phi = E.scalar_multiplication(2) # optional - sage.rings.finite_rings - sage: mor = phi.as_morphism() # optional - sage.rings.finite_rings - sage: mor.projective_degrees() # optional - sage.rings.finite_rings + sage: # needs sage.schemes + sage: k = GF(11) + sage: E = EllipticCurve(k, [1,1]) + sage: Q = E(6, 5) + sage: phi = E.scalar_multiplication(2) + sage: mor = phi.as_morphism() + sage: mor.projective_degrees() (12, 3) """ X = self.domain() @@ -2759,12 +2793,13 @@ def degree(self): EXAMPLES:: - sage: k = GF(11) # optional - sage.rings.finite_rings - sage: E = EllipticCurve(k, [1,1]) # optional - sage.rings.finite_rings - sage: Q = E(6, 5) # optional - sage.rings.finite_rings - sage: phi = E.scalar_multiplication(2) # optional - sage.rings.finite_rings - sage: mor = phi.as_morphism() # optional - sage.rings.finite_rings - sage: mor.degree() # optional - sage.rings.finite_rings + sage: # needs sage.schemes + sage: k = GF(11) + sage: E = EllipticCurve(k, [1,1]) + sage: Q = E(6, 5) + sage: phi = E.scalar_multiplication(2) + sage: mor = phi.as_morphism() + sage: mor.degree() 4 """ return self.projective_degrees()[0] // self.image().degree() diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py index 05675ce2cc6..a8a24adb27a 100644 --- a/src/sage/schemes/projective/projective_point.py +++ b/src/sage/schemes/projective/projective_point.py @@ -139,8 +139,8 @@ def __init__(self, X, v, check=True): :: sage: R. = PolynomialRing(ZZ) - sage: P = ProjectiveSpace(1, R.quo(t^2 + 1)) - sage: P([2*t, 1]) + sage: P = ProjectiveSpace(1, R.quo(t^2 + 1)) # needs sage.libs.pari + sage: P([2*t, 1]) # needs sage.libs.pari (2*tbar : 1) :: @@ -236,9 +236,10 @@ def _richcmp_(self, right, op): :: - sage: PS = ProjectiveSpace(Zp(5), 1, 'x') # optional - sage.rings.padics - sage: P = PS([0, 1]) # optional - sage.rings.padics - sage: P == PS(0) # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: PS = ProjectiveSpace(Zp(5), 1, 'x') + sage: P = PS([0, 1]) + sage: P == PS(0) True :: @@ -261,9 +262,9 @@ def _richcmp_(self, right, op): sage: PS = ProjectiveSpace(ZZ, 1, 'x') sage: P = PS([2, 1]) - sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # optional - sage.rings.padics - sage: Q = PS2([2, 1]) # optional - sage.rings.padics - sage: P == Q # optional - sage.rings.padics + sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # needs sage.rings.padics + sage: Q = PS2([2, 1]) # needs sage.rings.padics + sage: P == Q # needs sage.rings.padics True :: @@ -284,20 +285,23 @@ def _richcmp_(self, right, op): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(z^2 + 5) # optional - sage.rings.number_field - sage: OK = K.ring_of_integers() # optional - sage.rings.number_field - sage: t = OK.gen(1) # optional - sage.rings.number_field - sage: PS. = ProjectiveSpace(OK, 1) # optional - sage.rings.number_field - sage: P = PS(2, 1 + t) # optional - sage.rings.number_field - sage: Q = PS(1 - t, 3) # optional - sage.rings.number_field - sage: P == Q # optional - sage.rings.number_field + sage: K. = NumberField(z^2 + 5) + sage: OK = K.ring_of_integers() + sage: t = OK.gen(1) + sage: PS. = ProjectiveSpace(OK, 1) + sage: P = PS(2, 1 + t) + sage: Q = PS(1 - t, 3) + sage: P == Q True Check that :trac:`17429` is fixed:: + sage: # needs sage.rings.complex_interval_field sage: R. = PolynomialRing(QQ) - sage: r = (x^2 - x - 3).polynomial(x).roots(ComplexIntervalField(), multiplicities=False) + sage: r = (x^2 - x - 3).polynomial(x).roots(ComplexIntervalField(), + ....: multiplicities=False) sage: P. = ProjectiveSpace(ComplexIntervalField(), 1) sage: P1 = P(r[0], 1) sage: H = End(P) @@ -324,9 +328,10 @@ def _richcmp_(self, right, op): :: - sage: PS = ProjectiveSpace(Zp(5), 1, 'x') # optional - sage.rings.padics - sage: P = PS([0, 1]) # optional - sage.rings.padics - sage: P != PS(0) # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: PS = ProjectiveSpace(Zp(5), 1, 'x') + sage: P = PS([0, 1]) + sage: P != PS(0) False :: @@ -349,9 +354,9 @@ def _richcmp_(self, right, op): sage: PS = ProjectiveSpace(ZZ, 1, 'x') sage: P = PS([2, 1]) - sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # optional - sage.rings.padics - sage: Q = PS2([2, 1]) # optional - sage.rings.padics - sage: P != Q # optional - sage.rings.padics + sage: PS2 = ProjectiveSpace(Zp(7), 1, 'x') # needs sage.rings.padics + sage: Q = PS2([2, 1]) # needs sage.rings.padics + sage: P != Q # needs sage.rings.padics False :: @@ -396,11 +401,12 @@ def __hash__(self): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 3) # optional - sage.rings.number_field - sage: O = K.maximal_order() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(O, 1) # optional - sage.rings.number_field - sage: hash(P([1 + w, 2])) == hash(P([2, 1 - w])) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 3) + sage: O = K.maximal_order() + sage: P. = ProjectiveSpace(O, 1) + sage: hash(P([1 + w, 2])) == hash(P([2, 1 - w])) True TESTS:: @@ -441,8 +447,8 @@ def _matrix_times_point_(self, mat, dom): sage: P = ProjectiveSpace(QQ, 1) sage: Q = P(1,1) - sage: m = matrix(QQ, 2, 2, [1,1, 0,1]) - sage: m*Q + sage: m = matrix(QQ, 2, 2, [1,1, 0,1]) # needs sage.modules + sage: m*Q # needs sage.modules (2 : 1) :: @@ -450,25 +456,26 @@ def _matrix_times_point_(self, mat, dom): sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme(x - y) sage: Q = X(1,1) - sage: m = matrix(CC, 3, 3, [1,CC.0,0, CC.0,1,0, 1,1,1]) - sage: m*Q + sage: m = matrix(CC, 3, 3, [1,CC.0,0, CC.0,1,0, 1,1,1]) # needs sage.modules + sage: m*Q # needs sage.modules (0.333333333333333 + 0.333333333333333*I : 0.333333333333333 + 0.333333333333333*I : 1.00000000000000) :: - sage: P = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: Q = P(QQbar(sqrt(2)),1) # optional - sage.rings.number_field sage.symbolic - sage: m = matrix(ZZ, 2, 2, [1,-1, 0,1]) # optional - sage.rings.number_field sage.symbolic - sage: m*Q # optional - sage.rings.number_field sage.symbolic + sage: # needs sage.modules sage.rings.number_field sage.symbolic + sage: P = ProjectiveSpace(QQbar, 1) + sage: Q = P(QQbar(sqrt(2)),1) + sage: m = matrix(ZZ, 2, 2, [1,-1, 0,1]) + sage: m*Q (0.4142135623730951? : 1) :: sage: P = ProjectiveSpace(QQ, 1) sage: Q = P(1,1) - sage: m = matrix(QQ, 3, 2, [1,1, 0,1, 1,1]) - sage: m*Q + sage: m = matrix(QQ, 3, 2, [1,1, 0,1, 1,1]) # needs sage.modules + sage: m*Q # needs sage.modules Traceback (most recent call last): ... ValueError: matrix must be square @@ -504,6 +511,7 @@ def scale_by(self,t): :: + sage: # needs sage.libs.pari sage: R. = PolynomialRing(QQ) sage: S = R.quo(R.ideal(t^3)) sage: P. = ProjectiveSpace(S, 2) @@ -546,9 +554,10 @@ def normalize_coordinates(self): :: - sage: P = ProjectiveSpace(Zp(7), 2, 'x') # optional - sage.rings.padics - sage: p = P([-5, -15, -2]) # optional - sage.rings.padics - sage: p.normalize_coordinates(); p # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: P = ProjectiveSpace(Zp(7), 2, 'x') + sage: p = P([-5, -15, -2]) + sage: p.normalize_coordinates(); p (5 + O(7^20) : 1 + 2*7 + O(7^20) : 2 + O(7^20)) :: @@ -586,6 +595,7 @@ def normalize_coordinates(self): :: + sage: # needs sage.libs.singular sage: R. = PolynomialRing(QQ, 1) sage: S = R.quotient_ring(R.ideal(t^3)) sage: P. = ProjectiveSpace(S, 1) @@ -641,11 +651,12 @@ def dehomogenize(self,n): sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme(x^2 - y^2) sage: Q = X(23, 23, 46) - sage: Q.dehomogenize(2) + sage: Q.dehomogenize(2) # needs sage.libs.singular (1/2, 1/2) :: + sage: # needs sage.libs.pari sage: R. = PolynomialRing(QQ) sage: S = R.quo(R.ideal(t^3)) sage: P. = ProjectiveSpace(S, 2) @@ -655,16 +666,16 @@ def dehomogenize(self,n): :: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: Q = P(1, 3, 1) # optional - sage.rings.finite_rings - sage: Q.dehomogenize(0) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: Q = P(1, 3, 1) + sage: Q.dehomogenize(0) (3, 1) :: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: Q = P(1, 3, 0) # optional - sage.rings.finite_rings - sage: Q.dehomogenize(2) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: Q = P(1, 3, 0) + sage: Q.dehomogenize(2) Traceback (most recent call last): ... ValueError: can...t dehomogenize at 0 coordinate @@ -696,49 +707,50 @@ def global_height(self, prec=None): sage: P. = ProjectiveSpace(QQ, 2) sage: Q = P.point([4, 4, 1/30]) - sage: Q.global_height() + sage: Q.global_height() # needs sage.symbolic 4.78749174278205 :: sage: P. = ProjectiveSpace(ZZ, 2) sage: Q = P([4, 1, 30]) - sage: Q.global_height() + sage: Q.global_height() # needs sage.symbolic 3.40119738166216 :: sage: R. = PolynomialRing(QQ) - sage: k. = NumberField(x^2 + 5) # optional - sage.rings.number_field - sage: A = ProjectiveSpace(k, 2, 'z') # optional - sage.rings.number_field - sage: A([3, 5*w + 1, 1]).global_height(prec=100) # optional - sage.rings.number_field + sage: k. = NumberField(x^2 + 5) # needs sage.rings.number_field + sage: A = ProjectiveSpace(k, 2, 'z') # needs sage.rings.number_field + sage: A([3, 5*w + 1, 1]).global_height(prec=100) # needs sage.rings.number_field 2.4181409534757389986565376694 :: - sage: P. = ProjectiveSpace(QQbar, 2) # optional - sage.rings.number_field - sage: Q = P([QQbar(sqrt(3)), QQbar(sqrt(-2)), 1]) # optional - sage.rings.number_field - sage: Q.global_height() # optional - sage.rings.number_field + sage: P. = ProjectiveSpace(QQbar, 2) # needs sage.rings.number_field + sage: Q = P([QQbar(sqrt(3)), QQbar(sqrt(-2)), 1]) # needs sage.rings.number_field + sage: Q.global_height() # needs sage.rings.number_field 0.549306144334055 :: - sage: K = UniversalCyclotomicField() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: Q = P.point([K(4/3), K.gen(7), K.gen(5)]) # optional - sage.rings.number_field - sage: Q.global_height() # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K = UniversalCyclotomicField() + sage: P. = ProjectiveSpace(K, 2) + sage: Q = P.point([K(4/3), K.gen(7), K.gen(5)]) + sage: Q.global_height() 1.38629436111989 TESTS:: sage: P = ProjectiveSpace(QQ, 2) - sage: P(1/1, 2/3, 5/8).global_height() + sage: P(1/1, 2/3, 5/8).global_height() # needs sage.symbolic 3.17805383034795 sage: x = polygen(QQ, 'x') - sage: F. = NumberField(x^3 - 5) # optional - sage.rings.number_field - sage: P = ProjectiveSpace(F, 2) # optional - sage.rings.number_field - sage: P(u, u^2/5, 1).global_height() # optional - sage.rings.number_field + sage: F. = NumberField(x^3 - 5) # needs sage.rings.number_field + sage: P = ProjectiveSpace(F, 2) # needs sage.rings.number_field + sage: P(u, u^2/5, 1).global_height() # needs sage.rings.number_field 1.07295860828940 """ if prec is None: @@ -788,14 +800,14 @@ def local_height(self, v, prec=None): sage: P. = ProjectiveSpace(QQ, 2) sage: Q = P.point([4, 4, 1/150], False) - sage: Q.local_height(5) + sage: Q.local_height(5) # needs sage.rings.real_mpfr 3.21887582486820 :: sage: P. = ProjectiveSpace(QQ, 2) sage: Q = P([4, 1, 30]) - sage: Q.local_height(2) + sage: Q.local_height(2) # needs sage.rings.real_mpfr 0.693147180559945 """ K = FractionField(self.domain().base_ring()) @@ -822,14 +834,15 @@ def local_height_arch(self, i, prec=None): sage: P. = ProjectiveSpace(QQ, 2) sage: Q = P.point([4, 4, 1/150], False) - sage: Q.local_height_arch(0) + sage: Q.local_height_arch(0) # needs sage.rings.real_mpfr 1.38629436111989 :: - sage: P. = ProjectiveSpace(QuadraticField(5, 'w'), 2) # optional - sage.rings.number_field - sage: Q = P.point([4, 1, 30], False) # optional - sage.rings.number_field - sage: Q.local_height_arch(1) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: P. = ProjectiveSpace(QuadraticField(5, 'w'), 2) + sage: Q = P.point([4, 1, 30], False) + sage: Q.local_height_arch(1) 3.401197381662155375413236691607 """ K = FractionField(self.domain().base_ring()) @@ -862,9 +875,9 @@ def multiplier(self, f, n, check=True): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 3) - sage: f = DynamicalSystem_projective([x^2, y^2, 4*w^2, 4*z^2], domain=P) + sage: f = DynamicalSystem_projective([x^2, y^2, 4*w^2, 4*z^2], domain=P) # needs sage.schemes sage: Q = P.point([4, 4, 1, 1], False) - sage: Q.multiplier(f, 1) + sage: Q.multiplier(f, 1) # needs sage.schemes [ 2 0 -8] [ 0 2 -8] [ 0 0 -2] @@ -919,103 +932,106 @@ def is_preperiodic(self, f, err=0.1, return_period=False): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([x^3 - 3*x*y^2, y^3], domain=P) + sage: f = DynamicalSystem_projective([x^3 - 3*x*y^2, y^3], domain=P) # needs sage.schemes sage: Q = P(-1, 1) - sage: Q.is_preperiodic(f) + sage: Q.is_preperiodic(f) # needs sage.libs.singular sage.schemes True :: sage: P. = ProjectiveSpace(QQ, 2) sage: X = P.subscheme(z) - sage: f = DynamicalSystem([x^2 - y^2, y^2, z^2], domain=X) + sage: f = DynamicalSystem([x^2 - y^2, y^2, z^2], domain=X) # needs sage.schemes sage: p = X((-1, 1, 0)) - sage: p.is_preperiodic(f, return_period=True) + sage: p.is_preperiodic(f, return_period=True) # needs sage.libs.singular sage.schemes (0, 2) :: sage: P. = ProjectiveSpace(QQ,1) - sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2], domain=P) + sage: f = DynamicalSystem_projective([x^2 - 29/16*y^2, y^2], domain=P) # needs sage.schemes sage: Q = P(1, 4) - sage: Q.is_preperiodic(f, return_period=True) + sage: Q.is_preperiodic(f, return_period=True) # needs sage.libs.singular sage.schemes (1, 3) sage: Q = P(1, 1) - sage: Q.is_preperiodic(f, return_period=True) + sage: Q.is_preperiodic(f, return_period=True) # needs sage.libs.singular sage.schemes (0, 0) :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([x^5 + 5/4*x*y^4, y^5], domain=P) # optional - sage.rings.number_field - sage: Q = P([-1/2*a + 1/2, 1]) # optional - sage.rings.number_field - sage: Q.is_preperiodic(f) # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: P. = ProjectiveSpace(K, 1) + sage: f = DynamicalSystem_projective([x^5 + 5/4*x*y^4, y^5], domain=P) # needs sage.schemes + sage: Q = P([-1/2*a + 1/2, 1]) + sage: Q.is_preperiodic(f) # needs sage.schemes True - sage: Q = P([a, 1]) # optional - sage.rings.number_field - sage: Q.is_preperiodic(f) # optional - sage.rings.number_field + sage: Q = P([a, 1]) + sage: Q.is_preperiodic(f) # needs sage.schemes False :: sage: P. = ProjectiveSpace(QQ, 2) - sage: f = DynamicalSystem_projective([ + sage: f = DynamicalSystem_projective([ # needs sage.schemes ....: -38/45*x^2 + (2*y - 7/45*z)*x + (-1/2*y^2 - 1/2*y*z + z^2), ....: -67/90*x^2 + (2*y + z*157/90)*x - y*z, ....: z^2 ....: ], domain=P) sage: Q = P([1, 3, 1]) - sage: Q.is_preperiodic(f, return_period=True) + sage: Q.is_preperiodic(f, return_period=True) # needs sage.libs.singular sage.schemes (0, 9) :: sage: P. = ProjectiveSpace(QQ, 3) - sage: f = DynamicalSystem_projective([ + sage: f = DynamicalSystem_projective([ # needs sage.schemes ....: (-y - w)*x + (-13/30*y^2 + 13/30*w*y + w^2), ....: -1/2*x^2 + (-y + 3/2*w)*x + (-1/3*y^2 + 4/3*w*y), ....: -3/2*z^2 + 5/2*z*w + w^2, ....: w^2 ....: ], domain=P) sage: Q = P([3,0,4/3,1]) - sage: Q.is_preperiodic(f, return_period=True) + sage: Q.is_preperiodic(f, return_period=True) # needs sage.libs.singular sage.schemes (2, 24) :: + sage: # needs sage.rings.number_field sage.schemes sage.symbolic sage: from sage.misc.verbose import set_verbose sage: set_verbose(-1) - sage: P. = ProjectiveSpace(QQbar, 2) # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2, QQbar(sqrt(-1))*y^2, z^2], # optional - sage.rings.number_field sage.symbolic + sage: P. = ProjectiveSpace(QQbar, 2) + sage: f = DynamicalSystem_projective([x^2, QQbar(sqrt(-1))*y^2, z^2], ....: domain=P) - sage: Q = P([1, 1, 1]) # optional - sage.rings.number_field sage.symbolic - sage: Q.is_preperiodic(f) # optional - sage.rings.number_field sage.symbolic + sage: Q = P([1, 1, 1]) + sage: Q.is_preperiodic(f) True :: + sage: # needs sage.rings.number_field sage.schemes sage.symbolic sage: set_verbose(-1) - sage: P. = ProjectiveSpace(QQbar, 2) # optional - sage.rings.number_field - sage: f = DynamicalSystem_projective([x^2, y^2, z^2], domain=P) # optional - sage.rings.number_field - sage: Q = P([QQbar(sqrt(-1)), 1, 1]) # optional - sage.rings.number_field sage.symbolic - sage: Q.is_preperiodic(f) # optional - sage.rings.number_field sage.symbolic + sage: P. = ProjectiveSpace(QQbar, 2) + sage: f = DynamicalSystem_projective([x^2, y^2, z^2], domain=P) + sage: Q = P([QQbar(sqrt(-1)), 1, 1]) + sage: Q.is_preperiodic(f) True :: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2], domain=P) + sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2], domain=P) # needs sage.schemes sage: Q = P(-1,4) - sage: Q.is_preperiodic(f) + sage: Q.is_preperiodic(f) # needs sage.libs.singular sage.schemes True :: - sage: P. = ProjectiveSpace(GF(3), 2) # optional - sage.rings.finite_rings - sage: F = DynamicalSystem([x^2 - 2*y^2, y^2, z^2]) # optional - sage.rings.finite_rings - sage: Q = P(1, 1, 1) # optional - sage.rings.finite_rings - sage: Q.is_preperiodic(F, return_period=True) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(3), 2) + sage: F = DynamicalSystem([x^2 - 2*y^2, y^2, z^2]) # needs sage.schemes + sage: Q = P(1, 1, 1) + sage: Q.is_preperiodic(F, return_period=True) # needs sage.schemes (1, 1) TESTS:: @@ -1032,9 +1048,9 @@ def is_preperiodic(self, f, err=0.1, return_period=False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) + sage: f = DynamicalSystem_projective([16*x^2 - 29*y^2, 16*y^2]) # needs sage.schemes sage: Q = P(11,4) - sage: Q.is_preperiodic(f, err=2) + sage: Q.is_preperiodic(f, err=2) # needs sage.libs.singular sage.schemes False """ try: @@ -1098,9 +1114,9 @@ def __init__(self, X, v, check=True): :: - sage: P = ProjectiveSpace(1, GF(7)) # optional - sage.rings.finite_rings - sage: Q = P([2, 1]) # optional - sage.rings.finite_rings - sage: Q[0].parent() # optional - sage.rings.finite_rings + sage: P = ProjectiveSpace(1, GF(7)) + sage: Q = P([2, 1]) + sage: Q[0].parent() Finite Field of size 7 :: @@ -1192,10 +1208,10 @@ def normalize_coordinates(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: Q = P.point([GF(5)(1), GF(5)(3), GF(5)(0)], False); Q # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: Q = P.point([GF(5)(1), GF(5)(3), GF(5)(0)], False); Q (1 : 3 : 0) - sage: Q.normalize_coordinates(); Q # optional - sage.rings.finite_rings + sage: Q.normalize_coordinates(); Q (2 : 1 : 0) :: @@ -1223,27 +1239,29 @@ def _number_field_from_algebraics(self): EXAMPLES:: + sage: # needs sage.rings.number_field sage.symbolic sage: R. = PolynomialRing(QQ) - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: Q = P([-1/2*QQbar(sqrt(2)) + QQbar(I), 1]) # optional - sage.rings.number_field sage.symbolic - sage: S = Q._number_field_from_algebraics(); S # optional - sage.rings.number_field sage.symbolic + sage: P. = ProjectiveSpace(QQbar, 1) + sage: Q = P([-1/2*QQbar(sqrt(2)) + QQbar(I), 1]) + sage: S = Q._number_field_from_algebraics(); S (1/2*a^3 + a^2 - 1/2*a : 1) - sage: S.codomain() # optional - sage.rings.number_field sage.symbolic + sage: S.codomain() Projective Space of dimension 1 over Number Field in a with defining polynomial y^4 + 1 with a = 0.7071067811865475? + 0.7071067811865475?*I The following was fixed in :trac:`23808`:: + sage: # needs sage.rings.number_field sage.symbolic sage: R. = PolynomialRing(QQ) - sage: P. = ProjectiveSpace(QQbar, 1) # optional - sage.rings.number_field - sage: Q = P([-1/2*QQbar(sqrt(2)) + QQbar(I), 1]);Q # optional - sage.rings.number_field sage.symbolic + sage: P. = ProjectiveSpace(QQbar, 1) + sage: Q = P([-1/2*QQbar(sqrt(2)) + QQbar(I), 1]);Q (-0.7071067811865475? + 1*I : 1) - sage: S = Q._number_field_from_algebraics(); S # optional - sage.rings.number_field sage.symbolic + sage: S = Q._number_field_from_algebraics(); S (1/2*a^3 + a^2 - 1/2*a : 1) - sage: T = S.change_ring(QQbar) # Used to fail # optional - sage.rings.number_field sage.symbolic - sage: T # optional - sage.rings.number_field sage.symbolic + sage: T = S.change_ring(QQbar) # Used to fail + sage: T (-0.7071067811865475? + 1.000000000000000?*I : 1) - sage: Q[0] == T[0] # optional - sage.rings.number_field sage.symbolic + sage: Q[0] == T[0] True """ from sage.schemes.projective.projective_space import is_ProjectiveSpace @@ -1281,11 +1299,12 @@ def clear_denominators(self): :: + sage: # needs sage.rings.number_field sage: R. = PolynomialRing(QQ) - sage: K. = NumberField(x^2 - 3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: Q = P([1/w, 3, 0]) # optional - sage.rings.number_field - sage: Q.clear_denominators(); Q # optional - sage.rings.number_field + sage: K. = NumberField(x^2 - 3) + sage: P. = ProjectiveSpace(K, 2) + sage: Q = P([1/w, 3, 0]) + sage: Q.clear_denominators(); Q (w : 9 : 0) :: @@ -1325,13 +1344,13 @@ def intersection_multiplicity(self, X): sage: X = P.subscheme([x*z - y^2]) sage: Y = P.subscheme([x^3 - y*w^2 + z*w^2, x*y - z*w]) sage: Q1 = X([1/2, 1/4, 1/8, 1]) - sage: Q1.intersection_multiplicity(Y) + sage: Q1.intersection_multiplicity(Y) # needs sage.libs.singular 1 sage: Q2 = X([0,0,0,1]) - sage: Q2.intersection_multiplicity(Y) + sage: Q2.intersection_multiplicity(Y) # needs sage.libs.singular 5 sage: Q3 = X([0,0,1,0]) - sage: Q3.intersection_multiplicity(Y) + sage: Q3.intersection_multiplicity(Y) # needs sage.libs.singular 6 :: @@ -1363,10 +1382,10 @@ def multiplicity(self): sage: P. = ProjectiveSpace(QQ, 4) sage: X = P.subscheme([y^6 - x^3*w^2*t + t^5*w, x^2 - t^2]) sage: Q1 = X([1,0,2,1,1]) - sage: Q1.multiplicity() + sage: Q1.multiplicity() # needs sage.libs.singular 1 sage: Q2 = X([0,0,-2,1,0]) - sage: Q2.multiplicity() + sage: Q2.multiplicity() # needs sage.libs.singular 8 """ from sage.schemes.projective.projective_space import is_ProjectiveSpace @@ -1384,27 +1403,27 @@ def __hash__(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: hash(P(2, 1, 2)) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: hash(P(2, 1, 2)) 41 :: - sage: P. = ProjectiveSpace(GF(7), 2) # optional - sage.rings.finite_rings - sage: X = P.subscheme(x^2 - y^2) # optional - sage.rings.finite_rings - sage: hash(X(1, 1, 2)) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(7), 2) + sage: X = P.subscheme(x^2 - y^2) + sage: hash(X(1, 1, 2)) 81 :: - sage: P. = ProjectiveSpace(GF(13), 1) # optional - sage.rings.finite_rings - sage: hash(P(3, 4)) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(13), 1) + sage: hash(P(3, 4)) 17 :: - sage: P. = ProjectiveSpace(GF(13^3,'t'), 1) # optional - sage.rings.finite_rings - sage: hash(P(3, 4)) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(13^3,'t'), 1) # needs sage.rings.finite_rings + sage: hash(P(3, 4)) # needs sage.rings.finite_rings 2201 """ p = self.codomain().base_ring().order() @@ -1420,6 +1439,7 @@ class SchemeMorphism_point_abelian_variety_field(AdditiveGroupElement, SchemeMor EXAMPLES:: + sage: # needs sage.schemes sage: E = EllipticCurve([0,0,1,-1,0]) sage: origin = E(0) sage: origin.domain() diff --git a/src/sage/schemes/projective/projective_rational_point.py b/src/sage/schemes/projective/projective_rational_point.py index b0244869d07..31dc0703b5a 100644 --- a/src/sage/schemes/projective/projective_rational_point.py +++ b/src/sage/schemes/projective/projective_rational_point.py @@ -26,8 +26,8 @@ Projective over a finite field:: sage: from sage.schemes.projective.projective_rational_point import enum_projective_finite_field - sage: E = EllipticCurve('72').change_ring(GF(19)) # optional - sage.rings.finite_rings - sage: enum_projective_finite_field(E) # optional - sage.rings.finite_rings + sage: E = EllipticCurve('72').change_ring(GF(19)) # needs sage.schemes + sage: enum_projective_finite_field(E) # needs sage.schemes [(0 : 1 : 0), (1 : 0 : 1), (3 : 0 : 1), (4 : 9 : 1), (4 : 10 : 1), (6 : 6 : 1), (6 : 13 : 1), (7 : 6 : 1), (7 : 13 : 1), (9 : 4 : 1), (9 : 15 : 1), (12 : 8 : 1), (12 : 11 : 1), (13 : 8 : 1), (13 : 11 : 1), @@ -185,22 +185,23 @@ def enum_projective_number_field(X, **kwds): EXAMPLES:: + sage: # needs sage.rings.number_field sage: from sage.schemes.projective.projective_rational_point import enum_projective_number_field sage: u = QQ['u'].0 - sage: K = NumberField(u^3 - 5, 'v') # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: X = P.subscheme([x - y]) # optional - sage.rings.number_field - sage: enum_projective_number_field(X(K), bound=RR(5^(1/3)), prec=2^10) # optional - sage.rings.number_field + sage: K = NumberField(u^3 - 5, 'v') + sage: P. = ProjectiveSpace(K, 2) + sage: X = P.subscheme([x - y]) + sage: enum_projective_number_field(X(K), bound=RR(5^(1/3)), prec=2^10) [(0 : 0 : 1), (1 : 1 : 0), (-1 : -1 : 1), (1 : 1 : 1)] :: + sage: # needs sage.rings.number_field sage: u = QQ['u'].0 - sage: K = NumberField(u^2 + 3, 'v') # optional - sage.rings.number_field - sage: A. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: X = A.subscheme(x - y) # optional - sage.rings.number_field - sage: from sage.schemes.projective.projective_rational_point import enum_projective_number_field - sage: enum_projective_number_field(X, bound=2) # optional - sage.rings.number_field + sage: K = NumberField(u^2 + 3, 'v') + sage: A. = ProjectiveSpace(K, 1) + sage: X = A.subscheme(x - y) + sage: enum_projective_number_field(X, bound=2) [(1 : 1)] """ B = kwds.pop('bound') @@ -244,29 +245,30 @@ def enum_projective_finite_field(X): EXAMPLES:: - sage: F = GF(53) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(2, F) # optional - sage.rings.finite_rings sage: from sage.schemes.projective.projective_rational_point import enum_projective_finite_field - sage: len(enum_projective_finite_field(P(F))) # optional - sage.rings.finite_rings + sage: F = GF(53) + sage: P. = ProjectiveSpace(2, F) + sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2 + 53 + 1 2863 :: - sage: F = GF(9, 'a') # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(2,F) # optional - sage.rings.finite_rings - sage: C = Curve(X^3 - Y^3 + Z^2*Y) # optional - sage.rings.finite_rings - sage: enum_projective_finite_field(C(F)) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F = GF(9, 'a') + sage: P. = ProjectiveSpace(2,F) + sage: C = Curve(X^3 - Y^3 + Z^2*Y) # needs sage.schemes + sage: enum_projective_finite_field(C(F)) # needs sage.schemes [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: - sage: F = GF(5) # optional - sage.rings.finite_rings - sage: P2F. = ProjectiveSpace(2, F) # optional - sage.rings.finite_rings - sage: enum_projective_finite_field(P2F) # optional - sage.rings.finite_rings + sage: F = GF(5) + sage: P2F. = ProjectiveSpace(2, F) + sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), @@ -344,15 +346,15 @@ def sieve(X, bound): sage: from sage.schemes.projective.projective_rational_point import sieve sage: P. = ProjectiveSpace(QQ, 3) sage: Y = P.subscheme([x^2 - 3^2*y^2 + z*q, x + z + 4*q]) - sage: sorted(sieve(Y, 12)) # long time + sage: sorted(sieve(Y, 12)) # long time # needs sage.libs.singular [(-4 : -4/3 : 0 : 1), (-4 : 4/3 : 0 : 1), (-1 : -1/3 : 1 : 0), (-1 : 1/3 : 1 : 0)] :: sage: from sage.schemes.projective.projective_rational_point import sieve - sage: E = EllipticCurve('37a') - sage: sorted(sieve(E, 14)) # long time + sage: E = EllipticCurve('37a') # needs sage.schemes + sage: sorted(sieve(E, 14)) # long time # needs sage.libs.singular sage.schemes [(-1 : -1 : 1), (-1 : 0 : 1), (0 : -1 : 1), (0 : 0 : 1), (0 : 1 : 0), (1/4 : -5/8 : 1), (1/4 : -3/8 : 1), (1 : -1 : 1), (1 : 0 : 1), @@ -365,7 +367,7 @@ def sieve(X, bound): sage: from sage.schemes.projective.projective_rational_point import sieve sage: P. = ProjectiveSpace(2, QQ) sage: X = P.subscheme(3*x - 3/2*y) - sage: sieve(X, 3) + sage: sieve(X, 3) # needs sage.libs.singular [(-1 : -2 : 1), (-1/2 : -1 : 1), (-1/3 : -2/3 : 1), (0 : 0 : 1), (1/3 : 2/3 : 1), (1/2 : 1 : 0), (1/2 : 1 : 1), (1 : 2 : 1)] """ diff --git a/src/sage/schemes/projective/projective_space.py b/src/sage/schemes/projective/projective_space.py index eae8dd26fec..ecb34f8230a 100644 --- a/src/sage/schemes/projective/projective_space.py +++ b/src/sage/schemes/projective/projective_space.py @@ -24,7 +24,7 @@ sage: X = ProjectiveSpace(5)/QQ; X Projective Space of dimension 5 over Rational Field - sage: X/CC + sage: X/CC # needs sage.rings.real_mpfr Projective Space of dimension 5 over Complex Field with 53 bits of precision The third argument specifies the printing names of the generators of the @@ -59,7 +59,7 @@ Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x + y + z, x + y - z - sage: V.dimension() + sage: V.dimension() # needs sage.libs.singular 0 AUTHORS: @@ -141,7 +141,7 @@ def is_ProjectiveSpace(x): sage: from sage.schemes.projective.projective_space import is_ProjectiveSpace sage: is_ProjectiveSpace(ProjectiveSpace(5, names='x')) True - sage: is_ProjectiveSpace(ProjectiveSpace(5, GF(9, 'alpha'), names='x')) # optional - sage.rings.finite_rings + sage: is_ProjectiveSpace(ProjectiveSpace(5, GF(9, 'alpha'), names='x')) # needs sage.rings.finite_rings True sage: is_ProjectiveSpace(Spec(ZZ)) False @@ -170,7 +170,7 @@ def ProjectiveSpace(n, R=None, names=None): :: - sage: ProjectiveSpace(5)/GF(17) # optional - sage.rings.finite_rings + sage: ProjectiveSpace(5)/GF(17) Projective Space of dimension 5 over Finite Field of size 17 The default base ring is `\ZZ`. @@ -184,17 +184,17 @@ def ProjectiveSpace(n, R=None, names=None): :: - sage: R = GF(7)['x,y,z'] # optional - sage.rings.finite_rings - sage: P = ProjectiveSpace(R); P # optional - sage.rings.finite_rings + sage: R = GF(7)['x,y,z'] + sage: P = ProjectiveSpace(R); P Projective Space of dimension 2 over Finite Field of size 7 - sage: P.coordinate_ring() # optional - sage.rings.finite_rings + sage: P.coordinate_ring() Multivariate Polynomial Ring in x, y, z over Finite Field of size 7 - sage: P.coordinate_ring() is R # optional - sage.rings.finite_rings + sage: P.coordinate_ring() is R True :: - sage: ProjectiveSpace(3, Zp(5), 'y') # optional - sage.rings.padics + sage: ProjectiveSpace(3, Zp(5), 'y') # needs sage.rings.padics Projective Space of dimension 3 over 5-adic Ring with capped relative precision 20 :: @@ -204,8 +204,7 @@ def ProjectiveSpace(n, R=None, names=None): :: - sage: PS. = ProjectiveSpace(1, CC) - sage: PS + sage: PS. = ProjectiveSpace(1, CC); PS # needs sage.rings.real_mpfr Projective Space of dimension 1 over Complex Field with 53 bits of precision :: @@ -337,7 +336,7 @@ def __init__(self, n, R=ZZ, names=None): EXAMPLES:: - sage: ProjectiveSpace(3, Zp(5), 'y') # optional - sage.rings.padics + sage: ProjectiveSpace(3, Zp(5), 'y') # needs sage.rings.padics Projective Space of dimension 3 over 5-adic Ring with capped relative precision 20 """ AmbientSpace.__init__(self, n, R) @@ -419,7 +418,7 @@ def coordinate_ring(self): EXAMPLES:: - sage: ProjectiveSpace(3, GF(19^2,'alpha'), 'abcd').coordinate_ring() # optional - sage.rings.finite_rings + sage: ProjectiveSpace(3, GF(19^2,'alpha'), 'abcd').coordinate_ring() # needs sage.rings.finite_rings Multivariate Polynomial Ring in a, b, c, d over Finite Field in alpha of size 19^2 :: @@ -590,7 +589,7 @@ def _latex_(self): TESTS:: - sage: ProjectiveSpace(3, Zp(5), 'y')._latex_() # optional - sage.rings.padics + sage: ProjectiveSpace(3, Zp(5), 'y')._latex_() # needs sage.rings.padics '{\\mathbf P}_{\\Bold{Z}_{5}}^3' """ return "{\\mathbf P}_{%s}^%s" % (latex(self.base_ring()), @@ -622,9 +621,9 @@ def _linear_system_as_kernel(self, d, pt, m): If the degree `d` is 0, then a matrix consisting of the first unit vector is returned:: - sage: P = ProjectiveSpace(GF(5), 2, names='x') # optional - sage.rings.finite_rings - sage: pt = P([1, 1, 1]) # optional - sage.rings.finite_rings - sage: P._linear_system_as_kernel(0, pt, 3) # optional - sage.rings.finite_rings + sage: P = ProjectiveSpace(GF(5), 2, names='x') + sage: pt = P([1, 1, 1]) + sage: P._linear_system_as_kernel(0, pt, 3) # needs sage.modules [1] [0] [0] @@ -635,10 +634,10 @@ def _linear_system_as_kernel(self, d, pt, m): If the multiplicity `m` is 0, then a matrix with zero rows is returned:: - sage: P = ProjectiveSpace(GF(5), 2, names='x') # optional - sage.rings.finite_rings - sage: pt = P([1, 1, 1]) # optional - sage.rings.finite_rings - sage: M = P._linear_system_as_kernel(2, pt, 0) # optional - sage.rings.finite_rings - sage: [M.nrows(), M.ncols()] # optional - sage.rings.finite_rings + sage: P = ProjectiveSpace(GF(5), 2, names='x') + sage: pt = P([1, 1, 1]) + sage: M = P._linear_system_as_kernel(2, pt, 0) # needs sage.modules + sage: [M.nrows(), M.ncols()] # needs sage.modules [0, 6] The base ring does not need to be a field or even an integral domain. @@ -647,7 +646,7 @@ def _linear_system_as_kernel(self, d, pt, m): sage: R = Zmod(4) sage: P = ProjectiveSpace(R, 2, names='x') sage: pt = [R(1), R(3), R(0)] - sage: P._linear_system_as_kernel(3, pt, 2) + sage: P._linear_system_as_kernel(3, pt, 2) # needs sage.modules [1 3 0 1 0 0 3 0 0 0] [0 1 0 2 0 0 3 0 0 0] [0 0 1 0 3 0 0 1 0 0] @@ -656,10 +655,10 @@ def _linear_system_as_kernel(self, d, pt, m): (even when the base ring is a field and the list gives a well-defined point in projective space):: - sage: R = GF(5) # optional - sage.rings.finite_rings - sage: P = ProjectiveSpace(R, 2, names='x') # optional - sage.rings.finite_rings - sage: pt = [R(3), R(3), R(0)] # optional - sage.rings.finite_rings - sage: P._linear_system_as_kernel(3, pt, 2) # optional - sage.rings.finite_rings + sage: R = GF(5) + sage: P = ProjectiveSpace(R, 2, names='x') + sage: pt = [R(3), R(3), R(0)] + sage: P._linear_system_as_kernel(3, pt, 2) # needs sage.modules Traceback (most recent call last): ... TypeError: at least one component of pt=[3, 3, 0] must be equal to 1 @@ -673,7 +672,7 @@ def _linear_system_as_kernel(self, d, pt, m): sage: P = ProjectiveSpace(QQ, 3, names='x') sage: RPol. = PolynomialRing(QQ, 4) sage: pt = [t0,t1,1,t3] - sage: P._linear_system_as_kernel(2, pt, 2) + sage: P._linear_system_as_kernel(2, pt, 2) # needs sage.modules [ 2*t0 t1 1 t3 0 0 0 0 0 0] [ 0 t0 0 0 2*t1 1 t3 0 0 0] [ t0^2 t0*t1 t0 t0*t3 t1^2 t1 t1*t3 1 t3 t3^2] @@ -735,8 +734,8 @@ def _morphism(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: P2._morphism(P2.Hom(P2), [x,y,z]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: P2._morphism(P2.Hom(P2), [x,y,z]) Scheme endomorphism of Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y : z) to (x : y : z) @@ -765,8 +764,8 @@ def _point_homset(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: P2._point_homset(Spec(GF(3)), P2) Set of rational points of Projective Space of dimension 2 over Finite Field of size 3 """ return SchemeHomset_points_projective_ring(*args, **kwds) @@ -829,9 +828,9 @@ def _point(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: point_homset = P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings - sage: P2._point(point_homset, [1,2,3]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: point_homset = P2._point_homset(Spec(GF(3)), P2) + sage: P2._point(point_homset, [1,2,3]) (2 : 1 : 0) """ return SchemeMorphism_point_projective_ring(*args, **kwds) @@ -847,7 +846,7 @@ def _repr_(self): TESTS:: - sage: ProjectiveSpace(3, Zp(5), 'y')._repr_() # optional - sage.rings.padics + sage: ProjectiveSpace(3, Zp(5), 'y')._repr_() # needs sage.rings.padics 'Projective Space of dimension 3 over 5-adic Ring with capped relative precision 20' """ return "Projective Space of dimension %s over %s" % (self.dimension_relative(), self.base_ring()) @@ -915,14 +914,14 @@ def change_ring(self, R): sage: P. = ProjectiveSpace(2, ZZ) sage: PQ = P.change_ring(QQ); PQ Projective Space of dimension 2 over Rational Field - sage: PQ.change_ring(GF(5)) # optional - sage.rings.finite_rings + sage: PQ.change_ring(GF(5)) Projective Space of dimension 2 over Finite Field of size 5 :: - sage: K. = QuadraticField(2) # optional - sage.rings.number_field - sage: P = ProjectiveSpace(K, 2, 't') # optional - sage.rings.number_field - sage: P.change_ring(K.embeddings(QQbar)[0]) # optional - sage.rings.number_field + sage: K. = QuadraticField(2) # needs sage.rings.number_field + sage: P = ProjectiveSpace(K, 2, 't') # needs sage.rings.number_field + sage: P.change_ring(K.embeddings(QQbar)[0]) # needs sage.rings.number_field Projective Space of dimension 2 over Algebraic Field """ if isinstance(R, Map): @@ -964,9 +963,9 @@ def subscheme(self, X): sage: I = X.defining_ideal(); I Ideal (x*z^2, y^2*z, x*y^2) of Multivariate Polynomial Ring in x, y, z over Rational Field - sage: I.groebner_basis() + sage: I.groebner_basis() # needs sage.libs.singular [x*y^2, y^2*z, x*z^2] - sage: X.dimension() + sage: X.dimension() # needs sage.libs.singular 0 sage: X.base_ring() Rational Field @@ -1025,63 +1024,67 @@ def points_of_bounded_height(self, **kwds): :: sage: u = QQ['u'].0 - sage: P. = ProjectiveSpace(NumberField(u^2 - 2, 'v'), 2) # optional - sage.rings.number_field - sage: len(list(P.points_of_bounded_height(bound=2))) # optional - sage.rings.number_field + sage: P. = ProjectiveSpace(NumberField(u^2 - 2, 'v'), 2) # needs sage.rings.number_field + sage: len(list(P.points_of_bounded_height(bound=2))) # needs sage.rings.number_field 265 :: - sage: CF. = CyclotomicField(3) # optional - sage.rings.number_field - sage: R. = CF[] # optional - sage.rings.number_field - sage: L. = CF.extension(x^3 + 2) # optional - sage.rings.number_field - sage: Q. = ProjectiveSpace(L, 1) # optional - sage.rings.number_field - sage: sorted(list(Q.points_of_bounded_height(bound=1))) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: CF. = CyclotomicField(3) + sage: R. = CF[] + sage: L. = CF.extension(x^3 + 2) + sage: Q. = ProjectiveSpace(L, 1) + sage: sorted(list(Q.points_of_bounded_height(bound=1))) [(0 : 1), (1 : 0), (a + 1 : 1), (a : 1), (-1 : 1), (-a - 1 : 1), (-a : 1), (1 : 1)] :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: F. = NumberField(x^4 - 8*x^2 + 3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.number_field - sage: all(exp(p.global_height()) <= 1 # optional - sage.rings.number_field + sage: F. = NumberField(x^4 - 8*x^2 + 3) + sage: P. = ProjectiveSpace(F, 2) + sage: all(exp(p.global_height()) <= 1 # needs sage.symbolic ....: for p in P.points_of_bounded_height(bound=1)) True :: - sage: K. = CyclotomicField(3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: len(list(P.points_of_bounded_height(bound=1))) # optional - sage.rings.number_field + sage: K. = CyclotomicField(3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 2) # needs sage.rings.number_field + sage: len(list(P.points_of_bounded_height(bound=1))) # needs sage.rings.number_field 57 :: sage: u = QQ['u'].0 - sage: K. = NumberField(u^2 - 2) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: len(list(P.points_of_bounded_height(bound=2))) # optional - sage.rings.number_field + sage: K. = NumberField(u^2 - 2) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: len(list(P.points_of_bounded_height(bound=2))) # needs sage.rings.number_field 24 :: sage: R. = QQ[] - sage: K. = NumberField(x^4 - 8*x^2 + 3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 1) # optional - sage.rings.number_field - sage: len(list(P.points_of_bounded_height(bound=2))) # optional - sage.rings.number_field + sage: K. = NumberField(x^4 - 8*x^2 + 3) # needs sage.rings.number_field + sage: P. = ProjectiveSpace(K, 1) # needs sage.rings.number_field + sage: len(list(P.points_of_bounded_height(bound=2))) # needs sage.rings.number_field 108 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^5 + x^3 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: L = P.points_of_bounded_height(bound=1.2) # optional - sage.rings.number_field - sage: len(list(L)) # optional - sage.rings.number_field + sage: K. = NumberField(x^5 + x^3 + 1) + sage: P. = ProjectiveSpace(K, 2) + sage: L = P.points_of_bounded_height(bound=1.2) + sage: len(list(L)) 109 :: + sage: # needs sage.rings.number_field sage: K. = QuadraticField(2) sage: P. = ProjectiveSpace(K, 1) sage: sorted(list(P.points_of_bounded_height(bound=2))) @@ -1092,6 +1095,7 @@ def points_of_bounded_height(self, **kwds): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(3*x^2 + 1) sage: P. = ProjectiveSpace(K, 1) @@ -1101,6 +1105,7 @@ def points_of_bounded_height(self, **kwds): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(3*x^2 + 1) sage: O = K.maximal_order() @@ -1110,6 +1115,7 @@ def points_of_bounded_height(self, **kwds): :: + sage: # needs sage.rings.number_field sage: R. = QQ[] sage: K. = NumberField(x^3 - 7) sage: O = K.maximal_order() @@ -1136,6 +1142,7 @@ def points_of_bounded_height(self, **kwds): :: + sage: # needs sage.rings.number_field sage: K. = NumberField(x^2 + 1) sage: PK. = K[] sage: L. = K.extension(t^4 - i) @@ -1326,17 +1333,17 @@ def Lattes_map(self, E, m): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) - sage: E = EllipticCurve(QQ,[-1, 0]) - sage: P.Lattes_map(E, 2) + sage: E = EllipticCurve(QQ,[-1, 0]) # needs sage.schemes + sage: P.Lattes_map(E, 2) # needs sage.schemes Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (1/4*x^4 + 1/2*x^2*y^2 + 1/4*y^4 : x^3*y - x*y^3) TESTS:: - sage: P. = ProjectiveSpace(GF(37), 1) # optional - sage.rings.finite_rings - sage: E = EllipticCurve([1, 1]) # optional - sage.rings.finite_rings - sage: f = P.Lattes_map(E, 2); f # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(37), 1) + sage: E = EllipticCurve([1, 1]) # needs sage.rings.finite_rings sage.schemes + sage: f = P.Lattes_map(E, 2); f # needs sage.rings.finite_rings sage.schemes Dynamical System of Projective Space of dimension 1 over Finite Field of size 37 Defn: Defined on coordinates by sending (x : y) to (-9*x^4 + 18*x^2*y^2 - 2*x*y^3 - 9*y^4 : x^3*y + x*y^3 + y^4) @@ -1405,7 +1412,7 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) - sage: P.chebyshev_polynomial(5, 'first') + sage: P.chebyshev_polynomial(5, 'first') # needs sage.symbolic Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (16*x^5 - 20*x^3*y^2 + 5*x*y^4 : y^5) @@ -1413,7 +1420,7 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: P.chebyshev_polynomial(3, 'second') + sage: P.chebyshev_polynomial(3, 'second') # needs sage.symbolic Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (8*x^3 - 4*x*y^2 : y^3) @@ -1421,7 +1428,7 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: P.chebyshev_polynomial(3, 2) + sage: P.chebyshev_polynomial(3, 2) # needs sage.symbolic Traceback (most recent call last): ... ValueError: keyword 'kind' must have a value of either 'first' or 'second' @@ -1445,7 +1452,7 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): :: sage: P. = ProjectiveSpace(QQ, 1) - sage: P.chebyshev_polynomial(3, monic=True) + sage: P.chebyshev_polynomial(3, monic=True) # needs sage.symbolic Dynamical System of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (x^3 - 3*x*y^2 : y^3) @@ -1454,7 +1461,7 @@ def chebyshev_polynomial(self, n, kind='first', monic=False): sage: F. = FunctionField(QQ) sage: P. = ProjectiveSpace(F, 1) - sage: P.chebyshev_polynomial(4, monic=True) + sage: P.chebyshev_polynomial(4, monic=True) # needs sage.symbolic Dynamical System of Projective Space of dimension 1 over Rational function field in t over Rational Field Defn: Defined on coordinates by sending (y : z) to @@ -1495,8 +1502,8 @@ def veronese_embedding(self, d, CS=None, order='lex'): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 1) - sage: vd = P.veronese_embedding(4, order='invlex') - sage: vd + sage: vd = P.veronese_embedding(4, order='invlex') # needs sage.combinat + sage: vd # needs sage.combinat Scheme morphism: From: Projective Space of dimension 1 over Rational Field To: Projective Space of dimension 4 over Rational Field @@ -1507,14 +1514,14 @@ def veronese_embedding(self, d, CS=None, order='lex'): sage: P. = ProjectiveSpace(QQ, 2) sage: Q. = ProjectiveSpace(QQ, 5) - sage: vd = P.veronese_embedding(2, Q) - sage: vd + sage: vd = P.veronese_embedding(2, Q) # needs sage.combinat + sage: vd # needs sage.combinat Scheme morphism: From: Projective Space of dimension 2 over Rational Field To: Projective Space of dimension 5 over Rational Field Defn: Defined on coordinates by sending (x : y : z) to (x^2 : x*y : x*z : y^2 : y*z : z^2) - sage: vd(P.subscheme([])) + sage: vd(P.subscheme([])) # needs sage.combinat sage.libs.singular Closed subscheme of Projective Space of dimension 5 over Rational Field defined by: -u^2 + t*v, @@ -1577,19 +1584,19 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P1. = ProjectiveSpace(QQ, 2) sage: points_source = [P1([1, 4, 1]), P1([1, 2, 2]), P1([3, 5, 1]), P1([1, -1, 1])] sage: points_target = [P1([5, -2, 7]), P1([3, -2, 3]), P1([6, -5, 9]), P1([3, 6, 7])] - sage: m = P1.point_transformation_matrix(points_source, points_target); m + sage: m = P1.point_transformation_matrix(points_source, points_target); m # needs sage.modules [ -13/59 -128/59 -25/59] [538/177 8/59 26/177] [ -45/59 -196/59 1] - sage: [m*points_source[i] == points_target[i] for i in range(4)] + sage: [m*points_source[i] == points_target[i] for i in range(4)] # needs sage.modules [True, True, True, True] :: - sage: P. = ProjectiveSpace(GF(13), 1) # optional - sage.rings.finite_rings - sage: points_source = [P([-6, 7]), P([1, 4]), P([3, 2])] # optional - sage.rings.finite_rings - sage: points_target = [P([-1, 2]), P([0, 2]), P([-1, 6])] # optional - sage.rings.finite_rings - sage: P.point_transformation_matrix(points_source, points_target) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(13), 1) + sage: points_source = [P([-6, 7]), P([1, 4]), P([3, 2])] + sage: points_target = [P([-1, 2]), P([0, 2]), P([-1, 6])] + sage: P.point_transformation_matrix(points_source, points_target) # needs sage.modules [10 4] [10 1] @@ -1598,7 +1605,7 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P. = ProjectiveSpace(QQ, 1) sage: points_source = [P([-6, -4]), P([1, 4]), P([3, 2])] sage: points_target = [P([-1, 2]), P([0, 2]), P([-7, -3])] - sage: P.point_transformation_matrix(points_source, points_target) + sage: P.point_transformation_matrix(points_source, points_target) # needs sage.modules Traceback (most recent call last): ... ValueError: source points not independent @@ -1609,7 +1616,7 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P. = ProjectiveSpace(R, 1) sage: points_source = [P([-6*t, 7]), P([1, 4]), P([3, 2])] sage: points_target = [P([-1, 2*t]), P([0, 2]), P([-1, 6])] - sage: P.point_transformation_matrix(points_source, points_target) + sage: P.point_transformation_matrix(points_source, points_target) # needs sage.modules [ (1/3*t + 7/12)/(t^2 - 53/24*t) (-1/12*t - 7/48)/(t^2 - 53/24*t)] [(-2/3*t^2 - 7/36*t - 35/12)/(t^2 - 53/24*t) 1] @@ -1618,7 +1625,8 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P1. = ProjectiveSpace(RR, 2) sage: points_source = [P1([1, 4, 1]), P1([1, 2, 2]), P1([3, 5, 1]), P1([1, -1, 1])] sage: points_target = [P1([5, -2, 7]), P1([3, -2, 3]), P1([6, -5, 9]), P1([3, 6, 7])] - sage: P1.point_transformation_matrix(points_source, points_target) # abs tol 1e-13 + sage: P1.point_transformation_matrix(points_source, # abs tol 1e-13 # needs sage.modules + ....: points_target) [-0.0619047619047597 -0.609523809523810 -0.119047619047621] [ 0.853968253968253 0.0380952380952380 0.0412698412698421] [ -0.214285714285712 -0.933333333333333 0.280952380952379] @@ -1628,7 +1636,7 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P1. = ProjectiveSpace(ZZ, 2) sage: points_source = [P1([1, 4, 1]), P1([1, 2, 2]), P1([3, 5, 1]), P1([1, -1, 1])] sage: points_target = [P1([5, -2, 7]), P1([3, -2, 3]), P1([6, -5, 9]), P1([3, 6, 7])] - sage: P1.point_transformation_matrix(points_source, points_target) + sage: P1.point_transformation_matrix(points_source, points_target) # needs sage.modules [ -39 -384 -75] [ 538 24 26] [-135 -588 177] @@ -1638,7 +1646,8 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P1. = ProjectiveSpace(ZZ, 2) sage: points_source = [P1([1, 4, 1]), P1([1, 2, 2]), P1([3, 5, 1]), P1([1, -1, 1])] sage: points_target = [P1([5, -2, 7]), P1([3, -2, 3]), P1([6, -5, 9]), P1([3, 6, 7])] - sage: P1.point_transformation_matrix(points_source, points_target, normalize=False) + sage: P1.point_transformation_matrix(points_source, points_target, # needs sage.modules + ....: normalize=False) [-13/30 -64/15 -5/6] [269/45 4/15 13/45] [ -3/2 -98/15 59/30] @@ -1649,7 +1658,7 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P. = ProjectiveSpace(R, 1) sage: points_source = [P([-6*t, 7]), P([1, 4]), P([3, 2])] sage: points_target = [P([-1, 2*t]), P([0, 2]), P([-1, 6])] - sage: P.point_transformation_matrix(points_source, points_target) + sage: P.point_transformation_matrix(points_source, points_target) # needs sage.modules [ -48*t - 84 12*t + 21] [96*t^2 + 28*t + 420 -144*t^2 + 318*t] @@ -1658,7 +1667,7 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P. = ProjectiveSpace(QQ, 1) sage: points_source = [P([-6, -1]), P([1, 4]), P([3, 2])] sage: points_target = [P([-1, 2]), P([0, 2]), P([-2, 4])] - sage: P.point_transformation_matrix(points_source, points_target) + sage: P.point_transformation_matrix(points_source, points_target) # needs sage.modules Traceback (most recent call last): ... ValueError: target points not independent @@ -1710,7 +1719,8 @@ def point_transformation_matrix(self, points_source, points_target, normalize=Tr sage: P. = ProjectiveSpace(ZZ, 2) sage: points_source = [P(1, 0, 0), P(0, 1, 0), P(0, 0, 1), P(1, -1, -1)] sage: points_target = [P(0, 1, 0), P(-2, 0, 1), P(0, 0, 1), P(1, -1, -1)] - sage: P.point_transformation_matrix(points_source, points_target, normalize=True) + sage: P.point_transformation_matrix(points_source, points_target, # needs sage.modules + ....: normalize=True) [ 0 -2 0] [-2 0 0] [ 0 1 1] @@ -1786,10 +1796,10 @@ def hyperplane_transformation_matrix(self, plane_1, plane_2): sage: P. = ProjectiveSpace(QQ, 1) sage: plane1 = P.subscheme(x) sage: plane2 = P.subscheme(y) - sage: m = P.hyperplane_transformation_matrix(plane1, plane2); m + sage: m = P.hyperplane_transformation_matrix(plane1, plane2); m # needs sage.modules [0 1] [1 0] - sage: plane2(m*P((0,1))) + sage: plane2(m*P((0,1))) # needs sage.modules (1 : 0) :: @@ -1797,7 +1807,7 @@ def hyperplane_transformation_matrix(self, plane_1, plane_2): sage: P. = ProjectiveSpace(QQ, 3) sage: plane1 = P.subscheme(x + 2*y + z) sage: plane2 = P.subscheme(2*x + y + z) - sage: P.hyperplane_transformation_matrix(plane1, plane2) + sage: P.hyperplane_transformation_matrix(plane1, plane2) # needs sage.modules [1 0 0 0] [0 4 0 0] [0 0 2 0] @@ -1808,30 +1818,31 @@ def hyperplane_transformation_matrix(self, plane_1, plane_2): sage: P. = ProjectiveSpace(ZZ, 1) sage: plane1 = P.subscheme(x + y) sage: plane2 = P.subscheme(y) - sage: P.hyperplane_transformation_matrix(plane1, plane2) + sage: P.hyperplane_transformation_matrix(plane1, plane2) # needs sage.modules [-1 0] [ 1 1] :: - sage: K. = CyclotomicField(3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: plane1 = P.subscheme(x - 2*v*y + z) # optional - sage.rings.number_field - sage: plane2 = P.subscheme(x + v*y + v*z) # optional - sage.rings.number_field - sage: m = P.hyperplane_transformation_matrix(plane1, plane2) # optional - sage.rings.number_field - sage: m # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(3) + sage: P. = ProjectiveSpace(K, 2) + sage: plane1 = P.subscheme(x - 2*v*y + z) + sage: plane2 = P.subscheme(x + v*y + v*z) + sage: m = P.hyperplane_transformation_matrix(plane1, plane2); m # needs sage.modules [ v 0 0] [ 0 -2*v 0] [ 0 0 1] :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(x^2 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 3) # optional - sage.rings.number_field - sage: plane1 = P.subscheme(k*x + 2*k*y + z) # optional - sage.rings.number_field - sage: plane2 = P.subscheme(7*k*x + y + 9*z) # optional - sage.rings.number_field - sage: m = P.hyperplane_transformation_matrix(plane1, plane2); m # optional - sage.rings.number_field + sage: K. = NumberField(x^2 + 1) + sage: P. = ProjectiveSpace(K, 3) + sage: plane1 = P.subscheme(k*x + 2*k*y + z) + sage: plane2 = P.subscheme(7*k*x + y + 9*z) + sage: m = P.hyperplane_transformation_matrix(plane1, plane2); m # needs sage.modules [ 1 0 0 0] [ 0 14*k 0 0] [ 0 0 7/9 0] @@ -1839,23 +1850,24 @@ def hyperplane_transformation_matrix(self, plane_1, plane_2): :: - sage: K. = CyclotomicField(3) # optional - sage.rings.number_field - sage: R. = K[] # optional - sage.rings.number_field - sage: F. = K.extension(t^5 + 2) # optional - sage.rings.number_field - sage: G. = F.absolute_field() # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(G, 2) # optional - sage.rings.number_field - sage: plane1 = P.subscheme(x - 2*u*y + z) # optional - sage.rings.number_field - sage: plane2 = P.subscheme(x + u*y + z) # optional - sage.rings.number_field - sage: m = P.hyperplane_transformation_matrix(plane1, plane2) # optional - sage.rings.number_field - sage: plane2(m*P((2*u, 1, 0))) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(3) + sage: R. = K[] + sage: F. = K.extension(t^5 + 2) + sage: G. = F.absolute_field() + sage: P. = ProjectiveSpace(G, 2) + sage: plane1 = P.subscheme(x - 2*u*y + z) + sage: plane2 = P.subscheme(x + u*y + z) + sage: m = P.hyperplane_transformation_matrix(plane1, plane2) # needs sage.modules + sage: plane2(m*P((2*u, 1, 0))) # needs sage.modules (-u : 1 : 0) :: - sage: P. = ProjectiveSpace(FiniteField(2), 2) # optional - sage.rings.finite_rings - sage: plane1 = P.subscheme(x + y + z) # optional - sage.rings.finite_rings - sage: plane2 = P.subscheme(z) # optional - sage.rings.finite_rings - sage: P.hyperplane_transformation_matrix(plane1, plane2) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(FiniteField(2), 2) + sage: plane1 = P.subscheme(x + y + z) + sage: plane2 = P.subscheme(z) + sage: P.hyperplane_transformation_matrix(plane1, plane2) # needs sage.modules [1 0 0] [1 1 0] [1 1 1] @@ -1866,7 +1878,7 @@ def hyperplane_transformation_matrix(self, plane_1, plane_2): sage: P. = ProjectiveSpace(R, 2) sage: plane1 = P.subscheme(x + 9*t*y + z) sage: plane2 = P.subscheme(x + z) - sage: P.hyperplane_transformation_matrix(plane1, plane2) + sage: P.hyperplane_transformation_matrix(plane1, plane2) # needs sage.modules [ 1 9*t 0] [ 1 0 0] [ 0 0 1] @@ -1971,14 +1983,14 @@ def is_linearly_independent(self, points, n=None): sage: P. = ProjectiveSpace(QQ, 2) sage: points = [P((1, 0, 1)), P((1, 2, 1)), P((1, 3, 4))] - sage: P.is_linearly_independent(points) + sage: P.is_linearly_independent(points) # needs sage.modules True :: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: points = [P((1, 0, 1)), P((1, 2, 1)), P((1, 3, 4)), P((0, 0, 1))] # optional - sage.rings.finite_rings - sage: P.is_linearly_independent(points, 2) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(5), 2) + sage: points = [P((1, 0, 1)), P((1, 2, 1)), P((1, 3, 4)), P((0, 0, 1))] + sage: P.is_linearly_independent(points, 2) # needs sage.modules True :: @@ -1986,7 +1998,7 @@ def is_linearly_independent(self, points, n=None): sage: R. = QQ[] sage: P. = ProjectiveSpace(R, 2) sage: points = [P((c, 0, 1)), P((0, c, 1)), P((1, 0, 4)), P((0, 0, 1))] - sage: P.is_linearly_independent(points, 3) + sage: P.is_linearly_independent(points, 3) # needs sage.modules False :: @@ -1994,22 +2006,23 @@ def is_linearly_independent(self, points, n=None): sage: R. = QQ[] sage: P. = ProjectiveSpace(FractionField(R), 2) sage: points = [P((c, 0, 1)), P((0, c, 1)), P((1, 3, 4)), P((0, 0, 1))] - sage: P.is_linearly_independent(points, 3) + sage: P.is_linearly_independent(points, 3) # needs sage.modules True :: - sage: K. = CyclotomicField(3) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 2) # optional - sage.rings.number_field - sage: points = [P((k, k^2, 1)), P((0, k, 1)), P((1, 0, 4)), P((0, 0, 1))] # optional - sage.rings.number_field - sage: P.is_linearly_independent(points, 3) # optional - sage.rings.number_field + sage: # needs sage.rings.number_field + sage: K. = CyclotomicField(3) + sage: P. = ProjectiveSpace(K, 2) + sage: points = [P((k, k^2, 1)), P((0, k, 1)), P((1, 0, 4)), P((0, 0, 1))] + sage: P.is_linearly_independent(points, 3) # needs sage.modules True :: sage: P. = ProjectiveSpace(QQ, 1) sage: points = [P((1, 0)), P((1, 1))] - sage: P.is_linearly_independent(points) + sage: P.is_linearly_independent(points) # needs sage.modules True TESTS:: @@ -2054,8 +2067,8 @@ def _point_homset(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: P2._point_homset(Spec(GF(3)), P2) Set of rational points of Projective Space of dimension 2 over Finite Field of size 3 """ return SchemeHomset_points_projective_field(*args, **kwds) @@ -2068,9 +2081,9 @@ def _point(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: point_homset = P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings - sage: P2._point(point_homset, [1,2,3]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: point_homset = P2._point_homset(Spec(GF(3)), P2) + sage: P2._point(point_homset, [1,2,3]) (2 : 1 : 0) """ return SchemeMorphism_point_projective_field(*args, **kwds) @@ -2083,8 +2096,8 @@ def _morphism(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: P2._morphism(P2.Hom(P2), [x,y,z]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: P2._morphism(P2.Hom(P2), [x,y,z]) Scheme endomorphism of Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y : z) to (x : y : z) @@ -2119,7 +2132,7 @@ def subscheme_from_Chow_form(self, Ch, dim): sage: P = ProjectiveSpace(QQ, 4, 'z') sage: R. = PolynomialRing(QQ) sage: H = x1^2 + x2^2 + 5*x3*x4 - sage: P.subscheme_from_Chow_form(H, 3) + sage: P.subscheme_from_Chow_form(H, 3) # needs sage.modules Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: -5*z0*z1 + z2^2 + z3^2 @@ -2128,7 +2141,7 @@ def subscheme_from_Chow_form(self, Ch, dim): sage: P = ProjectiveSpace(QQ, 3, 'z') sage: R. = PolynomialRing(QQ) sage: H = x1 - x2 - x3 + x5 + 2*x0 - sage: P.subscheme_from_Chow_form(H, 1) + sage: P.subscheme_from_Chow_form(H, 1) # needs sage.modules Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: -z1 + z3, @@ -2138,11 +2151,12 @@ def subscheme_from_Chow_form(self, Ch, dim): :: - sage: P. = ProjectiveSpace(GF(7), 3) # optional - sage.rings.finite_rings - sage: X = P.subscheme([x3^2 + x1*x2, x2 - x0]) # optional - sage.rings.finite_rings - sage: Ch = X.Chow_form(); Ch # optional - sage.rings.finite_rings + sage: # needs sage.libs.singular + sage: P. = ProjectiveSpace(GF(7), 3) + sage: X = P.subscheme([x3^2 + x1*x2, x2 - x0]) + sage: Ch = X.Chow_form(); Ch t0^2 - 2*t0*t3 + t3^2 - t2*t4 - t4*t5 - sage: Y = P.subscheme_from_Chow_form(Ch, 1); Y # optional - sage.rings.finite_rings + sage: Y = P.subscheme_from_Chow_form(Ch, 1); Y Closed subscheme of Projective Space of dimension 3 over Finite Field of size 7 defined by: x1*x2 + x3^2, @@ -2153,8 +2167,8 @@ def subscheme_from_Chow_form(self, Ch, dim): -2*x0*x3 + 2*x2*x3, 2*x0*x3 - 2*x2*x3, x0^2 - 2*x0*x2 + x2^2 - sage: I = Y.defining_ideal() # optional - sage.rings.finite_rings - sage: I.saturation(I.ring().ideal(list(I.ring().gens())))[0] # optional - sage.rings.finite_rings + sage: I = Y.defining_ideal() + sage: I.saturation(I.ring().ideal(list(I.ring().gens())))[0] Ideal (x0 - x2, x1*x2 + x3^2) of Multivariate Polynomial Ring in x0, x1, x2, x3 over Finite Field of size 7 """ @@ -2214,7 +2228,7 @@ def curve(self, F): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 2) - sage: P.curve([y^2 - x*z]) + sage: P.curve([y^2 - x*z]) # needs sage.schemes Projective Plane Curve over Rational Field defined by y^2 - x*z """ from sage.schemes.curves.constructor import Curve @@ -2233,7 +2247,7 @@ def line_through(self, p, q): sage: P3. = ProjectiveSpace(3, QQ) sage: p1 = P3(1, 2, 3, 4) sage: p2 = P3(4, 3, 2, 1) - sage: P3.line_through(p1, p2) + sage: P3.line_through(p1, p2) # needs sage.schemes Projective Curve over Rational Field defined by -5/4*x0 + 5/2*x1 - 5/4*x2, -5/2*x0 + 15/4*x1 - 5/4*x3, -5/4*x0 + 15/4*x2 - 5/2*x3, -5/4*x1 + 5/2*x2 - 5/4*x3 @@ -2262,9 +2276,9 @@ def _point(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: point_homset = P2._point_homset(Spec(GF(3)), P2) # optional - sage.rings.finite_rings - sage: P2._point(point_homset, [1,2,3]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: point_homset = P2._point_homset(Spec(GF(3)), P2) + sage: P2._point(point_homset, [1,2,3]) (2 : 1 : 0) """ return SchemeMorphism_point_projective_finite_field(*args, **kwds) @@ -2277,8 +2291,8 @@ def _morphism(self, *args, **kwds): TESTS:: - sage: P2. = ProjectiveSpace(2, GF(3)) # optional - sage.rings.finite_rings - sage: P2._morphism(P2.Hom(P2), [x,y,z]) # optional - sage.rings.finite_rings + sage: P2. = ProjectiveSpace(2, GF(3)) + sage: P2._morphism(P2.Hom(P2), [x,y,z]) Scheme endomorphism of Projective Space of dimension 2 over Finite Field of size 3 Defn: Defined on coordinates by sending (x : y : z) to (x : y : z) @@ -2297,15 +2311,15 @@ def __iter__(self): EXAMPLES:: - sage: FF = FiniteField(3) # optional - sage.rings.finite_rings - sage: PP = ProjectiveSpace(0, FF) # optional - sage.rings.finite_rings - sage: [ x for x in PP ] # optional - sage.rings.finite_rings + sage: FF = FiniteField(3) + sage: PP = ProjectiveSpace(0, FF) + sage: [ x for x in PP ] [(1)] - sage: PP = ProjectiveSpace(1, FF) # optional - sage.rings.finite_rings - sage: [ x for x in PP ] # optional - sage.rings.finite_rings + sage: PP = ProjectiveSpace(1, FF) + sage: [ x for x in PP ] [(0 : 1), (1 : 1), (2 : 1), (1 : 0)] - sage: PP = ProjectiveSpace(2, FF) # optional - sage.rings.finite_rings - sage: [ x for x in PP ] # optional - sage.rings.finite_rings + sage: PP = ProjectiveSpace(2, FF) + sage: [ x for x in PP ] [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), @@ -2348,12 +2362,13 @@ def rational_points(self, F=None): EXAMPLES:: - sage: P = ProjectiveSpace(1, GF(3)) # optional - sage.rings.finite_rings - sage: P.rational_points() # optional - sage.rings.finite_rings + sage: P = ProjectiveSpace(1, GF(3)) + sage: P.rational_points() [(0 : 1), (1 : 1), (2 : 1), (1 : 0)] - sage: P.rational_points(GF(3^2, 'b')) # optional - sage.rings.finite_rings - [(0 : 1), (b : 1), (b + 1 : 1), (2*b + 1 : 1), (2 : 1), (2*b : 1), - (2*b + 2 : 1), (b + 2 : 1), (1 : 1), (1 : 0)] + sage: sorted(P.rational_points(GF(3^2, 'b')), key=str) # needs sage.rings.finite_rings + [(0 : 1), (1 : 0), (1 : 1), (2 : 1), + (2*b + 1 : 1), (2*b + 2 : 1), (2*b : 1), + (b + 1 : 1), (b + 2 : 1), (b : 1)] """ if F is None: return [P for P in self] @@ -2371,8 +2386,8 @@ def rational_points_dictionary(self): EXAMPLES:: - sage: P1 = ProjectiveSpace(GF(7), 1, 'x') # optional - sage.rings.finite_rings - sage: P1.rational_points_dictionary() # optional - sage.rings.finite_rings + sage: P1 = ProjectiveSpace(GF(7), 1, 'x') + sage: P1.rational_points_dictionary() {(0 : 1): 0, (1 : 0): 7, (1 : 1): 1, diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py index c247f630ff6..3240b01df2c 100644 --- a/src/sage/schemes/projective/projective_subscheme.py +++ b/src/sage/schemes/projective/projective_subscheme.py @@ -168,6 +168,7 @@ def dimension(self): EXAMPLES:: + sage: # needs sage.libs.singular sage: P2. = ProjectiveSpace(2, QQ) sage: P2.subscheme([]).dimension() 2 @@ -190,7 +191,7 @@ def dimension(self): x^2*y^2 + z^2*t^2, z^2 - w^2, 10*x^2 - z^2 + w^2 - sage: X.dimension() + sage: X.dimension() # needs sage.libs.singular 1 """ try: @@ -221,11 +222,11 @@ def affine_patch(self, i, AA=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: PP = ProjectiveSpace(2, QQ, names='X,Y,Z') sage: X,Y,Z = PP.gens() sage: C = PP.subscheme(X^3*Y + Y^3*Z + Z^3*X) - sage: U = C.affine_patch(0) - sage: U + sage: U = C.affine_patch(0); U Closed subscheme of Affine Space of dimension 2 over Rational Field defined by: Y^3*Z + Z^3 + Y sage: U.embedding_morphism() @@ -242,8 +243,8 @@ def affine_patch(self, i, AA=None): sage: A. = AffineSpace(QQ, 3) sage: X = A.subscheme([x - y*z]) - sage: Y = X.projective_embedding(1).codomain() - sage: Y.affine_patch(1, A).ambient_space() == A + sage: Y = X.projective_embedding(1).codomain() # needs sage.libs.singular + sage: Y.affine_patch(1, A).ambient_space() == A # needs sage.libs.singular True :: @@ -251,7 +252,7 @@ def affine_patch(self, i, AA=None): sage: P. = ProjectiveSpace(2, ZZ) sage: S = P.subscheme([u^2 - v*w]) sage: A. = AffineSpace(2, ZZ) - sage: S.affine_patch(1, A) + sage: S.affine_patch(1, A) # needs sage.libs.singular Closed subscheme of Affine Space of dimension 2 over Integer Ring defined by: x^2 - y """ @@ -310,9 +311,9 @@ def _best_affine_patch(self, point): TESTS:: - sage: F = GF(3) # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(F, 2) # optional - sage.rings.finite_rings - sage: S._best_affine_patch([0,1,2]) # optional - sage.rings.finite_rings + sage: F = GF(3) + sage: P. = ProjectiveSpace(F, 2) + sage: S._best_affine_patch([0,1,2]) 2 """ point = list(point) @@ -410,6 +411,7 @@ def is_smooth(self, point=None): EXAMPLES:: + sage: # needs sage.libs.singular sage: P2. = ProjectiveSpace(2, QQ) sage: cuspidal_curve = P2.subscheme([y^2*z - x^3]) sage: cuspidal_curve @@ -426,8 +428,8 @@ def is_smooth(self, point=None): TESTS:: - sage: H = P2.subscheme(x) - sage: H.is_smooth() # one of the few cases where the cone over the subvariety is smooth + sage: H = P2.subscheme(x) # needs sage.libs.singular + sage: H.is_smooth() # one of the few cases where the cone over the subvariety is smooth # needs sage.libs.singular True """ if point is not None: @@ -468,8 +470,9 @@ def orbit(self, f, N): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 3) - sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, (x-2*w)^2, x^2]) - sage: f.orbit(P.subscheme([x]), 5) + sage: f = DynamicalSystem_projective([(x-2*y)^2, (x-2*z)^2, # needs sage.schemes + ....: (x-2*w)^2, x^2]) + sage: f.orbit(P.subscheme([x]), 5) # needs sage.schemes [Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: x, Closed subscheme of Projective Space of dimension 3 over Rational Field @@ -498,9 +501,9 @@ def orbit(self, f, N): :: sage: PS. = ProjectiveSpace(QQ, 2) - sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) + sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) # needs sage.schemes sage: X = PS.subscheme([x - y]) - sage: X.orbit(f, [-1,2]) + sage: X.orbit(f, [-1,2]) # needs sage.schemes Traceback (most recent call last): ... TypeError: orbit bounds must be non-negative @@ -544,8 +547,8 @@ def nth_iterate(self, f, n): EXAMPLES:: sage: P. = ProjectiveSpace(QQ, 3) - sage: f = DynamicalSystem_projective([y^2, z^2, x^2, w^2]) - sage: f.nth_iterate(P.subscheme([x - w, y - z]), 3) + sage: f = DynamicalSystem_projective([y^2, z^2, x^2, w^2]) # needs sage.schemes + sage: f.nth_iterate(P.subscheme([x - w, y - z]), 3) # needs sage.schemes Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: y - z, @@ -554,9 +557,9 @@ def nth_iterate(self, f, n): :: sage: PS. = ProjectiveSpace(ZZ, 2) - sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) + sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) # needs sage.schemes sage: X = PS.subscheme([x - y]) - sage: X.nth_iterate(f, -2) + sage: X.nth_iterate(f, -2) # needs sage.schemes Traceback (most recent call last): ... TypeError: must be a forward orbit @@ -576,9 +579,9 @@ def nth_iterate(self, f, n): :: sage: PS. = ProjectiveSpace(QQ, 2) - sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) + sage: f = DynamicalSystem_projective([x^2, y^2, z^2]) # needs sage.schemes sage: X = PS.subscheme([x - y]) - sage: X.nth_iterate(f, 2.5) + sage: X.nth_iterate(f, 2.5) # needs sage.schemes Traceback (most recent call last): ... TypeError: Attempt to coerce non-integral RealNumber to Integer @@ -615,7 +618,7 @@ def _forward_image(self, f, check=True): sage: H = End(PS) sage: f = H([x^2, y^2 - 2*z^2, z^2]) sage: X = PS.subscheme(y - 2*z) - sage: X._forward_image(f) + sage: X._forward_image(f) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: y - 2*z @@ -627,7 +630,7 @@ def _forward_image(self, f, check=True): sage: H = End(PS) sage: f = H([y^2, x^2, w^2, z^2]) sage: X = PS.subscheme([z^2 + y*w, x - w]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Integer Ring defined by: y - z, @@ -635,11 +638,12 @@ def _forward_image(self, f, check=True): :: + sage: # needs sage.rings.real_mpfr sage: PS. = ProjectiveSpace(CC, 3) sage: H = End(PS) sage: f = H([x^2 + y^2, y^2, z^2-y^2, w^2]) sage: X = PS.subscheme([z - 2*w]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Complex Field with 53 bits of precision defined by: y + z + (-4.00000000000000)*w @@ -650,19 +654,20 @@ def _forward_image(self, f, check=True): sage: P. = ProjectiveSpace(FractionField(R), 2) sage: H = End(P) sage: f = H([x^2 + 2*y*z, t^2*y^2, z^2]) - sage: f([t^2*y - z]) + sage: f([t^2*y - z]) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Fraction Field of Univariate Polynomial Ring in t over Rational Field defined by: y - 1/(t^2)*z :: + sage: # needs sage.rings.padics sage: set_verbose(-1) - sage: PS. = ProjectiveSpace(Qp(3), 2) # optional - sage.rings.padics - sage: H = End(PS) # optional - sage.rings.padics - sage: f = H([x^2, 2*y^2, z^2]) # optional - sage.rings.padics - sage: X = PS.subscheme([2*x - y, z]) # optional - sage.rings.padics - sage: f(X) # optional - sage.rings.padics + sage: PS. = ProjectiveSpace(Qp(3), 2) + sage: H = End(PS) + sage: f = H([x^2, 2*y^2, z^2]) + sage: X = PS.subscheme([2*x - y, z]) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over 3-adic Field with capped relative precision 20 defined by: z, @@ -675,7 +680,7 @@ def _forward_image(self, f, check=True): sage: H = End(P) sage: f = H([y0*x^2 + y1*z^2, y2*y^2 + y3*z^2, z^2]) sage: X = P.subscheme(x*z) - sage: X._forward_image(f) + sage: X._forward_image(f) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Fraction Field of Multivariate Polynomial Ring in y0, y1, y2, y3 over Rational Field defined by: @@ -688,7 +693,7 @@ def _forward_image(self, f, check=True): sage: H = Hom(P2, P5) sage: f = H([x^2, x*y, x*z, y^2, y*z, z^2]) # Veronese map sage: X = P2.subscheme([]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 5 over Rational Field defined by: -z4^2 + z3*z5, @@ -705,7 +710,7 @@ def _forward_image(self, f, check=True): sage: H = Hom(P2, P3) sage: X = P2.subscheme([x - y, x - z]) sage: f = H([x^2, y^2, z^2, x*y]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: w - t, @@ -719,7 +724,7 @@ def _forward_image(self, f, check=True): sage: H = Hom(P2, P1) sage: f = H([x^2, y*z]) sage: X = P2.subscheme([x - y]) - sage: f(X) + sage: f(X) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: map must be a morphism @@ -730,7 +735,7 @@ def _forward_image(self, f, check=True): sage: H = End(PS) sage: f = H([x^3, x*y^2, x*z^2]) sage: X = PS.subscheme([x - y]) - sage: X._forward_image(f) + sage: X._forward_image(f) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: map must be a morphism @@ -742,7 +747,7 @@ def _forward_image(self, f, check=True): sage: Y = P1.subscheme([u - v]) sage: H = End(PS) sage: f = H([x^2, y^2, z^2]) - sage: Y._forward_image(f) + sage: Y._forward_image(f) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: subscheme must be in ambient space of domain of map @@ -801,7 +806,7 @@ def preimage(self, f, k=1, check=True): sage: H = End(PS) sage: f = H([y^2, x^2, z^2]) sage: X = PS.subscheme([x - y]) - sage: X.preimage(f) + sage: X.preimage(f) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Integer Ring defined by: -x^2 + y^2 @@ -811,7 +816,7 @@ def preimage(self, f, k=1, check=True): sage: P. = ProjectiveSpace(QQ, 4) sage: H = End(P) sage: f = H([x^2 - y^2, y^2, z^2, w^2, t^2 + w^2]) - sage: f.rational_preimages(P.subscheme([x - z, t^2, w - t])) + sage: f.rational_preimages(P.subscheme([x - z, t^2, w - t])) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 4 over Rational Field defined by: x^2 - y^2 - z^2, @@ -825,7 +830,7 @@ def preimage(self, f, k=1, check=True): sage: H = Hom(P1, P3) sage: X = P3.subscheme([u - v, 2*u - w, u + t]) sage: f = H([x^2, y^2, x^2 + y^2, x*y]) - sage: X.preimage(f) + sage: X.preimage(f) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: x^2 - y^2, @@ -839,7 +844,7 @@ def preimage(self, f, k=1, check=True): sage: H = Hom(P3, P1) sage: X = P1.subscheme([x - y]) sage: f = H([u^2, v^2]) - sage: X.preimage(f) + sage: X.preimage(f) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: map must be a morphism @@ -850,7 +855,7 @@ def preimage(self, f, k=1, check=True): sage: H = End(PS) sage: f = H([x^2, x^2, x^2]) sage: X = PS.subscheme([x - y]) - sage: X.preimage(f) + sage: X.preimage(f) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: map must be a morphism @@ -862,7 +867,7 @@ def preimage(self, f, k=1, check=True): sage: Y = P1.subscheme([u^2 - v^2]) sage: H = End(PS) sage: f = H([x^2, y^2, z^2]) - sage: Y.preimage(f) + sage: Y.preimage(f) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: subscheme must be in ambient space of codomain @@ -873,7 +878,7 @@ def preimage(self, f, k=1, check=True): sage: Y = P.subscheme([x - y]) sage: H = End(P) sage: f = H([x^2, y^2, z^2]) - sage: Y.preimage(f, k=2) + sage: Y.preimage(f, k=2) # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: x^4 - y^4 @@ -920,7 +925,7 @@ def dual(self): sage: P. = ProjectiveSpace(2, QQ) sage: I = R.ideal(x^2 + y^2 + z^2) sage: X = P.subscheme(I) - sage: X.dual() + sage: X.dual() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: y0^2 + y1^2 + y2^2 @@ -934,7 +939,7 @@ def dual(self): sage: P. = ProjectiveSpace(3, QQ) sage: I = R.ideal(y^2*z^2 - 4*x*z^3 - 4*y^3*w + 18*x*y*z*w - 27*x^2*w^2) sage: X = P.subscheme(I) - sage: X.dual() + sage: X.dual() # needs sage.libs.singular Closed subscheme of Projective Space of dimension 3 over Rational Field defined by: y2^2 - y1*y3, @@ -944,26 +949,27 @@ def dual(self): The singular locus of the quartic surface in the last example is itself supported on a twisted cubic:: - sage: X.Jacobian().radical() + sage: X.Jacobian().radical() # needs sage.libs.singular Ideal (z^2 - 3*y*w, y*z - 9*x*w, y^2 - 3*x*z) of Multivariate Polynomial Ring in x, y, z, w over Rational Field An example over a finite field:: - sage: R = PolynomialRing(GF(61), 'a,b,c') # optional - sage.rings.finite_rings - sage: P. = ProjectiveSpace(2, R.base_ring()) # optional - sage.rings.finite_rings - sage: X = P.subscheme(R.ideal(a*a + 2*b*b + 3*c*c)) # optional - sage.rings.finite_rings - sage: X.dual() # optional - sage.rings.finite_rings + sage: R = PolynomialRing(GF(61), 'a,b,c') + sage: P. = ProjectiveSpace(2, R.base_ring()) + sage: X = P.subscheme(R.ideal(a*a + 2*b*b + 3*c*c)) + sage: X.dual() # needs sage.libs.singular sage.rings.finite_rings Closed subscheme of Projective Space of dimension 2 over Finite Field of size 61 defined by: y0^2 - 30*y1^2 - 20*y2^2 TESTS:: - sage: R = PolynomialRing(Qp(3), 'a,b,c') # optional - sage.rings.padics - sage: P. = ProjectiveSpace(2, R.base_ring()) # optional - sage.rings.padics - sage: X = P.subscheme(R.ideal(a*a + 2*b*b + 3*c*c)) # optional - sage.rings.padics - sage: X.dual() # optional - sage.rings.padics + sage: # needs sage.rings.padics + sage: R = PolynomialRing(Qp(3), 'a,b,c') + sage: P. = ProjectiveSpace(2, R.base_ring()) + sage: X = P.subscheme(R.ideal(a*a + 2*b*b + 3*c*c)) + sage: X.dual() Traceback (most recent call last): ... NotImplementedError: base ring must be QQ or a finite field @@ -1025,17 +1031,17 @@ def degree(self): sage: P. = ProjectiveSpace(QQ, 5) sage: X = P.subscheme([x^7 + x*y*z*t^4 - u^7]) - sage: X.degree() + sage: X.degree() # needs sage.libs.singular 7 - sage: P. = ProjectiveSpace(GF(13), 3) # optional - sage.rings.finite_rings - sage: X = P.subscheme([y^3 - w^3, x + 7*z]) # optional - sage.rings.finite_rings - sage: X.degree() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(13), 3) + sage: X = P.subscheme([y^3 - w^3, x + 7*z]) + sage: X.degree() # needs sage.libs.singular 3 sage: P. = ProjectiveSpace(QQ, 4) - sage: C = P.curve([x^7 - y*z^3*w^2*u, w*x^2 - y*u^2, z^3 + y^3]) - sage: C.degree() + sage: C = P.curve([x^7 - y*z^3*w^2*u, w*x^2 - y*u^2, z^3 + y^3]) # needs sage.schemes + sage: C.degree() # needs sage.libs.singular sage.schemes 63 """ P = self.defining_ideal().hilbert_polynomial() @@ -1058,28 +1064,30 @@ def intersection_multiplicity(self, X, P): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(5), 2) # optional - sage.rings.finite_rings - sage: C = Curve([x^4 - z^2*y^2], P) # optional - sage.rings.finite_rings - sage: D = Curve([y^4*z - x^5 - x^3*z^2], P) # optional - sage.rings.finite_rings - sage: Q1 = P([0,1,0]) # optional - sage.rings.finite_rings - sage: C.intersection_multiplicity(D, Q1) # optional - sage.rings.finite_rings + sage: # needs sage.schemes + sage: P. = ProjectiveSpace(GF(5), 2) + sage: C = Curve([x^4 - z^2*y^2], P) + sage: D = Curve([y^4*z - x^5 - x^3*z^2], P) + sage: Q1 = P([0,1,0]) + sage: C.intersection_multiplicity(D, Q1) # needs sage.libs.singular 4 - sage: Q2 = P([0,0,1]) # optional - sage.rings.finite_rings - sage: C.intersection_multiplicity(D, Q2) # optional - sage.rings.finite_rings + sage: Q2 = P([0,0,1]) + sage: C.intersection_multiplicity(D, Q2) # needs sage.libs.singular 6 :: + sage: # needs sage.rings.number_field sage: R. = QQ[] - sage: K. = NumberField(a^4 + 1) # optional - sage.rings.number_field - sage: P. = ProjectiveSpace(K, 3) # optional - sage.rings.number_field - sage: X = P.subscheme([x^2 + y^2 - z*w]) # optional - sage.rings.number_field - sage: Y = P.subscheme([y*z - x*w, z - w]) # optional - sage.rings.number_field - sage: Q1 = P([b^2,1,0,0]) # optional - sage.rings.number_field - sage: X.intersection_multiplicity(Y, Q1) # optional - sage.rings.number_field + sage: K. = NumberField(a^4 + 1) + sage: P. = ProjectiveSpace(K, 3) + sage: X = P.subscheme([x^2 + y^2 - z*w]) + sage: Y = P.subscheme([y*z - x*w, z - w]) + sage: Q1 = P([b^2,1,0,0]) + sage: X.intersection_multiplicity(Y, Q1) # needs sage.libs.singular 1 - sage: Q2 = P([1/2*b^3 - 1/2*b, 1/2*b^3 - 1/2*b, 1, 1]) # optional - sage.rings.number_field - sage: X.intersection_multiplicity(Y, Q2) # optional - sage.rings.number_field + sage: Q2 = P([1/2*b^3 - 1/2*b, 1/2*b^3 - 1/2*b, 1, 1]) + sage: X.intersection_multiplicity(Y, Q2) # needs sage.libs.singular 1 :: @@ -1088,7 +1096,7 @@ def intersection_multiplicity(self, X, P): sage: X = P.subscheme([x^2 - z^2, y^3 - w*x^2]) sage: Y = P.subscheme([w^2 - 2*x*y + z^2, y^2 - w^2]) sage: Q = P([1,1,-1,1]) - sage: X.intersection_multiplicity(Y, Q) + sage: X.intersection_multiplicity(Y, Q) # needs sage.libs.singular Traceback (most recent call last): ... TypeError: the intersection of this subscheme and (=Closed subscheme of Affine Space of dimension 3 @@ -1129,29 +1137,30 @@ def multiplicity(self, P): sage: P. = ProjectiveSpace(QQ, 4) sage: X = P.subscheme([y^2 - x*t, w^7 - t*w*x^5 - z^7]) sage: Q1 = P([0,0,1,1,1]) - sage: X.multiplicity(Q1) + sage: X.multiplicity(Q1) # needs sage.libs.singular 1 sage: Q2 = P([1,0,0,0,0]) - sage: X.multiplicity(Q2) + sage: X.multiplicity(Q2) # needs sage.libs.singular 3 sage: Q3 = P([0,0,0,0,1]) - sage: X.multiplicity(Q3) + sage: X.multiplicity(Q3) # needs sage.libs.singular 7 :: + sage: # needs sage.rings.real_mpfr sage: P. = ProjectiveSpace(CC, 3) sage: X = P.subscheme([z^5*x^2*w - y^8]) sage: Q = P([2,0,0,1]) - sage: X.multiplicity(Q) + sage: X.multiplicity(Q) # needs sage.libs.singular 5 :: - sage: P. = ProjectiveSpace(GF(29), 3) # optional - sage.rings.finite_rings - sage: C = Curve([y^17 - x^5*w^4*z^8, x*y - z^2], P) # optional - sage.rings.finite_rings - sage: Q = P([3,0,0,1]) # optional - sage.rings.finite_rings - sage: C.multiplicity(Q) # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(29), 3) + sage: C = Curve([y^17 - x^5*w^4*z^8, x*y - z^2], P) # needs sage.schemes + sage: Q = P([3,0,0,1]) + sage: C.multiplicity(Q) # needs sage.libs.singular sage.schemes 8 """ if self.base_ring() not in Fields(): @@ -1193,8 +1202,7 @@ def veronese_embedding(self, d, CS=None, order='lex'): sage: P. = ProjectiveSpace(QQ, 2) sage: L = P.subscheme([y - x]) - sage: v = L.veronese_embedding(2) - sage: v + sage: v = L.veronese_embedding(2); v # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Projective Space of dimension 2 over Rational Field defined by: -x + y @@ -1206,17 +1214,17 @@ def veronese_embedding(self, d, CS=None, order='lex'): x0 - x3 Defn: Defined on coordinates by sending (x : y : z) to (x^2 : x*y : x*z : y^2 : y*z : z^2) - sage: v.codomain().degree() + sage: v.codomain().degree() # needs sage.libs.singular 2 sage: C = P.subscheme([y*z - x^2]) - sage: C.veronese_embedding(2).codomain().degree() + sage: C.veronese_embedding(2).codomain().degree() # needs sage.libs.singular 4 twisted cubic:: sage: P. = ProjectiveSpace(QQ, 1) sage: Q. = ProjectiveSpace(QQ, 3) - sage: P.subscheme([]).veronese_embedding(3, Q) + sage: P.subscheme([]).veronese_embedding(3, Q) # needs sage.libs.singular Scheme morphism: From: Closed subscheme of Projective Space of dimension 1 over Rational Field defined by: (no polynomials) @@ -1298,20 +1306,21 @@ def Chow_form(self): EXAMPLES:: - sage: P. = ProjectiveSpace(GF(17), 3) # optional - sage.rings.finite_rings - sage: X = P.subscheme([x3 + x1, x2 - x0, x2 - x3]) # optional - sage.rings.finite_rings - sage: X.Chow_form() # optional - sage.rings.finite_rings + sage: P. = ProjectiveSpace(GF(17), 3) + sage: X = P.subscheme([x3 + x1, x2 - x0, x2 - x3]) + sage: X.Chow_form() # needs sage.libs.singular t0 - t1 + t2 + t3 :: sage: P. = ProjectiveSpace(QQ, 3) sage: X = P.subscheme([x3^2 - 101*x1^2 - 3*x2*x0]) - sage: X.Chow_form() + sage: X.Chow_form() # needs sage.libs.singular t0^2 - 101*t2^2 - 3*t1*t3 :: + sage: # needs sage.libs.singular sage: P. = ProjectiveSpace(QQ, 3) sage: X = P.subscheme([x0*x2 - x1^2, x0*x3 - x1*x2, x1*x3 - x2^2]) sage: Ch = X.Chow_form(); Ch diff --git a/src/sage/schemes/riemann_surfaces/riemann_surface.py b/src/sage/schemes/riemann_surfaces/riemann_surface.py index 917de00d7b0..14599021c5d 100644 --- a/src/sage/schemes/riemann_surfaces/riemann_surface.py +++ b/src/sage/schemes/riemann_surfaces/riemann_surface.py @@ -1,3 +1,4 @@ +# sage.doctest: needs scipy sage.graphs sage.groups r""" Riemann matrices and endomorphism rings of algebraic Riemann surfaces @@ -124,6 +125,7 @@ from sage.misc.cachefunc import cached_method from sage.misc.flatten import flatten from sage.misc.functional import numerical_approx +from sage.misc.lazy_import import lazy_import from sage.misc.misc_c import prod from sage.modules.free_module import VectorSpace from sage.modules.free_module_integer import IntegerLattice @@ -134,12 +136,13 @@ from sage.rings.infinity import Infinity from sage.rings.integer_ring import ZZ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing -from sage.rings.qqbar import number_field_elements_from_algebraics from sage.rings.rational_field import QQ from sage.rings.real_mpfr import RealField from sage.schemes.curves.constructor import Curve import sage.libs.mpmath.all as mpall +lazy_import('sage.rings.qqbar', 'number_field_elements_from_algebraics') + def voronoi_ghost(cpoints, n=6, CC=CDF): r""" @@ -2372,7 +2375,8 @@ def period_matrix(self): easier to test.:: sage: parent(M) - Full MatrixSpace of 3 by 6 dense matrices over Complex Field with 30 bits of precision + Full MatrixSpace of 3 by 6 dense matrices + over Complex Field with 30 bits of precision sage: M.rank() 3 @@ -2438,7 +2442,7 @@ def plot_paths(self): sage: from sage.schemes.riemann_surfaces.riemann_surface import RiemannSurface sage: R. = QQ[] sage: S = RiemannSurface(y^2 - x^3 - x) - sage: S.plot_paths() + sage: S.plot_paths() # needs sage.plot Graphics object consisting of 2 graphics primitives """ from sage.plot.point import point2d @@ -2474,8 +2478,8 @@ def plot_paths3d(self, thickness=0.01): sage: from sage.schemes.riemann_surfaces.riemann_surface import RiemannSurface sage: R. = QQ[] - sage: S = RiemannSurface(y^2-x^3-x) - sage: S.plot_paths3d() + sage: S = RiemannSurface(y^2 - x^3 - x) + sage: S.plot_paths3d() # needs sage.plot Graphics3d Object """ from sage.plot.graphics import Graphics @@ -2955,7 +2959,7 @@ def _integrate_differentials_iteratively( sage: s = sign(w_start) sage: u_edge = ((z_start, w_start), z_end) sage: J, _ = S._integrate_differentials_iteratively(u_edge) - sage: bool(J[0]+s*S._RR(sqrt(pi)*gamma(5/4)/gamma(3/4)/2)<1e-10) + sage: bool(J[0] + s*S._RR(sqrt(pi)*gamma(5/4)/gamma(3/4)/2) < 1e-10) # needs sage.symbolic True .. NOTE:: diff --git a/src/sage/schemes/toric/all.py b/src/sage/schemes/toric/all.py index 9d7c83954a7..71ad52ef5c6 100644 --- a/src/sage/schemes/toric/all.py +++ b/src/sage/schemes/toric/all.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs from sage.misc.lazy_import import lazy_import lazy_import('sage.schemes.toric.weierstrass', 'WeierstrassForm') diff --git a/src/sage/schemes/toric/chow_group.py b/src/sage/schemes/toric/chow_group.py index 8c835df37d2..ae3d245c744 100644 --- a/src/sage/schemes/toric/chow_group.py +++ b/src/sage/schemes/toric/chow_group.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs # -*- coding: utf-8 -*- r""" The Chow group of a toric variety @@ -862,7 +863,7 @@ def degree(self, k=None): sage: points = [[1,0,0], [0,1,0], [0,0,1], [1,-1,1], [-1,0,-1]] sage: l = LatticePolytope(points) - sage: l.show3d() + sage: l.show3d() # needs sage.plot sage: X = ToricVariety(FaceFan(l)) sage: A = X.Chow_group() sage: A.degree(2) diff --git a/src/sage/schemes/toric/divisor.py b/src/sage/schemes/toric/divisor.py index c71ca05eede..3fbdae4cdb5 100644 --- a/src/sage/schemes/toric/divisor.py +++ b/src/sage/schemes/toric/divisor.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Toric divisors and divisor classes diff --git a/src/sage/schemes/toric/divisor_class.pyx b/src/sage/schemes/toric/divisor_class.pyx index d0c497d8a94..5a92fe5b38d 100644 --- a/src/sage/schemes/toric/divisor_class.pyx +++ b/src/sage/schemes/toric/divisor_class.pyx @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Toric rational divisor classes diff --git a/src/sage/schemes/toric/fano_variety.py b/src/sage/schemes/toric/fano_variety.py index 06e942c5336..a1405c966ec 100644 --- a/src/sage/schemes/toric/fano_variety.py +++ b/src/sage/schemes/toric/fano_variety.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Fano toric varieties @@ -1304,9 +1305,9 @@ def __init__(self, P_Delta, monomial_points=None, coefficient_names=None, Check that finite fields are handled correctly :trac:`14899`:: - sage: F = GF(5^2, "a") # optional - sage.rings.finite_rings - sage: X = P1xP1.change_ring(F) # optional - sage.rings.finite_rings - sage: X.anticanonical_hypersurface(monomial_points="all", # optional - sage.rings.finite_rings + sage: F = GF(5^2, "a") # needs sage.rings.finite_rings + sage: X = P1xP1.change_ring(F) # needs sage.rings.finite_rings + sage: X.anticanonical_hypersurface(monomial_points="all", # needs sage.rings.finite_rings ....: coefficients=[1]*X.Delta().npoints()) Closed subscheme of 2-d CPR-Fano toric variety covered by 4 affine patches defined by: diff --git a/src/sage/schemes/toric/homset.py b/src/sage/schemes/toric/homset.py index 4470303d8d4..bd535edf932 100644 --- a/src/sage/schemes/toric/homset.py +++ b/src/sage/schemes/toric/homset.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Set of homomorphisms between two toric varieties @@ -324,7 +325,7 @@ def is_finite(self): sage: P2 = toric_varieties.P2() sage: P2.point_set().is_finite() False - sage: P2.change_ring(GF(7)).point_set().is_finite() # optional - sage.rings.finite_rings + sage: P2.change_ring(GF(7)).point_set().is_finite() True """ variety = self.codomain() @@ -347,11 +348,11 @@ def _naive_enumerator(self, ring=None): EXAMPLES:: - sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P123.point_set() # optional - sage.rings.finite_rings - sage: next(iter(point_set._naive_enumerator())) # optional - sage.rings.finite_rings + sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) + sage: point_set = P123.point_set() + sage: next(iter(point_set._naive_enumerator())) (0, 0, 1) - sage: next(iter(point_set)) # optional - sage.rings.finite_rings + sage: next(iter(point_set)) [0 : 0 : 1] """ from sage.schemes.toric.points import NaiveFinitePointEnumerator @@ -378,11 +379,11 @@ def _finite_field_enumerator(self, finite_field=None): EXAMPLES:: - sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P123.point_set() # optional - sage.rings.finite_rings - sage: next(iter(point_set._finite_field_enumerator())) # optional - sage.rings.finite_rings + sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) + sage: point_set = P123.point_set() + sage: next(iter(point_set._finite_field_enumerator())) (0, 0, 1) - sage: next(iter(point_set)) # optional - sage.rings.finite_rings + sage: next(iter(point_set)) [0 : 0 : 1] """ from sage.schemes.toric.points import FiniteFieldPointEnumerator @@ -404,9 +405,9 @@ def _enumerator(self): EXAMPLES:: - sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P123.point_set() # optional - sage.rings.finite_rings - sage: point_set._enumerator() # optional - sage.rings.finite_rings + sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) + sage: point_set = P123.point_set() + sage: point_set._enumerator() """ ring = self.domain().base_ring() @@ -448,11 +449,11 @@ class SchemeHomset_points_toric_field(SchemeHomset_points_toric_base): unity:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_field=GF(7)) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: point_set.cardinality() # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_field=GF(7)) + sage: point_set = X.point_set() + sage: point_set.cardinality() 21 - sage: sorted(X.point_set().list()) # optional - sage.rings.finite_rings + sage: sorted(X.point_set().list()) [[0 : 0 : 1], [0 : 1 : 0], [0 : 1 : 1], [0 : 1 : 3], [1 : 0 : 0], [1 : 0 : 1], [1 : 0 : 3], [1 : 1 : 0], [1 : 1 : 1], [1 : 1 : 2], [1 : 1 : 3], [1 : 1 : 4], @@ -466,9 +467,9 @@ class SchemeHomset_points_toric_field(SchemeHomset_points_toric_base): on the fiber:: sage: fan = Fan([Cone([(1,0), (1,1)]), Cone([(1,1), (0,1)])]) - sage: blowup_plane = ToricVariety(fan, base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = blowup_plane.point_set() # optional - sage.rings.finite_rings - sage: sorted(point_set.list()) # optional - sage.rings.finite_rings + sage: blowup_plane = ToricVariety(fan, base_ring=GF(3)) + sage: point_set = blowup_plane.point_set() + sage: sorted(point_set.list()) [[0 : 1 : 0], [0 : 1 : 1], [0 : 1 : 2], [1 : 0 : 0], [1 : 0 : 1], [1 : 0 : 2], [1 : 1 : 0], [1 : 1 : 1], [1 : 1 : 2], @@ -477,8 +478,8 @@ class SchemeHomset_points_toric_field(SchemeHomset_points_toric_base): Toric varieties with torus factors (that is, where the fan is not full-dimensional) also work:: - sage: F_times_Fstar = ToricVariety(Fan([Cone([(1,0)])]), base_field=GF(3)) # optional - sage.rings.finite_rings - sage: sorted(F_times_Fstar.point_set().list()) # optional - sage.rings.finite_rings + sage: F_times_Fstar = ToricVariety(Fan([Cone([(1,0)])]), base_field=GF(3)) + sage: sorted(F_times_Fstar.point_set().list()) [[0 : 1], [0 : 2], [1 : 1], [1 : 2], [2 : 1], [2 : 2]] TESTS:: @@ -500,29 +501,29 @@ def cardinality(self): sage: o = lattice_polytope.cross_polytope(3) sage: V = ToricVariety(FaceFan(o)) - sage: V.change_ring(GF(2)).point_set().cardinality() # optional - sage.rings.finite_rings + sage: V.change_ring(GF(2)).point_set().cardinality() 27 - sage: V.change_ring(GF(8, "a")).point_set().cardinality() # optional - sage.rings.finite_rings + sage: V.change_ring(GF(8, "a")).point_set().cardinality() # needs sage.rings.finite_rings 729 - sage: V.change_ring(GF(101)).point_set().cardinality() # optional - sage.rings.finite_rings + sage: V.change_ring(GF(101)).point_set().cardinality() 1061208 For non-smooth varieties over finite fields, the homogeneous rescalings are solved. This is somewhat slower:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_field=GF(7)) # optional - sage.rings.finite_rings - sage: X.point_set().cardinality() # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_field=GF(7)) + sage: X.point_set().cardinality() 21 Fulton's formula does not apply since the variety is not smooth. And, indeed, naive application gives a different result:: - sage: q = X.base_ring().order() # optional - sage.rings.finite_rings - sage: n = X.dimension() # optional - sage.rings.finite_rings - sage: d = map(len, fan().cones()) # optional - sage.rings.finite_rings - sage: sum(dk * (q-1)**(n-k) for k, dk in enumerate(d)) # optional - sage.rings.finite_rings + sage: q = X.base_ring().order() + sage: n = X.dimension() + sage: d = map(len, fan().cones()) + sage: sum(dk * (q-1)**(n-k) for k, dk in enumerate(d)) 57 Over infinite fields the number of points is not very tricky:: @@ -571,11 +572,11 @@ def __iter__(self): EXAMPLES:: - sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P123.point_set() # optional - sage.rings.finite_rings - sage: next(iter(point_set.__iter__())) # optional - sage.rings.finite_rings + sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) + sage: point_set = P123.point_set() + sage: next(iter(point_set.__iter__())) [0 : 0 : 1] - sage: next(iter(point_set)) # syntactic sugar # optional - sage.rings.finite_rings + sage: next(iter(point_set)) # syntactic sugar [0 : 0 : 1] """ for pt in self._enumerator(): @@ -595,9 +596,9 @@ def _enumerator(self): EXAMPLES:: - sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P123.point_set() # optional - sage.rings.finite_rings - sage: point_set._enumerator() # optional - sage.rings.finite_rings + sage: P123 = toric_varieties.P2_123(base_ring=GF(3)) + sage: point_set = P123.point_set() + sage: point_set._enumerator() """ ambient = super()._enumerator() @@ -620,11 +621,11 @@ def __iter__(self): EXAMPLES:: - sage: P2. = toric_varieties.P2(base_ring=GF(5)) # optional - sage.rings.finite_rings - sage: cubic = P2.subscheme([x^3 + y^3 + z^3]) # optional - sage.rings.finite_rings - sage: list(cubic.point_set()) # optional - sage.rings.finite_rings + sage: P2. = toric_varieties.P2(base_ring=GF(5)) + sage: cubic = P2.subscheme([x^3 + y^3 + z^3]) + sage: list(cubic.point_set()) [[0 : 1 : 4], [1 : 0 : 4], [1 : 4 : 0], [1 : 1 : 2], [1 : 2 : 1], [1 : 3 : 3]] - sage: cubic.point_set().cardinality() # optional - sage.rings.finite_rings + sage: cubic.point_set().cardinality() 6 """ for p in self._enumerator(): @@ -640,11 +641,11 @@ def cardinality(self): EXAMPLES:: - sage: P2. = toric_varieties.P2(base_ring=GF(5)) # optional - sage.rings.finite_rings - sage: cubic = P2.subscheme([x^3 + y^3 + z^3]) # optional - sage.rings.finite_rings - sage: list(cubic.point_set()) # optional - sage.rings.finite_rings + sage: P2. = toric_varieties.P2(base_ring=GF(5)) + sage: cubic = P2.subscheme([x^3 + y^3 + z^3]) + sage: list(cubic.point_set()) [[0 : 1 : 4], [1 : 0 : 4], [1 : 4 : 0], [1 : 1 : 2], [1 : 2 : 1], [1 : 3 : 3]] - sage: cubic.point_set().cardinality() # optional - sage.rings.finite_rings + sage: cubic.point_set().cardinality() 6 """ try: diff --git a/src/sage/schemes/toric/ideal.py b/src/sage/schemes/toric/ideal.py index d2f0b094f5a..bf9eb94e331 100644 --- a/src/sage/schemes/toric/ideal.py +++ b/src/sage/schemes/toric/ideal.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Toric ideals @@ -217,7 +218,7 @@ def __init__(self, A, sage: ToricIdeal(A) Ideal (-z1^2 + z0*z2) of Multivariate Polynomial Ring in z0, z1, z2 over Rational Field - sage: ToricIdeal(A, names='x', base_ring=GF(101)) # optional - sage.rings.finite_rings + sage: ToricIdeal(A, names='x', base_ring=GF(101)) Ideal (-x1^2 + x0*x2) of Multivariate Polynomial Ring in x0, x1, x2 over Finite Field of size 101 sage: ToricIdeal(A, names='x', base_ring=FractionField(QQ['t'])) diff --git a/src/sage/schemes/toric/library.py b/src/sage/schemes/toric/library.py index 309b62e05c1..d70a3e95d5d 100644 --- a/src/sage/schemes/toric/library.py +++ b/src/sage/schemes/toric/library.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Library of toric varieties @@ -1330,7 +1331,7 @@ def torus(self, n, names='z+', base_ring=QQ): in 3-d lattice N sage: T3.gens() (z0, z1, z2) - sage: sorted(T3.change_ring(GF(3)).point_set().list()) # optional - sage.rings.finite_rings + sage: sorted(T3.change_ring(GF(3)).point_set().list()) [[1 : 1 : 1], [1 : 1 : 2], [1 : 2 : 1], [1 : 2 : 2], [2 : 1 : 1], [2 : 1 : 2], [2 : 2 : 1], [2 : 2 : 2]] """ diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py index 9a9f87a9b5e..1c8944b6dfc 100644 --- a/src/sage/schemes/toric/morphism.py +++ b/src/sage/schemes/toric/morphism.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Morphisms of toric varieties diff --git a/src/sage/schemes/toric/points.py b/src/sage/schemes/toric/points.py index 8a70350a30e..f9563bd0acc 100644 --- a/src/sage/schemes/toric/points.py +++ b/src/sage/schemes/toric/points.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs """ Enumerate points of a toric variety @@ -13,13 +14,13 @@ EXAMPLES:: - sage: P2 = toric_varieties.P2(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: point_set = P2.point_set() # optional - sage.rings.finite_rings - sage: point_set.cardinality() # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(3)) + sage: point_set = P2.point_set() + sage: point_set.cardinality() 13 - sage: next(iter(point_set)) # optional - sage.rings.finite_rings + sage: next(iter(point_set)) [0 : 0 : 1] - sage: list(point_set)[0:5] # optional - sage.rings.finite_rings + sage: list(point_set)[0:5] [[0 : 0 : 1], [1 : 0 : 0], [0 : 1 : 0], [0 : 1 : 1], [0 : 1 : 2]] """ @@ -122,8 +123,8 @@ def __init__(self, fan, ring): sage: from sage.schemes.toric.points import NaiveFinitePointEnumerator sage: fan = toric_varieties.P2().fan() - sage: n = NaiveFinitePointEnumerator(fan, GF(3)) # optional - sage.rings.finite_rings - sage: next(iter(n)) # optional - sage.rings.finite_rings + sage: n = NaiveFinitePointEnumerator(fan, GF(3)) + sage: next(iter(n)) (0, 0, 1) """ assert ring.is_finite() @@ -144,8 +145,8 @@ def rays(self): sage: fan.rays() Empty collection in 2-d lattice N - sage: n = NaiveFinitePointEnumerator(fan, GF(3)) # optional - sage.rings.finite_rings - sage: n.rays() # optional - sage.rings.finite_rings + sage: n = NaiveFinitePointEnumerator(fan, GF(3)) + sage: n.rays() N(1, 0), N(0, 1) in 2-d lattice N @@ -159,9 +160,9 @@ def units(self): EXAMPLES:: - sage: P2 = toric_varieties.P2(base_ring=GF(5)) # optional - sage.rings.finite_rings - sage: ne = P2.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: ne.units() # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(5)) + sage: ne = P2.point_set()._naive_enumerator() + sage: ne.units() (1, 2, 3, 4) """ return tuple(x for x in self.ring if x != 0) @@ -182,13 +183,13 @@ def roots(self, n): EXAMPLES:: - sage: P2 = toric_varieties.P2(base_ring=GF(5)) # optional - sage.rings.finite_rings - sage: ne = P2.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: ne.roots(2) # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(5)) + sage: ne = P2.point_set()._naive_enumerator() + sage: ne.roots(2) (1, 4) - sage: ne.roots(3) # optional - sage.rings.finite_rings + sage: ne.roots(3) (1,) - sage: ne.roots(4) # optional - sage.rings.finite_rings + sage: ne.roots(4) (1, 2, 3, 4) """ return tuple(x for x in self.ring if x**n == self.ring.one()) @@ -205,11 +206,11 @@ def _Chow_group_free(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X.Chow_group().degree(1) # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: X.Chow_group().degree(1) C3 x Z - sage: enum = X.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: enum._Chow_group_free() # optional - sage.rings.finite_rings + sage: enum = X.point_set()._naive_enumerator() + sage: enum._Chow_group_free() ((1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6)) """ units = self.units() @@ -233,11 +234,11 @@ def _Chow_group_torsion(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X.Chow_group().degree(1) # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: X.Chow_group().degree(1) C3 x Z - sage: enum = X.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: enum._Chow_group_torsion() # optional - sage.rings.finite_rings + sage: enum = X.point_set()._naive_enumerator() + sage: enum._Chow_group_torsion() ((1, 2, 4), (1, 4, 2)) """ if self.fan.is_smooth(): @@ -266,19 +267,19 @@ def rescalings(self): EXAMPLES:: - sage: P2_123 = toric_varieties.P2_123(base_ring=GF(5)) # optional - sage.rings.finite_rings - sage: ni = P2_123.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: ni.rescalings() # optional - sage.rings.finite_rings + sage: P2_123 = toric_varieties.P2_123(base_ring=GF(5)) + sage: ni = P2_123.point_set()._naive_enumerator() + sage: ni.rescalings() ((1, 1, 1), (1, 4, 4), (4, 2, 3), (4, 3, 2)) - sage: dP8 = toric_varieties.dP8(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: ni = dP8.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: ni.rescalings() # optional - sage.rings.finite_rings + sage: dP8 = toric_varieties.dP8(base_ring=GF(3)) + sage: ni = dP8.point_set()._naive_enumerator() + sage: ni.rescalings() ((1, 1, 1, 1), (1, 2, 2, 2), (2, 1, 2, 1), (2, 2, 1, 2)) - sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: ni = P1xP1.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: ni.rescalings() # optional - sage.rings.finite_rings + sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(3)) + sage: ni = P1xP1.point_set()._naive_enumerator() + sage: ni.rescalings() ((1, 1, 1, 1), (1, 1, 2, 2), (2, 2, 1, 1), (2, 2, 2, 2)) """ free = self._Chow_group_free() @@ -302,15 +303,15 @@ def orbit(self, point): EXAMPLES:: - sage: P2_123 = toric_varieties.P2_123(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: ne = P2_123.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: sorted(ne.orbit([1, 0, 0])) # optional - sage.rings.finite_rings + sage: P2_123 = toric_varieties.P2_123(base_ring=GF(7)) + sage: ne = P2_123.point_set()._naive_enumerator() + sage: sorted(ne.orbit([1, 0, 0])) [(1, 0, 0), (2, 0, 0), (4, 0, 0)] - sage: sorted(ne.orbit([0, 1, 0])) # optional - sage.rings.finite_rings + sage: sorted(ne.orbit([0, 1, 0])) [(0, 1, 0), (0, 6, 0)] - sage: sorted(ne.orbit([0, 0, 1])) # optional - sage.rings.finite_rings + sage: sorted(ne.orbit([0, 0, 1])) [(0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 0, 4), (0, 0, 5), (0, 0, 6)] - sage: sorted(ne.orbit([1, 1, 0])) # optional - sage.rings.finite_rings + sage: sorted(ne.orbit([1, 1, 0])) [(1, 1, 0), (1, 6, 0), (2, 1, 0), (2, 6, 0), (4, 1, 0), (4, 6, 0)] """ result = set() @@ -330,9 +331,9 @@ def cone_iter(self): EXAMPLES:: - sage: dP6 = toric_varieties.dP6(base_ring=GF(11)) # optional - sage.rings.finite_rings - sage: ne = dP6.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: for cone in ne.cone_iter(): # optional - sage.rings.finite_rings + sage: dP6 = toric_varieties.dP6(base_ring=GF(11)) + sage: ne = dP6.point_set()._naive_enumerator() + sage: for cone in ne.cone_iter(): ....: print(cone.ambient_ray_indices()) (0, 1) (1, 2) @@ -363,24 +364,24 @@ def coordinate_iter(self): EXAMPLES:: - sage: P2 = toric_varieties.P2(base_ring=GF(2)) # optional - sage.rings.finite_rings - sage: ni = P2.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: list(ni.coordinate_iter()) # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(2)) + sage: ni = P2.point_set()._naive_enumerator() + sage: list(ni.coordinate_iter()) [(0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)] - sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(2)) # optional - sage.rings.finite_rings - sage: ni = P1xP1.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: list(ni.coordinate_iter()) # optional - sage.rings.finite_rings + sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(2)) + sage: ni = P1xP1.point_set()._naive_enumerator() + sage: list(ni.coordinate_iter()) [(0, 1, 0, 1), (1, 0, 0, 1), (1, 0, 1, 0), (0, 1, 1, 0), (0, 1, 1, 1), (1, 0, 1, 1), (1, 1, 0, 1), (1, 1, 1, 0), (1, 1, 1, 1)] TESTS:: - sage: V = ToricVariety(Fan([Cone([(1,1)])]), base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: ni = V.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: list(ni.coordinate_iter()) # optional - sage.rings.finite_rings + sage: V = ToricVariety(Fan([Cone([(1,1)])]), base_ring=GF(3)) + sage: ni = V.point_set()._naive_enumerator() + sage: list(ni.coordinate_iter()) [(0, 1), (0, 2), (1, 1), (1, 2), (2, 1), (2, 2)] """ units = [x for x in self.ring if x != 0] @@ -405,15 +406,15 @@ def __iter__(self): EXAMPLES:: - sage: P2 = toric_varieties.P2(base_ring=GF(2)) # optional - sage.rings.finite_rings - sage: ni = P2.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: list(ni) # optional - sage.rings.finite_rings + sage: P2 = toric_varieties.P2(base_ring=GF(2)) + sage: ni = P2.point_set()._naive_enumerator() + sage: list(ni) [(0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)] - sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(3)) # optional - sage.rings.finite_rings - sage: ni = P1xP1.point_set()._naive_enumerator() # optional - sage.rings.finite_rings - sage: list(ni) # optional - sage.rings.finite_rings + sage: P1xP1 = toric_varieties.P1xP1(base_ring=GF(3)) + sage: ni = P1xP1.point_set()._naive_enumerator() + sage: list(ni) [(0, 1, 0, 1), (1, 0, 0, 1), (1, 0, 1, 0), (0, 1, 1, 0), (0, 1, 1, 1), (0, 1, 1, 2), (1, 0, 1, 1), (1, 0, 1, 2), (1, 1, 0, 1), (1, 2, 0, 1), (1, 1, 1, 0), (1, 2, 1, 0), @@ -438,9 +439,9 @@ def multiplicative_generator(self): EXAMPLES:: - sage: point_set = toric_varieties.P2(base_ring=GF(5^2, 'a')).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: ffe.multiplicative_generator() # optional - sage.rings.finite_rings + sage: point_set = toric_varieties.P2(base_ring=GF(5^2, 'a')).point_set() # needs sage.rings.finite_rings + sage: ffe = point_set._finite_field_enumerator() # needs sage.rings.finite_rings + sage: ffe.multiplicative_generator() # needs sage.rings.finite_rings a """ return self.ring.multiplicative_generator() @@ -462,18 +463,18 @@ def root_generator(self, n): EXAMPLES:: - sage: point_set = toric_varieties.P2(base_ring=GF(5)).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: ffe.root_generator(2) # optional - sage.rings.finite_rings + sage: point_set = toric_varieties.P2(base_ring=GF(5)).point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: ffe.root_generator(2) 4 - sage: ffe.root_generator(3) # optional - sage.rings.finite_rings + sage: ffe.root_generator(3) 1 - sage: ffe.root_generator(4) # optional - sage.rings.finite_rings + sage: ffe.root_generator(4) 2 TESTS:: - sage: for p in primes(10): # optional - sage.rings.finite_rings + sage: for p in primes(10): # needs sage.rings.finite_rings ....: for k in range(1, 5): ....: F = GF(p^k, 'a') ....: N = F.cardinality() - 1 @@ -499,13 +500,13 @@ def _Chow_group_free_generators(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X.Chow_group().degree(1) # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: X.Chow_group().degree(1) C3 x Z - sage: enum = X.point_set()._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: enum._Chow_group_free() # optional - sage.rings.finite_rings + sage: enum = X.point_set()._finite_field_enumerator() + sage: enum._Chow_group_free() ((1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6)) - sage: enum._Chow_group_free_generators() # optional - sage.rings.finite_rings + sage: enum._Chow_group_free_generators() ((3, 3, 3),) """ result = [] @@ -528,13 +529,13 @@ def _Chow_group_torsion_generators(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X.Chow_group().degree(1) # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: X.Chow_group().degree(1) C3 x Z - sage: enum = X.point_set()._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: enum._Chow_group_torsion() # optional - sage.rings.finite_rings + sage: enum = X.point_set()._finite_field_enumerator() + sage: enum._Chow_group_torsion() ((1, 2, 4), (1, 4, 2)) - sage: enum._Chow_group_torsion_generators() # optional - sage.rings.finite_rings + sage: enum._Chow_group_torsion_generators() ((1, 2, 4),) """ if self.fan.is_smooth(): @@ -568,19 +569,20 @@ def log(self, z): EXAMPLES:: - sage: F. = GF(5^2) # optional - sage.rings.finite_rings - sage: point_set = toric_varieties.P2_123(base_ring=F).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: z = tuple(a^i for i in range(25)); z # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(5^2) + sage: point_set = toric_varieties.P2_123(base_ring=F).point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: z = tuple(a^i for i in range(25)); z (1, a, a + 3, 4*a + 3, 2*a + 2, 4*a + 1, 2, 2*a, 2*a + 1, 3*a + 1, 4*a + 4, 3*a + 2, 4, 4*a, 4*a + 2, a + 2, 3*a + 3, a + 4, 3, 3*a, 3*a + 4, 2*a + 4, a + 1, 2*a + 3, 1) - sage: ffe.log(z) # optional - sage.rings.finite_rings + sage: ffe.log(z) (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0) - sage: ffe.exp(ffe.log(z)) == z # optional - sage.rings.finite_rings + sage: ffe.exp(ffe.log(z)) == z True - sage: ffe.log(ffe.exp(range(24))) == tuple(range(24)) # optional - sage.rings.finite_rings + sage: ffe.log(ffe.exp(range(24))) == tuple(range(24)) True """ base = self.multiplicative_generator() @@ -601,15 +603,16 @@ def exp(self, powers): EXAMPLES:: - sage: F. = GF(5^2) # optional - sage.rings.finite_rings - sage: point_set = toric_varieties.P2_123(base_ring=F).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: powers = list(range(24)) # optional - sage.rings.finite_rings - sage: ffe.exp(powers) # optional - sage.rings.finite_rings + sage: # needs sage.rings.finite_rings + sage: F. = GF(5^2) + sage: point_set = toric_varieties.P2_123(base_ring=F).point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: powers = list(range(24)) + sage: ffe.exp(powers) (1, a, a + 3, 4*a + 3, 2*a + 2, 4*a + 1, 2, 2*a, 2*a + 1, 3*a + 1, 4*a + 4, 3*a + 2, 4, 4*a, 4*a + 2, a + 2, 3*a + 3, a + 4, 3, 3*a, 3*a + 4, 2*a + 4, a + 1, 2*a + 3) - sage: ffe.log(ffe.exp(powers)) == tuple(powers) # optional - sage.rings.finite_rings + sage: ffe.log(ffe.exp(powers)) == tuple(powers) True """ base = self.multiplicative_generator() @@ -627,13 +630,13 @@ def rescaling_log_generators(self): EXAMPLES:: - sage: point_set = toric_varieties.P2_123(base_ring=GF(5)).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: ffe.rescalings() # optional - sage.rings.finite_rings + sage: point_set = toric_varieties.P2_123(base_ring=GF(5)).point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: ffe.rescalings() ((1, 1, 1), (1, 4, 4), (4, 2, 3), (4, 3, 2)) - sage: list(map(ffe.log, ffe.rescalings())) # optional - sage.rings.finite_rings + sage: list(map(ffe.log, ffe.rescalings())) [(0, 0, 0), (0, 2, 2), (2, 1, 3), (2, 3, 1)] - sage: ffe.rescaling_log_generators() # optional - sage.rings.finite_rings + sage: ffe.rescaling_log_generators() ((2, 3, 1),) """ free = self._Chow_group_free_generators() @@ -655,22 +658,22 @@ def cone_points_iter(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: cpi = ffe.cone_points_iter() # optional - sage.rings.finite_rings - sage: cone, nonzero_points, cokernel = list(cpi)[5] # optional - sage.rings.finite_rings - sage: cone # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: point_set = X.point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: cpi = ffe.cone_points_iter() + sage: cone, nonzero_points, cokernel = list(cpi)[5] + sage: cone 1-d cone of Rational polyhedral fan in 2-d lattice N - sage: cone.ambient_ray_indices() # optional - sage.rings.finite_rings + sage: cone.ambient_ray_indices() (2,) - sage: nonzero_points # optional - sage.rings.finite_rings + sage: nonzero_points [0, 1] - sage: cokernel # optional - sage.rings.finite_rings + sage: cokernel Finitely generated module V/W over Integer Ring with invariants (2) - sage: list(cokernel) # optional - sage.rings.finite_rings + sage: list(cokernel) [(0), (1)] - sage: [p.lift() for p in cokernel] # optional - sage.rings.finite_rings + sage: [p.lift() for p in cokernel] [(0, 0), (0, 1)] """ from sage.matrix.constructor import matrix, block_matrix, identity_matrix @@ -704,22 +707,22 @@ def __iter__(self): EXAMPLES:: - sage: point_set = toric_varieties.P2(base_ring=GF(2)).point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: list(ffe) # optional - sage.rings.finite_rings + sage: point_set = toric_varieties.P2(base_ring=GF(2)).point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: list(ffe) [(0, 0, 1), (1, 0, 0), (0, 1, 0), (0, 1, 1), (1, 0, 1), (1, 1, 0), (1, 1, 1)] sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: list(ffe) # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: point_set = X.point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: list(ffe) [(1, 0, 0), (0, 1, 0), (0, 0, 1), (0, 1, 1), (0, 1, 3), (1, 0, 1), (1, 0, 3), (1, 1, 0), (1, 3, 0), (1, 1, 1), (1, 1, 3), (1, 1, 2), (1, 1, 6), (1, 1, 4), (1, 1, 5), (1, 3, 2), (1, 3, 6), (1, 3, 4), (1, 3, 5), (1, 3, 1), (1, 3, 3)] - sage: set(point_set._naive_enumerator()) == set(ffe) # optional - sage.rings.finite_rings + sage: set(point_set._naive_enumerator()) == set(ffe) True """ nrays = len(self.rays()) @@ -741,10 +744,10 @@ def cardinality(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._finite_field_enumerator() # optional - sage.rings.finite_rings - sage: ffe.cardinality() # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, base_ring=GF(7)) + sage: point_set = X.point_set() + sage: ffe = point_set._finite_field_enumerator() + sage: ffe.cardinality() 21 """ n = 0 @@ -826,14 +829,14 @@ def inhomogeneous_equations(self, ring, nonzero_coordinates, cokernel): EXAMPLES:: sage: R. = QQ[] - sage: P2. = toric_varieties.P2(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: cone, nonzero_coordinates, cokernel = list(ffe.ambient.cone_points_iter())[5] # optional - sage.rings.finite_rings - sage: cone.ambient_ray_indices(), nonzero_coordinates # optional - sage.rings.finite_rings + sage: P2. = toric_varieties.P2(base_ring=GF(7)) + sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) + sage: point_set = X.point_set() + sage: ffe = point_set._enumerator() + sage: cone, nonzero_coordinates, cokernel = list(ffe.ambient.cone_points_iter())[5] + sage: cone.ambient_ray_indices(), nonzero_coordinates ((2,), [0, 1]) - sage: ffe.inhomogeneous_equations(R, nonzero_coordinates, cokernel) # optional - sage.rings.finite_rings + sage: ffe.inhomogeneous_equations(R, nonzero_coordinates, cokernel) [2*s^3 + 1, s^2] """ nrays = len(self.ambient.rays()) @@ -867,14 +870,14 @@ def solutions_serial(self, inhomogeneous_equations, log_range): EXAMPLES:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: P2. = toric_varieties.P2(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X = P2.subscheme(1) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: ffe.solutions_serial([s^2 - 1, s^6 - s^2], [range(6)]) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: P2. = toric_varieties.P2(base_ring=GF(7)) + sage: X = P2.subscheme(1) + sage: point_set = X.point_set() + sage: ffe = point_set._enumerator() + sage: ffe.solutions_serial([s^2 - 1, s^6 - s^2], [range(6)]) - sage: list(_) # optional - sage.rings.finite_rings + sage: list(_) [(0,), (3,)] """ from itertools import product @@ -895,14 +898,14 @@ def solutions(self, inhomogeneous_equations, log_range): EXAMPLES:: - sage: R. = GF(7)[] # optional - sage.rings.finite_rings - sage: P2. = toric_varieties.P2(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X = P2.subscheme(1) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: ffe.solutions([s^2 - 1, s^6 - s^2], [range(6)]) # optional - sage.rings.finite_rings + sage: R. = GF(7)[] + sage: P2. = toric_varieties.P2(base_ring=GF(7)) + sage: X = P2.subscheme(1) + sage: point_set = X.point_set() + sage: ffe = point_set._enumerator() + sage: ffe.solutions([s^2 - 1, s^6 - s^2], [range(6)]) - sage: sorted(_) # optional - sage.rings.finite_rings + sage: sorted(_) [(0,), (3,)] """ # Do simple cases in one process (this includes most doctests) @@ -941,18 +944,18 @@ def homogeneous_coordinates(self, log_t, nonzero_coordinates, cokernel): EXAMPLES:: - sage: P2. = toric_varieties.P2(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: cone, nonzero_coordinates, cokernel = list(ffe.ambient.cone_points_iter())[5] # optional - sage.rings.finite_rings - sage: cone.ambient_ray_indices(), nonzero_coordinates # optional - sage.rings.finite_rings + sage: P2. = toric_varieties.P2(base_ring=GF(7)) + sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) + sage: point_set = X.point_set() + sage: ffe = point_set._enumerator() + sage: cone, nonzero_coordinates, cokernel = list(ffe.ambient.cone_points_iter())[5] + sage: cone.ambient_ray_indices(), nonzero_coordinates ((2,), [0, 1]) - sage: ffe.homogeneous_coordinates([0], nonzero_coordinates, cokernel) # optional - sage.rings.finite_rings + sage: ffe.homogeneous_coordinates([0], nonzero_coordinates, cokernel) (1, 1, 0) - sage: ffe.homogeneous_coordinates([1], nonzero_coordinates, cokernel) # optional - sage.rings.finite_rings + sage: ffe.homogeneous_coordinates([1], nonzero_coordinates, cokernel) (1, 3, 0) - sage: ffe.homogeneous_coordinates([2], nonzero_coordinates, cokernel) # optional - sage.rings.finite_rings + sage: ffe.homogeneous_coordinates([2], nonzero_coordinates, cokernel) (1, 2, 0) """ z = [self.ambient.ring.zero()] * len(self.ambient.rays()) @@ -977,11 +980,11 @@ def __iter__(self): EXAMPLES:: - sage: P2. = toric_varieties.P2(base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) # optional - sage.rings.finite_rings - sage: point_set = X.point_set() # optional - sage.rings.finite_rings - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: list(ffe) # indirect doctest # optional - sage.rings.finite_rings + sage: P2. = toric_varieties.P2(base_ring=GF(7)) + sage: X = P2.subscheme([x^3 + 2*y^3 + 3*z^3, x*y*z + x*y^2]) + sage: point_set = X.point_set() + sage: ffe = point_set._enumerator() + sage: list(ffe) # indirect doctest [(1, 1, 6), (1, 2, 5), (1, 4, 3)] """ for cone, nonzero_coordinates, cokernel in self.ambient.cone_points_iter(): @@ -1001,10 +1004,10 @@ def cardinality(self): EXAMPLES:: sage: fan = NormalFan(ReflexivePolytope(2, 0)) - sage: X. = ToricVariety(fan, base_ring=GF(7)) # optional - sage.rings.finite_rings - sage: Y = X.subscheme(u^3 + v^3 + w^3 + u*v*w) # optional - sage.rings.finite_rings - sage: point_set = Y.point_set() # optional - sage.rings.finite_rings - sage: list(point_set) # optional - sage.rings.finite_rings + sage: X. = ToricVariety(fan, base_ring=GF(7)) + sage: Y = X.subscheme(u^3 + v^3 + w^3 + u*v*w) + sage: point_set = Y.point_set() + sage: list(point_set) [[0 : 1 : 3], [1 : 0 : 3], [1 : 3 : 0], @@ -1012,8 +1015,8 @@ def cardinality(self): [1 : 1 : 4], [1 : 3 : 2], [1 : 3 : 5]] - sage: ffe = point_set._enumerator() # optional - sage.rings.finite_rings - sage: ffe.cardinality() # optional - sage.rings.finite_rings + sage: ffe = point_set._enumerator() + sage: ffe.cardinality() 7 """ n = 0 diff --git a/src/sage/schemes/toric/sheaf/constructor.py b/src/sage/schemes/toric/sheaf/constructor.py index 11a189adbf3..52f00d99815 100644 --- a/src/sage/schemes/toric/sheaf/constructor.py +++ b/src/sage/schemes/toric/sheaf/constructor.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Construct sheaves on toric varieties diff --git a/src/sage/schemes/toric/sheaf/klyachko.py b/src/sage/schemes/toric/sheaf/klyachko.py index 0bff2218156..08cea1487f9 100644 --- a/src/sage/schemes/toric/sheaf/klyachko.py +++ b/src/sage/schemes/toric/sheaf/klyachko.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs """ Klyachko bundles and sheaves diff --git a/src/sage/schemes/toric/toric_subscheme.py b/src/sage/schemes/toric/toric_subscheme.py index e425ee3d0a8..acdfd05d0d1 100644 --- a/src/sage/schemes/toric/toric_subscheme.py +++ b/src/sage/schemes/toric/toric_subscheme.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Subschemes of toric space @@ -644,9 +645,9 @@ def is_nondegenerate(self): sage: P2. = toric_varieties.P2() sage: f = x^5 + 2*x*y^4 + y^5 - 2*y^3*z^2 + x*z^4 - 2*z^5 - sage: P2.change_ring(GF(5)).subscheme([f]).is_nondegenerate() # optional - sage.rings.finite_rings + sage: P2.change_ring(GF(5)).subscheme([f]).is_nondegenerate() True - sage: P2.change_ring(GF(7)).subscheme([f]).is_nondegenerate() # optional - sage.rings.finite_rings + sage: P2.change_ring(GF(7)).subscheme([f]).is_nondegenerate() False TESTS: diff --git a/src/sage/schemes/toric/variety.py b/src/sage/schemes/toric/variety.py index eabb25ca4a1..82d2ec7769a 100644 --- a/src/sage/schemes/toric/variety.py +++ b/src/sage/schemes/toric/variety.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs # -*- coding: utf-8 -*- r""" Toric varieties @@ -1536,7 +1537,7 @@ def plot(self, **options): EXAMPLES:: sage: X = toric_varieties.Cube_deformation(4) - sage: X.plot() + sage: X.plot() # needs sage.plot Graphics3d Object """ if "ray_label" not in options: @@ -1849,8 +1850,8 @@ def Stanley_Reisner_ideal(self): sage: fan = Fan([[0,1,3], [3,4], [2,0], [1,2,4]], ....: [(-3, -2, 1), (0, 0, 1), (3, -2, 1), (-1, -1, 1), (1, -1, 1)]) - sage: X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(5)) # optional - sage.rings.finite_rings - sage: SR = X.Stanley_Reisner_ideal(); SR # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(5)) + sage: SR = X.Stanley_Reisner_ideal(); SR Ideal (A*E, C*D, A*B*C, B*D*E) of Multivariate Polynomial Ring in A, B, C, D, E over Rational Field """ @@ -1873,8 +1874,8 @@ def linear_equivalence_ideal(self): sage: fan = Fan([[0,1,3], [3,4], [2,0], [1,2,4]], ....: [(-3, -2, 1), (0, 0, 1), (3, -2, 1), (-1, -1, 1), (1, -1, 1)]) - sage: X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(5)) # optional - sage.rings.finite_rings - sage: lin = X.linear_equivalence_ideal(); lin # optional - sage.rings.finite_rings + sage: X = ToricVariety(fan, coordinate_names='A B C D E', base_field=GF(5)) + sage: lin = X.linear_equivalence_ideal(); lin Ideal (-3*A + 3*C - D + E, -2*A - 2*C - D - E, A + B + C + D + E) of Multivariate Polynomial Ring in A, B, C, D, E over Rational Field """ @@ -2411,7 +2412,7 @@ def divisor_group(self, base_ring=ZZ): sage: dP6 = toric_varieties.dP6() sage: Div = dP6.divisor_group(); Div Group of ZZ-Divisors on 2-d CPR-Fano toric variety covered by 6 affine patches - sage: Div(x) + sage: Div(x) # needs sage.symbolic V(x) """ from sage.schemes.generic.divisor_group import DivisorGroup @@ -2487,7 +2488,7 @@ def _semigroup_ring(self, cone=None, names=None): (Multivariate Polynomial Ring in z0, z1 over Rational Field, Ideal (0) of Multivariate Polynomial Ring in z0, z1 over Rational Field, 2-d cone in 2-d lattice M) - sage: P2.change_ring(GF(101))._semigroup_ring(cone) # optional - sage.rings.finite_rings + sage: P2.change_ring(GF(101))._semigroup_ring(cone) (Multivariate Polynomial Ring in z0, z1 over Finite Field of size 101, Ideal (0) of Multivariate Polynomial Ring in z0, z1 over Finite Field of size 101, 2-d cone in 2-d lattice M) @@ -2739,10 +2740,10 @@ def count_points(self): sage: o = lattice_polytope.cross_polytope(3) sage: V = ToricVariety(FaceFan(o)) - sage: V2 = V.change_ring(GF(2)) # optional - sage.rings.finite_rings - sage: V2.point_set().cardinality() # optional - sage.rings.finite_rings + sage: V2 = V.change_ring(GF(2)) + sage: V2.point_set().cardinality() 27 - sage: V2.count_points() # optional - sage.rings.finite_rings + sage: V2.count_points() 27 """ return self.point_set().cardinality() diff --git a/src/sage/schemes/toric/weierstrass.py b/src/sage/schemes/toric/weierstrass.py index ecf28546aac..137dfd3e042 100644 --- a/src/sage/schemes/toric/weierstrass.py +++ b/src/sage/schemes/toric/weierstrass.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Weierstrass form of a toric elliptic curve diff --git a/src/sage/schemes/toric/weierstrass_covering.py b/src/sage/schemes/toric/weierstrass_covering.py index 5c7b899d93a..13e3c24b2c1 100644 --- a/src/sage/schemes/toric/weierstrass_covering.py +++ b/src/sage/schemes/toric/weierstrass_covering.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Map to the Weierstrass form of a toric elliptic curve diff --git a/src/sage/schemes/toric/weierstrass_higher.py b/src/sage/schemes/toric/weierstrass_higher.py index af9d56233db..2a83234e6ca 100644 --- a/src/sage/schemes/toric/weierstrass_higher.py +++ b/src/sage/schemes/toric/weierstrass_higher.py @@ -1,3 +1,4 @@ +# sage.doctest: needs sage.geometry.polyhedron sage.graphs r""" Weierstrass for elliptic curves in higher codimension @@ -262,17 +263,17 @@ def WeierstrassMap_P3(quadratic1, quadratic2, variables=None): TESTS:: - sage: R. = GF(101)[] # optional - sage.rings.finite_rings - sage: p1 = w^2 + x^2 + y^2 + z^2 # optional - sage.rings.finite_rings - sage: p2 = a0*w^2 + a1*x^2 + a2*y^2 + a3*z^2 # optional - sage.rings.finite_rings - sage: X, Y, Z = WeierstrassMap_P3(p1, p2, [w,x,y,z]) # optional - sage.rings.finite_rings - sage: X.total_degree(), len(X.coefficients()) # optional - sage.rings.finite_rings + sage: R. = GF(101)[] + sage: p1 = w^2 + x^2 + y^2 + z^2 + sage: p2 = a0*w^2 + a1*x^2 + a2*y^2 + a3*z^2 + sage: X, Y, Z = WeierstrassMap_P3(p1, p2, [w,x,y,z]) + sage: X.total_degree(), len(X.coefficients()) (22, 4164) - sage: Y.total_degree(), len(Y.coefficients()) # optional - sage.rings.finite_rings + sage: Y.total_degree(), len(Y.coefficients()) (33, 26912) - sage: Z.total_degree(), len(Z.coefficients()) # optional - sage.rings.finite_rings + sage: Z.total_degree(), len(Z.coefficients()) (10, 24) - sage: Z # optional - sage.rings.finite_rings + sage: Z w*x*y*z*a0^3*a1^2*a2 - w*x*y*z*a0^2*a1^3*a2 - w*x*y*z*a0^3*a1*a2^2 + w*x*y*z*a0*a1^3*a2^2 + w*x*y*z*a0^2*a1*a2^3 - w*x*y*z*a0*a1^2*a2^3 - w*x*y*z*a0^3*a1^2*a3 + w*x*y*z*a0^2*a1^3*a3 + w*x*y*z*a0^3*a2^2*a3