# HG changeset patch
# User davideklund
# Date 1324125053 -3600
# Node ID 6f1b82ae59dfb1f46806f424bf31f110f58acf60
# Parent 95d49e2ea03b9405b1f2039c8a3277abc325098c
Trac 11800: Ban defining polynomials of degree 2.
diff --git a/sage/schemes/hyperelliptic_curves/constructor.py b/sage/schemes/hyperelliptic_curves/constructor.py
--- a/sage/schemes/hyperelliptic_curves/constructor.py
+++ b/sage/schemes/hyperelliptic_curves/constructor.py
@@ -55,6 +55,14 @@
sage: k. = GF(9); R. = k[]
sage: HyperellipticCurve(x^3 + x - 1, x+a, names=['X','Y'])
Hyperelliptic Curve over Finite Field in a of size 3^2 defined by Y^2 + (X + a)*Y = X^3 + X + 2
+
+ Conics are excluded (the issue reported at #11800 has been resolved)::
+
+ sage: R. = GF(67)[]
+ sage: H = HyperellipticCurve(24*x^2 + 33*x + 43)
+ Traceback (most recent call last):
+ ...
+ ValueError: The equation y^2+hy=f is quadratic, and hence does not correspond to a hyperelliptic curve.
"""
if (not is_Polynomial(f)) or f == 0:
raise TypeError, "Arguments f (=%s) and h (= %s) must be polynomials and f must be non-zero"%(f,h)
@@ -67,7 +75,11 @@
raise TypeError, \
"Arguments f (=%s) and h (= %s) must be polynomials in the same ring"%(f,h)
df = f.degree()
- dh_2 = 2*h.degree()
+ dh = h.degree()
+ if df <= 2 and dh <= 1:
+ raise ValueError("The equation y^2+hy=f is quadratic, and hence "
+ "does not correspond to a hyperelliptic curve.")
+ dh_2 = 2*dh
if dh_2 < df:
g = (df-1)//2
else: