Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
AndrewVSutherland
GitHub Repository: AndrewVSutherland/lmfdb
Path: blob/main/scripts/artin_representations/extract_art.py
1128 views
1
# This is for generating information for computing Artin L-functions
2
# Run it with
3
# sage -python extract_art.py artinlabel count
4
#
5
# where artinlabel is the label for a specific artin representation
6
# and count is a positive integer. It will produce a file with the
7
# same name as the label containing:
8
# n
9
# list of encoded polynomials
10
# "count" more lines containing positive integers
11
#
12
# Here, n = a field where we factored the local factor, Q(\zeta_n)
13
# Each polynomial is encoded as [a_1, a_2, ..., a_m] to mean the
14
# reciprocal roots are \zeta_n^a_i=e(a_i/n)
15
# On the remaining lines, the value is an index back into the list
16
# of polynomials so that if the j-th of these lines is k, then
17
# the local factor of the j-th prime is the k-th polynomial
18
19
20
import sys, time, os
21
assert time
22
23
# check arguments first
24
25
if len(sys.argv) != 3:
26
print("I take two arguments, the label and a count")
27
print("Don't make me tell you again.")
28
sys.exit()
29
30
argv=sys.argv
31
label=argv[1]
32
33
# internally, we will call the count "bound"
34
try:
35
bound=int(argv[2])
36
if bound is None or bound<1:
37
print("Bound is not valid")
38
sys.exit()
39
except Exception:
40
print("Bound is not valid")
41
sys.exit()
42
43
import re
44
assert re
45
from sage.all import next_prime, ZZ, QQ, lcm, NumberField
46
47
# find lmfdb and the top of the tree
48
mypath = os.path.realpath(__file__)
49
while os.path.basename(mypath) != 'lmfdb':
50
mypath = os.path.dirname(mypath)
51
# now move up one more time...
52
mypath = os.path.dirname(mypath)
53
sys.path.append(mypath)
54
55
# load the password file
56
import yaml
57
pw_dict = yaml.load(open(os.path.join(mypath, "passwords.yaml")))
58
username = pw_dict['data']['username']
59
password = pw_dict['data']['password']
60
61
# fire it up
62
from lmfdb import base
63
assert base
64
from lmfdb.artin_representations.math_classes import ArtinRepresentation
65
66
from pymongo.mongo_client import MongoClient
67
C= MongoClient(host='lmfdb-ib:37010')
68
C['artin'].authenticate(username, password)
69
70
art=C.artin
71
rep=art.representations
72
nfgal=art.field_data
73
74
#utilities
75
76
# turn poly coefs into a string
77
def makels(li):
78
li2 = [str(x) for x in li]
79
return ','.join(li2)
80
81
def myroots(pol, n, zeta):
82
rts=[]
83
j=0
84
RR = pol.parent()
85
while pol.degree()>0 and j<n:
86
if pol(zeta**j)==0:
87
rts.append((n-j) % n)
88
pol = RR(pol/(y-zeta**j))
89
else:
90
j += 1
91
return rts
92
93
94
# select the ones we want
95
#artargs = {'Dim': {'$gte': 2, '$lte': 9}}
96
#allarts=rep.find(artargs)
97
98
#arep = rep.find_one({'Dim': {'$gte': 2}})
99
#ar = ArtinRepresentation(str(arep['Baselabel'])+'c1')
100
#ar = ArtinRepresentation('2.2e3_3e2.6t5.1c1')
101
102
baselabel=label.split('c')
103
a = rep.find_one({'Baselabel': baselabel[0]})
104
105
106
ar=ArtinRepresentation(label)
107
108
outfile=open(label, 'w')
109
110
cf=a['CharacterField']
111
cfz = ZZ(cf)
112
nf = ar.nf()
113
nfcc = nf.conjugacy_classes()
114
nfcc = [int(z.order()) for z in nfcc]
115
nfcc = lcm(nfcc)
116
if not cfz.divides(nfcc):
117
print("Failure "+str(cfz)+" divides "+str(nfcc)+" from "+label)
118
sys.exit()
119
R,x = QQ['x'].objgen()
120
pol1 = R.cyclotomic_polynomial(nfcc)
121
K,z=NumberField(R.cyclotomic_polynomial(nfcc),'z').objgen()
122
RR,y = K['y'].objgen()
123
zsmall = z**(nfcc/cfz)
124
allpols = [sum(y**k * sum(pp[k][j] * zsmall**j for j in range(len(pp[k]))) for k in range(len(pp))) for pp in ar.local_factors_table()]
125
allroots = [myroots(pp, nfcc, z) for pp in allpols]
126
127
outfile.write(str(nfcc)+"\n")
128
outfile.write(str(allroots)+"\n")
129
j=0
130
p=1
131
while j<bound:
132
p = next_prime(p)
133
outfile.write(str(ar.any_prime_to_cc_index(p))+"\n")
134
j+=1
135
136
#plist = [ar.any_prime_to_cc_index(p) for p in primes_first_n(bound)]
137
#for j in plist:
138
# outfile.write(str(j)+"\n")
139
140
outfile.close()
141
142