CurveData

337 days ago by Ben.LeVeque

f=open('/Users/bleveque/Sage/matched.txt') #opens the file matched.txt for reading 
       
K.<a>=NumberField(x^2-x-1) embs=K.embeddings(RR) def grabber(s): return eval('['+s.split('[')[1].split(']')[0]+']') #returns a-invariants def list_maker(s): s=s[:-1] #we want to add new text to each line, so we take off ret = [s] #\n first and define our list to eventually be returned #now we create the elliptic curve over K defined by the a-invariants E = EllipticCurve(K,grabber(s)) T = E.torsion_subgroup() #calculations for rank bounds TI = T.invariants() # t2 = len([a for a in TI if a%2 == 0]) # simon = E.simon_two_descent() # ret.append(str(simon[0])) #append upper rank bound ret.append(str(simon[1] - t2)) #append lower rank bound D=K(E.discriminant()) #calculate discriminant t='' #create string to add + or - for m in embs: e=m(D) if sgn(e)<0: t+='-' else: t+='+' t+=',' ret.append(t[:-1]) #append disc signs fac=D.factor() k=[str(e) for p,e in fac] #calculate disc ord ret.append(','.join(k)) #append disc ord #the next section adds ord_(j). There are certain curves (eg N=729 #2) which have #j-invariant 0. The denominator_ideal function is not defined for j=0, so we set #the value to be 1 if this is the case. try: denfac = K(E.j_invariant()).denominator_ideal().factor() except ValueError: denfac = [(1,1)] l=[str(e) for p,e in denfac] ret.append(','.join(l)) #append j-ord ret.append(','.join([str(e) for e in E.tamagawa_numbers()])) #append tamagawa z = E.conductor().factor() ret.append(','.join([str(E.kodaira_symbol(p)) for p,e in z])) #append kodaira return ret #output_string takes in the current line of data to be written to the new file #it adds the correct spacing after each entry which is defined below def output_string(curr_data): ret = '' for i,s in enumerate(curr_data): ret += s ret += (2+width[i]-len(s))*' ' return ret+'\n' 
       
data=[] for s in f.readlines(): data.append(list_maker(s)) width = [0 for i in range(8)] #sets uniform width for each column for cur_data in data: for i,e in enumerate(cur_data): t = len(e) if t > width[i]: width[i] = t g = open('/Users/bleveque/Sage/newellipticcurvedatafile2.txt','w') for curr_data in data: g.write(output_string(curr_data)) #writes data to new file g ^^ f.close() g.close()