Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagelib
Path: blob/master/sage/modular/modform/element.py
4045 views
1
# -*- coding: utf-8 -*-
2
"""
3
Elements of modular forms spaces
4
"""
5
6
#########################################################################
7
# Copyright (C) 2004--2008 William Stein <[email protected]>
8
#
9
# Distributed under the terms of the GNU General Public License (GPL)
10
#
11
# http://www.gnu.org/licenses/
12
#########################################################################
13
14
import space
15
import sage.modular.hecke.element as element
16
import sage.rings.all as rings
17
from sage.modular.modsym.space import is_ModularSymbolsSpace
18
from sage.modules.module_element import ModuleElement
19
from sage.modules.free_module_element import vector
20
from sage.misc.misc import verbose
21
from sage.modular.dirichlet import DirichletGroup
22
23
def is_ModularFormElement(x):
24
"""
25
Return True if x is a modular form.
26
27
EXAMPLES::
28
29
sage: from sage.modular.modform.element import is_ModularFormElement
30
sage: is_ModularFormElement(5)
31
False
32
sage: is_ModularFormElement(ModularForms(11).0)
33
True
34
"""
35
return isinstance(x, ModularFormElement)
36
37
def delta_lseries(prec=53,
38
max_imaginary_part=0,
39
max_asymp_coeffs=40):
40
r"""
41
Return the L-series of the modular form Delta.
42
43
This actually returns an interface to Tim Dokchitser's program
44
for computing with the L-series of the modular form `\Delta`.
45
46
INPUT:
47
48
- ``prec`` - integer (bits precision)
49
50
- ``max_imaginary_part`` - real number
51
52
- ``max_asymp_coeffs`` - integer
53
54
OUTPUT:
55
56
The L-series of `\Delta`.
57
58
EXAMPLES::
59
60
sage: L = delta_lseries()
61
sage: L(1)
62
0.0374412812685155
63
"""
64
from sage.lfunctions.all import Dokchitser
65
key = (prec, max_imaginary_part, max_asymp_coeffs)
66
L = Dokchitser(conductor = 1,
67
gammaV = [0,1],
68
weight = 12,
69
eps = 1,
70
prec = prec)
71
s = 'tau(n) = (5*sigma(n,3)+7*sigma(n,5))*n/12-35*sum(k=1,n-1,(6*k-4*(n-k))*sigma(k,3)*sigma(n-k,5));'
72
L.init_coeffs('tau(k)',pari_precode = s,
73
max_imaginary_part=max_imaginary_part,
74
max_asymp_coeffs=max_asymp_coeffs)
75
L.set_coeff_growth('2*n^(11/2)')
76
L.rename('L-series associated to the modular form Delta')
77
return L
78
79
class ModularForm_abstract(ModuleElement):
80
"""
81
Constructor for generic class of a modular form. This
82
should never be called directly; instead one should
83
instantiate one of the derived classes of this
84
class.
85
"""
86
def group(self):
87
"""
88
Return the group for which self is a modular form.
89
90
EXAMPLES::
91
92
sage: ModularForms(Gamma1(11), 2).gen(0).group()
93
Congruence Subgroup Gamma1(11)
94
"""
95
return self.parent().group()
96
97
def weight(self):
98
"""
99
Return the weight of self.
100
101
EXAMPLES::
102
103
sage: (ModularForms(Gamma1(9),2).6).weight()
104
2
105
"""
106
return self.parent().weight()
107
108
def level(self):
109
"""
110
Return the level of self.
111
112
EXAMPLES::
113
114
sage: ModularForms(25,4).0.level()
115
25
116
"""
117
return self.parent().level()
118
119
def _repr_(self):
120
"""
121
Return the string representation of self.
122
123
EXAMPLES::
124
125
sage: ModularForms(25,4).0._repr_()
126
'q + O(q^6)'
127
128
sage: ModularForms(25,4).3._repr_()
129
'q^4 + O(q^6)'
130
"""
131
return str(self.q_expansion())
132
133
def _ensure_is_compatible(self, other):
134
"""
135
Make sure self and other are compatible for arithmetic or
136
comparison operations. Raise an error if incompatible,
137
do nothing otherwise.
138
139
EXAMPLES::
140
141
sage: f = ModularForms(DirichletGroup(17).0^2,2).2
142
sage: g = ModularForms(DirichletGroup(17).0^2,2).1
143
sage: h = ModularForms(17,4).0
144
145
sage: f._ensure_is_compatible(g)
146
147
sage: f._ensure_is_compatible(h)
148
Traceback (most recent call last):
149
...
150
ArithmeticError: Modular forms must be in the same ambient space.
151
"""
152
if not isinstance(other, ModularForm_abstract):
153
raise TypeError, "Second argument must be a modular form."
154
if self.parent().ambient() != other.parent().ambient():
155
raise ArithmeticError, "Modular forms must be in the same ambient space."
156
157
def __call__(self, x, prec=None):
158
"""
159
Evaluate the q-expansion of this modular form at x.
160
161
EXAMPLES::
162
163
sage: f = ModularForms(DirichletGroup(17).0^2,2).2
164
165
sage: f(7) ## indirect doctest
166
-4851*zeta8^2 - 16464*zeta8 + 92372
167
168
sage: f(0)
169
0
170
"""
171
return self.q_expansion(prec)(x)
172
173
def valuation(self):
174
"""
175
Return the valuation of self (i.e. as an element of the power
176
series ring in q).
177
178
EXAMPLES::
179
180
sage: ModularForms(11,2).0.valuation()
181
1
182
sage: ModularForms(11,2).1.valuation()
183
0
184
sage: ModularForms(25,6).1.valuation()
185
2
186
sage: ModularForms(25,6).6.valuation()
187
7
188
"""
189
try:
190
return self.__valuation
191
except AttributeError:
192
v = self.qexp().valuation()
193
if not (v is rings.infinity):
194
self.__valuation = v
195
return v
196
v = self.qexp(self.parent().sturm_bound()).valuation()
197
self.__valuation = v
198
return v
199
200
def qexp(self, prec=None):
201
"""
202
Same as ``self.q_expansion(prec)``.
203
204
.. seealso:: :meth:`q_expansion`
205
206
EXAMPLES::
207
208
sage: CuspForms(1,12).0.qexp()
209
q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6)
210
"""
211
return self.q_expansion(prec)
212
213
214
def __eq__(self, other):
215
"""
216
Compare self to other.
217
218
EXAMPLES::
219
220
sage: f = ModularForms(6,4).0
221
sage: g = ModularForms(23,2).0
222
sage: f == g ## indirect doctest
223
False
224
sage: f == f
225
True
226
sage: f == loads(dumps(f))
227
True
228
"""
229
if not isinstance(other, ModularFormElement) or \
230
self.ambient_module() != other.ambient_module():
231
return False
232
else:
233
return self.element() == other.element()
234
235
def __cmp__(self, other):
236
"""
237
Compare self to other. If they are not the same object, but
238
are of the same type, compare them as vectors.
239
240
EXAMPLES::
241
242
sage: f = ModularForms(DirichletGroup(17).0^2,2).2
243
sage: g = ModularForms(DirichletGroup(17).0^2,2).1
244
sage: f == g ## indirect doctest
245
False
246
sage: f == f
247
True
248
"""
249
try:
250
self._ensure_is_compatible(other)
251
except:
252
return self.parent().__cmp__(other.parent())
253
if self.element() == other.element():
254
return 0
255
else:
256
return -1
257
258
def _compute(self, X):
259
"""
260
Compute the coefficients of `q^n` of the power series of self,
261
for `n` in the list `X`. The results are not cached. (Use
262
coefficients for cached results).
263
264
EXAMPLES::
265
266
sage: f = ModularForms(18,2).1
267
sage: f.q_expansion(20)
268
q + 8*q^7 + 4*q^10 + 14*q^13 - 4*q^16 + 20*q^19 + O(q^20)
269
sage: f._compute([10,17])
270
[4, 0]
271
sage: f._compute([])
272
[]
273
"""
274
if not isinstance(X, list) or len(X) == 0:
275
return []
276
bound = max(X)
277
q_exp = self.q_expansion(bound+1)
278
return [q_exp[i] for i in X]
279
280
def coefficients(self, X):
281
"""
282
The coefficients a_n of self, for integers n>=0 in the list
283
X. If X is an Integer, return coefficients for indices from 1
284
to X.
285
286
This function caches the results of the compute function.
287
288
TESTS::
289
290
sage: e = DirichletGroup(11).gen()
291
sage: f = EisensteinForms(e, 3).eisenstein_series()[0]
292
sage: f.coefficients([0,1])
293
[15/11*zeta10^3 - 9/11*zeta10^2 - 26/11*zeta10 - 10/11,
294
1]
295
sage: f.coefficients([0,1,2,3])
296
[15/11*zeta10^3 - 9/11*zeta10^2 - 26/11*zeta10 - 10/11,
297
1,
298
4*zeta10 + 1,
299
-9*zeta10^3 + 1]
300
sage: f.coefficients([2,3])
301
[4*zeta10 + 1,
302
-9*zeta10^3 + 1]
303
304
Running this twice once revealed a bug, so we test it::
305
306
sage: f.coefficients([0,1,2,3])
307
[15/11*zeta10^3 - 9/11*zeta10^2 - 26/11*zeta10 - 10/11,
308
1,
309
4*zeta10 + 1,
310
-9*zeta10^3 + 1]
311
"""
312
try:
313
self.__coefficients
314
except AttributeError:
315
self.__coefficients = {}
316
if isinstance(X, rings.Integer):
317
X = range(1,X+1)
318
Y = [n for n in X if not (n in self.__coefficients.keys())]
319
v = self._compute(Y)
320
for i in range(len(v)):
321
self.__coefficients[Y[i]] = v[i]
322
return [ self.__coefficients[x] for x in X ]
323
324
def __getitem__(self, n):
325
"""
326
Returns the `q^n` coefficient of the `q`-expansion of self or
327
returns a list containing the `q^i` coefficients of self
328
where `i` is in slice `n`.
329
330
EXAMPLES::
331
332
sage: f = ModularForms(DirichletGroup(17).0^2,2).2
333
sage: f.__getitem__(10)
334
zeta8^3 - 5*zeta8^2 - 2*zeta8 + 10
335
sage: f[30]
336
-2*zeta8^3 - 17*zeta8^2 + 4*zeta8 + 29
337
sage: f[10:15]
338
[zeta8^3 - 5*zeta8^2 - 2*zeta8 + 10,
339
-zeta8^3 + 11,
340
-2*zeta8^3 - 6*zeta8^2 + 3*zeta8 + 9,
341
12,
342
2*zeta8^3 - 7*zeta8^2 + zeta8 + 14]
343
"""
344
if isinstance(n, slice):
345
if n.stop is None:
346
return self.q_expansion().list()[n]
347
else:
348
return self.q_expansion(n.stop+1).list()[n]
349
else:
350
return self.q_expansion(n+1)[int(n)]
351
352
def padded_list(self, n):
353
"""
354
Return a list of length n whose entries are the first n
355
coefficients of the q-expansion of self.
356
357
EXAMPLES::
358
359
sage: CuspForms(1,12).0.padded_list(20)
360
[0, 1, -24, 252, -1472, 4830, -6048, -16744, 84480, -113643, -115920, 534612, -370944, -577738, 401856, 1217160, 987136, -6905934, 2727432, 10661420]
361
"""
362
return self.q_expansion(n).padded_list(n)
363
364
365
def _latex_(self):
366
"""
367
Return the LaTeX expression of self.
368
369
EXAMPLES:
370
sage: ModularForms(25,4).0._latex_()
371
'q + O(q^{6})'
372
373
sage: ModularForms(25,4).4._latex_()
374
'q^{5} + O(q^{6})'
375
"""
376
return self.q_expansion()._latex_()
377
378
def base_ring(self):
379
"""
380
Return the base_ring of self.
381
382
EXAMPLES::
383
384
sage: (ModularForms(117, 2).13).base_ring()
385
Rational Field
386
sage: (ModularForms(119, 2, base_ring=GF(7)).12).base_ring()
387
Finite Field of size 7
388
"""
389
return self.parent().base_ring()
390
391
def character(self, compute=True):
392
"""
393
Return the character of self. If ``compute=False``, then this will
394
return None unless the form was explicitly created as an element of a
395
space of forms with character, skipping the (potentially expensive)
396
computation of the matrices of the diamond operators.
397
398
EXAMPLES::
399
400
sage: ModularForms(DirichletGroup(17).0^2,2).2.character()
401
Dirichlet character modulo 17 of conductor 17 mapping 3 |--> zeta8
402
403
sage: CuspForms(Gamma1(7), 3).gen(0).character()
404
Dirichlet character modulo 7 of conductor 7 mapping 3 |--> -1
405
sage: CuspForms(Gamma1(7), 3).gen(0).character(compute = False) is None
406
True
407
sage: M = CuspForms(Gamma1(7), 5).gen(0).character()
408
Traceback (most recent call last):
409
...
410
ValueError: Form is not an eigenvector for <3>
411
"""
412
chi = self.parent().character()
413
if (chi is not None) or (not compute):
414
return chi
415
else: # do the expensive computation
416
G = DirichletGroup(self.parent().level(), base_ring = self.parent().base_ring())
417
gens = G.unit_gens()
418
i = self.valuation()
419
vals = []
420
for g in gens:
421
df = self.parent().diamond_bracket_operator(g)(self)
422
if df != (df[i] / self[i]) * self:
423
raise ValueError, "Form is not an eigenvector for <%s>" % g
424
vals.append(df[i] / self[i])
425
return G(vals)
426
427
def __nonzero__(self):
428
"""
429
Return True if self is nonzero, and False if not.
430
431
EXAMPLES::
432
433
sage: ModularForms(25,6).6.__nonzero__()
434
True
435
"""
436
return not self.element().is_zero()
437
438
def prec(self):
439
"""
440
Return the precision to which self.q_expansion() is
441
currently known. Note that this may be 0.
442
443
EXAMPLES::
444
445
sage: M = ModularForms(2,14)
446
sage: f = M.0
447
sage: f.prec()
448
0
449
450
sage: M.prec(20)
451
20
452
sage: f.prec()
453
0
454
sage: x = f.q_expansion() ; f.prec()
455
20
456
"""
457
try:
458
return self.__q_expansion[0]
459
except AttributeError:
460
return 0
461
462
def q_expansion(self, prec=None):
463
r"""
464
The `q`-expansion of the modular form to precision `O(q^\text{prec})`.
465
This function takes one argument, which is the integer prec.
466
467
EXAMPLES:
468
469
We compute the cusp form `\Delta`::
470
471
sage: delta = CuspForms(1,12).0
472
sage: delta.q_expansion()
473
q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6)
474
475
We compute the `q`-expansion of one of the cusp forms of level 23::
476
477
sage: f = CuspForms(23,2).0
478
sage: f.q_expansion()
479
q - q^3 - q^4 + O(q^6)
480
sage: f.q_expansion(10)
481
q - q^3 - q^4 - 2*q^6 + 2*q^7 - q^8 + 2*q^9 + O(q^10)
482
sage: f.q_expansion(2)
483
q + O(q^2)
484
sage: f.q_expansion(1)
485
O(q^1)
486
sage: f.q_expansion(0)
487
O(q^0)
488
"""
489
if prec is None:
490
prec = self.parent().prec()
491
prec = rings.Integer(prec)
492
if prec < 0:
493
raise ValueError, "prec (=%s) must be at least 0"%prec
494
try:
495
current_prec, f = self.__q_expansion
496
except AttributeError:
497
current_prec = 0
498
f = self.parent()._q_expansion_ring()(0, -1)
499
500
if current_prec == prec:
501
return f
502
elif current_prec > prec:
503
return f.add_bigoh(prec)
504
else:
505
f = self._compute_q_expansion(prec)
506
self.__q_expansion = (prec, f)
507
return f
508
509
def atkin_lehner_eigenvalue(self, d=None):
510
r"""
511
Return the eigenvalue of the Atkin-Lehner operator W_d acting on self
512
(which is either 1 or -1), or None if this form is not an eigenvector
513
for this operator. If d is not given or is None, use d = the level.
514
515
EXAMPLES::
516
517
sage: sage.modular.modform.element.ModularForm_abstract.atkin_lehner_eigenvalue(CuspForms(2, 8).0)
518
Traceback (most recent call last):
519
...
520
NotImplementedError
521
"""
522
raise NotImplementedError
523
524
# this function lives here so it is inherited by Newform (which does *not* derive from ModularFormElement)
525
def cuspform_lseries(self, prec=53,
526
max_imaginary_part=0,
527
max_asymp_coeffs=40):
528
r"""
529
Return the L-series of the weight k cusp form
530
f on `\Gamma_0(N)`.
531
532
This actually returns an interface to Tim Dokchitser's program
533
for computing with the L-series of the cusp form.
534
535
INPUT:
536
537
- ``prec`` - integer (bits precision)
538
539
- ``max_imaginary_part`` - real number
540
541
- ``max_asymp_coeffs`` - integer
542
543
OUTPUT:
544
545
The L-series of the cusp form.
546
547
EXAMPLES::
548
549
sage: f = CuspForms(2,8).newforms()[0]
550
sage: L = f.cuspform_lseries()
551
sage: L(1)
552
0.0884317737041015
553
sage: L(0.5)
554
0.0296568512531983
555
556
Consistency check with delta_lseries (which computes coefficients in pari)::
557
558
sage: delta = CuspForms(1,12).0
559
sage: L = delta.cuspform_lseries()
560
sage: L(1)
561
0.0374412812685155
562
sage: L = delta_lseries()
563
sage: L(1)
564
0.0374412812685155
565
566
We check that #5262 is fixed::
567
568
sage: E=EllipticCurve('37b2')
569
sage: h=Newforms(37)[1]
570
sage: Lh = h.cuspform_lseries()
571
sage: LE=E.lseries()
572
sage: Lh(1), LE(1)
573
(0.725681061936153, 0.725681061936153)
574
sage: CuspForms(1, 30).0.cuspform_lseries().eps
575
-1
576
"""
577
if self.q_expansion().list()[0] !=0:
578
raise TypeError,"f = %s is not a cusp form"%self
579
from sage.lfunctions.all import Dokchitser
580
key = (prec, max_imaginary_part, max_asymp_coeffs)
581
l = self.weight()
582
N = self.level()
583
w = self.atkin_lehner_eigenvalue()
584
if w is None:
585
raise ValueError, "Form is not an eigenform for Atkin-Lehner"
586
e = (-1)**(l/2)*w
587
L = Dokchitser(conductor = N,
588
gammaV = [0,1],
589
weight = l,
590
eps = e,
591
prec = prec)
592
s = 'coeff = %s;'%self.q_expansion(prec).list()
593
L.init_coeffs('coeff[k+1]',pari_precode = s,
594
max_imaginary_part=max_imaginary_part,
595
max_asymp_coeffs=max_asymp_coeffs)
596
L.check_functional_equation()
597
L.rename('L-series associated to the cusp form %s'%self)
598
return L
599
600
class Newform(ModularForm_abstract):
601
def __init__(self, parent, component, names, check=True):
602
r"""
603
Initialize a Newform object.
604
605
INPUT:
606
607
- ``parent`` - An ambient cuspidal space of modular forms for
608
which self is a newform.
609
610
- ``component`` - A simple component of a cuspidal modular
611
symbols space of any sign corresponding to this newform.
612
613
- ``check`` - If check is ``True``, check that parent and
614
component have the same weight, level, and character, that
615
component has sign 1 and is simple, and that the types are
616
correct on all inputs.
617
618
EXAMPLES::
619
620
sage: sage.modular.modform.element.Newform(CuspForms(11,2), ModularSymbols(11,2,sign=1).cuspidal_subspace(), 'a')
621
q - 2*q^2 - q^3 + 2*q^4 + q^5 + O(q^6)
622
623
sage: f = Newforms(DirichletGroup(5).0, 7,names='a')[0]; f[2].trace(f.base_ring().base_field())
624
-5*zeta4 - 5
625
"""
626
if check:
627
if not space.is_ModularFormsSpace(parent):
628
raise TypeError, "parent must be a space of modular forms"
629
if not is_ModularSymbolsSpace(component):
630
raise TypeError, "component must be a space of modular symbols"
631
if parent.group() != component.group():
632
raise ValueError, "parent and component must be defined by the same congruence subgroup"
633
if parent.weight() != component.weight():
634
raise ValueError, "parent and component must have the same weight"
635
if not component.is_cuspidal():
636
raise ValueError, "component must be cuspidal"
637
if not component.is_simple():
638
raise ValueError, "component must be simple"
639
extension_field = component.eigenvalue(1,name=names).parent()
640
if extension_field != parent.base_ring(): # .degree() != 1 and rings.is_NumberField(extension_field):
641
assert extension_field.base_field() == parent.base_ring()
642
extension_field = parent.base_ring().extension(extension_field.relative_polynomial(), names=names)
643
self.__name = names
644
ModuleElement.__init__(self, parent.base_extend(extension_field))
645
self.__modsym_space = component
646
self.__hecke_eigenvalue_field = extension_field
647
648
def _name(self):
649
"""
650
Return the name of the generator of the Hecke eigenvalue field
651
of self. Note that a name exists even when this field is QQ.
652
653
EXAMPLES::
654
655
sage: [ f._name() for f in Newforms(38,4,names='a') ]
656
['a0', 'a1', 'a2']
657
"""
658
return self.__name
659
660
def _compute_q_expansion(self, prec):
661
"""
662
Return the q-expansion of self to precision prec.
663
664
EXAMPLES::
665
666
sage: forms = Newforms(31, 6, names='a')
667
sage: forms[0]._compute_q_expansion(10)
668
q + a0*q^2 + (5/704*a0^4 + 43/704*a0^3 - 61/88*a0^2 - 197/44*a0 + 717/88)*q^3 + (a0^2 - 32)*q^4 + (-31/352*a0^4 - 249/352*a0^3 + 111/22*a0^2 + 218/11*a0 - 2879/44)*q^5 + (-1/352*a0^4 - 79/352*a0^3 - 67/44*a0^2 + 13/22*a0 - 425/44)*q^6 + (17/88*a0^4 + 133/88*a0^3 - 405/44*a0^2 - 1005/22*a0 - 35/11)*q^7 + (a0^3 - 64*a0)*q^8 + (39/352*a0^4 + 441/352*a0^3 - 93/44*a0^2 - 441/22*a0 - 5293/44)*q^9 + O(q^10)
669
sage: forms[0]._compute_q_expansion(15)
670
q + a0*q^2 + (5/704*a0^4 + 43/704*a0^3 - 61/88*a0^2 - 197/44*a0 + 717/88)*q^3 + (a0^2 - 32)*q^4 + (-31/352*a0^4 - 249/352*a0^3 + 111/22*a0^2 + 218/11*a0 - 2879/44)*q^5 + (-1/352*a0^4 - 79/352*a0^3 - 67/44*a0^2 + 13/22*a0 - 425/44)*q^6 + (17/88*a0^4 + 133/88*a0^3 - 405/44*a0^2 - 1005/22*a0 - 35/11)*q^7 + (a0^3 - 64*a0)*q^8 + (39/352*a0^4 + 441/352*a0^3 - 93/44*a0^2 - 441/22*a0 - 5293/44)*q^9 + (15/176*a0^4 - 135/176*a0^3 - 185/11*a0^2 + 311/11*a0 + 2635/22)*q^10 + (-291/704*a0^4 - 3629/704*a0^3 + 1139/88*a0^2 + 10295/44*a0 - 21067/88)*q^11 + (-75/176*a0^4 - 645/176*a0^3 + 475/22*a0^2 + 1503/11*a0 - 5651/22)*q^12 + (207/704*a0^4 + 2977/704*a0^3 + 581/88*a0^2 - 3307/44*a0 - 35753/88)*q^13 + (-5/22*a0^4 + 39/11*a0^3 + 763/22*a0^2 - 2296/11*a0 - 2890/11)*q^14 + O(q^15)
671
"""
672
return self.modular_symbols(1).q_eigenform(prec, names=self._name())
673
674
def __eq__(self, other):
675
"""
676
Return True if self equals other, and False otherwise.
677
678
EXAMPLES::
679
680
sage: f1, f2 = Newforms(17,4,names='a')
681
sage: f1.__eq__(f1)
682
True
683
sage: f1.__eq__(f2)
684
False
685
"""
686
try:
687
self._ensure_is_compatible(other)
688
except:
689
return False
690
if isinstance(other, Newform):
691
if self.q_expansion(self.parent().sturm_bound()) == other.q_expansion(other.parent().sturm_bound()):
692
return True
693
else:
694
return False
695
if is_ModularFormElement(other):
696
if self.element() == other.element():
697
return True
698
else:
699
return False
700
701
def __cmp__(self, other):
702
"""
703
Compare self with other.
704
705
EXAMPLES::
706
707
sage: f1, f2 = Newforms(19,4,names='a')
708
sage: f1.__cmp__(f1)
709
0
710
sage: f1.__cmp__(f2)
711
-1
712
sage: f2.__cmp__(f1)
713
-1
714
"""
715
try:
716
self._ensure_is_compatible(other)
717
except:
718
return self.parent().__cmp__(other.parent())
719
if isinstance(other, Newform):
720
if self.q_expansion(self.parent().sturm_bound()) == other.q_expansion(other.parent().sturm_bound()):
721
return 0
722
else:
723
return -1
724
if is_ModularFormElement(other):
725
if self.element() == other.element():
726
return 0
727
else:
728
return -1
729
730
def abelian_variety(self):
731
"""
732
Return the abelian variety associated to self.
733
734
EXAMPLES::
735
736
sage: Newforms(14,2)[0]
737
q - q^2 - 2*q^3 + q^4 + O(q^6)
738
sage: Newforms(14,2)[0].abelian_variety()
739
Newform abelian subvariety 14a of dimension 1 of J0(14)
740
"""
741
try:
742
return self.__abelian_variety
743
except AttributeError:
744
from sage.modular.abvar.abvar_newform import ModularAbelianVariety_newform
745
self.__abelian_variety = ModularAbelianVariety_newform(self)
746
return self.__abelian_variety
747
748
def hecke_eigenvalue_field(self):
749
r"""
750
Return the field generated over the rationals by the
751
coefficients of this newform.
752
753
EXAMPLES::
754
755
sage: ls = Newforms(35, 2, names='a') ; ls
756
[q + q^3 - 2*q^4 - q^5 + O(q^6),
757
q + a1*q^2 + (-a1 - 1)*q^3 + (-a1 + 2)*q^4 + q^5 + O(q^6)]
758
sage: ls[0].hecke_eigenvalue_field()
759
Rational Field
760
sage: ls[1].hecke_eigenvalue_field()
761
Number Field in a1 with defining polynomial x^2 + x - 4
762
"""
763
return self.__hecke_eigenvalue_field
764
765
def _compute(self, X):
766
"""
767
Compute the coefficients of `q^n` of the power series of self,
768
for `n` in the list `X`. The results are not cached. (Use
769
coefficients for cached results).
770
771
EXAMPLES::
772
773
sage: f = Newforms(39,4,names='a')[1] ; f
774
q + a1*q^2 - 3*q^3 + (2*a1 + 5)*q^4 + (-2*a1 + 14)*q^5 + O(q^6)
775
sage: f._compute([2,3,7])
776
[alpha, -3, -2*alpha + 2]
777
sage: f._compute([])
778
[]
779
"""
780
M = self.modular_symbols(1)
781
return [M.eigenvalue(x) for x in X]
782
783
def element(self):
784
"""
785
Find an element of the ambient space of modular forms which
786
represents this newform.
787
788
.. note::
789
790
This can be quite expensive. Also, the polynomial defining
791
the field of Hecke eigenvalues should be considered random,
792
since it is generated by a random sum of Hecke
793
operators. (The field itself is not random, of course.)
794
795
EXAMPLES::
796
797
sage: ls = Newforms(38,4,names='a')
798
sage: ls[0]
799
q - 2*q^2 - 2*q^3 + 4*q^4 - 9*q^5 + O(q^6)
800
sage: ls # random
801
[q - 2*q^2 - 2*q^3 + 4*q^4 - 9*q^5 + O(q^6),
802
q - 2*q^2 + (-a1 - 2)*q^3 + 4*q^4 + (2*a1 + 10)*q^5 + O(q^6),
803
q + 2*q^2 + (1/2*a2 - 1)*q^3 + 4*q^4 + (-3/2*a2 + 12)*q^5 + O(q^6)]
804
sage: type(ls[0])
805
<class 'sage.modular.modform.element.Newform'>
806
sage: ls[2][3].minpoly()
807
x^2 - 9*x + 2
808
sage: ls2 = [ x.element() for x in ls ]
809
sage: ls2 # random
810
[q - 2*q^2 - 2*q^3 + 4*q^4 - 9*q^5 + O(q^6),
811
q - 2*q^2 + (-a1 - 2)*q^3 + 4*q^4 + (2*a1 + 10)*q^5 + O(q^6),
812
q + 2*q^2 + (1/2*a2 - 1)*q^3 + 4*q^4 + (-3/2*a2 + 12)*q^5 + O(q^6)]
813
sage: type(ls2[0])
814
<class 'sage.modular.modform.element.ModularFormElement'>
815
sage: ls2[2][3].minpoly()
816
x^2 - 9*x + 2
817
"""
818
S = self.parent()
819
return S(self.q_expansion(S.sturm_bound()))
820
821
def modular_symbols(self, sign=0):
822
"""
823
Return the subspace with the specified sign of the space of
824
modular symbols corresponding to this newform.
825
826
EXAMPLES::
827
828
sage: f = Newforms(18,4)[0]
829
sage: f.modular_symbols()
830
Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 18 for Gamma_0(18) of weight 4 with sign 0 over Rational Field
831
sage: f.modular_symbols(1)
832
Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 11 for Gamma_0(18) of weight 4 with sign 1 over Rational Field
833
"""
834
return self.__modsym_space.modular_symbols_of_sign(sign)
835
836
def _defining_modular_symbols(self):
837
"""
838
Return the modular symbols space corresponding to self.
839
840
EXAMPLES::
841
842
sage: Newforms(43,2,names='a')
843
[q - 2*q^2 - 2*q^3 + 2*q^4 - 4*q^5 + O(q^6),
844
q + a1*q^2 - a1*q^3 + (-a1 + 2)*q^5 + O(q^6)]
845
sage: [ x._defining_modular_symbols() for x in Newforms(43,2,names='a') ]
846
[Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 4 for Gamma_0(43) of weight 2 with sign 1 over Rational Field,
847
Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 4 for Gamma_0(43) of weight 2 with sign 1 over Rational Field]
848
sage: ModularSymbols(43,2,sign=1).cuspidal_subspace().new_subspace().decomposition()
849
[
850
Modular Symbols subspace of dimension 1 of Modular Symbols space of dimension 4 for Gamma_0(43) of weight 2 with sign 1 over Rational Field,
851
Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 4 for Gamma_0(43) of weight 2 with sign 1 over Rational Field
852
]
853
"""
854
return self.__modsym_space
855
856
def number(self):
857
"""
858
Return the index of this space in the list of simple, new,
859
cuspidal subspaces of the full space of modular symbols for
860
this weight and level.
861
862
EXAMPLES::
863
864
sage: Newforms(43, 2, names='a')[1].number()
865
1
866
"""
867
return self._defining_modular_symbols().ambient().cuspidal_subspace().new_subspace().decomposition().index(self._defining_modular_symbols())
868
869
def __nonzero__(self):
870
"""
871
Return True, as newforms are never zero.
872
873
EXAMPLES::
874
875
sage: Newforms(14,2)[0].__nonzero__()
876
True
877
"""
878
return True
879
880
def character(self):
881
r"""
882
The nebentypus character of this newform (as a Dirichlet character with
883
values in the field of Hecke eigenvalues of the form).
884
885
EXAMPLES::
886
887
sage: Newforms(Gamma1(7), 4,names='a')[1].character()
888
Dirichlet character modulo 7 of conductor 7 mapping 3 |--> 1/2*a1
889
sage: chi = DirichletGroup(3).0; Newforms(chi, 7)[0].character() == chi
890
True
891
"""
892
return self._defining_modular_symbols().q_eigenform_character(self._name())
893
894
895
def atkin_lehner_eigenvalue(self, d=None):
896
r"""
897
Return the eigenvalue of the Atkin-Lehner operator W_d acting on this newform
898
(which is either 1 or -1). A ValueError will be raised if the character
899
of this form is not either trivial or quadratic. If d is not given or
900
is None, then d defaults to the level of self.
901
902
EXAMPLE::
903
904
sage: [x.atkin_lehner_eigenvalue() for x in ModularForms(53).newforms('a')]
905
[1, -1]
906
sage: CuspForms(DirichletGroup(5).0, 5).newforms()[0].atkin_lehner_eigenvalue()
907
Traceback (most recent call last):
908
...
909
ValueError: Atkin-Lehner only leaves space invariant when character is trivial or quadratic. In general it sends M_k(chi) to M_k(1/chi)
910
"""
911
return self.modular_symbols(sign=1).atkin_lehner_operator(d).matrix()[0,0]
912
913
class ModularFormElement(ModularForm_abstract, element.HeckeModuleElement):
914
def __init__(self, parent, x, check=True):
915
r"""
916
An element of a space of modular forms.
917
918
INPUT:
919
920
- ``parent`` - ModularForms (an ambient space of modular forms)
921
922
- ``x`` - a vector on the basis for parent
923
924
- ``check`` - if check is ``True``, check the types of the
925
inputs.
926
927
OUTPUT:
928
929
- ``ModularFormElement`` - a modular form
930
931
EXAMPLES::
932
933
sage: M = ModularForms(Gamma0(11),2)
934
sage: f = M.0
935
sage: f.parent()
936
Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(11) of weight 2 over Rational Field
937
"""
938
if not isinstance(parent, space.ModularFormsSpace):
939
raise TypeError, "First argument must be an ambient space of modular forms."
940
element.HeckeModuleElement.__init__(self, parent, x)
941
942
def _compute_q_expansion(self, prec):
943
"""
944
Computes the q-expansion of self to precision prec.
945
946
EXAMPLES::
947
948
sage: f = EllipticCurve('37a').modular_form()
949
sage: f.q_expansion() ## indirect doctest
950
q - 2*q^2 - 3*q^3 + 2*q^4 - 2*q^5 + O(q^6)
951
952
sage: f._compute_q_expansion(10)
953
q - 2*q^2 - 3*q^3 + 2*q^4 - 2*q^5 + 6*q^6 - q^7 + 6*q^9 + O(q^10)
954
"""
955
return self.parent()._q_expansion(element = self.element(), prec=prec)
956
957
def _add_(self, other):
958
"""
959
Add self to other.
960
961
EXAMPLES::
962
963
sage: f = ModularForms(DirichletGroup(17).0^2,2).2
964
sage: g = ModularForms(DirichletGroup(17).0^2,2).1
965
sage: f
966
q + (-zeta8^2 + 2)*q^2 + (zeta8 + 3)*q^3 + (-2*zeta8^2 + 3)*q^4 + (-zeta8 + 5)*q^5 + O(q^6)
967
968
sage: g
969
1 + (-14/73*zeta8^3 + 57/73*zeta8^2 + 13/73*zeta8 - 6/73)*q^2 + (-90/73*zeta8^3 + 64/73*zeta8^2 - 52/73*zeta8 + 24/73)*q^3 + (-81/73*zeta8^3 + 189/73*zeta8^2 - 3/73*zeta8 + 153/73)*q^4 + (72/73*zeta8^3 + 124/73*zeta8^2 + 100/73*zeta8 + 156/73)*q^5 + O(q^6)
970
971
sage: f+g ## indirect doctest
972
1 + q + (-14/73*zeta8^3 - 16/73*zeta8^2 + 13/73*zeta8 + 140/73)*q^2 + (-90/73*zeta8^3 + 64/73*zeta8^2 + 21/73*zeta8 + 243/73)*q^3 + (-81/73*zeta8^3 + 43/73*zeta8^2 - 3/73*zeta8 + 372/73)*q^4 + (72/73*zeta8^3 + 124/73*zeta8^2 + 27/73*zeta8 + 521/73)*q^5 + O(q^6)
973
"""
974
return ModularFormElement(self.parent(), self.element() + other.element())
975
976
def __mul__(self, other):
977
r"""
978
Calculate the product self * other.
979
980
This tries to determine the
981
characters of self and other, in order to avoid having to compute a
982
(potentially very large) Gamma1 space. Note that this might lead to
983
a modular form that is defined with respect to a larger subgroup than
984
the factors are.
985
986
An example with character::
987
988
sage: f = ModularForms(DirichletGroup(3).0, 3).0
989
sage: f * f
990
1 + 108*q^2 + 144*q^3 + 2916*q^4 + 8640*q^5 + O(q^6)
991
sage: (f*f).parent()
992
Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(3) of weight 6 over Rational Field
993
sage: (f*f*f).parent()
994
Modular Forms space of dimension 4, character [-1] and weight 9 over Rational Field
995
996
An example where the character is computed on-the-fly::
997
998
sage: f = ModularForms(Gamma1(3), 5).0
999
sage: f*f
1000
1 - 180*q^2 - 480*q^3 + 8100*q^4 + 35712*q^5 + O(q^6)
1001
sage: (f*f).parent()
1002
Modular Forms space of dimension 4 for Congruence Subgroup Gamma0(3) of weight 10 over Rational Field
1003
1004
An example with no character::
1005
1006
sage: f = ModularForms(Gamma1(3), 7).0
1007
sage: f*f
1008
q^2 - 54*q^4 + 128*q^5 + O(q^6)
1009
sage: (f*f).parent()
1010
Modular Forms space of dimension 5 for Congruence Subgroup Gamma0(3) of weight 14 over Rational Field
1011
1012
TESTS:
1013
1014
This shows that the issue at trac ticket #7548 is fixed::
1015
1016
sage: M = CuspForms(Gamma0(5*3^2), 2)
1017
sage: f = M.basis()[0]
1018
sage: 2*f
1019
2*q - 2*q^4 + O(q^6)
1020
sage: f*2
1021
2*q - 2*q^4 + O(q^6)
1022
"""
1023
1024
# boring case: scalar multiplication
1025
if not isinstance(other, ModularFormElement):
1026
return element.HeckeModuleElement.__mul__(self, other)
1027
1028
# first ensure the levels are equal
1029
if self.level() != other.level():
1030
raise NotImplementedError, "Cannot multiply forms of different levels"
1031
1032
# find out about characters
1033
try:
1034
eps1 = self.character()
1035
verbose("character of left is %s" % eps1)
1036
eps2 = other.character()
1037
verbose("character of right is %s" % eps2)
1038
newchar = eps1 * eps2
1039
verbose("character of product is %s" % newchar)
1040
except NotImplementedError:
1041
newchar = None
1042
verbose("character of product not determined")
1043
1044
# now do the math
1045
from constructor import ModularForms
1046
if newchar is not None:
1047
verbose("creating a parent with char")
1048
newparent = ModularForms(newchar, self.weight() + other.weight(), base_ring = newchar.base_ring())
1049
verbose("parent is %s" % newparent)
1050
else:
1051
newparent = ModularForms(self.group(), self.weight() + other.weight(), base_ring = rings.ZZ)
1052
m = newparent.sturm_bound()
1053
newqexp = self.qexp(m) * other.qexp(m)
1054
1055
return newparent.base_extend(newqexp.base_ring())(newqexp)
1056
1057
def modform_lseries(self, prec=53,
1058
max_imaginary_part=0,
1059
max_asymp_coeffs=40):
1060
r"""
1061
Return the L-series of the weight `k` modular form
1062
`f` on `\mathrm{SL}_2(\ZZ)`.
1063
1064
This actually returns an interface to Tim Dokchitser's program
1065
for computing with the L-series of the modular form.
1066
1067
INPUT:
1068
1069
- ``prec`` - integer (bits precision)
1070
1071
- ``max_imaginary_part`` - real number
1072
1073
- ``max_asymp_coeffs`` - integer
1074
1075
OUTPUT:
1076
1077
The L-series of the modular form.
1078
1079
EXAMPLES:
1080
1081
We compute with the L-series of the Eisenstein series `E_4`::
1082
1083
sage: f = ModularForms(1,4).0
1084
sage: L = f.modform_lseries()
1085
sage: L(1)
1086
-0.0304484570583933
1087
"""
1088
a = self.q_expansion(prec).list()
1089
if a[0] == 0:
1090
raise TypeError,"f = %s is a cusp form; please use f.cuspform_lseries() instead!"%self
1091
if self.level() != 1:
1092
raise TypeError, "f = %s is not a modular form for SL_2(Z)"%self
1093
from sage.lfunctions.all import Dokchitser
1094
key = (prec, max_imaginary_part, max_asymp_coeffs)
1095
l = self.weight()
1096
L = Dokchitser(conductor = 1,
1097
gammaV = [0,1],
1098
weight = l,
1099
eps = (-1)**l,
1100
poles = [l],
1101
prec = prec)
1102
b = a[1]
1103
for i in range(len(a)): ##to renormalize so that coefficient of q is 1
1104
a[i] =(1/b)*a[i]
1105
s = 'coeff = %s;'%a
1106
L.init_coeffs('coeff[k+1]',pari_precode = s,
1107
max_imaginary_part=max_imaginary_part,
1108
max_asymp_coeffs=max_asymp_coeffs)
1109
L.check_functional_equation()
1110
L.rename('L-series associated to the weight %s modular form on SL_2(Z)'%l)
1111
return L
1112
1113
def atkin_lehner_eigenvalue(self, d=None):
1114
r"""
1115
Return the eigenvalue of the Atkin-Lehner operator W_d acting on this
1116
modular form (which is either 1 or -1), or None if this form is not an
1117
eigenvector for this operator.
1118
1119
EXAMPLE::
1120
1121
sage: CuspForms(1, 30).0.atkin_lehner_eigenvalue()
1122
1
1123
sage: CuspForms(2, 8).0.atkin_lehner_eigenvalue()
1124
Traceback (most recent call last):
1125
...
1126
NotImplementedError: Don't know how to compute Atkin-Lehner matrix acting on this space (try using a newform constructor instead)
1127
"""
1128
try:
1129
f = self.parent().atkin_lehner_operator(d)(self)
1130
except NotImplementedError:
1131
raise NotImplementedError, "Don't know how to compute Atkin-Lehner matrix acting on this space" \
1132
+ " (try using a newform constructor instead)"
1133
if f == self:
1134
return 1
1135
elif f == -self:
1136
return -1
1137
else:
1138
return None
1139
1140
class ModularFormElement_elliptic_curve(ModularFormElement):
1141
"""
1142
A modular form attached to an elliptic curve.
1143
"""
1144
def __init__(self, parent, E):
1145
"""
1146
Modular form attached to an elliptic curve as an element
1147
of a space of modular forms.
1148
1149
EXAMPLES::
1150
1151
sage: E = EllipticCurve('5077a')
1152
sage: f = E.modular_form()
1153
sage: f
1154
q - 2*q^2 - 3*q^3 + 2*q^4 - 4*q^5 + O(q^6)
1155
sage: f.q_expansion(10)
1156
q - 2*q^2 - 3*q^3 + 2*q^4 - 4*q^5 + 6*q^6 - 4*q^7 + 6*q^9 + O(q^10)
1157
sage: f.parent()
1158
Modular Forms space of dimension 423 for Congruence Subgroup Gamma0(5077) of weight 2 over Rational Field
1159
1160
sage: E = EllipticCurve('37a')
1161
sage: f = E.modular_form() ; f
1162
q - 2*q^2 - 3*q^3 + 2*q^4 - 2*q^5 + O(q^6)
1163
sage: f == loads(dumps(f))
1164
True
1165
"""
1166
ModularFormElement.__init__(self, parent, None)
1167
## parent.find_in_space( E.q_expansion(parent.hecke_bound()) ))
1168
self.__E = E
1169
1170
1171
def elliptic_curve(self):
1172
"""
1173
Return elliptic curve associated to self.
1174
1175
EXAMPLES::
1176
1177
sage: E = EllipticCurve('11a')
1178
sage: f = E.modular_form()
1179
sage: f.elliptic_curve()
1180
Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field
1181
sage: f.elliptic_curve() is E
1182
True
1183
"""
1184
return self.__E
1185
1186
def _compute_element(self):
1187
"""
1188
Compute self as a linear combination of the basis elements
1189
of parent.
1190
1191
EXAMPLES::
1192
1193
sage: EllipticCurve('11a1').modular_form()._compute_element()
1194
(1, 0)
1195
sage: EllipticCurve('389a1').modular_form()._compute_element()
1196
(1, -2, -2, 2, -3, 4, -5, 0, 1, 6, -4, -4, -3, 10, 6, -4, -6, -2, 5, -6, 10, 8, -4, 0, 4, 6, 4, -10, -6, -12, 4, 8, 0)
1197
"""
1198
M = self.parent()
1199
S = M.cuspidal_subspace()
1200
## return S.find_in_space( self.__E.q_expansion( S.q_expansion_basis()[0].prec() ) ) + [0] * ( M.dimension() - S.dimension() )
1201
return vector(S.find_in_space( self.__E.q_expansion( S.sturm_bound() ) ) + [0] * ( M.dimension() - S.dimension() ))
1202
1203
def _compute_q_expansion(self, prec):
1204
r"""
1205
The `q`-expansion of the modular form to precision `O(q^\text{prec})`.
1206
This function takes one argument, which is the integer prec.
1207
1208
EXAMPLES::
1209
1210
sage: E = EllipticCurve('11a') ; f = E.modular_form()
1211
sage: f._compute_q_expansion(10)
1212
q - 2*q^2 - q^3 + 2*q^4 + q^5 + 2*q^6 - 2*q^7 - 2*q^9 + O(q^10)
1213
1214
sage: f._compute_q_expansion(30)
1215
q - 2*q^2 - q^3 + 2*q^4 + q^5 + 2*q^6 - 2*q^7 - 2*q^9 - 2*q^10 + q^11 - 2*q^12 + 4*q^13 + 4*q^14 - q^15 - 4*q^16 - 2*q^17 + 4*q^18 + 2*q^20 + 2*q^21 - 2*q^22 - q^23 - 4*q^25 - 8*q^26 + 5*q^27 - 4*q^28 + O(q^30)
1216
1217
sage: f._compute_q_expansion(10)
1218
q - 2*q^2 - q^3 + 2*q^4 + q^5 + 2*q^6 - 2*q^7 - 2*q^9 + O(q^10)
1219
"""
1220
return self.__E.q_expansion(prec)
1221
1222
def atkin_lehner_eigenvalue(self, d=None):
1223
r"""
1224
Calculate the eigenvalue of the Atkin-Lehner operator W_d acting on
1225
this form. If d is None, default to the level of the form. As this form
1226
is attached to an elliptic curve, we can read this off from the root
1227
number of the curve if d is the level.
1228
1229
EXAMPLE::
1230
1231
sage: EllipticCurve('57a1').newform().atkin_lehner_eigenvalue()
1232
1
1233
sage: EllipticCurve('57b1').newform().atkin_lehner_eigenvalue()
1234
-1
1235
sage: EllipticCurve('57b1').newform().atkin_lehner_eigenvalue(19)
1236
1
1237
"""
1238
if d is None:
1239
return -self.__E.root_number()
1240
else:
1241
return self.__E.modular_symbol_space().atkin_lehner_operator(d).matrix()[0,0]
1242
1243
######################################################################
1244
1245
class EisensteinSeries(ModularFormElement):
1246
"""
1247
An Eisenstein series.
1248
1249
EXAMPLES::
1250
1251
sage: E = EisensteinForms(1,12)
1252
sage: E.eisenstein_series()
1253
[
1254
691/65520 + q + 2049*q^2 + 177148*q^3 + 4196353*q^4 + 48828126*q^5 + O(q^6)
1255
]
1256
sage: E = EisensteinForms(11,2)
1257
sage: E.eisenstein_series()
1258
[
1259
5/12 + q + 3*q^2 + 4*q^3 + 7*q^4 + 6*q^5 + O(q^6)
1260
]
1261
sage: E = EisensteinForms(Gamma1(7),2)
1262
sage: E.set_precision(4)
1263
sage: E.eisenstein_series()
1264
[
1265
1/4 + q + 3*q^2 + 4*q^3 + O(q^4),
1266
1/7*zeta6 - 3/7 + q + (-2*zeta6 + 1)*q^2 + (3*zeta6 - 2)*q^3 + O(q^4),
1267
q + (-zeta6 + 2)*q^2 + (zeta6 + 2)*q^3 + O(q^4),
1268
-1/7*zeta6 - 2/7 + q + (2*zeta6 - 1)*q^2 + (-3*zeta6 + 1)*q^3 + O(q^4),
1269
q + (zeta6 + 1)*q^2 + (-zeta6 + 3)*q^3 + O(q^4)
1270
]
1271
"""
1272
def __init__(self, parent, vector, t, chi, psi):
1273
"""
1274
An Eisenstein series.
1275
1276
EXAMPLES::
1277
1278
sage: E = EisensteinForms(1,12) ## indirect doctest
1279
sage: E.eisenstein_series()
1280
[
1281
691/65520 + q + 2049*q^2 + 177148*q^3 + 4196353*q^4 + 48828126*q^5 + O(q^6)
1282
]
1283
sage: E = EisensteinForms(11,2)
1284
sage: E.eisenstein_series()
1285
[
1286
5/12 + q + 3*q^2 + 4*q^3 + 7*q^4 + 6*q^5 + O(q^6)
1287
]
1288
sage: E = EisensteinForms(Gamma1(7),2)
1289
sage: E.set_precision(4)
1290
sage: E.eisenstein_series()
1291
[
1292
1/4 + q + 3*q^2 + 4*q^3 + O(q^4),
1293
1/7*zeta6 - 3/7 + q + (-2*zeta6 + 1)*q^2 + (3*zeta6 - 2)*q^3 + O(q^4),
1294
q + (-zeta6 + 2)*q^2 + (zeta6 + 2)*q^3 + O(q^4),
1295
-1/7*zeta6 - 2/7 + q + (2*zeta6 - 1)*q^2 + (-3*zeta6 + 1)*q^3 + O(q^4),
1296
q + (zeta6 + 1)*q^2 + (-zeta6 + 3)*q^3 + O(q^4)
1297
]
1298
"""
1299
N = parent.level()
1300
K = parent.base_ring()
1301
if chi.parent().modulus() != N or psi.parent().modulus() != N:
1302
raise ArithmeticError, "Incompatible moduli"
1303
if chi.parent().base_ring() != K or psi.parent().base_ring() != K:
1304
raise ArithmeticError, "Incompatible base rings"
1305
t = int(t)
1306
#if not isinstance(t, int): raise TypeError, "weight must be an int"
1307
if parent.weight() == 2 and chi.is_trivial() \
1308
and psi.is_trivial() and t==1:
1309
raise ArithmeticError, "If chi and psi are trivial and k=2, then t must be >1."
1310
ModularFormElement.__init__(self, parent, vector)
1311
self.__chi = chi
1312
self.__psi = psi
1313
self.__t = t
1314
1315
def _compute_q_expansion(self, prec=None):
1316
"""
1317
Compute the q-expansion of self to precision prec.
1318
1319
EXAMPLES::
1320
1321
sage: EisensteinForms(11,2).eisenstein_series()[0]._compute_q_expansion(10)
1322
5/12 + q + 3*q^2 + 4*q^3 + 7*q^4 + 6*q^5 + 12*q^6 + 8*q^7 + 15*q^8 + 13*q^9 + O(q^10)
1323
"""
1324
if prec is None:
1325
prec = self.parent().prec()
1326
F = self._compute(range(prec))
1327
R = self.parent()._q_expansion_ring()
1328
return R(F, prec)
1329
1330
def _compute(self, X):
1331
r"""
1332
Compute the coefficients of `q^n` of the power series of self,
1333
for `n` in the list `X`. The results are not cached. (Use
1334
coefficients for cached results).
1335
1336
EXAMPLES::
1337
1338
sage: e = DirichletGroup(11).gen()
1339
sage: f = EisensteinForms(e, 3).eisenstein_series()[0]
1340
sage: f._compute([3,4,5])
1341
[-9*zeta10^3 + 1,
1342
16*zeta10^2 + 4*zeta10 + 1,
1343
25*zeta10^3 - 25*zeta10^2 + 25*zeta10 - 24]
1344
1345
"""
1346
if self.weight() == 2 and (self.__chi.is_trivial() and self.__psi.is_trivial()):
1347
return self.__compute_weight2_trivial_character(X)
1348
else: # general case
1349
return self.__compute_general_case(X)
1350
1351
def __compute_weight2_trivial_character(self, X):
1352
r"""
1353
Compute coefficients for self an Eisenstein series of the form
1354
`E_2 - t*E_2(q^t)`. Computes `a_n` for each `n \in X`.
1355
1356
EXAMPLES::
1357
1358
sage: EisensteinForms(14,2).eisenstein_series()[0]._EisensteinSeries__compute_weight2_trivial_character([0])
1359
[1/24]
1360
sage: EisensteinForms(14,2).eisenstein_series()[0]._EisensteinSeries__compute_weight2_trivial_character([0,4,11,38])
1361
[1/24, 1, 12, 20]
1362
"""
1363
F = self.base_ring()
1364
v = []
1365
t = self.__t
1366
for n in X:
1367
if n < 0:
1368
pass
1369
elif n == 0:
1370
v.append(F(t-1)/F(24))
1371
else:
1372
an = rings.sigma(n,1)
1373
if n%t==0:
1374
an -= t*rings.sigma(n/t,1)
1375
v.append(an)
1376
return v
1377
1378
def __compute_general_case(self, X):
1379
"""
1380
Returns the list coefficients of `q^n` of the power series of self,
1381
for `n` in the list `X`. The results are not cached. (Use
1382
coefficients for cached results).
1383
1384
General case (except weight 2, trivial character, where this
1385
is wrong!) `\chi` is a primitive character of conductor `L`
1386
`\psi` is a primitive character of conductor `M` We have
1387
`MLt \mid N`, and
1388
1389
.. math::
1390
1391
E_k(chi,psi,t) =
1392
c_0 + sum_{m \geq 1}[sum_{n|m} psi(n) * chi(m/n) * n^(k-1)] q^{mt},
1393
1394
with `c_0=0` if `L>1`, and `c_0=L(1-k,psi)/2` if `L=1` (that
1395
second `L` is an `L`-function `L`).
1396
1397
EXAMPLES::
1398
1399
sage: e = DirichletGroup(11).gen()
1400
sage: f = EisensteinForms(e, 3).eisenstein_series()[0]
1401
sage: f._EisensteinSeries__compute_general_case([1])
1402
[1]
1403
sage: f._EisensteinSeries__compute_general_case([2])
1404
[4*zeta10 + 1]
1405
sage: f._EisensteinSeries__compute_general_case([0,1,2])
1406
[15/11*zeta10^3 - 9/11*zeta10^2 - 26/11*zeta10 - 10/11, 1, 4*zeta10 + 1]
1407
"""
1408
c0, chi, psi, K, n, t, L, M = self.__defining_parameters()
1409
zero = K(0)
1410
k = self.weight()
1411
v = []
1412
for i in X:
1413
if i==0:
1414
v.append(c0)
1415
continue
1416
if i%t != 0:
1417
v.append(zero)
1418
else:
1419
m = i//t
1420
v.append(sum([psi(n)*chi(m/n)*n**(k-1) for \
1421
n in rings.divisors(m)]))
1422
return v
1423
1424
def __defining_parameters(self):
1425
"""
1426
Return defining parameters for self.
1427
1428
EXAMPLES::
1429
1430
sage: EisensteinForms(11,2).eisenstein_series()[0]._EisensteinSeries__defining_parameters()
1431
(-1/24, Dirichlet character modulo 1 of conductor 1 mapping 0 |--> 1, Dirichlet character modulo 1 of conductor 1 mapping 0 |--> 1, Rational Field, 2, 11, 1, 1)
1432
"""
1433
try:
1434
return self.__defining_params
1435
except AttributeError:
1436
chi = self.__chi.primitive_character()
1437
psi = self.__psi.primitive_character()
1438
k = self.weight()
1439
t = self.__t
1440
L = chi.conductor()
1441
M = psi.conductor()
1442
K = chi.base_ring()
1443
n = K.zeta_order()
1444
if L == 1:
1445
c0 = K(-psi.bernoulli(k))/K(2*k)
1446
else:
1447
c0 = K(0)
1448
self.__defining_params = (c0, chi, psi, K, n, t, L, M)
1449
return self.__defining_params
1450
1451
def chi(self):
1452
"""
1453
Return the parameter chi associated to self.
1454
1455
EXAMPLES::
1456
1457
sage: EisensteinForms(DirichletGroup(17).0,99).eisenstein_series()[1].chi()
1458
Dirichlet character modulo 17 of conductor 17 mapping 3 |--> zeta16
1459
"""
1460
return self.__chi
1461
1462
def psi(self):
1463
"""
1464
Return the parameter psi associated to self.
1465
1466
EXAMPLES::
1467
1468
sage: EisensteinForms(DirichletGroup(17).0,99).eisenstein_series()[1].psi()
1469
Dirichlet character modulo 17 of conductor 1 mapping 3 |--> 1
1470
"""
1471
return self.__psi
1472
1473
def t(self):
1474
"""
1475
Return the parameter t associated to self.
1476
1477
EXAMPLES::
1478
1479
sage: EisensteinForms(DirichletGroup(17).0,99).eisenstein_series()[1].t()
1480
1
1481
"""
1482
return self.__t
1483
1484
def parameters(self):
1485
"""
1486
Return chi, psi, and t, which are the defining parameters of self.
1487
1488
EXAMPLES::
1489
1490
sage: EisensteinForms(DirichletGroup(17).0,99).eisenstein_series()[1].parameters()
1491
(Dirichlet character modulo 17 of conductor 17 mapping 3 |--> zeta16, Dirichlet character modulo 17 of conductor 1 mapping 3 |--> 1, 1)
1492
"""
1493
return self.__chi, self.__psi, self.__t
1494
1495
def L(self):
1496
"""
1497
Return the conductor of self.chi().
1498
1499
EXAMPLES::
1500
1501
sage: EisensteinForms(DirichletGroup(17).0,99).eisenstein_series()[1].L()
1502
17
1503
"""
1504
return self.__chi.conductor()
1505
1506
def M(self):
1507
"""
1508
Return the conductor of self.psi().
1509
1510
EXAMPLES::
1511
1512
sage: EisensteinForms(DirichletGroup(17).0,99).eisenstein_series()[1].M()
1513
1
1514
"""
1515
return self.__psi.conductor()
1516
1517
def character(self):
1518
"""
1519
Return the character associated to self.
1520
1521
EXAMPLES::
1522
1523
sage: EisensteinForms(DirichletGroup(17).0,99).eisenstein_series()[1].character()
1524
Dirichlet character modulo 17 of conductor 17 mapping 3 |--> zeta16
1525
1526
sage: chi = DirichletGroup(7)[4]
1527
sage: E = EisensteinForms(chi).eisenstein_series() ; E
1528
[
1529
-1/7*zeta6 - 2/7 + q + (2*zeta6 - 1)*q^2 + (-3*zeta6 + 1)*q^3 + (-2*zeta6 - 1)*q^4 + (5*zeta6 - 4)*q^5 + O(q^6),
1530
q + (zeta6 + 1)*q^2 + (-zeta6 + 3)*q^3 + (zeta6 + 2)*q^4 + (zeta6 + 4)*q^5 + O(q^6)
1531
]
1532
sage: E[0].character() == chi
1533
True
1534
sage: E[1].character() == chi
1535
True
1536
1537
TESTS::
1538
1539
sage: [ [ f.character() == chi for f in EisensteinForms(chi).eisenstein_series() ] for chi in DirichletGroup(17) ]
1540
[[True], [], [True, True], [], [True, True], [], [True, True], [], [True, True], [], [True, True], [], [True, True], [], [True, True], []]
1541
1542
sage: [ [ f.character() == chi for f in EisensteinForms(chi).eisenstein_series() ] for chi in DirichletGroup(16) ]
1543
[[True, True, True, True, True], [], [True, True], [], [True, True, True, True], [], [True, True], []]
1544
"""
1545
try:
1546
return self.__character
1547
except AttributeError:
1548
self.__character = self.__chi * self.__psi
1549
return self.__character
1550
1551
def new_level(self):
1552
"""
1553
Return level at which self is new.
1554
1555
EXAMPLES::
1556
1557
sage: EisensteinForms(DirichletGroup(17).0,99).eisenstein_series()[1].level()
1558
17
1559
sage: EisensteinForms(DirichletGroup(17).0,99).eisenstein_series()[1].new_level()
1560
17
1561
sage: [ [x.level(), x.new_level()] for x in EisensteinForms(DirichletGroup(60).0^2,2).eisenstein_series() ]
1562
[[60, 2], [60, 3], [60, 2], [60, 5], [60, 2], [60, 2], [60, 2], [60, 3], [60, 2], [60, 2], [60, 2]]
1563
"""
1564
if self.__chi.is_trivial() and self.__psi.is_trivial() and self.weight() == 2:
1565
return rings.factor(self.__t)[0][0]
1566
return self.L()*self.M()
1567
1568
1569
1570
1571