CoCalc Shared Fileswww / cgi-bin / mfd / mfe_ap.pyOpen in CoCalc with one click!
Author: William A. Stein
1
#!/usr/bin/python
2
3
import cgi, mfd, sys, mfe_source, constants, pari
4
5
6
# returns a vector for the eigenvalue in terms of the powerbasis
7
def ap_powerbasis(value, embedding, field):
8
# get field extension degree
9
degree = get_field_degree(field)
10
11
vect = parse_ap_vector(value, degree)
12
basis = parse_basis(embedding, degree)
13
14
poly = ""
15
for i in range(0, degree):
16
poly = poly + "%s*(%s)+"%(vect[i], basis[i])
17
18
cmd = "Pol(" + poly[:-1] + ", x)"
19
# compute polynomial using PARI
20
poly = pari.pari(cmd)
21
22
return poly
23
24
# returns a list of the entries of the vector, corresponding to ap in terms of the basis given by embedding
25
def parse_ap_vector(value, degree):
26
str = value.replace(" ", "")
27
str = str[1:-1] + ","
28
29
vect = []
30
for i in range(0, degree):
31
stop = str.find(",")
32
vect.insert(i, str[:stop])
33
str = str[stop+1:]
34
return vect
35
36
# returns a list of strings (each one of which is a polynomial) corresponding to the embedding
37
def parse_basis(embedding, degree):
38
str = embedding[1:-1] + ","
39
str = str.replace(" ", "")
40
41
basis = []
42
for i in range(0, degree):
43
stop = str.find(",")
44
basis.insert(i, str[:stop])
45
str = str[stop + 1:]
46
return basis
47
48
# returns the degree of the field generated by 'field'
49
def get_field_degree(field):
50
start = field.find("x");
51
rest = field[start + 1:];
52
53
if rest[0] != "^":
54
return 1
55
else:
56
rest = rest[1:]
57
stopp = rest.find("+")
58
if stopp != -1:
59
deg = rest[:stopp]
60
stopm = deg.find("-")
61
if stopm != -1:
62
return eval(deg[:stopm])
63
else:
64
return eval(deg)
65
else:
66
stopm = rest.find("-")
67
return eval(rest[:stopm])
68
69
# returns the standard powerbasis for the field extension generated by field
70
def power_basis(field):
71
deg = get_field_degree(field)
72
basis = "["
73
for i in range(0, deg):
74
if i == 0:
75
basis = basis + "1, "
76
elif i == 1:
77
basis = basis + "x, "
78
else:
79
basis = basis + "x^%s, "%i
80
81
return basis[:-2] + "]"
82
83
form = cgi.FieldStorage()
84
85
print "Content-Type: text/html"
86
print ""
87
88
if form.has_key("code"):
89
code = form["code"].value
90
else:
91
print "Missing code"
92
sys.exit(0)
93
94
if form.has_key("n"):
95
n = int(form["n"].value)
96
else:
97
print "Missing n"
98
sys.exit(0)
99
100
101
M = mfd.ModSym(code)
102
value = M.ap(n)
103
trace = M.trace_ap(n)
104
charpoly = M.charpoly_ap(n)
105
source = M.ap_source()
106
embedding = M.ap_embedding()
107
field = M.ap_field()
108
109
bar="////////////////////////////////////////////////////////////\n"
110
print "//<pre>%s// Hecke eigenvalue a_%s for %s"%(bar,n,code)
111
if source != constants.not_computed:
112
print "// Source of data: %s"%mfe_source.Link(M.source(source))
113
print bar
114
if trace != constants.not_computed:
115
print "// This is the trace down to Q of a_%s"%n
116
print "trace_ap[%s] := %s; \n"%(n,trace)
117
if charpoly != constants.not_computed:
118
print "charpoly_ap[%s] := %s; \n"%(n,charpoly)
119
if value != constants.not_computed:
120
print "// The following is a_%s written in terms of a "%n+\
121
'<a href="%s/mfe_ap_data.py?code=%s">certain basis for the Hecke eigenvalue field</a>.'%\
122
(constants.CGIROOT,code)
123
print "ap[%s] := %s; \n"%(n,value.replace(",",",\n"))
124
125
print "// The following is a_%s written in terms of the "%n+\
126
'<a href="%s/mfe_ap_data_powerbasis.py?code=%s">power basis for the Hecke eigenvalue field</a>.'%\
127
(constants.CGIROOT,code)
128
129
print "ap[%s] := %s, \n"%(n,ap_powerbasis(value, embedding, field))
130
print "// where the Hecke eigenvalue field is K=Q[x]/(f)"
131
print "f := %s; \n"%field
132
133
134