isogeny_class for EC_NumberField sometimes raises errors

54 views
Skip to first unread message

Barinder Banwait

unread,
Jul 12, 2022, 11:19:09 AM7/12/22
to sage-devel
Dear sage-devel,

I am running into an issue with computing isogeny classes of elliptic curves over number fields.

Here is what I entered:

K.<a> = QuadraticField(4569)
myJ = 46969655/32768
E = EllipticCurve(j=K(myJ))
C = E.isogeny_class()

This raises a KeyError in the first instance, which seems to be handled via a direct call to IsogenyClass_EC_NumberField, but this then raises a ValueError: Cannot convert infinity or NaN to Sage Integer. The full stack trace is in the PS.

This error has occurred on sage-9.4 on a system whose `uname -a` is `Linux LEGENDRE 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux`, as well as on sage-9.7-beta5 on `Linux Barinder 5.4.0-121-generic #137-Ubuntu SMP Wed Jun 15 13:33:07 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux`.

Changing the field K to many other quadratic fields does not yield any error. However I did also notice this error with many j-invariants in QuadraticField(6537), so it somehow seems to be base-field dependent.

Best wishes,
Barinder

PS. Full traceback:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/structure/category_object.pyx in sage.structure.category_object.CategoryObject.getattr_from_category (build/cythonized/sage/structure/category_object.c:7074)()
    838         try:
--> 839             return self.__cached_methods[name]
    840         except KeyError:

KeyError: '_isoclass'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_number_field.py in isogeny_class(self, reducible_primes, algorithm, minimal_models)
   3007         try:
-> 3008             return self._isoclass
   3009         except AttributeError:

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/structure/category_object.pyx in sage.structure.category_object.CategoryObject.__getattr__ (build/cythonized/sage/structure/category_object.c:6993)()
    832         """
--> 833         return self.getattr_from_category(name)
    834

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/structure/category_object.pyx in sage.structure.category_object.CategoryObject.getattr_from_category (build/cythonized/sage/structure/category_object.c:7159)()
    847
--> 848             attr = getattr_from_other_class(self, cls, name)
    849             self.__cached_methods[name] = attr

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/cpython/getattr.pyx in sage.cpython.getattr.getattr_from_other_class (build/cythonized/sage/cpython/getattr.c:2552)()
    366         dummy_error_message.name = name
--> 367         raise AttributeError(dummy_error_message)
    368     cdef PyObject* attr = instance_getattr(cls, name)

AttributeError: 'sage.sets.pythonclass.Set_PythonType_class' object has no attribute '_Hom_'

During handling of the above exception, another exception occurred:

ValueError                                Traceback (most recent call last)
<ipython-input-1-a9c20a51d066> in <module>
      2 myJ = Integer(46969655)/Integer(32768)
      3 E = EllipticCurve(j=K(myJ))
----> 4 C = E.isogeny_class()

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_number_field.py in isogeny_class(self, reducible_primes, algorithm, minimal_models)
   3009         except AttributeError:
   3010             from sage.schemes.elliptic_curves.isogeny_class import IsogenyClass_EC_NumberField
-> 3011             self._isoclass = IsogenyClass_EC_NumberField(self, reducible_primes=reducible_primes, algorithm=algorithm, minimal_models=minimal_models)
   3012             return self._isoclass
   3013

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/isogeny_class.py in __init__(self, E, reducible_primes, algorithm, minimal_models)
    705         self._algorithm = algorithm
    706         self._minimal_models = minimal_models
--> 707         IsogenyClass_EC.__init__(self, E, label=None, empty=False)
    708
    709     def copy(self):

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/isogeny_class.py in __init__(self, E, label, empty)
     68         self._label = label
     69         if not empty:
---> 70             self._compute()
     71
     72     def __len__(self):

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/isogeny_class.py in _compute(self, verbose)
    789             sys.stdout.write(" possible isogeny degrees: %s" % degs)
    790             sys.stdout.flush()
--> 791         isogenies = E.isogenies_prime_degree(degs, minimal_models=self._minimal_models)
    792         if verbose:
    793             sys.stdout.write(" -actual isogeny degrees: %s" % Set(phi.degree() for phi in isogenies))

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_number_field.py in isogenies_prime_degree(self, l, algorithm, minimal_models)
   3108             return self.isogenies_prime_degree(L, minimal_models=minimal_models)
   3109
-> 3110         isogs = sum([self.isogenies_prime_degree(p, minimal_models=minimal_models) for p in l],
   3111                     [])
   3112

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_number_field.py in <listcomp>(.0)
   3108             return self.isogenies_prime_degree(L, minimal_models=minimal_models)
   3109
-> 3110         isogs = sum([self.isogenies_prime_degree(p, minimal_models=minimal_models) for p in l],
   3111                     [])
   3112

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_number_field.py in isogenies_prime_degree(self, l, algorithm, minimal_models)
   3097             try:
   3098                 if l.is_prime(proof=False):
-> 3099                     return isogenies_prime_degree(self, l, minimal_models=minimal_models)
   3100                 else:
   3101                     raise ValueError("%s is not prime." % l)

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/isogeny_small_degree.py in isogenies_prime_degree(E, l, minimal_models)
   2340         return isogenies_2(E, minimal_models=minimal_models)
   2341     if l==3:
-> 2342         return isogenies_3(E, minimal_models=minimal_models)
   2343
   2344     p = E.base_ring().characteristic()

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/isogeny_small_degree.py in isogenies_3(E, minimal_models)
    754     from sage.rings.number_field.number_field_base import is_NumberField
    755     model = "minimal" if minimal_models and is_NumberField(E.base_field()) else None
--> 756     isogs = [E.isogeny(f, model=model) for f in ff]
    757     return isogs
    758

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/isogeny_small_degree.py in <listcomp>(.0)
    754     from sage.rings.number_field.number_field_base import is_NumberField
    755     model = "minimal" if minimal_models and is_NumberField(E.base_field()) else None
--> 756     isogs = [E.isogeny(f, model=model) for f in ff]
    757     return isogs
    758

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_field.py in isogeny(self, kernel, codomain, degree, model, check)
    876         """
    877         try:
--> 878             return EllipticCurveIsogeny(self, kernel, codomain, degree, model, check=check)
    879         except AttributeError as e:
    880             raise RuntimeError("Unable to construct isogeny: %s" % e)

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_curve_isogeny.py in __init__(self, E, kernel, codomain, degree, model, check)
   1015         self.__compute_E2()
   1016
-> 1017         self.__setup_post_isomorphism(codomain, model)
   1018
   1019         if (pre_isom is not None):

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_curve_isogeny.py in __setup_post_isomorphism(self, codomain, model)
   1800                     raise ValueError("specifying minimal for model flag only valid with curves over number fields.")
   1801
-> 1802                 newE2 = oldE2.global_minimal_model(semi_global=True)
   1803                 post_isom = oldE2.isomorphism_to(newE2)
   1804

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_number_field.py in global_minimal_model(self, proof, semi_global)
   2042                 from .kraus import semi_global_minimal_model
   2043                 E, P = semi_global_minimal_model(self)
-> 2044             return E._scale_by_units()._reduce_model()
   2045
   2046         raise ValueError("%s has no global minimal model!  For a semi-global minimal model use semi_global=True" % self)

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_number_field.py in _scale_by_units(self)
    987         from sage.modules.all import vector
    988         v = vector([(x4.abs().nth_root(4)+x6.abs().nth_root(6)).log()*d for x4,x6,d in zip(c4s,c6s,degs)])
--> 989         es = [e.round() for e in -Ainv*U*v]
    990         u = prod([uj**ej for uj,ej in zip(fu,es)])
    991         return self.scale_curve(u)

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_number_field.py in <listcomp>(.0)
    987         from sage.modules.all import vector
    988         v = vector([(x4.abs().nth_root(4)+x6.abs().nth_root(6)).log()*d for x4,x6,d in zip(c4s,c6s,degs)])
--> 989         es = [e.round() for e in -Ainv*U*v]
    990         u = prod([uj**ej for uj,ej in zip(fu,es)])
    991         return self.scale_curve(u)

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/rings/real_mpfr.pyx in sage.rings.real_mpfr.RealNumber.round (build/cythonized/sage/rings/real_mpfr.c:22391)()
   3015         cdef RealNumber x = self._new()
   3016         mpfr_round(x.value, self.value)
-> 3017         return x.integer_part()
   3018
   3019     def floor(self):

/scratch/sage/sage-9.4/local/lib/python3.8/site-packages/sage/rings/real_mpfr.pyx in sage.rings.real_mpfr.RealNumber.integer_part (build/cythonized/sage/rings/real_mpfr.c:17420)()
   2256         """
   2257         if not mpfr_number_p(self.value):
-> 2258             raise ValueError('Cannot convert infinity or NaN to Sage Integer')
   2259
   2260         cdef Integer z = Integer()

ValueError: Cannot convert infinity or NaN to Sage Integer

John Cremona

unread,
Jul 12, 2022, 12:11:19 PM7/12/22
to SAGE devel
Barinder, I'll look into this (tomorrow) -- it's my code. Please open
a ticket and CC me. It's happening in the code to reduce a model with
respect to scaling by units.

John
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/6220eeaf-6fa3-450f-883b-4932f0cd2d74n%40googlegroups.com.

Barinder Banwait

unread,
Jul 12, 2022, 2:41:43 PM7/12/22
to sage-devel
Thanks John -- ticket raised here: https://trac.sagemath.org/ticket/34174#ticket

John Cremona

unread,
Jul 13, 2022, 3:59:09 AM7/13/22
to SAGE devel
On Tue, 12 Jul 2022 at 19:41, Barinder Banwait <b.s.ba...@gmail.com> wrote:
>
> Thanks John -- ticket raised here: https://trac.sagemath.org/ticket/34174#ticket

As a workaround, you can do two things (which will not be necessary
after I have finished with that ticket):
(1) replace E by E.integral_model(), or (better)
E.global_minimal_model(semi_global=True) before computing the isogeny
class
(2) use minimal_models=False in calling the isogeny_class() method.

The problem with this specific quadratic field is that the fundamental
unit has one very small conjugate.

Further discussions can be on ticket 34174.

John
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/f2dccd25-13fb-4de8-aad7-e0ef32895368n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages