Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/modular/modsym/modular_symbols.py
4069 views
1
r"""
2
Modular symbols {alpha, beta}
3
4
The ModularSymbol class represents a single modular symbol `X^i Y^{k-2-i} \{\alpha, \beta\}`.
5
6
AUTHOR:
7
8
- William Stein (2005, 2009)
9
10
TESTS::
11
12
sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]; s
13
{-1/9, 0}
14
sage: loads(dumps(s)) == s
15
True
16
"""
17
18
#*****************************************************************************
19
# Sage: System for Algebra and Geometry Experimentation
20
#
21
# Copyright (C) 2005, 2009 William Stein <[email protected]>
22
#
23
# Distributed under the terms of the GNU General Public License (GPL)
24
#
25
# This code is distributed in the hope that it will be useful,
26
# but WITHOUT ANY WARRANTY; without even the implied warranty of
27
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28
# General Public License for more details.
29
#
30
# The full text of the GPL is available at:
31
#
32
# http://www.gnu.org/licenses/
33
#*****************************************************************************
34
35
import sage.modular.cusps as cusps
36
import sage.modular.modsym.manin_symbols
37
from sage.structure.sage_object import SageObject
38
import sage.structure.formal_sum as formal_sum
39
import sage.rings.arith as arith
40
from sage.rings.integer_ring import ZZ
41
from sage.misc.latex import latex
42
43
_C = cusps.Cusps
44
45
X, Y = ZZ['X,Y'].gens()
46
47
class ModularSymbol(SageObject):
48
r"""
49
The modular symbol `X^i\cdot Y^{k-2-i}\cdot \{\alpha, \beta\}`.
50
"""
51
def __init__(self, space, i, alpha, beta):
52
"""
53
Initialise a modular symbol.
54
55
INPUT:
56
57
- ``space`` -- space of Manin symbols
58
59
- ``i`` -- integer
60
61
- ``alpha`` -- cusp
62
63
- ``beta`` -- cusp
64
65
EXAMPLES::
66
67
sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]; s
68
{-1/9, 0}
69
sage: type(s)
70
<class 'sage.modular.modsym.modular_symbols.ModularSymbol'>
71
sage: s = ModularSymbols(11,4).2.modular_symbol_rep()[0][1]; s
72
X^2*{-1/7, 0}
73
"""
74
self.__space = space
75
self.__i = i
76
self.__alpha = _C(alpha)
77
self.__beta = _C(beta)
78
79
def _repr_(self):
80
"""
81
String representation of this modular symbol.
82
83
EXAMPLES::
84
85
sage: s = ModularSymbols(11,4).2.modular_symbol_rep()[0][1]; s
86
X^2*{-1/7, 0}
87
sage: s._repr_()
88
'X^2*{-1/7, 0}'
89
sage: s.rename('sym')
90
sage: s
91
sym
92
"""
93
if self.weight() == 2:
94
polypart = ''
95
else:
96
polypart = str(self.polynomial_part()) + '*'
97
return "%s{%s, %s}"%(polypart, self.__alpha, self.__beta)
98
99
def __getitem__(self, j):
100
r"""
101
Given a modular symbols `s = X^i Y^{k-2-i}\{\alpha, \beta\}`, ``s[0]`` is `\alpha`
102
and ``s[1]`` is `\beta`.
103
104
EXAMPLES::
105
106
sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]; s
107
{-1/9, 0}
108
sage: s[0]
109
-1/9
110
sage: s[1]
111
0
112
sage: s[2]
113
Traceback (most recent call last):
114
...
115
IndexError: list index out of range
116
"""
117
return [self.__alpha, self.__beta][j]
118
119
def _latex_(self):
120
"""
121
Return Latex representation of this modular symbol.
122
123
EXAMPLES::
124
125
sage: s = ModularSymbols(11,4).2.modular_symbol_rep()[0][1]; s
126
X^2*{-1/7, 0}
127
sage: latex(s) # indirect doctest
128
X^{2}\left\{\frac{-1}{7}, 0\right\}
129
"""
130
if self.weight() == 2:
131
polypart = ''
132
else:
133
polypart = latex(self.polynomial_part())
134
return "%s\\left\\{%s, %s\\right\\}"%(polypart,
135
latex(self.__alpha), latex(self.__beta))
136
137
def __cmp__(self, other):
138
"""
139
Compare self to other.
140
141
EXAMPLES::
142
143
sage: M = ModularSymbols(11)
144
sage: s = M.2.modular_symbol_rep()[0][1]
145
sage: t = M.0.modular_symbol_rep()[0][1]
146
sage: s, t
147
({-1/9, 0}, {Infinity, 0})
148
sage: s < t
149
True
150
sage: t > s
151
True
152
sage: s == s
153
True
154
sage: t == t
155
True
156
"""
157
if not isinstance(other, ModularSymbol):
158
return cmp(type(self), type(other))
159
return cmp((self.__space,-self.__i,self.__alpha,self.__beta),
160
(other.__space,-other.__i,other.__alpha,other.__beta))
161
162
def space(self):
163
"""
164
The list of Manin symbols to which this symbol belongs.
165
166
EXAMPLES::
167
168
sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]
169
sage: s.space()
170
Manin Symbol List of weight 2 for Gamma0(11)
171
"""
172
return self.__space
173
174
def polynomial_part(self):
175
r"""
176
Return the polynomial part of this symbol, i.e. for a symbol of the
177
form `X^i Y^{k-2-i}\{\alpha, \beta\}`, return `X^i Y^{k-2-i}`.
178
179
EXAMPLES::
180
181
sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]
182
sage: s.polynomial_part()
183
1
184
sage: s = ModularSymbols(1,28).0.modular_symbol_rep()[0][1]; s
185
X^22*Y^4*{0, Infinity}
186
sage: s.polynomial_part()
187
X^22*Y^4
188
"""
189
i = self.__i
190
return X**i*Y**(self.weight()-2-i)
191
192
def i(self):
193
r"""
194
For a symbol of the form `X^i Y^{k-2-i}\{\alpha, \beta\}`, return `i`.
195
196
EXAMPLES::
197
198
sage: s = ModularSymbols(11).2.modular_symbol_rep()[0][1]
199
sage: s.i()
200
0
201
sage: s = ModularSymbols(1,28).0.modular_symbol_rep()[0][1]; s
202
X^22*Y^4*{0, Infinity}
203
sage: s.i()
204
22
205
"""
206
return self.__i
207
208
def weight(self):
209
r"""
210
Return the weight of the modular symbols space to which this symbol
211
belongs; i.e. for a symbol of the form `X^i Y^{k-2-i}\{\alpha,
212
\beta\}`, return `k`.
213
214
EXAMPLES::
215
216
sage: s = ModularSymbols(1,28).0.modular_symbol_rep()[0][1]
217
sage: s.weight()
218
28
219
"""
220
return self.__space.weight()
221
222
def alpha(self):
223
r"""
224
For a symbol of the form `X^i Y^{k-2-i}\{\alpha, \beta\}`, return `\alpha`.
225
226
EXAMPLES::
227
228
sage: s = ModularSymbols(11,4).1.modular_symbol_rep()[0][1]; s
229
X^2*{-1/6, 0}
230
sage: s.alpha()
231
-1/6
232
sage: type(s.alpha())
233
<class 'sage.modular.cusps.Cusp'>
234
"""
235
return self.__alpha
236
237
def beta(self):
238
r"""
239
For a symbol of the form `X^i Y^{k-2-i}\{\alpha, \beta\}`, return `\beta`.
240
241
EXAMPLES::
242
243
sage: s = ModularSymbols(11,4).1.modular_symbol_rep()[0][1]; s
244
X^2*{-1/6, 0}
245
sage: s.beta()
246
0
247
sage: type(s.beta())
248
<class 'sage.modular.cusps.Cusp'>
249
"""
250
return self.__beta
251
252
def apply(self, g):
253
r"""
254
Act on this symbol by the element `g \in {\rm GL}_2(\QQ)`.
255
256
INPUT:
257
258
- ``g`` -- a list ``[a,b,c,d]``, corresponding to the 2x2 matrix
259
`\begin{pmatrix} a & b \\ c & d \end{pmatrix} \in {\rm GL}_2(\QQ)`.
260
261
OUTPUT:
262
263
- ``FormalSum`` -- a formal sum `\sum_i c_i x_i`, where `c_i` are
264
scalars and `x_i` are ModularSymbol objects, such that the sum
265
`\sum_i c_i x_i` is the image of this symbol under the action of g.
266
No reduction is performed modulo the relations that hold in
267
self.space().
268
269
The action of `g` on symbols is by
270
271
.. math::
272
273
P(X,Y)\{\alpha, \beta\} \mapsto P(dX-bY, -cx+aY) \{g(\alpha), g(\beta)\}.
274
275
Note that for us we have `P=X^i Y^{k-2-i}`, which simplifies computation
276
of the polynomial part slightly.
277
278
EXAMPLES::
279
280
sage: s = ModularSymbols(11,2).1.modular_symbol_rep()[0][1]; s
281
{-1/8, 0}
282
sage: a=1;b=2;c=3;d=4; s.apply([a,b,c,d])
283
{15/29, 1/2}
284
sage: x = -1/8; (a*x+b)/(c*x+d)
285
15/29
286
sage: x = 0; (a*x+b)/(c*x+d)
287
1/2
288
sage: s = ModularSymbols(11,4).1.modular_symbol_rep()[0][1]; s
289
X^2*{-1/6, 0}
290
sage: s.apply([a,b,c,d])
291
16*X^2*{11/21, 1/2} - 16*X*Y*{11/21, 1/2} + 4*Y^2*{11/21, 1/2}
292
sage: P = s.polynomial_part()
293
sage: X,Y = P.parent().gens()
294
sage: P(d*X-b*Y, -c*X+a*Y)
295
16*X^2 - 16*X*Y + 4*Y^2
296
sage: x=-1/6; (a*x+b)/(c*x+d)
297
11/21
298
sage: x=0; (a*x+b)/(c*x+d)
299
1/2
300
sage: type(s.apply([a,b,c,d]))
301
<class 'sage.structure.formal_sum.FormalSum'>
302
"""
303
space = self.__space
304
i = self.__i
305
k = space.weight()
306
a,b,c,d = tuple(g)
307
coeffs = sage.modular.modsym.manin_symbols.apply_to_monomial(i, k-2, d, -b, -c, a)
308
g_alpha = self.__alpha.apply(g)
309
g_beta = self.__beta.apply(g)
310
return formal_sum.FormalSum([(coeffs[j], ModularSymbol(space, j, g_alpha, g_beta)) \
311
for j in reversed(range(k-1)) if coeffs[j] != 0])
312
313
def __manin_symbol_rep(self, alpha):
314
"""
315
Return Manin symbol representation of X^i*Y^(k-2-i){0,alpha}.
316
317
EXAMPLES::
318
319
sage: s = ModularSymbols(11,2).1.modular_symbol_rep()[0][1]; s
320
{-1/8, 0}
321
sage: s.manin_symbol_rep() # indirect doctest
322
-(-8,1) - (1,1)
323
sage: M = ModularSymbols(11,2)
324
sage: s = M( (1,9) ); s
325
(1,9)
326
sage: t = s.modular_symbol_rep()[0][1].manin_symbol_rep(); t
327
-(-9,1) - (1,1)
328
sage: M(t)
329
(1,9)
330
"""
331
space = self.__space
332
i = self.__i
333
k = space.weight()
334
v = [(0,1), (1,0)]
335
if not alpha.is_infinity():
336
v += [(x.numerator(), x.denominator()) for x in arith.convergents(alpha._rational_())]
337
sign = 1
338
apply = sage.modular.modsym.manin_symbols.apply_to_monomial
339
mansym = sage.modular.modsym.manin_symbols.ManinSymbol
340
z = formal_sum.FormalSum(0)
341
for j in range(1,len(v)):
342
c = sign*v[j][1]
343
d = v[j-1][1]
344
coeffs = apply(i, k-2, sign*v[j][0], v[j-1][0], sign*v[j][1], v[j-1][1])
345
w = [(coeffs[j], mansym(space, (j, c, d))) \
346
for j in range(k-1) if coeffs[j] != 0]
347
z += formal_sum.FormalSum(w)
348
sign *= -1
349
return z
350
351
def manin_symbol_rep(self):
352
"""
353
Returns a representation of self as a formal sum of Manin symbols.
354
(The result is not cached.)
355
356
EXAMPLES::
357
358
sage: M = ModularSymbols(11,4)
359
sage: s = M.1.modular_symbol_rep()[0][1]; s
360
X^2*{-1/6, 0}
361
sage: s.manin_symbol_rep()
362
-[Y^2,(1,1)] - 2*[X*Y,(-1,0)] - [X^2,(-6,1)] - [X^2,(-1,0)]
363
sage: M(s.manin_symbol_rep()) == M([2,-1/6,0])
364
True
365
"""
366
alpha = self.__alpha
367
beta = self.__beta
368
return -1*self.__manin_symbol_rep(alpha) + self.__manin_symbol_rep(beta)
369
370
371