Path: blob/master/src/sage/schemes/plane_curves/curve.py
8821 views
from sage.misc.all import latex123from sage.schemes.generic.algebraic_scheme import (4AlgebraicScheme_subscheme, AlgebraicScheme_subscheme_projective)56from sage.schemes.generic.divisor_group import DivisorGroup78from sage.schemes.generic.divisor import Divisor_curve910class Curve_generic(AlgebraicScheme_subscheme):11r"""12EXAMPLES::1314sage: A.<x,y,z> = AffineSpace(QQ,3)15sage: C = Curve([x-y,z-2])16sage: loads(C.dumps()) == C17True18"""1920def _repr_(self):21"""22EXAMPLES::2324sage: A.<x,y,z> = AffineSpace(QQ,3)25sage: C = Curve([x-y,z-2])26sage: C27Affine Space Curve over Rational Field defined by x - y, z - 22829sage: P.<x,y,z> = ProjectiveSpace(QQ,2)30sage: C = Curve(x-y)31sage: C32Projective Curve over Rational Field defined by x - y33"""34return "%s Curve over %s defined by %s"%(35self._repr_type(), self.base_ring(), ', '.join([str(x) for x in self.defining_polynomials()]))3637def _repr_type(self):38return "Generic"3940def _latex_(self):41"""42EXAMPLES:43sage: x,y,z = PolynomialRing(QQ, 3, names='x,y,z').gens()44sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2)45sage: latex(C)46- x^{3} + y^{2} z - 17 x z^{2} + y z^{2}4748sage: A2 = AffineSpace(2, QQ, names=['x','y'])49sage: x, y = A2.coordinate_ring().gens()50sage: C = Curve(y^2 - x^3 - 17*x + y)51sage: latex(C)52- x^{3} + y^{2} - 17 x + y53"""54return latex(self.defining_polynomial())5556def defining_polynomial(self):57return self.defining_polynomials()[0]5859def divisor_group(self, base_ring=None):60r"""61Return the divisor group of the curve.6263INPUT:6465- ``base_ring`` -- the base ring of the divisor66group. Usually, this is `\ZZ` (default) or `\QQ`.6768OUTPUT:6970The divisor group of the curve.7172EXAMPLES::7374sage: x,y,z = PolynomialRing(QQ, 3, names='x,y,z').gens()75sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2)76sage: Cp = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2)77sage: C.divisor_group() is Cp.divisor_group()78True79"""80return DivisorGroup(self, base_ring)8182def divisor(self, v, base_ring=None, check=True, reduce=True):83r"""84Return the divisor specified by ``v``.8586.. WARNING::8788The coefficients of the divisor must be in the base ring89and the terms must be reduced. If you set ``check=False``90and/or ``reduce=False`` it is your responsibility to pass91a valid object ``v``.92"""93return Divisor_curve(v, check=check, reduce=reduce, parent=self.divisor_group(base_ring))9495def genus(self):96"""97The geometric genus of the curve.98"""99return self.geometric_genus()100101def geometric_genus(self):102r"""103The geometric genus of the curve, which is by definition the104genus of the normalization of the projective closure of the105curve over the algebraic closure of the base field; the base106field must be a prime field.107108\note{Calls Singular's genus command.}109110EXAMPLE:111Examples of projective curves.112sage: P2 = ProjectiveSpace(2, GF(5), names=['x','y','z'])113sage: x, y, z = P2.coordinate_ring().gens()114sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2)115sage: C.geometric_genus()1161117sage: C = Curve(y^2*z - x^3)118sage: C.geometric_genus()1190120sage: C = Curve(x^10 + y^7*z^3 + z^10)121sage: C.geometric_genus()1223123124Examples of affine curves.125sage: x, y = PolynomialRing(GF(5), 2, 'xy').gens()126sage: C = Curve(y^2 - x^3 - 17*x + y)127sage: C.geometric_genus()1281129sage: C = Curve(y^2 - x^3)130sage: C.geometric_genus()1310132sage: C = Curve(x^10 + y^7 + 1)133sage: C.geometric_genus()1343135136"""137try:138return self.__genus139except AttributeError:140self.__genus = self.defining_ideal().genus()141return self.__genus142143def union(self, other):144from constructor import Curve145return Curve(AlgebraicScheme_subscheme.union(self, other))146147__add__ = union148149class Curve_generic_projective(Curve_generic, AlgebraicScheme_subscheme_projective):150pass151152153