Skip to content

Commit

Permalink
Trac #15378: composition of scheme morphism defined by polynomials
Browse files Browse the repository at this point in the history
Currently the following fails
{{{
sage: P.<x,y>=ProjectiveSpace(QQ,1)
sage: H=Hom(P,P)
sage: f=H([x^2 -29/16*y^2, y^2])
sage: f*f
Traceback (most recent call last):
...
TypeError: unsupported operand type(s) for *:
'SchemeMorphism_polynomial_projective_space_field' and
'SchemeMorphism_polynomial_projective_space_field'
}}}

We just propose a generic implementation.

URL: https://trac.sagemath.org/15378
Reported by: vdelecroix
Ticket author(s): Vincent Delecroix, Ben Hutz
Reviewer(s): Vincent Delecroix
  • Loading branch information
Release Manager authored and vbraun committed Aug 5, 2016
2 parents 06a3e78 + c6c853f commit 6bfeffe
Showing 1 changed file with 82 additions and 1 deletion.
83 changes: 82 additions & 1 deletion src/sage/schemes/generic/morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class SchemeMorphism(Element):
sub-class of :class:`~sage.structure.element.ModuleElement` and
:class:`SchemeMorphism`, but Cython would currently confuse cpdef
attributes of the two base classes. Proper inheritance should be used
as soon as this bug is fixed.
as soon as this bug is fixed. See :trac:`14711`.
EXAMPLES::
Expand Down Expand Up @@ -1330,6 +1330,7 @@ def change_ring(self, R, check=True):
Defn: Defined on coordinates by sending (x : y) to
(x : y)
Check that :trac:`16834` is fixed::
sage: A.<x,y,z> = AffineSpace(RR, 3)
Expand Down Expand Up @@ -1443,6 +1444,86 @@ def change_ring(self, R, check=True):
G.append(f.change_ring(R))
return(H(G, check))

def _composition_(self, other, homset):
r"""
Straightforward implementation of composition for scheme morphisms
defined by polynomials.
TESTS::
sage: P.<x,y> = ProjectiveSpace(QQ,1)
sage: H = Hom(P,P)
sage: f = H([x^2 -29/16*y^2, y^2])
sage: g = H([y,x+y])
sage: h = f*g
sage: h
Scheme endomorphism of Projective Space of dimension 1 over Rational
Field
Defn: Defined on coordinates by sending (x : y) to
(-29/16*x^2 - 29/8*x*y - 13/16*y^2 : x^2 + 2*x*y + y^2)
sage: p = P((1,3))
sage: h(p) == f(g(p))
True
sage: Q = ProjectiveSpace(QQ,2)
sage: H2 = Hom(P,Q)
sage: h2 = H2([x^2+y^2,x^2,y^2+2*x^2])
sage: h2 * f
Scheme morphism:
From: Projective Space of dimension 1 over Rational Field
To: Projective Space of dimension 2 over Rational Field
Defn: Defined on coordinates by sending (x : y) to
(x^4 - 29/8*x^2*y^2 + 1097/256*y^4 : x^4 - 29/8*x^2*y^2 + 841/256*y^4 : 2*x^4 - 29/4*x^2*y^2 + 969/128*y^4)
::
sage: A.<x,y> = AffineSpace(QQ, 2)
sage: A1.<z> = AffineSpace(QQ, 1)
sage: H = End(A)
sage: f = H([x^2+y^2, y^2/x])
sage: H1 = Hom(A, A1)
sage: g = H1([x + y^2])
sage: g*f
Scheme morphism:
From: Affine Space of dimension 2 over Rational Field
To: Affine Space of dimension 1 over Rational Field
Defn: Defined on coordinates by sending (x, y) to
((x^4 + x^2*y^2 + y^4)/x^2)
sage: f*g
Traceback (most recent call last):
...
TypeError: self (=Scheme endomorphism of Affine Space of dimension 2 over Rational Field
Defn: Defined on coordinates by sending (x, y) to
(x^2 + y^2, y^2/x)) domain must equal right (=Scheme morphism:
From: Affine Space of dimension 2 over Rational Field
To: Affine Space of dimension 1 over Rational Field
Defn: Defined on coordinates by sending (x, y) to
(y^2 + x)) codomain
Not both defined by polynomials::
sage: x = polygen(QQ)
sage: K.<a> = NumberField(x^2 - 2)
sage: p1, p2 = K.Hom(K)
sage: R.<x,y> = 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
To: Affine Space of dimension 2 over Number Field in a with defining polynomial x^2 - 2
Defn: Generic endomorphism of Affine Space of dimension 2 over Number Field in a with defining polynomial x^2 - 2
then
Generic endomorphism of Affine Space of dimension 2 over Number Field in a with defining polynomial x^2 - 2
"""
try:
opolys = tuple(other._polys)
except AttributeError:
return super(SchemeMorphism_polynomial, self)._composition_(other, homset)
return homset([p(*opolys) for p in self._polys])

############################################################################
# Rational points on schemes, which we view as morphisms determined
# by coordinates.
Expand Down

0 comments on commit 6bfeffe

Please sign in to comment.