Skip to content

Commit 2c761b1

Browse files
committed
Fix bug in classical_modular_polynomial; PR #37094
1 parent 439065e commit 2c761b1

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/sage/schemes/elliptic_curves/mod_poly.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ def classical_modular_polynomial(l, j=None):
8787
sage: Y = polygen(parent(j), 'Y')
8888
sage: classical_modular_polynomial(l,j) == classical_modular_polynomial(l)(j,Y)
8989
True
90+
sage: p = 2^216 * 3^137 - 1
91+
sage: F.<i> = GF(p^2, modulus=[1,0,1])
92+
sage: l = random_prime(50)
93+
sage: j = F.random_element()
94+
sage: Y = polygen(parent(j), 'Y')
95+
sage: classical_modular_polynomial(l,j) == classical_modular_polynomial(l)(j,Y)
96+
True
97+
sage: E = EllipticCurve(F, [0, 6, 0, 1, 0])
98+
sage: j = E.j_invariant()
99+
sage: classical_modular_polynomial(l,j) == classical_modular_polynomial(l)(j,Y)
100+
True
101+
sage: R.<Y> = QQ['Y']
102+
sage: j = QQ(1/2)
103+
sage: classical_modular_polynomial(l, j) == classical_modular_polynomial(l)(j, Y)
104+
True
90105
"""
91106
l = ZZ(l)
92107

@@ -133,12 +148,14 @@ def classical_modular_polynomial(l, j=None):
133148
# Now try to get the instantiated modular polynomial directly from PARI.
134149
# This should be slightly more efficient (in particular regarding memory
135150
# usage) than computing and evaluating the generic modular polynomial.
151+
# This currently only works if we are over Z/nZ.
136152
try:
137153
pari_Phi = pari.polmodular(l, 0, j)
154+
return R(pari_Phi)
138155
except PariError:
139156
pass
140-
else:
141-
return R(pari_Phi)
157+
except TypeError:
158+
return R(ZZ['Y'](pari_Phi))
142159

143160
# Nothing worked. Fall back to computing the generic modular polynomial
144161
# and simply evaluating it.

0 commit comments

Comments
 (0)