Path: blob/master/sage/modular/overconvergent/genus0.py
4091 views
# -*- coding: utf-8 -*-1r"""2Overconvergent p-adic modular forms for small primes34This module implements computations of Hecke operators and `U_p`-eigenfunctions5on `p`-adic overconvergent modular forms of tame level 1, where `p` is one of6the primes `\{2, 3, 5, 7, 13\}`, using the algorithms described in [Loe2007]_.78.. [Loe2007] David Loeffler, *Spectral expansions of overconvergent modular functions*,9Int. Math. Res. Not 2007 (050). `Arxiv preprint <http://uk.arxiv.org/abs/math/0701168>`_.1011AUTHORS:1213- David Loeffler (August 2008): initial version14- David Loeffler (March 2009): extensively reworked15- Lloyd Kilford (May 2009): add16:meth:`~sage.modular.overconvergent.genus0.OverconvergentModularFormsSpace.slopes`17method18- David Loeffler (June 2009): miscellaneous bug fixes and usability improvements1920The Theory21~~~~~~~~~~2223Let `p` be one of the above primes, so `X_0(p)` has genus 0, and let2425.. math::2627f_p = \sqrt[p-1]{\frac{\Delta(pz)}{\Delta(z)}}2829(an `\eta`-product of level `p` -- see module :mod:`sage.modular.etaproducts`).30Then one can show that `f_p` gives an isomorphism `X_0(p) \to \mathbb{P}^1`.31Furthermore, if we work over `\CC_p`, the `r`-overconvergent locus on `X_0(p)`32(or of `X_0(1)`, via the canonical subgroup lifting), corresponds to the33`p`-adic disc3435.. math::3637|f_p|_p \le p^{\frac{12r}{p-1}}.3839(This is Theorem 1 of [Loe2007]_.)4041Hence if we fix an element `c` with `|c| = p^{-\frac{12r}{p-1}}`, the space42`S_k^\dag(1, r)` of overconvergent `p`-adic modular forms has an orthonormal43basis given by the functions `(cf)^n`. So any element can be written in the44form `E_k \times \sum_{n \ge 0} a_n (cf)^n`, where `a_n \to 0` as `N \to45\infty`, and any such sequence `a_n` defines a unique overconvergent form.4647One can now find the matrix of Hecke operators in this basis, either by48calculating `q`-expansions, or (for the special case of `U_p`) using a49recurrence formula due to Kolberg.5051An Extended Example52~~~~~~~~~~~~~~~~~~~5354We create a space of 3-adic modular forms::5556sage: M = OverconvergentModularForms(3, 8, 1/6, prec=60)5758Creating an element directly as a linear combination of basis vectors.5960.. link6162::6364sage: f1 = M.3 + M.5; f1.q_expansion()6527*q^3 + 1055916/1093*q^4 + 19913121/1093*q^5 + 268430112/1093*q^6 + ...66sage: f1.coordinates(8)67[0, 0, 0, 1, 0, 1, 0, 0]6869We can coerce from elements of classical spaces of modular forms:7071.. link7273::7475sage: f2 = M(CuspForms(3, 8).0); f2763-adic overconvergent modular form of weight-character 8 with q-expansion q + 6*q^2 - 27*q^3 - 92*q^4 + 390*q^5 - 162*q^6 ...7778We express this in a basis, and see that the coefficients go to zero very fast:7980.. link8182::8384sage: [x.valuation(3) for x in f2.coordinates(60)]85[+Infinity, -1, 3, 6, 10, 13, 18, 20, 24, 27, 31, 34, 39, 41, 45, 48, 52, 55, 61, 62, 66, 69, 73, 76, 81, 83, 87, 90, 94, 97, 102, 104, 108, 111, 115, 118, 124, 125, 129, 132, 136, 139, 144, 146, 150, 153, 157, 160, 165, 167, 171, 174, 178, 181, 188, 188, 192, 195, 199, 202]8687This form has more level at `p`, and hence is less overconvergent:8889.. link9091::9293sage: f3 = M(CuspForms(9, 8).0); [x.valuation(3) for x in f3.coordinates(60)]94[+Infinity, -1, -1, 0, -4, -4, -2, -3, 0, 0, -1, -1, 1, 0, 3, 3, 3, 3, 5, 3, 7, 7, 6, 6, 8, 7, 10, 10, 8, 8, 10, 9, 12, 12, 12, 12, 14, 12, 17, 16, 15, 15, 17, 16, 19, 19, 18, 18, 20, 19, 22, 22, 22, 22, 24, 21, 25, 26, 24, 24]9596An error will be raised for forms which are not sufficiently overconvergent:9798.. link99100::101102sage: M(CuspForms(27, 8).0)103Traceback (most recent call last):104...105ValueError: Form is not overconvergent enough (form is only 1/12-overconvergent)106107Let's compute some Hecke operators. Note that the coefficients of this matrix are `p`-adically tiny:108109.. link110111::112113sage: M.hecke_matrix(3, 4).change_ring(Qp(3,prec=1))114[ 1 + O(3) 0 0 0]115[ 0 2*3^3 + O(3^4) 2*3^3 + O(3^4) 3^2 + O(3^3)]116[ 0 2*3^7 + O(3^8) 2*3^8 + O(3^9) 3^6 + O(3^7)]117[ 0 2*3^10 + O(3^11) 2*3^10 + O(3^11) 2*3^9 + O(3^10)]118119We compute the eigenfunctions of a 4x4 truncation:120121.. link122123::124125sage: efuncs = M.eigenfunctions(4)126sage: for i in [1..3]:127... print efuncs[i].q_expansion(prec=4).change_ring(Qp(3,prec=20))128(1 + O(3^20))*q + (2*3 + 3^15 + 3^16 + 3^17 + 2*3^19 + 2*3^20 + O(3^21))*q^2 + (2*3^3 + 2*3^4 + 2*3^5 + 2*3^6 + 2*3^7 + 2*3^8 + 2*3^9 + 2*3^10 + 2*3^11 + 2*3^12 + 2*3^13 + 2*3^14 + 2*3^15 + 2*3^16 + 3^17 + 2*3^18 + 2*3^19 + 3^21 + 3^22 + O(3^23))*q^3 + O(q^4)129(1 + O(3^20))*q + (3 + 2*3^2 + 3^3 + 3^4 + 3^12 + 3^13 + 2*3^14 + 3^15 + 2*3^17 + 3^18 + 3^19 + 3^20 + O(3^21))*q^2 + (3^7 + 3^13 + 2*3^14 + 2*3^15 + 3^16 + 3^17 + 2*3^18 + 3^20 + 2*3^21 + 2*3^22 + 2*3^23 + 2*3^25 + O(3^27))*q^3 + O(q^4)130(1 + O(3^20))*q + (2*3 + 3^3 + 2*3^4 + 3^6 + 2*3^8 + 3^9 + 3^10 + 2*3^11 + 2*3^13 + 3^16 + 3^18 + 3^19 + 3^20 + O(3^21))*q^2 + (3^9 + 2*3^12 + 3^15 + 3^17 + 3^18 + 3^19 + 3^20 + 2*3^22 + 2*3^23 + 2*3^27 + 2*3^28 + O(3^29))*q^3 + O(q^4)131132The first eigenfunction is a classical cusp form of level 3:133134.. link135136::137138sage: (efuncs[1] - M(CuspForms(3, 8).0)).valuation()13913140141The second is an Eisenstein series!142143.. link144145::146147sage: (efuncs[2] - M(EisensteinForms(3, 8).1)).valuation()14810149150The third is a genuinely new thing (not a classical modular form at all); the151coefficients are almost certainly not algebraic over `\QQ`. Note that the slope152is 9, so Coleman's classicality criterion (forms of slope `< k-1` are153classical) does not apply.154155.. link156157::158159sage: a3 = efuncs[3].q_expansion()[3]; a31603^9 + 2*3^12 + 3^15 + 3^17 + 3^18 + 3^19 + 3^20 + 2*3^22 + 2*3^23 + 2*3^27 + 2*3^28 + 3^32 + 3^33 + 2*3^34 + 3^38 + 2*3^39 + 3^40 + 2*3^41 + 3^44 + 3^45 + 3^46 + 2*3^47 + 2*3^48 + 3^49 + 3^50 + 2*3^51 + 2*3^52 + 3^53 + 2*3^54 + 3^55 + 3^56 + 3^57 + 2*3^58 + 2*3^59 + 3^60 + 2*3^61 + 2*3^63 + 2*3^64 + 3^65 + 2*3^67 + 3^68 + 2*3^69 + 2*3^71 + 3^72 + 2*3^74 + 3^75 + 3^76 + 3^79 + 3^80 + 2*3^83 + 2*3^84 + 3^85 + 2*3^87 + 3^88 + 2*3^89 + 2*3^90 + 2*3^91 + 3^92 + O(3^98)161sage: efuncs[3].slope()1629163164-----------165"""166167#*****************************************************************************168# Copyright (C) 2008 William Stein <[email protected]>169# 2008-9 David Loeffler <[email protected]>170#171# Distributed under the terms of the GNU General Public License (GPL)172# http://www.gnu.org/licenses/173#*****************************************************************************174175176from sage.matrix.all import matrix, MatrixSpace, diagonal_matrix177from sage.misc.misc import verbose178from sage.misc.cachefunc import cached_method179from sage.modular.all import (DirichletGroup, trivial_character, EtaProduct,180j_invariant_qexp, hecke_operator_on_qexp)181from sage.modular.arithgroup.all import (Gamma1, is_Gamma0, is_Gamma1)182from sage.modular.modform.element import ModularFormElement183from sage.modules.all import vector184from sage.modules.module import Module_old185from sage.structure.element import Vector, ModuleElement186from sage.plot.plot import plot187from sage.rings.all import (O, Infinity, ZZ, QQ, pAdicField, PolynomialRing, PowerSeriesRing, is_pAdicField)188import weakref189190from weightspace import WeightSpace_constructor as WeightSpace, WeightCharacter191__ocmfdict = {}192193####################194# Factory function #195####################196197def OverconvergentModularForms(prime, weight, radius, base_ring=QQ, prec = 20, char = None):198r"""199Create a space of overconvergent `p`-adic modular forms of level200`\Gamma_0(p)`, over the given base ring. The base ring need not be a201`p`-adic ring (the spaces we compute with typically have bases over202`\QQ`).203204INPUT:205206- ``prime`` - a prime number `p`, which must be one of the primes `\{2, 3,2075, 7, 13\}`, or the congruence subgroup `\Gamma_0(p)` where `p` is one of these208primes.209210- ``weight`` - an integer (which at present must be 0 or `\ge 2`), the211weight.212213- ``radius`` - a rational number in the interval `\left( 0, \frac{p}{p+1}214\right)`, the radius of overconvergence.215216- ``base_ring`` (default: `\QQ`), a ring over which to compute. This217need not be a `p`-adic ring.218219- ``prec`` - an integer (default: 20), the number of `q`-expansion terms to220compute.221222- ``char`` - a Dirichlet character modulo `p` or ``None`` (the default).223Here ``None`` is interpreted as the trivial character modulo `p`.224225The character `\chi` and weight `k` must satisfy `(-1)^k = \chi(-1)`, and226the base ring must contain an element `v` such that227`{\rm ord}_p(v) = \frac{12 r}{p-1}` where `r` is the radius of228overconvergence (and `{\rm ord}_p` is normalised so `{\rm ord}_p(p) = 1`).229230EXAMPLES::231232sage: OverconvergentModularForms(3, 0, 1/2)233Space of 3-adic 1/2-overconvergent modular forms of weight-character 0 over Rational Field234sage: OverconvergentModularForms(3, 16, 1/2)235Space of 3-adic 1/2-overconvergent modular forms of weight-character 16 over Rational Field236sage: OverconvergentModularForms(3, 3, 1/2, char = DirichletGroup(3,QQ).0)237Space of 3-adic 1/2-overconvergent modular forms of weight-character (3, 3, [-1]) over Rational Field238"""239if is_Gamma0(prime) or is_Gamma1(prime):240prime = prime.level()241else:242prime = ZZ(prime)243if char is None:244char = trivial_character(prime, base_ring=QQ)245if int(prime) not in [2, 3, 5, 7, 13]:246raise ValueError, "p must be one of {2, 3, 5, 7, 13}"247key = (prime, weight, radius, base_ring, prec, char)248if __ocmfdict.has_key(key):249w = __ocmfdict[key]250M = w()251if not (M is None):252return M253M = OverconvergentModularFormsSpace(*key)254__ocmfdict[key] = weakref.ref(M)255return M256257#########################258# Main class definition #259#########################260261class OverconvergentModularFormsSpace(Module_old):262r"""263A space of overconvergent modular forms of level `\Gamma_0(p)`,264where `p` is a prime such that `X_0(p)` has genus 0.265266Elements are represented as power series, with a formal power series `F`267corresponding to the modular form `E_k^\ast \times F(g)` where `E_k^\ast`268is the `p`-deprived Eisenstein series of weight-character `k`, and `g` is a269uniformiser of `X_0(p)` normalised so that the `r`-overconvergent region270`X_0(p)_{\ge r}` corresponds to `|g| \le 1`.271272TESTS::273274sage: K.<w> = Qp(13).extension(x^2-13); M = OverconvergentModularForms(13, 20, radius=1/2, base_ring=K)275sage: M is loads(dumps(M))276True277"""278279###############280# Init script #281###############282283def __init__(self, prime, weight, radius, base_ring, prec, char):284r"""285Create a space of overconvergent `p`-adic modular forms of level286`\Gamma_0(p)`, over the given base ring. The base ring need not be a287`p`-adic ring (the spaces we compute with typically have bases over288`\QQ`).289290EXAMPLES::291292sage: OverconvergentModularForms(3, 0, 1/2)293Space of 3-adic 1/2-overconvergent modular forms of weight-character 0 over Rational Field294"""295296self._p = prime297298if not ( base_ring == QQ or is_pAdicField(base_ring) ):299raise TypeError, "Base ring must be QQ or a p-adic field"300301if base_ring != QQ and base_ring.prime() != self._p:302raise TypeError, "Residue characteristic of base ring (=%s) must be %s" % (base_ring, self._p)303304if isinstance(weight, WeightCharacter):305self._wtchar = weight306else:307self._wtchar = WeightSpace(prime, base_ring = char.base_ring())(weight, char, algebraic=True)308309if not self._wtchar.is_even():310raise ValueError, "Weight-character must be even"311312Module_old.__init__(self, base_ring)313314self._prec = prec315316self._qsr = PowerSeriesRing(base_ring, 'q', prec) # q-series ring317self._gsr = PowerSeriesRing(base_ring, 'g', prec) # g-adic expansions, g = c*f318319self._cached_recurrence_matrix = None320self._set_radius(radius)321self._basis_cache = [self._wtchar.pAdicEisensteinSeries(self._qsr, self.prec())]322self._uniformiser = self._qsr(EtaProduct(prime, {prime: 24/ZZ(prime-1), ZZ(1):-24/ZZ(prime-1)}).qexp(self.prec()))323324for i in xrange(1, self.prec()):325self._basis_cache.append(self._basis_cache[-1] * self._uniformiser * self._const)326327#####################################328# Methods called by the init script #329#####################################330331def _set_radius(self, radius):332r"""333Set the radius of overconvergence to be `r`, where `r` is a rational334number in the interval `0 < r < \frac{p}{p+1}`.335336This only makes sense if the base ring contains an element of337normalised valuation `\frac{12r}{p-1}`. If this valuation is an338integer, we use the appropriate power of `p`. Otherwise, we assume the339base ring has a ``uniformiser`` method and take an appropriate power of340the uniformiser, raising an error if no such element exists.341342EXAMPLES::343344sage: M = OverconvergentModularForms(3, 2, 1/2) # indirect doctest345sage: M._set_radius(1/3); M346Space of 3-adic 1/3-overconvergent modular forms of weight-character 2 over Rational Field347348sage: L.<w> = Qp(3).extension(x^5 - 3)349sage: OverconvergentModularForms(3, 2, 1/30, base_ring=L).normalising_factor() # indirect doctest350w + O(w^101)351352sage: OverconvergentModularForms(3, 2, 1/40, base_ring=L)353Traceback (most recent call last):354...355ValueError: no element of base ring (=Eisenstein Extension ...) has normalised valuation 3/20356"""357358p = ZZ(self.prime())359360if (radius < 0 or radius > p/(p+1)):361raise ValueError, "radius (=%s) must be between 0 and p/(p+1)" % radius362d = 12/(p-1)*radius363if d.is_integral():364self._const = p ** ZZ(d)365self._radius = radius366else:367try:368pi = self.base_ring().uniformiser()369e = d / pi.normalized_valuation()370except AttributeError: # base ring isn't a p-adic ring371pi = p372e = d373if not e.is_integral():374raise ValueError, "no element of base ring (=%s) has normalised valuation %s" % (self.base_ring(), radius * 12 /(p-1))375self._radius = radius376self._const = pi ** ZZ(e)377378##############################################379# Boring functions that access internal data #380##############################################381382def is_exact(self):383r"""384True if elements of this space are represented exactly, i.e., there is385no precision loss when doing arithmetic. As this is never true for386overconvergent modular forms spaces, this returns False.387388EXAMPLES::389390sage: OverconvergentModularForms(13, 12, 0).is_exact()391False392"""393return False394395def change_ring(self, ring):396r"""397Return the space corresponding to self but over the given base ring.398399EXAMPLES::400401sage: M = OverconvergentModularForms(2, 0, 1/2)402sage: M.change_ring(Qp(2))403Space of 2-adic 1/2-overconvergent modular forms of weight-character 0 over 2-adic Field with ...404"""405return OverconvergentModularForms(self.prime(), self.weight(), self.radius(), ring, self.prec(), self.character())406407def base_extend(self, ring):408r"""409Return the base extension of self to the given base ring. There must be410a canonical map to this ring from the current base ring, otherwise a411TypeError will be raised.412413EXAMPLES::414415sage: M = OverconvergentModularForms(2, 0, 1/2, base_ring = Qp(2))416sage: M.base_extend(Qp(2).extension(x^2 - 2, names="w"))417Space of 2-adic 1/2-overconvergent modular forms of weight-character 0 over Eisenstein Extension of 2-adic Field ...418sage: M.base_extend(QQ)419Traceback (most recent call last):420...421TypeError: Base extension of self (over '2-adic Field with capped relative precision 20') to ring 'Rational Field' not defined.422"""423if ring.has_coerce_map_from(self.base_ring()):424return self.change_ring(ring)425else:426raise TypeError, "Base extension of self (over '%s') to ring '%s' not defined." % (self.base_ring(), ring)427428def _an_element_impl(self):429r"""430Return an element of this space (used by the coercion machinery).431432EXAMPLE::433434sage: OverconvergentModularForms(3, 2, 1/3, prec=4).an_element() # indirect doctest4353-adic overconvergent modular form of weight-character 2 with q-expansion 9*q + 216*q^2 + 2430*q^3 + O(q^4)436"""437return OverconvergentModularFormElement(self, self._gsr.an_element())438439def character(self):440r"""441Return the character of self. For overconvergent forms, the weight and442the character are unified into the concept of a weight-character, so443this returns exactly the same thing as self.weight().444445EXAMPLE::446447sage: OverconvergentModularForms(3, 0, 1/2).character()4480449sage: type(OverconvergentModularForms(3, 0, 1/2).character())450<class '...weightspace.AlgebraicWeight'>451sage: OverconvergentModularForms(3, 3, 1/2, char=DirichletGroup(3,QQ).0).character()452(3, 3, [-1])453"""454return self._wtchar455456def weight(self):457r"""458Return the character of self. For overconvergent forms, the weight and459the character are unified into the concept of a weight-character, so460this returns exactly the same thing as self.character().461462EXAMPLE::463464sage: OverconvergentModularForms(3, 0, 1/2).weight()4650466sage: type(OverconvergentModularForms(3, 0, 1/2).weight())467<class '...weightspace.AlgebraicWeight'>468sage: OverconvergentModularForms(3, 3, 1/2, char=DirichletGroup(3,QQ).0).weight()469(3, 3, [-1])470"""471return self._wtchar472473474def normalising_factor(self):475r"""476The normalising factor `c` such that `g = c f` is a parameter for the477`r`-overconvergent disc in `X_0(p)`, where `f` is the standard478uniformiser.479480EXAMPLE::481482sage: L.<w> = Qp(7).extension(x^2 - 7)483sage: OverconvergentModularForms(7, 0, 1/4, base_ring=L).normalising_factor()484w + O(w^41)485"""486return self._const487488def __cmp__(self, other):489r"""490Compare self to other.491492EXAMPLES::493494sage: OverconvergentModularForms(3, 12, 1/2) == ModularForms(3, 12)495False496sage: OverconvergentModularForms(3, 0, 1/2) == OverconvergentModularForms(3, 0, 1/3)497False498sage: OverconvergentModularForms(3, 0, 1/2) == OverconvergentModularForms(3, 0, 1/2, base_ring = Qp(3))499False500sage: OverconvergentModularForms(3, 0, 1/2) == OverconvergentModularForms(3, 0, 1/2)501True502"""503if not isinstance(other, OverconvergentModularFormsSpace):504return cmp(type(self), type(other))505else:506return cmp(self._params(), other._params())507508def _params(self):509r"""510Return the parameters that define this module uniquely: prime, weight,511character, radius of overconvergence and base ring. Mostly used for512pickling.513514EXAMPLES::515516sage: L.<w> = Qp(7).extension(x^2 - 7)517sage: OverconvergentModularForms(7, 0, 1/4, base_ring=L)._params()518(7, 0, 1/4, Eisenstein Extension ..., 20, Dirichlet character modulo 7 of conductor 1 mapping 3 |--> 1)519520"""521return (self.prime(), self.weight().k(), self.radius(), self.base_ring(), self.prec(), self.weight().chi())522523def __reduce__(self):524r"""525Return the function and arguments used to construct self. Used for pickling.526527EXAMPLES::528529sage: L.<w> = Qp(7).extension(x^2 - 7)530sage: OverconvergentModularForms(7, 0, 1/4, base_ring=L).__reduce__()531(<function OverconvergentModularForms at ...>, (7, 0, 1/4, Eisenstein Extension ..., 20, Dirichlet character modulo 7 of conductor 1 mapping 3 |--> 1))532533"""534return (OverconvergentModularForms, self._params())535536def gen(self, i):537r"""538Return the ith module generator of self.539540EXAMPLE::541542sage: M = OverconvergentModularForms(3, 2, 1/2, prec=4)543sage: M.gen(0)5443-adic overconvergent modular form of weight-character 2 with q-expansion 1 + 12*q + 36*q^2 + 12*q^3 + O(q^4)545sage: M.gen(1)5463-adic overconvergent modular form of weight-character 2 with q-expansion 27*q + 648*q^2 + 7290*q^3 + O(q^4)547sage: M.gen(30)5483-adic overconvergent modular form of weight-character 2 with q-expansion O(q^4)549"""550551return OverconvergentModularFormElement(self, gexp=self._gsr.gen()**i)552553def _repr_(self):554r"""555Return a string representation of self.556557EXAMPLES::558559sage: OverconvergentModularForms(3, 0, 1/2)._repr_()560'Space of 3-adic 1/2-overconvergent modular forms of weight-character 0 over Rational Field'561"""562return "Space of %s-adic %s-overconvergent modular forms of weight-character %s over %s" % (self.prime(), self.radius(), self.weight(), self.base_ring())563564def prime(self):565r"""566Return the residue characteristic of self, i.e. the prime `p` such that567this is a `p`-adic space.568569EXAMPLES::570571sage: OverconvergentModularForms(5, 12, 1/3).prime()5725573"""574return self._p575576577def radius(self):578r"""579The radius of overconvergence of this space.580581EXAMPLE::582583sage: OverconvergentModularForms(3, 0, 1/3).radius()5841/3585"""586return self._radius587588def gens(self):589r"""590Return a generator object that iterates over the (infinite) set of591basis vectors of self.592593EXAMPLES::594595sage: o = OverconvergentModularForms(3, 12, 1/2)596sage: t = o.gens()597sage: t.next()5983-adic overconvergent modular form of weight-character 12 with q-expansion 1 - 32760/61203943*q - 67125240/61203943*q^2 - ...599sage: t.next()6003-adic overconvergent modular form of weight-character 12 with q-expansion 27*q + 19829193012/61203943*q^2 + 146902585770/61203943*q^3 + ...601"""602i = 0603while 1:604yield self.gen(i)605i += 1606607def prec(self):608r"""609Return the series precision of self. Note that this is different from610the `p`-adic precision of the base ring.611612EXAMPLE::613614sage: OverconvergentModularForms(3, 0, 1/2).prec()61520616sage: OverconvergentModularForms(3, 0, 1/2,prec=40).prec()61740618"""619return self._prec620621#####################################622# Element construction and coercion #623# (unfortunately not using #624# the new coercion model) #625#####################################626627def __call__(self, input):628r"""629Create an element of this space. Allowable inputs are:630631- elements of compatible spaces of modular forms or overconvergent632modular forms633634- arbitrary power series in `q`635636- lists of elements of the base ring (interpreted as vectors in the637basis given by self.gens()).638639Precision may be specified by padding lists at the end with zeros;640inputs with a higher precision than the set precision of this space641will be rounded.642643EXAMPLES::644645From a `q`-expansion::646647sage: M = OverconvergentModularForms(3, 0, 1/2, prec=5)648sage: R.<q> = QQ[[]]649sage: f=M(q + q^2 - q^3 + O(q^16)); f6503-adic overconvergent modular form of weight-character 0 with q-expansion q + q^2 - q^3 + O(q^5)651sage: M.coordinate_vector(f)652(0, 1/27, -11/729, 173/19683, -3172/531441)653654From a list or a vector::655656sage: M([1,0,1])6573-adic overconvergent modular form of weight-character 0 with q-expansion 1 + 729*q^2 + O(q^3)658sage: M([1,0,1,0,0])6593-adic overconvergent modular form of weight-character 0 with q-expansion 1 + 729*q^2 + 17496*q^3 + 236196*q^4 + O(q^5)660sage: f = M([1,0,1,0,0]); v = M.coordinate_vector(f); v661(1, 0, 1, 0, 0)662sage: M(v) == f663True664665From a classical modular form::666667sage: f = CuspForms(Gamma0(3), 12).0; f668q - 176*q^4 + 2430*q^5 + O(q^6)669sage: fdag = OverconvergentModularForms(3, 12, 1/3, prec=8)(f); fdag6703-adic overconvergent modular form of weight-character 12 with q-expansion q - 176*q^4 + 2430*q^5 - 5832*q^6 - 19336*q^7 + O(q^8)671sage: fdag.parent().coordinate_vector(f)*(1 + O(3^2))672(0, 3^-2 + O(3^0), 2*3^-3 + 2*3^-2 + O(3^-1), 3^-4 + 3^-3 + O(3^-2), 2 + 3 + O(3^2), 2*3 + 3^2 + O(3^3), 2*3^4 + 2*3^5 + O(3^6), 3^5 + 3^6 + O(3^7))673sage: OverconvergentModularForms(3, 6, 1/3)(f)674Traceback (most recent call last):675...676TypeError: Cannot create an element of 'Space of 3-adic ...' from element of incompatible space 'Cuspidal subspace ...'677678We test that zero elements are handled properly::679680sage: M(0)6813-adic overconvergent modular form of weight-character 0 with q-expansion O(q^5)682sage: M(O(q^3))6833-adic overconvergent modular form of weight-character 0 with q-expansion O(q^3)684685We test coercion between spaces of different precision::686687sage: M10 = OverconvergentModularForms(3, 0, 1/2, prec=10)688sage: f = M10.1689sage: M(f)6903-adic overconvergent modular form of weight-character 0 with q-expansion 27*q + 324*q^2 + 2430*q^3 + 13716*q^4 + O(q^5)691sage: M10(M(f))6923-adic overconvergent modular form of weight-character 0 with q-expansion 27*q + 324*q^2 + 2430*q^3 + 13716*q^4 + O(q^5)693"""694if isinstance(input, (int, long)):695input = ZZ(input)696697if isinstance(input, OverconvergentModularFormElement):698if input.parent() is self:699return input700return self._coerce_from_ocmf(input)701702elif isinstance(input, ModularFormElement):703if ( (input.level() == 1 or input.level().prime_factors() == [self.prime()])704and input.weight() == self.weight().k()705and input.character().primitive_character() == self.weight().chi().primitive_character()):706p = ZZ(self.prime())707nu = (input.level() == 1 and p/(p+1)) or (1 / (p + 1) * p**(2 - input.level().valuation(p)))708if self.radius() > nu:709raise ValueError, "Form is not overconvergent enough (form is only %s-overconvergent)" % nu710else:711return self(self._qsr(input.q_expansion(self.prec())))712else:713raise TypeError, "Cannot create an element of '%s' from element of incompatible space '%s'" % (self, input.parent())714715elif isinstance(input, (list, tuple, Vector)):716v = list(input)717n = len(v)718return OverconvergentModularFormElement(self, gexp=self._gsr(v).add_bigoh(n), qexp=None)719720elif self._qsr.has_coerce_map_from(input.parent()):721return OverconvergentModularFormElement(self, gexp=None, qexp=self._qsr(input))722723else:724raise TypeError, "Don't know how to create an overconvergent modular form from %s" % input725726@cached_method727def zero_element(self):728"""729Return the zero of this space.730731EXAMPLE::732733sage: K.<w> = Qp(13).extension(x^2-13); M = OverconvergentModularForms(13, 20, radius=1/2, base_ring=K)734sage: K.zero_element()7350736"""737return self(0)738739def _coerce_from_ocmf(self, f):740r"""741Try to convert the overconvergent modular form `f` into an element of self. An error will be raised if this is742obviously nonsense.743744EXAMPLES::745sage: M = OverconvergentModularForms(3, 0, 1/2)746sage: MM = M.base_extend(Qp(3))747sage: R.<q> = Qp(3)[[]]; f = MM(q + O(q^2)); f7483-adic overconvergent modular form of weight-character 0 with q-expansion (1 + O(3^20))*q + O(q^2)749sage: M._coerce_from_ocmf(f)7503-adic overconvergent modular form of weight-character 0 with q-expansion q + O(q^2)751sage: f in M # indirect doctest752True753"""754prime, weight, radius, base_ring, prec, char = f.parent()._params()755if (prime, weight, char) != (self.prime(), self.weight().k(), self.weight().chi()):756raise TypeError, "Cannot create an element of '%s' from element of incompatible space '%s'" % (self, input.parent())757return self(self._qsr(f.q_expansion()))758759def _coerce_impl(self, x):760r"""761Canonical coercion of x into self. Here the possibilities for x are762more restricted.763764TESTS::765766sage: M = OverconvergentModularForms(3, 0, 1/2)767sage: MM = M.base_extend(Qp(3))768sage: MM.has_coerce_map_from(M) # indirect doctest769True770sage: MM.coerce(M.1)7713-adic overconvergent modular form of weight-character 0 with q-expansion (3^3 + O(3^23))*q + (3^4 + 3^5 + O(3^24))*q^2 ...772sage: M.has_coerce_map_from(MM)773False774sage: M.coerce(1)7753-adic overconvergent modular form of weight-character 0 with q-expansion 1 + O(q^20)776"""777if isinstance(x, OverconvergentModularFormElement) and self.base_ring().has_coerce_map_from(x.base_ring()):778return self._coerce_from_ocmf(x)779else:780return self.base_ring().coerce(x) * self.gen(0)781782783def coordinate_vector(self, x):784r"""785Write x as a vector with respect to the basis given by self.basis().786Here x must be an element of this space or something that can be787converted into one. If x has precision less than the default precision788of self, then the returned vector will be shorter.789790EXAMPLES::791792sage: M = OverconvergentModularForms(Gamma0(3), 0, 1/3, prec=4)793sage: M.coordinate_vector(M.gen(2))794(0, 0, 1, 0)795sage: q = QQ[['q']].gen(); M.coordinate_vector(q - q^2 + O(q^4))796(0, 1/9, -13/81, 74/243)797sage: M.coordinate_vector(q - q^2 + O(q^3))798(0, 1/9, -13/81)799"""800if hasattr(x, 'base_ring') and x.base_ring() != self.base_ring():801return self.base_extend(x.base_ring()).coordinate_vector(x)802803if x.parent() != self:804x = self(x)805806return vector(self.base_ring(), x.gexp().padded_list(x.gexp().prec()))807808809##########################################################810# Pointless routines required by parent class definition #811##########################################################812813def ngens(self):814r"""815The number of generators of self (as a module over its base ring), i.e. infinity.816817EXAMPLES::818819sage: M = OverconvergentModularForms(2, 4, 1/6)820sage: M.ngens()821+Infinity822"""823return Infinity824825def gens_dict(self):826r"""827Return a dictionary mapping the names of generators of this space to828their values. (Required by parent class definition.) As this does not829make any sense here, this raises a TypeError.830831EXAMPLES::832833sage: M = OverconvergentModularForms(2, 4, 1/6)834sage: M.gens_dict()835Traceback (most recent call last):836...837TypeError: gens_dict does not make sense as number of generators is infinite838"""839840raise TypeError, "gens_dict does not make sense as number of generators is infinite"841842#####################################843# Routines with some actual content #844#####################################845846def hecke_operator(self, f, m):847r"""848Given an element `f` and an integer `m`, calculates the Hecke operator849`T_m` acting on `f`.850851The input may be either a "bare" power series, or an852OverconvergentModularFormElement object; the return value will be of853the same type.854855EXAMPLE::856857sage: M = OverconvergentModularForms(3, 0, 1/2)858sage: f = M.1859sage: M.hecke_operator(f, 3)8603-adic overconvergent modular form of weight-character 0 with q-expansion 2430*q + 265356*q^2 + 10670373*q^3 + 249948828*q^4 + 4113612864*q^5 + 52494114852*q^6 + O(q^7)861sage: M.hecke_operator(f.q_expansion(), 3)8622430*q + 265356*q^2 + 10670373*q^3 + 249948828*q^4 + 4113612864*q^5 + 52494114852*q^6 + O(q^7)863"""864865# This should just be an instance of hecke_operator_on_qexp but that866# won't accept arbitrary power series as input, although it's clearly867# supposed to, which seems rather to defy the point but never mind...868869if f.parent() is self:870return self(self.hecke_operator(f.q_expansion(), m))871elif isinstance(f, OverconvergentModularFormElement):872if f.parent() is self.base_extend(f.parent().base_ring()):873return f.parent().hecke_operator(f, m)874else:875raise TypeError, "Not an element of this space"876else:877return hecke_operator_on_qexp(f, m, self.weight().k(), eps=self.weight().chi())878879880881def _convert_to_basis(self, qexp):882r"""883Given a `q`-expansion, converts it to a vector in the basis of this884space, to the maximum possible precision (which is the minimum of the885`q`-adic precision of the `q`-expansion and the precision of self).886887EXAMPLE::888889sage: M = OverconvergentModularForms(2, 0, 1/2)890sage: R.<q> = QQ[[]]891sage: M._convert_to_basis(q + q^2 + O(q^4))8921/64*g - 23/4096*g^2 + 201/65536*g^3 + O(g^4)893"""894n = min(qexp.prec(), self.prec())895x = qexp896g = self._gsr.gen()897answer = self._gsr(0)898for i in xrange(n):899assert(x.valuation() >= i)900answer += (x[i] / self._basis_cache[i][i])*g**i901x = x - self._basis_cache[i] * answer[i]902return answer + O(g**n)903904def hecke_matrix(self, m, n, use_recurrence = False, exact_arith = False):905r"""906Calculate the matrix of the `T_m` operator in the basis of this space,907truncated to an `n \times n` matrix. Conventions are that operators act908on the left on column vectors (this is the opposite of the conventions909of the sage.modules.matrix_morphism class!) Uses naive `q`-expansion910arguments if use_recurrence=False and uses the Kolberg style911recurrences if use_recurrence=True.912913The argument "exact_arith" causes the computation to be done with914rational arithmetic, even if the base ring is an inexact `p`-adic ring.915This is useful as there can be precision loss issues (particularly with916use_recurrence=False).917918EXAMPLES::919920sage: OverconvergentModularForms(2, 0, 1/2).hecke_matrix(2, 4)921[ 1 0 0 0]922[ 0 24 64 0]923[ 0 32 1152 4608]924[ 0 0 3072 61440]925sage: OverconvergentModularForms(2, 12, 1/2, base_ring=pAdicField(2)).hecke_matrix(2, 3) * (1 + O(2^2))926[ 1 + O(2^2) 0 0]927[ 0 2^3 + O(2^5) 2^6 + O(2^8)]928[ 0 2^4 + O(2^6) 2^7 + 2^8 + O(2^9)]929sage: OverconvergentModularForms(2, 12, 1/2, base_ring=pAdicField(2)).hecke_matrix(2, 3, exact_arith=True)930[ 1 0 0]931[ 0 33881928/1414477 64]932[ 0 -192898739923312/2000745183529 1626332544/1414477]933"""934935if exact_arith and not self.base_ring().is_exact():936return self.change_ring(QQ).hecke_matrix(m, n, use_recurrence)937938M = MatrixSpace(self.base_ring(), n)939mat = M(0)940for j in xrange(min(n, self.prime())):941l = self._convert_to_basis(self.hecke_operator(self._basis_cache[j], m))942for i in xrange(n):943try:944mat[i,j] = l[i]945except IndexError:946if not self.weight().is_zero():947raise ValueError, "n is too large for current precision"948else:949if i <= self.prime() * j:950raise ValueError, "n is too large computing initial conds: can't work out u[%s, %s]" % (i,j)951else:952mat[i,j] = 0 # computations are exact for weight 0, and we know these terms are zero953if use_recurrence:954if m != self.prime(): raise ValueError, "Recurrence method not valid when m != p"955for j in xrange(self.prime(), n):956# can only apply recurrence if have i,j both >= p.957if j >= self.prec():958for i in xrange(self.prime()):959if self.weight() != 0:960raise ValueError, "n is too large for current precision"961else:962if j <= self.prime() * i:963raise ValueError, "n is too large computing initial conds: can't work out u[%s,%s]" % (i,j)964mat[i,j] = 0965966967else:968l = self._convert_to_basis(self.hecke_operator(self._basis_cache[j], m))969for i in xrange(self.prime()):970mat[i,j] = l[i]971for i in xrange(self.prime(), n):972for u in xrange(self.prime()):973for v in xrange(self.prime()):974mat[i,j] = mat[i,j] + mat[i-u-1, j-v-1]*self.recurrence_matrix()[u,v]975976else:977if( n*self.prime() > self.prec()):978raise ValueError, "n is too large"979for j in xrange(self.prime(), n):980l = self._convert_to_basis(self.hecke_operator(self._basis_cache[j], m))981for i in xrange(n):982mat[i,j] = l[i]983return mat984985def slopes(self, n, use_recurrence=False):986r"""987Compute the slopes of the `U_p` operator acting on self, using an n x n matrix.988989EXAMPLES::990991sage: OverconvergentModularForms(5,2,1/3,base_ring=Qp(5),prec=100).slopes(5)992[0, 2, 5, 6, 9]993sage: OverconvergentModularForms(2,1,1/3,char=DirichletGroup(4,QQ).0).slopes(5)994[0, 2, 4, 6, 8]995"""996if self.base_ring() == QQ:997slopelist=self.cps_u(n).truncate().newton_slopes(self.prime())998elif is_pAdicField(self.base_ring()):999slopelist=self.cps_u(n).truncate().newton_slopes()1000else:1001print "slopes are only defined for base field QQ or a p-adic field"1002return [-i for i in slopelist]10031004def eigenfunctions(self, n, F = None, exact_arith=True):1005"""1006Calculate approximations to eigenfunctions of self. These are the1007eigenfunctions of self.hecke_matrix(p, n), which are approximations to1008the true eigenfunctions. Returns a list of1009OverconvergentModularFormElement objects, in increasing order of slope.10101011INPUT:10121013- ``n`` - integer. The size of the matrix to use.10141015- ``F`` - None, or a field over which to calculate eigenvalues. If the1016field is None, the current base ring is used. If the base ring is not1017a `p`-adic ring, an error will be raised.10181019- ``exact_arith`` - True or False (default True). If True, use exact1020rational arithmetic to calculate the matrix of the `U` operator and its1021characteristic power series, even when the base ring is an inexact1022`p`-adic ring. This is typically slower, but more numerically stable.10231024NOTE: Try using ``set_verbose(1, 'sage/modular/overconvergent')`` to1025get more feedback on what is going on in this algorithm. For even more1026feedback, use 2 instead of 1.10271028EXAMPLES::10291030sage: X = OverconvergentModularForms(2, 2, 1/6).eigenfunctions(8, Qp(2, 100))1031sage: X[1]10322-adic overconvergent modular form of weight-character 2 with q-expansion (1 + O(2^74))*q + (2^4 + 2^5 + 2^9 + 2^10 + 2^12 + 2^13 + 2^15 + 2^17 + 2^19 + 2^20 + 2^21 + 2^23 + 2^28 + 2^30 + 2^31 + 2^32 + 2^34 + 2^36 + 2^37 + 2^39 + 2^40 + 2^43 + 2^44 + 2^45 + 2^47 + 2^48 + 2^52 + 2^53 + 2^54 + 2^55 + 2^56 + 2^58 + 2^59 + 2^60 + 2^61 + 2^67 + 2^68 + 2^70 + 2^71 + 2^72 + 2^74 + 2^76 + O(2^78))*q^2 + (2^2 + 2^7 + 2^8 + 2^9 + 2^12 + 2^13 + 2^16 + 2^17 + 2^21 + 2^23 + 2^25 + 2^28 + 2^33 + 2^34 + 2^36 + 2^37 + 2^42 + 2^45 + 2^47 + 2^49 + 2^50 + 2^51 + 2^54 + 2^55 + 2^58 + 2^60 + 2^61 + 2^67 + 2^71 + 2^72 + O(2^76))*q^3 + (2^8 + 2^11 + 2^14 + 2^19 + 2^21 + 2^22 + 2^24 + 2^25 + 2^26 + 2^27 + 2^28 + 2^29 + 2^32 + 2^33 + 2^35 + 2^36 + 2^44 + 2^45 + 2^46 + 2^47 + 2^49 + 2^50 + 2^53 + 2^54 + 2^55 + 2^56 + 2^57 + 2^60 + 2^63 + 2^66 + 2^67 + 2^69 + 2^74 + 2^76 + 2^79 + 2^80 + 2^81 + O(2^82))*q^4 + (2 + 2^2 + 2^9 + 2^13 + 2^15 + 2^17 + 2^19 + 2^21 + 2^23 + 2^26 + 2^27 + 2^28 + 2^30 + 2^33 + 2^34 + 2^35 + 2^36 + 2^37 + 2^38 + 2^39 + 2^41 + 2^42 + 2^43 + 2^45 + 2^58 + 2^59 + 2^60 + 2^61 + 2^62 + 2^63 + 2^65 + 2^66 + 2^68 + 2^69 + 2^71 + 2^72 + O(2^75))*q^5 + (2^6 + 2^7 + 2^15 + 2^16 + 2^21 + 2^24 + 2^25 + 2^28 + 2^29 + 2^33 + 2^34 + 2^37 + 2^44 + 2^45 + 2^48 + 2^50 + 2^51 + 2^54 + 2^55 + 2^57 + 2^58 + 2^59 + 2^60 + 2^64 + 2^69 + 2^71 + 2^73 + 2^75 + 2^78 + O(2^80))*q^6 + (2^3 + 2^8 + 2^9 + 2^10 + 2^11 + 2^12 + 2^14 + 2^15 + 2^17 + 2^19 + 2^20 + 2^21 + 2^23 + 2^25 + 2^26 + 2^34 + 2^37 + 2^38 + 2^39 + 2^40 + 2^41 + 2^45 + 2^47 + 2^49 + 2^51 + 2^53 + 2^54 + 2^55 + 2^57 + 2^58 + 2^59 + 2^60 + 2^61 + 2^66 + 2^69 + 2^70 + 2^71 + 2^74 + 2^76 + O(2^77))*q^7 + O(q^8)1033sage: [x.slope() for x in X]1034[0, 4, 8, 14, 16, 18, 26, 30]1035"""10361037if F is None:1038F = self.base_ring()10391040if F.is_exact():1041#raise TypeError, "cannot calculate eigenfunctions over exact base fields"1042F = pAdicField(self.prime(), 100)10431044m = self.hecke_matrix(self.prime(), n, use_recurrence=True, exact_arith=exact_arith)1045cp = m.charpoly()1046eigenvalues = cp.roots(F)1047eigenfunctions = []1048verbose("Expected %s eigenvalues, got %s" % (n, len(eigenvalues)))1049for (r, d) in eigenvalues:1050v = r.valuation()1051if d != 1:1052#print "Warning: Root occurs with multiplicity"1053continue10541055mr = (m._pari_() - r._pari_())1056# Annoying thing: r isn't quite as precise as it claims to be1057# (bug reported to sage-support list)1058while F(mr.matdet()) != 0:1059verbose("p-adic solver returned wrong result in slope %s; refining" % r.valuation(), level=2)1060r = r - cp(r)/cp.derivative()(r)1061mr2 = (m._pari_() - r._pari_())1062if mr2.matdet().valuation(self.prime()) > mr.matdet().valuation(self.prime()):1063mr = mr21064else:1065mr = None1066break10671068if mr is None:1069verbose("Unable to calculate exact root in slope %s" % r.valuation())1070continue10711072# now calculate the kernel using PARI10731074v = mr._pari_().matker()10751076if repr(v) == "[;]":1077verbose("PARI returned empty eigenspace in slope %s" % r.valuation())1078continue1079# Can't happen? Does PARI always return a1080# nonempty kernel for matrices that have det1081# indistinguishable from 0?10821083if v.ncols() != 1:1084verbose("PARI returned non-simple eigenspace in slope %s" % r.valuation())1085continue10861087gexp = self._gsr(0)1088for i in xrange(v.nrows()):1089gexp += self._gsr.gen()**i * F(v[i,0])1090gexp = gexp + O(self._gsr.gen()**int(v.nrows()))10911092if gexp[0] != 0:1093gexp = gexp/gexp[0]1094elif gexp[1] != 0:1095gexp = gexp/gexp[1]/self._const1096# This is slightly subtle. We want all eigenfunctions to have q-exps in Z_p.1097# Normalising the q-term to be 1 doesn't work for the Eisenstein series if1098# we're in the 0 component of weight-character space. But normalising the const term1099# to 1 works as *none of the small primes we deal with are irregular*! :-)1100else:1101raise ValueError, "Constant and linear terms both zero!"1102# if this gets called something is very wrong.11031104efunc = OverconvergentModularFormElement(self.base_extend(F), gexp=gexp)1105efunc._notify_eigen(r)1106assert efunc.is_integral()1107# This sometimes fails if n is too large -- last row of matrix fills1108# up with garbage. I don't know why. XXX FIX THIS XXX1109eigenfunctions.append((r.valuation(), efunc))11101111eigenfunctions.sort() # sort by slope1112return [f for _,f in eigenfunctions]11131114def recurrence_matrix(self, use_smithline=True):1115r"""1116Return the recurrence matrix satisfied by the coefficients of `U`,1117that is a matrix `R =(r_{rs})_{r,s=1 \dots p}` such that `u_{ij} =1118\sum_{r,s=1}^p r_{rs} u_{i-r, j-s}`. Uses an elegant construction which1119I believe is due to Smithline. See [Loe2007]_.11201121EXAMPLES::11221123sage: OverconvergentModularForms(2, 0, 0).recurrence_matrix()1124[ 48 1]1125[4096 0]1126sage: OverconvergentModularForms(2, 0, 1/2).recurrence_matrix()1127[48 64]1128[64 0]1129sage: OverconvergentModularForms(3, 0, 0).recurrence_matrix()1130[ 270 36 1]1131[ 26244 729 0]1132[531441 0 0]1133sage: OverconvergentModularForms(5, 0, 0).recurrence_matrix()1134[ 1575 1300 315 30 1]1135[ 162500 39375 3750 125 0]1136[ 4921875 468750 15625 0 0]1137[ 58593750 1953125 0 0 0]1138[244140625 0 0 0 0]1139sage: OverconvergentModularForms(7, 0, 0).recurrence_matrix()1140[ 4018 8624 5915 1904 322 28 1]1141[ 422576 289835 93296 15778 1372 49 0]1142[ 14201915 4571504 773122 67228 2401 0 0]1143[ 224003696 37882978 3294172 117649 0 0 0]1144[ 1856265922 161414428 5764801 0 0 0 0]1145[ 7909306972 282475249 0 0 0 0 0]1146[13841287201 0 0 0 0 0 0]1147sage: OverconvergentModularForms(13, 0, 0).recurrence_matrix()1148[ 15145 124852 354536 ...1149"""11501151if self._cached_recurrence_matrix is not None:1152return self._cached_recurrence_matrix11531154MM = OverconvergentModularForms(self.prime(), 0, 0, base_ring=QQ)1155m = MM._discover_recurrence_matrix(use_smithline = True).base_extend(self.base_ring())11561157r = diagonal_matrix([self._const**i for i in xrange(self.prime())])1158self._cached_recurrence_matrix = (r**(-1)) * m * r1159self._cached_recurrence_matrix.set_immutable()1160return self._cached_recurrence_matrix116111621163def _discover_recurrence_matrix(self, use_smithline=True):1164r"""1165Does hard work of calculating recurrence matrix, which is cached to avoid doing this every time.11661167EXAMPLE::11681169sage: o = OverconvergentModularForms(3,12,0)1170sage: o._discover_recurrence_matrix() == o.recurrence_matrix()1171True1172"""11731174(f_ring, f) = PolynomialRing(self.base_ring(), "f").objgen()11751176if use_smithline:1177# Compute Smithline's polynomial H_p1178jq = self._qsr(j_invariant_qexp(1+self.prime()).shift(1).power_series())11791180# avoid dividing by q so as not to instantiate a Laurent series1181h = self._uniformiser.shift(-1) * jq1182fi = self._qsr(1)1183coeffs = []1184for i in xrange(self.prime()+2):1185if not h.valuation() >= i:1186raise ValueError, "Something strange is happening here"11871188coeffs.append(h[i] / fi[i])1189h = h - coeffs[-1] * fi1190fi = fi*self._uniformiser1191SmiH = f_ring(coeffs)1192assert SmiH.degree() == self.prime() + 11193# print "Smithline's H_p is: ",SmiH, " = ",SmiH.factor()1194xyring = PolynomialRing(self.base_ring(), ["x","y"], 2)1195x,y = xyring.gens()1196cc = self.prime() ** (-12/(self.prime() - 1))1197bigI = x*SmiH(y*cc)- y*cc*SmiH(x)1198smallI = xyring(bigI / (x - cc*y))1199# print "Smithline's I_p is: ", smallI1200r = matrix(ZZ, self.prime(), self.prime())1201for i in xrange(self.prime()):1202for j in xrange(self.prime()):1203r[i,j] = -smallI[i+1, j+1]1204return r1205else:1206# compute from U(f^j) for small j via Newton's identities1207# to be implemented when I can remember Newton's identities!1208raise NotImplementedError12091210def cps_u(self, n, use_recurrence=False):1211r"""1212Compute the characteristic power series of `U_p` acting on self, using1213an n x n matrix.12141215EXAMPLES::12161217sage: OverconvergentModularForms(3, 16, 1/2, base_ring=Qp(3)).cps_u(4)12181 + O(3^20) + (2 + 2*3 + 2*3^2 + 2*3^4 + 3^5 + 3^6 + 3^7 + 3^11 + 3^12 + 2*3^14 + 3^16 + 3^18 + O(3^19))*T + (2*3^3 + 3^5 + 3^6 + 3^7 + 2*3^8 + 2*3^9 + 2*3^10 + 3^11 + 3^12 + 2*3^13 + 2*3^16 + 2*3^18 + O(3^19))*T^2 + (2*3^15 + 2*3^16 + 2*3^19 + 2*3^20 + 2*3^21 + O(3^22))*T^3 + (3^17 + 2*3^18 + 3^19 + 3^20 + 3^22 + 2*3^23 + 2*3^25 + 3^26 + O(3^27))*T^41219sage: OverconvergentModularForms(3, 16, 1/2, base_ring=Qp(3), prec=30).cps_u(10)12201 + O(3^20) + (2 + 2*3 + 2*3^2 + 2*3^4 + 3^5 + 3^6 + 3^7 + 2*3^15 + O(3^16))*T + (2*3^3 + 3^5 + 3^6 + 3^7 + 2*3^8 + 2*3^9 + 2*3^10 + 2*3^11 + 2*3^12 + 2*3^13 + 3^14 + 3^15 + O(3^16))*T^2 + (3^14 + 2*3^15 + 2*3^16 + 3^17 + 3^18 + O(3^19))*T^3 + (3^17 + 2*3^18 + 3^19 + 3^20 + 3^21 + O(3^24))*T^4 + (3^29 + 2*3^32 + O(3^33))*T^5 + (2*3^44 + O(3^45))*T^6 + (2*3^59 + O(3^60))*T^7 + (2*3^78 + O(3^79))*T^812211222NOTES:12231224Uses the Hessenberg form of the Hecke matrix to compute the1225characteristic polynomial. Because of the use of relative precision1226here this tends to give better precision in the p-adic coefficients.1227"""1228m = self.hecke_matrix(self.prime(), n, use_recurrence)1229A = PowerSeriesRing(self.base_ring(),'T')12301231# From a conversation with David Loeffler, apparently self.base_ring()1232# is either the field of rational numbers or some p-adic field. In the1233# first case we want to use the linbox algorithm, and in the second1234# case the Hessenberg form algorithm.1235#1236if self.base_ring().is_exact():1237g = A(m.charpoly('T').reverse())1238else:1239g = A(m.charpoly('T', "hessenberg").reverse())12401241return g12421243class OverconvergentModularFormElement(ModuleElement):1244r"""1245A class representing an element of a space of overconvergent modular forms.12461247EXAMPLE::12481249sage: K.<w> = Qp(5).extension(x^7 - 5); s = OverconvergentModularForms(5, 6, 1/21, base_ring=K).01250sage: s == loads(dumps(s))1251True1252"""12531254def __init__(self, parent, gexp=None, qexp=None):1255r"""1256Create an element of this space.12571258EXAMPLE::12591260sage: OverconvergentModularForms(3, 2, 1/6,prec=5).an_element() # indirect doctest12613-adic overconvergent modular form of weight-character 2 with q-expansion 3*q + 72*q^2 + 810*q^3 + 6096*q^4 + O(q^5)1262"""12631264ModuleElement.__init__(self, parent)12651266self._p = self.parent().prime()1267#self.weight = self.parent().weight1268if (gexp is None and qexp is None) or (gexp is not None and qexp is not None):1269raise ValueError, "Must supply exactly one of a q-expansion and a g-expansion"1270if gexp is not None:1271self._gexp = gexp.add_bigoh(self.parent().prec())1272self._qexp = sum([self.parent()._basis_cache[i] * gexp[i] for i in xrange(min(gexp.prec(), self.parent().prec()))])1273self._qexp = self._qexp.add_bigoh(self._gexp.prec())1274else: # qexp is not None1275self._qexp = qexp.add_bigoh(self.parent().prec())1276self._gexp = self.parent()._convert_to_basis(self._qexp)12771278self._is_eigen = False1279self._eigenvalue = None1280self._slope = None128112821283def _add_(self, other):1284r"""1285Add self to other (where other has the same parent as self).12861287EXAMPLES::12881289sage: M = OverconvergentModularForms(2, 12, 1/6)1290sage: f = M.01291sage: f + f # indirect doctest12922-adic overconvergent modular form of weight-character 12 with q-expansion 2 - 131040/1414477*q ...1293"""1294return OverconvergentModularFormElement(self.parent(), gexp = self.gexp() + other.gexp())12951296def _lmul_(self, x):1297r"""1298Left multiplication by other.12991300EXAMPLES::13011302sage: M = OverconvergentModularForms(2, 12, 1/6)1303sage: f = M.01304sage: 2*f # indirect doctest13052-adic overconvergent modular form of weight-character 12 with q-expansion 2 - 131040/1414477*q ...13061307"""1308return OverconvergentModularFormElement(self.parent(), gexp = x * self.gexp())13091310def _rmul_(self, x):1311r"""1312Right multiplication by other.13131314EXAMPLES::13151316sage: M = OverconvergentModularForms(2, 12, 1/6)1317sage: f = M.01318sage: f * 3 # indirect doctest13192-adic overconvergent modular form of weight-character 12 with q-expansion 3 - 196560/1414477*q ...13201321"""1322return OverconvergentModularFormElement(self.parent(), gexp = x * self.gexp())13231324def prec(self):1325r"""1326Return the series expansion precision of this overconvergent modular1327form. (This is not the same as the `p`-adic precision of the1328coefficients.)13291330EXAMPLE::13311332sage: OverconvergentModularForms(5, 6, 1/3,prec=15).gen(1).prec()1333151334"""1335return self.gexp().prec()13361337def is_eigenform(self):1338r"""1339Return True if this is an eigenform. At present this returns False1340unless this element was explicitly flagged as an eigenform, using the1341_notify_eigen function.13421343EXAMPLE::13441345sage: M = OverconvergentModularForms(3, 0, 1/2)1346sage: f = M.eigenfunctions(3)[1]1347sage: f.is_eigenform()1348True1349sage: M.gen(4).is_eigenform()1350False1351"""1352return self._is_eigen13531354def slope(self):1355r"""1356Return the slope of this eigenform, i.e. the valuation of its1357`U_p`-eigenvalue. Raises an error unless this element was explicitly1358flagged as an eigenform, using the _notify_eigen function.13591360EXAMPLE::13611362sage: M = OverconvergentModularForms(3, 0, 1/2)1363sage: f = M.eigenfunctions(3)[1]1364sage: f.slope()136521366sage: M.gen(4).slope()1367Traceback (most recent call last):1368...1369TypeError: slope only defined for eigenfunctions1370"""1371if not self.is_eigenform(): raise TypeError, "slope only defined for eigenfunctions"1372return self._slope13731374def eigenvalue(self):1375r"""1376Return the `U_p`-eigenvalue of this eigenform. Raises an error unless1377this element was explicitly flagged as an eigenform, using the1378_notify_eigen function.13791380EXAMPLE::13811382sage: M = OverconvergentModularForms(3, 0, 1/2)1383sage: f = M.eigenfunctions(3)[1]1384sage: f.eigenvalue()13853^2 + 3^4 + 2*3^6 + 3^7 + 3^8 + 2*3^9 + 2*3^10 + 3^12 + 3^16 + 2*3^17 + 3^18 + 3^20 + 2*3^21 + 3^22 + 2*3^23 + 3^25 + 3^26 + 2*3^27 + 2*3^29 + 3^30 + 3^31 + 3^32 + 3^33 + 3^34 + 3^36 + 3^40 + 2*3^41 + 3^43 + 3^44 + 3^45 + 3^46 + 3^48 + 3^49 + 3^50 + 2*3^51 + 3^52 + 3^54 + 2*3^57 + 2*3^59 + 3^60 + 3^61 + 2*3^63 + 2*3^66 + 2*3^67 + 3^69 + 2*3^72 + 3^74 + 2*3^75 + 3^76 + 2*3^77 + 2*3^78 + 2*3^80 + 3^81 + 2*3^82 + 3^84 + 2*3^85 + 2*3^86 + 3^87 + 3^88 + 2*3^89 + 2*3^91 + 3^93 + 3^94 + 3^95 + 3^96 + 3^98 + 2*3^99 + O(3^100)1386sage: M.gen(4).eigenvalue()1387Traceback (most recent call last):1388...1389TypeError: eigenvalue only defined for eigenfunctions1390"""13911392if not self.is_eigenform(): raise TypeError, "eigenvalue only defined for eigenfunctions"1393return self._eigenvalue13941395def q_expansion(self, prec=None):1396r"""1397Return the `q`-expansion of self, to as high precision as it is known.13981399EXAMPLE::14001401sage: OverconvergentModularForms(3, 4, 1/2).gen(0).q_expansion()14021 - 120/13*q - 1080/13*q^2 - 120/13*q^3 - 8760/13*q^4 - 15120/13*q^5 - 1080/13*q^6 - 41280/13*q^7 - 5400*q^8 - 120/13*q^9 - 136080/13*q^10 - 159840/13*q^11 - 8760/13*q^12 - 263760/13*q^13 - 371520/13*q^14 - 15120/13*q^15 - 561720/13*q^16 - 45360*q^17 - 1080/13*q^18 - 823200/13*q^19 + O(q^20)1403"""1404if prec is None:1405return self._qexp1406elif prec > self.prec():1407raise ValueError1408else:1409return self._qexp.add_bigoh(prec)14101411def gexp(self):1412r"""1413Return the formal power series in `g` corresponding to this1414overconvergent modular form (so the result is `F` where this modular form1415is `E_k^\ast \times F(g)`, where `g` is the appropriately normalised1416parameter of `X_0(p)`).14171418EXAMPLE::14191420sage: M = OverconvergentModularForms(3, 0, 1/2)1421sage: f = M.eigenfunctions(3)[1]1422sage: f.gexp()1423(3^-3 + O(3^95))*g + (3^-1 + 1 + 2*3 + 3^2 + 2*3^3 + 3^5 + 3^7 + 3^10 + 3^11 + 3^14 + 3^15 + 3^16 + 2*3^19 + 3^21 + 3^22 + 2*3^23 + 2*3^24 + 3^26 + 2*3^27 + 3^29 + 3^31 + 3^34 + 2*3^35 + 2*3^36 + 3^38 + 2*3^39 + 3^41 + 2*3^42 + 2*3^43 + 2*3^44 + 2*3^46 + 2*3^47 + 3^48 + 2*3^49 + 2*3^50 + 3^51 + 2*3^54 + 2*3^55 + 2*3^56 + 3^57 + 2*3^58 + 2*3^59 + 2*3^60 + 3^61 + 3^62 + 3^63 + 3^64 + 2*3^65 + 3^67 + 3^68 + 2*3^69 + 3^70 + 2*3^71 + 2*3^74 + 3^76 + 2*3^77 + 3^78 + 2*3^79 + 2*3^80 + 3^84 + 2*3^85 + 2*3^86 + 3^88 + 2*3^89 + 3^91 + 3^92 + 2*3^94 + 3^95 + O(3^97))*g^2 + O(g^3)1424"""1425return self._gexp14261427def coordinates(self, prec=None):1428r"""1429Return the coordinates of this modular form in terms of the basis of this space.14301431EXAMPLES::14321433sage: M = OverconvergentModularForms(3, 0, 1/2, prec=15)1434sage: f = (M.0 + M.3); f.coordinates()1435[1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]1436sage: f.coordinates(6)1437[1, 0, 0, 1, 0, 0]1438sage: OverconvergentModularForms(3, 0, 1/6)(f).coordinates(6)1439[1, 0, 0, 729, 0, 0]1440sage: f.coordinates(100)1441Traceback (most recent call last):1442...1443ValueError: Precision too large for space1444"""144514461447if prec > self.prec(): raise ValueError, "Precision too large for space"1448if prec is None: prec = self.prec()1449return self._gexp.padded_list(prec)14501451def prime(self):1452r"""1453If this is a `p`-adic modular form, return `p`.14541455EXAMPLE::14561457sage: OverconvergentModularForms(2, 0, 1/2).an_element().prime()145821459"""1460return self._p14611462def _notify_eigen(self, eigenvalue):1463"""1464Flags this element as an eigenform. It then remembers some extra data.14651466EXAMPLE::14671468sage: OverconvergentModularForms(3, 16, 1/3).eigenfunctions(4) # indirect doctest1469[...]1470"""1471self._is_eigen = True1472self._eigenvalue = eigenvalue1473self._slope = eigenvalue.normalized_valuation()14741475def is_integral(self):1476r"""1477Test whether or not this element has `q`-expansion coefficients that1478are `p`-adically integral. This should always be the case with eigenfunctions, but sometimes1479if n is very large this breaks down for unknown reasons!14801481EXAMPLE::14821483sage: M = OverconvergentModularForms(2, 0, 1/3)1484sage: q = QQ[['q']].gen()1485sage: M(q - 17*q^2 + O(q^3)).is_integral()1486True1487sage: M(q - q^2/2 + 6*q^7 + O(q^9)).is_integral()1488False1489"""14901491for co in self.q_expansion().list():1492if (co * (1 + O(self.prime()))).valuation() < 0: # have to force it into ZZ_p1493return False1494return True14951496def _repr_(self):1497r"""1498String representation of self.14991500EXAMPLES::15011502sage: o=OverconvergentModularForms(3, 0, 1/2)1503sage: o([1, 0, 1, 3])._repr_()1504'3-adic overconvergent modular form of weight-character 0 with q-expansion 1 + 729*q^2 + 76545*q^3 + O(q^4)'1505"""1506return "%s-adic overconvergent modular form of weight-character %s with q-expansion %s" % (self.prime(), self.weight(), self.q_expansion())15071508def __cmp__(self, other):1509r"""1510Compare self to other.15111512EXAMPLES::15131514sage: o=OverconvergentModularForms(3, 0, 1/2)1515sage: o([1, 1, 1, 0, 0, 0, 0]) == o([2, 1, 0])1516False1517sage: o([1, 1, 1, 0, 0, 0, 0]) == o([1,1])1518True1519"""15201521if other.parent() != self.parent():1522raise ArithmeticError, "Can't get here!"1523return cmp(self.gexp(), other.gexp())15241525def r_ord(self, r):1526r"""1527The `p`-adic valuation of the norm of self on the `r`-overconvergent region.15281529EXAMPLES::15301531sage: o=OverconvergentModularForms(3, 0, 1/2)1532sage: t = o([1, 1, 1/3])1533sage: t.r_ord(1/2)153411535sage: t.r_ord(2/3)153631537"""1538ord = -Infinity1539p = self.prime()1540s = self.parent().radius()15411542F = self.parent().base_ring()1543if not is_pAdicField(F):1544F = pAdicField(p)15451546for i in xrange(self.prec()):1547ord = max( ord, 12/ZZ(p - 1)*i*(r - s) - F(self.gexp()[i]).normalized_valuation())15481549return ord15501551def valuation(self):1552r"""1553Return the `p`-adic valuation of this form (i.e. the minimum of the1554`p`-adic valuations of its coordinates).15551556EXAMPLES::15571558sage: M = OverconvergentModularForms(3, 0, 1/2)1559sage: (M.7).valuation()156001561sage: (3^18 * (M.2)).valuation()1562181563"""1564if is_pAdicField(self.parent().base_ring()):1565v = lambda u: u.normalized_valuation()1566else:1567v = lambda u: u.valuation(self.parent().prime())1568return min([v(x) for x in self.gexp().list()])15691570def governing_term(self, r):1571r"""1572The degree of the series term with largest norm on the `r`-overconvergent region.15731574EXAMPLES::15751576sage: o=OverconvergentModularForms(3, 0, 1/2)1577sage: f=o.eigenfunctions(10)[1]1578sage: f.governing_term(1/2)157911580"""1581p = self.prime()1582F = self.parent().base_ring()1583if not is_pAdicField(F):1584F = pAdicField(p)1585s = self.parent().radius()1586p = self.prime()15871588for i in xrange(self.gexp().prec()):1589if 12/ZZ(p - 1)*i*(r - s) - F(self.gexp()[i]).normalized_valuation() == self.r_ord(r):1590return i1591raise Exception, "Can't get here"15921593def valuation_plot(self, rmax = None):1594r"""1595Draw a graph depicting the growth of the norm of this overconvergent1596modular form as it approaches the boundary of the overconvergent1597region.15981599EXAMPLE::16001601sage: o=OverconvergentModularForms(3, 0, 1/2)1602sage: f=o.eigenfunctions(4)[1]1603sage: f.valuation_plot()1604"""1605if rmax is None: rmax = ZZ(self.prime())/ZZ(1 + self.prime())1606return plot(self.r_ord, (0, rmax) )16071608def weight(self):1609r"""1610Return the weight of this overconvergent modular form.16111612EXAMPLES::16131614sage: M = OverconvergentModularForms(13, 10, 1/2, base_ring = Qp(13).extension(x^2 - 13,names='a'))1615sage: M.gen(0).weight()1616101617"""1618return self.parent().weight()16191620def additive_order(self):1621r"""1622Return the additive order of this element (required attribute for all1623elements deriving from sage.modules.ModuleElement).16241625EXAMPLES::16261627sage: M = OverconvergentModularForms(13, 10, 1/2, base_ring = Qp(13).extension(x^2 - 13,names='a'))1628sage: M.gen(0).additive_order()1629+Infinity1630sage: M(0).additive_order()163111632"""1633from sage.rings.infinity import Infinity1634if self.is_zero(): return ZZ(1)1635else: return Infinity16361637def base_extend(self, R):1638r"""1639Return a copy of self but with coefficients in the given ring.16401641EXAMPLES::16421643sage: M = OverconvergentModularForms(7, 10, 1/2, prec=5)1644sage: f = M.11645sage: f.base_extend(Qp(7, 4))16467-adic overconvergent modular form of weight-character 10 with q-expansion (7 + O(7^5))*q + (6*7 + 4*7^2 + 7^3 + 6*7^4 + O(7^5))*q^2 + (5*7 + 5*7^2 + 7^4 + O(7^5))*q^3 + (7^2 + 4*7^3 + 3*7^4 + 2*7^5 + O(7^6))*q^4 + O(q^5)1647"""1648S = self.parent().base_extend(R)1649return S(self)16501651def _pari_(self):1652r"""1653Return the Pari object corresponding to self, which is just the1654`q`-expansion of self as a formal power series.16551656EXAMPLES::16571658sage: f = OverconvergentModularForms(3, 0, 1/2).11659sage: pari(f) # indirect doctest166027*q + 324*q^2 + 2430*q^3 + 13716*q^4 + 64557*q^5 + 265356*q^6 + 983556*q^7 + 3353076*q^8 + 10670373*q^9 + 32031288*q^10 + 91455804*q^11 + 249948828*q^12 + 657261999*q^13 + 1669898592*q^14 + 4113612864*q^15 + 9853898292*q^16 + 23010586596*q^17 + 52494114852*q^18 + 117209543940*q^19 + O(q^20)1661sage: pari(f.base_extend(Qp(3))) # indirect doctest1662(3^3 + O(3^23))*q + (3^4 + 3^5 + O(3^24))*q^2 + (3^5 + 3^7 + O(3^25))*q^3 + (3^3 + 3^4 + 2*3^5 + 2*3^8 + O(3^23))*q^4 + (2*3^4 + 3^5 + 3^6 + 2*3^7 + 3^10 + O(3^24))*q^5 + (3^6 + 3^7 + 3^8 + 3^9 + 3^10 + 3^11 + O(3^26))*q^6 + (2*3^3 + 3^4 + 2*3^6 + 2*3^7 + 2*3^8 + 3^9 + 3^10 + 2*3^11 + 3^12 + O(3^23))*q^7 + (2*3^4 + 3^5 + 3^8 + 2*3^9 + 2*3^10 + 2*3^13 + O(3^24))*q^8 + (3^7 + 2*3^9 + 2*3^12 + 2*3^14 + O(3^27))*q^9 + (2*3^5 + 3^8 + 3^9 + 2*3^10 + 2*3^13 + 2*3^15 + O(3^25))*q^10 + (3^4 + 2*3^5 + 2*3^6 + 3^8 + 2*3^9 + 3^12 + 3^14 + 2*3^16 + O(3^24))*q^11 + (3^5 + 3^6 + 2*3^8 + 2*3^9 + 2*3^10 + 2*3^12 + 3^14 + 2*3^15 + 2*3^16 + 3^17 + O(3^25))*q^12 + (2*3^3 + 2*3^4 + 2*3^5 + 3^8 + 2*3^9 + 2*3^11 + 3^13 + 2*3^14 + 2*3^17 + 3^18 + O(3^23))*q^13 + (2*3^4 + 2*3^6 + 2*3^7 + 3^8 + 2*3^9 + 3^10 + 3^12 + 3^14 + 2*3^15 + 2*3^16 + 3^18 + 3^19 + O(3^24))*q^14 + (2*3^6 + 3^7 + 3^9 + 3^10 + 3^11 + 2*3^14 + 3^15 + 2*3^16 + 3^17 + 3^18 + 3^20 + O(3^26))*q^15 + (3^3 + 2*3^4 + 2*3^7 + 2*3^8 + 3^9 + 3^10 + 2*3^11 + 3^12 + 2*3^14 + 2*3^15 + 3^17 + 3^18 + 2*3^19 + 2*3^20 + O(3^23))*q^16 + (2*3^5 + 2*3^7 + 2*3^8 + 3^10 + 3^11 + 2*3^12 + 2*3^13 + 3^14 + 3^15 + 3^17 + 2*3^18 + 3^19 + 2*3^21 + O(3^25))*q^17 + (3^8 + 3^9 + 2*3^10 + 2*3^11 + 3^12 + 3^14 + 3^15 + 3^16 + 3^17 + 2*3^21 + 3^22 + O(3^28))*q^18 + (2*3^3 + 3^5 + 2*3^6 + 2*3^8 + 2*3^9 + 3^11 + 2*3^12 + 3^13 + 3^14 + 2*3^15 + 3^16 + 3^17 + 2*3^18 + 3^19 + 2*3^21 + O(3^23))*q^19 + O(q^20)1663"""1664return self.q_expansion()._pari_()166516661667