Skip to content

Commit

Permalink
Trac #23808: Keep embedding info when converting algebraics to number…
Browse files Browse the repository at this point in the history
… field in projective morphism

Given a map or point defined over QQbar, you can call
_numberfield_from_algebraics to return a map over a number field.
However, the resulting object cannot be converted back to QQbar since
the embedding information is lost.

URL: https://trac.sagemath.org/23808
Reported by: paulfili
Ticket author(s): Paul Fili
Reviewer(s): David Roe, Ben Hutz
  • Loading branch information
Release Manager authored and vbraun committed Sep 10, 2017
2 parents e179582 + 693578c commit 75bac0f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 6 deletions.
38 changes: 33 additions & 5 deletions src/sage/schemes/projective/projective_morphism.py
Expand Up @@ -1295,7 +1295,7 @@ def degree_sequence(self, iterates=2):
sage: P2.<X,Y,Z> = 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]
Expand All @@ -1304,23 +1304,23 @@ def degree_sequence(self, iterates=2):
sage: F.<t> = PolynomialRing(QQ)
sage: P2.<X,Y,Z> = 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]
::
sage: P2.<X,Y,Z> = 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]
::
sage: P2.<X,Y,Z> = 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]
"""
Expand Down Expand Up @@ -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.<t>=PolynomialRing(QQ)
sage: s = (t^3+t+1).roots(QQbar)[0][0]
sage: P.<x,y>=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')
Expand Down
26 changes: 25 additions & 1 deletion src/sage/schemes/projective/projective_point.py
Expand Up @@ -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.<x> = PolynomialRing(QQ)
sage: P.<x,y> = 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))
Expand Down

0 comments on commit 75bac0f

Please sign in to comment.