# Elements of quasimodular forms rings#

AUTHORS:

• DAVID AYOTTE (2021-03-18): initial version

class sage.modular.quasimodform.element.QuasiModularFormsElement(parent, polynomial)#

A quasimodular forms ring element. Such an element is describbed by SageMath as a polynomial

$f_0 + f_1 E_2 + f_2 E_2^2 + \cdots + f_m E_2^m$

where each $$f_i$$ a graded modular form element (see GradedModularFormElement)

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: QM.gens()
[1 - 24*q - 72*q^2 - 96*q^3 - 168*q^4 - 144*q^5 + O(q^6),
1 + 240*q + 2160*q^2 + 6720*q^3 + 17520*q^4 + 30240*q^5 + O(q^6),
1 - 504*q - 16632*q^2 - 122976*q^3 - 532728*q^4 - 1575504*q^5 + O(q^6)]
sage: QM.0 + QM.1
2 + 216*q + 2088*q^2 + 6624*q^3 + 17352*q^4 + 30096*q^5 + O(q^6)
sage: QM.0 * QM.1
1 + 216*q - 3672*q^2 - 62496*q^3 - 322488*q^4 - 1121904*q^5 + O(q^6)
sage: (QM.0)^2
1 - 48*q + 432*q^2 + 3264*q^3 + 9456*q^4 + 21600*q^5 + O(q^6)
sage: QM.0 == QM.1
False


Quasimodular forms ring element can be created via a polynomial in $$E2$$ over the ring of modular forms:

sage: E2 = QM.polygen()
sage: E2.parent()
Univariate Polynomial Ring in E2 over Ring of Modular Forms for Modular Group SL(2,Z) over Rational Field
sage: QM(E2)
1 - 24*q - 72*q^2 - 96*q^3 - 168*q^4 - 144*q^5 + O(q^6)
sage: M = QM.modular_forms_subring()
sage: QM(M.0 * E2 + M.1 * E2^2)
2 - 336*q + 4320*q^2 + 398400*q^3 - 3772992*q^4 - 89283168*q^5 + O(q^6)

derivative()#

Return the derivative $$q \frac{d}{dq}$$ of the given quasimodular form.

If the form is not homogeneous, then this method sums the derivative of each homogeneous component.

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: E2, E4, E6 = QM.gens()
sage: dE2 = E2.derivative(); dE2
-24*q - 144*q^2 - 288*q^3 - 672*q^4 - 720*q^5 + O(q^6)
sage: dE2 == (E2^2 - E4)/12 # Ramanujan identity
True
sage: dE4 = E4.derivative(); dE4
240*q + 4320*q^2 + 20160*q^3 + 70080*q^4 + 151200*q^5 + O(q^6)
sage: dE4 == (E2 * E4 - E6)/3 # Ramanujan identity
True
sage: dE6 = E6.derivative(); dE6
-504*q - 33264*q^2 - 368928*q^3 - 2130912*q^4 - 7877520*q^5 + O(q^6)
sage: dE6 == (E2 * E6 - E4^2)/2 # Ramanujan identity
True


Note that the derivative of a modular form is not necessarily a modular form:

sage: dE4.is_modular_form()
False
sage: dE4.weight()
6

homogeneous_components()#

Return a dictionary where the values are the homogeneous components of the given graded form and the keys are the weights of those components.

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: (QM.0).homogeneous_components()
{2: 1 - 24*q - 72*q^2 - 96*q^3 - 168*q^4 - 144*q^5 + O(q^6)}
sage: (QM.0 + QM.1 + QM.2).homogeneous_components()
{2: 1 - 24*q - 72*q^2 - 96*q^3 - 168*q^4 - 144*q^5 + O(q^6),
4: 1 + 240*q + 2160*q^2 + 6720*q^3 + 17520*q^4 + 30240*q^5 + O(q^6),
6: 1 - 504*q - 16632*q^2 - 122976*q^3 - 532728*q^4 - 1575504*q^5 + O(q^6)}
sage: (1 + QM.0).homogeneous_components()
{0: 1, 2: 1 - 24*q - 72*q^2 - 96*q^3 - 168*q^4 - 144*q^5 + O(q^6)}


Return whether the given quasimodular form is a graded modular form element (see GradedModularFormElement).

EXAMPLES:

sage: QM = QuasiModularForms(1)
False
True
False
True
sage: QM = QuasiModularForms(Gamma0(6))
False
sage: (QM.1 + QM.2 + QM.1 * QM.3).is_graded_modular_form()
True
True


Note

A graded modular form in SageMath is not necessarily a modular form as it can have mixed weight components. To check for modular forms only, see the method is_modular_form().

is_homogeneous()#

Return whether the graded quasimodular form is a homogeneous element, that is, it lives in a unique graded components of the parent of self.

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: (QM.0).is_homogeneous()
True
sage: (QM.0 + QM.1).is_homogeneous()
False
sage: (QM.0 * QM.1 + QM.2).is_homogeneous()
True
sage: QM(1).is_homogeneous()
True
sage: (1 + QM.0).is_homogeneous()
False

is_modular_form()#

Return whether the given quasimodular form is a modular form.

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: (QM.0).is_modular_form()
False
sage: (QM.1).is_modular_form()
True
sage: (QM.1 + QM.2).is_modular_form() # mixed weight components
False
sage: QM.zero().is_modular_form()
True

is_one()#

Return whether the given quasimodular form is 1, i.e. the multiplicative identity.

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: QM.one().is_one()
True
sage: QM(1).is_one()
True
sage: (QM.0).is_one()
False

is_zero()#

Return whether the given quasimodular form is zero.

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: QM.zero().is_zero()
True
sage: QM(0).is_zero()
True
sage: QM(1/2).is_zero()
False
sage: (QM.0).is_zero()
False

polynomial(names='E2, E4, E6')#

Return a multivariate polynomial $$P(E_2, E_4, E_6)$$ corresponding to the given form where $$E_2$$, $$E_4$$ and $$E_6$$ are the generators of the quasimodular form ring given by the following method: gens().

INPUT:

• names (str, default: 'E2, E4, E6') – a list or tuple of names (strings), or a comma separated string. Correspond to the names of the variables;

OUTPUT: A multivariate polynomial in the variables names

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: (QM.0 + QM.1).polynomial()
E4 + E2
sage: (1/2 + QM.0 + 2*QM.1^2 + QM.0*QM.2).polynomial()
E2*E6 + 2*E4^2 + E2 + 1/2

q_expansion(prec=6)#

Return the $$q$$-expansion of the given quasimodular form up to precision prec (default: 6).

An alias of this method is qexp.

EXAMPLES:

sage: QM = QuasiModularForms()
sage: E2 = QM.0
sage: E2.q_expansion()
1 - 24*q - 72*q^2 - 96*q^3 - 168*q^4 - 144*q^5 + O(q^6)
sage: E2.q_expansion(prec=10)
1 - 24*q - 72*q^2 - 96*q^3 - 168*q^4 - 144*q^5 - 288*q^6 - 192*q^7 - 360*q^8 - 312*q^9 + O(q^10)

qexp(prec=6)#

Return the $$q$$-expansion of the given quasimodular form up to precision prec (default: 6).

An alias of this method is qexp.

EXAMPLES:

sage: QM = QuasiModularForms()
sage: E2 = QM.0
sage: E2.q_expansion()
1 - 24*q - 72*q^2 - 96*q^3 - 168*q^4 - 144*q^5 + O(q^6)
sage: E2.q_expansion(prec=10)
1 - 24*q - 72*q^2 - 96*q^3 - 168*q^4 - 144*q^5 - 288*q^6 - 192*q^7 - 360*q^8 - 312*q^9 + O(q^10)

serre_derivative()#

Return the Serre derivative of the given quasimodular form.

If the form is not homogeneous, then this method sums the Serre derivative of each homogeneous component.

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: E2, E4, E6 = QM.gens()
sage: DE2 = E2.serre_derivative(); DE2
-1/6 - 16*q - 216*q^2 - 832*q^3 - 2248*q^4 - 4320*q^5 + O(q^6)
sage: DE2 == (-E2^2 - E4)/12
True
sage: DE4 = E4.serre_derivative(); DE4
-1/3 + 168*q + 5544*q^2 + 40992*q^3 + 177576*q^4 + 525168*q^5 + O(q^6)
sage: DE4 == (-1/3) * E6
True
sage: DE6 = E6.serre_derivative(); DE6
-1/2 - 240*q - 30960*q^2 - 525120*q^3 - 3963120*q^4 - 18750240*q^5 + O(q^6)
sage: DE6 == (-1/2) * E4^2
True


The Serre derivative raises the weight of homogeneous elements by 2:

sage: F = E6 + E4 * E2
sage: F.weight()
6
sage: F.serre_derivative().weight()
8

to_polynomial(names='E2, E4, E6')#

Return a multivariate polynomial $$P(E_2, E_4, E_6)$$ corresponding to the given form where $$E_2$$, $$E_4$$ and $$E_6$$ are the generators of the quasimodular form ring given by the following method: gens().

INPUT:

• names (str, default: 'E2, E4, E6') – a list or tuple of names (strings), or a comma separated string. Correspond to the names of the variables;

OUTPUT: A multivariate polynomial in the variables names

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: (QM.0 + QM.1).polynomial()
E4 + E2
sage: (1/2 + QM.0 + 2*QM.1^2 + QM.0*QM.2).polynomial()
E2*E6 + 2*E4^2 + E2 + 1/2

weight()#

Return the weight of the given quasimodular form.

Note that the given form must be homogeneous.

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: (QM.0).weight()
2
sage: (QM.0 * QM.1 + QM.2).weight()
6
sage: QM(1/2).weight()
0
sage: (QM.0 + QM.1).weight()
Traceback (most recent call last):
...
ValueError: the given graded quasiform is not an homogeneous element

weights_list()#

Return the list of the weights of all the graded components of the given graded quasimodular form.

EXAMPLES:

sage: QM = QuasiModularForms(1)
sage: (QM.0).weights_list()
[2]
sage: (QM.0 + QM.1 + QM.2).weights_list()
[2, 4, 6]
sage: (QM.0 * QM.1 + QM.2).weights_list()
[6]
sage: QM(1/2).weights_list()
[0]