# Ticket #9287: trac_9287.coverage_for_elliptic_curves_part1.patch

File trac_9287.coverage_for_elliptic_curves_part1.patch, 15.3 KB (added by wuthrich, 12 years ago)

exported against 4.4.4.alpha0

• ## sage/schemes/elliptic_curves/modular_parametrization.py

# HG changeset patch
# User Chris Wuthrich <christian.wuthrich@gmail.com>
# Date 1277022073 -3600
# Node ID c6dd5166f5dce35f2ec7f819051f75d2812807f8
# Parent  556bb66e4c6dbb92a4ee37c1750d82a5c6298eeb
trac 9287: doctest coverage for elliptic curves, part I

diff -r 556bb66e4c6d -r c6dd5166f5dc sage/schemes/elliptic_curves/modular_parametrization.py
 a """ def __init__(self, E): """ r""" EXAMPLES:: s sage: from sage.schemes.elliptic_curves.ell_rational_field import ModularParameterization sage: phi = ModularParameterization(EllipticCurve('389a')) sage: phi(CC.0/5) (27.1965586309057 : -144.727322178983 : 1.00000000000000) sage: phi == loads(dumps(phi)) True """ self._E = E 'Modular parameterization from the upper half plane to Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field' """ return "Modular parameterization from the upper half plane to %s" % self._E def __cmp__(self,other): r""" Compares two modular parametrizations by simply comparing the elliptic curves. EXAMPLES:: sage: E = EllipticCurve('37a1') sage: phi = E.modular_parametrization() sage: phi == phi True """ c = cmp(type(self), type(other)) if c: return c return cmp(self._E, other._E) def __call__(self, z, prec=None): r""" Evaluate self at a point z \in X_0(N) where z is given by a
 a this is describes the way the modular symbols are normalized. See modular_symbol of an elliptic curve over Q for more details. EXAMPLES:: sage: E = EllipticCurve('11a1') sage: Lp = E.padic_lseries(3) sage: Lp.series(2,prec=3) 2 + 3 + 3^2 + 2*3^3 + O(3^4) + (1 + O(3))*T + (1 + O(3))*T^2 + O(T^3) """ self._E = E self._p = ZZ(p) self._modular_symbol = E.modular_symbol(sign=+1, use_eclib = use_eclib, normalize=normalize) def __add_negative_space(self): r""" r""" A helper function not designed for direct use. This function add the attribute _negative_modular_symbol to the class. This may take time and will only be needed when twisting with negative fundamental discriminants. EXAMPLES:: sage: E = EllipticCurve('11a1') sage: lp = E.padic_lseries(5) sage: lp.modular_symbol(1/7,sign=-1)  #indirect doctest -1 """ if self._use_eclib: verbose('Currently there is no negative modular symbols in eclib, so we have to fall back on the implementation of modular symbols in sage') n += 1 def _c_bounds(self, n): raise NotImplementedError #    def _c_bounds(self, n): #        raise NotImplementedError def _prec_bounds(self, n,prec): raise NotImplementedError #    def _prec_bounds(self, n,prec): #        raise NotImplementedError def teichmuller(self, prec): r""" [a.residue(prec).lift() for a in K.teichmuller_system()] def _e_bounds(self, n, prec): r""" A helper function not designed for direct use. It computes the valuations of the coefficients of \omega_n = (1+T)^{p^n}-1. EXAMPLES:: sage: E = EllipticCurve('11a1') sage: Lp = E.padic_lseries(2) sage: Lp._e_bounds(1,10) [+Infinity, 1, 0] sage: Lp._e_bounds(2,10) [+Infinity, 2, 1, 2, 0] sage: Lp._e_bounds(3,10) [+Infinity, 3, 2, 3, 1, 3, 2, 3, 0] sage: Lp._e_bounds(4,10) [+Infinity, 4, 3, 4, 2, 4, 3, 4, 1, 4] """ p = self._p prec = max(2,prec) R = PowerSeriesRing(ZZ,'T',prec+1) return [infinity] + [valuation(w[j],p) for j in range(1,min(w.degree()+1,prec))] def _get_series_from_cache(self, n, prec, D): r""" A helper function not designed for direct use. It picks up the series in the cache if it has been previously computed. EXAMPLES:: sage: E = EllipticCurve('11a1') sage: Lp = E.padic_lseries(5) sage: Lp._get_series_from_cache(3,5,1) sage: Lp.series(3,prec=5) 5 + 4*5^2 + 4*5^3 + O(5^4) + O(5)*T + O(5)*T^2 + O(5)*T^3 + O(5)*T^4 + O(T^5) sage: Lp._get_series_from_cache(3,5,1) 5 + 4*5^2 + 4*5^3 + O(5^4) + O(5)*T + O(5)*T^2 + O(5)*T^3 + O(5)*T^4 + O(T^5) """ try: return self.__series[(n,prec,D)] except AttributeError: return None def _set_series_in_cache(self, n, prec, D, f): r""" A helper function not designed for direct use. It picks up the series in the cache if it has been previously computed. EXAMPLES:: sage: E = EllipticCurve('11a1') sage: Lp = E.padic_lseries(5) sage: Lp.series(3,prec=5) 5 + 4*5^2 + 4*5^3 + O(5^4) + O(5)*T + O(5)*T^2 + O(5)*T^3 + O(5)*T^4 + O(T^5) sage: Lp._set_series_in_cache(3,5,1, 0) sage: Lp.series(3,prec=5) 0 """ self.__series[(n,prec,D)] = f return False def _c_bound(self): r""" A helper function not designed for direct use. It returns the maximal p-adic valuation of the possible denominators of the modular symbols. EXAMPLES:: sage: E = EllipticCurve('11a1') sage: Lp = E.padic_lseries(5) sage: Lp._c_bound() 1 sage: Lp = E.padic_lseries(17) sage: Lp._c_bound() 0 """ try: return self.__c_bound except AttributeError: return ans def _prec_bounds(self, n, prec): r""" A helper function not designed for direct use. It returns the p-adic precisions of the approximation to the p-adic L-function. EXAMPLES:: sage: E = EllipticCurve('11a1') sage: Lp = E.padic_lseries(5) sage: Lp._prec_bounds(3,10) [+Infinity, 1, 1, 1, 1, 0, 1, 1, 1, 1] sage: Lp._prec_bounds(3,12) [+Infinity, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1] sage: Lp._prec_bounds(4,5) [+Infinity, 2, 2, 2, 2] sage: Lp._prec_bounds(15,5) [+Infinity, 13, 13, 13, 13] """ p = self._p e = self._e_bounds(n-1, prec) c = self._c_bound() power_series = series def is_ordinary(self): r""" Return True if the elliptic that this L-function is attached to is ordinary. EXAMPLES:: sage: L = EllipticCurve('11a').padic_lseries(19) sage: L.is_ordinary() False """ return False def is_supersingular(self): r""" Return True if the elliptic that this L function is attached to is supersingular. EXAMPLES:: sage: L = EllipticCurve('11a').padic_lseries(19) sage: L.is_supersingular() True """ return True def _prec_bounds(self, n,prec): r""" A helper function not designed for direct use. It returns the p-adic precisions of the approximation to the p-adic L-function. EXAMPLES:: sage: E = EllipticCurve('11a1') sage: Lp = E.padic_lseries(19) sage: Lp._prec_bounds(3,5) [[+Infinity, +Infinity], [-1, -1], [-1, -1], [-1, -1], [-1, -1]] sage: Lp._prec_bounds(2,5) [[+Infinity, +Infinity], [-1, -2], [-1, -2], [-1, -2], [-1, -2]] sage: Lp._prec_bounds(10,5) [[+Infinity, +Infinity], [3, 2], [3, 2], [3, 2], [3, 2]] """ p = self._p e = self._e_bounds(n-1,prec) c0 = ZZ(n+2)/2 - method - either 'mw' (default) for Monsky-Washintzer or 'approx' for the method described by Bernardi and Perrin-Riou (much slower) (much slower and not fully tested) EXAMPLES:: def __phi_bpr(self, prec=0): r""" Returns the phi using the definition of bernardi-perrin-riou on page 232. This returns a geometric Frobenius \varphi on the Dieudonne module D_p(E) with respect to the basis \omega, the invariant differential, and \eta=x\omega. It satisfies  \varphi^2 - a_p/p\, \varphi + 1/p = 0. The algorithm used here is described in bernardi-perrin-riou on page 232. .. note: Warning. This function has not been sufficiently tested. It is very slow. EXAMPLES:: sage: E = EllipticCurve('11a1') sage: lp = E.padic_lseries(19) sage: lp.frobenius(prec=1,method="approx")   #indirect doctest [          O(19^0) 4*19^-1 + O(19^0)] [       14 + O(19)           O(19^0)] sage: E = EllipticCurve('17a1') sage: lp = E.padic_lseries(3) sage: lp.frobenius(prec=3,method="approx") [             O(3) 2*3^-1 + 2 + O(3)] [       1 + O(3^2)              O(3)] sage: lp.frobenius(prec=5,method="approx") [             3 + O(3^2) 2*3^-1 + 2 + 3 + O(3^2)] [     1 + 2*3^2 + O(3^3)            2*3 + O(3^2)] """ E = self._E p = self._p R = Qp(p,max(dpr,dga)+1) delta = R(delta,absprec=dpr) gamma = R(gamma,absprec=dga) verbose("result delta = %s\n      gamma = %s\n check : %s"%(delta,gamma, [Qp(3,k)(delta * cs[k] - gamma * ds[k] - cs[k-1]) for k in range(1,prec+1)] )) verbose("result delta = %s\n      gamma = %s\n check : %s"%(delta,gamma, [Qp(p,k)(delta * cs[k] - gamma * ds[k] - cs[k-1]) for k in range(1,prec+1)] )) a = delta c = -gamma d = E.ap(p) - a
 a # -*- coding: utf-8 -*- """ Miscellaneous p-adic functions import padic_lseries as plseries import sage.rings.arith as arith from sage.rings.all import ( Qp, Qp, Zp, Integers, Integer, O, from constructor import EllipticCurve def __check_padic_hypotheses(self, p): r""" Helper function that determines if p is an odd prime of good ordinary reduction. EXAMPLES:: sage: E = EllipticCurve('11a1') sage: from sage.schemes.elliptic_curves.padics import __check_padic_hypotheses sage: __check_padic_hypotheses(E,5) 5 sage: __check_padic_hypotheses(E,29) Traceback (most recent call last): ... ArithmeticError: p must be a good ordinary prime """ p = rings.Integer(p) if not p.is_prime(): raise ValueError, "p = (%s) must be prime"%p return output_ring(E2_of_X * fudge_factor_inverse) def matrix_of_frobenius(self, p, prec=20, check=False, check_hypotheses=True, algorithm="auto"): """ See the parameters and documentation for padic_E2. r""" Returns the matrix of Frobenius on the Monsky Washnitzer cohomology of the elliptic curve. INPUT: -  p - prime (= 5) for which E is good and ordinary -  prec - (relative) p-adic precision for result  (default 20) -  check - boolean (default: False), whether to perform a consistency check. This will slow down the computation by a constant factor 2. (The consistency check is to verify that its trace is correct to the specified precision. Otherwise, the trace is used to compute one column from the other one (possibly after a change of basis).) -  check_hypotheses - boolean, whether to check that this is a curve for which the p-adic sigma function makes sense -  algorithm - one of "standard", "sqrtp", or "auto". This selects which version of Kedlaya's algorithm is used. The "standard" one is the one described in Kedlaya's paper. The "sqrtp" one has better performance for large p, but only works when p > 6N (N= prec). The "auto" option selects "sqrtp" whenever possible. Note that if the "sqrtp" algorithm is used, a consistency check will automatically be applied, regardless of the setting of the "check" flag. OUTPUT: a matrix of p-adic number to precision prec See also the documentation of padic_E2. EXAMPLES:: sage: E = EllipticCurve('37a1') sage: E.matrix_of_frobenius(7) [             2*7 + 4*7^2 + 5*7^4 + 6*7^5 + 6*7^6 + 7^8 + 4*7^9 + 3*7^10 + 2*7^11 + 5*7^12 + 4*7^14 + 7^16 + 2*7^17 + 3*7^18 + 4*7^19 + 3*7^20 + O(7^21)                                   2 + 3*7 + 6*7^2 + 7^3 + 3*7^4 + 5*7^5 + 3*7^7 + 7^8 + 3*7^9 + 6*7^13 + 7^14 + 7^16 + 5*7^17 + 4*7^18 + 7^19 + O(7^20)] [    2*7 + 3*7^2 + 7^3 + 3*7^4 + 6*7^5 + 2*7^6 + 3*7^7 + 5*7^8 + 3*7^9 + 2*7^11 + 6*7^12 + 5*7^13 + 4*7^16 + 4*7^17 + 6*7^18 + 6*7^19 + 4*7^20 + O(7^21) 6 + 4*7 + 2*7^2 + 6*7^3 + 7^4 + 6*7^7 + 5*7^8 + 2*7^9 + 3*7^10 + 4*7^11 + 7^12 + 6*7^13 + 2*7^14 + 6*7^15 + 5*7^16 + 4*7^17 + 3*7^18 + 2*7^19 + O(7^20)] sage: M = E.matrix_of_frobenius(11,prec=3); M [   9*11 + 9*11^3 + O(11^4)          10 + 11 + O(11^3)] [     2*11 + 11^2 + O(11^4) 6 + 11 + 10*11^2 + O(11^3)] sage: M.det() 11 + O(11^4) sage: M.trace() 6 + 10*11 + 10*11^2 + O(11^3) sage: E.ap(11) -5 """ # TODO change the basis back to the original equation. # TODO, add lots of comments like the above check = True return frob_p # return frob_p ## why was this here ? if check: trace_of_frobenius = frob_p.trace().lift() % p**prec