Ticket #9467: 14330.patch

File 14330.patch, 27.5 KB (added by jen, 12 years ago)
  • new file sage/modular/abvar/padic_lseries.py

    # HG changeset patch
    # User Jen Balakrishnan <jen@math.mit.edu>
    # Date 1278706912 25200
    # Node ID cebe47683ff6f6fa77502ed5686fa583981cb52f
    # Parent  9e6c9dd499ff08c036f04a17639e166084c04c6b
    Ticket #9467
    
    New code for p-adic L-series
    
    diff -r 9e6c9dd499ff -r cebe47683ff6 sage/modular/abvar/padic_lseries.py
    - +  
     1# -*- coding: utf-8 -*-
     2r"""
     3p-adic L-series of modular Jacobians with ordinary reduction at p
     4
     5
     6REFERENCES:
     7       
     8- [MTT] B. Mazur, J. Tate, and J. Teitelbaum,
     9  On `p`-adic analogues of the conjectures of Birch and
     10  Swinnerton-Dyer, Inventiones mathematicae 84, (1986), 1-48.
     11   
     12- [SW] William Stein and Christian Wuthrich, Computations About Tate-Shafarevich Groups
     13  using Iwasawa theory, preprint 2009.
     14     
     15AUTHORS:
     16
     17- William Stein and Jennifer Balakrishnan (2010-07-01): first version
     18
     19"""
     20
     21######################################################################
     22#       Copyright (C) 2007 William Stein <wstein@gmail.com>
     23#
     24#  Distributed under the terms of the GNU General Public License (GPL)
     25#
     26#    This code is distributed in the hope that it will be useful,
     27#    but WITHOUT ANY WARRANTY; without even the implied warranty of
     28#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     29#    General Public License for more details.
     30#
     31#  The full text of the GPL is available at:
     32#
     33#                  http://www.gnu.org/licenses/
     34######################################################################
     35
     36
     37from sage.rings.integer_ring import   ZZ
     38from sage.rings.rational_field import QQ
     39from sage.rings.padics.factory import Qp, Zp
     40from sage.rings.infinity import infinity
     41from sage.rings.all import LaurentSeriesRing, PowerSeriesRing, PolynomialRing, Integers
     42
     43from sage.rings.integer import Integer
     44from sage.rings.arith import valuation, binomial, kronecker_symbol, gcd, prime_divisors, valuation
     45
     46from sage.structure.sage_object import SageObject
     47
     48from sage.misc.all import verbose, denominator, get_verbose
     49from sage.databases.cremona import parse_cremona_label
     50from sage.schemes.elliptic_curves.constructor import EllipticCurve
     51import sage.rings.arith as arith
     52
     53from sage.modules.free_module_element import vector
     54import sage.matrix.all as matrix
     55
     56# from sage.interfaces.all import gp
     57from sage.misc.functional import log
     58
     59from sage.modular.modsym.modsym import ModularSymbols
     60
     61class pAdicLseries(SageObject):
     62    r"""
     63    The `p`-adic L-series of a modular Jacobian
     64
     65    EXAMPLES:
     66    An ordinary example::
     67   
     68
     69    """
     70    def __init__(self, J, p, normalize='L_ratio'):
     71        r"""
     72        INPUT:
     73       
     74        -  ``J`` - modular abelian variety
     75        -  ``p`` - a prime of good reduction
     76        -  ``normalize`` - ``'L_ratio'`` (default), ``'period'`` or ``'none'``;
     77           this is describes the way the modular symbols
     78           are normalized
     79        """
     80        self._J = J
     81        self._level = J.level()
     82        self._p = ZZ(p)
     83        self._normalize = normalize
     84        if not self._p.is_prime():
     85            raise ValueError, "p (=%s) must be a prime"%p
     86
     87                       
     88    def __cmp__(self,other):
     89        r"""
     90        Compare self and other.
     91       
     92        TESTS::
     93            sage: lp1 = J0(23)[0].padic_lseries(5)
     94            sage: lp2 = J0(23)[0].padic_lseries(7)
     95            sage: lp3 = J0(29)[0].padic_lseries(5)
     96            sage: lp1 == lp1
     97            True
     98            sage: lp1 == lp2
     99            False
     100            sage: lp1 == lp3
     101            False
     102
     103        """
     104        c = cmp(type(self), type(other))
     105        if c:
     106            return c
     107        return cmp((self._J, self._p), (other._J, other._p))               
     108
     109    def modular_symbols_subspace(self):
     110        """
     111        """
     112        M = ModularSymbols(self._level,2,sign=1)
     113        self._modular_symbols_space = M
     114        S = M.cuspidal_submodule()
     115        N = S.new_subspace()
     116        D = N.decomposition()
     117        e = M([0,infinity])
     118        if len(D) == 1:
     119            A = D[0]
     120        else:
     121            for x in D:
     122                if x.rational_period_mapping()(e) == 0:
     123                    A = x
     124        self._modular_symbols_subspace = A           
     125        return A
     126   
     127    def real_quadratic_field(self):
     128        """
     129        The field of definition of the dual eigenform.
     130        """
     131        try:
     132            A = self._modular_symbols_subspace
     133        except AttributeError:
     134            A = self._modular_symbols_subspace = self.modular_symbols_subspace()
     135        v = self._dual_eigenvector = A.dual_eigenvector()
     136        K_f = self._real_quadratic_field = v[0].parent()
     137        return K_f
     138
     139    def psi(self):
     140        """
     141        The embedding $\Q(\alpha) \into \Q_p(a)$ sending $\alpha \mapsto a$.
     142        """
     143        try:
     144            K_f = self._real_quadratic_field
     145        except AttributeError:
     146            K_f = self._real_quadratic_field = self.real_quadratic_field()
     147        p = self._p
     148        kbar = K_f.residue_field(p)
     149        Q = Qp(p)
     150        F = Q.extension(K_f.defining_polynomial(),names='a')
     151        a = F.gen()
     152        psi = self._psi = K_f.hom([a])
     153        return psi
     154       
     155    def modular_symbol(self,r):
     156        """
     157        Compute the modular symbol at the cusp $r$.
     158        """
     159        v = self._dual_eigenvector
     160        psi = self._psi
     161        M = self._modular_symbols_space
     162        s = M([r,infinity])
     163        return psi(v.dot_product(s.element()))
     164
     165    def abelian_variety(self):
     166        r"""
     167        Return the abelian variety to which this `p`-adic L-series is associated.
     168       
     169        EXAMPLES::
     170       
     171            sage: L = J0(23)[0].padic_lseries(5)
     172            sage: L.abelian_variety()
     173            Simple abelian variety J0(23) of dimension 2
     174
     175        """
     176        return self._J
     177
     178    def prime(self):
     179        r"""
     180        Returns the prime `p` as in 'p-adic L-function'.       
     181       
     182        EXAMPLES::
     183       
     184            sage: L = J0(23)[0].padic_lseries(5)
     185            sage: L.prime()
     186            5
     187
     188        """
     189        return self._p
     190
     191    def _repr_(self):
     192        r"""
     193        Return print representation.
     194
     195        EXAMPLES::
     196       
     197        """
     198        s = "%s-adic L-series of %s"%(self._p, self._J)
     199        if not self._normalize == 'L_ratio':
     200            s += ' (not normalized)'
     201        return s
     202   
     203    def ap(self):
     204        """
     205        Return the Hecke eigenvalue $a_p$.
     206
     207        EXAMPLES::
     208
     209            sage: J = J0(23)[0]
     210            sage: for p in prime_range(5,30):
     211            ....:     L = J.padic_lseries(p)
     212            ....:     p, L.ap()
     213            ....:     
     214            (5, 2*alpha)
     215            (7, 2*alpha + 2)
     216            (11, -2*alpha - 4)
     217            (13, 3)
     218            (17, -2*alpha + 2)
     219            (19, -2)
     220            (23, 1)
     221            (29, -3)
     222
     223        """
     224
     225        try:
     226            A = self._modular_symbols_subspace
     227        except AttributeError:
     228            A = self._modular_symbols_subspace = self.modular_symbols_subspace()
     229        a_p = self._ap = A.eigenvalue(self._p)
     230        return a_p
     231 
     232    def is_ordinary(self):
     233        """
     234        Check if $p$ is an ordinary prime.
     235        """
     236        try:
     237            K_f = self._real_quadratic_field
     238        except AttributeError:
     239            K_f = self._real_quadratic_field = self.real_quadratic_field()
     240        try:
     241            a_p = self._ap
     242        except AttributeError:
     243            a_p = self._ap = self.ap()
     244        frak_p = [x[0] for x in K_f.factor(self._p)]
     245        not_in_p = [x for x in frak_p if a_p not in frak_p]
     246        if len(not_in_p) == 0:
     247            return False
     248        else:
     249            return True
     250       
     251
     252    def measure(self, a, n, prec, quadratic_twist=+1 ):
     253        r"""
     254        Return the measure on `\ZZ_p^{\times}` defined by
     255       
     256           `\mu_{J,\alpha}^+ ( a + p^n \ZZ_p  ) =
     257           \frac{1}{\alpha^n} \left [\frac{a}{p^n}\right]^{+} -
     258           \frac{1}{\alpha^{n+1}} \left[\frac{a}{p^{n-1}}\right]^{+}`
     259
     260        where `[\cdot]^{+}` is the modular symbol. This is used to define
     261        this `p`-adic L-function (at least when the reduction is good).
     262
     263        The optional argument ``quadratic_twist`` replaces `J` by the twist in the above formula,
     264        but the twisted modular symbol is computed using a sum over modular symbols of `J`
     265        rather then finding the modular symbols for the twist.
     266       
     267        Note that the normalisation is not correct at this
     268        stage: use  ``_quotient_of periods`` and ``_quotient_of periods_to_twist``
     269        to correct.
     270
     271        Note also that this function does not check if the condition
     272        on the ``quadratic_twist=D`` is satisfied. So the result will only
     273        be correct if for each prime `\ell` dividing `D`, we have
     274        `ord_{\ell}(N)<= ord_{\ell}(D)`, where `N` is the level
     275
     276        INPUT:
     277       
     278        -  ``a`` - an integer
     279       
     280        -  ``n`` - a non-negative integer
     281       
     282        -  ``prec`` - an integer
     283       
     284        -  ``quadratic_twist`` (default = 1) - a fundamental discriminant of a quadratic field,
     285           should be coprime to the level of `J`
     286
     287        EXAMPLES::
     288       
     289
     290        """
     291       
     292        if quadratic_twist > 0:
     293            s = +1
     294        else:
     295            s = -1
     296        try:
     297            p, alpha, z, w, f = self.__measure_data[(n,prec,s)]
     298        except (KeyError, AttributeError):
     299            if not hasattr(self, '__measure_data'):
     300                self.__measure_data = {}
     301            p = self._p
     302
     303            alpha = self.alpha(prec=prec)
     304            z = 1/(alpha**n)
     305            w = p**(n-1)
     306            f = self.modular_symbol
     307
     308            self.__measure_data[(n,prec,s)] = (p,alpha,z,w,f)
     309       
     310        if quadratic_twist == 1:
     311            return z * f(a/(p*w)) - (z/alpha) * f(a/w)
     312        else:
     313            D = quadratic_twist
     314            chip = kronecker_symbol(D,p)
     315            if self._E.conductor() % p == 0:
     316                mu = chip**n * z * sum([kronecker_symbol(D,u) * f(a/(p*w)+ZZ(u)/D) for u in range(1,abs(D))])
     317            else:
     318                mu = chip**n * sum([kronecker_symbol(D,u) *(z * f(a/(p*w)+ZZ(u)/D) - chip *(z/alpha)* f(a/w+ZZ(u)/D)) for u in range(1,abs(D))])
     319            return s*mu
     320       
     321    def alpha(self, prec=20):
     322        r"""
     323        Return a `p`-adic root `\alpha` of the polynomial `x^2 - a_p x
     324        + p` with `ord_p(\alpha) < 1`.  In the ordinary case this is
     325        just the unit root.
     326
     327        INPUT:
     328        -  ``prec`` - positive integer, the `p`-adic precision of the root.
     329
     330        EXAMPLES:
     331
     332        """
     333        try:
     334            return self._alpha[prec]
     335        except AttributeError:
     336            self._alpha = {}
     337        except KeyError:
     338            pass
     339       
     340        J = self._J
     341        p = self._p
     342        Q = Qp(p)
     343        try:
     344            a_p = self._ap
     345        except AttributeError:
     346            a_p = self._ap = self.ap()
     347        try:
     348            psi = self._psi
     349        except AttributeError:
     350            psi = self._psi = self.psi()
     351        K_f = self._real_quadratic_field
     352        F = Q.extension(K_f.defining_polynomial(),names='a')
     353        a = F.gen()
     354        G = K_f.embeddings(K_f)
     355        if G[0](K_f.gen()) == K_f.gen():
     356            conj_map = G[1]
     357        else:
     358            conj_map = G[0]
     359        v = self._dual_eigenvector
     360        v_conj = vector(conj_map(a) for a in v)
     361        a_p_conj = conj_map(a_p)
     362        a_p_conj_padic = psi(a_p_conj)
     363        a_p_padic = psi(a_p)
     364        R = F['x']
     365        x = R.gen()
     366        f = x**2 - a_p_padic*x + p
     367        fconj = x**2 - a_p_conj_padic*x + p
     368        norm_f = f*fconj
     369        norm_f_basefield = norm_f.change_ring(Q)
     370        FF = norm_f_basefield().factor()
     371        root0 = -f.gcd(FF[0][0])[0]
     372        root1 = -f.gcd(FF[1][0])[0]
     373        if root0.valuation() < 1:
     374            padic_lseries_alpha = root0
     375        else:
     376            padic_lseries_alpha = root1
     377        return padic_lseries_alpha 
     378
     379    def order_of_vanishing(self):
     380        r"""
     381        Return the order of vanishing of this `p`-adic L-series.
     382
     383        The output of this function is provably correct, due to a
     384        theorem of Kato [Ka].  This function will terminate if and only if
     385        the Mazur-Tate-Teitelbaum analogue [MTT] of the BSD conjecture about
     386        the rank of the curve is true and the subgroup of elements of
     387        `p`-power order in the Shafarevich-Tate group of this curve is
     388        finite.  I.e. if this function terminates (with no errors!),
     389        then you may conclude that the `p`-adic BSD rank conjecture is
     390        true and that the `p`-part of Sha is finite.
     391
     392        NOTE: currently `p` must be a prime of good ordinary reduction.
     393       
     394        REFERENCES:
     395       
     396        - [MTT] B. Mazur, J. Tate, and J. Teitelbaum,
     397          On `p`-adic analogues of the conjectures of Birch and
     398          Swinnerton-Dyer, Inventiones mathematicae 84, (1986), 1-48.
     399
     400        - [Ka] Kayuza Kato, `p`-adic Hodge theory and values of zeta functions of modular
     401          forms, Cohomologies `p`-adiques et applications arithmetiques III,
     402          Asterisque vol 295, SMF, Paris, 2004.
     403       
     404        EXAMPLES::
     405       
     406        """
     407        try:
     408            return self.__ord
     409        except AttributeError:
     410            pass
     411       
     412        if not self.is_ordinary():
     413            raise NotImplementedError
     414        E = self.elliptic_curve()
     415        if not E.is_good(self.prime()):
     416            raise ValueError, "prime must be of good reduction"
     417        r = E.rank()
     418        n = 1
     419        while True:
     420            f = self.series(n)
     421            v = f.valuation()
     422            if v < r:
     423                raise RuntimeError, "while computing p-adic order of vanishing, got a contradiction: the curve is %s, the curve has rank %s, but the p-adic L-series vanishes to order <= %s"%(E, r, v)
     424            if v == r:
     425                self.__ord = v
     426                return v
     427            n += 1
     428
     429    def _c_bounds(self, n):
     430        raise NotImplementedError
     431
     432    def _prec_bounds(self, n,prec):
     433        raise NotImplementedError
     434
     435    def teichmuller(self, prec):
     436        r"""
     437        Return Teichmuller lifts to the given precision.
     438       
     439        INPUT:
     440       
     441        - ``prec`` - a positive integer.
     442           
     443        OUTPUT:
     444       
     445        - a list of `p`-adic numbers, the cached Teichmuller lifts
     446
     447        EXAMPLES::
     448       
     449            sage: L = EllipticCurve('11a').padic_lseries(7)
     450            sage: L.teichmuller(1)
     451            [0, 1, 2, 3, 4, 5, 6]
     452            sage: L.teichmuller(2)
     453            [0, 1, 30, 31, 18, 19, 48]
     454        """
     455        p = self._p
     456        K = Qp(p, prec, print_mode='series')       
     457        return [Integer(0)] + \
     458               [a.residue(prec).lift() for a in K.teichmuller_system()]
     459
     460    def _e_bounds(self, n, prec):
     461        p = self._p
     462        prec = max(2,prec)
     463        R = PowerSeriesRing(ZZ,'T',prec+1)
     464        T = R(R.gen(),prec +1)
     465        w = (1+T)**(p**n) - 1
     466        return [infinity] + [valuation(w[j],p) for j in range(1,min(w.degree()+1,prec))]
     467       
     468    def _get_series_from_cache(self, n, prec, D):
     469        try:
     470            return self.__series[(n,prec,D)]
     471        except AttributeError:
     472            self.__series = {}
     473        except KeyError:
     474            for _n, _prec, _D in self.__series.keys():
     475                if _n == n and _D == D and _prec >= prec: 
     476                    return self.__series[(_n,_prec,_D)].add_bigoh(prec)
     477        return None
     478
     479    def _set_series_in_cache(self, n, prec, D, f):
     480        self.__series[(n,prec,D)] = f
     481 
     482
     483    def _quotient_of_periods_to_twist(self,D):
     484        r"""
     485        For a fundamental discriminant `D` of a quadratic number field this computes the constant `\eta` such that
     486        `\sqrt{D}\cdot\Omega_{E_D}^{+} =\eta\cdot \Omega_E^{sign(D)}`. As in [MTT]_ page 40.
     487        This is either 1 or 2 unless the condition on the twist is not satisfied, e.g. if we are 'twisting back'
     488        to a semi-stable curve.
     489       
     490        REFERENCES:
     491       
     492        - [MTT] B. Mazur, J. Tate, and J. Teitelbaum,
     493          On `p`-adic analogues of the conjectures of Birch and
     494          Swinnerton-Dyer, Invertiones mathematicae 84, (1986), 1-48.       
     495       
     496        .. note: No check on precision is made, so this may fail for huge `D`.
     497       
     498        EXAMPLES::
     499       
     500        """
     501        from sage.functions.all import sqrt
     502        # This funciton does not depend on p and could be moved out of this file but it is needed only here
     503       
     504        # Note that the number of real components does not change by twisting.
     505        if D == 1:
     506            return 1
     507        if D > 1:
     508            Et = self._E.quadratic_twist(D)
     509            qt = Et.period_lattice().basis()[0]/self._E.period_lattice().basis()[0]
     510            qt *= sqrt(qt.parent()(D))
     511        else:
     512            Et = self._E.quadratic_twist(D)
     513            qt = Et.period_lattice().basis()[0]/self._E.period_lattice().basis()[1].imag()
     514            qt *= sqrt(qt.parent()(-D))
     515        verbose('the real approximation is %s'%qt)
     516        # we know from MTT that the result has a denominator 1
     517        return QQ(int(round(8*qt)))/8
     518   
     519
     520class pAdicLseriesOrdinary(pAdicLseries):
     521    def series(self, n=2, quadratic_twist=+1, prec=5):
     522        r"""
     523        Returns the `n`-th approximation to the `p`-adic L-series as
     524        a power series in `T` (corresponding to `\gamma-1` with
     525        `\gamma=1+p` as a generator of `1+p\ZZ_p`).  Each
     526        coefficient is a `p`-adic number whose precision is provably
     527        correct.
     528       
     529        Here the normalization of the `p`-adic L-series is chosen
     530        such that `L_p(J,1) = (1-1/\alpha)^2 L(J,1)/\Omega_J`
     531        where `\alpha` is the unit root
     532
     533        INPUT:
     534       
     535        -  ``n`` - (default: 2) a positive integer
     536        -  ``quadratic_twist`` - (default: +1) a fundamental discriminant
     537           of a quadratic field, coprime to the
     538           conductor of the curve
     539        -  ``prec`` - (default: 5) maximal number of terms of the series
     540           to compute; to compute as many as possible just
     541           give a very large number for ``prec``; the result will
     542           still be correct.
     543
     544        ALIAS: power_series is identical to series.
     545
     546        EXAMPLES:
     547
     548            sage: J = J0(188)[0]
     549            sage: p = 7
     550            sage: L = J.padic_lseries(p)
     551            sage: L.is_ordinary()
     552            True
     553            sage: f = L.series(2)
     554            sage: f[0]
     555            O(7^20)
     556            sage: f[1].norm()
     557            3 + 4*7 + 3*7^2 + 6*7^3 + 5*7^4 + 5*7^5 + 6*7^6 + 4*7^7 + 5*7^8 + 7^10 + 5*7^11 + 4*7^13 + 4*7^14 + 5*7^15 + 2*7^16 + 5*7^17 + 7^18 + 7^19 + O(7^20)
     558
     559        """
     560        n = ZZ(n)
     561        if n < 1:
     562            raise ValueError, "n (=%s) must be a positive integer"%n
     563        if not self.is_ordinary():
     564            raise ValueError, "p (=%s) must be an ordinary prime"%p
     565        # check if the conditions on quadratic_twist are satisfied
     566        D = ZZ(quadratic_twist)
     567        if D != 1:
     568            if D % 4 == 0:
     569                d = D//4
     570                if not d.is_squarefree() or d % 4 == 1:
     571                    raise ValueError, "quadratic_twist (=%s) must be a fundamental discriminant of a quadratic field"%D
     572            else:
     573                if not D.is_squarefree() or D % 4 != 1:
     574                    raise ValueError, "quadratic_twist (=%s) must be a fundamental discriminant of a quadratic field"%D
     575            if gcd(D,self._p) != 1:
     576                raise ValueError, "quadratic twist (=%s) must be coprime to p (=%s) "%(D,self._p)
     577            if gcd(D,self._E.conductor())!= 1:
     578                for ell in prime_divisors(D):
     579                    if valuation(self._E.conductor(),ell) > valuation(D,ell) :
     580                        raise ValueError, "can not twist a curve of conductor (=%s) by the quadratic twist (=%s)."%(self._E.conductor(),D)
     581                   
     582           
     583        p = self._p
     584        if p == 2 and self._normalize :
     585            print 'Warning : For p=2 the normalization might not be correct !'
     586        #verbose("computing L-series for p=%s, n=%s, and prec=%s"%(p,n,prec))
     587       
     588#        bounds = self._prec_bounds(n,prec)
     589#        padic_prec = max(bounds[1:]) + 5
     590        padic_prec = 10
     591#        verbose("using p-adic precision of %s"%padic_prec)
     592       
     593        res_series_prec = min(p**(n-1), prec)
     594        verbose("using series precision of %s"%res_series_prec)
     595       
     596        ans = self._get_series_from_cache(n, res_series_prec,D)
     597        if not ans is None:
     598            verbose("found series in cache")
     599            return ans
     600 
     601        K = QQ
     602        gamma = K(1 + p)
     603        R = PowerSeriesRing(K,'T',res_series_prec)
     604        T = R(R.gen(),res_series_prec )
     605        L = R(0)
     606        one_plus_T_factor = R(1)
     607        gamma_power = K(1)
     608        teich = self.teichmuller(padic_prec)
     609        p_power = p**(n-1)
     610
     611        verbose("Now iterating over %s summands"%((p-1)*p_power))
     612        verbose_level = get_verbose()
     613        count_verb = 0
     614        for j in range(p_power):
     615            s = K(0)
     616            if verbose_level >= 2 and j/p_power*100 > count_verb + 3:
     617                verbose("%.2f percent done"%(float(j)/p_power*100))
     618                count_verb += 3
     619            for a in range(1,p):
     620                b = teich[a] * gamma_power
     621                s += self.measure(b, n, padic_prec,quadratic_twist=D)
     622            L += s * one_plus_T_factor
     623            one_plus_T_factor *= 1+T
     624            gamma_power *= gamma
     625
     626#        verbose("the series before adjusting the precision is %s"%L)
     627        # Now create series but with each coefficient truncated
     628        # so it is proven correct:
     629#        K = Qp(p, padic_prec, print_mode='series')
     630#        R = PowerSeriesRing(K,'T',res_series_prec)
     631#        L = R(L,res_series_prec)
     632#        aj = L.list()
     633#        if len(aj) > 0:
     634#            aj = [aj[0].add_bigoh(padic_prec-2)] + [aj[j].add_bigoh(bounds[j]) for j in range(1,len(aj))]
     635#        L = R(aj,res_series_prec )
     636       
     637#        L /= self._quotient_of_periods_to_twist(D)*self._E.real_components()
     638       
     639#        self._set_series_in_cache(n, res_series_prec, D, L)
     640       
     641        return L
     642
     643    power_series = series
     644
     645
     646
     647#    def _c_bound(self):
     648#        try:
     649#            return self.__c_bound
     650#        except AttributeError:
     651#            pass
     652#        E = self._E
     653#        p = self._p
     654#        if E.galois_representation().is_irreducible(p):
     655#            ans = 0
     656#        else:
     657#            m = E.modular_symbol_space(sign=1)
     658#            b = m.boundary_map().codomain()
     659#            C = b._known_cusps()  # all known, since computed the boundary map
     660#            ans = max([valuation(self.modular_symbol(a).denominator(), p) for a in C])
     661#        self.__c_bound = ans
     662#        return ans
     663               
     664#    def _prec_bounds(self, n, prec):
     665#        p = self._p
     666#        e = self._e_bounds(n-1, prec)
     667#        c = self._c_bound()
     668#        return [e[j] - c for j in range(len(e))]
     669
     670
  • new file sage/modular/abvar/padics.py

    diff -r 9e6c9dd499ff -r cebe47683ff6 sage/modular/abvar/padics.py
    - +  
     1"""
     2Miscellaneous p-adic functions
     3
     4p-adic functions from ell_rational_field.py, moved here to reduce
     5crowding in that file.
     6"""
     7
     8######################################################################
     9#       Copyright (C) 2007 William Stein <wstein@gmail.com>
     10#
     11#  Distributed under the terms of the GNU General Public License (GPL)
     12#
     13#    This code is distributed in the hope that it will be useful,
     14#    but WITHOUT ANY WARRANTY; without even the implied warranty of
     15#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     16#    General Public License for more details.
     17#
     18#  The full text of the GPL is available at:
     19#
     20#                  http://www.gnu.org/licenses/
     21######################################################################
     22
     23
     24import sage.rings.all as rings
     25import padic_lseries as plseries
     26import sage.rings.arith as arith
     27from sage.rings.all import (
     28    Qp,
     29    Integers,
     30    Integer,
     31    O,
     32    PowerSeriesRing,
     33    LaurentSeriesRing,
     34    RationalField)
     35import math
     36import sage.misc.misc as misc
     37import sage.matrix.all as matrix
     38sqrt = math.sqrt
     39
     40
     41def __check_padic_hypotheses(self, p):
     42    p = rings.Integer(p)
     43    if not p.is_prime():
     44        raise ValueError, "p = (%s) must be prime"%p
     45    if p == 2:
     46        raise ValueError, "p must be odd"
     47    if self.conductor() % p == 0 or self.ap(p) % p == 0:
     48        raise ArithmeticError, "p must be a good ordinary prime"
     49    return p
     50
     51
     52def padic_lseries(self, p, normalize='L_ratio',):
     53    r"""
     54    Return the `p`-adic `L`-series of self at
     55    `p`, which is an object whose approx method computes
     56    approximation to the true `p`-adic `L`-series to
     57    any desired precision.
     58   
     59    INPUT:
     60   
     61   
     62    -  ``p`` - prime
     63   
     64    -  ``normalize`` -  'L_ratio' (default), 'period' or 'none';
     65       this is describes the way the modular symbols
     66       are normalized. See modular_symbol for
     67       more details.
     68   
     69   
     70    EXAMPLES::
     71   
     72        sage: J = J0(37)[0]
     73        sage: L = J.padic_lseries(5); L
     74        5-adic L-series of Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field
     75        sage: type(L)
     76        <class 'sage.schemes.elliptic_curves.padic_lseries.pAdicLseriesOrdinary'>
     77   
     78    We compute the `3`-adic `L`-series of two curves of
     79    rank `0` and in each case verify the interpolation property
     80    for their leading coefficient (i.e., value at 0)::
     81   
     82        sage: e = EllipticCurve('11a')
     83        sage: ms = e.modular_symbol()
     84        sage: [ms(1/11), ms(1/3), ms(0), ms(oo)]
     85        [0, -3/10, 1/5, 0]
     86        sage: ms(0)
     87        1/5
     88        sage: L = e.padic_lseries(3)
     89        sage: P = L.series(5)
     90        sage: P(0)
     91        2 + 3 + 3^2 + 2*3^3 + 2*3^5 + 3^6 + O(3^7)
     92        sage: alpha = L.alpha(9); alpha
     93        2 + 3^2 + 2*3^3 + 2*3^4 + 2*3^6 + 3^8 + O(3^9)
     94        sage: R.<x> = QQ[]
     95        sage: f = x^2 - e.ap(3)*x + 3
     96        sage: f(alpha)
     97        O(3^9)
     98        sage: r = e.lseries().L_ratio(); r
     99        1/5
     100        sage: (1 - alpha^(-1))^2 * r
     101        2 + 3 + 3^2 + 2*3^3 + 2*3^5 + 3^6 + 3^7 + O(3^9)
     102        sage: P(0)
     103        2 + 3 + 3^2 + 2*3^3 + 2*3^5 + 3^6 + O(3^7)
     104   
     105    Next consider the curve 37b::
     106   
     107        sage: e = EllipticCurve('37b')
     108        sage: L = e.padic_lseries(3)
     109        sage: P = L.series(5)
     110        sage: alpha = L.alpha(9); alpha
     111        1 + 2*3 + 3^2 + 2*3^5 + 2*3^7 + 3^8 + O(3^9)
     112        sage: r = e.lseries().L_ratio(); r
     113        1/3
     114        sage: (1 - alpha^(-1))^2 * r
     115        3 + 3^2 + 2*3^4 + 2*3^5 + 2*3^6 + 3^7 + O(3^9)
     116        sage: P(0)
     117        3 + 3^2 + 2*3^4 + 2*3^5 + O(3^6)
     118   
     119    We can use eclib to compute the `L`-series::
     120 
     121        sage: e = EllipticCurve('11a')
     122        sage: L = e.padic_lseries(3,use_eclib=True)
     123        sage: L.series(5,prec=10)
     124        1 + 2*3^3 + 3^6 + O(3^7) + (2 + 2*3 + 3^2 + O(3^4))*T + (2 + 3 + 3^2 + 2*3^3 + O(3^4))*T^2 + (2*3 + 3^2 + O(3^3))*T^3 + (3 + 2*3^3 + O(3^4))*T^4 + (1 + 2*3 + 2*3^2 + O(3^4))*T^5 + (2 + 2*3^2 + O(3^3))*T^6 + (1 + 3 + 2*3^2 + 3^3 + O(3^4))*T^7 + (1 + 2*3 + 3^2 + 2*3^3 + O(3^4))*T^8 + (1 + 3 + O(3^2))*T^9 + O(T^10)
     125   
     126    """
     127    key = (p, normalize)
     128    try:
     129        return self._padic_lseries[key]
     130    except AttributeError:
     131        self._padic_lseries = {}
     132    except KeyError:
     133        pass
     134
     135#    if self.ap(p) % p != 0:
     136    Lp = plseries.pAdicLseriesOrdinary(self, p,normalize = normalize)
     137#    else:
     138#        Lp = plseries.pAdicLseriesSupersingular(self, p,
     139#                              normalize = normalize, use_eclib=use_eclib)
     140    self._padic_lseries[key] = Lp
     141    return Lp
     142