Ticket #11130: 11130-sagelib-simon-v2.patch

File 11130-sagelib-simon-v2.patch, 6.2 KB (added by jdemeyer, 8 years ago)

cremona's patch without the store_gens option and with some minor fixes

  • sage/schemes/elliptic_curves/ell_number_field.py

    # HG changeset patch
    # User John Cremona <john.cremona@gmail.com>
    # Date 1305822334 -3600
    # Node ID 35cda75bc998e963b5a76e791a50a50326a8b113
    # Parent  53c903189fc34b1abee880e2f27f6a7e34ebf844
    #11130: fix doctests for simon_two_descent
    
    diff --git a/sage/schemes/elliptic_curves/ell_number_field.py b/sage/schemes/elliptic_curves/ell_number_field.py
    a b  
    199199           For non-quadratic number fields, this code does return, but
    200200           it takes a long time.
    201201
    202         IMPLEMENTATION:
     202        ALGORITHM:
    203203
    204204        Uses Denis Simon's PARI/GP scripts from
    205205        http://www.math.unicaen.fr/~simon/.
     
    229229            listpointsmwr = [[Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7), 1]]
    230230            (1, 1, [(1/2*a + 3/2 : -a - 2 : 1)])
    231231
    232             sage: v = E.simon_two_descent(verbose=2); v
     232            sage: v = E.simon_two_descent(verbose=2)  # random output
    233233            K = bnfinit(y^2 + 7);
    234234            a = Mod(y,K.pol);
    235235            bnfellrank(K, [0,0,0,1,a]);
     
    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
    242242            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
     
    253260            rang(E/K)     = 1
    254261            listpointsmwr = [[Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7), 1]]
    255262            v =  [1, 1, [[Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7)]]]
     263            sage: v
    256264            (1, 1, [(1/2*a + 3/2 : -a - 2 : 1)])
    257265
    258266
  • sage/schemes/elliptic_curves/ell_rational_field.py

    diff --git a/sage/schemes/elliptic_curves/ell_rational_field.py b/sage/schemes/elliptic_curves/ell_rational_field.py
    a b  
    14551455            sage: E = EllipticCurve('5077a1')
    14561456            sage: set_random_seed(0)
    14571457            sage: E.simon_two_descent()
    1458             (3, 3, [(1 : 0 : 1), (0 : 2 : 1), (2 : -1 : 1)])
     1458            (3, 3, [(1 : -1 : 1), (2 : 0 : 1), (0 : 2 : 1)])
    14591459       
    14601460        In this example Simon's program does not find any points, though it
    14611461        does correctly compute the rank of the 2-Selmer group.
     
    14781478            (4, 4, [(4 : 3 : 1), (5 : -2 : 1), (6 : -1 : 1), (8 : 7 : 1)])
    14791479            sage: E = EllipticCurve([0, 0, 1, -79, 342])
    14801480            sage: set_random_seed(0)
    1481             sage: E.simon_two_descent()
     1481            sage: E.simon_two_descent()  # long time (9s on sage.math, 2011)
    14821482            (5, 5, [(5 : 8 : 1), (4 : 9 : 1), (3 : 11 : 1), (-1 : 20 : 1), (-6 : -25 : 1)])
    14831483            sage: E = EllipticCurve([1, 1, 0, -2582, 48720])
    14841484            sage: set_random_seed(0)
     
    15051505        """
    15061506        t = simon_two_descent(self, verbose=verbose, lim1=lim1, lim3=lim3, limtriv=limtriv,
    15071507                              maxprob=maxprob, limbigprime=limbigprime)
     1508        if t=='fail':
     1509            raise RuntimeError, 'Run-time error in simon_two_descent.'
     1510        if verbose>0:
     1511            print "simon_two_descent returns", t
    15081512        rank_low_bd = rings.Integer(t[0])
    15091513        two_selmer_rank = rings.Integer(t[1])
    15101514        gens_mod_two = [self(P) for P in t[2]]
    15111515        if rank_low_bd == two_selmer_rank - self.two_torsion_rank():
     1516            if verbose>0:
     1517                print "Rank determined successfully, saturating..."
    15121518            gens = [P for P in gens_mod_two if P.has_infinite_order()]
    15131519            gens = self.saturation(gens)[0]
    15141520            self.__gens[True] = gens
  • sage/schemes/elliptic_curves/gp_simon.py

    diff --git a/sage/schemes/elliptic_curves/gp_simon.py b/sage/schemes/elliptic_curves/gp_simon.py
    a b  
    4646    """
    4747    Interface to Simon's gp script for two-descent.
    4848
    49     NOTE:
     49    .. NOTE::
     50
    5051       Users should instead run E.simon_two_descent()
    5152
    52     EXAMPLES:
     53    EXAMPLES::
     54
    5355        sage: import sage.schemes.elliptic_curves.gp_simon
    5456        sage: E=EllipticCurve('389a1')
    5557        sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
     
    5759        sage: E.simon_two_descent()
    5860        (2, 2, [(1 : 0 : 1), (-11/9 : -55/27 : 1)])
    5961   
    60     TESTS:
     62    TESTS::
     63
    6164        sage: E = EllipticCurve('37a1').change_ring(QuadraticField(-11,'x'))
    6265        sage: E.simon_two_descent()
    6366        (1, 1, [(-1 : 0 : 1)])
     
    103106    if verbose > 0:
    104107        print s
    105108    v = gp.eval('ans')
     109    if v=='ans': # then the call to ellrank() or bnfellrank() failed
     110        return 'fail'
    106111    if verbose >= 2:
    107112        print "v = ", v
    108113    # pari represents field elements as Mod(poly, defining-poly)