Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AndrewVSutherland
GitHub Repository: AndrewVSutherland/lmfdb
Path: blob/main/scripts/lfunctions/build_Lfunction_db.py
1128 views
1
2
import sys
3
4
from sage.all import DirichletGroup
5
from sage.all import CC, EllipticCurve, sqrt
6
7
import sage.libs.lcalc.lcalc_Lfunction as lc
8
9
from lmfdb import base
10
C = base.getDBConnection()
11
12
Lfunctions = C.test.Lfunctions_test2
13
14
15
def remove_all():
16
Lfunctions.drop()
17
18
19
def insert_dirichlet_L_functions(start, end):
20
print("Putting Dirichlet L-functions into database.")
21
start = max(3, start)
22
for q in range(start, end):
23
print("Working on modulus", q)
24
sys.stdout.flush()
25
G = DirichletGroup(q)
26
for n in range(len(G)):
27
chi = G[n]
28
if chi.is_primitive():
29
L = lc.Lfunction_from_character(chi)
30
z = L.find_zeros_via_N(1)[0]
31
Lfunction_data = {}
32
Lfunction_data['first_zero'] = float(z)
33
Lfunction_data['description'] = "Dirichlet L-function for character number " + \
34
str(n) + " modulo " + str(q)
35
Lfunction_data['degree'] = 1
36
Lfunction_data['signature'] = (1, 0)
37
if chi.is_odd():
38
Lfunction_data['mu'] = [(1.0, 0.0), ]
39
else:
40
Lfunction_data['mu'] = [(0.0, 0.0), ]
41
42
Lfunction_data['level'] = q
43
44
coeffs = []
45
46
for k in range(0, 10):
47
coeffs.append(CC(chi(k)))
48
49
Lfunction_data['coeffs'] = [(float(x.real()), float(x.imag())) for x in coeffs]
50
Lfunction_data['special'] = {'type': 'dirichlet', 'modulus': q, 'number': n}
51
52
Lfunctions.insert(Lfunction_data)
53
54
55
def update_entries():
56
# one time function to run to update everything in the database with an extra tag
57
everything = Lfunctions.find()
58
for L in everything:
59
if L['description'].startswith("Dirichlet"):
60
n, q = L['description'][42:].split(" modulo ")
61
# print n, q
62
n = int(n)
63
q = int(q)
64
L['special'] = {'type': 'dirichlet', 'modulus': q, 'number': n}
65
Lfunctions.save(L)
66
elif L['description'].startswith("Elliptic"):
67
label = L['description'][36:]
68
L['special'] = {'type': 'elliptic', 'label': label}
69
Lfunctions.save(L)
70
71
72
def insert_EC_L_functions(start=1, end=100):
73
curves = C.ellcurves.curves
74
for N in range(start, end):
75
print("Processing conductor", N)
76
sys.stdout.flush()
77
query = curves.find({'conductor': N, 'number': 1})
78
for curve in query:
79
E = EllipticCurve([int(x) for x in curve['ainvs']])
80
L = lc.Lfunction_from_elliptic_curve(E)
81
first_zeros = L.find_zeros_via_N(curve['rank'] + 1)
82
if len(first_zeros) > 1:
83
if not first_zeros[-2] == 0:
84
print("problem")
85
86
z = float(first_zeros[-1])
87
88
Lfunction_data = {}
89
Lfunction_data['first_zero'] = z
90
Lfunction_data['description'] = 'Elliptic curve L-function for curve ' + str(curve['label'][:-1])
91
Lfunction_data['degree'] = 2
92
Lfunction_data['signature'] = [0, 1]
93
Lfunction_data['eta'] = [(1.0, 0), ]
94
95
Lfunction_data['level'] = N
96
Lfunction_data['special'] = {'type': 'elliptic', 'label': curve['label'][:-1]}
97
98
coeffs = []
99
100
for k in range(1, 11):
101
coeffs.append(CC(E.an(k) / sqrt(k)))
102
103
Lfunction_data['coeffs'] = [(float(x.real()), float(x.imag())) for x in coeffs]
104
105
Lfunctions.insert(Lfunction_data)
106
107
108
def build_indices():
109
Lfunctions.create_index("first_zero")
110
Lfunctions.create_index("level")
111
Lfunctions.create_index("degree")
112
113
114
if __name__ == "__main__":
115
# build_indices()
116
# remove_all()
117
for n in range(1, 10):
118
insert_EC_L_functions(n * 100, (n + 1) * 100)
119
# insert_dirichlet_L_functions(n * 100, (n+1)*100)
120
# insert_dirichlet_L_functions(50)
121
122