{{{id=1| x=var('x') K.=NumberField(x^2-x-1) /// }}} {{{id=2| %cython include 'sage/libs/pari/decl.pxi' from sage.libs.pari.gen import pari from libc.stdint cimport uint8_t, uint_fast8_t, uint32_t, uint_fast32_t, uint_fast64_t cdef extern from "pari/pari.h": cdef void NEXT_PRIME_VIADIFF(uint32_t, uint_fast8_t *) cdef uint_fast32_t[32] shiftTab shiftTab[ 0] = 0x00000001u shiftTab[ 1] = 0x00000002u shiftTab[ 2] = 0x00000004u shiftTab[ 3] = 0x00000008u shiftTab[ 4] = 0x00000010u shiftTab[ 5] = 0x00000020u shiftTab[ 6] = 0x00000040u shiftTab[ 7] = 0x00000080u shiftTab[ 8] = 0x00000100u shiftTab[ 9] = 0x00000200u shiftTab[10] = 0x00000400u shiftTab[11] = 0x00000800u shiftTab[12] = 0x00001000u shiftTab[13] = 0x00002000u shiftTab[14] = 0x00004000u shiftTab[15] = 0x00008000u shiftTab[16] = 0x00010000u shiftTab[17] = 0x00020000u shiftTab[18] = 0x00040000u shiftTab[19] = 0x00080000u shiftTab[20] = 0x00100000u shiftTab[21] = 0x00200000u shiftTab[22] = 0x00400000u shiftTab[23] = 0x00800000u shiftTab[24] = 0x01000000u shiftTab[25] = 0x02000000u shiftTab[26] = 0x04000000u shiftTab[27] = 0x08000000u shiftTab[28] = 0x10000000u shiftTab[29] = 0x20000000u shiftTab[30] = 0x40000000u shiftTab[31] = 0x80000000u cdef uint_fast8_t[256] twoDiv cdef uint_fast32_t tempItr, tempVar twoDiv[0] = 8u for tempItr in range(1,255u): tempVar = tempItr while not tempVar&1u: twoDiv[tempItr] += 1u tempVar >>= 1u cdef uint_fast32_t exp_mod(uint_fast64_t b, uint_fast32_t e, uint_fast32_t p): cdef uint_fast64_t q if e&1u: q = b else: q = 1ull e >>= 1u while e: b *= b if b > 4294967295ull: b %= p if e&1u: q *= b if q > 4294967295ull: q %= p e >>= 1u if q > 4294967295ull: q %= p return q cdef uint_fast32_t non_residue(uint_fast32_t p): cdef uint8_t *pariPrimePtr = diffptr cdef uint32_t pariP = 0u NEXT_PRIME_VIADIFF(pariP, pariPrimePtr) while True: NEXT_PRIME_VIADIFF(pariP, pariPrimePtr) if exp_mod(p,(pariP-1u)>>1u,pariP)%pariP > 1u: return pariP cdef uint_fast32_t sqrt5_mod(uint_fast32_t p): if p&3u == 3u: return exp_mod(5ull, (p+1u)>>2u, p)%p cdef uint_fast64_t q, z if p&7u == 5u: q = exp_mod(10ull, (p-5u)>>3u, p) z = q*q if z > 1844674407370955161ull: z %= p z *= 10ull z -= 1ull if z > 4294967295ull: z %= p q *= 5ull if q > 4294967295ull: q %= p return q*z%p cdef uint_fast32_t d, dp if p&15u == 9u: q = exp_mod(10ull, (p-9u)>>4u, p) if q > 4294967295ull: q %= p z = q*q if z > 1844674407370955161ull: z %= p z *= 10ull if z > 4294967295ull: z %= p q *= 5ull if q > 4294967295ull: q %= p if z*z%p == 1ull: d = non_residue(p) dp = exp_mod(d, (p-1u)>>3u, p) q *= dp if q > 4294967295ull: q %= p dp *= dp if dp > 4294967295ull: dp %= p z *= dp if z > 4294967295ull: z %= p z -= 1ull return q*z%p p -= 1u cdef uint_fast8_t r = 0u q = 8ull while q == 8ull: q = twoDiv[(p>>r)&0xFFu] r += q q = p>>r p += 1u r -= 2u cdef uint_fast64_t v = exp_mod(non_residue(p), q, p) d = exp_mod(5ull, (q-1u)>>1u, p) cdef uint_fast64_t res = 5ull*d if res > 4294967295ull: res %= p d *= d if d > 3689348814741910323ull: d %= p d *= 5ull d %= p cdef uint_fast8_t m while not d == 1u: m = r dp = d*d%p while not dp == 1u: dp *= dp dp %= p m -= 1u z = exp_mod(v, shiftTab[m], p) res *= z if res > 4294967295ull: res %= p z *= z if z > 4294967295ull: z %= p d *= z d %= p return res%p def get_primes(p): q = sqrt5_mod(p)-1u w = ((p+1u)>>1u)*q%p q = p-1u-w if w < q: return (w,q) return (q,w) /// }}} {{{id=3| def split_prime_combine(p, firstCurves, secondCurves): ret = [] r1,r2 = get_primes(p) if len(firstCurves) < len(secondCurves): firstCurves, secondCurves = secondCurves, firstCurves r1,r2 = r2,r1 for E in firstCurves: liftE = [E[0],0,E[1],0] for i in range(p): for j in range(p): if ((liftE[0]-r2*liftE[1])%p,(liftE[2]-r2*liftE[3])%p) in secondCurves: ret.append(list(liftE)) liftE[2] = (liftE[2]+r1)%p liftE[3] += 1 liftE[3] = 0 liftE[0] = (liftE[0]+r1)%p liftE[1] += 1 return ret def integral_combine(n, first, second, firstCurves, secondCurves): ret = [] for E in firstCurves: for i in range(second): for j in range(second): for k in range(second): for l in range(second): if [A%second for A in E] in secondCurves: ret.append(list(E)) E[3] = (E[3]+first)%n E[2] = (E[2]+first)%n E[1] = (E[1]+first)%n E[0] = (E[0]+first)%n return ret def curves_in_GF(p): ret = {} K = GF(p) for i in range(p): for j in range(p): try: E = EllipticCurve(K,[i,j]) ap = p-len(E.points())+1 if ret.has_key(ap): ret[ap].append(E) else: ret[ap] = [E] except ArithmeticError: pass return ret def various_lifts(A,B,p): q=(p+1)/2 if p%3==1: v = (2*p+1)/3 if p%3==2: v = (p+1)/3 ret = [] for s in [0,q,q*a,q+q*a]: for r in [v*s^2,v*(s^2+1),v*(s^2-1),v*(s^2+a),v*(s^2-a),v*(s^2+a+1),v*(s^2+a-1),v*(s^2-a+1),v*(s^2-a-1)]: for t in [0,q,q*a,q+q*a]: a1 = K(2*s)[0]%p+K(2*s)[1]%p*a a2 = K(3*r-s^2)[0]%p+K(3*r-s^2)[1]%p*a if a2[0]>1: comp0=a2[0]-p else: comp0 = a2[0] if a2[1]>1: comp1 = a2[1]-p else: comp1 = a2[1] a2 = comp0+comp1*a a3 = K(2*t)[0]%p+K(2*t)[1]%p*a a4 = K(A+3*r^2-2*s*t)[0]%p+K(A+3*r^2-2*s*t)[1]%p*a a6 = K(B+r*A+r^3-t^2)[0]%p+K(B+r*A+r^3-t^2)[1]%p*a for c in [a4,a4-p,a4-p*a,a4-p-p*a]: for d in [a6,a6-p,a6-p*a,a6-p-p*a]: #print (a1,a2,a3,c,d) ret.append((a1,a2,a3,c,d)) return ret def quick_disc(ainv): a1 = ainv[0] a2 = ainv[1] a3 = ainv[2] a4 = ainv[3] a6 = ainv[4] return -(a1^2+4*a2)^2*((a1^2+4*a2)*a6-a1*a3*a4+a2*a3^2-a4^2)-8*(a1*a3+2*a4)^3-27*(a3^2+4*a6)^2+9*(a1^2+4*a2)*(a1*a3+2*a4)*(a3^2+4*a6) def ap(E,p): return E.change_ring(p.residue_field()).trace_of_frobenius() def check_aps_against(E,aps): ret = True for i,p in enumerate([11,19,29,31,41,59,61,71,79,89]): r1 = K.primes_above(p)[0] r2 = K.primes_above(p)[1] if type(aps[2*i]) != str: if ap(E,r1) != aps[2*i] or ap(E,r2) != aps[2*i+1]: ret = False return ret /// }}} {{{id=4| aps = [4,2,'?','?',-2,4,0,4,2,-12,0,-4,6,-2,-8,0,-16,-6,-14,6] di={K(3*a-2): aps[0], K(3*a-1): aps[1], K(-4*a+1): aps[2], K(-4*a+3): aps[3], K(-a+6): aps[4], K(a+5): aps[5], K(5*a-2): aps[6], K(5*a-3): aps[7], K(a-7): aps[8], K(a+6): aps[9], K(7*a-2): aps[10], K(7*a-5): aps[11], K(7*a-3): aps[12], K(7*a-4): aps[13], K(a-9): aps[14], K(a+8): aps[15], K(-8*a+5): aps[16], K(-8*a+3): aps[17], K(a-10): aps[18], K(a+9): aps[19]} N=380 cond = -4*a-18 found = False for p in (11,19,29,31,41,59,61,71,79,89): print 'CURRENT PRIME: ',p r1 = K.primes_above(p)[0] r2 = K.primes_above(p)[1] ap1 = di[r1.gens_reduced()[0]] ap2 = di[r2.gens_reduced()[0]] if type(ap1) == str: continue c = r1.integral_basis()[1][0] d = r2.integral_basis()[1][0] if c>d: r1,r2 = r2,r1 ap1,ap2 = ap2,ap1 modp = curves_in_GF(p) firstp = [] for E in modp[ap1]: firstp.append((int(E.a4()),int(E.a6()))) secondp = [] for E in modp[ap2]: secondp.append((int(E.a4()),int(E.a6()))) big_list_newp = split_prime_combine(p,firstp,secondp) print 'Length of big_list_new%s:'%p,len(big_list_newp) current = 1 for e in big_list_newp: print current current += 1 A = e[0]+e[1]*a B = e[2]+e[3]*a for ainv in various_lifts(A,B,p): D = quick_disc(ainv).norm() if D%N==0: E = EllipticCurve(K,list(ainv)) if E.conductor() == cond: print E, 'tentative' if check_aps_against(E,aps): print E, 'a_ps match' found = True break if found: break if found: break /// WARNING: Output truncated! full_output.txt CURRENT PRIME: 11 Length of big_list_new11: 100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 ... 3065 Traceback (most recent call last): found = False File "", line 1, in File "/tmp/tmpkB6d56/___code___.py", line 11, in exec compile(u"for p in (_sage_const_11 ,_sage_const_19 ,_sage_const_29 ,_sage_const_31 ,_sage_const_41 ,_sage_const_59 ,_sage_const_61 ,_sage_const_71 ,_sage_const_79 ,_sage_const_89 ):\n print 'CURRENT PRIME: ',p\n r1 = K.primes_above(p)[_sage_const_0 ]\n r2 = K.primes_above(p)[_sage_const_1 ]\n ap1 = di[r1.gens_reduced()[_sage_const_0 ]]\n ap2 = di[r2.gens_reduced()[_sage_const_0 ]]\n if type(ap1) == str:\n continue\n c = r1.integral_basis()[_sage_const_1 ][_sage_const_0 ]\n d = r2.integral_basis()[_sage_const_1 ][_sage_const_0 ]\n if c>d:\n r1,r2 = r2,r1\n ap1,ap2 = ap2,ap1\n modp = curves_in_GF(p)\n firstp = []\n for E in modp[ap1]:\n firstp.append((int(E.a4()),int(E.a6())))\n secondp = []\n for E in modp[ap2]:\n secondp.append((int(E.a4()),int(E.a6())))\n big_list_newp = split_prime_combine(p,firstp,secondp)\n print 'Length of big_list_new%s:'%p,len(big_list_newp)\n current = _sage_const_1 \n for e in big_list_newp:\n print current\n current += _sage_const_1 \n A = e[_sage_const_0 ]+e[_sage_const_1 ]*a\n B = e[_sage_const_2 ]+e[_sage_const_3 ]*a\n for ainv in various_lifts(A,B,p):\n D = quick_disc(ainv).norm()\n if D%N==_sage_const_0 :\n E = EllipticCurve(K,list(ainv))\n if E.conductor() == cond:\n print E, 'tentative'\n if check_aps_against(E,aps):\n print E, 'a_ps match'\n found = True\n break\n if found:\n break\n if found:\n break" + '\n', '', 'single') File "", line 33, in File "/usr/local/sage/local/lib/python2.6/site-packages/sage/schemes/elliptic_curves/ell_number_field.py", line 1256, in conductor for d in self.local_data()],\ File "/usr/local/sage/local/lib/python2.6/site-packages/sage/schemes/elliptic_curves/ell_number_field.py", line 718, in local_data return [self._get_local_data(pr, proof) for pr in primes] File "/usr/local/sage/local/lib/python2.6/site-packages/sage/schemes/elliptic_curves/ell_number_field.py", line 777, in _get_local_data self._local_data[P, proof, algorithm] = EllipticCurveLocalData(self, P, proof, algorithm) File "/usr/local/sage/local/lib/python2.6/site-packages/sage/schemes/elliptic_curves/ell_local_data.py", line 271, in __init__ self._Emin, ch, self._val_disc, self._fp, self._KS, self._cp, self._split = self._tate(proof) File "/usr/local/sage/local/lib/python2.6/site-packages/sage/schemes/elliptic_curves/ell_local_data.py", line 796, in _tate r = -pinv(12*c4) * (c6 + b2 * c4) File "/usr/local/sage/local/lib/python2.6/site-packages/sage/schemes/elliptic_curves/ell_local_data.py", line 713, in pinv = lambda x: F.lift(~F(x)) File "residue_field.pyx", line 621, in sage.rings.residue_field.ResidueField_generic.lift (sage/rings/residue_field.c:6818) File "parent.pyx", line 915, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:6820) File "residue_field.pyx", line 1231, in sage.rings.residue_field.LiftingMap._call_ (sage/rings/residue_field.c:10160) File "/usr/local/sage/local/lib/python2.6/site-packages/sage/rings/number_field/number_field_ideal.py", line 2956, in __call__ return self.__OK(sum([z[i] * self.__Kgen**i for i in xrange(len(z))])) File "parent.pyx", line 915, in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:6820) File "coerce_maps.pyx", line 82, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3254) File "coerce_maps.pyx", line 77, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3157) File "/usr/local/sage/local/lib/python2.6/site-packages/sage/rings/number_field/order.py", line 1050, in _element_constructor_ if not embedding(x) in self._module_rep: File "map.pyx", line 517, in sage.categories.map.Map.__call__ (sage/categories/map.c:3350) File "map.pyx", line 536, in sage.categories.map.Map._call_ (sage/categories/map.c:3721) File "/usr/local/sage/local/lib/python2.6/site-packages/sage/rings/number_field/maps.py", line 238, in _call_ w = v + [self.__zero]*(self.__n - len(v)) File "element.pyx", line 1459, in sage.structure.element.RingElement.__mul__ (sage/structure/element.c:12096) File "coerce.pyx", line 713, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:6418) File "coerce.pyx", line 891, in sage.structure.coerce.CoercionModel_cache_maps.canonical_coercion (sage/structure/coerce.c:8637) File "coerce.pyx", line 310, in sage.structure.coerce.CoercionModel_cache_maps._record_exception (sage/structure/coerce.c:3843) File "/usr/local/sage/local/lib/python/traceback.py", line 236, in format_exc return ''.join(format_exception(etype, value, tb, limit)) File "/usr/local/sage/local/lib/python/traceback.py", line 142, in format_exception list = list + format_tb(tb, limit) File "/usr/local/sage/local/lib/python/traceback.py", line 76, in format_tb return format_list(extract_tb(tb, limit)) File "/usr/local/sage/local/lib/python/traceback.py", line 101, in extract_tb line = linecache.getline(filename, lineno, f.f_globals) File "/usr/local/sage/local/lib/python/linecache.py", line 14, in getline lines = getlines(filename, module_globals) File "/usr/local/sage/local/lib/python/linecache.py", line 40, in getlines return updatecache(filename, module_globals) File "/usr/local/sage/local/lib/python/linecache.py", line 115, in updatecache fullname = os.path.join(dirname, basename) File "/usr/local/sage/local/lib/python/posixpath.py", line 65, in join if b.startswith('/'): KeyboardInterrupt __SAGE__ }}} {{{id=5| /// }}}