Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/schemes/hyperelliptic_curves/mestre.py
8820 views
1
r"""
2
Mestre's algorithm
3
4
This file contains functions that:
5
6
- create hyperelliptic curves from the Igusa-Clebsch invariants (over
7
`\QQ` and finite fields)
8
- create Mestre's conic from the Igusa-Clebsch invariants
9
10
AUTHORS:
11
12
- Florian Bouyer
13
- Marco Streng
14
15
"""
16
#*****************************************************************************
17
# Copyright (C) 2011, 2012, 2013
18
# Florian Bouyer <[email protected]>
19
# Marco Streng <[email protected]>
20
#
21
# Distributed under the terms of the GNU General Public License (GPL)
22
# as published by the Free Software Foundation; either version 2 of
23
# the License, or (at your option) any later version.
24
# http://www.gnu.org/licenses/
25
#*****************************************************************************
26
27
from sage.matrix.all import Matrix
28
from sage.schemes.plane_conics.constructor import Conic
29
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
30
from sage.schemes.hyperelliptic_curves.constructor import HyperellipticCurve
31
32
33
def HyperellipticCurve_from_invariants(i, reduced=True, precision=None,
34
algorithm='default'):
35
r"""
36
Returns a hyperelliptic curve with the given Igusa-Clebsch invariants up to
37
scaling.
38
39
The output is a curve over the field in which the Igusa-Clebsch invariants
40
are given. The output curve is unique up to isomorphism over the algebraic
41
closure. If no such curve exists over the given field, then raise a
42
ValueError.
43
44
INPUT:
45
46
- ``i`` - list or tuple of length 4 containing the four Igusa-Clebsch
47
invariants: I2,I4,I6,I10.
48
- ``reduced`` - Boolean (default = True) If True, tries to reduce the
49
polynomial defining the hyperelliptic curve using the function
50
:func:`reduce_polynomial` (see the :func:`reduce_polynomial`
51
documentation for more details).
52
- ``precision`` - integer (default = None) Which precision for real and
53
complex numbers should the reduction use. This only affects the
54
reduction, not the correctness. If None, the algorithm uses the default
55
53 bit precision.
56
- ``algorithm`` - ``'default'`` or ``'magma'``. If set to ``'magma'``, uses
57
Magma to parameterize Mestre's conic (needs Magma to be installed).
58
59
OUTPUT:
60
61
A hyperelliptic curve object.
62
63
EXAMPLE:
64
65
Examples over the rationals::
66
67
sage: HyperellipticCurve_from_invariants([3840,414720,491028480,2437709561856])
68
Traceback (most recent call last):
69
...
70
NotImplementedError: Reduction of hyperelliptic curves not yet implemented. See trac #14755 and #14756.
71
sage: HyperellipticCurve_from_invariants([3840,414720,491028480,2437709561856],reduced = False)
72
Hyperelliptic Curve over Rational Field defined by y^2 = -x^6 + 4410*x^5 - 540*x^4 + 4320*x^3 - 19440*x^2 + 46656*x - 46656
73
sage: HyperellipticCurve_from_invariants([21, 225/64, 22941/512, 1])
74
Traceback (most recent call last):
75
...
76
NotImplementedError: Reduction of hyperelliptic curves not yet implemented. See trac #14755 and #14756.
77
78
An example over a finite field::
79
80
sage: HyperellipticCurve_from_invariants([GF(13)(1),3,7,5])
81
Hyperelliptic Curve over Finite Field of size 13 defined by y^2 = 8*x^5 + 5*x^4 + 5*x^2 + 9*x + 3
82
83
An example over a number field::
84
85
sage: K = QuadraticField(353, 'a')
86
sage: H = HyperellipticCurve_from_invariants([21, 225/64, 22941/512, 1], reduced = false)
87
sage: f = K['x'](H.hyperelliptic_polynomials()[0])
88
89
If the Mestre Conic defined by the Igusa-Clebsch invariants has no rational
90
points, then there exists no hyperelliptic curve over the base field with
91
the given invariants.::
92
93
sage: HyperellipticCurve_from_invariants([1,2,3,4])
94
Traceback (most recent call last):
95
...
96
ValueError: No such curve exists over Rational Field as there are no rational points on Projective Conic Curve over Rational Field defined by -2572155000*u^2 - 317736000*u*v + 1250755459200*v^2 + 2501510918400*u*w + 39276887040*v*w + 2736219686912*w^2
97
98
Mestre's algorithm only works for generic curves of genus two, so another
99
algorithm is needed for those curves with extra automorphism. See also
100
:trac:`12199`::
101
102
sage: P.<x> = QQ[]
103
sage: C = HyperellipticCurve(x^6+1)
104
sage: i = C.igusa_clebsch_invariants()
105
sage: HyperellipticCurve_from_invariants(i)
106
Traceback (most recent call last):
107
...
108
TypeError: F (=0) must have degree 2
109
110
111
Igusa-Clebsch invariants also only work over fields of charateristic
112
different from 2, 3, and 5, so another algorithm will be needed for fields
113
of those characteristics. See also :trac:`12200`::
114
115
sage: P.<x> = GF(3)[]
116
sage: HyperellipticCurve(x^6+x+1).igusa_clebsch_invariants()
117
Traceback (most recent call last):
118
...
119
NotImplementedError: Invariants of binary sextics/genus 2 hyperelliptic curves not implemented in characteristics 2, 3, and 5
120
sage: HyperellipticCurve_from_invariants([GF(5)(1),1,0,1])
121
Traceback (most recent call last):
122
...
123
ZeroDivisionError: Inverse does not exist.
124
125
ALGORITHM:
126
127
This is Mestre's algorithm [M1991]_. Our implementation is based on the
128
formulae on page 957 of [LY2001]_, cross-referenced with [W1999]_ to
129
correct typos.
130
131
First construct Mestre's conic using the :func:`Mestre_conic` function.
132
Parametrize the conic if possible.
133
Let `f_1, f_2, f_3` be the three coordinates of the parametrization of the
134
conic by the projective line, and change them into one variable by letting
135
`F_i = f_i(t, 1)`. Note that each `F_i` has degree at most 2.
136
137
Then construct a sextic polynomial
138
`f = \sum_{0<=i,j,k<=3}{c_{ijk}*F_i*F_j*F_k}`,
139
where `c_{ijk}` are defined as rational functions in the invariants
140
(see the source code for detailed formulae for `c_{ijk}`).
141
The output is the hyperelliptic curve `y^2 = f`.
142
143
REFERENCES:
144
145
.. [LY2001] K. Lauter and T. Yang, "Computing genus 2 curves from
146
invariants on the Hilbert moduli space", Journal of Number Theory 131
147
(2011), pages 936 - 958
148
.. [M1991] J.-F. Mestre, "Construction de courbes de genre 2 a partir de
149
leurs modules", in Effective methods in algebraic geometry
150
(Castiglioncello, 1990), volume 94 of Progr. Math., pages 313 - 334
151
.. [W1999] P. van Wamelen, Pari-GP code, section "thecubic"
152
https://www.math.lsu.edu/~wamelen/Genus2/FindCurve/igusa2curve.gp
153
"""
154
from sage.structure.sequence import Sequence
155
i = Sequence(i)
156
k = i.universe()
157
try:
158
k = k.fraction_field()
159
except (TypeError, AttributeError, NotImplementedError):
160
pass
161
162
MConic, x, y, z = Mestre_conic(i, xyz=True)
163
if k.is_finite():
164
reduced = False
165
166
t = k['t'].gen()
167
168
if algorithm == 'magma':
169
from sage.interfaces.all import magma
170
from sage.misc.sage_eval import sage_eval
171
if MConic.has_rational_point(algorithm='magma'):
172
parametrization = [l.replace('$.1', 't').replace('$.2', 'u') \
173
for l in str(magma(MConic).Parametrization()).splitlines()[4:7]]
174
[F1, F2, F3] = [sage_eval(p, locals={'t':t,'u':1,'a':k.gen()}) \
175
for p in parametrization]
176
else:
177
raise ValueError("No such curve exists over %s as there are no " \
178
"rational points on %s" % (k, MConic))
179
else:
180
if MConic.has_rational_point():
181
parametrization = MConic.parametrization(morphism=False)[0]
182
[F1, F2, F3] = [p(t, 1) for p in parametrization]
183
else:
184
raise ValueError("No such curve exists over %s as there are no " \
185
"rational points on %s" % (k, MConic))
186
187
# setting the cijk from Mestre's algorithm
188
c111 = 12*x*y - 2*y/3 - 4*z
189
c112 = -18*x**3 - 12*x*y - 36*y**2 - 2*z
190
c113 = -9*x**3 - 36*x**2*y -4*x*y - 6*x*z - 18*y**2
191
c122 = c113
192
c123 = -54*x**4 - 36*x**2*y - 36*x*y**2 - 6*x*z - 4*y**2 - 24*y*z
193
c133 = -27*x**4/2 - 72*x**3*y - 6*x**2*y - 9*x**2*z - 39*x*y**2 - \
194
36*y**3 - 2*y*z
195
c222 = -27*x**4 - 18*x**2*y - 6*x*y**2 - 8*y**2/3 + 2*y*z
196
c223 = 9*x**3*y - 27*x**2*z + 6*x*y**2 + 18*y**3 - 8*y*z
197
c233 = -81*x**5/2 - 27*x**3*y - 9*x**2*y**2 - 4*x*y**2 + 3*x*y*z - 6*z**2
198
c333 = 27*x**4*y/2 - 27*x**3*z/2 + 9*x**2*y**2 + 3*x*y**3 - 6*x*y*z + \
199
4*y**3/3 - 10*y**2*z
200
201
# writing out the hyperelliptic curve polynomial
202
f = c111*F1**3 + c112*F1**2*F2 + c113*F1**2*F3 + c122*F1*F2**2 + \
203
c123*F1*F2*F3 + c133*F1*F3**2 + c222*F2**3 + c223*F2**2*F3 + \
204
c233*F2*F3**2 + c333*F3**3
205
206
try:
207
f = f*f.denominator() # clear the denominator
208
except (AttributeError, TypeError):
209
pass
210
211
if reduced:
212
raise NotImplementedError("Reduction of hyperelliptic curves not " \
213
"yet implemented. " \
214
"See trac #14755 and #14756.")
215
216
return HyperellipticCurve(f)
217
218
219
def Mestre_conic(i, xyz=False, names='u,v,w'):
220
r"""
221
Return the conic equation from Mestre's algorithm given the Igusa-Clebsch
222
invariants.
223
224
It has a rational point if and only if a hyperelliptic curve
225
corresponding to the invariants exists.
226
227
INPUT:
228
229
- ``i`` - list or tuple of length 4 containing the four Igusa-Clebsch
230
invariants: I2, I4, I6, I10
231
- ``xyz`` - Boolean (default: False) if True, the algorithm also
232
returns three invariants x,y,z used in Mestre's algorithm
233
- ``names`` (default: 'u,v,w') - the variable names for the Conic
234
235
OUTPUT:
236
237
A Conic object
238
239
EXAMPLES:
240
241
A standard example::
242
243
sage: Mestre_conic([1,2,3,4])
244
Projective Conic Curve over Rational Field defined by -2572155000*u^2 - 317736000*u*v + 1250755459200*v^2 + 2501510918400*u*w + 39276887040*v*w + 2736219686912*w^2
245
246
Note that the algorithm works over number fields as well::
247
248
sage: k = NumberField(x^2-41,'a')
249
sage: a = k.an_element()
250
sage: Mestre_conic([1,2+a,a,4+a])
251
Projective Conic Curve over Number Field in a with defining polynomial x^2 - 41 defined by (-801900000*a + 343845000)*u^2 + (855360000*a + 15795864000)*u*v + (312292800000*a + 1284808579200)*v^2 + (624585600000*a + 2569617158400)*u*w + (15799910400*a + 234573143040)*v*w + (2034199306240*a + 16429854656512)*w^2
252
253
And over finite fields::
254
255
sage: Mestre_conic([GF(7)(10),GF(7)(1),GF(7)(2),GF(7)(3)])
256
Projective Conic Curve over Finite Field of size 7 defined by -2*u*v - v^2 - 2*u*w + 2*v*w - 3*w^2
257
258
An example with xyz::
259
260
sage: Mestre_conic([5,6,7,8], xyz=True)
261
(Projective Conic Curve over Rational Field defined by -415125000*u^2 + 608040000*u*v + 33065136000*v^2 + 66130272000*u*w + 240829440*v*w + 10208835584*w^2, 232/1125, -1072/16875, 14695616/2109375)
262
263
ALGORITHM:
264
265
The formulas are taken from pages 956 - 957 of [LY2001]_ and based on pages
266
321 and 332 of [M1991]_.
267
268
See the code or [LY2001]_ for the detailed formulae defining x, y, z and L.
269
270
"""
271
from sage.structure.sequence import Sequence
272
k = Sequence(i).universe()
273
try:
274
k = k.fraction_field()
275
except (TypeError, AttributeError, NotImplementedError):
276
pass
277
278
I2, I4, I6, I10 = i
279
280
#Setting x,y,z as in Mestre's algorithm (Using Lauter and Yang's formulas)
281
x = 8*(1 + 20*I4/(I2**2))/225
282
y = 16*(1 + 80*I4/(I2**2) - 600*I6/(I2**3))/3375
283
z = -64*(-10800000*I10/(I2**5) - 9 - 700*I4/(I2**2) + 3600*I6/(I2**3) +
284
12400*I4**2/(I2**4) - 48000*I4*I6/(I2**5))/253125
285
286
L = Matrix([[x+6*y , 6*x**2+2*y , 2*z ],
287
[6*x**2+2*y, 2*z , 9*x**3 + 4*x*y + 6*y**2 ],
288
[2*z , 9*x**3+4*x*y+6*y**2, 6*x**2*y + 2*y**2 + 3*x*z]])
289
290
try:
291
L = L*L.denominator() # clears the denominator
292
except (AttributeError, TypeError):
293
pass
294
295
u, v, w = PolynomialRing(k, names).gens()
296
MConic = Conic(k, L, names)
297
if xyz:
298
return MConic, x, y, z
299
return MConic
300
301