42.2 Generic spaces of modular forms

Module: sage.modular.modform.space

Generic spaces of modular forms

EXAMPLES (computation of base ring): Return the base ring of this space of modular forms.

For spaces of modular forms for $ \Gamma_0(N)$ or $ \Gamma_1(N)$ , the default base ring is $ \mathbf{Q}$ :

sage: ModularForms(11,2).base_ring()
Rational Field
sage: ModularForms(1,12).base_ring()
Rational Field
sage: CuspForms(Gamma1(13),3).base_ring()
Rational Field

The base ring can be explicitly specified in the constructor function.

sage: ModularForms(11,2,base_ring=GF(13)).base_ring()
Finite Field of size 13

For modular forms with character the default base ring is the field generated by the image of the character.

sage: ModularForms(DirichletGroup(13).0,3).base_ring()
Cyclotomic Field of order 12 and degree 4

For example, if the character is quadratic then the field is $ \mathbf{Q}$ (if the characteristic is 0 ).

sage: ModularForms(DirichletGroup(13).0^6,3).base_ring()
Rational Field

An example in characteristic $ 7$ :

sage: ModularForms(13,3,base_ring=GF(7)).base_ring()
Finite Field of size 7

Module-level Functions

contains_each( V, B)

Determine whether or not V contains every element of B. Used here for linear algebra, but works very generally.

sage: contains_each = sage.modular.modform.space.contains_each
sage: contains_each( range(20), prime_range(20) )
True
sage: contains_each( range(20), range(30) )
False

is_ModularFormsSpace( x)

Return True if x is a $ \code{ModularFormsSpace}$ .

sage: is_ModularFormsSpace(ModularForms(11,2))
True
sage: is_ModularFormsSpace(CuspForms(11,2))
True
sage: is_ModularFormsSpace(3)
False

Class: ModularFormsSpace

class ModularFormsSpace
A generic space of modular forms.
ModularFormsSpace( self, group, weight, character, base_ring)

Generic spaces of modular forms. For spaces of modular forms for $ \Gamma_0(N)$ or $ \Gamma_1(N)$ , the default base ring is $ \mathbf{Q}$ .

sage: ModularForms(11,2)
Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(11) of
weight 2 over Rational Field

sage: ModularForms(11,2,base_ring=GF(13))
Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(11) of
weight 2 over Finite Field of size 13

sage: ModularForms(DirichletGroup(13).0,3)
Modular Forms space of dimension 3, character [zeta12] and weight 3 over
Cyclotomic Field of order 12 and degree 4

sage: M = ModularForms(11,2)
sage: M == loads(dumps(M))
True

Functions: base_extend,$ \,$ basis,$ \,$ change_ring,$ \,$ character,$ \,$ cuspidal_submodule,$ \,$ cuspidal_subspace,$ \,$ decomposition,$ \,$ echelon_basis,$ \,$ echelon_form,$ \,$ eisenstein_series,$ \,$ eisenstein_submodule,$ \,$ eisenstein_subspace,$ \,$ embedded_submodule,$ \,$ find_in_space,$ \,$ gen,$ \,$ gens,$ \,$ group,$ \,$ has_character,$ \,$ has_coerce_map_from_impl,$ \,$ integral_basis,$ \,$ intersect,$ \,$ is_ambient,$ \,$ level,$ \,$ modular_symbols,$ \,$ new_submodule,$ \,$ new_subspace,$ \,$ newforms,$ \,$ newspaces,$ \,$ prec,$ \,$ q_echelon_basis,$ \,$ q_expansion_basis,$ \,$ q_integral_basis,$ \,$ set_precision,$ \,$ span,$ \,$ span_of_basis,$ \,$ sturm_bound,$ \,$ weight

base_extend( self, base_ring)

Return the base extension of self to base_ring.

basis( self)

Return a basis for self.

sage: MM = ModularForms(11,2)
sage: MM.basis()
[
q - 2*q^2 - q^3 + 2*q^4 + q^5 + O(q^6),
1 + 12/5*q + 36/5*q^2 + 48/5*q^3 + 84/5*q^4 + 72/5*q^5 + O(q^6)
]

change_ring( self, R)

Change the base ring of this space of modular forms.

TODO: Write this function.

sage: sage.modular.modform.space.ModularFormsSpace(Gamma0(11),2,DirichletGroup(1).0,QQ).change_ring(GF(7))
Traceback (most recent call last):
...
NotImplementedError: This function has not yet been implemented.

character( self)

Return the Dirichlet character of this space.

sage: M = ModularForms(DirichletGroup(11).0, 3)
sage: M.character()
[zeta10]
sage: s = M.cuspidal_submodule()
sage: s.character()
[zeta10]
sage: CuspForms(DirichletGroup(11).0,3).character()
[zeta10]

cuspidal_submodule( self)

Return the cuspidal submodule of self.

sage: N = ModularForms(6,4) ; N
Modular Forms space of dimension 5 for Congruence Subgroup Gamma0(6) of
weight 4 over Rational Field
sage: N.eisenstein_subspace().dimension()
4

sage: N.cuspidal_submodule()
Cuspidal subspace of dimension 1 of Modular Forms space of dimension 5 for
Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

sage: N.cuspidal_submodule().dimension()
1

cuspidal_subspace( self)

Synonym for cuspidal_submodule.

sage: N = ModularForms(6,4) ; N
Modular Forms space of dimension 5 for Congruence Subgroup Gamma0(6) of
weight 4 over Rational Field
sage: N.eisenstein_subspace().dimension()
4

sage: N.cuspidal_subspace()
Cuspidal subspace of dimension 1 of Modular Forms space of dimension 5 for
Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

sage: N.cuspidal_submodule().dimension()
1

decomposition( self)

This function returns a list of submodules $ V(f_i,t)$ corresponding to newforms $ f_i$ of some level dividing the level of self, such that the direct sum of the submodules equals self, if possible. The space $ V(f_i,t)$ is the image under $ g(q)$ maps to $ g(q^t)$ of the intersection with $ R[[q]]$ of the space spanned by the conjugates of $ f_i$ , where $ R$ is the base ring of self.

TODO: Implement this function.

sage: M = ModularForms(11,2); M.decomposition()
Traceback (most recent call last):
...
NotImplementedError

echelon_basis( self)

Return a basis for self in reduced echelon form. This means that if we view the $ q$ -expansions of the basis as defining rows of a matrix (with infinitely many columns), then this matrix is in reduced echelon form.

sage: M = ModularForms(Gamma0(11),4)
sage: M.echelon_basis()
[
1 + O(q^6),
q - 9*q^4 - 10*q^5 + O(q^6),
q^2 + 6*q^4 + 12*q^5 + O(q^6),
q^3 + q^4 + q^5 + O(q^6)
]
sage: M.cuspidal_subspace().echelon_basis()
[
q + 3*q^3 - 6*q^4 - 7*q^5 + O(q^6),
q^2 - 4*q^3 + 2*q^4 + 8*q^5 + O(q^6)
]

sage: M = ModularForms(SL2Z, 12)
sage: M.echelon_basis()
[
1 + 196560*q^2 + 16773120*q^3 + 398034000*q^4 + 4629381120*q^5 + O(q^6),
q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6)
]

sage: M = CuspForms(Gamma0(17),4, prec=10)
sage: M.echelon_basis()
[
q + 2*q^5 - 8*q^7 - 8*q^8 + 7*q^9 + O(q^10),
q^2 - 3/2*q^5 - 7/2*q^6 + 9/2*q^7 + q^8 - 4*q^9 + O(q^10),
q^3 - 2*q^6 + q^7 - 4*q^8 - 2*q^9 + O(q^10),
q^4 - 1/2*q^5 - 5/2*q^6 + 3/2*q^7 + 2*q^9 + O(q^10)
]

echelon_form( self)

Return a space of modular forms isomorphic to self but with basis of $ q$ -expansions in reduced echelon form.

This is useful, e.g., the default basis for spaces of modular forms is rarely in echelon form, but echelon form is useful for quickly recognizing whether a $ q$ -expansion is in the space.

We first illustrate two ambient spaces and their echelon forms.

sage: M = ModularForms(11)
sage: M.basis()
[
q - 2*q^2 - q^3 + 2*q^4 + q^5 + O(q^6),
1 + 12/5*q + 36/5*q^2 + 48/5*q^3 + 84/5*q^4 + 72/5*q^5 + O(q^6)
]
sage: M.echelon_form().basis()
[
1 + 12*q^2 + 12*q^3 + 12*q^4 + 12*q^5 + O(q^6),
q - 2*q^2 - q^3 + 2*q^4 + q^5 + O(q^6)
]

sage: M = ModularForms(Gamma1(6),4)
sage: M.basis()
[
q - 2*q^2 - 3*q^3 + 4*q^4 + 6*q^5 + O(q^6),
1 + O(q^6),
q - 8*q^4 + 126*q^5 + O(q^6),
q^2 + 9*q^4 + O(q^6),
q^3 + O(q^6)
]
sage: M.echelon_form().basis()
[
1 + O(q^6),
q + 94*q^5 + O(q^6),
q^2 + 36*q^5 + O(q^6),
q^3 + O(q^6),
q^4 - 4*q^5 + O(q^6)
]

We create a space with a funny basis then compute the corresponding echelon form.

sage: M = ModularForms(11,4)
sage: M.basis()
[
q + 3*q^3 - 6*q^4 - 7*q^5 + O(q^6),
q^2 - 4*q^3 + 2*q^4 + 8*q^5 + O(q^6),
1 + O(q^6),
q + 9*q^2 + 28*q^3 + 73*q^4 + 126*q^5 + O(q^6)
]
sage: F = M.span_of_basis([M.0 + 1/3*M.1, M.2 + M.3]); F.basis()
[
q + 1/3*q^2 + 5/3*q^3 - 16/3*q^4 - 13/3*q^5 + O(q^6),
1 + q + 9*q^2 + 28*q^3 + 73*q^4 + 126*q^5 + O(q^6)
]
sage: E = F.echelon_form(); E.basis()
[
1 + 26/3*q^2 + 79/3*q^3 + 235/3*q^4 + 391/3*q^5 + O(q^6),
q + 1/3*q^2 + 5/3*q^3 - 16/3*q^4 - 13/3*q^5 + O(q^6)
]

eisenstein_series( self)

Compute the Eisenstein series associated to this space.

NOTE: This function should be overridden by all derived classes.

sage: M = sage.modular.modform.space.ModularFormsSpace(Gamma0(11),2,DirichletGroup(1).0,base_ring=QQ) ; M.eisenstein_series()
Traceback (most recent call last):
...
NotImplementedError: computation of Eisenstein series in this space not yet
implemented

eisenstein_submodule( self)

Return the Eisenstein submodule for this space of modular forms.

sage: M = ModularForms(11,2)
sage: M.eisenstein_submodule()
Eisenstein subspace of dimension 1 of Modular Forms space of dimension 2
for Congruence Subgroup Gamma0(11) of weight 2 over Rational Field

eisenstein_subspace( self)

Synonym for eisenstein_submodule.

sage: M = ModularForms(11,2)
sage: M.eisenstein_subspace()
Eisenstein subspace of dimension 1 of Modular Forms space of dimension 2
for Congruence Subgroup Gamma0(11) of weight 2 over Rational Field

embedded_submodule( self)

Return the underlying module of self.

sage: N = ModularForms(6,4)
sage: N.dimension()
5

sage: N.embedded_submodule()
Vector space of dimension 5 over Rational Field

find_in_space( self, f, [forms=None], [prec=None], [indep=True])

Input:

f
- a modular form or power series
forms
- (default: None) a specific list of modular forms or q-expansions.
prec
- if forms are given, compute with them to the given precision
indep
- (default: True) whether the given list of forms are assumed to form a basis.

Output: A list of numbers that give f as a linear combination of the basis for this space or of the given forms if independent=True.

NOTE: If the list of forms is given, they do *not* have to be in self.

sage: M = ModularForms(11,2)
sage: N = ModularForms(10,2)
sage: M.find_in_space( M.basis()[0] )
[1, 0]

sage: M.find_in_space( N.basis()[0], forms=N.basis() )
[1, 0, 0]

sage: M.find_in_space( N.basis()[0] )
Traceback (most recent call last):
...
ArithmeticError: vector is not in free module

gen( self, n)

Return the nth generator of self.

sage: N = ModularForms(6,4)
sage: N.basis()
[
q - 2*q^2 - 3*q^3 + 4*q^4 + 6*q^5 + O(q^6),
1 + O(q^6),
q - 8*q^4 + 126*q^5 + O(q^6),
q^2 + 9*q^4 + O(q^6),
q^3 + O(q^6)
]

sage: N.gen(0)
q - 2*q^2 - 3*q^3 + 4*q^4 + 6*q^5 + O(q^6)

sage: N.gen(4)
q^3 + O(q^6)

sage: N.gen(5)
Traceback (most recent call last):
...
ValueError: Generator 5 not defined

gens( self)

Return a complete set of generators for self.

sage: N = ModularForms(6,4)
sage: N.gens()
[
q - 2*q^2 - 3*q^3 + 4*q^4 + 6*q^5 + O(q^6),
1 + O(q^6),
q - 8*q^4 + 126*q^5 + O(q^6),
q^2 + 9*q^4 + O(q^6),
q^3 + O(q^6)
]

group( self)

Return the congruence subgroup associated to this space of modular forms.

sage: ModularForms(Gamma0(12),4).group()
Congruence Subgroup Gamma0(12)

sage: CuspForms(Gamma1(113),2).group()
Congruence Subgroup Gamma1(113)

Note that $ \Gamma_1(1)$ and $ \SL _2(\mathbf{Z})$ are replaced by $ \Gamma_0(1)$ .

sage: CuspForms(Gamma1(1),12).group()
Congruence Subgroup Gamma0(1)
sage: CuspForms(SL2Z,12).group()
Congruence Subgroup Gamma0(1)

has_character( self)

Return True if this space of modular forms has a specific character.

This is True exactly when the character() function does not return None.

A space for $ \Gamma_0(N)$ has trivial character, hence has a character.

sage: CuspForms(Gamma0(11),2).has_character()
True

A space for $ \Gamma_1(N)$ (for $ N\geq 2$ ) never has a specific character.

sage: CuspForms(Gamma1(11),2).has_character()
False
sage: CuspForms(DirichletGroup(11).0,3).has_character()
True

has_coerce_map_from_impl( self, from_par)

Code to make ModularFormsSpace work well with coercion framework.

sage: M = ModularForms(22,2)
sage: M.has_coerce_map_from_impl(M.cuspidal_subspace())
True
sage: M.has_coerce_map_from(ModularForms(22,4))
False

integral_basis( self)

Return an integral basis for this space of modular forms.

In this example the integral and echelon bases are different.

sage: m = ModularForms(97,2,prec=10)
sage: s = m.cuspidal_subspace()
sage: s.integral_basis()
[
q + 2*q^7 + 4*q^8 - 2*q^9 + O(q^10),
q^2 + q^4 + q^7 + 3*q^8 - 3*q^9 + O(q^10),
q^3 + q^4 - 3*q^8 + q^9 + O(q^10),
2*q^4 - 2*q^8 + O(q^10),
q^5 - 2*q^8 + 2*q^9 + O(q^10),
q^6 + 2*q^7 + 5*q^8 - 5*q^9 + O(q^10),
3*q^7 + 6*q^8 - 4*q^9 + O(q^10)
]
sage: s.echelon_basis()
[
q + 2/3*q^9 + O(q^10),
q^2 + 2*q^8 - 5/3*q^9 + O(q^10),
q^3 - 2*q^8 + q^9 + O(q^10),
q^4 - q^8 + O(q^10),
q^5 - 2*q^8 + 2*q^9 + O(q^10),
q^6 + q^8 - 7/3*q^9 + O(q^10),
q^7 + 2*q^8 - 4/3*q^9 + O(q^10)
]

Here's another example where there is a big gap in the valuations:

sage: m = CuspForms(64,2)
sage: m.integral_basis()
[
q + O(q^6),
q^2 + O(q^6),
q^5 + O(q^6)
]

TESTS:

sage: m = CuspForms(11*2^4,2, prec=13); m
Cuspidal subspace of dimension 19 of Modular Forms space of dimension 30
for Congruence Subgroup Gamma0(176) of weight 2 over Rational Field
sage: m.integral_basis()          # takes a long time (3 or 4 seconds)
[
q + O(q^13),
q^2 + O(q^13),
q^3 + O(q^13),
q^4 + O(q^13),
q^5 + O(q^13),
q^6 + O(q^13),
q^7 + O(q^13),
q^8 + O(q^13),
q^9 + O(q^13),
q^10 + O(q^13),
q^11 + O(q^13),
q^12 + O(q^13),
O(q^13),
O(q^13),
O(q^13),
O(q^13),
O(q^13),
O(q^13),
O(q^13)
]

intersect( self, right)

If self and right live in the same ambient module, return the intersection of self and right (as submodules).

sage: N = ModularForms(6,4); S = N.cuspidal_subspace()

sage: N.intersect(S)
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

sage: S.intersect(N)
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

sage: S.intersect(N.eisenstein_subspace())
Modular Forms subspace of dimension 0 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

is_ambient( self)

Return True if this an ambient space of modular forms.

sage: M = ModularForms(Gamma1(4),4)
sage: M.is_ambient()
True

sage: E = M.eisenstein_subspace()
sage: E.is_ambient()
False

level( self)

Return the level of self.

sage: M = ModularForms(47,3)
sage: M.level()
47

modular_symbols( self, [sign=0])

Return the space of modular symbols corresponding to self with the given sign.

NOTE: This function should be overridden by all derived classes.

sage: M = sage.modular.modform.space.ModularFormsSpace(Gamma0(11),2,DirichletGroup(1).0,base_ring=QQ) ; M.modular_symbols()
Traceback (most recent call last):
...
NotImplementedError: computation of associated modular symbols space not
yet implemented

new_submodule( self, [p=None])

Return the new submodule of self. If p is specified, return the p-new submodule of self.

NOTE: This function should be overridden by all derived classes.

sage: M = sage.modular.modform.space.ModularFormsSpace(Gamma0(11),2,DirichletGroup(1).0,base_ring=QQ) ; M.new_submodule()
Traceback (most recent call last):
...
NotImplementedError: computation of new submodule not yet implemented

new_subspace( self, [p=None])

Synonym for new_submodule.

sage: M = sage.modular.modform.space.ModularFormsSpace(Gamma0(11),2,DirichletGroup(1).0,base_ring=QQ) ; M.new_subspace()
Traceback (most recent call last):
...
NotImplementedError: computation of new submodule not yet implemented

newforms( self, [names=None])

Return all cusp forms in the cuspidal subspace of self.

newspaces( self)

This function returns a list of submodules $ S(M,t)$ and $ E(M,t)$ , corresponding to levels $ M$ dividing $ N$ and integers $ t$ dividing $ N/M$ , such that self is the direct sum of these spaces, if possible. Here $ S(M,t)$ is by definition the image under $ f(q) \mapsto f(q^t)$ of the new submodule of cusp forms of level $ M$ , and similarly $ E(M,t)$ is the image of Eisenstein series.

Notes: (1) the submodules $ S(M,t)$ need not be stable under Hecke operators of index dividing $ N/M$ . (2) Since self can be an arbitrary submodule, there's no guarantee any $ S(M,t)$ or $ E(M,t)$ is in self, so the return list could be empty.

sage: N = ModularForms(6,4)
sage: N.newspaces()
[Modular Forms subspace of dimension 1 of Modular Forms space of dimension
5 for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field,
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field,
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field,
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field,
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field]

prec( self, [new_prec=None])

Return or set the default precision used for displaying $ q$ -expansions of elements of this space.

Input:

new_prec
- positive integer (default: None)

Output: if new_prec is None, returns the current precision.

sage: M = ModularForms(1,12)
sage: S = M.cuspidal_subspace()
sage: S.prec()
6
sage: S.basis()
[
q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6)
]
sage: S.prec(8)
8
sage: S.basis()
[
q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 - 6048*q^6 - 16744*q^7 + O(q^8)
]

q_echelon_basis( self, [prec=None])

Return the echelon form of the basis of $ q$ -expansions of self up to precision prec.

The $ q$ -expansions are power series (not actual modular forms). The number of $ q$ -expansions returned equals the dimension.

sage: M = ModularForms(11,2)
sage: M.q_expansion_basis()
[
q - 2*q^2 - q^3 + 2*q^4 + q^5 + O(q^6),
1 + 12/5*q + 36/5*q^2 + 48/5*q^3 + 84/5*q^4 + 72/5*q^5 + O(q^6)
]

sage: M.q_echelon_basis()
[
1 + 12*q^2 + 12*q^3 + 12*q^4 + 12*q^5 + O(q^6),
q - 2*q^2 - q^3 + 2*q^4 + q^5 + O(q^6)
]

q_expansion_basis( self, [prec=None])

Return a sequence of q-expansions for the basis of this space computed to the given input precision.

Input:

prec
- integer (>=0) or None

If prec is None, the prec is computed to be *at least* large enough so that each q-expansion determines the form as an element of this space.

NOTE: In fact, the q-expansion basis is always computed to *at least* self.prec().

sage: S = ModularForms(11,2).cuspidal_submodule()
sage: S.q_expansion_basis()
[
q - 2*q^2 - q^3 + 2*q^4 + q^5 + O(q^6)
]            
sage: S.q_expansion_basis(5)
[
q - 2*q^2 - q^3 + 2*q^4 + O(q^5)
]
sage: S = ModularForms(1,24).cuspidal_submodule()
sage: S.q_expansion_basis(8)
[
q + 195660*q^3 + 12080128*q^4 + 44656110*q^5 - 982499328*q^6 -
147247240*q^7 + O(q^8),
q^2 - 48*q^3 + 1080*q^4 - 15040*q^5 + 143820*q^6 - 985824*q^7 + O(q^8)
]

q_integral_basis( self, [prec=None])

Return a $ \mathbf{Z}$ -reduced echelon basis of $ q$ -expansions for self.

The $ q$ -expansions are power series with coefficients in $ \mathbf{Z}$ ; they are not actual modular forms.

The base ring of self must be $ \mathbf{Q}$ . The number of $ q$ -expansions returned equals the dimension.

sage: S = CuspForms(11,2)
sage: S.q_integral_basis(5)
[
q - 2*q^2 - q^3 + 2*q^4 + O(q^5)
]

set_precision( self, new_prec)

Set the default precision used for displaying $ q$ -expansions.

Input:

new_prec
- positive integer

sage: M = ModularForms(Gamma0(37),2)
sage: M.set_precision(10)
sage: S = M.cuspidal_subspace()
sage: S.basis()
[
q + q^3 - 2*q^4 - q^7 - 2*q^9 + O(q^10),
q^2 + 2*q^3 - 2*q^4 + q^5 - 3*q^6 - 4*q^9 + O(q^10)
]

sage: S.set_precision(0)
sage: S.basis()
[
O(q^0),
O(q^0)
]

The precision of subspaces is the same as the precision of the ambient space.

sage: S.set_precision(2)
sage: M.basis()
[
q + O(q^2),
O(q^2),
1 + 2/3*q + O(q^2)
]

The precision must be nonnegative:

sage: S.set_precision(-1)
Traceback (most recent call last):
...
ValueError: n (=-1) must be >= 0

We do another example with nontrivial character.

sage: M = ModularForms(DirichletGroup(13).0^2)
sage: M.set_precision(10)
sage: M.cuspidal_subspace().0
q + (-zeta6 - 1)*q^2 + (2*zeta6 - 2)*q^3 + zeta6*q^4 + (-2*zeta6 + 1)*q^5 +
(-2*zeta6 + 4)*q^6 + (2*zeta6 - 1)*q^8 - zeta6*q^9 + O(q^10)

span( self, B)

Take a set B of forms, and return the subspace of self with B as a basis.

sage: N = ModularForms(6,4) ; N
Modular Forms space of dimension 5 for Congruence Subgroup Gamma0(6) of
weight 4 over Rational Field

sage: N.span_of_basis([N.basis()[0]])
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

sage: N.span_of_basis([N.basis()[0], N.basis()[1]])
Modular Forms subspace of dimension 2 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

sage: N.span_of_basis( N.basis() )
Modular Forms subspace of dimension 5 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

span_of_basis( self, B)

Take a set B of forms, and return the subspace of self with B as a basis.

sage: N = ModularForms(6,4) ; N
Modular Forms space of dimension 5 for Congruence Subgroup Gamma0(6) of
weight 4 over Rational Field

sage: N.span_of_basis([N.basis()[0]])
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

sage: N.span_of_basis([N.basis()[0], N.basis()[1]])
Modular Forms subspace of dimension 2 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

sage: N.span_of_basis( N.basis() )
Modular Forms subspace of dimension 5 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

sturm_bound( self, [M=None])

For a space M of modular forms, this function returns an integer B such that two modular forms in either self or M are equal if and only if their q-expansions are equal to precision B (note that this is 1+ the usual Sturm bound, since $ O(q^{prec})$ has precision prec). If M is none, then M is set equal to self.

sage: S37=CuspForms(37,2)
sage: S37.sturm_bound()
8
sage: M = ModularForms(11,2)
sage: M.sturm_bound()
3
sage: ModularForms(Gamma1(15),2).sturm_bound()
33

NOTES: Reference for the Sturm bound that we use in the definition of of this function:

J. Sturm, On the congruence of modular forms, Number theory (New York, 1984-1985), Springer, Berlin, 1987, pp. 275-280.

Useful Remark:

Kevin Buzzard pointed out to me (William Stein) in Fall 2002 that the above bound is fine for Gamma1 with character, as one sees by taking a power of $ f$ . More precisely, if $ f
\equiv 0 \pmod{p}$ for first $ s$ coefficients, then $ f^r = 0 \pmod{p}$ for first $ sr$ coefficents. Since the weight of $ f^r$ is $ r$   weight$ (f)$ , it follows that if $ s \geq $ the sturm bound for $ \Gamma_0$ at weight(f), then $ f^r$ has valuation large enough to be forced to be 0 at $ r\cdot$ weight(f) by Sturm bound (which is valid if we choose $ r$ right). Thus $ f
\equiv 0 \pmod{p}$ . Conclusion: For $ \Gamma_1$ with fixed character, the Sturm bound is exactly the same as for $ \Gamma_0$ . A key point is that we are finding $ \mathbf{Z}[\varepsilon ]$ generators for the Hecke algebra here, not $ \mathbf{Z}$ -generators. So if one wants generators for the Hecke algebra over $ \mathbf{Z}$ , this bound is wrong.

This bound works over any base, even a finite field. There might be much better bounds over $ \mathbf{Q}$ , or for comparing two eigenforms.

weight( self)

Return the weight of this space of modular forms.

sage: M = ModularForms(Gamma1(13),11)
sage: M.weight()
11

sage: M = ModularForms(Gamma0(997),100)
sage: M.weight()
100

sage: M = ModularForms(Gamma0(97),4)
sage: M.weight()
4
sage: M.eisenstein_submodule().weight()
4

Special Functions: __add__,$ \,$ __and__,$ \,$ __call__,$ \,$ __cmp__,$ \,$ __contains__,$ \,$ __init__,$ \,$ _coerce_impl,$ \,$ _compute_hecke_matrix,$ \,$ _compute_hecke_matrix_prime,$ \,$ _compute_q_expansion_basis,$ \,$ _has_natural_inclusion_map_to,$ \,$ _ModularFormsSpace__create_newspace,$ \,$ _ModularFormsSpace__newspace_bases,$ \,$ _ModularFormsSpace__normalize_prec,$ \,$ _ModularFormsSpace__submodule_from_subset_of_basis,$ \,$ _q_expansion,$ \,$ _q_expansion_module,$ \,$ _q_expansion_ring,$ \,$ _q_expansion_zero

__add__( self, right)

If self and right live inside the same ambient module, return the sum of the two spaces (as modules).

sage: N = ModularForms(6,4) ; ls = N.newspaces() ; ls
[Modular Forms subspace of dimension 1 of Modular Forms space of dimension
5 for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field,
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field,
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field,
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field,
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field]

sage: N1 = ls[2] ; N2 = ls[3]
sage: N1.__add__(N2)
Modular Forms subspace of dimension 2 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

__and__( self, right)

Return intersect of self and right.

sage: N = ModularForms(6,4); S = N.cuspidal_subspace()

sage: N.__and__(S)
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

sage: S.__and__(N)
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

__call__( self, x, [check=True])

Try to coerce x into self. If x is a vector of length self.dimension(), interpret it as a list of coefficients for self.basis() and return that linear combination. If x is a power series, it tries to determine whether or not x lives in self. If so, it returns x as an element of M, and throws an error if not.

sage: M = ModularForms(13,4)
sage: M.dimension()
5

sage: M([1,2,3,4,5])
4 + 6*q + 47*q^2 + 143*q^3 + 358*q^4 + 630*q^5 + O(q^6)

sage: M([1,3])
Traceback (most recent call last):
...
TypeError: entries must be a list of length 5

sage: R = M._q_expansion_ring()
sage: M(R([0,1,0,0,0,-2,-4,-2,-12]).add_bigoh(9))
q - 2*q^5 + O(q^6)

sage: M.set_precision(9)         
sage: M(R([0,1,0,0,0,-2,-4,-2,-12]).add_bigoh(9))
q - 2*q^5 - 4*q^6 - 2*q^7 - 12*q^8 + O(q^9)

Note that one only needs coefficients up to self.sturm_bound() to determine the form:

sage: M(R([0,1,0,0,0,-2,-4,-2,-12]).add_bigoh(8))
q - 2*q^5 - 4*q^6 - 2*q^7 - 12*q^8 + O(q^9)

sage: M(R([0,1,1,0,0,0,-4,-2,-12]).add_bigoh(9))
Traceback (most recent call last):
...
ArithmeticError: vector is not in free module

sage: S = CuspForms(1,12) ; R = PowerSeriesRing(QQ,'q') ; q = R.0
sage: f = q+O(q^2) ; S(f)
q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6)
sage: f = q+2*q^2+O(q^3) ; S(f)
Traceback (most recent call last):
...
ValueError: q-expansion does not correspond to a form in self
sage: f = q-24*q^2+O(q^3) ; S(f)
q - 24*q^2 + 252*q^3 - 1472*q^4 + 4830*q^5 + O(q^6)

__cmp__( self, x)

Compare self and x.

For spaces of modular forms, we order first by signature, then by dimension, and then by the ordering on the underlying free modules.

sage: N = ModularForms(6,4) ; S = N.cuspidal_subspace()
sage: S.__cmp__(N)
-1
sage: N.__cmp__(S)
1
sage: N.__cmp__(N)
0
sage: M = ModularForms(11,2)
sage: N.__cmp__(M)
-1
sage: M.__cmp__(N)
-1

__contains__( self, x)

True if x is an element or submodule of self.

TODO: This function is still *quite* rudimentary. If self is ambient, it checks containment. Otherwise, it throws a NotImplementedError.

sage: M = ModularForms(11,2) ; N = ModularForms(6,4)
sage: M.__contains__(M)
True
sage: M.__contains__(N)
False
sage: N.__contains__(N.cuspidal_submodule())
True
sage: M.__contains__(N.cuspidal_submodule())
False
sage: M.cuspidal_submodule().__contains__(N)
Traceback (most recent call last):
...
NotImplementedError

_coerce_impl( self, x)

Code to coerce an element into self.

sage: M = ModularForms(22,2) ; S = CuspForms(22,2)
sage: sum(S.basis()) 
q + q^2 - q^3 - 4*q^4 + q^5 + O(q^6)
sage: sum(S.basis() + M.basis())
1 + 3*q + 3*q^2 + 2*q^3 - 7*q^4 + 8*q^5 + O(q^6)
sage: M._coerce_impl(S.basis()[0])
q - q^3 - 2*q^4 + q^5 + O(q^6)

sage: M = ModularForms(Gamma0(22)) ; N = ModularForms(Gamma0(44))
sage: M.basis()[0]
q - q^3 - 2*q^4 + q^5 + O(q^6)
sage: N(M.basis()[0])
q - q^3 - 2*q^4 + q^5 + O(q^6)

_compute_hecke_matrix( self, n)

Compute the matrix of the Hecke operator T_n acting on self.

sage: M = ModularForms(11,2)
sage: M._compute_hecke_matrix(6)
[ 2  0]
[ 0 12]

sage: M = ModularForms(11,2)
sage: M2 = M.span([M.0 + M.1])
sage: M2.hecke_matrix(2)
Traceback (most recent call last):
...
ArithmeticError: vector is not in free module

_compute_hecke_matrix_prime( self, p, [prec=None])

Compute the matrix of the Hecke operator T_p acting on self.

sage: M = ModularForms(11,2)
sage: M._compute_hecke_matrix_prime(2)
[-2  0]
[ 0  3]

sage: M = ModularForms(11,2)
sage: M2 = M.span([M.0 + M.1])
sage: M2.hecke_matrix(2)
Traceback (most recent call last):
...
ArithmeticError: vector is not in free module

_compute_q_expansion_basis( self, prec)

sage: sage.modular.modform.space.ModularFormsSpace(Gamma0(11),2,DirichletGroup(1).0,QQ)._compute_q_expansion_basis(5)
Traceback (most recent call last):
...
NotImplementedError: this must be implemented in the derived class

_has_natural_inclusion_map_to( self, right)

Return true if there is a natural inclusion map from modular forms in self to modular forms in right.

Input:

self, right
- spaces of modular forms

Output: True if self embeds in right, and False otherwise.

TODO: Barring a few trivial cases, this only works in the case that right.is_ambient() returns True.

sage: N = ModularForms(6,4) ; S = N.cuspidal_subspace()

sage: N._has_natural_inclusion_map_to(S)
Traceback (most recent call last):
...
NotImplementedError

sage: S._has_natural_inclusion_map_to(N)
True

sage: M = ModularForms(11,2)
sage: N._has_natural_inclusion_map_to(M)
False

_ModularFormsSpace__create_newspace( self, basis, level, t, is_cuspidal)

Create a newspace as a subspace of self based on the input data.

sage: N = ModularForms(6,4)
sage: N._ModularFormsSpace__create_newspace( [(1,0,0,0,0)], N.level(), 1, True)
Modular Forms subspace of dimension 1 of Modular Forms space of dimension 5
for Congruence Subgroup Gamma0(6) of weight 4 over Rational Field

_ModularFormsSpace__newspace_bases( self)

Find bases for all new subspaces of self.

sage: N = ModularForms(6,4)
sage: N._ModularFormsSpace__newspace_bases()
[(6, 1, True, [(1, 0, 0, 0, 0)]),
(1, 6, False, [(0, 1, 0, 0, 0)]),
(1, 3, False, [(0, 0, 1, 0, 0)]),
(1, 2, False, [(0, 0, 0, 1, 0)]),
(1, 1, False, [(0, 0, 0, 0, 1)])]

_ModularFormsSpace__normalize_prec( self, prec)

If prec=None, return self.prec(). Otherwise, make sure prec is a sensible choice of precision and return it.

sage: N = ModularForms(6,4) 
sage: N._ModularFormsSpace__normalize_prec(int(3))
3

sage: type(N._ModularFormsSpace__normalize_prec(int(3)))
<type 'sage.rings.integer.Integer'>

_ModularFormsSpace__submodule_from_subset_of_basis( self, x)

Return the submodule of self generated by the elements of x.

sage: N = ModularForms(6,4)
sage: N._ModularFormsSpace__submodule_from_subset_of_basis( [0,2] )
Vector space of degree 5 and dimension 2 over Rational Field
Basis matrix:
[1 0 0 0 0]
[0 0 1 0 0]

_q_expansion( self, element, prec)

Take an element of self (specified as a list, tuple, or vector), and return the corresponding q-expansion.

sage: m = ModularForms(Gamma0(23),2); m
Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(23) of
weight 2 over Rational Field
sage: m.basis()
[
q - q^3 - q^4 + O(q^6),
q^2 - 2*q^3 - q^4 + 2*q^5 + O(q^6),
1 + 12/11*q + 36/11*q^2 + 48/11*q^3 + 84/11*q^4 + 72/11*q^5 + O(q^6)
]
sage: m._q_expansion([1,2,0], 5)
q + 2*q^2 - 5*q^3 - 3*q^4 + O(q^5)

_q_expansion_module( self)

Return module spanned by coefficients of q-expansions to sufficient precision to determine elements of this space.

sage: M = ModularForms(11,2)
sage: M._q_expansion_module()
Vector space of degree 3 and dimension 2 over Rational Field
User basis matrix:
[   0    1   -2]
[   1 12/5 36/5]
sage: CuspForms(1,12)._q_expansion_module()
Vector space of degree 2 and dimension 1 over Rational Field
User basis matrix:
[0 1]

_q_expansion_ring( self)

Returns the parent for q-expansions of modular forms in self.

sage: M = ModularForms(11,2)
sage: M._q_expansion_ring()
Power Series Ring in q over Rational Field

_q_expansion_zero( self)

Returns the q-expansion of the modular form 0.

sage: M = ModularForms(11,2)
sage: M._q_expansion_zero()
0
sage: M._q_expansion_zero() == M._q_expansion_ring()(0)
True

See About this document... for information on suggesting changes.