CoCalc Shared Filescode / dokchitser.sagews
Authors: Jennifer Balakrishnan, Alex Best, Maarten Derickx, Masato Kuwata, James Rickards, Harald Schilly, William A. Stein, Andrew Sutherland, Nicholas Triantafillou, Isabel Vogt, and 1 more author...

Tim Dokchitser's $L$-functions code is in Sage:

http://doc.sagemath.org/html/en/reference/lfunctions/sage/lfunctions/dokchitser.html

more examples here: https://people.maths.bris.ac.uk/~matyd/computel/

some examples of doing Dokchitser by hand and guessing at Euler factors https://magma.maths.usyd.edu.au/magma/handbook/text/1523

%md
http://wstein.org/papers/sqrt5/tables/

%md
https://trac.sagemath.org/ticket/12015









L = Dokchitser(conductor=1, gammaV=[0,1], weight=12, eps=1)

pari_precode = 'tau(n)=(5*sigma(n,3)+7*sigma(n,5))*n/12 - 35*sum(k=1,n-1,(6*k-4*(n-k))*sigma(k,3)*sigma(n-k,5))'

L.init_coeffs?

%time L.init_coeffs('tau(k)', pari_precode=pari_precode)

CPU time: 0.00 s, Wall time: 0.02 s
L.num_coeffs()
L.set_coeff_growth('2*n^(11/2)')
L.num_coeffs()

12 11
print L(1)
print L(1, 1.1)
print L.taylor_series(1,3)

0.0374412812685155 0.0374412812685155 0.0374412812685155 + 0.0709221123619322*z + 0.0380744761270520*z^2 + O(z^3)
def aps(E, n):
K = E.base_field()
ap_list = []
for p in K.primes_of_bounded_norm_iter(n):
Ep = E.change_ring(K.residue_field(p))
ap_list += [(p.norm(), p.norm() + 1 - Ep.count_points())]
return ap_list













































































































































































































d = 4
fact = [prime for (prime, i) in m.factor()]
rootlist = [2,1,1,1]

def chip(pri):
return CC(chi(fact,rootlist,d)(pri.gens_reduced()[0]))

li = []
li2 = []
for p in prime_range(2000):
for q in K.primes_above(p):
if K.ideal(p).is_prime():
li += [chip(q).argument()]
else:
li2 += [chip(q).argument()]
histogram(li)
histogram(li2)


def rep(alpha, primes):
vals = []
for p in primes:
vals += [p.ideallog(alpha)[0]]
return vals

class NFChar():
def __init__(self, factored_conductor, rootlist, order, zeta = None):
self._factored_conductor = factored_conductor
self._rootlist = rootlist
assert gcd(rootlist+[d])==1, "the order of the character is not %s"%(order)
self._order = order
if zeta is None:
self._zeta = CC.zeta(d)
else:
#assert zeta**d==1
self._zeta = zeta

K = factored_conductor[0].number_field()

for g in K.unit_group().gens():
assert self._call_nf_elt(K(g)) == 1, " character is not 1 on units"

def __call__(self, p):
assert p.is_principal()
return self._call_nf_elt(p.gens_reduced()[0])

def _call_nf_elt(self,alpha):
fact = self._factored_conductor
rootlist = self._rootlist

for prime in fact:
if alpha in prime:
return 0
#return m.ideallog(p.gens_reduced()[0])
reps = rep(alpha, [prime for prime in fact])

return self._zeta**(sum([rootlist[i]*reps[i] for i in range(len(rootlist))]) % self._order)

def is_primitive(self):
return all(i%self._order != 0 for i in self._rootlist)

def conductor(self):
return prod(self._factored_conductor).norm()

def order(self):
return self._order

K.<phi>=NumberField(x^2 -x-1)
E = EllipticCurve(K, [1, phi + 1, phi, phi, 0])
m = K.prime_above(13)#*K.prime_above(3) #* K.prime_above(13) * K.prime_above(5) * K.prime_above(23)
d = 2
fact = [prime for (prime, i) in m.factor()]


rootlist = [2,3,1,1]
Chi = NFChar(fact,rootlist,d); Chi

<__builtin__.NFChar instance at 0x7fd031e230e0>


︠485a7d7d-91a9-46dd-9bfb-51c46c6241e0︠


foundlist = d*[1]
for t in Integers(d)^len(m.factor()):
try:
if 0 in list(t):
continue
rootlist = list(t.lift())
chi = NFChar(fact,rootlist,d)
foundlist = rootlist

print rootlist
except:
pass

[1]




from psage.eulerprod import LSeriesEllipticCurve, LSeriesEllipticCurveSqrt5, LSeriesTwist

Error compiling Cython file: ------------------------------------------------------------ ... AUTHOR: - William Stein """ include "stdsage.pxi" ^ ------------------------------------------------------------ psage/number_fields/sqrt5/prime.pyx:47:0: 'stdsage.pxi' not found Error compiling Cython file: ------------------------------------------------------------ ... - William Stein """ include "stdsage.pxi" include "interrupt.pxi" ^ ------------------------------------------------------------ psage/number_fields/sqrt5/prime.pyx:48:0: 'interrupt.pxi' not found Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 995, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "psage/eulerprod.py", line 50, in <module> from number_fields.sqrt5.prime import primes_of_bounded_norm, Prime File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 445, in load_module language_level=self.language_level) File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 234, in load_module exec("raise exc, None, tb", {'exc': exc, 'tb': tb}) File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 216, in load_module inplace=build_inplace, language_level=language_level) File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 192, in build_module reload_support=pyxargs.reload_support) File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/pyximport/pyxbuild.py", line 102, in pyx_to_dll dist.run_commands() File "/projects/sage/sage-7.5/local/lib/python/distutils/dist.py", line 953, in run_commands self.run_command(cmd) File "/projects/sage/sage-7.5/local/lib/python/distutils/dist.py", line 972, in run_command cmd_obj.run() File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run _build_ext.build_ext.run(self) File "/projects/sage/sage-7.5/local/lib/python/distutils/command/build_ext.py", line 340, in run self.build_extensions() File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/Cython/Distutils/old_build_ext.py", line 193, in build_extensions self.build_extension(ext) File "/projects/sage/sage-7.5/local/lib/python/distutils/command/build_ext.py", line 499, in build_extension depends=ext.depends) File "/projects/sage/sage-7.5/local/lib/python/distutils/ccompiler.py", line 574, in compile self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) File "/projects/sage/sage-7.5/local/lib/python/distutils/unixccompiler.py", line 126, in _compile raise CompileError, msg ImportError: Building module psage.number_fields.sqrt5.prime failed: ["CompileError: command 'gcc' failed with exit status 1\n"]


newchi = NFChar(fact, foundlist, d)
newchi(K.prime_above(2))
L = LSeriesEllipticCurveSqrt5(E)
print "done1"
LEchi =  LSeriesTwist(L, newchi, epsilon='solve', conductor=ZZ(5^2*E.conductor().norm()*(newchi.conductor()^2)))
print E.conductor().norm()
print newchi.conductor()
LEchi
print "done2"

1.00000000000000 done1 31 169 Twist of L-series of Elliptic Curve defined by y^2 + x*y + phi*y = x^3 + (phi+1)*x^2 + phi*x over Number Field in phi with defining polynomial x^2 - x - 1 by <__builtin__.NFChar instance at 0x7fcfe5d7f440> done2
LEchi.anlist(100)
L.conductor()
L.epsilon()
L.number_of_coefficients(2)
L.degree()
L.hodge_numbers()
L(3/2)
LEchi.number_of_coefficients(5)
LEchi.degree()
LEchi.hodge_numbers()
LEchi(ComplexField(5)(3/2))

Error compiling Cython file: ------------------------------------------------------------ ... AUTHOR: - William Stein """ include "stdsage.pxi" ^ ------------------------------------------------------------ prime.pyx:47:0: 'stdsage.pxi' not found Error compiling Cython file: ------------------------------------------------------------ ... - William Stein """ include "stdsage.pxi" include "interrupt.pxi" ^ ------------------------------------------------------------ prime.pyx:48:0: 'interrupt.pxi' not found Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 995, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "psage/eulerprod.py", line 1183, in anlist if norm(P) <= bound: File "psage/eulerprod.py", line 2498, in _local_factor L0 = self._L.local_factor(P, prec) File "sage/misc/cachefunc.pyx", line 2038, in sage.misc.cachefunc.CachedMethodCaller.__call__ (/projects/sage/sage-7.5/src/build/cythonized/sage/misc/cachefunc.c:10792) w = self._instance_call(*args, **kwds) File "sage/misc/cachefunc.pyx", line 1914, in sage.misc.cachefunc.CachedMethodCaller._instance_call (/projects/sage/sage-7.5/src/build/cythonized/sage/misc/cachefunc.c:10238) return self.f(self._instance, *args, **kwds) File "psage/eulerprod.py", line 1034, in local_factor """ File "psage/eulerprod.py", line 1983, in _local_factor def _local_factor(self, P, prec): File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 445, in load_module language_level=self.language_level) File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 234, in load_module exec("raise exc, None, tb", {'exc': exc, 'tb': tb}) File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 216, in load_module inplace=build_inplace, language_level=language_level) File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/pyximport/pyximport.py", line 192, in build_module reload_support=pyxargs.reload_support) File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/pyximport/pyxbuild.py", line 102, in pyx_to_dll dist.run_commands() File "/projects/sage/sage-7.5/local/lib/python/distutils/dist.py", line 953, in run_commands self.run_command(cmd) File "/projects/sage/sage-7.5/local/lib/python/distutils/dist.py", line 972, in run_command cmd_obj.run() File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run _build_ext.build_ext.run(self) File "/projects/sage/sage-7.5/local/lib/python/distutils/command/build_ext.py", line 340, in run self.build_extensions() File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/Cython/Distutils/old_build_ext.py", line 193, in build_extensions self.build_extension(ext) File "/projects/sage/sage-7.5/local/lib/python/distutils/command/build_ext.py", line 499, in build_extension depends=ext.depends) File "/projects/sage/sage-7.5/local/lib/python/distutils/ccompiler.py", line 574, in compile self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) File "/projects/sage/sage-7.5/local/lib/python/distutils/unixccompiler.py", line 126, in _compile raise CompileError, msg ImportError: Building module prime failed: ["CompileError: command 'gcc' failed with exit status 1\n"]
%timeit(number=1,repeat=1) L.anlist(100)

1 loops, best of 1: 1.63 s per loop
%timeit(number=1,repeat=1) L.anlist(200)

1 loops, best of 1: 2.3 s per loop
%timeit(number=1,repeat=1) L.anlist(300)


1 loops, best of 1: 1.93 s per loop
%timeit(number=1,repeat=1) LEchi.anlist(300)

1 loops, best of 1: 336 ms per loop
LSeriesEllipticCurve(EllipticCurve('389a'))(10)

Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 995, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "./eulerprod.py", line 1295, in __call__ return self._function(prec(s))(s) File "sage/misc/cachefunc.pyx", line 2038, in sage.misc.cachefunc.CachedMethodCaller.__call__ (/projects/sage/sage-7.5/src/build/cythonized/sage/misc/cachefunc.c:10792) w = self._instance_call(*args, **kwds) File "sage/misc/cachefunc.pyx", line 1914, in sage.misc.cachefunc.CachedMethodCaller._instance_call (/projects/sage/sage-7.5/src/build/cythonized/sage/misc/cachefunc.c:10238) return self.f(self._instance, *args, **kwds) File "./eulerprod.py", line 1405, in _function return self._dokchitser(prec, eps, T=T) File "./eulerprod.py", line 1450, in _dokchitser X = self.anlist(n, prec) File "./eulerprod.py", line 1186, in anlist coefficients = list(coefficients)[0] File "./eulerprod.py", line 1228, in _compute_anlist extend_multiplicatively_generic(coefficients) NameError: global name 'extend_multiplicatively_generic' is not defined
E.

EllipticCurve_from_j(1).quadratic_twist(5).conductor().factor()

5^2 * 11^2 * 157^2
L(2)

Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-7.5/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 995, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "./eulerprod.py", line 1295, in __call__ return self._function(prec(s))(s) File "sage/misc/cachefunc.pyx", line 2038, in sage.misc.cachefunc.CachedMethodCaller.__call__ (/projects/sage/sage-7.5/src/build/cythonized/sage/misc/cachefunc.c:10792) w = self._instance_call(*args, **kwds) File "sage/misc/cachefunc.pyx", line 1914, in sage.misc.cachefunc.CachedMethodCaller._instance_call (/projects/sage/sage-7.5/src/build/cythonized/sage/misc/cachefunc.c:10238) return self.f(self._instance, *args, **kwds) File "./eulerprod.py", line 1405, in _function return self._dokchitser(prec, eps, T=T) File "./eulerprod.py", line 1450, in _dokchitser X = self.anlist(n, prec) File "./eulerprod.py", line 1171, in anlist self._precompute_local_factors(bound+1, prec=prec) File "./eulerprod.py", line 1932, in _precompute_local_factors from psage.number_fields.sqrt5.prime import primes_of_bounded_norm, Prime ImportError: No module named psage.number_fields.sqrt5.prime
LSeriesEllipticCurve?


File:
Signature : LSeriesEllipticCurve(self, s)
Docstring :
EXAMPLES::
sage: from psage.lseries.eulerprod import LSeriesEllipticCurve
sage: L = LSeriesEllipticCurve(EllipticCurve('389a')) sage: L(2)
0.360092863578881