Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/lfunctions/sympow.py
8817 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
These examples only work if you run ``sympow -new_data 2`` in a
128
Sage shell first. Alternatively, within Sage, execute::
129
130
sage: sympow('-new_data 2') # not tested
131
132
This command precomputes some data needed for the following
133
examples. ::
134
135
sage: a = sympow.L(EllipticCurve('11a'), 2, 16) # not tested
136
sage: a # not tested
137
'1.057599244590958E+00'
138
sage: RR(a) # not tested
139
1.05759924459096
140
"""
141
if n % 2 == 1:
142
raise ValueError, "n (=%s) must be even"%n
143
if prec > 64:
144
raise ValueError, "prec (=%s) must be at most 64"%prec
145
if prec < 1:
146
raise ValueError, "prec (=%s) must be at least 1"%prec
147
v = self('-sp %sp%s %s'%(n, prec, self._curve_str(E)))
148
i = v.rfind(': ')
149
if i == -1:
150
print self._fix_err(v)
151
raise RuntimeError, "failed to compute symmetric power"
152
x = v[i+2:]
153
return x
154
155
156
def Lderivs(self, E, n, prec, d):
157
r"""
158
Return `0^{th}` to `d^{th}` derivatives of
159
`L(\mathrm{Sym}^{(n)}(E,s)` to prec digits of precision, where
160
`s` is the right edge if `n` is even and the center
161
if `n` is odd.
162
163
INPUT:
164
165
166
- ``E`` - elliptic curve
167
168
- ``n`` - integer (even or odd)
169
170
- ``prec`` - integer
171
172
- ``d`` - integer
173
174
175
OUTPUT: a string, exactly as output by sympow
176
177
.. note::
178
179
To use this function you may have to run a few commands
180
like ``sympow('-new_data 1d2')``, each which takes a
181
few minutes. If this function fails it will indicate what commands
182
have to be run.
183
184
EXAMPLES::
185
186
sage: print sympow.Lderivs(EllipticCurve('11a'), 1, 16, 2) # not tested
187
...
188
1n0: 2.538418608559107E-01
189
1w0: 2.538418608559108E-01
190
1n1: 1.032321840884568E-01
191
1w1: 1.059251499158892E-01
192
1n2: 3.238743180659171E-02
193
1w2: 3.414818600982502E-02
194
"""
195
if prec > 64:
196
raise ValueError, "prec (=%s) must be at most 64"%prec
197
if prec < 1:
198
raise ValueError, "prec (=%s) must be at least 1"%prec
199
v = self('-sp %sp%sd%s %s'%(n, prec, d, self._curve_str(E)))
200
return self._fix_err(v)
201
202
def modular_degree(self, E):
203
"""
204
Return the modular degree of the elliptic curve E, assuming the
205
Stevens conjecture.
206
207
INPUT:
208
209
210
- ``E`` - elliptic curve over Q
211
212
213
OUTPUT:
214
215
216
- ``integer`` - modular degree
217
218
219
EXAMPLES: We compute the modular degrees of the lowest known
220
conductor curves of the first few ranks::
221
222
sage: sympow.modular_degree(EllipticCurve('11a'))
223
1
224
sage: sympow.modular_degree(EllipticCurve('37a'))
225
2
226
sage: sympow.modular_degree(EllipticCurve('389a'))
227
40
228
sage: sympow.modular_degree(EllipticCurve('5077a'))
229
1984
230
sage: sympow.modular_degree(EllipticCurve([1, -1, 0, -79, 289]))
231
334976
232
"""
233
v = self('%s -moddeg'%self._curve_str(E))
234
s = 'Modular Degree is '
235
i = v.find(s)
236
if i == -1:
237
print self._fix_err(v)
238
raise RuntimeError, "failed to compute modular degree"
239
return sage.rings.all.Integer(v[i+len(s):])
240
241
def analytic_rank(self, E):
242
r"""
243
Return the analytic rank and leading `L`-value of the
244
elliptic curve `E`.
245
246
INPUT:
247
248
249
- ``E`` - elliptic curve over Q
250
251
252
OUTPUT:
253
254
255
- ``integer`` - analytic rank
256
257
- ``string`` - leading coefficient (as string)
258
259
260
.. note::
261
262
The analytic rank is *not* computed provably correctly in
263
general.
264
265
.. note::
266
267
In computing the analytic rank we consider
268
`L^{(r)}(E,1)` to be `0` if
269
`L^{(r)}(E,1)/\Omega_E > 0.0001`.
270
271
EXAMPLES: We compute the analytic ranks of the lowest known
272
conductor curves of the first few ranks::
273
274
sage: sympow.analytic_rank(EllipticCurve('11a'))
275
(0, '2.53842e-01')
276
sage: sympow.analytic_rank(EllipticCurve('37a'))
277
(1, '3.06000e-01')
278
sage: sympow.analytic_rank(EllipticCurve('389a'))
279
(2, '7.59317e-01')
280
sage: sympow.analytic_rank(EllipticCurve('5077a'))
281
(3, '1.73185e+00')
282
sage: sympow.analytic_rank(EllipticCurve([1, -1, 0, -79, 289]))
283
(4, '8.94385e+00')
284
sage: sympow.analytic_rank(EllipticCurve([0, 0, 1, -79, 342])) # long time
285
(5, '3.02857e+01')
286
sage: sympow.analytic_rank(EllipticCurve([1, 1, 0, -2582, 48720])) # long time
287
(6, '3.20781e+02')
288
sage: sympow.analytic_rank(EllipticCurve([0, 0, 0, -10012, 346900])) # long time
289
(7, '1.32517e+03')
290
"""
291
v = self('%s -analrank'%self._curve_str(E))
292
s = 'Analytic Rank is '
293
i = v.rfind(s)
294
if i == -1:
295
print self._fix_err(v)
296
raise RuntimeError, "failed to compute analytic rank"
297
j = v.rfind(':')
298
r = sage.rings.all.Integer(v[i+len(s):j])
299
i = v.rfind(' ')
300
L = v[i+1:]
301
return r, L
302
303
def new_data(self, n):
304
"""
305
Pre-compute data files needed for computation of n-th symmetric
306
powers.
307
"""
308
print self('-new_data %s'%n)
309
310
def help(self):
311
h = """
312
sympow('-sp 2p16 -curve "[1,2,3,4,5]"')
313
will compute L(Sym^2 E,edge) for E=[1,2,3,4,5] to 16 digits of precision
314
The result
315
2n0: 8.370510845377639E-01
316
2w0: 8.370510845377586E-01
317
consists of two calculations using different parameters to test the
318
functional equation (to see if these are sufficiently close).
319
320
sympow('-sp 3p12d2,4p8 -curve "[1,2,3,4,5]"')
321
will compute the 0th-2nd derivatives of L(Sym^3 E,center) to 12 digits
322
and L(Sym^4 E,edge) to 8 digits
323
324
Special cases: When a curve has CM, Hecke power can be used instead
325
326
sympow('-sp 7p12d1 -hecke -curve "[0,0,1,-16758,835805]"')
327
328
will compute the 0th-1st derivatives of L(Sym^7 psi,special) to 12 digits.
329
330
Bloch-Kato numbers can be obtained for powers not congruent to 0 mod 4:
331
332
sympow('-sp 2bp16 -curve "[1,2,3,4,5]"')
333
334
should return
335
2n0: 4.640000000000006E+02
336
2w0: 4.639999999999976E+02
337
which can be seen to be very close to the integer 464.
338
339
Modular degrees can be computed with the -moddeg option.
340
341
sympow('-curve "[1,2,3,4,5]" -moddeg')
342
343
should return
344
Modular Degree is 464
345
346
Analytic ranks can be computed with the -analrank option.
347
348
sympow('-curve "[1,2,3,4,5]" -analrank')
349
350
should return
351
Analytic Rank is 1 : L'-value 3.51873e+00
352
353
and (if the mesh file for the fifth derivative is present)
354
355
sympow('-curve "[0,0,1,-79,342]" -analrank')
356
357
should return
358
Analytic Rank is 5 : leading L-term 3.02857e+01
359
360
========================================================================
361
362
Adding new symmetric powers:
363
364
SYMPOW keeps data for symmetric powers in the directory datafiles
365
If a pre-computed mesh of inverse Mellin transform values is not
366
available for a given symmetric power, SYMPOW will fail. The command
367
368
sympow('-new_data 2')
369
370
will add the data the 2nd symmetric power, while
371
372
sympow('-new_data 3d2')
373
374
will add the data for the 2nd derivative and 3rd symmetric power,
375
376
sympow('-new_data 6d0h')
377
378
will add the data for the 0th derivative of the 6th Hecke power, and
379
380
sympow('-new_data 4c')
381
382
will add data for the 4th symmetric power for curves with CM
383
(these need to be done separately for powers divisible by 4).
384
385
The mesh files are stored in binary form, and thus endian-ness is a
386
worry when moving from one platform to another.
387
388
To enable modular degree computations, the 2nd symmetric power must
389
be extant, and analytic rank requires derivatives of the 1st power.
390
391
===================================================================
392
393
Output of "!sympow -help":
394
395
-bound # an upper BOUND for how many ap to compute
396
-help print the help message and exit
397
-info [] [] only report local information for primes/sympows
398
1st argument is prime range, 2nd is sympow range
399
-local only report local information (bad primes)
400
-curve [] input a curve in [a1,a2,a3,a4,a6] form
401
-label [] label the given curve
402
-quiet turn off some messages
403
-verbose turn on some messages
404
-rootno # compute the root number of the #th symmetric power
405
-moddeg compute the modular degree
406
-analrank compute the analytic rank
407
-sloppy [] for use with -analrank; have X sloppy digits
408
-nocm abort if curve has complex multiplication
409
-noqt ignore even powers of non-minimal quad twists
410
-hecke compute Hecke symmetric powers for a CM curve
411
-maxtable set the max size of factor tables: 2^27 default
412
-sp [] argument to specify which powers
413
this is a comma separated list
414
in each entry, the 1st datum is the sympow
415
then could come b which turns Bloch-Kato on
416
then could come w# which specifies how many tests
417
then could come s# which says # sloppy digits
418
then must come p# which specifies the precision
419
or P# which says ignore BOUND for this power
420
then must come d# which says the derivative bound
421
or D# which says do only this derivative
422
(neither need be indicated for even powers)
423
default is 2w3s1p32,3bp16d1,4p8
424
-new_data [] will compute inverse Mellin transform mesh for
425
the given data: the format is [sp]d[dv]{h,c}
426
sp is the symmetric power, dv is the derivative,
427
h indicates Hecke powers, and c indicates CM case
428
d[dv] is given only for odd or Hecke powers
429
Examples: 1d3 2 2d1h 3d2 4 4c 5d0 6 7d0h 11d1 12c
430
NOTE: new_data runs a shell script that uses GP
431
Other options are used internally/recursively by -new_data
432
"""
433
pager()(h)
434
435
436
437
438
# An instance
439
sympow = Sympow()
440
441
442
443