Implement period_lattice for elliptic curves over RealField, ComplexField, etc.
Implement E.period_lattice() method for elliptic curves over other fields.
(The code is mostly already there, just need minor adaptation.)
:memo: Checklist
- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion. (not aware of one)
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation preview.
Documentation preview for this PR (built with commit 31441bab38df4ccb2339249fbf637ff771585db3; changes) is ready! :tada: This preview will update shortly after each push to this PR.
The failing test looks unrelated to the changes, I think.
@JohnCremona Perhaps you might be interested in this.
I'll look at this next week
Caveat:
- A
EllipticCurve_number_fieldinherits fromEllipticCurve_field. - Given an instance of
EllipticCurve_field, you can call.period_lattice()on it with no argument and it will return something. - This contract is not satisfied with an
EllipticCurve_number_fieldobject, violate Liskov substitution principle.
What do you think?
One way is to default embedding=None for EllipticCurve_number_field.period_lattice(), but then we need to think what to do in that case.
-
use
E.base_field().coerce_embedding()(suggested in https://github.com/sagemath/sage/issues/38363 ). This breaks backwards compatibility, but I think this is the best option. -
give an error: this is not the current behavior with
embedding=None(thus also break backwards compatibility), but would be the safest option. -
follow the current behavior of
PeriodLattice_ellconstructor whenembedding=None:embedding-- (default:None) an embedding of the base fieldKofEinto a real or complex field. IfNone:- use the built-in coercion to
\RRforK=\QQ; - use the first embedding into
\RRgiven byK.embeddings(RealField()), if there are any; - use the first embedding into
\CCgiven byK.embeddings(ComplexField()), ifKis totally complex.
- use the built-in coercion to
@JohnCremona Can I get a review? Thanks.
I think it is up to the original author to fix the failing tests, which do not look serious. My positive review was only in principle, once these things have been sorted out.
Indeed the failing tests are not serious (it's just one error message over another). I didn't notice the test failure after merging the branch, sorry.
Changing the behavior to only use coerce_embedding instead of arbitrarily pick the first embedding sounds like a good idea, I will implement it later.
I decide to just fix the failing tests by relax the thing being tested for.
The part of using canonical embedding feels like a behavioral change ⟹ deprecation period ⟹ etc. and it's probably easiest to handle it in a separate pull request.
There are still some failing tests being flagged. Do they fail when run locally?
I… use GitHub Actions to run the tests, sorry. Should really get around to figure out how to run it locally…
The tests passed now, can someone add the "s: positive review" label? Thanks.
I will -- but first can you merge with the base branch?
On 32-bit:
**********************************************************************
File "src/sage/schemes/elliptic_curves/period_lattice.py", line 1746, in sage.schemes.elliptic_curves.period_lattice.PeriodLattice_ell.elliptic_logarithm
Failed example:
L.elliptic_exponential(_)
Expected:
(3.00000000000000 + 9.20856947066460e-16*I : -5.59022723358798 - 0.0894418024719718*I : 1.00000000000000)
Got:
(3.00000000000000 + 9.21992199947644e-16*I : -5.59022723358798 - 0.0894418024719718*I : 1.00000000000000)
**********************************************************************
File "src/sage/schemes/elliptic_curves/period_lattice.py", line 1750, in sage.schemes.elliptic_curves.period_lattice.PeriodLattice_ell.elliptic_logarithm
Failed example:
L.elliptic_exponential(_)
Expected:
(3.0000000000000000000000000000 - 1.4773628579202938936348512161e-30*I : -5.5902272335879800026836302686 - 0.089441802471969391005702381090*I : 1.0000000000000000000000000000)
Got:
(3.0000000000000000000000000000 - 1.4773628576434657795460561386e-30*I : -5.5902272335879800026836302686 - 0.089441802471969391005702381090*I : 1.0000000000000000000000000000)
**********************************************************************
1 item had failures:
2 of 98 in sage.schemes.elliptic_curves.period_lattice.PeriodLattice_ell.elliptic_logarithm
[447 tests, 2 failures, 3.31s wall]
**********************************************************************
Looks innocuous --- just add some appropriate # abs tol.
I decide to add a lot more # abs tol in other places.
Actually I'm more surprised that the existing tests all pass — maybe because pari (or whatever being used) is guaranteed to return result within 0.51 ulp, which will make it deterministic as long as the result doesn't lie at the midpoint.