def homogenize(self,n,newvar='h'): r""" Return the homogenization of ``self``. If ``self.domain()`` is a subscheme, the domain of the homogenized map is the projective embedding of ``self.domain()``. The domain and codomain can be homogenized at different coordinates: ``n[0]`` for the domain and ``n[1]`` for the codomain. INPUT: - ``newvar`` -- the name of the homogenization variable (only used when ``self.domain()`` is affine space) - ``n`` -- a tuple of nonnegative integers. If ``n`` is an integer, then the two values of the tuple are assumed to be the same. OUTPUT: - :class:`SchemMorphism_polynomial_projective_space` EXAMPLES:: sage: A.<x,y>=AffineSpace(ZZ,2) sage: H=Hom(A,A) sage: f=H([(x^2-2)/x^5,y^2]) sage: f.homogenize(2,'z') Scheme endomorphism of Projective Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x : y : z) to (x^2*z^5 - 2*z^7 : x^5*y^2 : x^5*z^2) :: sage: A.<x,y>=AffineSpace(CC,2) sage: H=Hom(A,A) sage: f=H([(x^2-2)/(x*y),y^2-x]) sage: f.homogenize((2,0),'z') Scheme endomorphism of Projective Space of dimension 2 over Complex Field with 53 bits of precision Defn: Defined on coordinates by sending (x : y : z) to (x*y*z^2 : x^2*z^2 + (-2.00000000000000)*z^4 : x*y^3 - x^2*y*z) :: sage: A.<x,y>=AffineSpace(ZZ,2) sage: X=A.subscheme([x-y^2]) sage: H=Hom(X,X) sage: f=H([9*y^2,3*y]) sage: f.homogenize(2) 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 (9*x0*x2 : 3*x1*x2 : x2^2) :: sage: R.<t>=PolynomialRing(ZZ) sage: A.<x,y>=AffineSpace(R,2) sage: H=Hom(A,A) sage: f=H([(x^2-2)/y,y^2-x]) sage: f.homogenize((2,0),'z') Scheme endomorphism of Projective Space of dimension 2 over Univariate Polynomial Ring in t over Integer Ring Defn: Defined on coordinates by sending (x : y : z) to (y*z^2 : x^2*z + (-2)*z^3 : y^3 - x*y*z) :: sage: A.<x>=AffineSpace(QQ,1) sage: H=End(A) sage: f=H([x^2-1]) sage: f.homogenize((1,0),'y') Scheme endomorphism of Projective Space of dimension 1 over Rational Field Defn: Defined on coordinates by sending (x : y) to (y^2 : x^2 - y^2) """ A=self.domain() B=self.codomain() N=A.ambient_space().dimension_relative() NB=B.ambient_space().dimension_relative() #it is possible to homogenize the domain and codomain at different coordinates if isinstance(n,(tuple,list)): ind=tuple(n) else: ind=(n,n) #homogenize the domain Vars=list(A.ambient_space().variable_names()) Vars.insert(ind[0],newvar) S=PolynomialRing(A.base_ring(),Vars) #find the denominators if a rational function try: l=lcm([self[i].denominator() for i in range(N)]) except Exception: #no lcm l=prod([self[i].denominator() for i in range(N)]) from sage.rings.polynomial.polynomial_ring import PolynomialRing_general from sage.rings.polynomial.multi_polynomial_ring_generic import MPolynomialRing_generic if self.domain().base_ring()==RealField() or self.domain().base_ring()==ComplexField(): F=[S(((self[i]*l).numerator())._maxima_().divide(self[i].denominator())[0].sage()) for i in range(N)] elif isinstance(self.domain().base_ring(),(PolynomialRing_general,MPolynomialRing_generic)): F=[S(((self[i]*l).numerator())._maxima_().divide(self[i].denominator())[0].sage()) for i in range(N)] else: F=[S(self[i]*l) for i in range(N)] #homogenize the codomain F.insert(ind[1],S(l)) d=max([F[i].degree() for i in range(N+1)]) F=[F[i].homogenize(newvar)*S.gen(N)**(d-F[i].degree()) for i in range(N+1)] from sage.schemes.affine.affine_space import is_AffineSpace if is_AffineSpace(A)==True: from sage.schemes.projective.projective_space import ProjectiveSpace X=ProjectiveSpace(A.base_ring(),NB,Vars) else: X=A.projective_embedding(ind[1]).codomain() phi=S.hom(X.ambient_space().gens(),X.ambient_space().coordinate_ring()) F=[phi(f) for f in F] H=Hom(X,X) return(H(F))
def homogenize(self,n,newvar='h'): r""" Return the homogenization of ``self``. If ``self.domain()`` is a subscheme, the domain of the homogenized map is the projective embedding of ``self.domain()`` INPUT: - ``newvar`` -- the name of the homogenization variable (only used when ``self.domain()`` is affine space) - ``n`` -- the n-th projective embedding into projective space OUTPUT: - :class:`SchemMorphism_polynomial_projective_space` EXAMPLES:: sage: A.<x,y>=AffineSpace(ZZ,2) sage: H=Hom(A,A) sage: f=H([(x^2-2)/x^5,y^2]) sage: f.homogenize(2,'z') Scheme endomorphism of Projective Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x : y : z) to (x^2*z^5 - 2*z^7 : x^5*y^2 : x^5*z^2) :: sage: A.<x,y>=AffineSpace(CC,2) sage: H=Hom(A,A) sage: f=H([(x^2-2)/(x*y),y^2-x]) sage: f.homogenize(0,'z') Scheme endomorphism of Projective Space of dimension 2 over Complex Field with 53 bits of precision Defn: Defined on coordinates by sending (x : y : z) to (x*y*z^2 : x^2*z^2 + (-2.00000000000000)*z^4 : x*y^3 - x^2*y*z) :: sage: A.<x,y>=AffineSpace(ZZ,2) sage: X=A.subscheme([x-y^2]) sage: H=Hom(X,X) sage: f=H([9*y^2,3*y]) sage: f.homogenize(2) 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 (9*x0*x2 : 3*x1*x2 : x2^2) :: sage: R.<t>=PolynomialRing(ZZ) sage: A.<x,y>=AffineSpace(R,2) sage: H=Hom(A,A) sage: f=H([(x^2-2)/y,y^2-x]) sage: f.homogenize(0,'z') Scheme endomorphism of Projective Space of dimension 2 over Univariate Polynomial Ring in t over Integer Ring Defn: Defined on coordinates by sending (x : y : z) to (y*z^2 : x^2*z + (-2)*z^3 : y^3 - x*y*z) """ A=self.domain() B=self.codomain() N=A.ambient_space().dimension_relative() NB=B.ambient_space().dimension_relative() Vars=list(A.ambient_space().variable_names())+[newvar] S=PolynomialRing(A.base_ring(),Vars) try: l=lcm([self[i].denominator() for i in range(N)]) except Exception: #no lcm l=prod([self[i].denominator() for i in range(N)]) from sage.rings.polynomial.polynomial_ring import PolynomialRing_general from sage.rings.polynomial.multi_polynomial_ring_generic import MPolynomialRing_generic if self.domain().base_ring()==RealField() or self.domain().base_ring()==ComplexField(): F=[S(((self[i]*l).numerator())._maxima_().divide(self[i].denominator())[0].sage()) for i in range(N)] elif isinstance(self.domain().base_ring(),(PolynomialRing_general,MPolynomialRing_generic)): F=[S(((self[i]*l).numerator())._maxima_().divide(self[i].denominator())[0].sage()) for i in range(N)] else: F=[S(self[i]*l) for i in range(N)] F.insert(n,S(l)) d=max([F[i].degree() for i in range(N+1)]) F=[F[i].homogenize(newvar)*S.gen(N)**(d-F[i].degree()) for i in range(N+1)] from sage.schemes.affine.affine_space import is_AffineSpace if is_AffineSpace(A)==True: from sage.schemes.projective.projective_space import ProjectiveSpace X=ProjectiveSpace(A.base_ring(),NB,Vars) else: X=A.projective_embedding(n).codomain() phi=S.hom(X.ambient_space().gens(),X.ambient_space().coordinate_ring()) F=[phi(f) for f in F] H=Hom(X,X) return(H(F))
def homogenize(self, n, newvar='h'): r""" Return the homogenization of ``self``. If ``self.domain()`` is a subscheme, the domain of the homogenized map is the projective embedding of ``self.domain()`` INPUT: - ``newvar`` -- the name of the homogenization variable (only used when ``self.domain()`` is affine space) - ``n`` -- the n-th projective embedding into projective space OUTPUT: - :class:`SchemMorphism_polynomial_projective_space` EXAMPLES:: sage: A.<x,y>=AffineSpace(ZZ,2) sage: H=Hom(A,A) sage: f=H([(x^2-2)/x^5,y^2]) sage: f.homogenize(2,'z') Scheme endomorphism of Projective Space of dimension 2 over Integer Ring Defn: Defined on coordinates by sending (x : y : z) to (x^2*z^5 - 2*z^7 : x^5*y^2 : x^5*z^2) :: sage: A.<x,y>=AffineSpace(CC,2) sage: H=Hom(A,A) sage: f=H([(x^2-2)/(x*y),y^2-x]) sage: f.homogenize(0,'z') Scheme endomorphism of Projective Space of dimension 2 over Complex Field with 53 bits of precision Defn: Defined on coordinates by sending (x : y : z) to (x*y*z^2 : x^2*z^2 + (-2.00000000000000)*z^4 : x*y^3 - x^2*y*z) :: sage: A.<x,y>=AffineSpace(ZZ,2) sage: X=A.subscheme([x-y^2]) sage: H=Hom(X,X) sage: f=H([9*y^2,3*y]) sage: f.homogenize(2) 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 (9*x0*x2 : 3*x1*x2 : x2^2) :: sage: R.<t>=PolynomialRing(ZZ) sage: A.<x,y>=AffineSpace(R,2) sage: H=Hom(A,A) sage: f=H([(x^2-2)/y,y^2-x]) sage: f.homogenize(0,'z') Scheme endomorphism of Projective Space of dimension 2 over Univariate Polynomial Ring in t over Integer Ring Defn: Defined on coordinates by sending (x : y : z) to (y*z^2 : x^2*z + (-2)*z^3 : y^3 - x*y*z) """ A = self.domain() B = self.codomain() N = A.ambient_space().dimension_relative() NB = B.ambient_space().dimension_relative() Vars = list(A.ambient_space().variable_names()) + [newvar] S = PolynomialRing(A.base_ring(), Vars) try: l = lcm([self[i].denominator() for i in range(N)]) except Exception: #no lcm l = prod([self[i].denominator() for i in range(N)]) from sage.rings.polynomial.polynomial_ring import PolynomialRing_general from sage.rings.polynomial.multi_polynomial_ring_generic import MPolynomialRing_generic if self.domain().base_ring() == RealField() or self.domain().base_ring( ) == ComplexField(): F = [ S(((self[i] * l).numerator())._maxima_().divide( self[i].denominator())[0].sage()) for i in range(N) ] elif isinstance(self.domain().base_ring(), (PolynomialRing_general, MPolynomialRing_generic)): F = [ S(((self[i] * l).numerator())._maxima_().divide( self[i].denominator())[0].sage()) for i in range(N) ] else: F = [S(self[i] * l) for i in range(N)] F.insert(n, S(l)) d = max([F[i].degree() for i in range(N + 1)]) F = [ F[i].homogenize(newvar) * S.gen(N)**(d - F[i].degree()) for i in range(N + 1) ] from sage.schemes.affine.affine_space import is_AffineSpace if is_AffineSpace(A) == True: from sage.schemes.projective.projective_space import ProjectiveSpace X = ProjectiveSpace(A.base_ring(), NB, Vars) else: X = A.projective_embedding(n).codomain() phi = S.hom(X.ambient_space().gens(), X.ambient_space().coordinate_ring()) F = [phi(f) for f in F] H = Hom(X, X) return (H(F))