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 b  
    6666
    6767    """
    6868    def __init__(self, E):
    69         """
     69        r"""
    7070        EXAMPLES::
    7171        s
    7272            sage: from sage.schemes.elliptic_curves.ell_rational_field import ModularParameterization
    7373            sage: phi = ModularParameterization(EllipticCurve('389a'))
    7474            sage: phi(CC.0/5)
    7575            (27.1965586309057 : -144.727322178983 : 1.00000000000000)
     76
     77            sage: phi == loads(dumps(phi))
     78            True
     79
    7680        """
    7781        self._E = E
    7882   
     
    101105            'Modular parameterization from the upper half plane to Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field'
    102106        """
    103107        return "Modular parameterization from the upper half plane to %s" % self._E
    104    
     108
     109    def __cmp__(self,other):
     110        r"""
     111        Compares two modular parametrizations by simply comparing the elliptic curves.
     112
     113        EXAMPLES::
     114
     115            sage: E = EllipticCurve('37a1')
     116            sage: phi = E.modular_parametrization()
     117            sage: phi == phi
     118            True
     119        """
     120        c = cmp(type(self), type(other))
     121        if c:
     122            return c
     123        return cmp(self._E, other._E)               
     124       
    105125    def __call__(self, z, prec=None):
    106126        r"""
    107127        Evaluate self at a point `z \in X_0(N)` where `z` is given by a
  • sage/schemes/elliptic_curves/padic_lseries.py

    diff -r 556bb66e4c6d -r c6dd5166f5dc sage/schemes/elliptic_curves/padic_lseries.py
    a b  
    141141           this is describes the way the modular symbols
    142142           are normalized. See ``modular_symbol`` of
    143143           an elliptic curve over Q for more details.
    144            
     144       
     145        EXAMPLES::
     146
     147            sage: E = EllipticCurve('11a1')
     148            sage: Lp = E.padic_lseries(3)
     149            sage: Lp.series(2,prec=3)
     150            2 + 3 + 3^2 + 2*3^3 + O(3^4) + (1 + O(3))*T + (1 + O(3))*T^2 + O(T^3)
    145151        """
    146152        self._E = E
    147153        self._p = ZZ(p)
     
    160166        self._modular_symbol = E.modular_symbol(sign=+1, use_eclib = use_eclib, normalize=normalize)
    161167
    162168    def __add_negative_space(self):
    163         r"""
     169        r"""       
     170        A helper function not designed for direct use.
     171
    164172        This function add the attribute ``_negative_modular_symbol`` to the class. This may take time
    165173        and will only be needed when twisting with negative fundamental discriminants.
     174
     175        EXAMPLES::
     176
     177        sage: E = EllipticCurve('11a1')
     178        sage: lp = E.padic_lseries(5)
     179        sage: lp.modular_symbol(1/7,sign=-1)  #indirect doctest
     180        -1
     181
    166182        """   
    167183        if self._use_eclib:
    168184            verbose('Currently there is no negative modular symbols in eclib, so we have to fall back on the implementation of modular symbols in sage')
     
    542558            n += 1
    543559
    544560
    545     def _c_bounds(self, n):
    546         raise NotImplementedError
     561#    def _c_bounds(self, n):
     562#        raise NotImplementedError
    547563
    548     def _prec_bounds(self, n,prec):
    549         raise NotImplementedError
     564#    def _prec_bounds(self, n,prec):
     565#        raise NotImplementedError
    550566
    551567    def teichmuller(self, prec):
    552568        r"""
     
    574590               [a.residue(prec).lift() for a in K.teichmuller_system()]
    575591
    576592    def _e_bounds(self, n, prec):
     593        r"""
     594        A helper function not designed for direct use.
     595   
     596        It computes the valuations of the coefficients of `\omega_n = (1+T)^{p^n}-1`.
     597
     598        EXAMPLES::
     599
     600            sage: E = EllipticCurve('11a1')
     601            sage: Lp = E.padic_lseries(2)
     602            sage: Lp._e_bounds(1,10)
     603            [+Infinity, 1, 0]
     604            sage: Lp._e_bounds(2,10)
     605            [+Infinity, 2, 1, 2, 0]
     606            sage: Lp._e_bounds(3,10)
     607            [+Infinity, 3, 2, 3, 1, 3, 2, 3, 0]
     608            sage: Lp._e_bounds(4,10)
     609            [+Infinity, 4, 3, 4, 2, 4, 3, 4, 1, 4]
     610
     611 
     612        """
    577613        p = self._p
    578614        prec = max(2,prec)
    579615        R = PowerSeriesRing(ZZ,'T',prec+1)
     
    582618        return [infinity] + [valuation(w[j],p) for j in range(1,min(w.degree()+1,prec))]
    583619       
    584620    def _get_series_from_cache(self, n, prec, D):
     621        r"""       
     622        A helper function not designed for direct use.
     623
     624        It picks up the series in the cache if it has been previously computed.
     625
     626        EXAMPLES::
     627
     628            sage: E = EllipticCurve('11a1')
     629            sage: Lp = E.padic_lseries(5)
     630            sage: Lp._get_series_from_cache(3,5,1)
     631            sage: Lp.series(3,prec=5)
     632            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)
     633            sage: Lp._get_series_from_cache(3,5,1)
     634            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)
     635        """
    585636        try:
    586637            return self.__series[(n,prec,D)]
    587638        except AttributeError:
     
    593644        return None
    594645
    595646    def _set_series_in_cache(self, n, prec, D, f):
     647        r"""
     648        A helper function not designed for direct use.
     649
     650        It picks up the series in the cache if it has been previously computed.
     651
     652        EXAMPLES::
     653
     654            sage: E = EllipticCurve('11a1')
     655            sage: Lp = E.padic_lseries(5)
     656            sage: Lp.series(3,prec=5)
     657            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)
     658            sage: Lp._set_series_in_cache(3,5,1, 0)
     659            sage: Lp.series(3,prec=5)
     660            0
     661        """
    596662        self.__series[(n,prec,D)] = f
    597663 
    598664
     
    854920        return False
    855921
    856922    def _c_bound(self):
     923        r"""
     924        A helper function not designed for direct use.
     925
     926        It returns the maximal `p`-adic valuation of the possible denominators
     927        of the modular symbols.
     928
     929        EXAMPLES::
     930
     931            sage: E = EllipticCurve('11a1')
     932            sage: Lp = E.padic_lseries(5)
     933            sage: Lp._c_bound()
     934            1
     935            sage: Lp = E.padic_lseries(17)
     936            sage: Lp._c_bound()
     937            0
     938
     939        """
    857940        try:
    858941            return self.__c_bound
    859942        except AttributeError:
     
    871954        return ans
    872955               
    873956    def _prec_bounds(self, n, prec):
     957        r"""
     958        A helper function not designed for direct use.
     959
     960        It returns the `p`-adic precisions of the approximation
     961        to the `p`-adic L-function.
     962
     963        EXAMPLES::
     964
     965            sage: E = EllipticCurve('11a1')
     966            sage: Lp = E.padic_lseries(5)
     967            sage: Lp._prec_bounds(3,10)
     968            [+Infinity, 1, 1, 1, 1, 0, 1, 1, 1, 1]
     969            sage: Lp._prec_bounds(3,12)
     970            [+Infinity, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1]
     971            sage: Lp._prec_bounds(4,5)
     972            [+Infinity, 2, 2, 2, 2]
     973            sage: Lp._prec_bounds(15,5)
     974            [+Infinity, 13, 13, 13, 13]
     975 
     976        """
    874977        p = self._p
    875978        e = self._e_bounds(n-1, prec)
    876979        c = self._c_bound()
     
    9891092    power_series = series
    9901093
    9911094    def is_ordinary(self):
     1095        r"""
     1096        Return True if the elliptic that this L-function is attached
     1097        to is ordinary.
     1098       
     1099        EXAMPLES::
     1100       
     1101            sage: L = EllipticCurve('11a').padic_lseries(19)           
     1102            sage: L.is_ordinary()
     1103            False
     1104        """
    9921105        return False
    9931106
    9941107    def is_supersingular(self):
     1108        r"""
     1109        Return True if the elliptic that this L function is attached
     1110        to is supersingular.
     1111               
     1112        EXAMPLES::
     1113       
     1114            sage: L = EllipticCurve('11a').padic_lseries(19)           
     1115            sage: L.is_supersingular()
     1116            True
     1117        """
    9951118        return True
    9961119
    9971120    def _prec_bounds(self, n,prec):
     1121        r"""
     1122        A helper function not designed for direct use.
     1123
     1124        It returns the `p`-adic precisions of the approximation
     1125        to the `p`-adic L-function.
     1126
     1127        EXAMPLES::
     1128
     1129            sage: E = EllipticCurve('11a1')
     1130            sage: Lp = E.padic_lseries(19)
     1131            sage: Lp._prec_bounds(3,5)
     1132            [[+Infinity, +Infinity], [-1, -1], [-1, -1], [-1, -1], [-1, -1]]
     1133            sage: Lp._prec_bounds(2,5)
     1134            [[+Infinity, +Infinity], [-1, -2], [-1, -2], [-1, -2], [-1, -2]]
     1135            sage: Lp._prec_bounds(10,5)
     1136            [[+Infinity, +Infinity], [3, 2], [3, 2], [3, 2], [3, 2]]
     1137        """
    9981138        p = self._p
    9991139        e = self._e_bounds(n-1,prec)
    10001140        c0 = ZZ(n+2)/2
     
    10661206
    10671207        - ``method`` - either 'mw' (default) for Monsky-Washintzer
    10681208          or 'approx' for the method described by Bernardi and Perrin-Riou
    1069           (much slower)
     1209          (much slower and not fully tested)
    10701210                         
    10711211
    10721212        EXAMPLES::
     
    11231263     
    11241264    def __phi_bpr(self, prec=0):
    11251265        r"""
    1126         Returns the phi using the definition of bernardi-perrin-riou on page 232.
     1266        This returns a geometric Frobenius `\varphi` on the Dieudonne module `D_p(E)`
     1267        with respect to the basis `\omega`, the invariant differential, and `\eta=x\omega`.
     1268        It satisfies  `\varphi^2 - a_p/p\, \varphi + 1/p = 0`.
     1269
     1270        The algorithm used here is described in bernardi-perrin-riou on page 232.
     1271
     1272        .. note: Warning. This function has not been sufficiently tested. It is very slow.
     1273
     1274        EXAMPLES::
     1275
     1276            sage: E = EllipticCurve('11a1')
     1277            sage: lp = E.padic_lseries(19)
     1278            sage: lp.frobenius(prec=1,method="approx")   #indirect doctest
     1279            [          O(19^0) 4*19^-1 + O(19^0)]
     1280            [       14 + O(19)           O(19^0)]
     1281
     1282            sage: E = EllipticCurve('17a1')
     1283            sage: lp = E.padic_lseries(3)
     1284            sage: lp.frobenius(prec=3,method="approx")
     1285            [             O(3) 2*3^-1 + 2 + O(3)]
     1286            [       1 + O(3^2)              O(3)]
     1287            sage: lp.frobenius(prec=5,method="approx")
     1288            [             3 + O(3^2) 2*3^-1 + 2 + 3 + O(3^2)]
     1289            [     1 + 2*3^2 + O(3^3)            2*3 + O(3^2)]
     1290
     1291
    11271292        """
    11281293        E = self._E
    11291294        p = self._p
     
    11791344        R = Qp(p,max(dpr,dga)+1)
    11801345        delta = R(delta,absprec=dpr)
    11811346        gamma = R(gamma,absprec=dga)
    1182         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)] ))
     1347        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)] ))
    11831348        a = delta
    11841349        c = -gamma
    11851350        d = E.ap(p) - a
  • sage/schemes/elliptic_curves/padics.py

    diff -r 556bb66e4c6d -r c6dd5166f5dc sage/schemes/elliptic_curves/padics.py
    a b  
     1# -*- coding: utf-8 -*-
    12"""
    23Miscellaneous p-adic functions
    34
     
    2526import padic_lseries as plseries
    2627import sage.rings.arith as arith
    2728from sage.rings.all import (
    28     Qp,
     29    Qp, Zp,
    2930    Integers,
    3031    Integer,
    3132    O,
     
    4243from constructor import EllipticCurve
    4344
    4445def __check_padic_hypotheses(self, p):
     46    r"""
     47    Helper function that determines if `p`
     48    is an odd prime of good ordinary reduction.
     49
     50    EXAMPLES::
     51        sage: E = EllipticCurve('11a1')
     52        sage: from sage.schemes.elliptic_curves.padics import __check_padic_hypotheses
     53        sage: __check_padic_hypotheses(E,5)
     54        5
     55        sage: __check_padic_hypotheses(E,29)
     56        Traceback (most recent call last):
     57        ...
     58        ArithmeticError: p must be a good ordinary prime
     59
     60    """
    4561    p = rings.Integer(p)
    4662    if not p.is_prime():
    4763        raise ValueError, "p = (%s) must be prime"%p
     
    14261442    return output_ring(E2_of_X * fudge_factor_inverse)
    14271443
    14281444def matrix_of_frobenius(self, p, prec=20, check=False, check_hypotheses=True, algorithm="auto"):
    1429     """
    1430     See the parameters and documentation for padic_E2.
     1445    r"""   
     1446    Returns the matrix of Frobenius on the Monsky Washnitzer cohomology of the elliptic curve.
     1447   
     1448    INPUT:
     1449   
     1450    -  ``p`` - prime (= 5) for which `E` is good
     1451       and ordinary
     1452   
     1453    -  ``prec`` - (relative) `p`-adic precision for
     1454       result  (default 20)
     1455   
     1456    -  ``check`` - boolean (default: False), whether to perform a
     1457       consistency check. This will slow down the computation by a
     1458       constant factor 2. (The consistency check is to verify
     1459       that its trace is correct to the specified precision. Otherwise,
     1460       the trace is used to compute one column from the other one
     1461       (possibly after a change of basis).)
     1462   
     1463    -  ``check_hypotheses`` - boolean, whether to check
     1464       that this is a curve for which the `p`-adic sigma function makes
     1465       sense
     1466   
     1467    -  ``algorithm`` - one of "standard", "sqrtp", or
     1468       "auto". This selects which version of Kedlaya's algorithm is used.
     1469       The "standard" one is the one described in Kedlaya's paper. The
     1470       "sqrtp" one has better performance for large `p`, but only
     1471       works when `p > 6N` (`N=` prec). The "auto" option
     1472       selects "sqrtp" whenever possible.
     1473   
     1474       Note that if the "sqrtp" algorithm is used, a consistency check
     1475       will automatically be applied, regardless of the setting of the
     1476       "check" flag.
     1477     
     1478    OUTPUT: a matrix of `p`-adic number to precision ``prec``
     1479   
     1480    See also the documentation of padic_E2.
     1481 
     1482    EXAMPLES::
     1483
     1484        sage: E = EllipticCurve('37a1')
     1485        sage: E.matrix_of_frobenius(7)
     1486        [             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)]
     1487        [    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)]
     1488        sage: M = E.matrix_of_frobenius(11,prec=3); M
     1489        [   9*11 + 9*11^3 + O(11^4)          10 + 11 + O(11^3)]
     1490        [     2*11 + 11^2 + O(11^4) 6 + 11 + 10*11^2 + O(11^3)]
     1491        sage: M.det()
     1492        11 + O(11^4)
     1493        sage: M.trace()
     1494        6 + 10*11 + 10*11^2 + O(11^3)
     1495        sage: E.ap(11)
     1496        -5
     1497
    14311498    """
    14321499    # TODO change the basis back to the original equation.
    14331500    # TODO, add lots of comments like the above
     
    15061573        check = True
    15071574
    15081575
    1509     return frob_p
     1576    # return frob_p ## why was this here ?
    15101577
    15111578    if check:
    15121579        trace_of_frobenius = frob_p.trace().lift() % p**prec