From 6243ff58f7f602577883452c1344dff7a413ce35 Mon Sep 17 00:00:00 2001 From: user202729 <25191436+user202729@users.noreply.github.com> Date: Tue, 12 Nov 2024 21:56:38 +0700 Subject: [PATCH] Allow construct elliptic curve given period_lattice --- .../schemes/elliptic_curves/constructor.py | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/src/sage/schemes/elliptic_curves/constructor.py b/src/sage/schemes/elliptic_curves/constructor.py index 831ee47e280..198df446001 100755 --- a/src/sage/schemes/elliptic_curves/constructor.py +++ b/src/sage/schemes/elliptic_curves/constructor.py @@ -524,6 +524,106 @@ def create_object(self, version, key, *, names=None, **kwds): from .ell_generic import EllipticCurve_generic return EllipticCurve_generic(R, x) + @staticmethod + def _eisenstein_series_e_eval(weight, tau, prec): + r""" + Private method to evaluate `E_{2k}`. To be merged with modular form code later. + + INPUT: + + - prec -- precision in bits + + OUTPUT: + + Element of ``ComplexField(prec)`` equal to `E_{2k}(\tau)` where ``2k == weight``. + + TESTS: + + Example values:: + + sage: tau = CC(2/3*I+4/5) + sage: weight = 6 + + Evaluating using our method:: + + sage: EllipticCurve._eisenstein_series_e_eval(weight, tau, 53) # abs tol 1e-10 + 2.06948373064822 + 9.23822630732235*I + + Approximately evaluate using convergent sum:: + + sage: sum((a+b*tau)^-weight for a in (-50..50) for b in (-50..50) if gcd(a, b)==1)/2 # abs tol 1e-10 + 2.06948373572619 + 9.23822632418512*I + + Approximately evaluate using `q`-expansion:: + + sage: M4 = EisensteinForms(Gamma0(1), weight=weight) + sage: e4 = M4.0 + sage: e4.qexp(prec=50).polynomial()(exp(2*pi*I * tau).n(200)) # abs tol 1e-60 + 2.0694837306482189422343628966349567015465461257928410093613 + 9.2382263073223530637169893909058439360384065238856673719976*I + + Higher precision:: + + sage: EllipticCurve._eisenstein_series_e_eval(weight, tau, 200) # abs tol 1e-60 + 2.0694837306482189422343628966349567015465461257928410093613 + 9.2382263073223530637169893909058439360384065238856673719976*I + """ + from sage.libs.pari.all import pari + from sage.rings.complex_mpfr import ComplexField + mf = pari.mfinit([1,weight],3) + [f] = pari.mfbasis(mf) + old_prec = pari.get_real_precision_bits() + pari.set_real_precision_bits(prec) + F = ComplexField(prec) + result = pari.mfeval(mf, f, F(tau), precision=prec)/pari.mfcoef(f, 0) + # for some reason precision=prec passed above doesn't work, thus need pari.set_real_precision_bits(prec) + pari.set_real_precision_bits(old_prec) + return F(result) + + @staticmethod + def _eisenstein_series_g_eval(weight, tau, prec): + r""" + Similar to :meth:`_eisenstein_series_e_eval`, but evaluates `G_{2k}`. + + TESTS:: + + sage: tau = CC(2/3*I+4/5) + sage: weight = 6 + sage: EllipticCurve._eisenstein_series_g_eval(weight, tau, 53) # abs tol 1e-10 + 4.21074983052932 + 18.7968908775932*I + """ + from sage.functions.transcendental import zeta + e = EllipticCurve._eisenstein_series_e_eval(weight, tau, prec) + return e.parent()(zeta(weight) * 2 * e) + + @staticmethod + def from_period_lattice_basis(w1, w2): + r""" + Construct an elliptic curve from a period lattice basis. + + INPUT: + + - ``w1``, ``w2`` -- basis elements, must be element of ``ComplexField(prec)`` for some ``prec`` + + OUTPUT: + + ``EllipticCurve`` instance with base ring ``ComplexField(prec)`` + + EXAMPLES:: + + sage: F = ComplexField(53) + sage: w1 = F(1) + sage: w2 = F(I * sqrt(7)) + sage: E = EllipticCurve.from_period_lattice_basis(w1, w2) + sage: E.period_lattice().basis() # abs tol 1e-10 + (-2.64575131106483*I, -1.00000000000000) + """ + F = w1.parent() + if F != w2.parent(): + raise ValueError("basis elements must have the same parent") + prec = F.precision() + tau = w2/w1 + g2 = -60*EllipticCurve._eisenstein_series_g_eval(4, tau, prec)/w1**4 + g3 = -140*EllipticCurve._eisenstein_series_g_eval(6, tau, prec)/w1**6 + return EllipticCurve(F, [(g2/4).real(), (g3/4).real()]) EllipticCurve = EllipticCurveFactory('sage.schemes.elliptic_curves.constructor.EllipticCurve')