Path: blob/master/sage/modular/modsym/modular_symbols.py
4069 views
r"""1Modular symbols {alpha, beta}23The ModularSymbol class represents a single modular symbol `X^i Y^{k-2-i} \{\alpha, \beta\}`.45AUTHOR:67- William Stein (2005, 2009)89TESTS::1011sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]; s12{-1/9, 0}13sage: loads(dumps(s)) == s14True15"""1617#*****************************************************************************18# Sage: System for Algebra and Geometry Experimentation19#20# Copyright (C) 2005, 2009 William Stein <[email protected]>21#22# Distributed under the terms of the GNU General Public License (GPL)23#24# This code is distributed in the hope that it will be useful,25# but WITHOUT ANY WARRANTY; without even the implied warranty of26# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU27# General Public License for more details.28#29# The full text of the GPL is available at:30#31# http://www.gnu.org/licenses/32#*****************************************************************************3334import sage.modular.cusps as cusps35import sage.modular.modsym.manin_symbols36from sage.structure.sage_object import SageObject37import sage.structure.formal_sum as formal_sum38import sage.rings.arith as arith39from sage.rings.integer_ring import ZZ40from sage.misc.latex import latex4142_C = cusps.Cusps4344X, Y = ZZ['X,Y'].gens()4546class ModularSymbol(SageObject):47r"""48The modular symbol `X^i\cdot Y^{k-2-i}\cdot \{\alpha, \beta\}`.49"""50def __init__(self, space, i, alpha, beta):51"""52Initialise a modular symbol.5354INPUT:5556- ``space`` -- space of Manin symbols5758- ``i`` -- integer5960- ``alpha`` -- cusp6162- ``beta`` -- cusp6364EXAMPLES::6566sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]; s67{-1/9, 0}68sage: type(s)69<class 'sage.modular.modsym.modular_symbols.ModularSymbol'>70sage: s = ModularSymbols(11,4).2.modular_symbol_rep()[0][1]; s71X^2*{-1/7, 0}72"""73self.__space = space74self.__i = i75self.__alpha = _C(alpha)76self.__beta = _C(beta)7778def _repr_(self):79"""80String representation of this modular symbol.8182EXAMPLES::8384sage: s = ModularSymbols(11,4).2.modular_symbol_rep()[0][1]; s85X^2*{-1/7, 0}86sage: s._repr_()87'X^2*{-1/7, 0}'88sage: s.rename('sym')89sage: s90sym91"""92if self.weight() == 2:93polypart = ''94else:95polypart = str(self.polynomial_part()) + '*'96return "%s{%s, %s}"%(polypart, self.__alpha, self.__beta)9798def __getitem__(self, j):99r"""100Given a modular symbols `s = X^i Y^{k-2-i}\{\alpha, \beta\}`, ``s[0]`` is `\alpha`101and ``s[1]`` is `\beta`.102103EXAMPLES::104105sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]; s106{-1/9, 0}107sage: s[0]108-1/9109sage: s[1]1100111sage: s[2]112Traceback (most recent call last):113...114IndexError: list index out of range115"""116return [self.__alpha, self.__beta][j]117118def _latex_(self):119"""120Return Latex representation of this modular symbol.121122EXAMPLES::123124sage: s = ModularSymbols(11,4).2.modular_symbol_rep()[0][1]; s125X^2*{-1/7, 0}126sage: latex(s) # indirect doctest127X^{2}\left\{\frac{-1}{7}, 0\right\}128"""129if self.weight() == 2:130polypart = ''131else:132polypart = latex(self.polynomial_part())133return "%s\\left\\{%s, %s\\right\\}"%(polypart,134latex(self.__alpha), latex(self.__beta))135136def __cmp__(self, other):137"""138Compare self to other.139140EXAMPLES::141142sage: M = ModularSymbols(11)143sage: s = M.2.modular_symbol_rep()[0][1]144sage: t = M.0.modular_symbol_rep()[0][1]145sage: s, t146({-1/9, 0}, {Infinity, 0})147sage: s < t148True149sage: t > s150True151sage: s == s152True153sage: t == t154True155"""156if not isinstance(other, ModularSymbol):157return cmp(type(self), type(other))158return cmp((self.__space,-self.__i,self.__alpha,self.__beta),159(other.__space,-other.__i,other.__alpha,other.__beta))160161def space(self):162"""163The list of Manin symbols to which this symbol belongs.164165EXAMPLES::166167sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]168sage: s.space()169Manin Symbol List of weight 2 for Gamma0(11)170"""171return self.__space172173def polynomial_part(self):174r"""175Return the polynomial part of this symbol, i.e. for a symbol of the176form `X^i Y^{k-2-i}\{\alpha, \beta\}`, return `X^i Y^{k-2-i}`.177178EXAMPLES::179180sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]181sage: s.polynomial_part()1821183sage: s = ModularSymbols(1,28).0.modular_symbol_rep()[0][1]; s184X^22*Y^4*{0, Infinity}185sage: s.polynomial_part()186X^22*Y^4187"""188i = self.__i189return X**i*Y**(self.weight()-2-i)190191def i(self):192r"""193For a symbol of the form `X^i Y^{k-2-i}\{\alpha, \beta\}`, return `i`.194195EXAMPLES::196197sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]198sage: s.i()1990200sage: s = ModularSymbols(1,28).0.modular_symbol_rep()[0][1]; s201X^22*Y^4*{0, Infinity}202sage: s.i()20322204"""205return self.__i206207def weight(self):208r"""209Return the weight of the modular symbols space to which this symbol210belongs; i.e. for a symbol of the form `X^i Y^{k-2-i}\{\alpha,211\beta\}`, return `k`.212213EXAMPLES::214215sage: s = ModularSymbols(1,28).0.modular_symbol_rep()[0][1]216sage: s.weight()21728218"""219return self.__space.weight()220221def alpha(self):222r"""223For a symbol of the form `X^i Y^{k-2-i}\{\alpha, \beta\}`, return `\alpha`.224225EXAMPLES::226227sage: s = ModularSymbols(11,4).1.modular_symbol_rep()[0][1]; s228X^2*{-1/6, 0}229sage: s.alpha()230-1/6231sage: type(s.alpha())232<class 'sage.modular.cusps.Cusp'>233"""234return self.__alpha235236def beta(self):237r"""238For a symbol of the form `X^i Y^{k-2-i}\{\alpha, \beta\}`, return `\beta`.239240EXAMPLES::241242sage: s = ModularSymbols(11,4).1.modular_symbol_rep()[0][1]; s243X^2*{-1/6, 0}244sage: s.beta()2450246sage: type(s.beta())247<class 'sage.modular.cusps.Cusp'>248"""249return self.__beta250251def apply(self, g):252r"""253Act on this symbol by the element `g \in {\rm GL}_2(\QQ)`.254255INPUT:256257- ``g`` -- a list ``[a,b,c,d]``, corresponding to the 2x2 matrix258`\begin{pmatrix} a & b \\ c & d \end{pmatrix} \in {\rm GL}_2(\QQ)`.259260OUTPUT:261262- ``FormalSum`` -- a formal sum `\sum_i c_i x_i`, where `c_i` are263scalars and `x_i` are ModularSymbol objects, such that the sum264`\sum_i c_i x_i` is the image of this symbol under the action of g.265No reduction is performed modulo the relations that hold in266self.space().267268The action of `g` on symbols is by269270.. math::271272P(X,Y)\{\alpha, \beta\} \mapsto P(dX-bY, -cx+aY) \{g(\alpha), g(\beta)\}.273274Note that for us we have `P=X^i Y^{k-2-i}`, which simplifies computation275of the polynomial part slightly.276277EXAMPLES::278279sage: s = ModularSymbols(11,2).1.modular_symbol_rep()[0][1]; s280{-1/8, 0}281sage: a=1;b=2;c=3;d=4; s.apply([a,b,c,d])282{15/29, 1/2}283sage: x = -1/8; (a*x+b)/(c*x+d)28415/29285sage: x = 0; (a*x+b)/(c*x+d)2861/2287sage: s = ModularSymbols(11,4).1.modular_symbol_rep()[0][1]; s288X^2*{-1/6, 0}289sage: s.apply([a,b,c,d])29016*X^2*{11/21, 1/2} - 16*X*Y*{11/21, 1/2} + 4*Y^2*{11/21, 1/2}291sage: P = s.polynomial_part()292sage: X,Y = P.parent().gens()293sage: P(d*X-b*Y, -c*X+a*Y)29416*X^2 - 16*X*Y + 4*Y^2295sage: x=-1/6; (a*x+b)/(c*x+d)29611/21297sage: x=0; (a*x+b)/(c*x+d)2981/2299sage: type(s.apply([a,b,c,d]))300<class 'sage.structure.formal_sum.FormalSum'>301"""302space = self.__space303i = self.__i304k = space.weight()305a,b,c,d = tuple(g)306coeffs = sage.modular.modsym.manin_symbols.apply_to_monomial(i, k-2, d, -b, -c, a)307g_alpha = self.__alpha.apply(g)308g_beta = self.__beta.apply(g)309return formal_sum.FormalSum([(coeffs[j], ModularSymbol(space, j, g_alpha, g_beta)) \310for j in reversed(range(k-1)) if coeffs[j] != 0])311312def __manin_symbol_rep(self, alpha):313"""314Return Manin symbol representation of X^i*Y^(k-2-i){0,alpha}.315316EXAMPLES::317318sage: s = ModularSymbols(11,2).1.modular_symbol_rep()[0][1]; s319{-1/8, 0}320sage: s.manin_symbol_rep() # indirect doctest321-(-8,1) - (1,1)322sage: M = ModularSymbols(11,2)323sage: s = M( (1,9) ); s324(1,9)325sage: t = s.modular_symbol_rep()[0][1].manin_symbol_rep(); t326-(-9,1) - (1,1)327sage: M(t)328(1,9)329"""330space = self.__space331i = self.__i332k = space.weight()333v = [(0,1), (1,0)]334if not alpha.is_infinity():335v += [(x.numerator(), x.denominator()) for x in arith.convergents(alpha._rational_())]336sign = 1337apply = sage.modular.modsym.manin_symbols.apply_to_monomial338mansym = sage.modular.modsym.manin_symbols.ManinSymbol339z = formal_sum.FormalSum(0)340for j in range(1,len(v)):341c = sign*v[j][1]342d = v[j-1][1]343coeffs = apply(i, k-2, sign*v[j][0], v[j-1][0], sign*v[j][1], v[j-1][1])344w = [(coeffs[j], mansym(space, (j, c, d))) \345for j in range(k-1) if coeffs[j] != 0]346z += formal_sum.FormalSum(w)347sign *= -1348return z349350def manin_symbol_rep(self):351"""352Returns a representation of self as a formal sum of Manin symbols.353(The result is not cached.)354355EXAMPLES::356357sage: M = ModularSymbols(11,4)358sage: s = M.1.modular_symbol_rep()[0][1]; s359X^2*{-1/6, 0}360sage: s.manin_symbol_rep()361-[Y^2,(1,1)] - 2*[X*Y,(-1,0)] - [X^2,(-6,1)] - [X^2,(-1,0)]362sage: M(s.manin_symbol_rep()) == M([2,-1/6,0])363True364"""365alpha = self.__alpha366beta = self.__beta367return -1*self.__manin_symbol_rep(alpha) + self.__manin_symbol_rep(beta)368369370371