Path: blob/main/scripts/artin_representations/extract_art.py
1128 views
# This is for generating information for computing Artin L-functions1# Run it with2# sage -python extract_art.py artinlabel count3#4# where artinlabel is the label for a specific artin representation5# and count is a positive integer. It will produce a file with the6# same name as the label containing:7# n8# list of encoded polynomials9# "count" more lines containing positive integers10#11# Here, n = a field where we factored the local factor, Q(\zeta_n)12# Each polynomial is encoded as [a_1, a_2, ..., a_m] to mean the13# reciprocal roots are \zeta_n^a_i=e(a_i/n)14# On the remaining lines, the value is an index back into the list15# of polynomials so that if the j-th of these lines is k, then16# the local factor of the j-th prime is the k-th polynomial171819import sys, time, os20assert time2122# check arguments first2324if len(sys.argv) != 3:25print("I take two arguments, the label and a count")26print("Don't make me tell you again.")27sys.exit()2829argv=sys.argv30label=argv[1]3132# internally, we will call the count "bound"33try:34bound=int(argv[2])35if bound is None or bound<1:36print("Bound is not valid")37sys.exit()38except Exception:39print("Bound is not valid")40sys.exit()4142import re43assert re44from sage.all import next_prime, ZZ, QQ, lcm, NumberField4546# find lmfdb and the top of the tree47mypath = os.path.realpath(__file__)48while os.path.basename(mypath) != 'lmfdb':49mypath = os.path.dirname(mypath)50# now move up one more time...51mypath = os.path.dirname(mypath)52sys.path.append(mypath)5354# load the password file55import yaml56pw_dict = yaml.load(open(os.path.join(mypath, "passwords.yaml")))57username = pw_dict['data']['username']58password = pw_dict['data']['password']5960# fire it up61from lmfdb import base62assert base63from lmfdb.artin_representations.math_classes import ArtinRepresentation6465from pymongo.mongo_client import MongoClient66C= MongoClient(host='lmfdb-ib:37010')67C['artin'].authenticate(username, password)6869art=C.artin70rep=art.representations71nfgal=art.field_data7273#utilities7475# turn poly coefs into a string76def makels(li):77li2 = [str(x) for x in li]78return ','.join(li2)7980def myroots(pol, n, zeta):81rts=[]82j=083RR = pol.parent()84while pol.degree()>0 and j<n:85if pol(zeta**j)==0:86rts.append((n-j) % n)87pol = RR(pol/(y-zeta**j))88else:89j += 190return rts919293# select the ones we want94#artargs = {'Dim': {'$gte': 2, '$lte': 9}}95#allarts=rep.find(artargs)9697#arep = rep.find_one({'Dim': {'$gte': 2}})98#ar = ArtinRepresentation(str(arep['Baselabel'])+'c1')99#ar = ArtinRepresentation('2.2e3_3e2.6t5.1c1')100101baselabel=label.split('c')102a = rep.find_one({'Baselabel': baselabel[0]})103104105ar=ArtinRepresentation(label)106107outfile=open(label, 'w')108109cf=a['CharacterField']110cfz = ZZ(cf)111nf = ar.nf()112nfcc = nf.conjugacy_classes()113nfcc = [int(z.order()) for z in nfcc]114nfcc = lcm(nfcc)115if not cfz.divides(nfcc):116print("Failure "+str(cfz)+" divides "+str(nfcc)+" from "+label)117sys.exit()118R,x = QQ['x'].objgen()119pol1 = R.cyclotomic_polynomial(nfcc)120K,z=NumberField(R.cyclotomic_polynomial(nfcc),'z').objgen()121RR,y = K['y'].objgen()122zsmall = z**(nfcc/cfz)123allpols = [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()]124allroots = [myroots(pp, nfcc, z) for pp in allpols]125126outfile.write(str(nfcc)+"\n")127outfile.write(str(allroots)+"\n")128j=0129p=1130while j<bound:131p = next_prime(p)132outfile.write(str(ar.any_prime_to_cc_index(p))+"\n")133j+=1134135#plist = [ar.any_prime_to_cc_index(p) for p in primes_first_n(bound)]136#for j in plist:137# outfile.write(str(j)+"\n")138139outfile.close()140141142