Ticket #3674: sage-trac3674new-extra5.patch

File sage-trac3674new-extra5.patch, 5.1 KB (added by cremona, 9 years ago)
  • sage/schemes/elliptic_curves/ell_rational_field.py

    # HG changeset patch
    # User John Cremona <john.cremona@gmail.com>
    # Date 1218566278 -3600
    # Node ID d1f50c27f88c02b8f539addffe8c43bf0e207424
    # Parent  42f537045600495fa2adb630834e1ff70b55da46
    Further tuning
    
    diff -r 42f537045600 -r d1f50c27f88c sage/schemes/elliptic_curves/ell_rational_field.py
    a b  
    37983798            e1,e2,e3:  -3.01243037259331 1.06582054769620 1.94660982489710
    37993799            Minimal eigenvalue of height pairing matrix:  0.472730555831538
    38003800            x-coords of points on compact component with  -3 <=x<= 1
    3801             set([0, -1, -3, -2, 1])
     3801            [-3, -2, -1, 0, 1]
    38023802            x-coords of points on non-compact component with  2 <=x<= 6
    3803             set([2, 3, 4])
     3803            [2, 3, 4]
    38043804            starting search of remaining points using coefficient bound  6
    38053805            x-coords of extra integral points:
    3806             set([2, 3, 4, 37, 406, 8, 11, 14, 816, 52, 21, 342, 93])
     3806            [2, 3, 4, 8, 11, 14, 21, 37, 52, 93, 342, 406, 816]
    38073807            Total number of integral points: 18
    38083808
    38093809        It is also possible to not specify mw_base, but then the
     
    39303930                    use_t(P)
    39313931                return xs
    39323932           
    3933             # Otherwise is is very very much faster to first compute
    3934             # the linear combinations over RR, and only compte them as
    3935             # rational points if they are approximately integral
     3933            # Otherwise it is very very much faster to first compute
     3934            # the linear combinations over RR, and only compute them as
     3935            # rational points if they are approximately integral.
     3936
     3937            # Note: making eps larger here will dramatically increase
     3938            # the running time.  If evidence arises that integral
     3939            # points are being missed, it would be better to increase
     3940            # the real precision than to increase eps.
    39363941
    39373942            def is_approx_integral(P):
    3938                 return (abs(P[0]-P[0].round()))<0.1 #one case was 0.09, so 0.001 was too small
    3939            
    3940             RR = RealField() #(100)
     3943                eps = 0.0001
     3944                return (abs(P[0]-P[0].round()))<eps and (abs(P[1]-P[1].round()))<eps
     3945           
     3946            RR = RealField(100) #(100)
    39413947            ER = self.change_ring(RR)
     3948
     3949# Note: doing [ER(P) for P in mw_base] sometimes fails.  This way is
     3950# harder since we have to make sure we don't use -P instead of P, but
     3951# is safer.
     3952
    39423953            Rgens = [ER.lift_x(P[0]) for P in mw_base]
    39433954            for i in range(r):
    39443955                if abs(Rgens[i][1]-mw_base[i][1])>abs((-Rgens[i])[1]-mw_base[i][1]):
    39453956                    Rgens[i] = -Rgens[i]
    3946             #for ni in cartesian_product_iterator([range(-N,N+1) for i in range(r-1)]+[range(N+1)]): ##opt1
    3947             for mi in range(ceil(((2*H_q+1)**r)/2)): ##opt2
    3948                 ni = Z(mi).digits(base=2*H_q+1, padto=r, digits=range(-H_q, H_q+1)) ##opt2
     3957
     3958            # the ni loop through all tuples (a1,a2,...,ar) with
     3959            # |ai|<=N, but we stop immediately after using the tuple
     3960            # (0,0,...,0).
     3961
     3962            for ni in cartesian_product_iterator([range(-N,N+1) for i in range(r)]): ##opt1
     3963
     3964#  Alternative version not using the fancy iterator:
     3965#            for mi in range(ceil(((2*H_q+1)**r)/2)): ##opt2
     3966#                ni = Z(mi).digits(base=2*H_q+1, padto=r, digits=range(-H_q, H_q+1)) ##opt2
     3967
     3968                if all([n==0 for n in ni]):
     3969                    use_t(self(0))
     3970                    break
    39493971                RP=sum([ni[i]*Rgens[i] for i in range(r)],ER(0))
    39503972                for T in tors_points:
    39513973                    if is_approx_integral(RP+ER(T)):
     
    41584180            x_int_points = integral_x_coords_in_interval(ceil(e1-b2_12), floor(e2-b2_12)+1)
    41594181            if verbose:
    41604182                print 'x-coords of points on compact component with ',ceil(e1-b2_12),'<=x<=',floor(e2-b2_12)
    4161                 print x_int_points
     4183                L = list(x_int_points) # to have the order
     4184                L.sort()               # deterministic for doctests!
     4185                print L
    41624186        else:
    41634187            x_int_points = set()
    41644188           
     
    41694193        x_int_points = x_int_points.union(x_int_points2)
    41704194        if verbose:
    41714195            print 'x-coords of points on non-compact component with ',x0,'<=x<=',x1-1
    4172             print x_int_points2
     4196            L = list(x_int_points2)
     4197            L.sort()
     4198            print L
    41734199       
    41744200        if verbose:
    41754201            print 'starting search of remaining points using coefficient bound ',H_q
     
    41774203        x_int_points = x_int_points.union(x_int_points3)
    41784204        if verbose:
    41794205            print 'x-coords of extra integral points:'
    4180             print x_int_points3
     4206            L = list(x_int_points3)
     4207            L.sort()
     4208            print L
    41814209
    41824210        # Now we have all the x-coordinates of integral points, and we
    41834211        # construct the points, depending on the parameter both_signs: