Skip to content

Commit a822a21

Browse files
author
Release Manager
committed
gh-35035: make _multiple_x_*() methods work for all n≠0 Currently, these methods expect $n\geq2$ for no real reason. This patch makes them work for all $n\neq0$. URL: #35035 Reported by: Lorenz Panny Reviewer(s): John Cremona
2 parents 0847642 + c55d7d6 commit a822a21

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/sage/schemes/elliptic_curves/ell_generic.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,14 @@ def _multiple_x_numerator(self, n, x=None):
19911991
19921992
EXAMPLES::
19931993
1994+
sage: E = EllipticCurve([1,2])
1995+
sage: E._multiple_x_numerator(3)
1996+
x^9 - 12*x^7 - 192*x^6 + 30*x^5 - 48*x^4 + 228*x^3 + 96*x^2 + 393*x + 528
1997+
sage: E._multiple_x_numerator(-3)
1998+
x^9 - 12*x^7 - 192*x^6 + 30*x^5 - 48*x^4 + 228*x^3 + 96*x^2 + 393*x + 528
1999+
2000+
::
2001+
19942002
sage: E = EllipticCurve("37a")
19952003
sage: P = E.gens()[0]
19962004
sage: x = P[0]
@@ -2043,9 +2051,9 @@ def _multiple_x_numerator(self, n, x=None):
20432051
sage: E._multiple_x_numerator(5)
20442052
x^25 + 65037*x^23 + 55137*x^22 + ... + 813*x^2 + 10220*x + 42539
20452053
"""
2046-
n = rings.Integer(n)
2047-
if n < 2:
2048-
raise ValueError("n must be at least 2")
2054+
n = rings.Integer(n).abs()
2055+
if not n:
2056+
raise ValueError("n must be nonzero")
20492057

20502058
if x is None:
20512059
try:
@@ -2061,6 +2069,9 @@ def _multiple_x_numerator(self, n, x=None):
20612069
cache = None
20622070
xx = x
20632071

2072+
if n == 1:
2073+
return xx
2074+
20642075
polys = self.division_polynomial_0([-2,-1,n-1,n,n+1], x)
20652076

20662077
if n % 2 == 0:
@@ -2101,6 +2112,14 @@ def _multiple_x_denominator(self, n, x=None):
21012112
21022113
EXAMPLES::
21032114
2115+
sage: E = EllipticCurve([1,2])
2116+
sage: E._multiple_x_denominator(3)
2117+
9*x^8 + 36*x^6 + 144*x^5 + 30*x^4 + 288*x^3 + 564*x^2 - 48*x + 1
2118+
sage: E._multiple_x_denominator(-3)
2119+
9*x^8 + 36*x^6 + 144*x^5 + 30*x^4 + 288*x^3 + 564*x^2 - 48*x + 1
2120+
2121+
::
2122+
21042123
sage: E = EllipticCurve("43a")
21052124
sage: P = E.gens()[0]
21062125
sage: x = P[0]
@@ -2128,9 +2147,9 @@ def _multiple_x_denominator(self, n, x=None):
21282147
sage: E._multiple_x_denominator(5)
21292148
25*x^24 + 3100*x^22 + 19000*x^21 + ... + 24111*x^2 + 52039*x + 56726
21302149
"""
2131-
n = rings.Integer(n)
2132-
if n < 2:
2133-
raise ValueError("n must be at least 2")
2150+
n = rings.Integer(n).abs()
2151+
if not n:
2152+
raise ValueError("n must be nonzero")
21342153

21352154
if x is None:
21362155
try:

0 commit comments

Comments
 (0)