Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/schemes/plane_curves/constructor.py
8820 views
1
"""
2
Plane curve constructors
3
4
AUTHORS:
5
6
- William Stein (2005-11-13)
7
8
- David Kohel (2006-01)
9
"""
10
11
#*****************************************************************************
12
# Copyright (C) 2005 William Stein <[email protected]>
13
#
14
# Distributed under the terms of the GNU General Public License (GPL)
15
#
16
# This code is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
# General Public License for more details.
20
#
21
# The full text of the GPL is available at:
22
#
23
# http://www.gnu.org/licenses/
24
#*****************************************************************************
25
26
from sage.rings.polynomial.multi_polynomial_element import is_MPolynomial
27
from sage.rings.polynomial.multi_polynomial_ring import is_MPolynomialRing
28
from sage.rings.finite_rings.constructor import is_FiniteField
29
30
from sage.structure.all import Sequence
31
32
from sage.schemes.generic.all import (is_AmbientSpace, is_AlgebraicScheme)
33
34
from sage.schemes.affine.all import AffineSpace
35
36
from sage.schemes.projective.all import ProjectiveSpace
37
38
39
from projective_curve import (ProjectiveCurve_generic,
40
ProjectiveSpaceCurve_generic,
41
ProjectiveCurve_finite_field,
42
ProjectiveCurve_prime_finite_field)
43
44
from affine_curve import (AffineCurve_generic,
45
AffineSpaceCurve_generic,
46
AffineCurve_finite_field,
47
AffineCurve_prime_finite_field)
48
49
from sage.schemes.plane_conics.constructor import Conic
50
51
def Curve(F):
52
"""
53
Return the plane or space curve defined by `F`, where
54
`F` can be either a multivariate polynomial, a list or
55
tuple of polynomials, or an algebraic scheme.
56
57
If `F` is in two variables the curve is affine, and if it
58
is homogenous in `3` variables, then the curve is
59
projective.
60
61
EXAMPLE: A projective plane curve
62
63
::
64
65
sage: x,y,z = QQ['x,y,z'].gens()
66
sage: C = Curve(x^3 + y^3 + z^3); C
67
Projective Curve over Rational Field defined by x^3 + y^3 + z^3
68
sage: C.genus()
69
1
70
71
EXAMPLE: Affine plane curves
72
73
::
74
75
sage: x,y = GF(7)['x,y'].gens()
76
sage: C = Curve(y^2 + x^3 + x^10); C
77
Affine Curve over Finite Field of size 7 defined by x^10 + x^3 + y^2
78
sage: C.genus()
79
0
80
sage: x, y = QQ['x,y'].gens()
81
sage: Curve(x^3 + y^3 + 1)
82
Affine Curve over Rational Field defined by x^3 + y^3 + 1
83
84
EXAMPLE: A projective space curve
85
86
::
87
88
sage: x,y,z,w = QQ['x,y,z,w'].gens()
89
sage: C = Curve([x^3 + y^3 - z^3 - w^3, x^5 - y*z^4]); C
90
Projective Space Curve over Rational Field defined by x^3 + y^3 - z^3 - w^3, x^5 - y*z^4
91
sage: C.genus()
92
13
93
94
EXAMPLE: An affine space curve
95
96
::
97
98
sage: x,y,z = QQ['x,y,z'].gens()
99
sage: C = Curve([y^2 + x^3 + x^10 + z^7, x^2 + y^2]); C
100
Affine Space Curve over Rational Field defined by x^10 + z^7 + x^3 + y^2, x^2 + y^2
101
sage: C.genus()
102
47
103
104
EXAMPLE: We can also make non-reduced non-irreducible curves.
105
106
::
107
108
sage: x,y,z = QQ['x,y,z'].gens()
109
sage: Curve((x-y)*(x+y))
110
Projective Conic Curve over Rational Field defined by x^2 - y^2
111
sage: Curve((x-y)^2*(x+y)^2)
112
Projective Curve over Rational Field defined by x^4 - 2*x^2*y^2 + y^4
113
114
EXAMPLE: A union of curves is a curve.
115
116
::
117
118
sage: x,y,z = QQ['x,y,z'].gens()
119
sage: C = Curve(x^3 + y^3 + z^3)
120
sage: D = Curve(x^4 + y^4 + z^4)
121
sage: C.union(D)
122
Projective Curve over Rational Field defined by
123
x^7 + x^4*y^3 + x^3*y^4 + y^7 + x^4*z^3 + y^4*z^3 + x^3*z^4 + y^3*z^4 + z^7
124
125
The intersection is not a curve, though it is a scheme.
126
127
::
128
129
sage: X = C.intersection(D); X
130
Closed subscheme of Projective Space of dimension 2 over Rational Field defined by:
131
x^3 + y^3 + z^3,
132
x^4 + y^4 + z^4
133
134
Note that the intersection has dimension `0`.
135
136
::
137
138
sage: X.dimension()
139
0
140
sage: I = X.defining_ideal(); I
141
Ideal (x^3 + y^3 + z^3, x^4 + y^4 + z^4) of Multivariate Polynomial Ring in x, y, z over Rational Field
142
143
EXAMPLE: In three variables, the defining equation must be
144
homogeneous.
145
146
If the parent polynomial ring is in three variables, then the
147
defining ideal must be homogeneous.
148
149
::
150
151
sage: x,y,z = QQ['x,y,z'].gens()
152
sage: Curve(x^2+y^2)
153
Projective Conic Curve over Rational Field defined by x^2 + y^2
154
sage: Curve(x^2+y^2+z)
155
Traceback (most recent call last):
156
...
157
TypeError: x^2 + y^2 + z is not a homogeneous polynomial!
158
159
The defining polynomial must always be nonzero::
160
161
sage: P1.<x,y> = ProjectiveSpace(1,GF(5))
162
sage: Curve(0*x)
163
Traceback (most recent call last):
164
...
165
ValueError: defining polynomial of curve must be nonzero
166
"""
167
if is_AlgebraicScheme(F):
168
return Curve(F.defining_polynomials())
169
170
if isinstance(F, (list, tuple)):
171
if len(F) == 1:
172
return Curve(F[0])
173
F = Sequence(F)
174
P = F.universe()
175
if not is_MPolynomialRing(P):
176
raise TypeError, "universe of F must be a multivariate polynomial ring"
177
178
for f in F:
179
if not f.is_homogeneous():
180
A = AffineSpace(P.ngens(), P.base_ring())
181
A._coordinate_ring = P
182
return AffineSpaceCurve_generic(A, F)
183
184
A = ProjectiveSpace(P.ngens()-1, P.base_ring())
185
A._coordinate_ring = P
186
return ProjectiveSpaceCurve_generic(A, F)
187
188
if not is_MPolynomial(F):
189
raise TypeError, "F (=%s) must be a multivariate polynomial"%F
190
191
P = F.parent()
192
k = F.base_ring()
193
if F.parent().ngens() == 2:
194
if F == 0:
195
raise ValueError, "defining polynomial of curve must be nonzero"
196
A2 = AffineSpace(2, P.base_ring())
197
A2._coordinate_ring = P
198
199
if is_FiniteField(k):
200
if k.is_prime_field():
201
return AffineCurve_prime_finite_field(A2, F)
202
else:
203
return AffineCurve_finite_field(A2, F)
204
else:
205
return AffineCurve_generic(A2, F)
206
207
elif F.parent().ngens() == 3:
208
if F == 0:
209
raise ValueError, "defining polynomial of curve must be nonzero"
210
P2 = ProjectiveSpace(2, P.base_ring())
211
P2._coordinate_ring = P
212
213
if F.total_degree() == 2 and k.is_field():
214
return Conic(F)
215
216
if is_FiniteField(k):
217
if k.is_prime_field():
218
return ProjectiveCurve_prime_finite_field(P2, F)
219
else:
220
return ProjectiveCurve_finite_field(P2, F)
221
else:
222
return ProjectiveCurve_generic(P2, F)
223
224
225
else:
226
227
raise TypeError, "Number of variables of F (=%s) must be 2 or 3"%F
228
229
230
231