1 Introduction

In the 1990s Hejhal [8] derived an algorithm to compute the Laplace eigenvalues and Fourier coefficients of Maass cusp forms for certain subgroups of \(\text {SL}_2(\mathbb {Z})\). In 2006 Strömberg, in his PhD thesis [21], further generalised this method to compute the eigenvalues of Maass cusp forms for congruence subgroups \(\Gamma _0(N)\) with a character. Whilst this algorithm is numerically stable in practice, it unfortunately relies on a heuristic argument and has not yet been proven to rigorously converge to true Maass cusp forms.

There has been progress towards numerically verifying numerical computations of Maass cusp forms, most notably from Booker, Strömbergsson and Venkatesh [5], who derived a method to numerically verify Maass cusp forms for \(\text {SL}_2(\mathbb {Z})\). Using this method they verified the first 10 Laplace eigenvalues to 100 decimal places. For general level N, there currently does not exist an algorithm to rigorously verify numerical computations of Maass cusp forms for \(\Gamma _0(N)\).

In this paper, we derive an algorithm to numerically compute and rigorously verify the Laplace and Hecke eigenvalues for Maass cusp forms for \(\Gamma _0(N)\) with N squarefree and trivial character. The main tool that we use is an explicit version of the Selberg trace formula with Hecke operators derived by Strömbergsson in [22]. The inclusion of the Hecke operators allows us to use linear algebra to help pick out individual eigenvalues.

The Selberg trace formula has been used for numerical computation before by Booker and Strömbergsson in [4] to numerically verify the Selberg eigenvalue conjecture. However those authors were focused on proving the non-existence of Maass forms in an interval, rather than computing individual examples. In the case of holomorphic modular forms, explicit versions of the Selberg trace formula have been used to compute bases of cusp forms, for example in [2].

The outline of the paper is as follows. In Sect. 2 we present the algorithm for computing and then rigorously verifying the Laplace eigenvalues and Hecke eigenvalues of Maass cusp forms for squarefree level and trivial character. In Sect. 3 we state the explicit form of the Selberg trace formula that we use and explain computational aspects on how to compute it. In Sect. 4 we choose and optimise the test function for the trace formula such that it maximises the precision of the computation. Finally, in Sect. 5 we state the computational results and show some numerical evidence towards the Ramanujan–Petersson conjecture, Sato–Tate conjecture and the Riemann hypothesis for L-functions of Maass cusp forms.

2 Algorithm

In this section, we derive the algorithm to compute and rigorously verify the Laplace and Hecke eigenvalues for Maass cusp forms of squarefree level N. The central tool used here is the Selberg trace formula with Hecke operators. The main idea here is to use linear algebra to remove the contribution of all the forms up to some limit and isolate just one form. We then use our approximation to this form to see how well it removes the remaining contribution.

2.1 Preliminary

Let \(\mathbb {H}= \{ z = x+iy \in \mathbb {C}\mid y > 0\}\) denote the hyperbolic upper half-plane. This is acted on by certain subgroups of the modular group \(\text {SL}_2(\mathbb {Z})\) via linear fractional transformations. For \(N \in \mathbb {N}\), the subgroups we shall consider in this paper are the Hecke congruence subgroups \(\Gamma _0(N) \subseteq \text {SL}_2(\mathbb {Z})\) defined by

$$\begin{aligned} \Gamma _0(N) = \left\{ \left. \begin{pmatrix} a&{}b\\ c&{}d \end{pmatrix} \in \text {SL}_2(\mathbb {Z}) \right| c \equiv 0 \quad mod N\right\} . \end{aligned}$$

A Maass cusp form for \(\Gamma _0(N)\) of weight 0 is a non-constant, smooth function \(f: \Gamma _0(N) \backslash \mathbb {H}\rightarrow \mathbb {C}\) that satisfies the following properties:

  1. (1)

    \(f(\gamma z) = f(z)\) for all \(z \in \mathbb {H}\) and \(\gamma \in \Gamma _0(N)\);

  2. (2)

    f vanishes at the cusps of \(\Gamma _0(N)\);

  3. (3)

    \(f \in L^2(\Gamma _0(N) \backslash \mathbb {H})\);

  4. (4)

    f is an eigenfunction of the Laplace–Beltrami operator \(\Delta \) on \(\mathbb {H}\) given by

    $$\begin{aligned} \Delta = -y^2 \left( \frac{\partial ^2}{\partial x^2} + \frac{\partial ^2}{\partial y^2} \right) . \end{aligned}$$

Now if \(K \mid N\), then \(\Gamma _0(N) \subseteq \Gamma _0(K)\). Notably, if f is a Maass cusp form of \(\Gamma _0(K)\), then f(kz) is a Maass cusp form of \(\Gamma _0(N)\) for all \(k \mid \frac{N}{K}\). Forms that arise like this for \(\Gamma _0(N)\) we call “oldforms”. We define “newforms” to be forms in the orthogonal complement (with respect to the Petersson inner product) of the space spanned by the oldforms.

In addition, we define the Hecke eigenvalues a(n) of a level N Maass form f by the relation

$$\begin{aligned} a(n) f = T_n f, \end{aligned}$$

where \(T_n\) is the nth Hecke operator, defined by

$$\begin{aligned} T_n f(z) = \frac{1}{\sqrt{|n|}} \underset{\begin{array}{c} ad=n\\ (a,N) = 1 \\ d> 0 \end{array}}{\sum } \sum _{j = 0}^{d-1} {\left\{ \begin{array}{ll} f \left( \frac{az + j}{d} \right) &{} \text {if } n > 0,\\ f \left( \frac{a \overline{z} + j}{d} \right) &{} \text {if } n < 0. \end{array}\right. } \end{aligned}$$

For newforms, we normalise the Hecke eigenvalues by setting \(a(1)=1\). Furthermore, we say a Maass form is even if \(a(-n) = a(n)\) and odd if \(a(-n) = -a(n)\). More information about the theory of Maass cusp forms can be found in Bump [7] and Iwaniec [9].

Consider the space of Maass newforms of level N, Laplace eigenvalue \(\lambda \) and trivial character, denoted by \(S_{\lambda }(N)\). Let \(\lbrace f_j \rbrace _{j=1}^{\infty }\) be a sequence of normalised Hecke eigenforms such that it is a basis for \(\bigoplus _{\lambda > 0} S_{\lambda }(N)\). Let \(\lambda _j\) denote the Laplace eigenvalue of \(f_j\) and assume that \(\lambda _1 \le \lambda _2 \le \cdots \). In addition, let \(a_j(n)\) be the Hecke eigenvalues for \(f_j\).

The Selberg trace formula allows us to compute

$$\begin{aligned} t(n,H) := \sum _{j=1}^{\infty } a_j(n) H(\lambda _j), \end{aligned}$$

for any non-zero \(n \in \mathbb {Z}\) with \((n,N) = 1\) and any sufficiently nice test function H. Using the Hecke relations, we compute that

$$\begin{aligned} \left( \sum _{m=1}^{M} c(m) a_j(m) \right) ^2 = \sum _{m_1 = 1}^{M} \sum _{m_2 = 1}^{M} c(m_1) c(m_2) \sum _{d | (m_1,m_2)} a_j \left( \frac{m_1 m_2}{d^2} \right) , \end{aligned}$$

for any sequence \(\lbrace c(m) \rbrace _{m=1}^{M}\) of real numbers, satisfying \(c(m) = 0\) whenever \((m,N) > 1\). Thus, defining

$$\begin{aligned} Q(c,H) := \sum _{j=1}^{\infty } \left( \sum _{m=1}^{M} c(m) a_j(m) \right) ^2 H(\lambda _j), \end{aligned}$$

we have

$$\begin{aligned} Q(c,H) = \sum _{m_1 = 1}^{M} \sum _{m_2 = 1}^{M} c(m_1) c(m_2) \sum _{d | (m_1,m_2)} t \left( \frac{m_1 m_2}{d^2}, H \right) . \end{aligned}$$
(1)

2.2 Computing the forms

Let H be a non-negative test function and let \(\widetilde{H}(\lambda ) = \lambda H(\lambda )\). Let Q and \(\widetilde{Q}\) denote the respective matrices of the quadratic forms Q(cH) and \(Q(c,\widetilde{H})\). Thus the approximations of the Laplace eigenvalues are the solutions to the generalised symmetric eigenvalue equation

$$\begin{aligned} \widetilde{Q}x = \lambda Q x. \end{aligned}$$
(2)

We solve this by first diagonalising \(Q = PDP^T\), where P is an orthogonal matrix and D is diagonal with positive entries. Then the solutions to (2) will just be the eigenvalues of \(D^{-1/2} P^T \widetilde{Q} P D^{-1/2}\). For each eigenvalue \(\widetilde{\lambda }_i\), we set \(c_i\) to be the corresponding eigenvector. We will use the components of \(c_i\) to form the sequence c(m) for each eigenvalue.

2.3 Verifying the forms

Firstly, for the verification we shall prove that there exists a Laplace eigenvalue near \(\widetilde{\lambda }_i\). For this, we define the Rayleigh quotient

$$\begin{aligned} \varepsilon _i := \sqrt{ \frac{Q(c_i,\widetilde{H}_i)}{Q(c_i,H)} }, \end{aligned}$$
(3)

where \(\widetilde{H}_i(\lambda ) = H(\lambda ) (\lambda - \widetilde{\lambda }_i)^2\), for the same \(c_i\) computed above. Then \(\varepsilon _{i}^{2}\) is a weighted average of \((\lambda - \widetilde{\lambda }_i)^2\) and hence there exists a cuspidal eigenvalue \(\lambda \in [\widetilde{\lambda }_i - \varepsilon _i, \widetilde{\lambda }_i + \varepsilon _i]\).

Next we prove completeness of the eigenvalues, i.e. prove that we have not missed any. We choose a test function \(H^*(\lambda )\) that is positive and monotonically decreasing for \(\lambda > 0\). Then \(H^*(\lambda ) \ge H^*(\widetilde{\lambda }_i + \varepsilon _i)\) for all \(\lambda \in [\widetilde{\lambda }_i - \varepsilon _i, \widetilde{\lambda }_i + \varepsilon _i]\). Hence any eigenvalue \(\lambda \) that is not contained in \(\bigcup _i [\widetilde{\lambda }_i - \varepsilon _i, \widetilde{\lambda }_i + \varepsilon _i]\) must satisfy

$$\begin{aligned} H^*(\lambda ) \le t(1,H^*) + \sum _i H^*(\widetilde{\lambda }_i + \varepsilon _i). \end{aligned}$$

Here the second sum ranges over all i such that \([\widetilde{\lambda }_i - \varepsilon _i, \widetilde{\lambda }_i + \varepsilon _i]\) does not overlap the corresponding interval for any smaller value of i. Since \(H^*\) is monotonic, this determines numbers \(\delta _i > 0\) such that \(|\lambda _i - \widetilde{\lambda }_i| \le \varepsilon _i\) and \(|\lambda _j - \widetilde{\lambda }_i|\ge \delta _i\) for \(j \in \mathbb {N}\backslash \lbrace i \rbrace \). Note that this approach only works well if the \(\lambda _i\) turn out to be distinct and well separated. It is conjectured that the Laplacian spectrum is simple for squarefree level and trivial character, with Poissonian spacing statistics. There exists some theoretical and numerical evidence for this, namely from [13] and [20] respectively. For this algorithm, we will see from the data that this will be the case.

Finally, we consider the Hecke eigenvalues. For \(j \ge 1\) and any sequence \(\lbrace c(m) \rbrace _{m = 1}^{M}\), define

$$\begin{aligned} L_j(c) = \sum _{m=1}^{M} c(m) a_j(m). \end{aligned}$$

Let \(H, \widetilde{H}_i\) be as above. Then

$$\begin{aligned} \left( \sum _{j \ne i} L_j(c_i) a_j(n) H(\lambda _j) \right) ^2&\le \sum _{j \ne i} L_j(c_i)^2 H(\lambda _j) \sum _{j=1}^{\infty } (a_j(n))^2 H(\lambda _j)\\&\le \delta _i^{-2} Q(c_i, \widetilde{H}_i) Q(e_n, H) = \varepsilon _i^2 \delta _i^{-2} Q(c_i, H) Q(e_n, H), \end{aligned}$$

where \(e_n(m) = 1\) if \(m=n\) and 0 otherwise. Thus, defining

$$\begin{aligned} \eta _{i,n} = \frac{\varepsilon _i}{\delta _i} \sqrt{Q(c_i, H) Q(e_n,H)} \quad and \quad W_i = L_i(c_i) H(\lambda _i), \end{aligned}$$
(4)

we have

$$\begin{aligned} A_i(n) := a_i(n) W_i = \sum _{m=1}^{M} c_i(m) \sum _{d | (m,n)} t \left( \frac{mn}{d^2}, H\right) + \beta _{i,n} \eta _{i,n}, \end{aligned}$$

where \(\beta _{i,n}\) is some real constant that depends on i and n and satisfies \(|\beta _{i,n}| \le 1\). We can use this to compute \(a_i(n)\), with \((n,N) = 1\), by using the fact that \(a_i(1)=1\) to compute \(W_i\) to a proven accuracy.

In practice, we will choose one test function H that is both positive and monotonically decreasing and use this throughout.

2.4 Computing \(a_n\) for \((n,N) > 1\) for squarefree level N

Let f be a primitive Maass newform of squarefree level N, Laplace eigenvalue \(\lambda = 1/4 + R^2\) and trivial character, with Fourier coefficients \(a_n\). By Atkin–Lehner theory [1] (see [21, §1.2.6] for non-holomorphic case), for each prime \(p \mid N\) we have \(a_p = \pm 1/\sqrt{p}\). Moreover, defining \(w = \mu (N) \sqrt{N} \prod _{p \mid N} a_p = \prod _{p|N} \text {sign}(-a_p)\), we have \(f(z) = w f(-1/Nz)\). Hence, we just need to find the signs of the \(a_p\) for \(p \mid N\), and then use the Hecke relations to find all \(a_n\) for \((n,N)>1\).

Suppose first that f is even, so its Fourier expansion is of the form

$$\begin{aligned} f(z) = \sum _{n=1}^{\infty } \frac{a_n}{\sqrt{n}} W_{iR}(2 \pi n y) \cos (2 \pi n x), \end{aligned}$$

where \(W_s(y) := \sqrt{y} K_s(y)\) and \(K_s(y)\) is the K-Bessel function. Substituting \(z=iy\) into the relation \(f(z) = w f(-1/Nz)\), we have

$$\begin{aligned} \sum _{n=1}^{\infty } \frac{a_n}{\sqrt{n}} \left( W_{iR}(2 \pi n y) - w W_{iR} \left( \frac{2 \pi n}{Ny}\right) \right) = 0. \end{aligned}$$
(5)

If \(w = -1\) then taking \(y = 1/\sqrt{N}\) in (5) yields

$$\begin{aligned} \sum _{n=1}^{\infty } \frac{a_n}{\sqrt{n}} W_{iR} \left( \frac{2 \pi n}{\sqrt{N}} \right) = 0. \end{aligned}$$

If \(w = 1\) then taking \(y = \sqrt{2/N}\) in (5) yields

$$\begin{aligned} \sum _{n=1}^{\infty } \frac{a_n}{\sqrt{n}} \left( W_{iR} \left( \frac{2 \pi n \sqrt{2}}{\sqrt{N}} \right) - W_{iR} \left( \frac{\pi n \sqrt{2}}{\sqrt{N}} \right) \right) = 0. \end{aligned}$$

Now suppose f is odd, so its Fourier expansion takes the form

$$\begin{aligned} f(z) = \sum _{n=1}^{\infty } \frac{a_n}{\sqrt{n}} W_{iR}(2 \pi n y) \sin (2 \pi n x). \end{aligned}$$

In this case plugging in \(z=iy\) would only give the trivial relation \(0=0\), so instead we first differentiate with respect to x. For this we consider

$$\begin{aligned} \frac{\partial }{\partial x} (f(z) - w f(-1/Nz))|_{z=iy} = 0. \end{aligned}$$

After some computation this yields

$$\begin{aligned} \sum _{n=1}^{\infty } a_n \sqrt{n} \left( W_{iR}(2 \pi n y) + \frac{w}{N y^2} W_{iR} \left( \frac{2 \pi n}{Ny} \right) \right) =0. \end{aligned}$$
(6)

If \(w=1\) then taking \(y=1/\sqrt{N}\) in (6) yields

$$\begin{aligned} \sum _{n=1}^{\infty } a_n \sqrt{n} W_{iR} \left( \frac{2 \pi n}{\sqrt{N}} \right) = 0. \end{aligned}$$

If \(w=-1\) then taking \(y=\sqrt{2/N}\) in (6) yields

$$\begin{aligned} \sum _{n=1}^{\infty } a_n \sqrt{n} \left( W_{iR} \left( \frac{2 \pi n \sqrt{2}}{\sqrt{N}} \right) - \frac{1}{2} W_{iR} \left( \frac{\pi n \sqrt{2}}{\sqrt{N}} \right) \right) = 0. \end{aligned}$$

In summary, if we define

$$\begin{aligned} W(y) = {\left\{ \begin{array}{ll} W_{iR}(y) &{} \text {if}~ f \text {is even and}\, w=-1, \\ W_{iR}(y\sqrt{2}) - W_{iR}(y/\sqrt{2}) &{} \text {if}\, f \text {is even and}~ w=1,\\ \frac{y \sqrt{N}}{2 \pi } W_{iR}(y) &{} \text {if}\, f \, \text {is odd and}~ w=1,\\ \frac{y \sqrt{N}}{2 \pi } \left( W_{iR}(y\sqrt{2}) - \frac{1}{2}W_{iR}(y/\sqrt{2})\right) &{} \text {if}~ f\, \text {is odd and}\, w=-1, \end{array}\right. } \end{aligned}$$

then

$$\begin{aligned} \sum _{n=1}^{\infty } \frac{a_n}{\sqrt{n}} W \left( \frac{2 \pi n}{\sqrt{N}} \right) = 0. \end{aligned}$$

Now computationally we will only have accurate approximations of \(a_n\) for \(n \le M\), so we must truncate the above sums at M and estimate the error incurred. Using the current best estimate towards to Ramanujan–Petersson conjecture from Kim–Sarnak [12], we have \(|a_p| \le p^{7/64} + p^{-7/64}\), which implies \(|a_n/\sqrt{n}| \le \theta \approx 1.758\). We also have that

$$\begin{aligned} |W_{iR}(y)| \le \sqrt{\frac{\pi }{2}} e^{-y} \text { for } y > 0. \end{aligned}$$

With both of these results we can easily find bounds for the tails of the sums and obtain

$$\begin{aligned} \left| \sum _{n=M+1}^{\infty } \frac{a_n}{\sqrt{n}} W \left( \frac{2 \pi n}{\sqrt{N}} \right) \right| \le {\left\{ \begin{array}{ll} \theta \sqrt{\frac{\pi }{2}} \frac{\exp \left( - \frac{2 \pi M}{\sqrt{N}} \right) }{\exp \left( \frac{2 \pi }{\sqrt{N}} \right) -1} &{} \text {if}~ f\, \text {is even and}\, w=-1, \\ 2\theta \sqrt{\frac{\pi }{2}} \frac{\exp \left( -\frac{\pi M \sqrt{2}}{\sqrt{N}} \right) }{\exp \left( \frac{\pi \sqrt{2}}{\sqrt{N}} \right) -1} &{} \text {if}~ f\, \text {is even and}\, w=1,\\ \theta \sqrt{\frac{\pi }{2}} \frac{\left( (M+1) \exp \left( \frac{2 \pi }{\sqrt{N}} \right) - M\right) }{ \exp \left( \frac{2 \pi M}{\sqrt{N}} \right) \left( \exp \left( \frac{2 \pi }{\sqrt{N}} \right) - 1\right) ^2} &{} \text {if}~ f\, \text {is odd and}\, w=1,\\ \frac{3 \theta }{2} \sqrt{\frac{\pi }{2}} \frac{ \left( (M+1) \exp \left( \frac{\pi \sqrt{2}}{\sqrt{N}} \right) - M\right) }{\exp \left( \frac{\pi M \sqrt{2}}{\sqrt{N}} \right) \left( \exp \left( \frac{\pi \sqrt{2}}{\sqrt{N}} \right) - 1\right) ^2} &{} \text {if}~ f \,\text {is odd and}\, w=-1. \end{array}\right. } \end{aligned}$$

To find the signs of the \(a_p\) for \(p \mid N\) we just test every combination of \(\pm 1\) for the signs of the \(a_p\), then use this to compute w and the corresponding sum from the above cases. Heuristically, we expect only one of these sums to be within the error derived. When there is only one sum within the errors, we can say that the result is rigorous. We then take the signs of the \(a_p\) for \(p \mid N\) and w from that sum. In practice we see this works well, provided the Laplace eigenvalue and Hecke eigenvalues are computed to a high enough precision.

3 The Selberg trace formula for squarefree level N

In the algorithm given in Sect. 2, an essential tool we need is an explicit version of the Selberg trace formula with Hecke operators. Currently, this has only been derived for squarefree level by Strömbergsson in [22]. For our computation, we rewrite this in the following form, following the steps of Proposition 2.2 in [3].

Theorem 3.1

(The Selberg trace formula for Maass newforms for squarefree level and trivial character) Fix \(\delta > 0\), let h(t) be a even analytic function on the strip \(\lbrace t \in \mathbb {C}:\text {Im}(t) \le \frac{1}{2} + \delta \rbrace \) such that \(h(r) \in \mathbb {R}\) for \(r \in \mathbb {R}\) and \(h(r) = O((1 + |r|^2)^{-1-\delta })\). Define g as the Fourier transform of h given by

$$\begin{aligned} g(u) = \frac{1}{2 \pi } \int _{-\infty }^{\infty } h(r) e^{-iru} dr. \end{aligned}$$

Let \(\lbrace f_j \rbrace \) be a sequence of normalised Hecke eigenforms of squarefree level N, with Laplacian eigenvalues \(\lambda _j = \frac{1}{4} + r_j^2\) and respective Hecke eigenvalues \(a_j(n)\).

Then, for \((N,n)=1\) we have

$$\begin{aligned}&\frac{\mu (N) \sigma _1(|n|)}{\sqrt{|n|}} h \left( \frac{i}{2} \right) + \sum _{j> 0} h(r_j) a_j(n)\\&\quad = \underset{\begin{array}{c} t \in \mathbb {Z}\\ \sqrt{D} = \sqrt{t^2 - 4n} \not \in \mathbb {Q} \end{array}}{\sum } c_N(D) \cdot {\left\{ \begin{array}{ll} g \left( \log \left( \frac{(|t| + \sqrt{D})^2}{4 |n|} \right) \right) &{} \text {if } D> 0,\\ \frac{\sqrt{|D/4n|}}{2 \pi } \int _{-\infty }^{\infty } \frac{g(u) \cosh (u/2)}{\sinh ^2(u/2) + |D/4n|}du &{} \text {if } D < 0 \end{array}\right. }\\&\qquad +\Lambda (N) \underset{\begin{array}{c} ad = n \\ a>0 \\ a \ne d \end{array}}{\sum } \frac{ g\left( \log \left| \frac{a}{d} \right| \right) }{(N^{\infty },|a-d|)} - 2\Lambda (N) \underset{\begin{array}{c} ad = n \\ a>0 \end{array}}{\sum } \sum _{r=0}^{\infty } N^{-r} g\left( \log \left| \frac{a}{d} \right| - 2r \log (N)\right) \\&\qquad +{\left\{ \begin{array}{ll} -\frac{\prod _{p|N}(p-1)}{12 \sqrt{n}} \int _{-\infty }^{\infty } \frac{g'(u)}{\sinh \left( \frac{u}{2} \right) }du &{} if \sqrt{n} \in \mathbb {Z}, \\ 0 &{} otherwise, \end{array}\right. }\\ \end{aligned}$$

where

$$\begin{aligned} c_N(D)&= L(1,\psi _D) \prod _{p|N} (\psi _d(p) - 1)\\&= \frac{L(1, \psi _d)}{l} \prod _{p|N} (\psi _d(p) - 1) \prod _{p | l} \left[ 1 + (p - \psi _d(p)) \frac{(l,p^{\infty }) - 1}{p-1} \right] , \end{aligned}$$

with \(D = dl^2\), \(l>0\), d a fundamental discriminant and \(\psi _d(p) = \left( \frac{d}{p} \right) \). Here \((l,p^{\infty })\) denotes the largest power of p that divides l.

Remark 1

We refer to the terms in the sum with \(D>0\) as the hyperbolic terms and the terms \(D<0\) as the elliptic terms. The terms that are multiplied by the von Mangoldt function \(\Lambda (N)\) we call the parabolic terms, and the term when \(\sqrt{n} \in \mathbb {Z}\) we call the identity term.

3.1 Computational remarks

The main numerical bottleneck of computing the trace formula is from the contribution of the hyperbolic terms, which involves computing the class number and regulator of \(\mathbb {Q}(\sqrt{D})\). For numerical stability, it is best to consider a test function g that is compactly supported. This allows one to compute the terms on the geometric side to arbitrary precision with a fixed finite list of class numbers. Precisely we would need class numbers \(h_{\mathbb {Q}(\sqrt{D})}\) for \(D = t^2 - 4n < (2n\cosh (X/2))^2\). For our computation, we used Pari [14] to compute these real class numbers and regulators, and verified the calculations with [10].

We can also get a bonus increase in the precision by considering the parity of the forms separately. The traces are given by \(\frac{1}{2} (t(n,h) + t(-n,h))\) and \(\frac{1}{2} (t(n,h) - t(-n,h))\) for the even and odd forms respectively.

Computing the integrals appearing in the elliptic terms to arbitrary precision can also be challenging given the large number of them appearing for values of D and n. We can remedy this by noting that \(|D/4n| \in (0,1]\) for \(D = t^2 - 4n < 0\), and considering the integrals as functions \(f:(0,1] \rightarrow \mathbb {R}\) defined by

$$\begin{aligned} f(x) = \int _{0}^{\infty } \frac{g(u) \cosh (u/2)}{\sinh ^2(u/2) + x}du. \end{aligned}$$

This function is analytic with respect to the variable x, hence we can approximate this integral with a Taylor series, where the only integrals we need to compute are given in the Taylor coefficients. Explicitly, for x near \(x_0\), we can approximate f(x) by

$$\begin{aligned} f(x) = \sum _{k=0}^{K} \frac{f^{(k)}(x_0)}{k!} (x-x_0)^k + R_K(x), \end{aligned}$$

where \(R_K(x)\) is the error term given by

$$\begin{aligned} R_K(x) = \frac{f^{(K+1)}(\xi )}{(K+1)!} (x-x_0)^{K+1}, \end{aligned}$$

for some \(\xi \) in the closed interval between x and \(x_0\). To find the Taylor coefficients, we use Leibniz’s integral rule to get

$$\begin{aligned} \frac{d^k}{dx^k} f(x) = k! (-1)^k \int _0^{\infty } \frac{g(u) \cosh (u/2)}{(\sinh ^2(u/2) + x)^{k+1}}du. \end{aligned}$$

To bound the error term, let \(\xi \in [x_0,x]\) and \(M_g = \max _{y \in [0,\infty )} |g(y)|\). Then

$$\begin{aligned} |f^{(K+1)}(\xi )|&= (K+1)! \left| \int _0^{\infty } \frac{g(u) \cosh (u/2)}{(\sinh ^2(u/2) + \xi )^{K+2}}du \right| \\&\le M_g (K+1)! \int _0^{\infty } \frac{\cosh (u/2)}{(\sinh ^2(u/2) + \xi )^{K+2}}du. \end{aligned}$$

Here we have that

$$\begin{aligned} \int _0^{\infty } \frac{\cosh (u/2)}{(\sinh ^2(u/2) + \xi )^{K+2}}du = \pi \xi ^{-3/2-K} \prod _{k=1}^{K+1} \left( \frac{2k-1}{2k}\right) . \end{aligned}$$

Hence we can bound the error term in the Taylor series by

$$\begin{aligned} |R_K(x)| \le \frac{\pi M_g}{\sqrt{x_0}} \left| 1 - \frac{x}{x_0}\right| ^{K+1} \prod _{k=1}^{K+1} \left( \frac{2k-1}{2k}\right) . \end{aligned}$$

To compute all the elliptic integrals, we shall need to choose the sample points for our Taylor series, such that it minimises the number of Taylor coefficients that are needed to be computed. Since there is a singularity at \(x=0\), it is best for us to choose our sampling points geometrically, that is \(x_j = c^{-j}\) for some \(c>1\). Suppose, we take K terms of a Taylor expansion around the point \(x_j\), we can see that error is of size about \(|1-x/x_0|^{K}\). For our sample points, we have

$$\begin{aligned} \left| 1 - \frac{x}{x_0}\right| \le \left( \frac{c-1}{c+1} \right) , \end{aligned}$$

hence the worst our error could be is \(\left( \frac{c-1}{c+1} \right) ^K\). Note, that given x we can choose \(j = \lceil \log _c(\frac{2}{(c+1)x}) \rceil \). Thus to choose the number of sampling points needed, we just consider the smallest value of x that we could feasibly have.

We see that the number of sample points is about \(\log _c n\), where n is the largest Hecke operator we shall need to consider. So in total we have to compute about \(K \log _c n\) integrals, and we want to minimise this with respect to the constraint that \(\left( \frac{c-1}{c+1} \right) ^K < \varepsilon \) for some fixed error tolerance \(\varepsilon \). This surprisingly has the exact solution with \(c = 1+\sqrt{2}\) and \(K = \log _c(1/\varepsilon )\).

4 Choice of test function

As stated in Sects. 2 and 3, we will want a test function that is even, positive and monotonically decreasing. Moreover, to aid in computations, we will also want g, the Fourier transform of h, to be compactly supported. This will make all the integrals and sums on the geometric side have finite bounds which will help when implementing the algorithm.

4.1 Candidate test function

A good initial function to consider is powers of the \(\text {sinc}(x) = \sin (x)/x\) function. For even powers, this is a positive even function with a compactly supported Fourier transform. However, this function is not monotonically decreasing. To remedy this we consider the test function

$$\begin{aligned} h_1(t) = \frac{\pi ^2}{\pi ^2 + 4} \left[ \text {sinc}^2\left( \frac{t}{2} \right) + \frac{1}{2} \text {sinc}^2\left( \frac{t-\pi }{2} \right) + \frac{1}{2} \text {sinc}^2\left( \frac{t+\pi }{2} \right) \right] , \end{aligned}$$

and let \(h_d(t) = h_1(t)^d\) for \(d \in \mathbb {N}\). Then \(h_d(t)\) is a positive, even and monotonically decreasing function on \(\mathbb {R}_{>0}\), satisfying \(h_d(0)=1\) and

$$\begin{aligned} h_d(t) \sim \left( \frac{4 \pi ^2}{\pi ^2 + 4} \right) ^d t^{-2d}, \end{aligned}$$

as \(|t| \rightarrow \infty \). Moreover, its Fourier transform

$$\begin{aligned} g_d(x) = \frac{1}{\pi } \int _0^{\infty } h_d(t) \cos (t x) dt, \end{aligned}$$

is compactly supported on \([-d,d]\). For a fixed d we can express \(g_d\) in the form

$$\begin{aligned} g_d(x) = \sum _{m \in \lbrace -1,0,1 \rbrace } A_m(x) e^{\pi i m x}, \end{aligned}$$

where

$$\begin{aligned} A_m(x) = A_{m,j} \left( x - j - \frac{1}{2}\right) \quad for x \in [j,j+1), j \in \lbrace -d, \ldots , d-1 \rbrace , \end{aligned}$$

for some \(A_{m,j} \in \mathbb {C}[x]\) satisfying \(A_{m,-1-j}(x) = A_{-m,j}(-x) = \overline{A_{m,j}(-x)}\). Note that all the \(A_{m,j}\) are determined by those with \(m \in \lbrace 0,1 \rbrace \) and \(j \in \lbrace 0,\ldots ,d-1 \rbrace \).

Specifically, for \(d=1\), we have

$$\begin{aligned} A_{0,0}(x) = \frac{\pi ^2}{\pi ^2 + 4} \left( \frac{1}{2}-x\right) \quad and \quad A_{1,0}(x) = \frac{1}{2} A_{0,0}(x). \end{aligned}$$

For \(d>1\), we compute the functions using convolutions. More explicitly, suppose we are given functions

$$\begin{aligned} A(x) = \sum _{m \in \{ -1,0,1 \}} A_m(x) e^{\pi i m x} \quad and \quad B(x) = \sum _{m \in \{ -1,0,1 \}} B_m(x) e^{\pi i m x}, \end{aligned}$$

and we wish to compute their convolution \(C = A*B\), which is again a function of the same form. For a set S, we define the indicator function \({\textbf {1}}_S(x) = 1\) if \(x \in S\) and 0 if \(x \not \in S\). It suffices to consider the constituent functions

$$\begin{aligned} A_{m,j}\left( x-j-\frac{1}{2} \right) e^{\pi i m x}{} {\textbf {1}}_{[j,j+1)}(x) \quad and \quad B_{n,k}\left( x-k-\frac{1}{2} \right) e^{\pi i n x}{} {\textbf {1}}_{[k,k+1)}(x), \end{aligned}$$

with convolution

$$\begin{aligned} \int _{\mathbb {R}} A_{m,j}\left( y-j-\frac{1}{2} \right) e^{\pi i m y}{} {\textbf {1}}_{[j,j+1)}(y) B_{n,k}\left( x-y-k-\frac{1}{2} \right) e^{\pi i n (x-y)}{} {\textbf {1}}_{[k,k+1)}(x-y)dy. \end{aligned}$$

Consider \(x \in [j+k+\delta ,j+k+\delta +1)\) for some \(\delta \in \{ 0,1 \}\), and let \(t = x - \left( j+k+\delta + \frac{1}{2} \right) \). We make the change of variable \(y \mapsto y + j + \frac{1}{2}\) to get

$$\begin{aligned}&\int _{\mathbb {R}} A_{m,j}(y) e^{\pi i m \left( y+j+\frac{1}{2}\right) } {\textbf {1}}_{\left[ -\frac{1}{2}\right. , \left. \frac{1}{2}\right) }(y)B_{n,k} \left( t + \delta - \frac{1}{2} -y \right) e^{\pi i n \left( x - y - j - \frac{1}{2}\right) } {\textbf {1}}_{(t+\delta -1,t+\delta ]}(y)dy \nonumber \\&\quad = e^{\pi i (m-n) \left( j + \frac{1}{2} \right) + \pi i n x} (-1)^{\delta } \int _{\delta - \frac{1}{2}}^{t} A_{m,j}(y) B_{n,k} \left( t + \delta - \frac{1}{2} - y\right) e^{\pi i (m-n)y} dy. \end{aligned}$$
(7)

When \(m \ne n\) we apply repeated integration by parts to see that (7) becomes

$$\begin{aligned}&e^{\pi i (m-n) \left( j + \frac{1}{2} \right) + \pi i n x} (-1)^{\delta } \sum _{r=0}^{\deg {A_{m,j}}} \sum _{s=0}^{\deg {B_{n,k}}} \frac{(-1)^s \left( {\begin{array}{c}r+s\\ s\end{array}}\right) }{(-\pi i (m-n))^{r+s+1}}\\&\qquad \cdot \left( A_{m,j}^{(r)} \left( \delta - \frac{1}{2} \right) B_{n,k}^{(s)}(t) e^{\pi i (m-n) \left( \delta - \frac{1}{2} \right) } - A_{m,j}^{(r)}(t) B_{n,k}^{(s)} \left( \delta - \frac{1}{2} \right) e^{\pi i (m-n)t} \right) \\&\quad = (-1)^{(m-n+1) \delta } \sum _{r=0}^{\deg {A_{m,j}}} \sum _{s=0}^{\deg {B_{n,k}}} \frac{(-1)^s \left( {\begin{array}{c}r+s\\ s\end{array}}\right) }{(-\pi i (m-n))^{r+s+1}}\\&\qquad \cdot \left( A_{m,j}^{(r)} \left( \delta - \frac{1}{2} \right) B_{n,k}^{(s)}(t) (-1)^{(m-n)j} e^{\pi i n x} - A_{m,j}^{(r)}(t) B_{n,k}^{(s)} \left( \delta - \frac{1}{2} \right) (-1)^{(m-n)k}e^{\pi i m x} \right) . \end{aligned}$$

Note that this will contribute to both the \(C_{m,j+k+\delta }\) and \(C_{n,j+k+\delta }\) terms.

When \(m=n\), we define polynomials \(P_{\delta ,l} \in \mathbb {C}[y]\) such that \(P_{\delta ,0} = A_{m,j}(y)\) and

$$\begin{aligned} P_{\delta ,l} = \int _{\delta - \frac{1}{2}}^{y} P_{\delta ,l-1}(u)du, \end{aligned}$$

for \(l \ge 1\). Then applying integration by parts, (7) becomes

$$\begin{aligned} (-1)^{\delta } \sum _{l=1}^{\deg {B_{n,k}}+1} B_{n,k}^{(l-1)} \left( \delta - \frac{1}{2} \right) P_{\delta ,l}(t) e^{\pi i m x}. \end{aligned}$$

4.2 Optimising the test function

We wish to optimise the decay of the test function for certain given constants such that we maximise the precision with which we compute the trace formula. Suppose we aim for a final precision of B bits. Due to the square roots in (3) and (4), we must consider terms larger than \(2^{-2B}\) to be significant, and use a working precision of at least 2B bits. Let \(X \in \mathbb {R}_{>0}, d \in \mathbb {N}\) and consider the test function

$$\begin{aligned} h(r) = h_d \left( \frac{Xr}{d} \right) . \end{aligned}$$
(8)

From this we see that g, the Fourier transform of h, is compactly supported on \([-X,X]\). We take the edge of the precision window to be the point \(R_{\mathrm{max}}\) at which

$$\begin{aligned} h(R_{\mathrm{max}}) = h_1(XR_{\mathrm{max}}/d)^d = 2^{-2B}. \end{aligned}$$
(9)

Fix a level N. Let M be the number of level N newforms with trivial character, fixed parity and Laplace eigenvalue \(\lambda \le \frac{1}{4} +R_{\mathrm{max}}^2\) and let \(D_{\mathrm{max}}\) be the largest size of discriminant appearing in the hyperbolic sum. The value M will control the size of the matrices appearing in the linear algebra and \(D_{\max }\) will control how many hyperbolic terms will appear. We want the ability to choose these values since these are the main sections of the algorithm that are constrained by external factors. For example, we will only have a list of class numbers up to a certain limit that that could feasibly be computed. The idea of this section is to first fix NM and \(D_{\mathrm{max}}\), then find \(R_{\mathrm{max}},X\) and d such that it maximises the precision B.

So fix NM and \(D_{\mathrm{max}}\). To find \(R_{\mathrm{max}}\), we have from [15] that

$$\begin{aligned} M = \frac{R_{\mathrm{max}}^2}{24}N + O( \sqrt{\lambda } \log {\lambda }), \end{aligned}$$

which we can rearrange to compute \(R_{\mathrm{max}}\) by

$$\begin{aligned} R_{\mathrm{max}} \approx \sqrt{\frac{24M}{N}}. \end{aligned}$$

To find X, we use the fact that g is compactly supported on \([-X,X]\) and hence, we have that

$$\begin{aligned} D_{\mathrm{max}} = \left( 2M\cosh \left( \frac{X}{2} \right) \right) ^2, \end{aligned}$$

which we can rearrange to compute X by

$$\begin{aligned} X = 2\cosh ^{-1} \left( \frac{\sqrt{D_{\mathrm{max}}}}{2M} \right) . \end{aligned}$$

Once we have values for \(R_{\mathrm{max}}\) and X, we can find d by first rearranging (9) to obtain

$$\begin{aligned} -\log _2 \left( h_1 \left( \frac{XR_{\mathrm{max}}}{d} \right) \right) d = 2B. \end{aligned}$$

We can now find a d which maximises the left side of this equation, which in turn will maximise our final precision B. Note that since \(d \in \mathbb {N}\), we can find the maximum by sampling the left side of the equation over integer values of d and choosing the largest value.

Thus, once we have computed these values, the test function we use for the computation is given by (8). In practice, when choosing the level N, we pick N to be the largest level we are computing with and use this test function for all smaller levels as well.

5 Computational results

5.1 Computing the forms

We implemented this algorithm in the C programming language, predominately using the ball-arithmetic library Arb [11] throughout our computations to manage round-off errors. For the main computation, following the notation from Sect. 4.2, we chose the numbers \(D_{\mathrm{max}} = 10^9,M = 2000\) and the maximum level we consider is \(N = 105\). Using SageMath [23], we find \(X \approx 5.51341, R_{\mathrm{max}} \approx 21.38089, d=13\) and \(2B \approx 63\).

With these numbers, we computed a total of 33214 Laplace eigenvalues of Maass cusp forms, each with all Hecke eigenvalues \(a_n\) with \(n \le 2000\) and \((n,N)=1\), for squarefree levels \(2 \le N \le 105\). The range of the \(\varepsilon _i\)’s computed is between \(10^{-15}\) and \(10^{-2}\). Of these forms 17243 are even and 15971 are odd.

Of these Laplace eigenvalues, we proved completeness for 16207 of them and hence, their Hecke eigenvalues have rigorous error bounds. We could only compute completeness for all prime levels \(2 \le N \le 67\) and all composite squarefree levels \(6 \le N \le 105\) due to the precision of the computed trace formula values in the linear algebra. Each of these complete Laplace eigenvalues will correspond to a provably unique Maass cusp form. Of these forms 8419 are even and 7788 are odd.

We observed that the closest distance between two Maass forms in the completed range was approximately \(3 \times 10^{-6}\) from the level 23 Laplace eigenvalues of \(10.85166055 \ldots \) and \(10.8516021 \ldots \). The closest distance between two even forms was approximately \(1.4 \times 10^{-5}\) from the level 53 Laplace eigenvalues of \(5.876312 \ldots \) and \(5.876299 \ldots \). The closest distance between two odd forms was approximately \(3 \times 10^{-6}\) from the level 55 Laplace eigenvalues of \(8.350572 \ldots \) and \(8.350569 \ldots \).

The entire computation took just under two weeks of time on 64 cores of 2.5GHz AMD Opteron processors. As predicted, the computation was dominated by computing the hyperbolic terms.

5.2 Ramanujan–Petersson conjecture

The Ramanujan–Petersson conjecture states that for prime p, the pth Fourier coefficient \(a_p\) for a Maass cusp form on \(\Gamma _0(N)\) should satisfy \(|a_p| \le 2\). For the data we computed, we verified this was true for all Hecke eigenvalues with \(p \le 2000\) for 13271 of our Maass forms that we proved completeness for.

5.3 Sato–Tate conjecture

The Sato–Tate conjecture is a statistical conjecture about the asymptotic distribution of eigenvalues \(a_p\) of Hecke operators \(T_p\) for primes p. It states that the \(a_p\) should be asymptotically distributed with the Sato–Tate measure given by

$$\begin{aligned} \mu _{\infty } = \frac{1}{\pi } \sqrt{1 - \frac{x^2}{4}} dx, \end{aligned}$$

as \(p \rightarrow \infty \). A related result, proven by Sarnak in [17], states that instead if we fix a prime \(p \not \mid N\) and let the level tend to infinity, then the points \(a_p\) of these forms are asymptotically distributed by the measure

$$\begin{aligned} \mu _p = f_p \mu _{\infty }, \end{aligned}$$

where

$$\begin{aligned} f_p(x) = \frac{p+1}{(p^{1/2} + p^{-1/2})^2 - x^2}, \end{aligned}$$

for \(x \in [-2,2]\). As an example, for \(p=2\), the points should be distributed asymptotically with respect to

$$\begin{aligned} \mu _2 = \frac{3 \sqrt{4-x^2}}{9 - 2x^2} \frac{dx}{\pi }. \end{aligned}$$
(10)

We used the Maass form data to create Fig. 1, which illustrates a strong connection to the predicted result of the Sato–Tate conjecture and the result proven by Sarnak.

Fig. 1
figure 1

Comparison of our data to predicted distributions. The left-hand figure concerns the distribution of the classical Sato–Tate conjecture; the histogram has 10003411 data points in 3162 bins. The right-hand figure compares our data to Sarnak’s theorem [17] for \(a_2\); the histogram has 23806 data points in 154 bins

Fig. 2
figure 2

Plot of the Z-function on the critical line associated to the first level 105 Maass cusp form with Laplace eigenvalue \(R = 0.4366582 \ldots \)

5.4 L-function and the Riemann hypothesis

Let f be a Maass cusp form, with Laplace eigenvalue \(\lambda = \frac{1}{4} + R^2\), of level N and trivial character. Moreover, let \(a_f(n)\) be the Hecke eigenvalues of f. We define the associated L-function to f by

$$\begin{aligned} L_f(s) = \sum _{n=1} \frac{a_f(n)}{n^s}, \end{aligned}$$

where \(\text {Re}(s) > 1\). This can be analytically continued to the whole complex plane and satisfies the functional equation

$$\begin{aligned} \Lambda _f(s) = N^{\frac{s}{2}}\Gamma _{\mathbb {R}}(s + a + iR) \Gamma _{\mathbb {R}}(s + a - iR) L_f(s) = \omega (-1)^a \Lambda _f(1-s), \end{aligned}$$

where

  • \(\Gamma _{\mathbb {R}}(s) = \pi ^{-s/2} \Gamma (s/2),\)

  • \(\omega \) is the eigenvalue of the Fricke involution given by \(f(z) = \omega f \left( -\frac{1}{Nz} \right) \),

  • \(a=0\) if f is even and \(a=1\) if f is odd.

It is conjectured, analogous to the Riemann zeta function, that L-functions associated to Maass cusp forms on \(\Gamma _0(N)\) satisfy a Riemann hypothesis, that is all the zeros of \(L_f(s)\) in the strip \(\lbrace s \in \mathbb {C}| 0< \text {Re}(s) < 1 \rbrace \) lie on the line \(s = 1/2 + it, t \in \mathbb {R}\). When computing zeros on the critical line of these L-functions, it is easier to work with the associated real-valued Z-function, defined by

$$\begin{aligned} Z(t) = \bar{\varepsilon }^{1/2} \frac{\gamma (1/2+it)}{|\gamma (1/2+it)|} L_f(1/2+it), \end{aligned}$$

where \(\gamma (s) = N^{\frac{s}{2}}\Gamma _{\mathbb {R}}(s + a + iR) \Gamma _{\mathbb {R}}(s + a - iR)\) and \(\varepsilon = \omega (-1)^a\). Since \(|Z(t)| = |L_f(1/2+it)|\), they share the same zeros on the critical line. An example of a Z-function is shown in Fig. 2.

For the Maass forms we computed we used Rubenstein’s library lcalc [16] to compute the L-function and calculate the zeros in the strip. We did this for all complete forms with \(\varepsilon _i \le 10^{-10}\) and found no zeros off the line, up to height \(t=100\). To do this we computed the \(a_f(n)\) with \((n,N) > 1\) up to \(n \le 2000\) using the method in Sect. 2.4. The method employed in lcalc to find zeros on the critical line is heuristic, however computing zeros on the critical line could be made rigorous with more work using the method in [6].