Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generalize EllipticCurve_field.division_field() to composite orders #35936

Conversation

yyyyx4
Copy link
Member

@yyyyx4 yyyyx4 commented Jul 12, 2023

The .division_field() method is currently restricted to prime orders for no serious reason. This patch makes it work for composite orders, generalizing an observation of @JohnCremona in the process.

Note: I'm not sure if this is the optimal approach. I also played around with building the extension as a tower corresponding to the factorization of $n$, but (at least in Sage) it seemed significantly slower than the version here.

Fixes #24340.

@yyyyx4 yyyyx4 force-pushed the public/generalize_elliptic_curve_division_field_to_composite_orders branch 2 times, most recently from 7266f83 to bb9dc2a Compare July 14, 2023 14:06
@yyyyx4 yyyyx4 requested a review from JohnCremona July 15, 2023 09:55
@JohnCremona
Copy link
Member

I am looking at this now...

Copy link
Member

@JohnCremona JohnCremona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me -- makes me wonder why Jeroen Demeyer only did the special case originally.

In particular, I like the new version of "my" theorem from back in 2014, and I agree with the formula for the order of GL(2,Z/l^e).

@vbraun
Copy link
Member

vbraun commented Jul 26, 2023

Merge conflict

@yyyyx4 yyyyx4 force-pushed the public/generalize_elliptic_curve_division_field_to_composite_orders branch from bb9dc2a to 1371efb Compare July 30, 2023 20:50
@yyyyx4
Copy link
Member Author

yyyyx4 commented Jul 30, 2023

Trivial rebase.

@JohnCremona
Copy link
Member

As far as I can see the Build & test failures are nothing to do with this PR.

@vbraun
Copy link
Member

vbraun commented Aug 3, 2023

On 32-bit:

**********************************************************************
File "src/sage/schemes/elliptic_curves/ell_field.py", line 960, in sage.schemes.elliptic_curves.ell_field.EllipticCurve_field.division_field
Failed example:
    L,emb = E.division_field(6, names='b', map=True); L
Expected:
    Number Field in b with defining polynomial x^24 + 12*x^23 + 66*x^22 - 504*x^21 + 92415*x^20 + 1372020*x^19 + 9791248*x^18 + 9161712*x^17 + 2248687014*x^16 + 39282444252*x^15 + 319379172870*x^14 + 1647604458936*x^13 + 6124888492503*x^12 + 17596271352348*x^11 + 40654930682496*x^10 + 76552797892176*x^9 + 116296878586974*x^8 + 139157022368196*x^7 + 127681305928690*x^6 + 87539428627680*x^5 + 43598049444279*x^4 + 15182945758692*x^3 + 3479289119772*x^2 + 468890060424*x + 28234163953
Got:
    Number Field in b with defining polynomial x^24 + 12*x^23 + 60*x^22 - 748*x^21 + 88770*x^20 + 1180044*x^19 + 8551940*x^18 - 708228*x^17 + 2284255983*x^16 + 32115364424*x^15 + 203444451120*x^14 + 822405799992*x^13 + 2424523350052*x^12 + 5377339210008*x^11 + 8644132255008*x^10 + 8848231490680*x^9 + 2752472816535*x^8 - 6580645409556*x^7 - 8282520603340*x^6 + 4765765122900*x^5 + 23260329950922*x^4 + 29928476880028*x^3 + 20978490720540*x^2 + 8228002291692*x + 1453615904761
**********************************************************************

@JohnCremona
Copy link
Member

Does the automatic testing inclde 32-bit testing? I hope so. I'll be happy with this once tests pass (and I know that I said that before the necessary fix in 560bf2a).

Copy link

Documentation preview for this PR (built with commit dfd4aa5; changes) is ready! 🎉

@yyyyx4
Copy link
Member Author

yyyyx4 commented Nov 12, 2023

I don't think it does, but from experience it looks like @vbraun will run tests on a 32-bit machine manually. Anyway, if the result consistently matches the one in #35936 (comment) then the updated doctest should definitely pass...

@JohnCremona
Copy link
Member

@vbraun Can you explain the "needs work" tag?

@yyyyx4
Copy link
Member Author

yyyyx4 commented Nov 20, 2023

I interpreted the "needs work" label to be for the failing 32-bit doctest, which should be fixed now.

vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 4, 2023
…composite orders

    
The `.division_field()` method is currently restricted to prime orders
for no serious reason. This patch makes it work for composite orders,
generalizing [an observation of @JohnCremona](https://github.com/sagemat
h/sage/issues/11905#issuecomment-1417417647) in the process.

Note: I'm not sure if this is the optimal approach. I also played around
with building the extension as a tower corresponding to the
factorization of $n$, but (at least in Sage) it seemed significantly
slower than the version here.

Fixes sagemath#24340.
    
URL: sagemath#35936
Reported by: Lorenz Panny
Reviewer(s): John Cremona
@vbraun vbraun merged commit b60398e into sagemath:develop Dec 6, 2023
17 of 21 checks passed
@mkoeppe mkoeppe added this to the sage-10.3 milestone Dec 6, 2023
@yyyyx4 yyyyx4 deleted the public/generalize_elliptic_curve_division_field_to_composite_orders branch December 6, 2023 14:52
@tornaria
Copy link
Contributor

On recent betas (at least 10.3.beta5 and beta6) but not on 10.2:

$ sage -c 'EllipticCurve(GF(528238639), [78525647, 395630016, 427518312, 245441800, 351879008]).division_field(3)'
Traceback (most recent call last):
  File "sage/rings/finite_rings/integer_mod.pyx", line 382, in sage.rings.finite_rings.integer_mod.IntegerMod_abstract.__init__ (build/cythonized/sage/rings/finite_rings/integer_mod.c:12780)
  File "sage/structure/parent.pyx", line 901, in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:12676)
  File "sage/structure/coerce_maps.pyx", line 163, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:6957)
  File "sage/structure/coerce_maps.pyx", line 158, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:6849)
  File "sage/rings/integer.pyx", line 712, in sage.rings.integer.Integer.__init__ (build/cythonized/sage/rings/integer.c:15629)
TypeError: unable to coerce <class 'sage.categories.morphism.IdentityMorphism'> to an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/sage/structure/sequence.py", line 450, in __init__
    x[i] = universe(x[i])
           ^^^^^^^^^^^^^^
  File "sage/structure/parent.pyx", line 901, in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:12676)
  File "sage/structure/coerce_maps.pyx", line 163, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:6957)
  File "sage/structure/coerce_maps.pyx", line 158, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:6849)
  File "/usr/lib/python3.12/site-packages/sage/rings/finite_rings/integer_mod_ring.py", line 1175, in _element_constructor_
    return integer_mod.IntegerMod(self, x)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sage/rings/finite_rings/integer_mod.pyx", line 203, in sage.rings.finite_rings.integer_mod.IntegerMod (build/cythonized/sage/rings/finite_rings/integer_mod.c:11185)
  File "sage/rings/finite_rings/integer_mod.pyx", line 390, in sage.rings.finite_rings.integer_mod.IntegerMod_abstract.__init__ (build/cythonized/sage/rings/finite_rings/integer_mod.c:13015)
  File "sage/structure/parent.pyx", line 901, in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:12676)
  File "sage/structure/coerce_maps.pyx", line 163, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:6957)
  File "sage/structure/coerce_maps.pyx", line 158, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (build/cythonized/sage/structure/coerce_maps.c:6849)
  File "sage/rings/rational.pyx", line 547, in sage.rings.rational.Rational.__init__ (build/cythonized/sage/rings/rational.cpp:14519)
  File "sage/rings/rational.pyx", line 692, in sage.rings.rational.Rational._Rational__set_value (build/cythonized/sage/rings/rational.cpp:16605)
TypeError: unable to convert Identity endomorphism of Finite Field of size 528238639 to a rational

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/sagemath/10.3b5/bin/sage-eval", line 10, in <module>
    eval(compile(s,'<cmdline>','exec'))
  File "<cmdline>", line 1, in <module>
  File "/usr/lib/python3.12/site-packages/sage/schemes/elliptic_curves/ell_field.py", line 1108, in division_field
    h = self.defining_polynomial().change_ring(F_to_K)(x, polygen(K), 1)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sage/rings/polynomial/multi_polynomial.pyx", line 883, in sage.rings.polynomial.multi_polynomial.MPolynomial.change_ring (build/cythonized/sage/rings/polynomial/multi_polynomial.c:16673)
  File "sage/structure/parent_gens.pyx", line 304, in sage.structure.parent_gens.ParentWithGens.hom (build/cythonized/sage/structure/parent_gens.c:5679)
  File "sage/structure/parent.pyx", line 1439, in sage.structure.parent.Parent.hom (build/cythonized/sage/structure/parent.c:15783)
  File "sage/structure/parent.pyx", line 903, in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:12703)
  File "sage/structure/coerce_maps.pyx", line 182, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_with_args (build/cythonized/sage/structure/coerce_maps.c:7555)
  File "sage/structure/coerce_maps.pyx", line 172, in sage.structure.coerce_maps.DefaultConvertMap_unique._call_with_args (build/cythonized/sage/structure/coerce_maps.c:7347)
  File "/usr/lib/python3.12/site-packages/sage/rings/homset.py", line 195, in _element_constructor_
    x = self.domain().base().Hom(self.codomain().base())(x)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/sage/rings/finite_rings/homset.py", line 99, in __call__
    return FiniteFieldHomomorphism_prime(self, im_gens, base_map=base_map, check=check)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "sage/rings/finite_rings/hom_prime_finite_field.pyx", line 75, in sage.rings.finite_rings.hom_prime_finite_field.FiniteFieldHomomorphism_prime.__init__ (build/cythonized/sage/rings/finite_rings/hom_prime_finite_field.c:5793)
  File "sage/rings/finite_rings/hom_finite_field.pyx", line 240, in sage.rings.finite_rings.hom_finite_field.FiniteFieldHomomorphism_generic.__init__ (build/cythonized/sage/rings/finite_rings/hom_finite_field.c:6734)
  File "sage/rings/morphism.pyx", line 1730, in sage.rings.morphism.RingHomomorphism_im_gens.__init__ (build/cythonized/sage/rings/morphism.c:17279)
  File "/usr/lib/python3.12/site-packages/sage/structure/sequence.py", line 266, in Sequence
    return Sequence_generic(x, universe, check, immutable, cr, cr_str, use_sage_types)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/sage/structure/sequence.py", line 452, in __init__
    raise TypeError("unable to convert {} to an element of {}"
TypeError: unable to convert Identity endomorphism of Finite Field of size 528238639 to an element of Finite Field of size 528238639

FWIW, 528238639 is prime.

@yyyyx4
Copy link
Member Author

yyyyx4 commented Jan 23, 2024

That looks like #36832.

@tornaria
Copy link
Contributor

That looks like #36832.

Thanks, I searched division_field and only found this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generalize the division_field method of elliptic curve to the composite case
6 participants