This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
element.py
2237 lines (1797 loc) · 80.7 KB
/
element.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""
Elements of modular forms spaces
"""
#*****************************************************************************
# Copyright (C) 2004-2008 William Stein <wstein@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
from __future__ import absolute_import
from six.moves import range
import sage.modular.hecke.element as element
from sage.rings.all import ZZ, QQ, Integer, RealField, ComplexField
from sage.rings.fast_arith import prime_range
from sage.rings.morphism import RingHomomorphism
from sage.rings.number_field.number_field_morphisms import NumberFieldEmbedding
from sage.modular.modsym.space import is_ModularSymbolsSpace
from sage.modular.modsym.modsym import ModularSymbols
from sage.modules.free_module_element import vector
from sage.misc.misc import verbose
from sage.arith.srange import xsrange
from sage.modular.dirichlet import DirichletGroup
from sage.misc.superseded import deprecated_function_alias
from sage.arith.all import lcm, divisors, moebius, sigma, factor
from sage.structure.element import coercion_model, ModuleElement
def is_ModularFormElement(x):
"""
Return True if x is a modular form.
EXAMPLES::
sage: from sage.modular.modform.element import is_ModularFormElement
sage: is_ModularFormElement(5)
False
sage: is_ModularFormElement(ModularForms(11).0)
True
"""
return isinstance(x, ModularFormElement)
def delta_lseries(prec=53,
max_imaginary_part=0,
max_asymp_coeffs=40):
r"""
Return the L-series of the modular form Delta.
This actually returns an interface to Tim Dokchitser's program
for computing with the L-series of the modular form `\Delta`.
INPUT:
- ``prec`` - integer (bits precision)
- ``max_imaginary_part`` - real number
- ``max_asymp_coeffs`` - integer
OUTPUT:
The L-series of `\Delta`.
EXAMPLES::
sage: L = delta_lseries()
sage: L(1)
0.0374412812685155
"""
from sage.lfunctions.all import Dokchitser
# key = (prec, max_imaginary_part, max_asymp_coeffs)
L = Dokchitser(conductor = 1,
gammaV = [0, 1],
weight = 12,
eps = 1,
prec = prec)
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));'
L.init_coeffs('tau(k)',pari_precode = s,
max_imaginary_part=max_imaginary_part,
max_asymp_coeffs=max_asymp_coeffs)
L.set_coeff_growth('2*n^(11/2)')
L.rename('L-series associated to the modular form Delta')
return L
class ModularForm_abstract(ModuleElement):
"""
Constructor for generic class of a modular form. This
should never be called directly; instead one should
instantiate one of the derived classes of this
class.
"""
def group(self):
"""
Return the group for which self is a modular form.
EXAMPLES::
sage: ModularForms(Gamma1(11), 2).gen(0).group()
Congruence Subgroup Gamma1(11)
"""
return self.parent().group()
def weight(self):
"""
Return the weight of self.
EXAMPLES::
sage: (ModularForms(Gamma1(9),2).6).weight()
2
"""
return self.parent().weight()
def level(self):
"""
Return the level of self.
EXAMPLES::
sage: ModularForms(25,4).0.level()
25
"""
return self.parent().level()
def _repr_(self):
"""
Return the string representation of self.
EXAMPLES::
sage: ModularForms(25,4).0._repr_()
'q + O(q^6)'
sage: ModularForms(25,4).3._repr_()
'q^4 + O(q^6)'
"""
return str(self.q_expansion())
def __call__(self, x, prec=None):
"""
Evaluate the q-expansion of this modular form at x.
EXAMPLES::
sage: f = ModularForms(DirichletGroup(17).0^2,2).2
sage: q = f.q_expansion().parent().gen()
sage: f(q^2 + O(q^7))
q^2 + (-zeta8^2 + 2)*q^4 + (zeta8 + 3)*q^6 + O(q^7)
sage: f(0)
0
"""
return self.q_expansion(prec)(x)
def valuation(self):
"""
Return the valuation of self (i.e. as an element of the power
series ring in q).
EXAMPLES::
sage: ModularForms(11,2).0.valuation()
1
sage: ModularForms(11,2).1.valuation()
0
sage: ModularForms(25,6).1.valuation()
2
sage: ModularForms(25,6).6.valuation()
7
"""
try:
return self.__valuation
except AttributeError:
v = self.qexp().valuation()
if v != self.qexp().prec():
self.__valuation = v
return v
v = self.qexp(self.parent().sturm_bound()).valuation()
self.__valuation = v
return v
def qexp(self, prec=None):
"""
Same as ``self.q_expansion(prec)``.
.. SEEALSO:: :meth:`q_expansion`
EXAMPLES::
sage: CuspForms(1,12).0.qexp()
q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6)
"""
return self.q_expansion(prec)
def __eq__(self, other):
"""
Compare self to other.
EXAMPLES::
sage: f = ModularForms(6,4).0
sage: g = ModularForms(23,2).0
sage: f == g ## indirect doctest
False
sage: f == f
True
sage: f == loads(dumps(f))
True
"""
if not isinstance(other, ModularFormElement) or \
self.ambient_module() != other.ambient_module():
return False
else:
return self.element() == other.element()
def __ne__(self, other):
"""
Return True if ``self != other``.
EXAMPLES::
sage: f = Newforms(Gamma1(30), 2, names='a')[1]
sage: g = ModularForms(23, 2).0
sage: f != g
True
sage: f != f
False
TESTS:
The following used to fail (see :trac:`18068`)::
sage: f != loads(dumps(f))
False
"""
return not (self == other)
def _compute(self, X):
"""
Compute the coefficients of `q^n` of the power series of self,
for `n` in the list `X`. The results are not cached. (Use
coefficients for cached results).
EXAMPLES::
sage: f = ModularForms(18,2).1
sage: f.q_expansion(20)
q + 8*q^7 + 4*q^10 + 14*q^13 - 4*q^16 + 20*q^19 + O(q^20)
sage: f._compute([10,17])
[4, 0]
sage: f._compute([])
[]
"""
if not isinstance(X, list) or len(X) == 0:
return []
bound = max(X)
q_exp = self.q_expansion(bound+1)
return [q_exp[i] for i in X]
def coefficients(self, X):
"""
The coefficients a_n of self, for integers n>=0 in the list
X. If X is an Integer, return coefficients for indices from 1
to X.
This function caches the results of the compute function.
TESTS::
sage: e = DirichletGroup(11).gen()
sage: f = EisensteinForms(e, 3).eisenstein_series()[0]
sage: f.coefficients([0,1])
[15/11*zeta10^3 - 9/11*zeta10^2 - 26/11*zeta10 - 10/11,
1]
sage: f.coefficients([0,1,2,3])
[15/11*zeta10^3 - 9/11*zeta10^2 - 26/11*zeta10 - 10/11,
1,
4*zeta10 + 1,
-9*zeta10^3 + 1]
sage: f.coefficients([2,3])
[4*zeta10 + 1,
-9*zeta10^3 + 1]
Running this twice once revealed a bug, so we test it::
sage: f.coefficients([0,1,2,3])
[15/11*zeta10^3 - 9/11*zeta10^2 - 26/11*zeta10 - 10/11,
1,
4*zeta10 + 1,
-9*zeta10^3 + 1]
"""
try:
self.__coefficients
except AttributeError:
self.__coefficients = {}
if isinstance(X, Integer):
X = list(range(1, X + 1))
Y = [n for n in X if not (n in self.__coefficients.keys())]
v = self._compute(Y)
for i in range(len(v)):
self.__coefficients[Y[i]] = v[i]
return [ self.__coefficients[x] for x in X ]
def __getitem__(self, n):
"""
Returns the `q^n` coefficient of the `q`-expansion of self or
returns a list containing the `q^i` coefficients of self
where `i` is in slice `n`.
EXAMPLES::
sage: f = ModularForms(DirichletGroup(17).0^2,2).2
sage: f.__getitem__(10)
zeta8^3 - 5*zeta8^2 - 2*zeta8 + 10
sage: f[30]
-2*zeta8^3 - 17*zeta8^2 + 4*zeta8 + 29
sage: f[10:15]
[zeta8^3 - 5*zeta8^2 - 2*zeta8 + 10,
-zeta8^3 + 11,
-2*zeta8^3 - 6*zeta8^2 + 3*zeta8 + 9,
12,
2*zeta8^3 - 7*zeta8^2 + zeta8 + 14]
"""
if isinstance(n, slice):
if n.stop is None:
return self.q_expansion().list()[n]
else:
return self.q_expansion(n.stop+1).list()[n]
else:
return self.q_expansion(n+1)[int(n)]
def padded_list(self, n):
"""
Return a list of length n whose entries are the first n
coefficients of the q-expansion of self.
EXAMPLES::
sage: CuspForms(1,12).0.padded_list(20)
[0, 1, -24, 252, -1472, 4830, -6048, -16744, 84480, -113643, -115920, 534612, -370944, -577738, 401856, 1217160, 987136, -6905934, 2727432, 10661420]
"""
return self.q_expansion(n).padded_list(n)
def _latex_(self):
"""
Return the LaTeX expression of self.
EXAMPLES:
sage: ModularForms(25,4).0._latex_()
'q + O(q^{6})'
sage: ModularForms(25,4).4._latex_()
'q^{5} + O(q^{6})'
"""
return self.q_expansion()._latex_()
def base_ring(self):
"""
Return the base_ring of self.
EXAMPLES::
sage: (ModularForms(117, 2).13).base_ring()
Rational Field
sage: (ModularForms(119, 2, base_ring=GF(7)).12).base_ring()
Finite Field of size 7
"""
return self.parent().base_ring()
def character(self, compute=True):
"""
Return the character of self. If ``compute=False``, then this will
return None unless the form was explicitly created as an element of a
space of forms with character, skipping the (potentially expensive)
computation of the matrices of the diamond operators.
EXAMPLES::
sage: ModularForms(DirichletGroup(17).0^2,2).2.character()
Dirichlet character modulo 17 of conductor 17 mapping 3 |--> zeta8
sage: CuspForms(Gamma1(7), 3).gen(0).character()
Dirichlet character modulo 7 of conductor 7 mapping 3 |--> -1
sage: CuspForms(Gamma1(7), 3).gen(0).character(compute = False) is None
True
sage: M = CuspForms(Gamma1(7), 5).gen(0).character()
Traceback (most recent call last):
...
ValueError: Form is not an eigenvector for <3>
"""
chi = self.parent().character()
if (chi is not None) or (not compute):
return chi
else: # do the expensive computation
G = DirichletGroup(self.parent().level(), base_ring = self.parent().base_ring())
gens = G.unit_gens()
i = self.valuation()
vals = []
for g in gens:
df = self.parent().diamond_bracket_operator(g)(self)
if df != (df[i] / self[i]) * self:
raise ValueError("Form is not an eigenvector for <%s>" % g)
vals.append(df[i] / self[i])
return G(vals)
def __bool__(self):
"""
Return ``True`` if ``self`` is nonzero, and ``False`` if not.
EXAMPLES::
sage: bool(ModularForms(25,6).6)
True
"""
return not self.element().is_zero()
__nonzero__ = __bool__
def prec(self):
"""
Return the precision to which self.q_expansion() is
currently known. Note that this may be 0.
EXAMPLES::
sage: M = ModularForms(2,14)
sage: f = M.0
sage: f.prec()
0
sage: M.prec(20)
20
sage: f.prec()
0
sage: x = f.q_expansion() ; f.prec()
20
"""
try:
return self.__q_expansion[0]
except AttributeError:
return 0
def q_expansion(self, prec=None):
r"""
The `q`-expansion of the modular form to precision `O(q^\text{prec})`.
This function takes one argument, which is the integer prec.
EXAMPLES:
We compute the cusp form `\Delta`::
sage: delta = CuspForms(1,12).0
sage: delta.q_expansion()
q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6)
We compute the `q`-expansion of one of the cusp forms of level 23::
sage: f = CuspForms(23,2).0
sage: f.q_expansion()
q - q^3 - q^4 + O(q^6)
sage: f.q_expansion(10)
q - q^3 - q^4 - 2*q^6 + 2*q^7 - q^8 + 2*q^9 + O(q^10)
sage: f.q_expansion(2)
q + O(q^2)
sage: f.q_expansion(1)
O(q^1)
sage: f.q_expansion(0)
O(q^0)
sage: f.q_expansion(-1)
Traceback (most recent call last):
...
ValueError: prec (= -1) must be non-negative
"""
if prec is None:
prec = self.parent().prec()
prec = Integer(prec)
try:
current_prec, f = self.__q_expansion
except AttributeError:
current_prec = 0
f = self.parent()._q_expansion_ring()(0, 0)
if current_prec == prec:
return f
elif current_prec > prec:
return f.add_bigoh(prec)
else:
f = self._compute_q_expansion(prec)
self.__q_expansion = (prec, f)
return f
def atkin_lehner_eigenvalue(self, d=None):
r"""
Return the eigenvalue of the Atkin-Lehner operator W_d acting on self
(which is either 1 or -1), or None if this form is not an eigenvector
for this operator. If d is not given or is None, use d = the level.
EXAMPLES::
sage: sage.modular.modform.element.ModularForm_abstract.atkin_lehner_eigenvalue(CuspForms(2, 8).0)
Traceback (most recent call last):
...
NotImplementedError
"""
raise NotImplementedError
# The methods period() and lseries() below currently live
# in ModularForm_abstract so they are inherited by Newform (which
# does *not* derive from ModularFormElement).
def period(self, M, prec=53):
r"""
Return the period of ``self`` with respect to `M`.
INPUT:
- ``self`` -- a cusp form `f` of weight 2 for `Gamma_0(N)`
- ``M`` -- an element of `\Gamma_0(N)`
- ``prec`` -- (default: 53) the working precision in bits. If
`f` is a normalised eigenform, then the output is correct to
approximately this number of bits.
OUTPUT:
A numerical approximation of the period `P_f(M)`. This period
is defined by the following integral over the complex upper
half-plane, for any `\alpha` in `\Bold{P}^1(\QQ)`:
.. MATH::
P_f(M) = 2 \pi i \int_\alpha^{M(\alpha)} f(z) dz.
This is independent of the choice of `\alpha`.
EXAMPLES::
sage: C = Newforms(11, 2)[0]
sage: m = C.group()(matrix([[-4, -3], [11, 8]]))
sage: C.period(m)
-0.634604652139776 - 1.45881661693850*I
sage: f = Newforms(15, 2)[0]
sage: g = Gamma0(15)(matrix([[-4, -3], [15, 11]]))
sage: f.period(g) # abs tol 1e-15
2.17298044293747e-16 - 1.59624222213178*I
If `E` is an elliptic curve over `\QQ` and `f` is the newform
associated to `E`, then the periods of `f` are in the period
lattice of `E` up to an integer multiple::
sage: E = EllipticCurve('11a3')
sage: f = E.newform()
sage: g = Gamma0(11)([3, 1, 11, 4])
sage: f.period(g)
0.634604652139777 + 1.45881661693850*I
sage: omega1, omega2 = E.period_lattice().basis()
sage: -2/5*omega1 + omega2
0.634604652139777 + 1.45881661693850*I
The integer multiple is 5 in this case, which is explained by
the fact that there is a 5-isogeny between the elliptic curves
`J_0(5)` and `E`.
The elliptic curve `E` has a pair of modular symbols attached
to it, which can be computed using the method
:meth:`sage.schemes.elliptic_curves.ell_rational_field.EllipticCurve_rational_field.modular_symbol`.
These can be used to express the periods of `f` as exact
linear combinations of the real and the imaginary period of `E`::
sage: s = E.modular_symbol(sign=+1)
sage: t = E.modular_symbol(sign=-1, implementation="sage")
sage: s(3/11), t(3/11)
(1/10, 1/2)
sage: s(3/11)*omega1 + t(3/11)*2*omega2.imag()*I
0.634604652139777 + 1.45881661693850*I
ALGORITHM:
We use the series expression from [Cre1997]_, Chapter II,
Proposition 2.10.3. The algorithm sums the first `T` terms of
this series, where `T` is chosen in such a way that the result
would approximate `P_f(M)` with an absolute error of at most
`2^{-\text{prec}}` if all computations were done exactly.
Since the actual precision is finite, the output is currently
*not* guaranteed to be correct to ``prec`` bits of precision.
TESTS::
sage: C = Newforms(11, 2)[0]
sage: g = Gamma0(15)(matrix([[-4, -3], [15, 11]]))
sage: C.period(g)
Traceback (most recent call last):
...
TypeError: matrix [-4 -3]
[15 11]
is not an element of Congruence Subgroup Gamma0(11)
sage: f = Newforms(Gamma0(15), 4)[0]
sage: f.period(g)
Traceback (most recent call last):
...
ValueError: period pairing only defined for cusp forms of weight 2
sage: S = Newforms(Gamma1(17), 2, names='a')
sage: f = S[1]
sage: g = Gamma1(17)([18, 1, 17, 1])
sage: f.period(g)
Traceback (most recent call last):
...
NotImplementedError: period pairing only implemented for cusp forms of trivial character
sage: E = ModularForms(Gamma0(4), 2).eisenstein_series()[0]
sage: gamma = Gamma0(4)([1, 0, 4, 1])
sage: E.period(gamma)
Traceback (most recent call last):
...
NotImplementedError: Don't know how to compute Atkin-Lehner matrix acting on this space (try using a newform constructor instead)
sage: E = EllipticCurve('19a1')
sage: M = Gamma0(19)([10, 1, 19, 2])
sage: E.newform().period(M) # abs tol 1e-14
-1.35975973348831 + 1.09365931898146e-16*I
"""
R = RealField(prec)
N = self.level()
if not self.character().is_trivial():
raise NotImplementedError('period pairing only implemented for cusp forms of trivial character')
if self.weight() != 2:
raise ValueError('period pairing only defined for cusp forms of weight 2')
if not isinstance(self, (Newform, ModularFormElement_elliptic_curve)):
print('Warning: not a newform, precision not guaranteed')
M = self.group()(M)
# coefficients of the matrix M
(b, c, d) = (M.b(), M.c() / N, M.d())
if d == 0:
return R.zero()
if d < 0:
(b, c, d) = (-b, -c, -d)
twopi = 2 * R.pi()
I = R.complex_field().gen()
rootN = R(N).sqrt()
eps = self.atkin_lehner_eigenvalue()
mu_N = (-twopi / rootN).exp()
mu_dN = (-twopi / d / rootN).exp()
mu_d = (twopi * I / d).exp()
# We bound the tail of the series by means of the triangle
# inequality and the following bounds (tau(n) = #divisors(n)):
# mu_N <= mu_dN
# |a_n(f)| <= tau(n)*sqrt(n) (holds if f is a newform)
# tau(n) <= sqrt(3)*sqrt(n) for all n >= 1
# This gives a correct but somewhat coarse lower bound on the
# number of terms needed. We ignore rounding errors.
numterms = (((1 - mu_dN) * R(2)**(-prec)
/ ((abs(eps - 1) + 2) * R(3).sqrt())).log()
/ mu_dN.log()).ceil()
coeff = self.coefficients(numterms)
return sum((coeff[n - 1] / n)
*((eps - 1) * mu_N ** n
+ mu_dN ** n * (mu_d ** (n * b) - eps * mu_d ** (n * c)))
for n in range(1, numterms + 1))
def lseries(self, embedding=0, prec=53,
max_imaginary_part=0,
max_asymp_coeffs=40,
conjugate=None):
r"""
Return the L-series of the weight k cusp form
`f` on `\Gamma_0(N)`.
This actually returns an interface to Tim Dokchitser's program for
computing with the L-series of the cusp form.
INPUT:
- ``embedding`` - either an embedding of the coefficient field of self
into `\CC`, or an integer `i` between 0 and D-1 where D is the degree
of the coefficient field (meaning to pick the `i`-th embedding).
(Default: 0)
- ``prec`` - integer (bits precision). Default: 53.
- ``max_imaginary_part`` - real number. Default: 0.
- ``max_asymp_coeffs`` - integer. Default: 40.
- ``conjugate`` -- deprecated synonym for ``embedding``.
For more information on the significance of the last three arguments,
see :mod:`~sage.lfunctions.dokchitser`.
.. note::
If an explicit embedding is given, but this embedding is specified
to smaller precision than ``prec``, it will be automatically
refined to precision ``prec``.
OUTPUT:
The L-series of the cusp form, as a
:class:`sage.lfunctions.dokchitser.Dokchitser` object.
EXAMPLES::
sage: f = CuspForms(2,8).newforms()[0]
sage: L = f.lseries()
sage: L
L-series associated to the cusp form q - 8*q^2 + 12*q^3 + 64*q^4 - 210*q^5 + O(q^6)
sage: L(1)
0.0884317737041015
sage: L(0.5)
0.0296568512531983
As a consistency check, we verify that the functional equation holds::
sage: abs(L.check_functional_equation()) < 1.0e-20
True
For non-rational newforms we can specify an embedding of the coefficient field::
sage: f = Newforms(43, names='a')[1]
sage: K = f.hecke_eigenvalue_field()
sage: phi1, phi2 = K.embeddings(CC)
sage: L = f.lseries(embedding=phi1)
sage: L
L-series associated to the cusp form q + a1*q^2 - a1*q^3 + (-a1 + 2)*q^5 + O(q^6), a1=-1.41421356237310
sage: L(1)
0.620539857407845
sage: L = f.lseries(embedding=1)
sage: L(1)
0.921328017272472
For backward-compatibility, ``conjugate`` is accepted as a synonym for ``embedding``::
sage: f.lseries(conjugate=1)
doctest:...: DeprecationWarning: The argument 'conjugate' for 'lseries' is deprecated -- use the synonym 'embedding'
See http://trac.sagemath.org/19668 for details.
L-series associated to the cusp form q + a1*q^2 - a1*q^3 + (-a1 + 2)*q^5 + O(q^6), a1=1.41421356237310
We compute with the L-series of the Eisenstein series `E_4`::
sage: f = ModularForms(1,4).0
sage: L = f.lseries()
sage: L(1)
-0.0304484570583933
sage: L = eisenstein_series_lseries(4)
sage: L(1)
-0.0304484570583933
Consistency check with delta_lseries (which computes coefficients in pari)::
sage: delta = CuspForms(1,12).0
sage: L = delta.lseries()
sage: L(1)
0.0374412812685155
sage: L = delta_lseries()
sage: L(1)
0.0374412812685155
We check that :trac:`5262` is fixed::
sage: E = EllipticCurve('37b2')
sage: h = Newforms(37)[1]
sage: Lh = h.lseries()
sage: LE = E.lseries()
sage: Lh(1), LE(1)
(0.725681061936153, 0.725681061936153)
sage: CuspForms(1, 30).0.lseries().eps
-1
We can change the precision (in bits)::
sage: f = Newforms(389, names='a')[0]
sage: L = f.lseries(prec=30)
sage: abs(L(1)) < 2^-30
True
sage: L = f.lseries(prec=53)
sage: abs(L(1)) < 2^-53
True
sage: L = f.lseries(prec=100)
sage: abs(L(1)) < 2^-100
True
sage: f = Newforms(27, names='a')[0]
sage: L = f.lseries()
sage: L(1)
0.588879583428483
"""
if conjugate is not None:
from sage.misc.superseded import deprecation
deprecation(19668, "The argument 'conjugate' for 'lseries' is deprecated -- use the synonym 'embedding'")
embedding=conjugate
from sage.lfunctions.all import Dokchitser
# key = (prec, max_imaginary_part, max_asymp_coeffs)
l = self.weight()
N = self.level()
w = self.atkin_lehner_eigenvalue()
if w is None:
raise ValueError("Form is not an eigenform for Atkin-Lehner")
e = (-1) ** (l // 2) * w
if self.q_expansion()[0] == 0:
poles = [] # cuspidal
else:
poles = [l] # non-cuspidal
L = Dokchitser(conductor = N,
gammaV = [0, 1],
weight = l,
eps = e,
poles = poles,
prec = prec)
# Find out how many coefficients of the Dirichlet series are needed
# in order to compute to the required precision
num_coeffs = L.num_coeffs()
coeffs = self.q_expansion(num_coeffs+1).padded_list()
# renormalize so that coefficient of q is 1
b = coeffs[1]
if b != 1:
invb = 1/b
coeffs = (invb*c for c in coeffs)
# compute the requested embedding
K = self.base_ring()
if isinstance(embedding, RingHomomorphism):
# Target of embedding might have precision less than desired, so
# need to refine
emb = NumberFieldEmbedding(K, ComplexField(prec), embedding(K.gen()))
else:
emb = self.base_ring().embeddings(ComplexField(prec))[embedding]
s = 'coeff = %s;' % [emb(_) for _ in coeffs]
L.init_coeffs('coeff[k+1]',pari_precode = s,
max_imaginary_part=max_imaginary_part,
max_asymp_coeffs=max_asymp_coeffs)
L.check_functional_equation()
if K == QQ:
L.rename('L-series associated to the cusp form %s'%self)
else:
L.rename('L-series associated to the cusp form %s, %s=%s' \
% (self, K.variable_name(), emb(K.gen())))
return L
cuspform_lseries = deprecated_function_alias(16917, lseries)
def symsquare_lseries(self, chi=None, embedding=0, prec=53):
"""
Compute the symmetric square L-series of this modular form, twisted by
the character `\chi`.
INPUT:
- ``chi`` -- Dirichlet character to twist by, or None (default None,
interpreted as the trivial character).
- ``embedding`` -- embedding of the coefficient field into `\RR` or
`\CC`, or an integer `i` (in which case take the `i`-th embedding)
- ``prec`` -- The desired precision in bits (default 53).
OUTPUT: The symmetric square L-series of the cusp form, as a
:class:`sage.lfunctions.dokchitser.Dokchitser` object.
EXAMPLES::
sage: CuspForms(1, 12).0.symsquare_lseries()(22)
0.999645711124771
An example twisted by a nontrivial character::
sage: psi = DirichletGroup(7).0^2
sage: L = CuspForms(1, 16).0.symsquare_lseries(psi)
sage: L(22)
0.998407750967420 - 0.00295712911510708*I
An example with coefficients not in `\QQ`::
sage: F = Newforms(1, 24, names='a')[0]
sage: K = F.hecke_eigenvalue_field()
sage: phi = K.embeddings(RR)[0]
sage: L = F.symsquare_lseries(embedding=phi)
sage: L(5)
verbose -1 (...: dokchitser.py, __call__) Warning: Loss of 8 decimal digits due to cancellation
-3.57698266793901e19
TESTS::
sage: CuspForms(1,16).0.symsquare_lseries(prec=200).check_functional_equation().abs() < 1.0e-80
True
sage: CuspForms(1, 12).0.symsquare_lseries(prec=1000)(22) # long time (20s)
0.999645711124771397835729622033153189549796658647254961493709341358991830134499267117001769570658192128781135161587571716303826382489492569725002840546129937149159065273765309218543427544527498868033604310899372849565046516553245752253255585377793879866297612679545029546953895098375829822346290125161
Check that :trac:`23247` is fixed::
sage: F = Newforms(1,12)[0]
sage: chi = DirichletGroup(7).0
sage: abs(F.symsquare_lseries(chi).check_functional_equation()) < 1e-5
True
AUTHORS:
- Martin Raum (2011) -- original code posted to sage-nt
- David Loeffler (2015) -- added support for twists, integrated into
Sage library
"""
from sage.lfunctions.all import Dokchitser
weight = self.weight()
C = ComplexField(prec)
if self.level() != 1:
raise NotImplementedError("Symmetric square L-functions only implemented for level 1")
# compute the requested embedding
if isinstance(embedding, RingHomomorphism):
# Target of embedding might have precision less than desired, so
# need to refine
K = self.base_ring()
emb = NumberFieldEmbedding(K, ComplexField(prec), embedding(K.gen()))
else:
emb = self.base_ring().embeddings(ComplexField(prec))[embedding]
if chi is None:
eps = 1
N = 1
else:
assert chi.is_primitive()
chi = chi.change_ring(C)
eps = chi.gauss_sum()**3 / chi.base_ring()(chi.conductor())**QQ( (3, 2) )
N = chi.conductor()**3
if (chi is None) or chi.is_even():
L = Dokchitser(N, [0, 1, -weight + 2], 2 * weight - 1,
eps, prec=prec)
else:
L = Dokchitser(N, [0, 1, -weight + 1], 2 * weight - 1,
eps * C((0, 1)), prec=prec)
lcoeffs_prec = L.num_coeffs()
t = verbose("Computing %s coefficients of F" % lcoeffs_prec, level=1)
F_series = [u**2 for u in self.qexp(lcoeffs_prec + 1).list()[1:]]
verbose("done", t, level=1)
# utility function for Dirichlet convolution of series
def dirichlet_convolution(A, B):
return [sum(A[d-1] * B[n/d - 1] for d in divisors(n))
for n in range(1, 1 + min(len(A), len(B)))]
# The Dirichlet series for \zeta(2 s - 2 k + 2)
riemann_series = [ n**(weight - 1) if n.is_square() else 0
for n in xsrange(1, lcoeffs_prec + 1) ]
# The Dirichlet series for 1 / \zeta(s - k + 1)
mu_series = [ moebius(n) * n**(weight - 1) for n in xsrange(1, lcoeffs_prec + 1) ]
conv_series = dirichlet_convolution(mu_series, riemann_series)
dirichlet_series = dirichlet_convolution(conv_series, F_series)
# If the base ring is QQ we pass the coefficients to GP/PARI as exact
# rationals. Otherwise, need to use the embedding.
if self.base_ring() != QQ:
dirichlet_series = map(emb, dirichlet_series)
if chi is not None:
pari_precode_chi = str(chi.values()) + "[n%" + str(chi.conductor()) + "+1]; "
else:
pari_precode_chi = "1"
pari_precode = "hhh(n) = " + str(dirichlet_series) + "[n] * " + pari_precode_chi
L.init_coeffs( "hhh(k)", w="conj(hhh(k))",
pari_precode=pari_precode)
return L
def petersson_norm(self, embedding=0, prec=53):
r"""
Compute the Petersson scalar product of f with itself:
.. MATH::
\langle f, f \rangle = \int_{\Gamma_0(N) \backslash \mathbb{H}} |f(x + iy)|^2 y^k\, \mathrm{d}x\, \mathrm{d}y.
Only implemented for N = 1 at present. It is assumed that `f` has real
coefficients. The norm is computed as a special value of the symmetric
square L-function, using the identity