Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/schemes/plane_curves/curve.py
4108 views
1
from sage.misc.all import latex
2
3
4
from sage.schemes.generic.algebraic_scheme import (
5
AlgebraicScheme_subscheme, AlgebraicScheme_subscheme_projective)
6
7
from sage.schemes.generic.divisor_group import DivisorGroup
8
9
from sage.schemes.generic.divisor import Divisor_curve
10
11
class Curve_generic(AlgebraicScheme_subscheme):
12
r"""
13
EXAMPLES::
14
15
sage: A.<x,y,z> = AffineSpace(QQ,3)
16
sage: C = Curve([x-y,z-2])
17
sage: loads(C.dumps()) == C
18
True
19
"""
20
21
def _repr_(self):
22
"""
23
EXAMPLES::
24
25
sage: A.<x,y,z> = AffineSpace(QQ,3)
26
sage: C = Curve([x-y,z-2])
27
sage: C
28
Affine Space Curve over Rational Field defined by x - y, z - 2
29
30
sage: P.<x,y,z> = ProjectiveSpace(QQ,2)
31
sage: C = Curve(x-y)
32
sage: C
33
Projective Curve over Rational Field defined by x - y
34
"""
35
return "%s Curve over %s defined by %s"%(
36
self._repr_type(), self.base_ring(), ', '.join([str(x) for x in self.defining_polynomials()]))
37
38
def _repr_type(self):
39
return "Generic"
40
41
def _latex_(self):
42
"""
43
EXAMPLES:
44
sage: x,y,z = PolynomialRing(QQ, 3, names='x,y,z').gens()
45
sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2)
46
sage: latex(C)
47
- x^{3} + y^{2} z - 17 x z^{2} + y z^{2}
48
49
sage: A2 = AffineSpace(2, QQ, names=['x','y'])
50
sage: x, y = A2.coordinate_ring().gens()
51
sage: C = Curve(y^2 - x^3 - 17*x + y)
52
sage: latex(C)
53
- x^{3} + y^{2} - 17 x + y
54
"""
55
return latex(self.defining_polynomial())
56
57
def defining_polynomial(self):
58
return self.defining_polynomials()[0]
59
60
def divisor_group(self, base_ring=None):
61
r"""
62
Return the divisor group of the curve.
63
64
INPUT:
65
66
- ``base_ring`` -- the base ring of the divisor
67
group. Usually, this is `\ZZ` (default) or `\QQ`.
68
69
OUTPUT:
70
71
The divisor group of the curve.
72
73
EXAMPLES::
74
75
sage: x,y,z = PolynomialRing(QQ, 3, names='x,y,z').gens()
76
sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2)
77
sage: Cp = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2)
78
sage: C.divisor_group() is Cp.divisor_group()
79
True
80
"""
81
return DivisorGroup(self, base_ring)
82
83
def divisor(self, v, base_ring=None, check=True, reduce=True):
84
r"""
85
Return the divisor specified by ``v``.
86
87
.. WARNING::
88
89
The coefficients of the divisor must be in the base ring
90
and the terms must be reduced. If you set ``check=False``
91
and/or ``reduce=False`` it is your responsibility to pass
92
a valid object ``v``.
93
"""
94
return Divisor_curve(v, check=check, reduce=reduce, parent=self.divisor_group(base_ring))
95
96
def genus(self):
97
"""
98
The geometric genus of the curve.
99
"""
100
return self.geometric_genus()
101
102
def geometric_genus(self):
103
r"""
104
The geometric genus of the curve, which is by definition the
105
genus of the normalization of the projective closure of the
106
curve over the algebraic closure of the base field; the base
107
field must be a prime field.
108
109
\note{Calls Singular's genus command.}
110
111
EXAMPLE:
112
Examples of projective curves.
113
sage: P2 = ProjectiveSpace(2, GF(5), names=['x','y','z'])
114
sage: x, y, z = P2.coordinate_ring().gens()
115
sage: C = Curve(y^2*z - x^3 - 17*x*z^2 + y*z^2)
116
sage: C.geometric_genus()
117
1
118
sage: C = Curve(y^2*z - x^3)
119
sage: C.geometric_genus()
120
0
121
sage: C = Curve(x^10 + y^7*z^3 + z^10)
122
sage: C.geometric_genus()
123
3
124
125
Examples of affine curves.
126
sage: x, y = PolynomialRing(GF(5), 2, 'xy').gens()
127
sage: C = Curve(y^2 - x^3 - 17*x + y)
128
sage: C.geometric_genus()
129
1
130
sage: C = Curve(y^2 - x^3)
131
sage: C.geometric_genus()
132
0
133
sage: C = Curve(x^10 + y^7 + 1)
134
sage: C.geometric_genus()
135
3
136
137
"""
138
try:
139
return self.__genus
140
except AttributeError:
141
self.__genus = self.defining_ideal().genus()
142
return self.__genus
143
144
def union(self, other):
145
from constructor import Curve
146
return Curve(AlgebraicScheme_subscheme.union(self, other))
147
148
__add__ = union
149
150
class Curve_generic_projective(Curve_generic, AlgebraicScheme_subscheme_projective):
151
pass
152
153