Attachment 'sha_v2.sage'
Download 1 def minPolyGen(conductor,degree):
2 """
3 Give an integer m for which the multiplicative group of
4 of ZZ/mZZ is cyclic then for each divisor d of euler_phi(m), there
5 will be a unique subfield of Q(zeta_m) of degree d. This returns
6 this polynomial which generates such an extension.
7
8 EXAMPLE:
9 m=7, d=3
10 K.<a> = NumberField(minPolyGen(7,3))
11 """
12 n = conductor
13 d = degree
14
15 # check that the Z/nZ has cyclic multiplicative group
16 if not n % 2 == 0 and not n.is_prime_power():
17 raise ValueError, 'Invalid input because (ZZ/%sZZ)* is not cyclic' % n
18 if n % 2 == 0:
19 nprime = Integer(n/2)
20 if not nprime.is_prime_power() or nprime % 4 == 0:
21 raise ValueError, 'Invalid input because (ZZ/%sZZ)* is not cyclic' % n
22
23 # check that there will be such a field of degree d in side QQ(zeta_n)
24 if euler_phi(n) % d != 0:
25 raise ValueError, 'No field exists because %s does not divide %s=phi(%s)' % (d,euler_phi(n),n)
26
27 f = euler_phi(n)/d
28 R = IntegerModRing(n)
29 g = R.unit_gens()[0]
30 zetap = CC.zeta(n)
31
32 # create a list alpha of all the Galois conjugates
33 alpha = []
34 for i in range(d):
35 alpha.append(0)
36 for j in range(f):
37 alpha[i] += zetap^(Integer(g^(d*j+i)))
38
39 S.<x> = ZZ[]
40 the_poly = prod(x - a for a in alpha)
41 coeff = [CC(x).real_part().round() for x in the_poly.coefficients()]
42 new_poly = S(0)
43 for i in range(len(coeff)):
44 new_poly += coeff[i]*S.gen()^i
45 return new_poly
46
47 def shaOrderFast(E,K,mod_symb,m,precision=10^(-10)):
48 """
49 E = EllipticCurve/Q we want #Sha(E/K) for
50 K = Field to check over
51 mod_symb = modular symbols of E
52 m = conductor of K (should be 1 mod d)
53 precision = a precision to which we will consider something an integer
54
55 Want to return:
56 0: integral order of sha
57 1: real order of sha
58 2: product without the L(E,1) term (j=0 below)
59 """
60 print '\t checking conductor %s on curve %s' % (m,E.cremona_label())
61 if E.conductor() % m == 0:
62 raise ValueError, 'field conductor m=%s was not coprime to E.conductor()=%s' % (m,E.conductor())
63 d = K.degree()
64 EK = E.change_ring(K)
65 tor_order = EK.torsion_subgroup().order()^2
66 tamagawa_factor = EK.tamagawa_product_bsd()
67 product_result = 1
68 R = IntegerModRing(m)
69 g = R.unit_gens()[0]
70 bits = 53
71 accurate = False
72 while accurate == False:
73 C = ComplexField(bits)
74 z = C.zeta(m-1)
75 max_ellchi = 0
76 symbols = [mod_symb(Integer(g^k)/m) for k in range(m-1)]
77 for j in range(1,d):
78 ellchi = sum(z^((m-1)*j*k/d)*symbols[k] for k in range(m-1))
79 max_ellchi = max(max_ellchi,ellchi.norm())
80 product_result *= ellchi
81 nontrivial_part = CC(product_result.real_part())
82 product_result *= mod_symb(0)
83 real_result = CC(product_result*tor_order/(tamagawa_factor*E.real_components()^d)).real_part()
84 int_result = real_result.round()
85 if nontrivial_part != 0:
86 epsilon = max_ellchi/(2*tor_order^(d-1)*euler_phi(m)*nontrivial_part*max([r for r in symbols]))
87 epsilon = CC(epsilon.norm())
88 b = RR(-log(epsilon)/log(2))
89 print b
90 if b < bits:
91 accurate = True
92 else:
93 bits *= 2
94 product_result = 1 # resset the result
95 else:
96 accurate = True
97
98 return [int_result, real_result, nontrivial_part]
99
100 def sha_fast(p,field_conductor_bound=100,curve_conductor_bound=20,curve_conductor_lower_bound=11,spacing=20,filename='sha_fast_data.txt'):
101 """
102 p = degree of fields K to consider sha(E/K)
103 field_conductor_bound = bound on the conductor of the number field
104 curve_conductor_bound = UPPER bound on conductor of elliptic_curves to consider
105 curve_conductor_lower_bound = LOWER bound on conductor of elliptic_curves to consider
106 spacing = formatting
107 filename = filename if you want to specify one
108 """
109 if filename == 'sha_fast_data.txt':
110 filename = 'sha_data_%s_%s_%s_%s.txt' % (p, field_conductor_bound, curve_conductor_lower_bound, curve_conductor_bound)
111 bad_filename = filename+'.exceptions'
112 candidates = [q for q in prime_range(field_conductor_bound) if q % p == 1]
113 print 'Candidates field conductors initialized...'
114 fields=[NumberField(minPolyGen(q,p),'a') for q in candidates]
115 print 'Fields initialized...'
116 file = open(filename, 'a')
117 bad_file = open(bad_filename, 'a')
118 print 'Writing to file %s' % filename
119 file.write('Data for fields of degree %s of conductor < %s with curves having conductor between %s and %s\n' % (p, field_conductor_bound, curve_conductor_lower_bound, curve_conductor_bound))
120 bad_file.write('Exceptions thrown for fields of degree %s of conductor < %s with curves having conductor between %s and %s\n' % (p, field_conductor_bound, curve_conductor_lower_bound, curve_conductor_bound))
121 file.write('%s %s %s %s %s %s\n' % ('Curve label'.ljust(spacing), 'ZZ(#Sha(E/K))'.ljust(spacing), '#Sha(E/K)'.ljust(spacing), 'ell_chi'.ljust(spacing), 'Field conductor'.ljust(spacing), 'Field degree'.ljust(spacing)))
122 for E in CremonaDatabase().iter_optimal([curve_conductor_lower_bound..curve_conductor_bound]):
123 print 'Beginning curve %s' % E.cremona_label()
124 try:
125 M = E.modular_symbol()
126 except:
127 bad_file.write('Curve %s did not compute its modular symbols correctly\n' % E.cremona_label())
128 else:
129 for q in candidates:
130 try:
131 shaData = shaOrderFast(E,fields[candidates.index(q)],M,q)
132 except ValueError as detail:
133 bad_file.write('Curve %s threw exception: %s\n' % (E.cremona_label(), detail))
134 except:
135 bad_file.write('Curve %s threw unrecorded exception\n' % E.cremona_label())
136 else:
137 shaOrder = shaData[0]
138 shaOrder_R = shaData[1]
139 chi_factors = shaData[2]
140 to_write = '%s %s %s %s %s %s\n' % (str(E.cremona_label()).ljust(spacing), is_square(shaOrder) and str(shaOrder).ljust(spacing) or (str(shaOrder)+'***').ljust(spacing), str('%.4f' % shaOrder_R).ljust(spacing), str('%.4f' % chi_factors).ljust(spacing), str(q).ljust(spacing), str(fields[candidates.index(q)].degree()))
141 file.write(to_write)
142 file.close()
143 bad_file.close()
144 print 'Finished'
145
146
147 def sha_list_for_curve(d,E,field_conductor_bound=100,spacing=20,filename=None):
148 """
149 d = degree of fields K to consider sha(E/K)
150 field_conductor_bound = bound on the conductor of the number field
151 spacing = formatting
152 filename = filename if you want to specify one
153 """
154 if filename == None:
155 filename = 'sha_data_%s_%s_%s.txt' % (d, E.cremona_label(), field_conductor_bound)
156 bad_filename = filename+'.exceptions'
157 candidates = [q for q in prime_range(field_conductor_bound) if q % d == 1]
158 print 'Candidates field conductors initialized...'
159 fields=[NumberField(minPolyGen(q,d),'a') for q in candidates]
160 print 'Fields initialized...'
161 file = open(filename, 'a')
162 bad_file = open(bad_filename, 'a')
163 print 'Writing to file %s' % filename
164 file.write('Data for fields of degree %s, prime conductor < %s with curve %s\n' % (d, field_conductor_bound, E.cremona_label()))
165 bad_file.write('Exceptions for fields of degree %s, prime conductor < %s with curve %s\n' % (d,field_conductor_bound,E.cremona_label()))
166 file.write('%s %s %s %s %s %s\n' % ('Curve label'.ljust(spacing), 'ZZ(#Sha(E/K))'.ljust(spacing), '#Sha(E/K)'.ljust(spacing), 'ell_chi'.ljust(spacing), 'Field conductor'.ljust(spacing), 'Field degree'.ljust(spacing)))
167 print 'Beginning curve %s' % E.cremona_label()
168 try:
169 M = E.modular_symbol()
170 except:
171 bad_file.write('Curve %s did not compute its modular symbols correctly\n' % E.cremona_label())
172 else:
173 for q in candidates:
174 try:
175 shaData = shaOrderFast(E,fields[candidates.index(q)],M,q)
176 except ValueError as detail:
177 bad_file.write('Curve %s threw exception: %s\n' % (E.cremona_label(), detail))
178 except:
179 bad_file.write('Curve %s threw unrecorded exception\n' % E.cremona_label())
180 else:
181 shaOrder = shaData[0]
182 shaOrder_R = shaData[1]
183 chi_factors = shaData[2]
184 to_write = '%s %s %s %s %s %s\n' % (str(E.cremona_label()).ljust(spacing), is_square(shaOrder) and str(shaOrder).ljust(spacing) or (str(shaOrder)+'***').ljust(spacing), str('%.4f' % shaOrder_R).ljust(spacing), str('%.4f' % chi_factors).ljust(spacing), str(q).ljust(spacing), str(fields[candidates.index(q)].degree()))
185 file.write(to_write)
186 file.close()
187 bad_file.close()
188 print 'Finished'
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.