# HG changeset patch
# User Marco Streng <marco.streng@gmail.com>
# Date 1332017412 0
# Node ID 2098beb80393878b4cb3d903b9f1fbd5ed233350
# Parent d2397c4ac9d76b005de2a517a819799c07a46777
Trac 11800: points at infinity for hyperelliptic curves
diff git a/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py b/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py
a

b


218  218  points.append(self.point([K(1), s/r, K(0)], check=True)) 
219  219  # the case r = 0 need not be considered 
220  220  elif K.characteristic() == 2: # deg(P) = 2 and char(K) = 2 
221   # quadratic equation doesn't work in characteristic 2 so use brute force 
222   points += [self.point([K(1), y, K(0)], check=True) for y in K if not P(K(1), y, K(0))] 
 221  # quadratic equation doesn't work in characteristic 2 so use brute 
 222  # force 
 223  points += [self.point([K(1), y, K(0)], check=True) for y in K \ 
 224  if not P(K(1), y, K(0))] 
223  225  else: # deg(P) = 2 and char(K) not 2 
224  226  # P(1, y, 0) = y^2 + r*y + s 
225   if f.degree() < 2: 
226   s = 0 
227   else: 
228   s = f.coeffs()[1] 
229   if h.degree() < 1: 
230   r = 0 
231   else: 
232   r = h.coeffs()[1] 
 227  s = f[2] 
 228  r = h[1] 
233  229  d = r**2/4  s 
234  230  if not d: # d = 0 
235  231  points.append(self.point([K(1), r/2, K(0)], check=True)) 
236  232  elif d.is_square(): 
237  233  sqrtd = d.sqrt() 
238   points.append(self.point([K(1), r/2 + sqrtd, K(0)], check=True)) 
239   points.append(self.point([K(1), r/2  sqrtd, K(0)], check=True)) 
 234  points.append(self.point([K(1), r/2+sqrtd, K(0)], check=True)) 
 235  points.append(self.point([K(1), r/2sqrtd, K(0)], check=True)) 
240  236  
241  237  if K.characteristic() == 2: 
242  238  # quadratic equation doesn't work in characteristic 2 
… 
… 

326  322  points.append(self.point([K(1), s/r, K(0)], check=True)) 
327  323  # the case r = 0 need not be considered 
328  324  elif K.characteristic() == 2: # deg(P) = 2 and char(K) = 2 
329   # quadratic equation doesn't work in characteristic 2 so use brute force 
330   points += [self.point([K(1), y, K(0)], check=True) for y in K if not P(K(1), y, K(0))] 
 325  # quadratic equation doesn't work in characteristic 2 so use brute 
 326  # force 
 327  points += [self.point([K(1), y, K(0)], check=True) for y in K \ 
 328  if not P(K(1), y, K(0))] 
331  329  else: # deg(P) = 2 and char(K) not 2 
332  330  # P(1, y, 0) = y^2 + r*y + s 
333   if f.degree() < 2: 
334   s = 0 
335   else: 
336   s = f.coeffs()[1] 
337   if h.degree() < 1: 
338   r = 0 
339   else: 
340   r = h.coeffs()[1] 
 331  s = f[2] 
 332  r = h[1] 
341  333  d = r**2/4  s 
342  334  sqrtd = square_roots[d] 
343  335  if not d: # d = 0 
344  336  points.append(self.point([K(1), r/2, K(0)], check=True)) 
345  337  elif sqrtd is not None: 
346   points.append(self.point([K(1), r/2 + sqrtd, K(0)], check=True)) 
347   points.append(self.point([K(1), r/2  sqrtd, K(0)], check=True)) 
 338  points.append(self.point([K(1), r/2+sqrtd, K(0)], check=True)) 
 339  points.append(self.point([K(1), r/2sqrtd, K(0)], check=True)) 
348  340  
349  341  if K.characteristic() == 2 or brute_force: 
350  342  # quadratic equation doesn't work in characteristic 2 
… 
… 

401  393  sage: H.points() 
402  394  [(0 : 6 : 1), (0 : 1 : 1), (1 : 4 : 1), (1 : 3 : 1), (2 : 4 : 1), (2 : 3 : 1), (3 : 6 : 1), (3 : 1 : 1)] 
403  395  
404   The method currently lists points on the plane projective model, that is the closure 
405   in $\mathbb{P}^2$ of the curve defined by $y^2+hy=f$. This means that one point 
406   $(0:1:0)$ at infinity is returned if the degree of the curve is at least 4 and 
407   $\deg(f)>\deg(h)+1$. This point is a singular point of the plane model. Later 
408   implementations may consider a smooth model instead since that would be a more 
409   relevant object. Then, for a curve whose only singularity is at $(0:1:0)$, the point 
410   at infinity would be replaced by a number of rational points of the smooth model. 
411   We illustrate this with an example of a genus 2 hyperelliptic curve:: 
 396  The method currently lists points on the plane projective model, that 
 397  is the closure in $\mathbb{P}^2$ of the curve defined by $y^2+hy=f$. 
 398  This means that one point $(0:1:0)$ at infinity is returned if the 
 399  degree of the curve is at least 4 and $\deg(f)>\deg(h)+1$. This point 
 400  is a singular point of the plane model. Later implementations may 
 401  consider a smooth model instead since that would be a more relevant 
 402  object. Then, for a curve whose only singularity is at $(0:1:0)$, the 
 403  point at infinity would be replaced by a number of rational points of 
 404  the smooth model. We illustrate this with an example of a genus 2 
 405  hyperelliptic curve:: 
412  406  
413  407  sage: R.<x>=GF(11)[] 
414  408  sage: H = HyperellipticCurve(x*(x+1)*(x+2)*(x+3)*(x+4)*(x+5)) 
415  409  sage: H.points() 
416  410  [(0 : 1 : 0), (0 : 0 : 1), (1 : 7 : 1), (1 : 4 : 1), (5 : 7 : 1), (5 : 4 : 1), (6 : 0 : 1), (7 : 0 : 1), (8 : 0 : 1), (9 : 0 : 1), (10 : 0 : 1)] 
417  411  
418   The plane model of the genus 2 hyperelliptic curve in the above example is the curve 
419   in $\mathbb{P}^2$ defined by $y^2z^4=g(x,z)$ where $g(x,z)=x(x+z)(x+2z)(x+3z)(x+4z)(x+5z).$ 
420   This model has one point at infinity $(0:1:0)$ which is also the only singular point of the 
421   plane model. In contrast, the hyperelliptic curve is smooth and imbeds via the equation 
422   $y^2=g(x,z)$ into weighted projected space $\mathbb{P}(1,3,1)$. The latter model has two 
423   points at infinity: $(1:1:0)$ and $(1:1:0)$. 
 412  The plane model of the genus 2 hyperelliptic curve in the above example 
 413  is the curve in $\mathbb{P}^2$ defined by $y^2z^4=g(x,z)$ where 
 414  $g(x,z)=x(x+z)(x+2z)(x+3z)(x+4z)(x+5z).$ This model has one point at 
 415  infinity $(0:1:0)$ which is also the only singular point of the plane 
 416  model. In contrast, the hyperelliptic curve is smooth and imbeds via 
 417  the equation $y^2=g(x,z)$ into weighted projected space 
 418  $\mathbb{P}(1,3,1)$. The latter model has two points at infinity: 
 419  $(1:1:0)$ and $(1:1:0)$. 
424  420  """ 
425  421  from sage.rings.finite_rings.constructor import zech_log_bound 
426  422  try: 