Path: blob/master/sage/modular/modform/hecke_operator_on_qexp.py
4091 views
"""1Hecke Operators on `q`-expansions2"""34#########################################################################5# Copyright (C) 2004--2006 William Stein <[email protected]>6#7# Distributed under the terms of the GNU General Public License (GPL)8#9# http://www.gnu.org/licenses/10#########################################################################1112from sage.modular.dirichlet import DirichletGroup, is_DirichletCharacter13from sage.rings.all import (divisors, gcd, ZZ, Integer, is_PowerSeries, Infinity, CyclotomicField)14from sage.matrix.all import matrix, MatrixSpace15from element import is_ModularFormElement1617def hecke_operator_on_qexp(f, n, k, eps = None,18prec=None, check=True, _return_list=False):19r"""20Given the `q`-expansion `f` of a modular form with character21`\varepsilon`, this function computes the image of `f` under the22Hecke operator `T_{n,k}` of weight `k`.2324EXAMPLES::2526sage: M = ModularForms(1,12)27sage: hecke_operator_on_qexp(M.basis()[0], 3, 12)28252*q - 6048*q^2 + 63504*q^3 - 370944*q^4 + O(q^5)29sage: hecke_operator_on_qexp(M.basis()[0], 1, 12, prec=7)30q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 - 6048*q^6 + O(q^7)31sage: hecke_operator_on_qexp(M.basis()[0], 1, 12)32q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 - 6048*q^6 - 16744*q^7 + 84480*q^8 - 113643*q^9 - 115920*q^10 + 534612*q^11 - 370944*q^12 - 577738*q^13 + O(q^14)3334sage: M.prec(20)352036sage: hecke_operator_on_qexp(M.basis()[0], 3, 12)37252*q - 6048*q^2 + 63504*q^3 - 370944*q^4 + 1217160*q^5 - 1524096*q^6 + O(q^7)38sage: hecke_operator_on_qexp(M.basis()[0], 1, 12)39q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 - 6048*q^6 - 16744*q^7 + 84480*q^8 - 113643*q^9 - 115920*q^10 + 534612*q^11 - 370944*q^12 - 577738*q^13 + 401856*q^14 + 1217160*q^15 + 987136*q^16 - 6905934*q^17 + 2727432*q^18 + 10661420*q^19 - 7109760*q^20 + O(q^21)4041sage: (hecke_operator_on_qexp(M.basis()[0], 1, 12)*252).add_bigoh(7)42252*q - 6048*q^2 + 63504*q^3 - 370944*q^4 + 1217160*q^5 - 1524096*q^6 + O(q^7)4344sage: hecke_operator_on_qexp(M.basis()[0], 6, 12)45-6048*q + 145152*q^2 - 1524096*q^3 + O(q^4)4647An example on a formal power series::4849sage: R.<q> = QQ[[]]50sage: f = q + q^2 + q^3 + q^7 + O(q^8)51sage: hecke_operator_on_qexp(f, 3, 12)52q + O(q^3)53sage: hecke_operator_on_qexp(delta_qexp(24), 3, 12).prec()54855sage: hecke_operator_on_qexp(delta_qexp(25), 3, 12).prec()5695758An example of computing `T_{p,k}` in characteristic `p`::5960sage: p = 19961sage: fp = delta_qexp(prec=p^2+1, K=GF(p))62sage: tfp = hecke_operator_on_qexp(fp, p, 12)63sage: tfp == fp[p] * fp64True65sage: tf = hecke_operator_on_qexp(delta_qexp(prec=p^2+1), p, 12).change_ring(GF(p))66sage: tfp == tf67True68"""69if eps is None:70# Need to have base_ring=ZZ to work over finite fields, since71# ZZ can coerce to GF(p), but QQ can't.72eps = DirichletGroup(1, base_ring=ZZ).gen(0)73if check:74if not (is_PowerSeries(f) or is_ModularFormElement(f)):75raise TypeError, "f (=%s) must be a power series or modular form"%f76if not is_DirichletCharacter(eps):77raise TypeError, "eps (=%s) must be a Dirichlet character"%eps78k = Integer(k)79n = Integer(n)80v = []8182if prec is None:83if is_ModularFormElement(f):84# always want at least three coefficients, but not too many, unless85# requested86pr = max(f.prec(), f.parent().prec(), (n+1)*3)87pr = min(pr, 100*(n+1))88prec = pr // n + 189else:90prec = (f.prec() / ZZ(n)).ceil()91if prec == Infinity: prec = f.parent().default_prec() // n + 19293if f.prec() < prec:94f._compute_q_expansion(prec)9596p = Integer(f.base_ring().characteristic())97if k != 1 and p.is_prime() and n.is_power_of(p):98# if computing T_{p^a} in characteristic p, use the simpler (and faster)99# formula100v = [f[m*n] for m in range(prec)]101else:102l = k-1103for m in range(prec):104am = sum([eps(d) * d**l * f[m*n//(d*d)] for \105d in divisors(gcd(n, m)) if (m*n) % (d*d) == 0])106v.append(am)107if _return_list:108return v109if is_ModularFormElement(f):110R = f.parent()._q_expansion_ring()111else:112R = f.parent()113return R(v, prec)114115def _hecke_operator_on_basis(B, V, n, k, eps):116"""117Does the work for hecke_operator_on_basis once the input118is normalized.119120EXAMPLES::121122sage: hecke_operator_on_basis(ModularForms(1,16).q_expansion_basis(30), 3, 16) # indirect doctest123[ -3348 0]124[ 0 14348908]125126The following used to cause a segfault due to accidentally127transposed second and third argument (#2107)::128129sage: B = victor_miller_basis(100,30)130sage: t2 = hecke_operator_on_basis(B, 100, 2)131Traceback (most recent call last):132...133ValueError: The given basis vectors must be linearly independent.134"""135prec = V.degree()136TB = [hecke_operator_on_qexp(f, n, k, eps, prec, check=False, _return_list=True)137for f in B]138TB = [V.coordinate_vector(w) for w in TB]139return matrix(V.base_ring(), len(B), len(B), TB, sparse=False)140141def hecke_operator_on_basis(B, n, k, eps=None,142already_echelonized = False):143r"""144Given a basis `B` of `q`-expansions for a space of modular forms145with character `\varepsilon` to precision at least `\#B\cdot n+1`,146this function computes the matrix of `T_n` relative to `B`.147148.. note::149150If the elements of B are not known to sufficient precision,151this function will report that the vectors are linearly152dependent (since they are to the specified precision).153154INPUT:155156- ``B`` - list of q-expansions157158- ``n`` - an integer >= 1159160- ``k`` - an integer161162- ``eps`` - Dirichlet character163164- ``already_echelonized`` -- bool (default: False); if True, use that the165basis is already in Echelon form, which saves a lot of time.166167EXAMPLES::168169sage: sage.modular.modform.constructor.ModularForms_clear_cache()170sage: ModularForms(1,12).q_expansion_basis()171[172q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6),1731 + 65520/691*q + 134250480/691*q^2 + 11606736960/691*q^3 + 274945048560/691*q^4 + 3199218815520/691*q^5 + O(q^6)174]175sage: hecke_operator_on_basis(ModularForms(1,12).q_expansion_basis(), 3, 12)176Traceback (most recent call last):177...178ValueError: The given basis vectors must be linearly independent.179180sage: hecke_operator_on_basis(ModularForms(1,12).q_expansion_basis(30), 3, 12)181[ 252 0]182[ 0 177148]183184TESTS:185186This shows that the problem with finite fields reported at trac #8281 is solved::187188sage: bas_mod5 = [f.change_ring(GF(5)) for f in victor_miller_basis(12, 20)]189sage: hecke_operator_on_basis(bas_mod5, 2, 12)190[4 0]191[0 1]192193This shows that empty input is handled sensibly (trac #12202)::194195sage: x = hecke_operator_on_basis([], 3, 12); x196[]197sage: x.parent()198Full MatrixSpace of 0 by 0 dense matrices over Cyclotomic Field of order 1 and degree 1199sage: y = hecke_operator_on_basis([], 3, 12, eps=DirichletGroup(13).0^2); y200[]201sage: y.parent()202Full MatrixSpace of 0 by 0 dense matrices over Cyclotomic Field of order 12 and degree 4203"""204if not isinstance(B, (list, tuple)):205raise TypeError, "B (=%s) must be a list or tuple"%B206if len(B) == 0:207if eps is None:208R = CyclotomicField(1)209else:210R = eps.base_ring()211return MatrixSpace(R, 0)(0)212f = B[0]213R = f.base_ring()214if eps is None:215eps = DirichletGroup(1, R).gen(0)216all_powerseries = True217for x in B:218if not is_PowerSeries(x):219all_powerseries = False220if not all_powerseries:221raise TypeError, "each element of B must be a power series"222n = Integer(n)223k = Integer(k)224prec = (f.prec()-1)//n225A = R**prec226V = A.span_of_basis([g.padded_list(prec) for g in B],227already_echelonized = already_echelonized)228return _hecke_operator_on_basis(B, V, n, k, eps)229230231232233