{{{id=1| f=open('/home/psharaba/ECD/CLlist.txt') /// }}} {{{id=2| f.readline().split() /// ['124', '252', '[a+1,a-1,a+1,5*a-16,4*a-21]', '[a,a+1,1,-5*a-9,-20*a-22]'] }}} {{{id=4| x = var('x') K. = NumberField(x^2-x-1) import psage.modform.hilbert.sqrt5.tables as sqrt5 from nosqlite import Client def local_db(): return Client('/home/psharaba/ECD/localdb').db def network_db(): raise NotImplementedError def create_local_db(): db = local_db() c = db.curves # collection c.ensure_index(unique=True, weq=1) for X in open('/home/psharaba/ECD/CLlist.txt').readlines(): v = X.split() d = {'N':int(v[0]), 'cond':v[1], 'weq':v[-1]} try: c.insert(d) except Exception, msg: print msg def compute_all_lseries(Nmin, Nmax): db = local_db() c = db.curves X = db('select weq from curves where N>=%s and N<=%s and dokchitser is NULL'%(Nmin, Nmax)) print "%s left to do"%len(X) @parallel def comp(weq): ainvs = sage_eval(weq, {'a':a}) print ainvs E = EllipticCurve(K, ainvs) w = walltime() L = E.lseries().dokchitser() w0 = walltime(w) d = {'dokchitser':(L,w0)} print d c = local_db().curves c.update(d, weq=weq) for A in comp(X): print A def compute_leading_coeff(force=False): # For each entry in the database for which the 'dokchitser' field # is set, but 'Lstar' is not set, grab the 'dokchitser' field, # compute the leading coefficient of L, and record in Lstar. db = local_db() c = db.curves if 'Lstar' in c.columns() and not force: X = db('select weq from curves where dokchitser not NULL and Lstar is NULL') else: X = db('select weq from curves where dokchitser not NULL') print "%s left to do"%len(X) @parallel def comp(weq): c = local_db().curves v = c.find_one(weq=weq) L = v['dokchitser'][0] f = L.taylor_series(1, 6) r_an = 0 while abs(f[r_an])<1e-10: r_an += 1 if r_an == 6: raise RuntimeError Lstar = float(f[r_an]) d = {'r_an':r_an, 'Lstar':Lstar} c.update(d, weq=v['weq']) print d for A in comp(X): print A def fix_compute_leading_coeff(): # For each entry in the database for which the 'dokchitser' field # is set, but 'Lstar' is not set, grab the 'dokchitser' field, # compute the leading coefficient of L, and record in Lstar. db = local_db() c = db.curves X = db('select weq from curves where Lstar>=-1e-10 and Lstar<=1e-10 and dokchitser is not NULL') print "%s left to redo"%len(X) @parallel def comp(weq): c = local_db().curves v = c.find_one(weq=weq) L = v['dokchitser'][0] f = L.taylor_series(1, 6) r_an = 0 while abs(f[r_an])<1e-10: r_an += 1 if r_an == 6: raise RuntimeError Lstar = float(f[r_an]) d = {'r_an':r_an, 'Lstar':Lstar} c.update(d, weq=v['weq']) print d for A in comp(X): print A def leading_coeff_table(file): db = local_db() X = db('select N,cond,weq,r_an,Lstar from curves where Lstar is not NULL order by N') if isinstance(file, str): file = open(file, 'w') file.write('N cond weq r_an Lstar\n') for v in X: file.write('%s %s %s %s %s\n'%v) def saturate_rank_01(E, sat_bound): v = E.simon_two_descent() t2 = E.two_torsion_rank() sel2 = v[1] rank_bound = sel2 - t2 if rank_bound >1: raise NotImplementedError if rank_bound == 0: return 0 Q = v[-1][0] for p in prime_range(sat_bound): if len(Q.division_points(p)) != 0: Q = Q.division_points(p)[0] return Q def regulator_new(E,sat_bound): Q = saturate_rank_01(E,sat_bound) if Q: return Q.height()/2, [Q] else: return int(1), [] def compute_regulators(Nmax, sat_bound=20, force=False): db = local_db() c = db.curves if 'reg' in c.columns() and not force: X = db('select weq from curves where reg is NULL and N<=%s'%Nmax) else: X = db('select weq from curves where N<=%s'%Nmax) print "%s left to do"%len(X) @parallel def comp(weq): ainvs = sage_eval(weq, {'a':a}) E = EllipticCurve(K, ainvs) try: reg, gens = regulator_new(E,sat_bound) if not isinstance(reg, int): reg = float(reg) except NotImplementedError: print "skipping %s since not implemented!!!"%weq return d = {'reg':reg, 'gens':gens, 'sat_bound':sat_bound} print d c = local_db().curves c.update(d, weq=weq) return E.conductor().norm() for A in comp(X): print A def reg_table(file): db = local_db() X = db('select N,cond,weq,reg,sat_bound from curves where reg is not NULL order by N') if isinstance(file, str): file = open(file, 'w') file.write('N cond weq reg sat_bound\n') for v in X: file.write('%s %s %s %s %s\n'%v) def period_stuff(E): w = [] v = [] for phi in K.embeddings(RR): B = E.period_lattice(phi).basis() a = B[0].real() if abs(B[1].real()) <1e-20: a *= 2 v.append(float(a)) w.append(B) return v, w def compute_periods(): db = local_db() c = db.curves if 'real0' in c.columns(): X = db('select weq from curves where real0 is NULL order by N') else: X = db('select weq from curves order by N') print "%s left to do"%len(X) @parallel def comp(weq): t = walltime() ainvs = sage_eval(weq, {'a':a}) E = EllipticCurve(K, ainvs) v, w = period_stuff(E) d = {'real0':v[0], 'real1':v[1], 'period_lattice0':w[0], 'period_lattice1':w[1]} c = local_db().curves c.update(d, weq=weq) print d, walltime(t) return walltime(t) for A in comp(X): print A def omega_table(file): db = local_db() X = db('select N,cond,weq,real0,real1 from curves where real0 is not NULL order by N') print "%s entries"%len(X) if isinstance(file, str): file = open(file, 'w') file.write('N cond weq real0 real1\n') for v in X: file.write('%s %s %s %s %s\n'%v) ######################################################### ############# isogeny classes ############### ######################################################### def ap(E,p): return E.change_ring(p.residue_field()).trace_of_frobenius() R. = GF(2)[] def frob(E,p): t = ap(E,p) return ch^2 - ap(E, p)*ch + int(p.norm()) def disc(E, p): t = ap(E, p) return t^2 - 4*p.norm() def isogeny_primes(E, norm_bound, isog_degree_bound): #Returns prime for which E has an isogeny P = [p for p in sqrt5.ideals_of_bounded_norm(norm_bound) if p.is_prime() and E.has_good_reduction(p)] w = set(primes(isog_degree_bound+1)) i = 0 w.remove(2) while len(w) > 0 and i < len(P): d = disc(E, P[i]) w = [ell for ell in w if not (legendre_symbol(d,ell) == -1)] i = i +1 i = 0 while i < len(P): if frob(E,P[i]).is_irreducible(): break i = i+1 if i == len(P): w.insert(0,2) return w def closed_under_multiplication_by_m(E, f, m): """ INPUT: - E -- elliptic curve in *short* Weierstrass form - f -- a polynomial that defines a finite subset S of E[p] that is closed under [-1] - m -- integer m >= 2 coprime to p. We assume that p is odd. OUTPUT: - True if [m]*S = S, and False otherwise. """ K = E.base_field() h = E.multiplication_by_m(m, x_only=True) n = h.numerator(); d = h.denominator() S. = K[] psi = n.parent().hom([x,0]) tau = f.parent().hom([x]) r = tau(f).resultant(psi(n)-Z*psi(d), x) r0 = S.hom([0,f.parent().gen()])(r) return r0.monic() == f.monic() def is_subgroup(E, f, p): """ INPUT: - E -- elliptic curve in *short* Weierstrass form - f -- a polynomial that defines a finite subset S of E[p] that is closed under [-1] - p -- an odd prime OUTPUT: - True exactly if S union {0} is a group. """ m = primitive_root(p) return closed_under_multiplication_by_m(E, f, m) def isogeny_class_computation(E, p): if p != 2: E = E.short_weierstrass_model() F = E.division_polynomial(p).change_ring(K) candidates = [f for f in divisors(F) if f.degree() == (p-1)/2 and is_subgroup(E,f,p)] v = [] w = [] for f in candidates: try: v.append(E.change_ring(K).isogeny(f).codomain()) w.append(f) except ValueError: pass v = [F.change_ring(K).global_minimal_model() for F in v] return v else: w = [Q for Q in E.torsion_subgroup() if order(Q)==2] v = [E.isogeny(E(Q)).codomain() for Q in w] return v def curve_isogeny_vector(E): #Returns isogeny class and adjacency matrix curve_list = [E] i = 0 Adj = matrix(50) ins = 1 norm_bound, isog_degree_bound = 500,500 while i < len(curve_list): isolist = isogeny_primes(curve_list[i],norm_bound, isog_degree_bound) for p in isolist: for F in isogeny_class_computation(curve_list[i],p): bool = True for G in curve_list: if F.is_isomorphic(G): bool = False Adj[i,curve_list.index(G)]=p #if a curve in the isogeny class computation is isom Adj[curve_list.index(G),i]=p #to a curve already in the list, we want a line if bool: curve_list.append(F) Adj[i,ins]=p Adj[ins,i]=p ins += 1 i+=1 Adj = Adj.submatrix(nrows=len(curve_list),ncols=len(curve_list)) return {'curve_list':curve_list, 'adjacency_matrix':Adj, 'norm_bound':norm_bound, 'isog_degree_bound':isog_degree_bound, 'subgroup_checked':True} def compute_isogeny_classes(): db = local_db() c = db.curves if 'isoclass' in c.columns(): #X = db('select weq from curves where isoclass is NULL order by N') # since the isoclasses are all wrong anyways... X = db('select weq from curves order by N') else: X = db('select weq from curves order by N') print "%s left to do"%len(X) @parallel(8) def comp(weq): t = walltime() ainvs = sage_eval(weq, {'a':a}) E = EllipticCurve(K, ainvs) iso = curve_isogeny_vector(E) d = {'isoclass':iso} c = local_db().curves c.update(d, weq=weq) print d, walltime(t) return walltime(t) for A in comp(X): print A def isogeny_table(file): db = local_db() c = db.curves X = c.find('N>=1', fields=['N','cond','weq','isoclass'], order_by='N') if isinstance(file, str): file = open(file, 'w') file.write('N cond weq iso_class iso_matrix\n') i = 0 for v in X: if not v.has_key('isoclass'): continue if not v['isoclass'].has_key('subgroup_checked'): print "crap: ", v continue i += 1 iso = v['isoclass'] M = iso['adjacency_matrix'] mat = "matrix(%s,%s)"%(M.nrows(),str(M.list()).replace(' ','')) ainvs=str([list(E.ainvs()) for E in iso['curve_list']]).replace(' ','') s = '%s %s %s %s %s'%(v['N'],v['cond'],v['weq'],ainvs,mat) print i, s file.write(s+'\n') file.flush() /// }}}