@@ -778,3 +778,36 @@ def from_polynomial(self, polynomial):
778
778
raise ValueError ("the number of variables (%s) of the given polynomial cannot exceed the number of generators (%s) of the quasimodular forms ring" % (nb_var , self .ngens ()))
779
779
gens_dict = {poly_parent .gen (i ):self .gen (i ) for i in range (0 , nb_var )}
780
780
return self (polynomial .subs (gens_dict ))
781
+
782
+ def basis_of_weight (self , weight ):
783
+ r"""
784
+ Return a basis of elements generating the subspace of the given weight.
785
+
786
+ EXAMPLES::
787
+
788
+ sage: QM = QuasiModularForms(1)
789
+ sage: QM.basis_of_weight(12)
790
+ [q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6),
791
+ 1 + 65520/691*q + 134250480/691*q^2 + 11606736960/691*q^3 + 274945048560/691*q^4 + 3199218815520/691*q^5 + O(q^6),
792
+ 1 - 288*q - 129168*q^2 - 1927296*q^3 + 65152656*q^4 + 1535768640*q^5 + O(q^6),
793
+ 1 + 432*q + 39312*q^2 - 1711296*q^3 - 14159664*q^4 + 317412000*q^5 + O(q^6),
794
+ 1 - 576*q + 21168*q^2 + 308736*q^3 - 15034608*q^4 - 39208320*q^5 + O(q^6),
795
+ 1 + 144*q - 17712*q^2 + 524736*q^3 - 2279088*q^4 - 79760160*q^5 + O(q^6),
796
+ 1 - 144*q + 8208*q^2 - 225216*q^3 + 2634192*q^4 + 1488672*q^5 + O(q^6)]
797
+ sage: QM = QuasiModularForms(Gamma1(3))
798
+ sage: QM.basis_of_weight(3)
799
+ [1 + 54*q^2 + 72*q^3 + 432*q^5 + O(q^6),
800
+ q + 3*q^2 + 9*q^3 + 13*q^4 + 24*q^5 + O(q^6)]
801
+ sage: QM.basis_of_weight(5)
802
+ [1 - 90*q^2 - 240*q^3 - 3744*q^5 + O(q^6),
803
+ q + 15*q^2 + 81*q^3 + 241*q^4 + 624*q^5 + O(q^6),
804
+ 1 - 24*q - 18*q^2 - 1320*q^3 - 5784*q^4 - 10080*q^5 + O(q^6),
805
+ q - 21*q^2 - 135*q^3 - 515*q^4 - 1392*q^5 + O(q^6)]
806
+ """
807
+ basis = []
808
+ E2 = self .weight_2_eisenstein_series ()
809
+ for j in range (weight // 2 ):
810
+ basis += [f * E2 ** j for f in self .__modular_forms_subring .modular_forms_of_weight (weight - 2 * j ).basis ()]
811
+ if not weight % 2 :
812
+ basis .append (E2 ** (Integer (weight / 2 )))
813
+ return basis
0 commit comments