From b3002ef28b0b1f9ae39b1222c446625037420db9 Mon Sep 17 00:00:00 2001 From: Grayson Jorgenson Date: Wed, 25 May 2016 17:17:18 -0400 Subject: [PATCH] 20676: First pass at implementation. --- src/sage/schemes/plane_curves/affine_curve.py | 39 +++++++++++++++++++ .../schemes/plane_curves/projective_curve.py | 28 +++++++++++++ 2 files changed, 67 insertions(+) diff --git a/src/sage/schemes/plane_curves/affine_curve.py b/src/sage/schemes/plane_curves/affine_curve.py index d080ac7db89..72fd6931467 100644 --- a/src/sage/schemes/plane_curves/affine_curve.py +++ b/src/sage/schemes/plane_curves/affine_curve.py @@ -20,6 +20,7 @@ # http://www.gnu.org/licenses/ #***************************************************************************** +from sage.categories.homset import Hom from sage.interfaces.all import singular from sage.misc.all import add @@ -29,8 +30,10 @@ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing from sage.schemes.affine.affine_space import is_AffineSpace + from sage.schemes.generic.algebraic_scheme import AlgebraicScheme_subscheme_affine +from sage.schemes.projective.projective_space import ProjectiveSpace from curve import Curve_generic @@ -46,6 +49,42 @@ def __init__(self, A, X): if d != 1: raise ValueError("defining equations (=%s) define a scheme of dimension %s != 1"%(X,d)) + def projective_closure(self): + r""" + Return the projective closure of this affine curve. + + OUTPUT: + + - a curve in projective space. + + EXAMPLES:: + + sage: A. = AffineSpace(CC,3) + sage: C = Curve([x-y,z-2]) + sage: C.projective_closure() + Projective Space Curve over Complex Field with 53 bits of precision defined by + x0 - x1, x2 + (-2.00000000000000)*x3 + + :: + + sage: A. = AffineSpace(QQ,3) + sage: C = Curve([y-x^2,z-x^3]) + sage: C.projective_closure() + Projective Space Curve over Rational Field defined by x0^2 - x1*x3, + x0*x1 - x2*x3, x1^2 - x0*x2 + """ + I = self.defining_ideal() + # compute a Groebner basis of this ideal with respect to a graded monomial order + R = self.ambient_space().coordinate_ring().change_ring(order='degrevlex') + n = self.ambient_space().dimension_relative() + P = ProjectiveSpace(self.ambient_space().base_ring(),n) + RH = P.coordinate_ring() + G = R.ideal([R(f) for f in I.gens()]).groebner_basis() + H = Hom(R,RH) + phi = H([RH.gens()[i] for i in range(0,n)]) + from constructor import Curve + return Curve([phi(f).homogenize(RH.gens()[n]) for f in G]) + class AffineCurve_generic(Curve_generic): def __init__(self, A, f): P = f.parent() diff --git a/src/sage/schemes/plane_curves/projective_curve.py b/src/sage/schemes/plane_curves/projective_curve.py index f29625978cc..ea0fd3530ff 100644 --- a/src/sage/schemes/plane_curves/projective_curve.py +++ b/src/sage/schemes/plane_curves/projective_curve.py @@ -22,9 +22,11 @@ # http://www.gnu.org/licenses/ #***************************************************************************** +from sage.categories.homset import Hom from sage.interfaces.all import singular from sage.misc.all import add, sage_eval from sage.rings.all import degree_lowest_rational_function +from sage.schemes.affine.affine_space import AffineSpace from sage.schemes.projective.projective_space import is_ProjectiveSpace @@ -42,6 +44,32 @@ def __init__(self, A, X): if d != 1: raise ValueError("defining equations (=%s) define a scheme of dimension %s != 1"%(X,d)) + def affine_patch(self,i): + r""" + Return the `i`th affine patch of this projective curve. + + OUTPUT: + + - a curve in affine space. + + EXAMPLES:: + + sage: P. = ProjectiveSpace(CC,3) + sage: C = Curve([y*z - x^2,w^2 - x*y]) + sage: C.affine_patch(0) + Affine Space Curve over Complex Field with 53 bits of precision defined by + x0*x1 - 1.00000000000000, x2^2 - x0 + """ + I = self.defining_ideal() + n = self.ambient_space().dimension_relative() + A = AffineSpace(self.ambient_space().base_ring(),n) + H = Hom(self.ambient_space().coordinate_ring(),A.coordinate_ring()) + l = list(A.coordinate_ring().gens()) + l.insert(i,1) + phi = H(l) + from constructor import Curve + return Curve([phi(f) for f in I.gens()]) + class ProjectiveCurve_generic(Curve_generic_projective): def __init__(self, A, f): if not (is_ProjectiveSpace(A) and A.dimension != 2):