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