Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/lfunctions/sympow.py
4057 views
1
r"""
2
Watkins Symmetric Power `L`-function Calculator
3
4
SYMPOW is a package to compute special values of symmetric power
5
elliptic curve L-functions. It can compute up to about 64 digits of
6
precision. This interface provides complete access to sympow, which
7
is a standard part of Sage (and includes the extra data files).
8
9
.. note::
10
11
Each call to ``sympow`` runs a complete
12
``sympow`` process. This incurs about 0.2 seconds
13
overhead.
14
15
AUTHORS:
16
17
- Mark Watkins (2005-2006): wrote and released sympow
18
19
- William Stein (2006-03-05): wrote Sage interface
20
21
ACKNOWLEDGEMENT (from sympow readme):
22
23
24
- The quad-double package was modified from David Bailey's
25
package: http://crd.lbl.gov/~dhbailey/mpdist/
26
27
- The ``squfof`` implementation was modified from
28
Allan Steel's version of Arjen Lenstra's original LIP-based code.
29
30
- The ``ec_ap`` code was originally written for the
31
kernel of MAGMA, but was modified to use small integers when
32
possible.
33
34
- SYMPOW was originally developed using PARI, but due to licensing
35
difficulties, this was eliminated. SYMPOW also does not use the
36
standard math libraries unless Configure is run with the -lm
37
option. SYMPOW still uses GP to compute the meshes of inverse
38
Mellin transforms (this is done when a new symmetric power is added
39
to datafiles).
40
"""
41
42
########################################################################
43
# Copyright (C) 2006 William Stein <[email protected]>
44
#
45
# Distributed under the terms of the GNU General Public License (GPL)
46
#
47
# http://www.gnu.org/licenses/
48
########################################################################
49
50
import os
51
52
from sage.structure.sage_object import SageObject
53
from sage.misc.all import pager, verbose
54
import sage.rings.all
55
56
class Sympow(SageObject):
57
r"""
58
Watkins Symmetric Power `L`-function Calculator
59
60
Type ``sympow.[tab]`` for a list of useful commands
61
that are implemented using the command line interface, but return
62
objects that make sense in Sage.
63
64
You can also use the complete command-line interface of sympow via
65
this class. Type ``sympow.help()`` for a list of
66
commands and how to call them.
67
"""
68
def _repr_(self):
69
"""
70
Returns a string describing this calculator module
71
"""
72
return "Watkins Symmetric Power L-function Calculator"
73
74
def __call__(self, args):
75
"""
76
Used to call sympow with given args
77
"""
78
cmd = 'sympow %s'%args
79
v = os.popen(cmd).read().strip()
80
verbose(v, level=2)
81
return v
82
83
def _fix_err(self, err):
84
w = err
85
j = w.rfind('./sympow')
86
if j != -1:
87
w = w[:j-1] + "sympow('" + w[j+9:] + ')'
88
return w
89
90
def _curve_str(self, E):
91
return '-curve "%s"'%(str(list(E.minimal_model().a_invariants())).replace(' ',''))
92
93
def L(self, E, n, prec):
94
r"""
95
Return `L(\mathrm{Sym}^{(n)}(E, \text{edge}))` to prec digits of
96
precision, where edge is the *right* edge. Here `n` must be
97
even.
98
99
INPUT:
100
101
102
- ``E`` - elliptic curve
103
104
- ``n`` - even integer
105
106
- ``prec`` - integer
107
108
109
OUTPUT:
110
111
112
- ``string`` - real number to prec digits of precision
113
as a string.
114
115
116
.. note::
117
118
Before using this function for the first time for a given
119
`n`, you may have to type ``sympow('-new_data n')``,
120
where ``n`` is replaced by your value of `n`.
121
122
If you would like to see the extensive output sympow prints when
123
running this function, just type ``set_verbose(2)``.
124
125
EXAMPLES::
126
127
sage: a = sympow.L(EllipticCurve('11a'), 2, 16); a # optional
128
'1.057599244590958E+00'
129
sage: RR(a) # optional -- requires precomputations
130
1.05759924459096
131
"""
132
if n % 2 == 1:
133
raise ValueError, "n (=%s) must be even"%n
134
if prec > 64:
135
raise ValueError, "prec (=%s) must be at most 64"%prec
136
if prec < 1:
137
raise ValueError, "prec (=%s) must be at least 1"%prec
138
v = self('-sp %sp%s %s'%(n, prec, self._curve_str(E)))
139
i = v.rfind(': ')
140
if i == -1:
141
print self._fix_err(v)
142
raise RuntimeError, "failed to compute symmetric power"
143
x = v[i+2:]
144
return x
145
146
147
def Lderivs(self, E, n, prec, d):
148
r"""
149
Return `0^{th}` to `d^{th}` derivatives of
150
`L(\mathrm{Sym}^{(n)}(E,s)` to prec digits of precision, where
151
`s` is the right edge if `n` is even and the center
152
if `n` is odd.
153
154
INPUT:
155
156
157
- ``E`` - elliptic curve
158
159
- ``n`` - integer (even or odd)
160
161
- ``prec`` - integer
162
163
- ``d`` - integer
164
165
166
OUTPUT: a string, exactly as output by sympow
167
168
.. note::
169
170
To use this function you may have to run a few commands
171
like ``sympow('-new_data 1d2')``, each which takes a
172
few minutes. If this function fails it will indicate what commands
173
have to be run.
174
175
EXAMPLES::
176
177
sage: print sympow.Lderivs(EllipticCurve('11a'), 1, 16, 2) # not tested
178
...
179
1n0: 2.538418608559107E-01
180
1w0: 2.538418608559108E-01
181
1n1: 1.032321840884568E-01
182
1w1: 1.059251499158892E-01
183
1n2: 3.238743180659171E-02
184
1w2: 3.414818600982502E-02
185
"""
186
if prec > 64:
187
raise ValueError, "prec (=%s) must be at most 64"%prec
188
if prec < 1:
189
raise ValueError, "prec (=%s) must be at least 1"%prec
190
v = self('-sp %sp%sd%s %s'%(n, prec, d, self._curve_str(E)))
191
return self._fix_err(v)
192
193
def modular_degree(self, E):
194
"""
195
Return the modular degree of the elliptic curve E, assuming the
196
Stevens conjecture.
197
198
INPUT:
199
200
201
- ``E`` - elliptic curve over Q
202
203
204
OUTPUT:
205
206
207
- ``integer`` - modular degree
208
209
210
EXAMPLES: We compute the modular degrees of the lowest known
211
conductor curves of the first few ranks::
212
213
sage: sympow.modular_degree(EllipticCurve('11a'))
214
1
215
sage: sympow.modular_degree(EllipticCurve('37a'))
216
2
217
sage: sympow.modular_degree(EllipticCurve('389a'))
218
40
219
sage: sympow.modular_degree(EllipticCurve('5077a'))
220
1984
221
sage: sympow.modular_degree(EllipticCurve([1, -1, 0, -79, 289]))
222
334976
223
"""
224
v = self('%s -moddeg'%self._curve_str(E))
225
s = 'Modular Degree is '
226
i = v.find(s)
227
if i == -1:
228
print self._fix_err(v)
229
raise RuntimeError, "failed to compute modular degree"
230
return sage.rings.all.Integer(v[i+len(s):])
231
232
def analytic_rank(self, E):
233
r"""
234
Return the analytic rank and leading `L`-value of the
235
elliptic curve `E`.
236
237
INPUT:
238
239
240
- ``E`` - elliptic curve over Q
241
242
243
OUTPUT:
244
245
246
- ``integer`` - analytic rank
247
248
- ``string`` - leading coefficient (as string)
249
250
251
.. note::
252
253
The analytic rank is *not* computed provably correctly in
254
general.
255
256
.. note::
257
258
In computing the analytic rank we consider
259
`L^{(r)}(E,1)` to be `0` if
260
`L^{(r)}(E,1)/\Omega_E > 0.0001`.
261
262
EXAMPLES: We compute the analytic ranks of the lowest known
263
conductor curves of the first few ranks::
264
265
sage: sympow.analytic_rank(EllipticCurve('11a'))
266
(0, '2.53842e-01')
267
sage: sympow.analytic_rank(EllipticCurve('37a'))
268
(1, '3.06000e-01')
269
sage: sympow.analytic_rank(EllipticCurve('389a'))
270
(2, '7.59317e-01')
271
sage: sympow.analytic_rank(EllipticCurve('5077a'))
272
(3, '1.73185e+00')
273
sage: sympow.analytic_rank(EllipticCurve([1, -1, 0, -79, 289]))
274
(4, '8.94385e+00')
275
sage: sympow.analytic_rank(EllipticCurve([0, 0, 1, -79, 342])) # long time
276
(5, '3.02857e+01')
277
sage: sympow.analytic_rank(EllipticCurve([1, 1, 0, -2582, 48720])) # long time
278
(6, '3.20781e+02')
279
sage: sympow.analytic_rank(EllipticCurve([0, 0, 0, -10012, 346900])) # long time
280
(7, '1.32517e+03')
281
"""
282
v = self('%s -analrank'%self._curve_str(E))
283
s = 'Analytic Rank is '
284
i = v.rfind(s)
285
if i == -1:
286
print self._fix_err(v)
287
raise RuntimeError, "failed to compute analytic rank"
288
j = v.rfind(':')
289
r = sage.rings.all.Integer(v[i+len(s):j])
290
i = v.rfind(' ')
291
L = v[i+1:]
292
return r, L
293
294
def new_data(self, n):
295
"""
296
Pre-compute data files needed for computation of n-th symmetric
297
powers.
298
"""
299
print self('-new_data %s'%n)
300
301
def help(self):
302
h = """
303
sympow('-sp 2p16 -curve "[1,2,3,4,5]"')
304
will compute L(Sym^2 E,edge) for E=[1,2,3,4,5] to 16 digits of precision
305
The result
306
2n0: 8.370510845377639E-01
307
2w0: 8.370510845377586E-01
308
consists of two calculations using different parameters to test the
309
functional equation (to see if these are sufficiently close).
310
311
sympow('-sp 3p12d2,4p8 -curve "[1,2,3,4,5]"')
312
will compute the 0th-2nd derivatives of L(Sym^3 E,center) to 12 digits
313
and L(Sym^4 E,edge) to 8 digits
314
315
Special cases: When a curve has CM, Hecke power can be used instead
316
317
sympow('-sp 7p12d1 -hecke -curve "[0,0,1,-16758,835805]"')
318
319
will compute the 0th-1st derivatives of L(Sym^7 psi,special) to 12 digits.
320
321
Bloch-Kato numbers can be obtained for powers not congruent to 0 mod 4:
322
323
sympow('-sp 2bp16 -curve "[1,2,3,4,5]"')
324
325
should return
326
2n0: 4.640000000000006E+02
327
2w0: 4.639999999999976E+02
328
which can be seen to be very close to the integer 464.
329
330
Modular degrees can be computed with the -moddeg option.
331
332
sympow('-curve "[1,2,3,4,5]" -moddeg')
333
334
should return
335
Modular Degree is 464
336
337
Analytic ranks can be computed with the -analrank option.
338
339
sympow('-curve "[1,2,3,4,5]" -analrank')
340
341
should return
342
Analytic Rank is 1 : L'-value 3.51873e+00
343
344
and (if the mesh file for the fifth derivative is present)
345
346
sympow('-curve "[0,0,1,-79,342]" -analrank')
347
348
should return
349
Analytic Rank is 5 : leading L-term 3.02857e+01
350
351
========================================================================
352
353
Adding new symmetric powers:
354
355
SYMPOW keeps data for symmetric powers in the directory datafiles
356
If a pre-computed mesh of inverse Mellin transform values is not
357
available for a given symmetric power, SYMPOW will fail. The command
358
359
sympow('-new_data 2')
360
361
will add the data the 2nd symmetric power, while
362
363
sympow('-new_data 3d2')
364
365
will add the data for the 2nd derivative and 3rd symmetric power,
366
367
sympow('-new_data 6d0h')
368
369
will add the data for the 0th derivative of the 6th Hecke power, and
370
371
sympow('-new_data 4c')
372
373
will add data for the 4th symmetric power for curves with CM
374
(these need to be done separately for powers divisible by 4).
375
376
The mesh files are stored in binary form, and thus endian-ness is a
377
worry when moving from one platform to another.
378
379
To enable modular degree computations, the 2nd symmetric power must
380
be extant, and analytic rank requires derivatives of the 1st power.
381
382
===================================================================
383
384
Output of "!sympow -help":
385
386
-bound # an upper BOUND for how many ap to compute
387
-help print the help message and exit
388
-info [] [] only report local information for primes/sympows
389
1st argument is prime range, 2nd is sympow range
390
-local only report local information (bad primes)
391
-curve [] input a curve in [a1,a2,a3,a4,a6] form
392
-label [] label the given curve
393
-quiet turn off some messages
394
-verbose turn on some messages
395
-rootno # compute the root number of the #th symmetric power
396
-moddeg compute the modular degree
397
-analrank compute the analytic rank
398
-sloppy [] for use with -analrank; have X sloppy digits
399
-nocm abort if curve has complex multiplication
400
-noqt ignore even powers of non-minimal quad twists
401
-hecke compute Hecke symmetric powers for a CM curve
402
-maxtable set the max size of factor tables: 2^27 default
403
-sp [] argument to specify which powers
404
this is a comma separated list
405
in each entry, the 1st datum is the sympow
406
then could come b which turns Bloch-Kato on
407
then could come w# which specifies how many tests
408
then could come s# which says # sloppy digits
409
then must come p# which specifies the precision
410
or P# which says ignore BOUND for this power
411
then must come d# which says the derivative bound
412
or D# which says do only this derivative
413
(neither need be indicated for even powers)
414
default is 2w3s1p32,3bp16d1,4p8
415
-new_data [] will compute inverse Mellin transform mesh for
416
the given data: the format is [sp]d[dv]{h,c}
417
sp is the symmetric power, dv is the derivative,
418
h indicates Hecke powers, and c indicates CM case
419
d[dv] is given only for odd or Hecke powers
420
Examples: 1d3 2 2d1h 3d2 4 4c 5d0 6 7d0h 11d1 12c
421
NOTE: new_data runs a shell script that uses GP
422
Other options are used internally/recursively by -new_data
423
"""
424
pager()(h)
425
426
427
428
429
# An instance
430
sympow = Sympow()
431
432
433
434