Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/schemes/generic/hypersurface.py
4100 views
1
r"""
2
Hypersurfaces in affine and projective space
3
4
AUTHORS:
5
6
- William Stein <[email protected]> (2005-12-08)
7
- David Kohel <[email protected]> (2005-12-08)
8
- Alex Ghitza <[email protected]> (2009-04-17)
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
# The full text of the GPL is available at:
17
#
18
# http://www.gnu.org/licenses/
19
#*****************************************************************************
20
21
from sage.rings.all import is_MPolynomial
22
from algebraic_scheme import AlgebraicScheme_subscheme_projective, AlgebraicScheme_subscheme_affine
23
24
def is_Hypersurface(self):
25
"""
26
Return True if self is a hypersurface, i.e. an object of the type
27
ProjectiveHypersurface or AffineHypersurface.
28
29
EXAMPLES::
30
31
sage: from sage.schemes.generic.hypersurface import is_Hypersurface
32
sage: R.<x, y, z> = ZZ[]
33
sage: H = ProjectiveHypersurface(x*z+y^2)
34
sage: is_Hypersurface(H)
35
True
36
37
::
38
39
sage: H = AffineHypersurface(x*z+y^2)
40
sage: is_Hypersurface(H)
41
True
42
43
::
44
45
sage: H = ProjectiveSpace(QQ, 5)
46
sage: is_Hypersurface(H)
47
False
48
"""
49
return isinstance(self, (ProjectiveHypersurface, AffineHypersurface))
50
51
class ProjectiveHypersurface(AlgebraicScheme_subscheme_projective):
52
"""
53
The projective hypersurface defined by the given polynomial.
54
55
EXAMPLES::
56
57
sage: P.<x, y, z> = ProjectiveSpace(ZZ, 2)
58
sage: ProjectiveHypersurface(x-y, P)
59
Projective hypersurface defined by x - y in Projective Space of dimension 2 over Integer Ring
60
61
::
62
63
sage: R.<x, y, z> = QQ[]
64
sage: ProjectiveHypersurface(x-y)
65
Projective hypersurface defined by x - y in Projective Space of dimension 2 over Rational Field
66
"""
67
68
def __init__(self, poly, ambient=None):
69
"""
70
Return the projective hypersurface in the space ambient
71
defined by the polynomial poly.
72
73
If ambient is not given, it will be constructed based on
74
poly.
75
76
EXAMPLES::
77
78
sage: P.<x, y, z> = ProjectiveSpace(ZZ, 2)
79
sage: ProjectiveHypersurface(x-y, P)
80
Projective hypersurface defined by x - y in Projective Space of dimension 2 over Integer Ring
81
82
::
83
84
sage: R.<x, y, z> = QQ[]
85
sage: ProjectiveHypersurface(x-y)
86
Projective hypersurface defined by x - y in Projective Space of dimension 2 over Rational Field
87
88
TESTS::
89
90
sage: H = ProjectiveHypersurface(x-y)
91
sage: H == loads(dumps(H))
92
True
93
"""
94
if not is_MPolynomial(poly):
95
raise TypeError, \
96
"Defining polynomial (=%s) must be a multivariate polynomial."%poly
97
if not poly.is_homogeneous():
98
raise TypeError, "Defining polynomial (=%s) must be homogeneous."%poly
99
if ambient == None:
100
R = poly.parent()
101
from projective_space import ProjectiveSpace
102
ambient = ProjectiveSpace(R.base_ring(), R.ngens()-1)
103
ambient._coordinate_ring = R
104
AlgebraicScheme_subscheme_projective.__init__(self, ambient, [poly])
105
106
def _repr_(self):
107
"""
108
Return a string representation of this projective
109
hypersurface.
110
111
EXAMPLES::
112
113
sage: R.<x, y, z> = ZZ[]
114
sage: H = ProjectiveHypersurface(x*z+y^2)
115
sage: H
116
Projective hypersurface defined by y^2 + x*z in Projective Space of dimension 2 over Integer Ring
117
sage: H._repr_()
118
'Projective hypersurface defined by y^2 + x*z in Projective Space of dimension 2 over Integer Ring'
119
"""
120
return "Projective hypersurface defined by %s in %s"%(
121
self.defining_polynomial(), self.ambient_space())
122
123
def defining_polynomial(self):
124
"""
125
Return the polynomial equation that cuts out this projective
126
hypersurface.
127
128
EXAMPLES::
129
130
sage: R.<x, y, z> = ZZ[]
131
sage: H = ProjectiveHypersurface(x*z+y^2)
132
sage: H.defining_polynomial()
133
y^2 + x*z
134
"""
135
return self.defining_polynomials()[0]
136
137
138
class AffineHypersurface(AlgebraicScheme_subscheme_affine):
139
"""
140
The affine hypersurface defined by the given polynomial.
141
142
EXAMPLES::
143
144
sage: A.<x, y, z> = AffineSpace(ZZ, 3)
145
sage: AffineHypersurface(x*y-z^3, A)
146
Affine hypersurface defined by -z^3 + x*y in Affine Space of dimension 3 over Integer Ring
147
148
::
149
150
sage: A.<x, y, z> = QQ[]
151
sage: AffineHypersurface(x*y-z^3)
152
Affine hypersurface defined by -z^3 + x*y in Affine Space of dimension 3 over Rational Field
153
"""
154
def __init__(self, poly, ambient=None):
155
"""
156
Return the affine hypersurface in the space ambient
157
defined by the polynomial poly.
158
159
If ambient is not given, it will be constructed based on
160
poly.
161
162
EXAMPLES::
163
164
sage: A.<x, y, z> = AffineSpace(ZZ, 3)
165
sage: AffineHypersurface(x*y-z^3, A)
166
Affine hypersurface defined by -z^3 + x*y in Affine Space of dimension 3 over Integer Ring
167
168
::
169
170
sage: A.<x, y, z> = QQ[]
171
sage: AffineHypersurface(x*y-z^3)
172
Affine hypersurface defined by -z^3 + x*y in Affine Space of dimension 3 over Rational Field
173
174
TESTS::
175
176
sage: H = AffineHypersurface(x*y-z^3)
177
sage: H == loads(dumps(H))
178
True
179
"""
180
if not is_MPolynomial(poly):
181
raise TypeError, "Defining polynomial (= %s) must be a multivariate polynomial"%poly
182
if ambient == None:
183
R = poly.parent()
184
from affine_space import AffineSpace
185
ambient = AffineSpace(R.base_ring(), R.ngens())
186
ambient._coordinate_ring = R
187
AlgebraicScheme_subscheme_affine.__init__(self, ambient, [poly])
188
189
def _repr_(self):
190
"""
191
Return a string representation of this affine
192
hypersurface.
193
194
EXAMPLES::
195
196
sage: R.<x, y, z> = ZZ[]
197
sage: H = AffineHypersurface(x*z+y^2)
198
sage: H
199
Affine hypersurface defined by y^2 + x*z in Affine Space of dimension 3 over Integer Ring
200
sage: H._repr_()
201
'Affine hypersurface defined by y^2 + x*z in Affine Space of dimension 3 over Integer Ring'
202
"""
203
return "Affine hypersurface defined by %s in %s"%(
204
self.defining_polynomial(), self.ambient_space())
205
206
def defining_polynomial(self):
207
"""
208
Return the polynomial equation that cuts out this affine
209
hypersurface.
210
211
EXAMPLES::
212
213
sage: R.<x, y, z> = ZZ[]
214
sage: H = AffineHypersurface(x*z+y^2)
215
sage: H.defining_polynomial()
216
y^2 + x*z
217
"""
218
return self.defining_polynomials()[0]
219
220
221
222
223