# 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


3798  3798  e1,e2,e3: 3.01243037259331 1.06582054769620 1.94660982489710 
3799  3799  Minimal eigenvalue of height pairing matrix: 0.472730555831538 
3800  3800  xcoords of points on compact component with 3 <=x<= 1 
3801   set([0, 1, 3, 2, 1]) 
 3801  [3, 2, 1, 0, 1] 
3802  3802  xcoords of points on noncompact component with 2 <=x<= 6 
3803   set([2, 3, 4]) 
 3803  [2, 3, 4] 
3804  3804  starting search of remaining points using coefficient bound 6 
3805  3805  xcoords 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] 
3807  3807  Total number of integral points: 18 
3808  3808  
3809  3809  It is also possible to not specify mw_base, but then the 
… 
… 

3930  3930  use_t(P) 
3931  3931  return xs 
3932  3932  
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. 
3936  3941  
3937  3942  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) 
3941  3947  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  
3942  3953  Rgens = [ER.lift_x(P[0]) for P in mw_base] 
3943  3954  for i in range(r): 
3944  3955  if abs(Rgens[i][1]mw_base[i][1])>abs((Rgens[i])[1]mw_base[i][1]): 
3945  3956  Rgens[i] = Rgens[i] 
3946   #for ni in cartesian_product_iterator([range(N,N+1) for i in range(r1)]+[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 
3949  3971  RP=sum([ni[i]*Rgens[i] for i in range(r)],ER(0)) 
3950  3972  for T in tors_points: 
3951  3973  if is_approx_integral(RP+ER(T)): 
… 
… 

4158  4180  x_int_points = integral_x_coords_in_interval(ceil(e1b2_12), floor(e2b2_12)+1) 
4159  4181  if verbose: 
4160  4182  print 'xcoords of points on compact component with ',ceil(e1b2_12),'<=x<=',floor(e2b2_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 
4162  4186  else: 
4163  4187  x_int_points = set() 
4164  4188  
… 
… 

4169  4193  x_int_points = x_int_points.union(x_int_points2) 
4170  4194  if verbose: 
4171  4195  print 'xcoords of points on noncompact component with ',x0,'<=x<=',x11 
4172   print x_int_points2 
 4196  L = list(x_int_points2) 
 4197  L.sort() 
 4198  print L 
4173  4199  
4174  4200  if verbose: 
4175  4201  print 'starting search of remaining points using coefficient bound ',H_q 
… 
… 

4177  4203  x_int_points = x_int_points.union(x_int_points3) 
4178  4204  if verbose: 
4179  4205  print 'xcoords of extra integral points:' 
4180   print x_int_points3 
 4206  L = list(x_int_points3) 
 4207  L.sort() 
 4208  print L 
4181  4209  
4182  4210  # Now we have all the xcoordinates of integral points, and we 
4183  4211  # construct the points, depending on the parameter both_signs: 