diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index 5436cc2332d..6133fe16e80 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -1295,7 +1295,7 @@ def degree_sequence(self, iterates=2): sage: P2. = ProjectiveSpace(QQ, 2) sage: H = End(P2) - sage: f = H([Z^2, X*Y, Y^2]) + sage: f = H([Z^2, X*Y, Y^2]) sage: f.degree_sequence(15) [2, 3, 5, 8, 11, 17, 24, 31, 45, 56, 68, 91, 93, 184, 275] @@ -1304,7 +1304,7 @@ def degree_sequence(self, iterates=2): sage: F. = PolynomialRing(QQ) sage: P2. = ProjectiveSpace(F, 2) sage: H = End(P2) - sage: f = H([Y*Z, X*Y, Y^2 + t*X*Z]) + sage: f = H([Y*Z, X*Y, Y^2 + t*X*Z]) sage: f.degree_sequence(5) [2, 3, 5, 8, 13] @@ -1312,7 +1312,7 @@ def degree_sequence(self, iterates=2): sage: P2. = ProjectiveSpace(QQ, 2) sage: H = End(P2) - sage: f = H([X^2, Y^2, Z^2]) + sage: f = H([X^2, Y^2, Z^2]) sage: f.degree_sequence(10) [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024] @@ -1320,7 +1320,7 @@ def degree_sequence(self, iterates=2): sage: P2. = ProjectiveSpace(ZZ, 2) sage: H = End(P2) - sage: f = H([X*Y, Y*Z+Z^2, Z^2]) + sage: f = H([X*Y, Y*Z+Z^2, Z^2]) sage: f.degree_sequence(10) [2, 3, 4, 5, 6, 7, 8, 9, 10, 11] """ @@ -5196,12 +5196,40 @@ def _number_field_from_algebraics(self): To: Projective Space of dimension 2 over Number Field in a with defining polynomial y^4 + 3*y^2 + 1 Defn: Defined on coordinates by sending (z0 : z1) to (z0^2 + (a^3 + 2*a)*z0*z1 + 3*z1^2 : z1^2 : (2*a^2 + 3)*z0*z1) + + The following was fixed in :trac:`23808`:: + + sage: R.=PolynomialRing(QQ) + 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() + 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 (z0 : z1) to + ((-0.6823278038280193?)*z0^3 + (-13)*z1^3 : (-14)*z1^3) + """ from sage.schemes.projective.projective_space import is_ProjectiveSpace if not (is_ProjectiveSpace(self.domain()) and is_ProjectiveSpace(self.domain())): raise NotImplementedError("not implemented for subschemes") - K,C,phi = number_field_elements_from_algebraics([c for f in self for c in f.coefficients()]) + K_pre,C,phi = number_field_elements_from_algebraics([c for f in self for c in f.coefficients()]) + # Trac 23808: The field K_pre returned above does not have its embedding set to be phi + # and phi is forgotten, so we redefine K_pre to be a field K with phi as the specified + # embedding: + if K_pre is QQ: + K = QQ + else: + from sage.rings.number_field.number_field import NumberField + K = NumberField(K_pre.polynomial(), embedding=phi(K_pre.gen()), name='a') + psi = K_pre.hom([K.gen()], K) # Identification of K_pre with K + C = [ psi(c) for c in C ] # The elements of C were in K_pre, move them to K from sage.schemes.projective.projective_space import ProjectiveSpace N = self.domain().dimension_relative() PS = ProjectiveSpace(K,N,'z') diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py index 7573c117daa..2e8992e5111 100644 --- a/src/sage/schemes/projective/projective_point.py +++ b/src/sage/schemes/projective/projective_point.py @@ -1748,12 +1748,36 @@ def _number_field_from_algebraics(self): (1/2*a^3 + a^2 - 1/2*a : 1) sage: S.codomain() Projective Space of dimension 1 over Number Field in a with defining polynomial y^4 + 1 + + The following was fixed in :trac:`23808`:: + + sage: R. = PolynomialRing(QQ) + 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 + (1/2*a^3 + a^2 - 1/2*a : 1) + sage: T = S.change_ring(QQbar) # Used to fail + sage: T + (-0.7071067811865475? + 1.000000000000000?*I : 1) + sage: Q[0] == T[0] + True """ from sage.schemes.projective.projective_space import is_ProjectiveSpace if not is_ProjectiveSpace(self.codomain()): raise NotImplementedError("not implemented for subschemes") - K,P,phi = number_field_elements_from_algebraics(list(self)) + # Trac #23808: Keep the embedding info associated with the number field K + # used below, instead of in the separate embedding map phi which is + # forgotten. + K_pre,P,phi = number_field_elements_from_algebraics(list(self)) + if K_pre is QQ: + K = QQ + else: + from sage.rings.number_field.number_field import NumberField + K = NumberField(K_pre.polynomial(), embedding=phi(K_pre.gen()), name='a') + psi = K_pre.hom([K.gen()], K) # Identification of K_pre with K + P = [ psi(p) for p in P ] # The elements of P were elements of K_pre from sage.schemes.projective.projective_space import ProjectiveSpace PS = ProjectiveSpace(K,self.codomain().dimension_relative(),'z') return(PS(P))