-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraded_ring_element.py
1561 lines (1261 loc) · 59.5 KB
/
graded_ring_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
r"""
Graded rings of modular forms for Hecke triangle groups
AUTHORS:
- Jonas Jermann (2013): initial version
"""
#*****************************************************************************
# Copyright (C) 2013-2014 Jonas Jermann <[email protected]>
#
# Distributed under the terms of the GNU General Public License (GPL)
# 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 sage.rings.all import ZZ, infinity, LaurentSeries, O
from sage.functions.all import exp
from sage.symbolic.all import pi, i
from sage.structure.parent_gens import localvars
from sage.structure.element import CommutativeAlgebraElement
from sage.structure.unique_representation import UniqueRepresentation
from sage.misc.cachefunc import cached_method
from constructor import rational_type, FormsSpace, FormsRing
from series_constructor import MFSeriesConstructor
# Warning: We choose CommutativeAlgebraElement because we want the
# corresponding operations (e.g. __mul__) even though the category
# (and class) of the parent is in some cases not
# CommutativeAlgebras but Modules
class FormsRingElement(CommutativeAlgebraElement, UniqueRepresentation):
r"""
Element of a FormsRing.
"""
from analytic_type import AnalyticType
AT = AnalyticType()
@staticmethod
def __classcall__(cls, parent, rat):
r"""
Return a (cached) instance with canonical parameters.
EXAMPLES::
sage: from graded_ring import ModularFormsRing
sage: (x,d) = var("x","d")
sage: el = FormsRingElement(ModularFormsRing(), x*d)
sage: el.rat()
x*d
sage: el.rat().parent()
Fraction Field of Multivariate Polynomial Ring in x, y, z, d over Integer Ring
"""
rat = parent.rat_field()(rat)
# rat.reduce() <- maybe add this for the nonexact case
return super(FormsRingElement,cls).__classcall__(cls, parent, rat)
def __init__(self, parent, rat):
r"""
Element of a FormsRing ``parent`` corresponding to the rational
function ``rat`` evaluated at ``x=F_rho``, ``y=F_i``, ``z=E2``
and ``d`` by the formal parameter from ``parent.coeff_ring()``.
The functions ``F_rho, F_i, E2`` can be obtained from
``self.parent().graded_ring()``.
INPUT:
- ``parent`` - An (non abstract) instance of ``FormsRing_abstract``.
- ``rat`` - A rational function in ``parent.rat_field()``, the
fraction field of the polynomial ring in ``x,y,z,d``
over the base ring of ``parent``.
OUTPUT:
An element of ``parent``. If ``rat`` does not correspond to such
an element an exception is raised.
EXAMPLES::
sage: from graded_ring import QModularFormsRing
sage: (x,y,z,d)=var("x,y,z,d")
sage: MR = QModularFormsRing(group=5)
sage: el = MR(x^3*d + y*z)
sage: el
f_rho^3*d + f_i*E2
sage: el.rat()
x^3*d + y*z
sage: el.parent()
QuasiModularFormsRing(n=5) over Integer Ring
sage: el.rat().parent()
Fraction Field of Multivariate Polynomial Ring in x, y, z, d over Integer Ring
"""
self._rat = rat
(elem, homo, self._weight, self._ep, self._analytic_type) = rational_type(rat, parent.hecke_n(), parent.base_ring())
if not (
elem and\
self._analytic_type <= parent.analytic_type() ):
raise Exception("{} does not correspond to an element of the {}.".format(rat, parent))
super(FormsRingElement, self).__init__(parent)
# Unfortunately the polynomial ring does not give unique
# representations of elements (with respect to ==)
def __eq__(self, other):
r"""
Return whether ``self`` is equal to ``other``.
They are considered equal if the corresponding rational
functions are equal and the groups match up.
EXAMPLES::
sage: from graded_ring import MModularFormsRing
sage: (x,y,z,d) = MModularFormsRing().pol_ring().gens()
sage: MModularFormsRing(group=3)(x) == MModularFormsRing(group=4)(x)
False
sage: MModularFormsRing()(-1/x) is MModularFormsRing()(1/(-x))
False
sage: MModularFormsRing()(-1/x) == MModularFormsRing()(1/(-x))
True
sage: MModularFormsRing(base_ring=CC)(-1/x) == MModularFormsRing()(1/(-x))
True
"""
if (super(FormsRingElement, self).__eq__(other)):
return True
elif (isinstance(other, FormsRingElement)):
return (self.group() == other.group() and self.rat() == other.rat())
else:
return False
def _repr_(self):
r"""
Return the string representation of ``self``.
EXAMPLES::
sage: from graded_ring import QModularFormsRing
sage: (x,y,z,d)=var("x,y,z,d")
sage: QModularFormsRing(group=5)(x^3*z-d*y)
f_rho^3*E2 - f_i*d
"""
return self._rat_repr()
def _rat_repr(self):
r"""
Return a string representation of ``self`` as a rational function in the generators.
EXAMPLES::
sage: from space import QModularForms
sage: (x,y,z,d)=var("x,y,z,d")
sage: QModularForms(group=5, k=6, ep=-1)(x^3*z)._rat_repr()
'f_rho^3*E2'
"""
#return "{} in {}".format(str(self._rat), self.parent())
with localvars(self.parent()._pol_ring, "f_rho, f_i, E2, d"):
pol_str = str(self._rat)
return "{}".format(pol_str)
def _qexp_repr(self):
r"""
Return a string representation of ``self`` as a Fourier series.
EXAMPLES::
sage: from graded_ring import QModularFormsRing
sage: (x,y,z,d)=var("x,y,z,d")
sage: MR = QModularFormsRing(group=5)
sage: MR.disp_prec(3)
sage: MR(x^3*z-d*y)._qexp_repr()
'-d + 1 + ((65*d + 33)/(200*d))*q + ((1755*d + 1437)/(320000*d^2))*q^2 + O(q^3)'
"""
n=self.hecke_n()
# For now the series constructor doesn't behave well for non exact bases... :(
if (self.group().is_arithmetic() or not self.base_ring().is_exact()):
return str(self.q_expansion_fixed_d().add_bigoh(self.parent()._disp_prec))
else:
return str(self.q_expansion().add_bigoh(self.parent()._disp_prec))
def _latex_(self):
r"""
Return the LaTeX representation of ``self``.
EXAMPLES::
sage: from graded_ring import QModularFormsRing
sage: (x,y,z,d)=var("x,y,z,d")
sage: latex(QModularFormsRing(group=5)(x^3*z-d*y))
f_{\rho}^{3} E_{2} - f_{i} d
sage: from space import CuspForms
sage: latex(CuspForms(k=12)(x^3-y^2))
f_{\rho}^{3} - f_{i}^{2}
"""
from sage.misc.latex import latex
with localvars(self.parent()._pol_ring, "f_rho, f_i, E2, d"):
latex_str = latex(self._rat)
return latex_str
def group(self):
r"""
Return the (Hecke triangle) group of ``self.parent()``.
EXAMPLES::
sage: from space import ModularForms
sage: ModularForms(group=12, k=4).E4().group()
Hecke triangle group for n = 12
"""
return self.parent().group()
def hecke_n(self):
r"""
Return the parameter ``n`` of the (Hecke triangle) group of ``self.parent()``.
EXAMPLES::
sage: from space import ModularForms
sage: ModularForms(group=12, k=6).E6().hecke_n()
12
"""
return self.parent().hecke_n()
def base_ring(self):
r"""
Return base ring of ``self.parent()``.
EXAMPLES::
sage: from space import ModularForms
sage: ModularForms(group=12, k=4, base_ring=CC).E4().base_ring()
Complex Field with 53 bits of precision
"""
return self.parent().base_ring()
def coeff_ring(self):
r"""
Return coefficient ring of ``self``.
EXAMPLES::
sage: from graded_ring import ModularFormsRing
sage: ModularFormsRing().E6().coeff_ring()
Fraction Field of Univariate Polynomial Ring in d over Integer Ring
"""
return self.parent().coeff_ring()
def rat(self):
r"""
Return the rational function representing ``self``.
EXAMPLES::
sage: from graded_ring import ModularFormsRing
sage: ModularFormsRing(group=12).Delta().rat()
x^30*d - x^18*y^2*d
"""
return self._rat
def is_homogeneous(self):
r"""
Return whether ``self`` is homogeneous.
EXAMPLES::
sage: from graded_ring import QModularFormsRing
sage: QModularFormsRing(group=12).Delta().is_homogeneous()
True
sage: QModularFormsRing(group=12).Delta().parent().is_homogeneous()
False
sage: x,y,z,d=var("x,y,z,d")
sage: QModularFormsRing(group=12)(x^3+y^2+z+d).is_homogeneous()
False
"""
return self._weight != None
def weight(self):
r"""
Return the weight of ``self``.
EXAMPLES::
sage: from graded_ring import QModularFormsRing
sage: from space import ModularForms
sage: x,y,z,d = var("x,y,z,d")
sage: QModularFormsRing()(x+y).weight() is None
True
sage: ModularForms(group=18).F_i().weight()
9/4
"""
return self._weight
def ep(self):
r"""
Return the multiplier of ``self``.
EXAMPLES::
sage: from graded_ring import QModularFormsRing
sage: from space import ModularForms
sage: x,y,z,d = var("x,y,z,d")
sage: QModularFormsRing()(x+y).ep() is None
True
sage: ModularForms(group=18).F_i().ep()
-1
"""
return self._ep
def degree(self):
r"""
Return the degree of ``self`` in the graded ring.
If ``self`` is not homogeneous, then ``(None, None)``
is returned.
EXAMPLES::
sage: from graded_ring import QModularFormsRing
sage: from space import ModularForms
sage: x,y,z,d = var("x,y,z,d")
sage: QModularFormsRing()(x+y).degree() == (None, None)
True
sage: ModularForms(group=18).F_i().degree()
(9/4, -1)
"""
return (self._weight,self._ep)
def is_modular(self):
r"""
Return whether ``self`` (resp. its homogeneous components)
transform like modular forms.
EXAMPLES::
sage: from graded_ring import QModularFormsRing
sage: from space import QModularForms
sage: x,y,z,d = var("x,y,z,d")
sage: QModularFormsRing(group=5)(x^2+y-d).is_modular()
True
sage: QModularFormsRing(group=5)(x^2+y-d+z).is_modular()
False
sage: QModularForms(group=18).F_i().is_modular()
True
sage: QModularForms(group=18).E2().is_modular()
False
"""
return not (self.AT("quasi") <= self._analytic_type)
def is_weakly_holomorphic(self):
r"""
Return whether ``self`` is weakly holomorphic
in the sense that: ``self`` has at most a power of ``f_inf``
in its denominator.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: from space import QMModularForms
sage: x,y,z,d = var("x,y,z,d")
sage: QMModularFormsRing(group=5)(x/(x^5-y^2)+z).is_weakly_holomorphic()
True
sage: QMModularFormsRing(group=5)(x^2+y/x-d).is_weakly_holomorphic()
False
sage: QMModularForms(group=18).J_inv().is_weakly_holomorphic()
True
"""
return self.AT("weak", "quasi") >= self._analytic_type
def is_holomorphic(self):
r"""
Return whether ``self`` is holomorphic
in the sense that the denominator of ``self``
is constant.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: from space import QMModularForms
sage: x,y,z,d = var("x,y,z,d")
sage: QMModularFormsRing(group=5)((y^3-z^5)/(x^5-y^2)+y-d).is_holomorphic()
False
sage: QMModularFormsRing(group=5)(x^2+y-d+z).is_holomorphic()
True
sage: QMModularForms(group=18).J_inv().is_holomorphic()
False
sage: QMModularForms(group=18).F_i().is_holomorphic()
True
"""
return self.AT("holo", "quasi") >= self._analytic_type
def is_cuspidal(self):
r"""
Return whether ``self`` is cuspidal
in the sense that ``self`` is holomorphic and ``f_inf``
divides the numerator.
EXAMPLES::
sage: from graded_ring import QModularFormsRing
sage: from space import QModularForms
sage: x,y,z,d = var("x,y,z,d")
sage: QModularFormsRing(group=5)(y^3-z^5).is_cuspidal()
False
sage: QModularFormsRing(group=5)(z*x^5-z*y^2).is_cuspidal()
True
sage: QModularForms(group=18).Delta().is_cuspidal()
True
sage: QModularForms(group=18).F_rho().is_cuspidal()
False
"""
return self.AT("cusp", "quasi") >= self._analytic_type
def is_zero(self):
r"""
Return whether ``self`` is the zero function.
EXAMPLES::
sage: from graded_ring import QModularFormsRing
sage: from space import QModularForms
sage: x,y,z,d = var("x,y,z,d")
sage: QModularFormsRing(group=5)(1).is_zero()
False
sage: QModularFormsRing(group=5)(0).is_zero()
True
sage: QModularForms(group=18).zero().is_zero()
True
sage: QModularForms(group=18).Delta().is_zero()
False
"""
return self.AT(["quasi"]) >= self._analytic_type
def analytic_type(self):
r"""
Return the analytic type of ``self``.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: from space import QMModularForms
sage: x,y,z,d = var("x,y,z,d")
sage: QMModularFormsRing(group=5)(x/z+d).analytic_type()
quasi meromorphic modular
sage: QMModularFormsRing(group=5)((y^3-z^5)/(x^5-y^2)+y-d).analytic_type()
quasi weakly holomorphic modular
sage: QMModularFormsRing(group=5)(x^2+y-d).analytic_type()
modular
sage: QMModularForms(group=18).J_inv().analytic_type()
weakly holomorphic modular
sage: QMModularForms(group=18).Delta().analytic_type()
cuspidal
"""
return self._analytic_type
def numerator(self):
r"""
Return the numerator of ``self``.
I.e. the (properly reduced) new form corresponding to
the numerator of ``self.rat()``.
Note that the parent of ``self`` might (probably will) change.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: from space import QMModularForms
sage: x,y,z,d = var("x,y,z,d")
sage: QMModularFormsRing(group=5)((y^3-z^5)/(x^5-y^2)+y-d).numerator()
f_rho^5*f_i - f_rho^5*d - E2^5 + f_i^2*d
sage: QMModularFormsRing(group=5)((y^3-z^5)/(x^5-y^2)+y-d).numerator().parent()
QuasiModularFormsRing(n=5) over Integer Ring
sage: QMModularForms(group=5, k=-2, ep=-1)(x/y).numerator()
1 + 7/(100*d)*q + 21/(160000*d^2)*q^2 + 1043/(192000000*d^3)*q^3 + 45479/(1228800000000*d^4)*q^4 + O(q^5)
sage: QMModularForms(group=5, k=-2, ep=-1)(x/y).numerator().parent()
QuasiModularForms(n=5, k=4/3, ep=1) over Integer Ring
"""
res = self.parent().rat_field()(self._rat.numerator())
# In general the numerator has a different weight than the original function...
new_parent = self.parent().extend_type(ring=True).reduce_type(["holo", "quasi"])
return new_parent(res).reduce()
def denominator(self):
r"""
Return the denominator of ``self``.
I.e. the (properly reduced) new form corresponding to
the numerator of ``self.rat()``.
Note that the parent of ``self`` might (probably will) change.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: from space import QMModularForms
sage: x,y,z,d = var("x,y,z,d")
sage: QMModularFormsRing(group=5).Delta().full_reduce().denominator()
1 + O(q^5)
sage: QMModularFormsRing(group=5)((y^3-z^5)/(x^5-y^2)+y-d).denominator()
f_rho^5 - f_i^2
sage: QMModularFormsRing(group=5)((y^3-z^5)/(x^5-y^2)+y-d).denominator().parent()
QuasiModularFormsRing(n=5) over Integer Ring
sage: QMModularForms(group=5, k=-2, ep=-1)(x/y).denominator()
1 - 13/(40*d)*q - 351/(64000*d^2)*q^2 - 13819/(76800000*d^3)*q^3 - 1163669/(491520000000*d^4)*q^4 + O(q^5)
sage: QMModularForms(group=5, k=-2, ep=-1)(x/y).denominator().parent()
QuasiModularForms(n=5, k=10/3, ep=-1) over Integer Ring
"""
res = self.parent().rat_field()(self._rat.denominator())
# In general the denominator has a different weight than the original function...
new_parent = self.parent().extend_type("holo", ring=True).reduce_type(["holo", "quasi"])
return new_parent(res).reduce()
def _add_(self,other):
r"""
Return the sum of ``self`` and ``other``.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: from space import QMModularForms
sage: MR = QMModularFormsRing(group=7)
sage: E2 = MR.E2().full_reduce()
sage: E4 = MR.E4().full_reduce()
sage: E6 = MR.E6().full_reduce()
sage: Delta = MR.Delta().full_reduce()
sage: J_inv = MR.J_inv().full_reduce()
sage: ring_el = MR(1/x+1).full_reduce()
sage: (Delta^2*E2 + E6*E4^2).parent()
QuasiModularFormsRing(n=7) over Integer Ring
sage: E4 + Delta
f_rho^15*d - f_rho^8*f_i^2*d + f_rho^5
sage: (E4 + QQ(1) + ring_el).parent()
MeromorphicModularFormsRing(n=7) over Integer Ring
sage: (E4^3 + 1.1*Delta).parent()
ModularForms(n=7, k=12, ep=1) over Real Field with 53 bits of precision
sage: (E4 + FractionField(PolynomialRing(CC,'d')).gen()).parent()
ModularFormsRing(n=7) over Complex Field with 53 bits of precision
sage: subspace = MR.reduce_type(["holo"], degree=(12,1)).subspace([Delta, E6^2])
sage: gen0 = subspace.gen(0)
sage: gen1 = subspace.gen(1)
sage: subspace2 = MR.reduce_type(["holo"], degree=(12,1)).subspace([Delta, Delta + E6^2])
sage: gen2 = subspace2.gen(0)
sage: gen3 = subspace2.gen(1)
sage: (gen0 + gen1).parent()
Subspace of dimension 2 of ModularForms(n=7, k=12, ep=1) over Integer Ring
sage: (gen0 + Delta*J_inv).parent()
WeakModularForms(n=7, k=12, ep=1) over Integer Ring
sage: gen0 + E2
f_rho^15*d - f_rho^8*f_i^2*d + E2
sage: (gen0 + E2).parent()
QuasiModularFormsRing(n=7) over Integer Ring
sage: gen2 + ring_el
(f_rho^16*d - f_rho^9*f_i^2*d + f_rho + 1)/f_rho
sage: (gen0 + int(1)).parent()
ModularFormsRing(n=7) over Integer Ring
"""
return self.parent()(self._rat+other._rat)
def _sub_(self,other):
r"""
Return the difference of ``self`` and ``other``.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: from space import QMModularForms
sage: MR = QMModularFormsRing(group=7)
sage: E2 = MR.E2().full_reduce()
sage: E4 = MR.E4().full_reduce()
sage: E6 = MR.E6().full_reduce()
sage: Delta = MR.Delta().full_reduce()
sage: J_inv = MR.J_inv().full_reduce()
sage: ring_el = MR(1/x+1).full_reduce()
sage: E6^2-E4^3
-1/d*q - 17/(56*d^2)*q^2 - 88887/(2458624*d^3)*q^3 - 941331/(481890304*d^4)*q^4 + O(q^5)
sage: (E6^2-E4^3).parent()
ModularForms(n=7, k=12, ep=1) over Integer Ring
sage: (E4 - int(1)).parent()
ModularFormsRing(n=7) over Integer Ring
sage: E4 - FractionField(PolynomialRing(CC,'d')).gen()
f_rho^5 - d
sage: ((E4+E6)-E6).parent()
ModularFormsRing(n=7) over Integer Ring
sage: subspace = MR.reduce_type(["holo"], degree=(12,1)).subspace([Delta, E6^2])
sage: gen0 = subspace.gen(0)
sage: gen1 = subspace.gen(1)
sage: subspace2 = MR.reduce_type(["holo"], degree=(12,1)).subspace([Delta, Delta + E6^2])
sage: gen2 = subspace2.gen(0)
sage: gen3 = subspace2.gen(1)
sage: (gen0 - gen2).parent()
ModularForms(n=7, k=12, ep=1) over Integer Ring
sage: (gen2 - ring_el).parent()
MeromorphicModularFormsRing(n=7) over Integer Ring
sage: (gen0 - 1.1).parent()
ModularFormsRing(n=7) over Real Field with 53 bits of precision
"""
#reduce at the end? See example "sage: ((E4+E6)-E6).parent()"
return self.parent()(self._rat-other._rat)
#def _rmul_(self,other):
# res = self.parent().rat_field()(self._rat*other)
# return self.parent()(res)
#def _lmul_(self,other):
# res = self.parent().rat_field()(other*self._rat)
# return self.parent()(res)
#def _rdiv_(self,other):
# res = self.parent().rat_field()(self._rat/other)
# return self.parent()(res)
def _mul_(self,other):
r"""
Return the product of ``self`` and ``other``.
Note that the parent might (probably will) change.
If ``parent.has_reduce_hom() == True`` then
the result is reduced to be an element of
the corresponding forms space if possible.
In particular this is the case if both ``self``
and ``other`` are (homogeneous) elements of a
forms space.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: from space import QMModularForms
sage: MR = QMModularFormsRing(group=8)
sage: E2 = MR.E2().full_reduce()
sage: E4 = MR.E4().full_reduce()
sage: E6 = MR.E6().full_reduce()
sage: Delta = MR.Delta().full_reduce()
sage: J_inv = MR.J_inv().full_reduce()
sage: ring_el = MR(1/x+1).full_reduce()
sage: (1*Delta).parent()
CuspForms(n=8, k=12, ep=1) over Integer Ring
sage: (1.1*Delta).parent()
ModularForms(n=8, k=12, ep=1) over Real Field with 53 bits of precision
sage: (E2*E4).parent()
QuasiModularForms(n=8, k=6, ep=-1) over Integer Ring
sage: E4^2
1 + 15/(32*d)*q + 3255/(32768*d^2)*q^2 + 105445/(8388608*d^3)*q^3 + 36379615/(34359738368*d^4)*q^4 + O(q^5)
sage: (E4^2).parent()
ModularForms(n=8, k=8, ep=1) over Integer Ring
sage: (1.1*E4).parent()
ModularForms(n=8, k=4, ep=1) over Real Field with 53 bits of precision
sage: (J_inv*ring_el).parent()
MeromorphicModularFormsRing(n=8) over Integer Ring
sage: (E4*FractionField(PolynomialRing(CC,'d')).gen()).parent()
ModularForms(n=8, k=4, ep=1) over Complex Field with 53 bits of precision
sage: subspace = MR.reduce_type(["holo"], degree=(12,1)).subspace([Delta, E6^2])
sage: gen0 = subspace.gen(0)
sage: gen1 = subspace.gen(1)
sage: subspace2 = MR.reduce_type(["holo"], degree=(12,1)).subspace([Delta, Delta + E6^2])
sage: gen2 = subspace2.gen(0)
sage: gen3 = subspace2.gen(1)
sage: (gen0 * gen1).parent()
ModularForms(n=8, k=24, ep=1) over Integer Ring
sage: (gen0 * Delta*J_inv).parent()
WeakModularForms(n=8, k=24, ep=1) over Integer Ring
sage: (gen0 * Delta*J_inv).reduced_parent()
CuspForms(n=8, k=24, ep=1) over Integer Ring
sage: (gen0 * E2).parent()
QuasiModularForms(n=8, k=14, ep=-1) over Integer Ring
sage: gen2 * ring_el
f_rho^18*d + f_rho^17*d - f_rho^10*f_i^2*d - f_rho^9*f_i^2*d
sage: (gen2 * ring_el).parent()
MeromorphicModularFormsRing(n=8) over Integer Ring
sage: (1.1*gen0).parent()
ModularForms(n=8, k=12, ep=1) over Real Field with 53 bits of precision
"""
res = self.parent().rat_field()(self._rat*other._rat)
new_parent = self.parent().extend_type(ring=True)
# The product of two homogeneous elements is homogeneous
return new_parent(res).reduce()
def _div_(self,other):
r"""
Return the division of ``self`` by ``other``.
Note that the parent might (probably will) change.
If ``parent.has_reduce_hom() == True`` then
the result is reduced to be an element of
the corresponding forms space if possible.
In particular this is the case if both ``self``
and ``other`` are (homogeneous) elements of a
forms space.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: from space import QMModularForms
sage: MR = QMModularFormsRing(group=8)
sage: E2 = MR.E2().full_reduce()
sage: E4 = MR.E4().full_reduce()
sage: E6 = MR.E6().full_reduce()
sage: Delta = MR.Delta().full_reduce()
sage: J_inv = MR.J_inv().full_reduce()
sage: ring_el = MR(1/x+1).full_reduce()
sage: (1/Delta).parent()
MeromorphicModularForms(n=8, k=-12, ep=1) over Integer Ring
sage: (1.1/Delta).parent()
MeromorphicModularForms(n=8, k=-12, ep=1) over Real Field with 53 bits of precision
sage: (Delta/Delta).parent()
MeromorphicModularForms(n=8, k=0, ep=1) over Integer Ring
sage: 1/E4
1 - 15/(64*d)*q + 2145/(65536*d^2)*q^2 - 59545/(16777216*d^3)*q^3 + 22622585/(68719476736*d^4)*q^4 + O(q^5)
sage: (ring_el/J_inv).parent()
MeromorphicModularFormsRing(n=8) over Integer Ring
sage: (FractionField(PolynomialRing(CC,'d')).gen()/E4).parent()
MeromorphicModularForms(n=8, k=-4, ep=1) over Complex Field with 53 bits of precision
sage: (E4^(-2)).parent()
MeromorphicModularForms(n=8, k=-8, ep=1) over Integer Ring
sage: ((E4.as_ring_element())^(-2)).parent() == (E4^(-2)).parent()
True
sage: (MR(x)^(-3)).parent()
QuasiMeromorphicModularFormsRing(n=8) over Integer Ring
sage: subspace = MR.reduce_type(["holo"], degree=(12,1)).subspace([Delta, E6^2])
sage: gen0 = subspace.gen(0)
sage: gen1 = subspace.gen(1)
sage: subspace2 = MR.reduce_type(["holo"], degree=(12,1)).subspace([Delta, Delta + E6^2])
sage: gen2 = subspace2.gen(0)
sage: gen3 = subspace2.gen(1)
sage: (gen0 / gen1).parent()
MeromorphicModularForms(n=8, k=0, ep=1) over Integer Ring
sage: (gen0 / Delta).parent()
MeromorphicModularForms(n=8, k=0, ep=1) over Integer Ring
sage: ring_el / gen2
(f_rho + 1)/(f_rho^19*d - f_rho^11*f_i^2*d)
sage: (ring_el / gen2).parent()
MeromorphicModularFormsRing(n=8) over Integer Ring
sage: (1.1/gen0).parent()
MeromorphicModularForms(n=8, k=-12, ep=1) over Real Field with 53 bits of precision
"""
res = self.parent().rat_field()(self._rat/other._rat)
new_parent = self.parent().extend_type("mero", ring=True)
# The division of two homogeneous elements is homogeneous
return new_parent(res).reduce()
def sqrt(self):
r"""
Try to return the square root of ``self``.
I.e. the element corresponding to ``sqrt(self.rat())``.
Whether this works or not depends on whether
``sqrt(self.rat())`` works and coerces into
``self.parent().rat_field()``.
Note that the parent might (probably will) change.
If ``parent.has_reduce_hom() == True`` then
the result is reduced to be an element of
the corresponding forms space if possible.
In particular this is the case if ``self``
is a (homogeneous) element of a forms space.
TODO::
sage: from space import QModularForms
sage: E2=QModularForms(k=2, ep=-1).E2()
sage: sqrt(E2^2) # todo: not implemented
"""
res = self.parent().rat_field()(self._rat.sqrt())
new_parent = self.parent().extend_type(ring=True)
# The sqrt of a homogeneous element is homogeneous if it exists
return self.parent()(res).reduce()
#def __invert__(self,other):
# res = self.parent().rat_field()(1/self._rat)
# new_parent = self.parent().extend_type(ring=True, mero=True)
# return new_parent(res).reduce()
def diff_op(self, op, new_parent=None):
r"""
Return the differential operator ``op`` applied to ``self``.
If ``parent.has_reduce_hom() == True`` then the result
is reduced to be an element of the corresponding forms
space if possible.
INPUT:
- ``op`` - An element of ``self.parent().diff_alg()``.
I.e. an element of the algebra over ``QQ``
of differential operators generated
by ``X, Y, Z, dX, dY, DZ``, where e.g. ``X``
corresponds to the multiplication by ``x``
(resp. ``F_rho``) and ``dX`` corresponds to ``d/dx``.
To expect a homogeneous result after applying
the operator to a homogeneous element it should
should be homogeneous operator (with respect
to the the usual, special grading).
- ``new_parent`` - Try to convert the result to the specified
``new_parent``. If ``new_parent == None`` (default)
then the parent is extended to a
"quasi meromorphic" ring.
OUTPUT:
The new element.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: MR = QMModularFormsRing(group=8, red_hom=True)
sage: (X,Y,Z,dX,dY,dZ) = MR.diff_alg().gens()
sage: n=MR.hecke_n()
sage: mul_op = 4/(n-2)*X*dX + 2*n/(n-2)*Y*dY + 2*Z*dZ
sage: der_op = MR._derivative_op()
sage: ser_op = MR._serre_derivative_op()
sage: der_op == ser_op + (n-2)/(4*n)*Z*mul_op
True
sage: Delta = MR.Delta().full_reduce()
sage: E2 = MR.E2().full_reduce()
sage: Delta.diff_op(mul_op) == 12*Delta
True
sage: Delta.diff_op(mul_op).parent()
QuasiMeromorphicModularForms(n=8, k=12, ep=1) over Integer Ring
sage: Delta.diff_op(mul_op, Delta.parent()).parent()
CuspForms(n=8, k=12, ep=1) over Integer Ring
sage: E2.diff_op(mul_op, E2.parent()) == 2*E2
True
sage: Delta.diff_op(Z*mul_op, Delta.parent().extend_type("quasi", ring=True)) == 12*E2*Delta
True
sage: ran_op = X + Y*X*dY*dX + dZ + dX^2
sage: Delta.diff_op(ran_op)
f_rho^19*d + 306*f_rho^16*d - f_rho^11*f_i^2*d - 20*f_rho^10*f_i^2*d - 90*f_rho^8*f_i^2*d
sage: E2.diff_op(ran_op)
f_rho*E2 + 1
"""
(x,y,z,d) = self.parent().rat_field().gens()
(X,Y,Z,dX,dY,dZ) = self.parent().diff_alg().gens()
L = op.monomials()
new_rat = 0
for mon in L:
mon_summand = self._rat
mon_summand = mon_summand.derivative(x,mon.degree(dX))
mon_summand = mon_summand.derivative(y,mon.degree(dY))
mon_summand = mon_summand.derivative(z,mon.degree(dZ))
mon_summand *= x**(mon.degree(X))
mon_summand *= y**(mon.degree(Y))
mon_summand *= z**(mon.degree(Z))
new_rat += op.monomial_coefficient(mon)*mon_summand
res = self.parent().rat_field()(new_rat)
if (new_parent == None):
new_parent = self.parent().extend_type(["quasi", "mero"], ring=True)
return new_parent(res).reduce()
# note that this is qd/dq, resp 1/(2*pi*i)*d/dtau
def derivative(self):
r"""
Return the derivative ``d/dq = 1/(2*pi*i) d/dtau`` of ``self``.
Note that the parent might (probably will) change.
In particular its analytic type will be extended
to contain "quasi".
If ``parent.has_reduce_hom() == True`` then
the result is reduced to be an element of
the corresponding forms space if possible.
In particular this is the case if ``self``
is a (homogeneous) element of a forms space.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: MR = QMModularFormsRing(group=7, red_hom=True)
sage: n = MR.hecke_n()
sage: E2 = MR.E2().full_reduce()
sage: E6 = MR.E6().full_reduce()
sage: F_rho = MR.F_rho().full_reduce()
sage: F_i = MR.F_i().full_reduce()
sage: F_inf = MR.F_inf().full_reduce()
sage: derivative(F_rho) == 1/n * (F_rho*E2 - F_i)
True
sage: derivative(F_i) == 1/2 * (F_i*E2 - F_rho**(n-1))
True
sage: derivative(F_inf) == F_inf * E2
True
sage: derivative(F_inf).parent()
QuasiCuspForms(n=7, k=38/5, ep=-1) over Integer Ring
sage: derivative(E2) == (n-2)/(4*n) * (E2**2 - F_rho**(n-2))
True
sage: derivative(E2).parent()
QuasiModularForms(n=7, k=4, ep=1) over Integer Ring
"""
return self.diff_op(self.parent()._derivative_op(), self.parent().extend_type("quasi", ring=True))
def serre_derivative(self):
r"""
Return the Serre derivative of ``self``.
Note that the parent might (probably will) change.
However a modular element is returned if ``self``
was already modular.
If ``parent.has_reduce_hom() == True`` then
the result is reduced to be an element of
the corresponding forms space if possible.
In particular this is the case if ``self``
is a (homogeneous) element of a forms space.
EXAMPLES::
sage: from graded_ring import QMModularFormsRing
sage: MR = QMModularFormsRing(group=7, red_hom=True)
sage: n = MR.hecke_n()
sage: Delta = MR.Delta().full_reduce()
sage: E2 = MR.E2().full_reduce()
sage: E4 = MR.E4().full_reduce()
sage: E6 = MR.E6().full_reduce()
sage: F_rho = MR.F_rho().full_reduce()
sage: F_i = MR.F_i().full_reduce()
sage: F_inf = MR.F_inf().full_reduce()
sage: F_rho.serre_derivative() == -1/n * F_i
True
sage: F_i.serre_derivative() == -1/2 * E4 * F_rho
True
sage: F_inf.serre_derivative() == 0
True
sage: E2.serre_derivative() == -(n-2)/(4*n) * (E2^2 + E4)
True
sage: E4.serre_derivative() == -(n-2)/n * E6
True
sage: E6.serre_derivative() == -1/2 * E4^2 - (n-3)/n * E6^2 / E4
True
sage: E6.serre_derivative().parent()
ModularForms(n=7, k=8, ep=1) over Integer Ring
"""
return self.diff_op(self.parent()._serre_derivative_op(), self.parent().extend_type(ring=True))
@cached_method
def order_inf(self):
"""
Return the order at infinity of ``self``.
If ``self`` is homogeneous and modular then
only the rational function ``self.rat()`` is used.
Otherwise the Fourier expansion is used
(with increasing precision until the order
can be determined).
EXAMPLES::