CoCalc Public Fileswww / talks / mazur-explicit-formula / go2.sage
Author: William A. Stein
1
attach "explicit.pyx"
2
3
list1 = ["11a", "14a", "37a", "43a", "389a", "433a", "5077a", "11197a"]
4
list2 = ["816b", "5423a", "2340i", "2379b", "2432d", "29862s", "3776h", "128b", "160a", "192a", "10336d"]
5
6
ncpus = 16
7
8
def plots(curves=list1, rng="1e9", ncpus=ncpus) :
9
B = int(eval(rng))
10
print "output path = ", rng
11
print "B = ", B
12
13
def f(label):
14
dp = DataPlots(label, B, data_path='data')
15
v = dp.data(num_points=5000, log_X_scale=True, verbose=True)
16
for w in ['raw','medium','well']:
17
g = plot_step_function(v[w]['mean'],thickness=5,fontsize=24)
18
g.save('plots/%s/%s-%s-%s.svg'%(rng, label, w, B), gridlines=True)
19
return label, v['raw']['mean'][-1][1], v['medium']['mean'][-1][1], v['well']['mean'][-1][1]
20
21
@parallel(ncpus)
22
def g(label):
23
return f(label)
24
25
if ncpus > 1:
26
for input, output in g(curves):
27
print output
28
else:
29
for lbl in curves:
30
print f(lbl)
31
32
def aplist_data(curves=list1, rng="1e9"):
33
B = int(eval(rng))
34
@parallel(ncpus)
35
def f(lbl):
36
E = EllipticCurve(lbl)
37
aplist_sobj = 'data/%s-aplist-%s.sobj'%(lbl, B)
38
if not os.path.exists(aplist_sobj):
39
v = E.aplist(B)
40
v = [int(ap) for ap in v]
41
save(v, aplist_sobj)
42
43
for input, output in f(curves):
44
print input, output
45
46
def lseries_data(curves=list1+list2, rng="1e5"):
47
B = int(eval(rng))
48
@parallel(ncpus)
49
def f(lbl):
50
E = EllipticCurve(lbl)
51
zeros_sobj = 'data/%s-zeros-%s.sobj'%(lbl, B)
52
if not os.path.exists(zeros_sobj):
53
v = E.lseries().zeros(B)
54
v = [int(ap) for ap in v]
55
save(v, zeros_sobj)
56
57
for input, output in f(curves):
58
print input, output
59
60
def zeros(lbl, num_zeros=10000):
61
assert num_zeros <= 10000
62
63
64
def zero_sum_mean_plots(curves=list1+list2, num_zeros=10000, Xmax=1e9, num_points=10000):
65
assert num_zeros <= 10000
66
@parallel(ncpus)
67
def f(lbl):
68
path = "plots/mean_zero_sums/%s/"%num_zeros
69
if not os.path.exists(path):
70
os.makedirs(path)
71
fname = "%s/%s-%s-%s-%s.svg"%(path, lbl, num_zeros, Xmax, num_points)
72
if os.path.exists(fname):
73
74
v = mean_zero_sum_plot(zeros(lbl,num_zeros), num_points, Xmax)
75
line(v).save(fname)
76
77
for input, output in f(curves):
78
print input, output
79
80
def zero_sum_mean_animations(curves=list1+list2, num_zeros=[10,20,..,500], Xmax=1e9, num_points=10000):
81
assert max(num_zeros) <= 10000
82
@parallel(ncpus)
83
def f(lbl):
84
path = "plots/mean_zero_sums/animations/%s-%s"%(Xmax, num_points)
85
if not os.path.exists(path):
86
os.makedirs(path)
87
fname = "%s/%s.gif"%(path, lbl)
88
if os.path.exists(fname):
89
90
v = zeros(lbl)
91
frames = [line(mean_zero_sum_plot(v[:n], num_points, Xmax)) for n in num_zeros]
92
ymax = max([f.ymax() for f in frames])
93
ymin = min([f.ymin() for f in frames])
94
A = animate(frames, ymax=ymax, ymin=ymin)
95
A.save(fname)
96
97
for input, output in f(curves):
98
print input, output
99
100
101
#########################################################
102
103
def zero_sum_plots(curves=list1+list2, num_zeros='1e4', Xmax='1e9', num_points='1e3'):
104
path = "plots/zero_sums/%s/"%num_zeros
105
if not os.path.exists(path):
106
os.makedirs(path)
107
fname = "%s/%s-%s-%s-%s.svg"%(path, lbl, num_zeros, Xmax, num_points)
108
if os.path.exists(fname):
109
110
if isinstance(Xmax,str):
111
Xmax = float(Xmax)
112
if isinstance(num_points, str):
113
num_points=int(float(num_points))
114
if isinstance(num_zeros, str):
115
num_zeros=int(float(num_zeros))
116
@parallel(ncpus)
117
def f(lbl):
118
v = zero_sum_plot(zeros(lbl,num_zeros), num_points, Xmax)
119
line(v).save(fname)
120
121
for input, output in f(curves):
122
print input, output
123
124
def zero_sum_animations(curves=list1+list2, num_zeros=[10,15,..,500], Xmax='1e20', num_points='1e4'):
125
assert max(num_zeros) <= 10000
126
path = "plots/zero_sums/animations/%s-%s"%(Xmax, num_points)
127
if not os.path.exists(path):
128
os.makedirs(path)
129
if isinstance(Xmax,str):
130
Xmax = float(Xmax)
131
if isinstance(num_points, str):
132
num_points=int(float(num_points))
133
@parallel(ncpus)
134
def f(lbl):
135
fname = "%s/%s.gif"%(path, lbl)
136
if os.path.exists(fname):
137
138
v = zeros(lbl)
139
frames = [line(zero_sum_plot(v[:n], num_points, Xmax), thickness=.4) +
140
text(str(n),(log(Xmax)/10,.15),fontsize=16,color='black') for n in num_zeros]
141
ymax = max([f.ymax() for f in frames])
142
ymin = min([f.ymin() for f in frames])
143
A = animate(frames, ymax=ymax, ymin=ymin, figsize=[8,5])
144
A.save(fname)
145
146
for input, output in f(curves):
147
print input, output
148
149
150
def zero_sum_no_log_animations(curves=list1+list2, num_zeros=[4..100], Xmax='1e20', num_points='1e4'):
151
assert max(num_zeros) <= 10000
152
path = "plots/zero_sums_no_log/animations/%s-%s"%(Xmax, num_points)
153
if not os.path.exists(path):
154
os.makedirs(path)
155
if isinstance(Xmax,str):
156
Xmax = float(Xmax)
157
if isinstance(num_points, str):
158
num_points=int(float(num_points))
159
@parallel(ncpus)
160
def f(lbl):
161
fname = "%s/%s.gif"%(path, lbl)
162
if os.path.exists(fname):
163
164
v = zeros(lbl)
165
frames = [line(zero_sum_no_log_plot(v[:n], num_points, Xmax), thickness=.3) +
166
text(str(n),(log(Xmax)/10,.15),fontsize=16,color='black') for n in num_zeros]
167
ymax = max([f.ymax() for f in frames])
168
ymin = min([f.ymin() for f in frames])
169
A = animate(frames, ymax=ymax, ymin=ymin, figsize=[8,5])
170
A.save(fname)
171
172
for input, output in f(curves):
173
print input, output
174
175