Ticket #11130: 11130-sagelib-simon.patch

File 11130-sagelib-simon.patch, 8.4 KB (added by cremona, 8 years ago)

Apply to sage library after previous

  • sage/schemes/elliptic_curves/ell_number_field.py

    # HG changeset patch
    # User John Cremona <john.cremona@gmail.com>
    # Date 1305822334 -3600
    # Node ID 402a9b27da6434a3eaa931503bf375c16a52fe53
    # Parent  714a9ee90148b5734d5601f4be9e7dc892c060f1
    #11130: fix doctests for simon_two_descent
    
    diff -r 714a9ee90148 -r 402a9b27da64 sage/schemes/elliptic_curves/ell_number_field.py
    a b  
    237237            A = 0
    238238            B = Mod(1, y^2 + 7)
    239239            C = Mod(y, y^2 + 7)
    240             LS2gen = [Mod(Mod(-5, y^2 + 7)*x^2 + Mod(-3*y, y^2 + 7)*x + Mod(8, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y + 1/2, y^2 + 7)*x - 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))]
     240            LS2gen = [Mod(Mod(-5, y^2 + 7)*x^2 + Mod(-3*y, y^2 + 7)*x + Mod(8, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y - 1/2, y^2 + 7)*x - 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))]
    241241            #LS2gen = 2
    242             Recherche de points triviaux sur la courbe
     242            Recherche de points triviaux sur la courbe 
    243243            points triviaux sur la courbe = [[1, 1, 0], [Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7), 1]]
    244244            zc = Mod(Mod(-5, y^2 + 7)*x^2 + Mod(-3*y, y^2 + 7)*x + Mod(8, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
    245245            symbole de Hilbert (Mod(2, y^2 + 7),Mod(-5, y^2 + 7)) = -1
     246            zc = Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y - 1/2, y^2 + 7)*x + Mod(-1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
     247            symbole de Hilbert (Mod(-2*y + 2, y^2 + 7),Mod(1, y^2 + 7)) = 0
     248            sol de Legendre = [1, 0, 1]~
     249            zc*z1^2 = Mod(Mod(2*y - 2, y^2 + 7)*x + Mod(2*y + 10, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
     250            quartique : (-1/2*y + 1/2)*Y^2 = x^4 + (-3*y - 15)*x^2 + (-8*y - 16)*x + (-11/2*y - 15/2)
     251            reduite: Y^2 = (-1/2*y + 1/2)*x^4 - 4*x^3 + (-3*y + 3)*x^2 + (2*y - 2)*x + (1/2*y + 3/2)
     252            non ELS en [2, [0, 1]~, 1, 1, [1, 1]~]
    246253            zc = Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y + 1/2, y^2 + 7)*x + Mod(-1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
    247254            vient du point trivial [Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7), 1]
    248255            m1 = 1
  • sage/schemes/elliptic_curves/ell_rational_field.py

    diff -r 714a9ee90148 -r 402a9b27da64 sage/schemes/elliptic_curves/ell_rational_field.py
    a b  
    13691369            raise ValueError, "algorithm %s not defined"%algorithm
    13701370
    13711371
    1372     def simon_two_descent(self, verbose=0, lim1=5, lim3=50, limtriv=10, maxprob=20, limbigprime=30):
     1372    def simon_two_descent(self, verbose=0, lim1=5, lim3=50, limtriv=10, maxprob=20, limbigprime=30, store_gens=True):
    13731373        r"""
    13741374        Computes a lower bound for the rank of the Mordell-Weil group `E(Q)`,
    13751375        the rank of the 2-Selmer group, and a list of independent points on
     
    13961396           between small and large prime numbers. Use probabilistic tests for
    13971397           large primes. If 0, don't any probabilistic tests.
    13981398       
     1399        - ``store_gens`` - (default: True) if True and if the rank has
     1400           been determined precisely, the set of points returned by
     1401           the descent function is satuarated and stored.     
    13991402       
    14001403        OUTPUT:
    14011404       
     
    14311434            sage: E = EllipticCurve('389a1')
    14321435            sage: set_random_seed(0)
    14331436            sage: E.simon_two_descent()
    1434             (2, 2, [(1 : 0 : 1), (-11/9 : -55/27 : 1)])
     1437            (2, 2, [(0 : -1 : 1), (1 : 0 : 1)])
    14351438            sage: E = EllipticCurve('5077a1')
    14361439            sage: set_random_seed(0)
    14371440            sage: E.simon_two_descent()
    1438             (3, 3, [(1 : 0 : 1), (0 : 2 : 1), (2 : -1 : 1)])
     1441            (3, 3, [(0 : 2 : 1), (1 : -1 : 1), (2 : 0 : 1)])
    14391442       
    14401443        In this example Simon's program does not find any points, though it
    14411444        does correctly compute the rank of the 2-Selmer group.
     
    14591462            sage: E = EllipticCurve([0, 0, 1, -79, 342])
    14601463            sage: set_random_seed(0)
    14611464            sage: E.simon_two_descent()
    1462             (5, 5, [(5 : 8 : 1), (4 : 9 : 1), (3 : 11 : 1), (-1 : 20 : 1), (-6 : -25 : 1)])
     1465            (5, 5, [(-6 : -25 : 1), (-1 : 20 : 1), (3 : 11 : 1), (4 : 9 : 1), (5 : 8 : 1)])
    14631466            sage: E = EllipticCurve([1, 1, 0, -2582, 48720])
    14641467            sage: set_random_seed(0)
    1465             sage: r, s, G = E.simon_two_descent(); r,s
     1468            sage: r, s, G = E.simon_two_descent(store_gens=False); r,s
    14661469            (6, 6)
    14671470            sage: E = EllipticCurve([0, 0, 0, -10012, 346900])
    14681471            sage: set_random_seed(0)
    1469             sage: r, s, G = E.simon_two_descent(); r,s
     1472            sage: r, s, G = E.simon_two_descent(store_gens=False); r,s
    14701473            (7, 7)
    14711474            sage: E = EllipticCurve([0, 0, 1, -23737, 960366])   
    14721475            sage: set_random_seed(0)
    1473             sage: r, s, G = E.simon_two_descent(); r,s
     1476            sage: r, s, G = E.simon_two_descent(store_gens=False); r,s
    14741477            (8, 8)
    14751478
    14761479        Example from trac 10832::
    14771480            sage: E = EllipticCurve([1,0,0,-6664,86543])
    14781481            sage: E.simon_two_descent()
    1479             (2, 3, [(173 : 1943 : 1), (-73 : -394 : 1), (323/4 : 1891/8 : 1)])
     1482            (2, 3, [(-73 : -394 : 1), (323/4 : 1891/8 : 1)])
    14801483            sage: E.rank()
    14811484            2
    14821485            sage: E.gens()
     
    14851488        """
    14861489        t = simon_two_descent(self, verbose=verbose, lim1=lim1, lim3=lim3, limtriv=limtriv,
    14871490                              maxprob=maxprob, limbigprime=limbigprime)
     1491        if t=='fail':
     1492            raise RuntimeError, 'Run-time error in simon_two_descent.'
     1493        if verbose>0:
     1494            print "simon_two_descent returns ",t
    14881495        rank_low_bd = rings.Integer(t[0])
    14891496        two_selmer_rank = rings.Integer(t[1])
    14901497        gens_mod_two = [self(P) for P in t[2]]
    1491         if rank_low_bd == two_selmer_rank - self.two_torsion_rank():
    1492             gens = [P for P in gens_mod_two if P.has_infinite_order()]
    1493             gens = self.saturation(gens)[0]
    1494             self.__gens[True] = gens
    1495             self.__gens[True].sort()
    1496             self.__rank[True] = len(self.__gens[True])
     1498        if store_gens:
     1499            if rank_low_bd == two_selmer_rank - self.two_torsion_rank():
     1500                if verbose>0:
     1501                    print "Rank determined successfully, saturating..."
     1502                gens = [P for P in gens_mod_two if P.has_infinite_order()]
     1503                gens = self.saturation(gens)[0]
     1504                gens.sort()
     1505                self.__gens[True] = gens
     1506                self.__rank[True] = len(gens)
     1507                gens_mod_two = gens
    14971508        return rank_low_bd, two_selmer_rank, gens_mod_two
    14981509
    14991510    two_descent_simon = simon_two_descent
     
    16001611            4
    16011612            sage: EllipticCurve([0, 0, 1, -79, 342]).rank(proof=False)  # long time -- but under a minute
    16021613            5
    1603             sage: EllipticCurve([0, 0, 1, -79, 342]).simon_two_descent()[0]  # much faster -- almost instant.
     1614            sage: EllipticCurve([0, 0, 1, -79, 342]).simon_two_descent(store_gens=0)[0]  # much faster -- almost instant.
    16041615            5
    16051616       
    16061617        Examples with denominators in defining equations::
     
    16721683                    print "curve then trying this command again.  You could also try rank"
    16731684                    print "with only_use_mwrank=False."
    16741685                    del E.__mwrank_curve
    1675                     raise RuntimeError, 'Rank not provably correct.'
     1686                    raise RuntimeError, 'Rank not provably correct.' 
    16761687                else:
    16771688                    misc.verbose("Warning -- rank not proven correct", level=1)
    16781689            self.__rank[proof] = r
  • sage/schemes/elliptic_curves/gp_simon.py

    diff -r 714a9ee90148 -r 402a9b27da64 sage/schemes/elliptic_curves/gp_simon.py
    a b  
    103103    if verbose > 0:
    104104        print s
    105105    v = gp.eval('ans')
     106    if v=='ans': # then the call to ellrank() or bnfellrank() failed
     107        return 'fail'
    106108    if verbose >= 2:
    107109        print "v = ", v
    108110    # pari represents field elements as Mod(poly, defining-poly)