When computing with spaces of modular forms, it is helpful to have
easy-to-compute formulas for dimensions of these spaces. Such
formulas provide a check on the output of the algorithms from
Chapter *General Modular Symbols* that compute explicit bases for spaces of
modular forms. We can also use dimension formulas to improve the
efficiency of some of the algorithms in Chapter *General Modular Symbols*, since
we can use them to determine the ranks of certain matrices without
having to explicitly compute those matrices. Dimension formulas can also be
used in generating bases of -expansions; if we know the dimension
of and if we have a process for computing -expansions
of elements of , e.g., multiplying together
-expansions of certain forms of smaller weight, then we can tell
when we are done generating .

This chapter contains formulas for dimensions of spaces of modular
forms, along with some remarks about how to evaluate these formulas.
In some cases we give dimension formulas for spaces that we
will define in later chapters.
We also give
many examples, some of which were computed using the modular symbols
algorithms from Chapter *General Modular Symbols*.

Many of the dimension formulas and algorithms we give below grew out
of Shimura’s book [**Shi94**] and a program that Bruce Kaskel
wrote (around 1996) in PARI, which Kevin Buzzard extended. That
program codified dimension formulas that Buzzard and Kaskel found or
extracted from the literature (mainly [**Shi94**, Section 2.6]).
The algorithms for dimensions of spaces with nontrivial character are
from [**CO77**], with some refinements
suggested by Kevin Buzzard.

For the rest of this chapter, denotes a positive integer and
is an integer. We will give *no simple formulas* for
dimensions of spaces of weight modular forms; in fact, it
might not be possible to give such formulas since the
methods used to derive the formulas below do not apply in the case
. If , the only modular forms are the constants, and for
the dimension of is .

For a nonzero integer and a prime , let be the largest integer such that . In the formulas in this chapter, always denotes a prime number. Let be the space of modular forms of level weight and character , and let and be the cuspidal and Eisenstein subspaces, respectively.

The dimension formulas below for ,
, and can be
found in [**DS05**, Ch. 3],
[**Shi94**, Section 2.6] [1] and
[**Miy89**, Section 2.5]. They are derived using the Riemann-Roch Theorem
applied to the covering or and
appropriately chosen divisors. It would be natural to give a sample
argument along these lines at this point, but we will not since it
easy to find such arguments in other books and survey papers (see,
e.g., [**DI95**]). So you will not learn much about how to
derive dimension formulas from this chapter. What you will learn is
precisely what the dimension formulas are, which is something that is
often hard to extract from obscure references.

In addition to reading this chapter, the reader may wish to consult
[**Mar05**] for proofs of similar dimension formulas,
asymptotic results, and a nonrecursive formula for dimensions of
certain new subspaces.

For any prime and any positive integer , let be the power of that divides . Also, let

Note that is the index of in
(see *Exercise 6.1*).

Proposition 6.1

We have , and for even,

The dimension of the Eisenstein subspace is

The following is a table of for some values of and :

Example 6.2

Use the commands `dimension_cusp_forms`,
`dimension_eis`, and `dimension_modular_forms`
to compute the dimensions of the three spaces ,
and , respectively.
For example,

```
sage: dimension_cusp_forms(Gamma0(2007),2)
221
sage: dimension_eis(Gamma0(2007),2)
7
sage: dimension_modular_forms(Gamma0(2007),2)
228
```

Remark 6.3

Csirik, Wetherell, and Zieve prove in
[**CWZ01**] that a random positive integer has
probability of being a value of

and they give bounds on the size of the set of values of below
some given . For example, they show that are the first few integers that are not of the
form for any . See *Figure 6.1*
for a plot of the very erratic function . In
contrast, the function is very
well behaved (see *Figure 6.2*).

Figure 6.1

Dimension of as a function of

Figure 6.2

Dimension of as a function of .

In this section we assume the reader is either
familiar with newforms or has read Section *Atkin-Lehner-Li Theory*.

For any integer , let

where the product is over primes that exactly divide .
Note that is *not* the Moebius function, but it
has a similar flavor.

Proposition 6.4

The dimension of the new subspace is

where the sum is over the positive divisors of .
As a consequence of *Theorem 9.4*,
we also have

where is the number of divisors of .

Example 6.5

We compute the dimension of the new subspace of
using the Sage command `dimension_new_cusp_forms`
as follows:

```
sage: dimension_new_cusp_forms(Gamma0(11),12)
8
sage: dimension_cusp_forms(Gamma0(11),12)
10
sage: dimension_new_cusp_forms(Gamma0(2007),12)
1017
sage: dimension_cusp_forms(Gamma0(2007),12)
2460
```

This section follows Section *Modular Forms for * closely, but with
suitable modifications with replaced by .

Define functions of a positive integer by the following formulas:

Note that is the genus of the modular curve (associated to ) and is the number of cusps of .

Proposition 6.6

We have . If , then so

where is given by the formula of
*Proposition 6.1*. If , let

Then for ,

The dimension of the Eisenstein subspace is as follows:

The dimension of the new subspace of is

where is as in the statement
of *Proposition 6.4*.

Remark 6.7

Since , the formulas above for and also yield a formula for the dimension of .

Figure 6.3

Dimension of as a function of .

The following table contains the dimension of for some sample values of and :

Example 6.8

We compute dimensions of spaces of modular forms for :

```
sage: dimension_cusp_forms(Gamma1(2007),2)
147409
sage: dimension_eis(Gamma1(2007),2)
3551
sage: dimension_modular_forms(Gamma1(2007),2)
150960
```

Fix a Dirichlet character of modulus ,
and let be the conductor of (we do *not*
assume that is primitive).
Assume that , since otherwise
and the formulas of
Section *Modular Forms for * apply. Also, assume that ,
since otherwise . In this section we
discuss formulas for computing each of ,
and .

In [**CO77**], Cohen and
Oesterl’e assert (without *published* proof; see Remark *Remark 6.11* below)
that for any and ,
as above,

where is as in Section *Modular Forms for *,
and
,
and are

It remains to define . Fix a prime divisor and let . Then

This flexible formula can be used to compute the dimension of , , and for any , , , by using that

One thing that is not straightforward when implementing an algorithm to compute the above dimension formulas is how to efficiently compute the sets and . Kevin Buzzard suggested the following two algorithms. Note that if is odd, then , so the sum over is only needed when is even.

Algorithm 6.9

Given a positive integer and an even Dirichlet character of modulus , this algorithm computes .

[Factor ] Compute the prime factorization of .

[Initialize] Set and .

[Loop Over Prime Divisors] Set . If , return . Otherwise set and .

- If , return .
- If and , return .
- If and , go to step
*(3)*. - Compute a generator using
*Algorithm 4.4*. - Compute .
- Use the Chinese Remainder Theorem to find such that and .
- Set .
- Set .

- If , set and go to
step
*(3)*.

- If , set and go to
step
*(3)*.

Proof

Note that , since is even. By the Chinese
Remainder Theorem, the set is empty if and only if there is
no square root of modulo some prime power divisor of . If
is empty, the algorithm correctly detects this fact in
steps *(a)* – *(b)*.
Thus assume is
nonempty. For each prime power that exactly divides
, let be such that and for . This is the value of
computed in steps *(d)* – *(g)*
(as one sees using elementary number theory).

The next key observation is that

(1)

since by the Chinese Remainder Theorem the elements of are
in bijection with the choices for a square root of modulo each
prime power divisors of . The observation (1)
is a huge gain from an efficiency point of view—if had
prime factors, then would have size , which could be
prohibitive, where the product involves only factors. To finish
the proof, just note that steps
*(h)* – *(j)*
compute the local factors ,
where again we use that is even. Note that a solution
of lifts uniquely to a solution mod for
any , because the kernel of the natural homomorphism is a group of -power order.

The algorithm for computing the sum over is similar.

For , to compute , use the formula directly and the fact that , unless and . To compute for , use the fact that the big formula at the beginning of this section is valid for any integer to replace by and that for to rewrite the formula as

Note also that for , if and only if is trivial and it equals otherwise. We then also obtain

We can also compute when directly, since

The following table contains the dimension of for some sample values of and . In each case, is the product of characters of maximal order corresponding to the prime power factors of (i.e., the product of the generators of the group of Dirichlet characters of modulus ).

Example 6.10

We compute the last line of the above table. First we create the character .

```
sage: G = DirichletGroup(2007)
sage: e = prod(G.gens(), G(1))
```

Next we compute the dimension of the four spaces.

```
sage: dimension_cusp_forms(e,2)
222
sage: dimension_cusp_forms(e,3)
0
sage: dimension_cusp_forms(e,4)
670
sage: dimension_cusp_forms(e,24)
5150
```

We can also compute dimensions of the corresponding spaces of Eisenstein series.

```
sage: dimension_eis(e,2)
4
sage: dimension_eis(e,3)
0
sage: dimension_eis(e,4)
4
sage: dimension_eis(e,24)
4
```

Remark 6.11

Cohen and Oesterl’e also give dimension formulas for spaces of
half-integral weight modular forms, which we do not give in this
chapter. Note that [**CO77**] does not
contain any *proofs* that their claimed formulas are correct,
but instead they say only that “Les formules qui les donnent sont
connues de beaucoup de gens et il existe plusieurs m’ethodes
permettant de les obtenir (th’eor`eme de Riemann-Roch, application
des formules de trace donn’ees par Shimura).” [2]
Fortunately, in [**Que06**],
Jordi Quer derives the
(integral weight) formulas of [**CO77**]
along with formulas for dimensions of spaces and
for more general congruence subgroups.

Let be the conductor of a Dirichlet character of modulus . Then the dimension of the new subspace of is

where is as in the statement
of *Proposition 6.4*, and is the restriction
of mod .

Example 6.12

We compute the dimension of for a quadratic character of modulus .

```
sage: G = DirichletGroup(2007, QQ)
sage: e = prod(G.gens(), G(1))
sage: dimension_new_cusp_forms(e,2)
76
```

Exercise 6.1

Let and be as in this chapter.

- Prove that .
- Prove that for , , so is the index of in .

Exercise 6.2

Use *Proposition 6.4* to find a formula
for . Verify that this formula is
the same as the one in Corollary *Corollary 2.16*.

Exercise 6.3

Suppose either that or that is prime and . Prove that .

Exercise 6.4

Fill in the details of the proof of *Algorithm 6.9*.

Exercise 6.5

Implement a computer program to compute as a function of and .

Footnotes

[1] | The formulas in [Shi94, Section 2.6] contain some minor mistakes. |

[2] | The formulas that we give here are well known and there exist many methods to prove them, e.g., the Riemann-Roch theorem and applications of the trace formula of Shimura. |