Ticket #11800: trac_11800_ban_degree_two.patch

File trac_11800_ban_degree_two.patch, 2.1 KB (added by davideklund, 8 years ago)

The patch bans defining polynomials of degree two for hyperelliptic curves, and corrects two typos.

  • sage/schemes/hyperelliptic_curves/constructor.py

    # HG changeset patch
    # User davideklund <daek@kth.se>
    # Date 1324125053 -3600
    # Node ID c369c262e668bea81d320973be8f64340088a0cf
    # Parent  2a2abbcad325ccca9399981ceddf5897eb467e64
    Trac 11800: Ban defining polynomials of degree 2.
    
    diff -r 2a2abbcad325 -r c369c262e668 sage/schemes/hyperelliptic_curves/constructor.py
    a b  
    5555        sage: k.<a> = GF(9); R.<x> = k[]   
    5656        sage: HyperellipticCurve(x^3 + x - 1, x+a, names=['X','Y'])
    5757        Hyperelliptic Curve over Finite Field in a of size 3^2 defined by Y^2 + (X + a)*Y = X^3 + X + 2
     58
     59    Conics are excluded (the issue reported at #11800 has been resolved)::
     60
     61        sage: R.<x> = GF(67)[]
     62        sage: H = HyperellipticCurve(24*x^2 + 33*x + 43)
     63        Traceback (most recent call last):
     64        ...
     65        ValueError: The equation y^2+hy=f is quadratic, and hence does not correspond to a hyperelliptic curve.
    5866    """
    5967    if not is_Polynomial(f):
    6068        raise TypeError, "Arguments f (=%s) and h (= %s) must be polynomials"%(f,h)
     
    6876        raise TypeError, \
    6977              "Arguments f (=%s) and h (= %s) must be polynomials in the same ring"%(f,h)
    7078    df = f.degree()
    71     dh_2 = 2*h.degree()
     79    dh = h.degree()
     80    if df <= 2 and dh <= 1:
     81        raise ValueError("The equation y^2+hy=f is quadratic, and hence "
     82                         "does not correspond to a hyperelliptic curve.")
     83    dh_2 = 2*dh
    7284    if dh_2 < df:
    7385        g = (df-1)//2
    7486    elif df < dh_2:
     
    7688    else:
    7789        a0 = f.leading_coefficient()
    7890        b0 = h.leading_coefficient()
    79         A0 = 4*a0 + b0^2
     91        A0 = 4*a0 + b0**2
    8092        if A0 != 0:
    8193            g = (df-1)//2
    8294        else:
    8395            if P(2) == 0:
    8496                raise TypeError, "Arguments define a curve with finite singularity."
    85             f0 = 4*f + h^2
     97            f0 = 4*f + h**2
    8698            d0 = f0.degree()
    8799            g = (d0-1)//2
    88100    R = P.base_ring()