Dimension Formulas

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 q-expansions; if we know the dimension of M_k(N,\eps) and if we have a process for computing q-expansions of elements of M_k(N,\eps), e.g., multiplying together q-expansions of certain forms of smaller weight, then we can tell when we are done generating M_k(N,\eps).

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, N denotes a positive integer and k\geq 2 is an integer. We will give no simple formulas for dimensions of spaces of weight 1 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 k=1. If k=0, the only modular forms are the constants, and for k<0 the dimension of M_k(N,\eps) is 0.

For a nonzero integer N and a prime p, let v_p(N) be the largest integer e such that p^e \mid N. In the formulas in this chapter, p always denotes a prime number. Let M_k(N,\eps) be the space of modular forms of level N weight k and character \eps, and let S_k(N,\eps) and E_k(N,\eps) be the cuspidal and Eisenstein subspaces, respectively.

The dimension formulas below for S_k(\Gamma_0(N)), S_k(\Gamma_1(N)), E_k(\Gamma_0(N)) and E_k(\Gamma_1(N)) 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 X_0(N)\to X_0(1) or X_1(N)\to X_1(1) 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.

Modular Forms for \Gamma_0(N)

For any prime p and any positive integer N, let v_p(N) be the power of p that divides N. Also, let

\mu_0(N) &= \prod_{p\mid N} \left( p^{v_p(N)} + p^{v_p(N)-1} \right),\\
\mu_{0,2}(N) &= \begin{cases}
0 & \text{if $4\mid N$,}\\
\prod_{p\mid N} \left(1 + \kr{-4}{p}\right) & \text{otherwise,}
\mu_{0,3}(N) &= \begin{cases}
0 & \text{if $2\mid N$ or $9\mid N$,}\\
\prod_{p\mid N} \left(1 + \kr{-3}{p}\right) & \text{otherwise,}
c_0(N) &= \sum_{d\mid N} \vphi(\gcd(d,N/d)),\\
g_0(N) &= 1 + \frac{\mu_0(N)}{12} - \frac{\mu_{0,2}(N)}{4} - \
\frac{\mu_{0,3}(N)}{3} - \frac{c_0(N)}{2}.\\

Note that \mu_0(N) is the index of \Gamma_0(N) in \SL_2(\Z) (see Exercise 6.1).

Proposition 6.1

We have \dim S_2(\Gamma_0(N)) = g_0(N), and for k\geq 4 even,

\dim S_k(\Gamma_0(N)) &=
(k-1) \cdot (g_0(N) - 1) \,\,+ \,\,
\left( \frac{k}{2} - 1 \right) \cdot c_0(N) \,\,   \\
&\qquad\qquad   + \mu_{0,2}(N)\cdot \left\lfloor\frac{k}{4}\right\rfloor \,\,+ \,\,
\mu_{0,3}(N)\cdot \left\lfloor \frac{k}{3}\right\rfloor.

The dimension of the Eisenstein subspace is

\dim E_k(\Gamma_0(N)) =
c_0(N) & \text{if $k\neq 2$,}\\
c_0(N)-1 & \text{if $k=2$.}

The following is a table of \dim S_k(\Gamma_0(N)) for some values of N and k:

$N$ & $S_2(\Gamma_0(N))$ & $S_4(\Gamma_0(N))$ &
      $S_6(\Gamma_0(N))$ & $S_{24}(\Gamma_0(N))$\\\hline
1 & 0 & 0 & 0 & 2\\
10 & 0 & 3 & 5 & 33\\
11 & 1 & 2 & 4 & 22\\
100 & 7 & 36 & 66 & 336\\
389 & 32 & 97 & 161 & 747\\
1000 & 131 & 430 & 730 & 3430\\
2007 & 221 & 806 & 1346 & 6206\\
100000 & 14801 & 44800 & 74800 & 344800\\\hline

Example 6.2

Use the commands dimension_cusp_forms, dimension_eis, and dimension_modular_forms to compute the dimensions of the three spaces S_k(\Gamma_0(N)), E_k(\Gamma_0(N)) and M_k(\Gamma_0(N)), respectively. For example,

sage: dimension_cusp_forms(Gamma0(2007),2)
sage: dimension_eis(Gamma0(2007),2)
sage: dimension_modular_forms(Gamma0(2007),2)

Remark 6.3

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

g_0(N)=\dim S_2(\Gamma_0(N)),

and they give bounds on the size of the set of values of g_0(N) below some given x. For example, they show that 150, 180, 210, 286,
304, 312, \ldots are the first few integers that are not of the form g_0(N) for any N. See Figure 6.1 for a plot of the very erratic function g_0(N). In contrast, the function k\mapsto \dim S_{2k}(\Gamma_0(12)) is very well behaved (see Figure 6.2).

Figure 6.1

Dimension of S_2(\Gamma_0(N)) as a function of N


Figure 6.2

Dimension of S_{2k}(\Gamma_0(12)) as a function of k.


New and Old Subspaces

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

For any integer R, let

\overline{\mu}(R) =
0 & \text{if $p^3\mid R$ for some $p$,}\\
\ds \prod_{p\mid\mid R} -2 & \text{otherwise},

where the product is over primes that exactly divide R. Note that \overline{\mu} is not the Moebius function, but it has a similar flavor.

Proposition 6.4

The dimension of the new subspace is

\dim S_k(\Gamma_0(N))_{\new} = \sum_{M\mid N} \overline{\mu}(N/M)
\cdot \dim S_k(\Gamma_0(M)),

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

\dim S_k(\Gamma_0(N)) = \sum_{M\mid N} \sigma_0(N/M)
\dim S_k(\Gamma_0(M))_{\new},

where \sigma_0(N/M) is the number of divisors of N/M.

Example 6.5

We compute the dimension of the new subspace of S_k(\Gamma_0(N)) using the Sage command dimension_new_cusp_forms as follows:

sage: dimension_new_cusp_forms(Gamma0(11),12)
sage: dimension_cusp_forms(Gamma0(11),12)
sage: dimension_new_cusp_forms(Gamma0(2007),12)
sage: dimension_cusp_forms(Gamma0(2007),12)

Modular Forms for \Gamma_1(N)

This section follows Section Modular Forms for closely, but with suitable modifications with \Gamma_0(N) replaced by \Gamma_1(N).

Define functions of a positive integer N by the following formulas:

\mu_1(N) &=
\mu_0(N) & \text{if $N=1,2$,}\\
\ds\frac{\phi(N)\cdot \mu_0(N)}{2} & \text{otherwise,}
\end{cases} \\
\mu_{1,2}(N) &= \begin{cases}
0 & \text{if $N\geq 4$,}\\
\mu_{0,2}(N) & \text{otherwise,}
\mu_{1,3}(N) &= \begin{cases}
0 & \text{if $N\geq 4$,}\\
\mu_{0,3}(N) & \text{otherwise,}
c_1(N) &=
c_0(N) & \text{if $N=1,2$,}\\
3      & \text{if $N=4$,}\\
\ds \sum_{d \mid N} \frac{\phi(d)\phi(N/d)}{2} & \text{otherwise},
\end{cases} \\
g_1(N) &= 1 + \frac{\mu_1(N)}{12} - \frac{\mu_{1,2}(N)}{4} - \frac{\mu_{1,3}(N)}{3}
- \frac{c_1(N)}{2}.

Note that g_1(N) is the genus of the modular curve X_1(N) (associated to \Gamma_1(N)) and c_1(N) is the number of cusps of X_1(N).

Proposition 6.6

We have \dim S_2(\Gamma_1(N)) = g_1(N). If N\leq 2, then \Gamma_0(N)=\Gamma_1(N) so

S_k(\Gamma_1(N)) = \dim S_k(\Gamma_0(N)),

where \dim S_k(\Gamma_0(N)) is given by the formula of Proposition 6.1. If k\geq 3, let

a(N,k) = (k-1)(g_1(N)
- 1) + \left(\frac{k}{2} -1\right)\cdot c_1(N).

Then for N\geq 3,

\dim S_k(\Gamma_1(N)) =
a + 1/2 & \text{if $N=4$ and $2\nmid k$,}\\
a + \lfloor{} k/3\rfloor{} & \text{if $N=3$,}\\
a & \text{otherwise.}

The dimension of the Eisenstein subspace is as follows:

\dim E_k(\Gamma_1(N)) =
c_1(N) & \text{if $k\neq 2$,}\\
c_1(N)-1 & \text{if $k=2$.}

The dimension of the new subspace of M_k(\Gamma_1(N)) is

\dim S_k(\Gamma_1(N))_{\new} =
\sum_{M \mid N} \overline{\mu}(N/M) \cdot \dim S_k(\Gamma_1(M)),

where \overline{\mu} is as in the statement of Proposition 6.4.

Remark 6.7

Since M_k = S_k \oplus E_k, the formulas above for \dim S_k and \dim E_k also yield a formula for the dimension of M_k.

Figure 6.3

Dimension of S_2(\Gamma_1(N)) as a function of N.


The following table contains the dimension of S_k(\Gamma_1(N)) for some sample values of N and k:

$N$ & $S_2(\Gamma_1(N))$ & $S_3(\Gamma_1(N))$ &
      $S_4(\Gamma_1(N))$ & $S_{24}(\Gamma_1(N))$\\\hline
1 & 0 & 0 & 0 & 2\\
10 & 0 & 2 & 5 & 65\\
11 & 1 & 5 & 10 & 110\\
100 & 231 & 530 & 830 & 6830\\
389 & 6112 & 12416 & 18721 & 144821\\
1000 & 28921 & 58920 & 88920 & 688920\\
2007 & 147409 & 296592 & 445776 & 3429456\\
 100000 & 299792001 & 599792000 & 899792000 & 6899792000\\\hline

Example 6.8

We compute dimensions of spaces of modular forms for \Gamma_1(N):

sage: dimension_cusp_forms(Gamma1(2007),2)
sage: dimension_eis(Gamma1(2007),2)
sage: dimension_modular_forms(Gamma1(2007),2)

Modular Forms with Character

Fix a Dirichlet character \eps of modulus N, and let c be the conductor of \eps (we do not assume that \eps is primitive). Assume that \eps \neq 1, since otherwise M_k(N,\eps) = M_k(\Gamma_0(N)) and the formulas of Section Modular Forms for apply. Also, assume that \eps(-1)=(-1)^k, since otherwise \dim M_k(\Gamma_0(N)) = 0. In this section we discuss formulas for computing each of M_k(N,\eps), S_k(N,\eps) and E_k(N,\eps).

In [CO77], Cohen and Oesterl’e assert (without published proof; see Remark Remark 6.11 below) that for any k\in\Z and N, \eps as above,

\dim S_k(N,\eps) &- \dim M_{2-k}(N,\eps)\\
&= \frac{k-1}{12} \cdot \mu_0(N) \,\,-\,\,
\frac{1}{2} \cdot \prod_{p\mid N} \lambda(p, N, v_p(c))\\
&\qquad + \gamma_4(k) \cdot\!\!
\sum_{x \in A_4(N)} \eps(x) \,\,\,+\,\,\,
\gamma_3(k) \cdot \!\! \sum_{x \in A_3(N)} \eps(x)

where \mu_0(N) is as in Section Modular Forms for , A_4(N) = \{x \in \Z/N\Z : x^2 +1 = 0\} and A_3(N) = \{x \in \Z/N\Z : x^2 + x + 1 = 0 \}, and \gamma_3, \gamma_4 are

\gamma_4(k) &=
-1/4 & \text{if $k\con 2\pmod{4}$,}\\
1/4 & \text{if $k\con 0\pmod{4}$,}\\
0 & \text{if $k$ is odd.}
\gamma_3(k) &=
-1/3 & \text{if $k\con 2\pmod{3}$,}\\
1/3 & \text{if $k\con 0\pmod{3}$,}\\
0 & \text{if $k\con 1\pmod{3}$.}

It remains to define \lambda. Fix a prime divisor p\mid N and let r=v_p(N). Then

\lambda(p,N,v_p(c)) =
p^{\frac{r}{2}} + p^{\frac{r}{2} - 1} & \text{if $2\cdot v_p(c)\leq r$ and $2\mid r$,}\\
2\cdot p^{\frac{r-1}{2}} & \text{if $2\cdot v_p(c)\leq r$ and $2\nmid r$,}\\
2\cdot p^{r-v_p(c)} & \text{if $2\cdot v_p(c) > r$.}

This flexible formula can be used to compute the dimension of M_k(N,\eps), S_k(N,\eps), and E_k(N,\eps) for any N, \eps, k\neq 1, by using that

\dim S_k(N,\eps) &= 0 \qquad \text{if $k\leq 0$,}\\
\dim M_k(N,\eps) &= 0 \qquad \text{if $k<0$,}\\
\dim M_0(N,\eps) &= 1 \qquad \text{if $k=0$.}

One thing that is not straightforward when implementing an algorithm to compute the above dimension formulas is how to efficiently compute the sets A_4(N) and A_6(N). Kevin Buzzard suggested the following two algorithms. Note that if k is odd, then \gamma_4(k)=0, so the sum over A_4(N) is only needed when k is even.

Algorithm 6.9

Given a positive integer N and an even Dirichlet character \eps of modulus N, this algorithm computes \sum_{x \in A_4(N)} \eps(x).

  1. [Factor N] Compute the prime factorization p_1^{e_1} \cdots p_n^{e_n} of N.

  2. [Initialize] Set t\set 1 and i\set 0.

  3. [Loop Over Prime Divisors] Set i\set i+1. If i>n, return t. Otherwise set p\set p_i and e\set e_i.

    1. If p\con 3\pmod{4}, return 0.
    2. If p=2 and e>1, return 0.
    3. If p=2 and e=1, go to step (3).
    4. Compute a generator a\in (\Z/p\Z)^* using Algorithm 4.4.
    5. Compute \omega = a^{(p-1)/4}.
    6. Use the Chinese Remainder Theorem to find x\in\Z/N\Z such that x\con a\pmod{p} and x\con 1\pmod{N/p^e}.
    7. Set x \set x^{p^{r-1}}.
    8. Set s\set \eps(x).
    1. If s=1, set t\set 2t and go to step (3).
    1. If s=-1, set t\set -2t and go to step (3).


Note that \eps(-x)=\eps(x), since \eps is even. By the Chinese Remainder Theorem, the set A_4(N) is empty if and only if there is no square root of -1 modulo some prime power divisor of p. If A_4(N) is empty, the algorithm correctly detects this fact in steps (a)(b). Thus assume A_4(N) is nonempty. For each prime power p_i^{e_i} that exactly divides N, let x_i \in Z/N\Z be such that x_i^2 = -1 and x_i\con
1\pmod{p_j^{e_j}} for i \neq j. This is the value of x computed in steps (d)(g) (as one sees using elementary number theory).

The next key observation is that

(1)\prod_i (\eps(x_i) + \eps(-x_i)) =
\sum_{x \in A_4(N)} \eps(x),

since by the Chinese Remainder Theorem the elements of A_4(N) are in bijection with the choices for a square root of -1 modulo each prime power divisors of N. The observation (1) is a huge gain from an efficiency point of view—if N had r prime factors, then A_4(N) would have size 2^r, which could be prohibitive, where the product involves only r factors. To finish the proof, just note that steps (h)(j) compute the local factors \eps(x_i) + \eps(-x_i) = 2\eps(x_i), where again we use that \eps is even. Note that a solution of x^2+1 \con 0\pmod{p} lifts uniquely to a solution mod p^n for any n, because the kernel of the natural homomorphism (\Z/p^n\Z)^*
\to (\Z/p\Z)^* is a group of p-power order.

The algorithm for computing the sum over A_3(N) is similar.

For k\geq 2, to compute \dim S_k(N,\eps), use the formula directly and the fact that \dim M_{2-k}(N,\eps) = 0, unless \eps=1 and k=2. To compute \dim M_k(N,\eps) for k\geq 2, use the fact that the big formula at the beginning of this section is valid for any integer k to replace k by 2-k and that \dim S_k(N,\eps)=0 for k\leq 0 to rewrite the formula as

\dim M_k(N,\eps) &= - (\dim S_{2-k}(N,\eps) - \dim M_{k}(N,\eps))\\
&=-\Bigl( \frac{1-k}{12} \cdot \mu_0(N) \,\,-\,\,
\frac{1}{2} \cdot \prod_{p\mid N} \lambda(p, N, v_p(c))\\
&\qquad + \gamma_4(2-k) \cdot\!\!
\sum_{x \in A_4(N)} \eps(x) \,\,\,+\,\,\,
\gamma_3(2-k) \cdot \!\! \sum_{x \in A_3(N)} \eps(x)\Bigr).

Note also that for k=0, \dim E_k(N,\eps) = 1 if and only if \eps is trivial and it equals 0 otherwise. We then also obtain

\dim E_k(N,\eps) = \dim M_k(N,\eps) - \dim S_k(N,\eps).

We can also compute \dim E_k(N,\eps) when k=1 directly, since

\dim S_{2-1}(N,\eps) = \dim S_{1}(N,\eps).

The following table contains the dimension of S_k(N,\eps) for some sample values of N and k. In each case, \eps is the product of characters \eps_p of maximal order corresponding to the prime power factors of N (i.e., the product of the generators of the group D(N,\C^*) of Dirichlet characters of modulus N).

$N$ & $\dim S_2(N,\eps)$ & $\dim S_3(N,\eps)$ &
      $\dim S_4(N,\eps)$ & $\dim S_{24}(N,\eps)$\\\hline
1 & 0 & 0 & 0 & 2\\
10 & 0 & 1 & 0 & 0\\
11 & 0 & 1 & 0 & 0\\
100 & 13 & 0 & 43 & 343\\
389 & 0 & 64 & 0 & 0\\
1000 & 148 & 0 & 448 & 3448\\
2007 & 222 & 0 & 670 & 5150\\\hline

Example 6.10

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

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)
sage: dimension_cusp_forms(e,3)
sage: dimension_cusp_forms(e,4)
sage: dimension_cusp_forms(e,24)

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

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

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 S_k(G) and M_k(G) for more general congruence subgroups.

Let f be the conductor of a Dirichlet character \eps of modulus N. Then the dimension of the new subspace of M_k(N,\eps) is

\dim S_k(N,\eps)_{\new} =
\sum_{M\text{ such that }f \mid M \mid N} \overline{\mu}(N/M) \cdot \dim S_k(M,\eps'),

where \overline{\mu} is as in the statement of Proposition 6.4, and \eps' is the restriction of \eps mod M.

Example 6.12

We compute the dimension of S_2(2007,\eps)_{\new} for \eps a quadratic character of modulus 2007.

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


Exercise 6.1

Let \mu_0 and \mu_1 be as in this chapter.

  1. Prove that \mu_0(N) = [\SL_2(\Z):\Gamma_0(N)].
  2. Prove that for N\geq 3, \mu_1(N) = [\SL_2(\Z):\Gamma_1(N)]/2, so \mu_1(N) is the index of \Gamma_1(N) \cdot \{\pm 1\} in \PSL_2(\Z) = \SL_2(\Z)/\{\pm 1\}.

Exercise 6.2

Use Proposition 6.4 to find a formula for \dim S_k(\SL_2(\Z)). Verify that this formula is the same as the one in Corollary Corollary 2.16.

Exercise 6.3

Suppose either that N=1 or that N is prime and k=2. Prove that M_k(\Gamma_0(N))_{\new} = M_k(\Gamma_0(N)).

Exercise 6.4

Fill in the details of the proof of Algorithm 6.9.

Exercise 6.5

Implement a computer program to compute \dim S_k(\Gamma_0(N)) as a function of k and N.


[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.