1 Introduction

1.1 Restriction norm of eigenfunctions

The question, ‘to what extent can the mass of a Laplace eigenfunction \(\phi \) on a Riemannian manifold X localize?’, is a classical problem in analysis and is often quantified by upper (or lower) bounds for \(L^p\)-bounds for the restriction of \(\phi \) to suitable submanifolds \(Y \subseteq X\). The prototypical example is the case where X is a surface and Y is a curve, often a geodesic; see e.g. [13, 15, 18, 30, 62, 67, 68] and references therein.

If X is the quotient of a symmetric space by an arithmetic lattice (often called an arithmetic manifold), an additional layer of number theoretic structure enters. Not only can this be used to obtain stronger bounds [61], but sometimes the period integrals can be expressed in terms of special values of L-functions. A typical such case is the \(L^2\)-restriction of a Maaß form for the group \(\mathrm{SL}_{n+1}(\mathbb {Z})\) to its upper left n-by-n block, which can be expressed as an average of central values of \(\mathrm{GL}(n) \times \mathrm{GL}(n+1)\) Rankin–Selberg L-functions [56, 57]. Other potential cases arise from the Gross-Prasad conjecture [38], see [69] for an illuminating discussion. Often in this context, optimal restriction norm bounds are equivalent to the Lindelöf conjecture on average over the spectral family of L-functions in question.

In this paper we consider a new and somewhat different instance of the interplay between mass equidistribution and L-functions in the context of certain Siegel modular forms F for the symplectic group \(\mathrm{Sp}_4(\mathbb {Z})\): we investigate the \(L^2\)-restriction of a Saito–Kurokawa lift F(Z) on the 6-dimensional Siegel upper half space \(\mathbb {H}^{(2)}\) to the 3-dimensional subspace where the argument \(Z = X+iY \in \mathbb {H}^{(2)}\) is restricted to its imaginary part. This is geometrically a very natural set-up, it is a direct higher-dimensional analogue of the classical problem of bounding a cusp form f for \(\mathrm{SL}_2(\mathbb {Z})\) on the vertical geodesic, mentioned at the beginning; cf. [11, Sect. 7]. While the latter leads, via Hecke’s integral representation, directly to the corresponding L-function L(fs), things become much more involved for Siegel modular forms.

We start by stating the corresponding period formula. For an even positive integer k let \(S_k^{(2)}\) denote the space of Siegel modular forms of degree 2 of weight k for the group \(\mathrm{Sp}_4(\mathbb {Z})\), equipped with the standard Petersson inner product; see Sect. 2. We think of k as tending to infinity and are interested in asymptotic results with respect to k. We restrict the argument of a cusp form \(F\in S_k^{(2)}\) to its imaginary part iY with \(Y \in \mathcal {P}(\mathbb {R})\) where \(\mathcal {P}(\mathbb {R})\), equipped with the measure \(dY/(\det Y)^{3/2}\), is the set of positive definite symmetric 2-by-2 matrices. Consider the restriction norm

$$\begin{aligned} \mathcal {N}(F) := \frac{\pi ^2}{90} \cdot \frac{1}{\Vert F \Vert ^2_2} \int \limits _{\mathrm{SL}_2(\mathbb {Z}) \backslash \mathcal {P}(\mathbb {R})} |F(i Y)|^2 (\det Y)^{k} \frac{dY}{(\det Y)^{3/2}}, \end{aligned}$$
(1.1)

where \(\mathrm{SL}_2(\mathbb {Z})\) acts on \(\mathcal {P}(\mathbb {R})\) by \(\gamma \mapsto \gamma ^{\top } Y \gamma \). Letting \(\mathbb {H}\) denote the usual upper half plane, we observe that \(\mathrm{SL}_2(\mathbb {Z}) \backslash \mathcal {P}(\mathbb {R}) \cong \mathrm{SL}_2(\mathbb {Z}) \backslash \mathbb {H} \times \mathbb {R}_{>0}\) has infinite measure; see (6.1) below. The factor

$$\begin{aligned} \frac{\pi ^2}{90} = \frac{3}{\pi } \cdot \frac{\pi ^3}{270} = \frac{\text {vol}(\mathrm{Sp}_4(\mathbb {Z}) \backslash \mathbb {H}^{(2)}) }{ \text {vol} (\mathrm{SL}_2(\mathbb {Z}) \backslash \mathbb {H})} \end{aligned}$$

accounts for the fact that, in accordance with the literature, we choose the standard measures on \(\mathrm{Sp}_4(\mathbb {Z}) \backslash \mathbb {H}^{(2)}\) and \(\mathrm{SL}_2(\mathbb {Z}) \backslash \mathbb {H}\) which are not probability measures.

Let \(\Lambda \) denote a set of spectral components of \(L^2(\mathrm{SL}_2(\mathbb {Z})\backslash \mathbb {H})\) consisting of the constant function \(\sqrt{3/\pi }\), an orthonormal basis of Hecke–Maaß cusp forms and the Eisenstein series \(E(., 1/2 + it)\) for \(t \in \mathbb {R}\). The set \(\Lambda \) is equipped with the counting measure on its discrete part and with the measure \(dt/4\pi \) on its continuous part. We denote by \(\int _{\Lambda }\) the corresponding combined sum/integral. For \(F \in S_k^{(2)}\) and \(\mathtt{u} \in \Lambda \) let \(L(F \times \mathtt{u}, s)\) denote the Koecher–Maaß series defined in (6.3). This series has a functional equation featuring the gamma factors \(G(F \times \mathtt{u}, s)\) as defined in (6.4), but has no Euler product. The following proposition is proved in Sect. 6.

Proposition 1

For \(F \in S_k^{(2)}\) with even k we have

$$\begin{aligned} \begin{aligned}&\mathcal {N}(F) = \frac{\pi ^2}{90 }\cdot \frac{1}{32} \cdot \frac{1}{ \Vert F \Vert ^2_2} \int \limits _{-\infty }^{\infty } \int \limits _{\Lambda _{\text { ev}}} |G(F \times \overline{\mathtt{u}}, 1/2 + it) L(F \times \overline{\mathtt{u}}, 1/2 + it) |^2 d\mathtt{u} \, dt , \end{aligned} \end{aligned}$$

where \(\Lambda _{\text { ev}}\) denotes the set of all even \(\mathtt{u} \in \Lambda \).

An arithmetically interesting subfamily of Siegel modular forms are the Saito–Kurokawa lifts \(F_h\) (sometimes called the Maaß Spezialschar) of half-integral weight modular forms \(h \in S^+_{k-1/2}(4)\) in Kohnen’s plus-space or equivalently their Shimura lifts \(f_h \in S_{2k-2}\) (see Sect. 2 for details). In this case, the Koecher–Maaß series \(L(F_h \times \mathtt{u}, s)\) roughly becomes a Rankin–Selberg L-function of two half-integral weight cusp forms, namely of h and the weight 1/2 automorphic form whose Shimura lift equals \(\mathtt{u}\); see Proposition 16 below and cf. [24]. Of course, this series also has no Euler product. The convexity bound for L-functions along with trivial bounds implies

$$\begin{aligned} \mathcal {N}(F_h) \ll k^{2+\varepsilon }, \end{aligned}$$

whilst the statement

$$\begin{aligned} \mathcal {N}(F_h) \ll k^{\varepsilon } \end{aligned}$$
(1.2)

would follow from the Lindelöf hypothesis for these L-functions. It should be noted, however, that in absence of an Euler product it is not expected that these L-functions satisfy the Riemann hypothesis, but one may still hope that the Lindelöf hypothesis is true; see [49] for some support of this conjecture. However, even if it is, then proving (1.2) appears to be far out of reach by current technology—it corresponds to an average of size \(k^{3/2}\) of a family of L-functions of conductor \(k^8\). (This is analogous to the genus 1 situation in which the \(L^2\)-restriction norm of a holomorphic cusp form of weight k leads to an average of size \(k^{1/2}\) of a family of L-functions of conductor \(k^4\); see [11, (1.12)].) These problems belong to the hard cases where sharp bounds for the \(L^2\)-restriction norm imply very strong subconvexity bounds.

1.2 The main result and mass equidistribution in higher rank

Fix a smooth, non-negative test function W with non-empty support in [1, 2]. Let \(\omega := \int _1^2 W(x) x\, dx\) and consider

$$\begin{aligned} \mathcal {N}_{\text {av}}(K) := \frac{1}{\omega } \cdot \frac{12}{ K^2} \cdot \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \sum _{h \in B_{k-1/2}^+(4)} \mathcal {N}(F_h) \end{aligned}$$
(1.3)

for a large parameter K and a Hecke eigenbasis \(B_{k-1/2}^+(4)\) of \(S_{k-1/2}^+(4)\). Note that \(\dim S_{k-1/2}^+(4) \sim k/6\). The first main result of this paper is the following asymptotic formula.

Theorem 2

We have \(\mathcal {N}_{\text {{ av}}}(K) = 4\log K + O(1)\) as \(K \rightarrow \infty \).

This may be interpreted as an asymptotic average version of the Lindelöf hypothesis for twisted Koecher–Maaß series. This restriction problem, however, is structurally quite different from all previously considered restriction problems with connections to L-functions: (a) the period formula features L-functions that are not in the Selberg class and (b) Theorem 2 reveals that the restriction norm does generally not remain bounded.

There is a strong connection between Theorem 2 and the mass equidistribution conjecture that we now explain. Let g be a test function on \(\mathrm{Sp}_4(\mathbb {Z}) \backslash \mathbb {H}^{(2)}\). Then the (arithmetic) mass equidistribution conjecture for the Siegel upper half space states that

$$\begin{aligned} \frac{1}{\Vert F \Vert ^2} \int \limits _{\mathrm{Sp}_4(\mathbb {Z}) \backslash \mathbb {H}^{(2)}} g(Z) |F(Z)|^2 (\det Y)^{k} \frac{dX\, dY}{(\det Y)^{3}} \longrightarrow \int \limits _{\mathrm{Sp}_4(\mathbb {Z}) \backslash \mathbb {H}^{(2)}} g(Z) \frac{dX\, dY}{(\det Y)^{3}} \end{aligned}$$

as F traverses a sequence of Hecke–Siegel cusp forms of growing weight. While the corresponding statement for classical cusp forms of degree 1 was proved by Holowinsky and Soundararajan [36], no such statement has been obtained for Siegel modular forms of higher degree (but see [70] for certain cases of the quantum unique ergodicity conjecture in higher rank and [19] for an averaged version). Nevertheless, one may even go one step further and conjecture that the above limit holds when one restricts the full space \(\mathrm{Sp}_4(\mathbb {Z}) \backslash \mathbb {H}^{(2)}\) to a lower-dimensional submanifold. In particular, one might conjecture that

$$\begin{aligned}&\frac{\text {vol}(\mathrm{Sp}_4(\mathbb {Z}) \backslash \mathbb {H}^{(2)}) }{\Vert F \Vert ^2} \int \limits _{\mathrm{SL}_2(\mathbb {Z}) \backslash \mathcal {P}(\mathbb {R})} g(Y) |F(iY)|^2 (\det Y)^{k} \frac{ dY}{(\det Y)^{3/2}}\\&\quad \longrightarrow \int \limits _{\mathrm{SL}_2(\mathbb {Z}) \backslash \mathcal {P}(\mathbb {R})} g(Y) \frac{ dY}{(\det Y)^{3/2}} \end{aligned}$$

holds. As the right hand side has infinite measure, we cannot simply replace g with the constant function. This is precisely the reason why \(\mathcal {N}_{\text {av}}(K)\) is unbounded as \(K \rightarrow \infty \). However, since F is a cusp form, the \(L^2\)-normalized and \(\mathrm{Sp}_4(\mathbb {Z})\)-invariant function \(|F(iY)|^2 (\det Y)^{k}/\Vert F \Vert ^2\) decays exponentially quickly if Y is (in a precise sense) very large or very small. So effectively g may be restricted to the characteristic function of a compact set depending on k. We quantify this in Appendix C and show that, for such g, the right hand side equals

$$\begin{aligned} \text {vol}(\mathrm{SL}_2(\mathbb {Z})\backslash \mathbb {H})\cdot 4 \log k + O(1). \end{aligned}$$

In this case the previous asymptotic reads

$$\begin{aligned} \mathcal {N}(F) \sim 4\log k \end{aligned}$$
(1.4)

as \(k \rightarrow \infty \). The asymptotic (1.4) is, of course, highly conjectural, and as mentioned above even the ordinary higher rank mass equidistribution conjecture (without restricting to a thin subset) is currently out of reach. As an aside we remark that one has to be careful with such conjectures. For instance, the \(L^2\)-norm restriction of even Maaß forms for \(\mathrm{SL}_2(\mathbb {Z})\) to the vertical geodesic is twice as big as one might think [74].

Theorem 2 provides an unconditional proof of (1.4) on average over Saito–Kurokawa lifts in agreement with the mass equidistribution conjecture for the rank two Siegel upper half space.

In particular, the constant 4 in Theorem 2 is very relevant, and this constant has a story of its own. It is the outcome of several archimedean integrals, numerical values in period formulae and a gigantic Euler product whose special value can be expressed in terms of zeta values (cf. (12.8)). In deducing its value we have corrected several numerical constants in the literature. We shall come back to this point in due course; see for instance the remark after Lemma 8. The authors would like to thank Gergely Harcos for useful and clarifying discussions in this respect.

Theorem 2 opens the door for several other related problems. The reader may wonder as to how the norms of the other Siegel cusp forms behave; that is, those forms which are not obtain via global parabolic induction (non-CAP), unlike the Saito–Kurukawa lifts. Any reasonable spectral average would include at least the space of Siegel modular forms \(S_k^{(2)}\) of weight k which is of dimension \(\sim ck^{3}\) for some constant c (in fact \(c = 1/8640\)). This leads to a bigger average than the one presently considered over about \(k^2\) Saito–Kurokawa lifts. The starting point for the \(L^2\)-restriction norm of all Siegel modular forms is again the period formula in Proposition 1. Coupled with an approximate functional equation (as in Lemma 17), this is amenable to the Kitaoka–Petersson formula [50] and an analysis along the lines of [9]. We hope to return to this interesting problem soon.

A different symplectic restriction problem was treated in [59] and [11], where the argument \(Z \in \mathbb {H}^{(2)}\) of Saito–Kurokawa lifts was restricted to the diagonal, a four-dimensional subspace of \(\mathbb {H}^{(2)}\). The corresponding analogue of Proposition 1, due to Ichino [37], leads to an average of size k of Langlands L-functions of conductor \(k^4\).

Whilst the proof of Theorem 2 rests on many ingredients which we address in detail in the coming sections, we would like to highlight a few results which may be of stand alone interest. We describe these in the remainder of the introduction.

1.3 A relative trace formula for pairs of Heegner periods

Here we focus on a novel trace formula of independent interest beyond its application in proving Theorem 2.

Let D be a discriminant, i.e. a non-square integer \(\equiv 0, 1\) (mod 4). For a discriminant \(D < 0\) let \(H_D \subseteq \mathrm{SL}_2(\mathbb {Z}) \backslash \mathbb {H}\) denote the set of all Heegner points; that is, the set of all \(z = (\sqrt{|D|}i - B)/(2A)\) where \(AX^2 + BXY + CY^2\) is a \(\Gamma \)-equivalence class of integral quadratic forms of discriminant \(D = B^2 - 4AC\). For a function \(f : \mathrm{SL}_2(\mathbb {Z}) \backslash \mathbb {H} \rightarrow \mathbb {C}\) define the period (“trace”)

$$\begin{aligned} P(D; f) = \sum _{z \in H_D} \frac{f(z)}{\epsilon (z)} \end{aligned}$$
(1.5)

where \(\epsilon (z) \in \{1, 2, 3\}\) is the order of the stabilizer of z in \(\mathrm{PSL}_2(\mathbb {Z})\). Its counterparts for positive discriminants D are periods over geodesic cycles. These periods are classical objects with myriad interwoven connections to half-integral weight modular forms, base change L-functions, quadratic fields and quadratic forms. The key point is that the corresponding generating series has (metaplectic) modular properties. An interesting special case is the constant function \(f = 1\) in which case \(P(D; 1) = H(D)\) is, by definition, the Hurwitz class number.

With applications to the above mentioned symplectic restriction problem in mind, we are interested in pairs of Heegner periods in the spectral average

$$\begin{aligned} \int \limits _{\Lambda _{\text {ev}}} P(D_1; \mathtt{u}) \overline{P(D_2; \mathtt{u})} h(t_\mathtt{u}) d\mathtt{u} \end{aligned}$$

for a suitable test function h, two discriminants \(D_1, D_2 < 0\) and \(\Lambda _{\text {ev}}\) as in Proposition 1. While pairs of geodesics have been studied in a few situations [63,64,65] (but only for compact Riemann surfaces and not from an arithmetic point of view), to the best of our knowledge nothing seems to be known about spectral averages of pairs of Heegner periods. Opening the sums in the definition of \(P(D_1; \mathtt{u})\) and \(P(D_2; \mathtt{u})\), this can be expressed as a double sum of an automorphic kernel

$$\begin{aligned} \sum _{z_1 \in H_{D_1}}\sum _{z_2 \in H_{D_2}} \frac{1}{\epsilon (z_1)\epsilon (z_2)}\sum _{\gamma \in \Gamma } k(z_1, \gamma z_2) \end{aligned}$$

in the usual notation which resembles the set-up of a relative trace formula. However, the standard methods in this situation (e.g. [32]) do not easily apply here as the stabilizers of \(z_1\) and \(z_2\) are essentially trivial. We thus take a different approach to establish the following relative trace formula for which we need some notation. For \(n >0\) and \(t \in \mathbb {R}\) let

$$\begin{aligned} W_t( n) := \frac{1}{2\pi i} \int \limits _{(2)} \frac{\Gamma (\frac{1}{2}(\frac{1}{2} + s + 2it))\Gamma (\frac{1}{2}(\frac{1}{2} + s -2 it))}{\Gamma ( \frac{1}{4} + it)\Gamma ( \frac{1}{4} -it)\pi ^s} e^{s^2} n^{-s} \frac{ds}{s}. \end{aligned}$$

For \(t\in \mathbb {R}\), \(x > 0\) and \(\kappa \in \mathbb {R}\) let

$$\begin{aligned} F(x, t, \kappa ) = J_{it}(x) \cos (\pi \kappa /2 - \pi i t/2) - J_{-it}(x) \cos (\pi \kappa /2 + \pi i t/2) \end{aligned}$$
(1.6)

where \(J_{it}(x)\) is the Bessel function. Finally, for \(\kappa \in \mathbb {Z} + 1/2\), \(n, m \in \mathbb {Z}\) and \(c \in \mathbb {N}\) define the modified Kloosterman sums

$$\begin{aligned} K^+_{\kappa }(m, n, c) = \sum _{\begin{array}{c} d\, (\text {mod }c)\\ (d, c) = 1 \end{array}} \epsilon ^{2\kappa }_d \left( \frac{c}{d}\right) e\left( \frac{md + n{\bar{d}}}{c}\right) \cdot {\left\{ \begin{array}{ll} 0, &{} 4 \not \mid c,\\ 2, &{} 4 \mid c, \, 8 \not \mid c,\\ 1, &{} 8 \mid c, \end{array}\right. } \end{aligned}$$
(1.7)

where

$$\begin{aligned} \epsilon _d = {\left\{ \begin{array}{ll} 1, &{} d \equiv 1\, (\mathrm{mod }\,4), \\ i, &{} d \equiv 3\, (\mathrm{mod }\, 4).\end{array}\right. } \end{aligned}$$
(1.8)

Note that \(K^+_{\kappa }(n, m, c)\) is symmetric in m and n and 2-periodic in \(\kappa \). They satisfy the Weil-type bound

$$\begin{aligned} K_{\kappa }^+(m, n, c) \ll c^{1/2 + \varepsilon }(m, n, c)^{1/2}, \end{aligned}$$
(1.9)

see e.g. [73, Lemma 4] in the case \(n=m\), the general case being analogous. In order to simplify the notation we assume that \(D_1, D_2\) are fundamental discriminants. In Section 7 we state the general version for arbitrary negative discriminants.

Theorem 3

Let \(\Delta _1, \Delta _2\) be negative fundamental discriminants and let h be an even function, holomorphic in \(|\mathfrak {I}t | < 2/3\) with \(h(t) \ll (1+|t|)^{-10}\). Then

$$\begin{aligned} \begin{aligned}&\frac{1}{|\Delta _1\Delta _2|^{1/4}}\int \limits _{\Lambda _{\text {{ ev}}}} P(\Delta _1; \mathtt{u}) \overline{P(\Delta _2; \mathtt{u})} h(t_\mathtt{u}) d\mathtt{u} = \frac{3}{\pi } \frac{H(\Delta _1)H(\Delta _2)}{|\Delta _1\Delta _2|^{1/4}} h(i/2)\\&\quad + \int \limits _{-\infty }^{\infty } \Big |\frac{\Delta _1\Delta _2}{4}\Big |^{ it/2} \frac{ \Gamma (-\frac{1}{4} + \frac{it}{2}) e^{(1/2- it)^2}}{ \sqrt{8\pi } \Gamma (\frac{1}{4} + \frac{i t}{2})} \frac{L( \chi _{\Delta _1}, 1/2 + it)L(\chi _{\Delta _2}, 1/2 + it)}{ \zeta (1+ 2it)} h(t) \frac{dt}{4\pi }\\&\quad + \delta _{\Delta _1= \Delta _2} \sum _m\frac{\chi _{\Delta _1}(m)}{m} \int \limits _{-\infty }^{\infty } W_{t}(m) h(t) t \tanh (\pi t) \frac{dt}{4\pi ^2} \\&\quad + e(3/8) \sum _{n, c, m} \frac{ K_{3/2}^+(|\Delta _1| n^2, |\Delta _2|, c)\chi _{\Delta _1}(m)}{ n^{1/2}cm} \int \limits _{-\infty }^{\infty } \frac{F(4\pi n\sqrt{|\Delta _1\Delta _2|}/c, t, 1/2)}{\cosh (\pi t)} h(t) W_{t}(nm) t \frac{dt}{\pi }. \end{aligned} \end{aligned}$$

The experienced reader will spot the strategy of the proof from the shape of the formula: A Katok-Sarnak-type formula translates \(P(\Delta ; \mathtt{u})\) into a product of a first and a \(\Delta \)-th half-integral weight Fourier coefficient. In this way, a pair of two Heegner periods becomes a product of four half-integral weight Fourier coefficients. A quadrilinear form of half-integral weight Fourier coefficients is not directly amenable to any known spectral summation formula, so this looks like a dead end, but we can use a Waldspurger-type formula a second time, now in the other direction, to translate the two first coefficients into a central L-value. This L-value can be written explicitly as a sum of Hecke eigenvalues by an approximate functional equation. We can now use the correspondence between half-integral and integral weight forms a third time, namely by combining the Hecke eigenvalues into the half-integral weight coefficients by means of metaplectic Hecke relations. Finally, the Kuznetsov formula for the Kohnen plus space provides the desired geometric evaluation of the relative trace. This particular version of the Kuznetsov formula is also new and will be stated and proved in Sect. 5. The same strategy works also with minor modifications for pairs of (traces of) geodesic cycle integrals.

1.4 Mean values of L-functions

We highlight another ingredient of independent interest, a special case of which (Corollary 5) is a hybrid Lindelöf-on-average bound for central values of twisted L-functions. Its proof is deferred to Sect. 8.

Proposition 4

Let \(\mathcal {D}, \mathcal {T} \geqslant 1\) and \(\varepsilon > 0\). For a fundamental discriminant \(\Delta \) let \(\chi _{\Delta } = (\frac{\Delta }{.})\) be the Jacobi–Kronecker symbol.

(a) We have

$$\begin{aligned} \sum _{t_{ u} \leqslant \mathcal {T}}\alpha (u) \sum _{\begin{array}{c} |\Delta | \leqslant \mathcal {D} \Delta \text { fund. discr.} \end{array}} L({u} \times \chi _{\Delta }, 1/2) \ll \Big (\sum _{t_{ u} \leqslant \mathcal {T}}|\alpha (u)|^2\Big )^{1/2} (\mathcal {T}\mathcal {D})^{1+\varepsilon } \end{aligned}$$

where the sum is over an orthonormal basis of Hecke–Maaß cusp forms u with spectral parameter \(t_{u}\), and \(\alpha (u)\) is any sequence of complex numbers, indexed by Maaß forms.

(b) We have

$$\begin{aligned}&\int \limits _{-\mathcal {T}}^\mathcal {T} \alpha (t) \sum _{\begin{array}{c} |\Delta | \leqslant \mathcal {D}\\ \Delta \text {fund. discr.} \end{array}} |L( \chi _{\Delta }, 1/2 + it)|^2 dt \ll \Bigg (\int \limits _{-\mathcal {T}}^\mathcal {T}|\alpha (t)|^2 dt\Bigg )^{1/2} (\mathcal {T}^{1/2}\mathcal {D})^{1+\varepsilon } \end{aligned}$$

for an arbitrary function \(\alpha : [-\mathcal {T}, \mathcal {T}] \rightarrow \mathbb {C}\).

The proof uses, among other things, the spectral large sieve of Deshouillers-Iwaniec [21] and Heath-Brown’s large sieve for quadratic characters [34]. Note that \(L({ u} \times \chi _{\Delta }, 1/2) \geqslant 0\) is non-negative [47, Corollary 1]. The key point here is that there is complete uniformity in \(\mathcal {T}\) and \(\mathcal {D}\).

We give an immediate application. Let us choose \(\alpha (u) = L(u, 1/2)\) and note that

$$\begin{aligned} L(u, 1/2) L(u \times \chi _{\Delta }, 1/2) = L(\mathrm{BC}_{K}(u), 1/2) \end{aligned}$$

where the right hand side is the base change L-function to \(K = \mathbb {Q}(\sqrt{\Delta })\). We can now use a standard mean value bound for L(u, 1/2), e.g. [41, Theorem 3], to conclude

Corollary 5

For \(\mathcal {T}, \mathcal {D} \geqslant 1\) and \(\varepsilon > 0\) we have

$$\begin{aligned} \sum _{t_{ u} \leqslant \mathcal {T}} \sum _{\begin{array}{c} \deg K/\mathbb {Q} = 2\\ |\text {{ disc}}(K)| \leqslant \mathcal {D} \end{array}} L(\mathrm{BC}_{K}(u), 1/2) \ll (\mathcal {T}^2\mathcal {D})^{1+\varepsilon } \end{aligned}$$

where the first sum runs over a basis of Hecke–Maaß cusp forms u with spectral parameter \(t_u \leqslant \mathcal {T}\).

Again this bound is completely uniform and best-possible in the \(\mathcal {D}\) and \(\mathcal {T}\) aspect. We give another interpretation of Proposition 4(a). For odd u, the root number of \(L(u \times \chi _{\Delta }, s)\) is \(-1\) (see [10, Lemma 2.1]), so the central value vanishes. For even u the central L-values \(L(u \times \chi _{\Delta }, 1/2)\), as in (4.9) below, are proportional to squares of Fourier coefficients \(b_v(\Delta )\) of weight 1/2 Maaß forms v in Kohnen’s subspace for \(\Gamma _0(4)\), normalized as in (3.7). We refer to Sect. 3 for the relevant definitions. In particular, for the usual choice of the Whittaker function the normalized Fourier coefficient \(\tilde{b}_v(\Delta ) = e^{-\pi |t_v|/2} |t_v|^{ \text {sgn}(\Delta )/4} |\Delta |^{1/2} b_v(\Delta ) \) is of size one on average. In this way we conclude bounds for linear forms in half-integral weight Rankin–Selberg coefficients:

$$\begin{aligned} \sum _{1/4 \leqslant t_{ v} \leqslant \mathcal {T}}\alpha (v) \sum _{\begin{array}{c} |\Delta | \leqslant \mathcal {D}\\ \Delta \text { fund. discr.} \end{array}} |\tilde{b}_v(\Delta )|^2 \ll \Bigg (\sum _{t_{ v} \leqslant \mathcal {T}}|\alpha (v)|^2\Bigg )^{1/2} (\mathcal {T}\mathcal {D})^{1+\varepsilon }, \end{aligned}$$
(1.10)

where the v-sum runs over an \(L^2\)-normalized Hecke eigenbasis of non-exceptional weight 1/2 Maaß forms in Kohnen’s subspace for \(\Gamma _0(4)\) with spectral parameter \(t_v\). We refer to the remark after the proof of Lemma 8 for more details.

1.5 Organization of the paper

Sections 25 prepare the stage and compile all necessary automorphic information. New results include versions of the half-integral Kuznetsov formula and a Voronoi formula for Hurwitz class numbers in Sect. 5.

Proposition 1, Theorem 3, and Proposition 4 are proved in Sects. 68 respectively. This is followed by an interlude on the analysis of special functions and oscillatory integrals in Sect. 9.

In the remainder we complete the proof of Theorem 2. In Sect 10 we first prove an upper bound \(\mathcal {N}_{\text {av}}(K) \ll K^{\varepsilon }\) by a preliminary argument. This will be useful and necessary to control certain auxiliary variables and error terms later. The full asymptotic formula is derived in Sects. 1114. Due to several applications of certain spectral summation formulae, we have various diagonal and off-diagonal terms. Section 12 treats the total diagonal term that extracts the leading term \(4\log K\) in Theorem 2. Sections 13 and 14 deal with the diagonal off-diagonal and the off-off-diagonal term.

1.6 Common notation

For \( c\not = 0\) we extend the Jacobi-Symbol \(\chi _c(d)= (\frac{c}{d})\) for positive odd integers d to all integers \(d\not = 0\) as the completely multiplicative function defined by \(\chi _c(-1) = \text {sign}( c)\) and \(\chi _c(2) = 1\) if \(c \equiv 1 \, (\text {mod }8)\), \(\chi _c(2) = -1\) if \(c \equiv 5 \, (\text {mod }8)\), \(\chi _c(2) = 0\) if c is even. The value of \(\chi _c(2)\) remains undefined only if \(c \equiv 3 \, (\text {mod }4)\).

We call an integer \(D \in \mathbb {Z} \setminus \{0\}\) a discriminant if \(D \equiv 0\) or 1 (mod 4). Every discriminant D can uniquely be written as \(D = \Delta f^2\) for some \(f\in \mathbb {N}\) and some fundamental discriminant \(\Delta \) (possibly \(\Delta = 1\)). For each discriminant D, the map \(\chi _D\) is a quadratic character of modulus |D| that is induced by the character \(\chi _{\Delta }\) corresponding to the field \(\mathbb {Q}(\sqrt{\Delta })\). (If \(\Delta = 1\), then \(\chi _{\Delta }\) is the trivial character.) Throughout, the letters D and \(\Delta \) are always reserved for discriminants resp. fundamental discriminants, usually negative.

The letter \(\Gamma \) is used for the gamma function and also for the group \(\Gamma = \mathrm{SL}_2(\mathbb {Z})\); confusion will not arise. We write \({\overline{\Gamma }} = \mathrm{PSL}_2(\mathbb {Z})\).

For \(a, b \in \mathbb {N}\) we write \(a \mid b^{\infty }\) to mean that all prime divisors of a divide b. We also write \((a, b^{\infty }) = a/a_1\) where \(a_1\) is the largest divisor of a that is coprime to b. We use the usual exponential notation \(e(z):=e^{2\pi i z}\) for \(z\in \mathbb {C}\). The letter \(\varepsilon \) denotes an arbitrarily small positive constant, not necessarily the same at every occurrence. The Kronecker symbol \(\delta _{S}\) takes the value 1 if the statement S is true and 0 otherwise. The notation \(\int _{(\sigma )}\) denotes a complex contour integral over the vertical line with real part \(\sigma \). We use the usual Vinogradov symbols \(\ll \) and \(\gg \), and we use \(\asymp \) to mean both \(\ll \) and \(\gg \). We always assume that the number K in Theorem 2 is sufficiently large.

2 Holomorphic forms of degree one and two

For a positive integer k let \(S^+_{k-1/2}(4)\) denote Kohnen’s plus [51] space of holomorphic cusp forms of weight \(k-1/2\) and level 4. These have a Fourier expansion of the form

$$\begin{aligned} h(z) = \sum _{(-1)^k n \equiv 0, 3\, (\text {mod 4})} c_h(n) e(nz) \end{aligned}$$
(2.1)

and form a finite-dimensional Hilbert space with the inner product

$$\begin{aligned} \langle h_1, h_2 \rangle = \int \limits _{\Gamma _0(4) \backslash \mathbb {H}} h_1(z) \overline{h_2(z)} y^{k-1/2} \frac{dx\, dy}{y^2}. \end{aligned}$$
(2.2)

This space is isomorphic (as a module of the Hecke algebra) to the space \(S_{2k-2}\) of holomorphic cusp forms of weight \(2k-2\) and level 1 [51, Theorem 1]. We denote by \(f_h \in S_{2k-2}\) the (unique up to scaling) image of a newform \(h \in S^+_{k-1/2}(4)\). The Hecke algebra on \(S^+_{k - 1/2}\) is generated by the operators \(T(p^2)\), p prime, and for \(p=2\) we follow Kohnen’s definition [51, p. 250] of T(4) that allows a uniform treatment of all primes including \(p=2\). If \(\lambda (p)\) are the Hecke eigenvalues of \(f_h\) (normalized so that the Deligne’s bound reads \(|\lambda (p)| \leqslant 2\)), then

$$\begin{aligned} \lambda (p) c_h(n) = p^{3/2 - k} c_h(p^2 n) + p^{-1/2} \chi _{ (-1)^{k+1} n}(p) c_h(n) + p^{k - 3/2} c_h(n/p^2)\nonumber \\ \end{aligned}$$
(2.3)

for all primes p with the convention \(c_h(x) = 0\) for \(x \not \in \{n \in \mathbb {N} \mid (-1)^k n \equiv 0, 3\, (\text {mod 4}) \}\). Iterating this formula gives

$$\begin{aligned} \lambda (m) c_h(n) = \sum _{\begin{array}{c} d_1 \mid d_2 \mid m\\ (d_1d_2)^2 \mid m^2n \end{array}} \left( \frac{d_1}{d_2} \right) ^{1/2} \chi _{ (-1)^{k+1} n}(d_1d_2) c_h\left( \frac{m^2}{(d_1d_2)^2}n\right) \left( \frac{m}{d_1d_2}\right) ^{3/2 - k}\nonumber \\ \end{aligned}$$
(2.4)

for squarefree \(m \in \mathbb {N}\).

The space \(S^{+}_{k-1/2}(4)\) can be characterized as an eigenspace of a certain operator acting on the space \(S_{k-1/2}(4)\) of all holomorphic cusp forms of weight \(k-1/2\) and level 4 [51, Proposition 2]. It possesses Poincaré series \(P^+_n \in S^+_{k-1/2}(4)\) satisfying the usual relationFootnote 1 [52, (4)]

$$\begin{aligned} \langle h, P^+_n\rangle = \frac{\Gamma (k-3/2)}{(4\pi n)^{k-3/2}} c_h(n) \end{aligned}$$

for all \((-1)^k n \equiv 0, 3\, (\text {mod 4})\) and all \(h \in S^+_{k-1/2}(4)\) with Fourier expansion (2.1). These Poincaré series are the orthogonal projections of the Poincaré series \(P_n \in S_{k-1/2}(4)\) onto \(S^{+}_{k-1/2}(4)\) and their Fourier coefficients are computed explicitly in [52, Proposition 4]. This gives us the following Petersson formula for Kohnen’s plus space.

Lemma 6

Let \(k \geqslant 3\) be an integer, \(\kappa = k-1/2\). Let \(\{h_j\}\) be an orthogonal basis of \(S^+_{\kappa }(4)\) with Fourier coefficients \(c_j(n)\) as in (2.1). Let nm be positive integers with \((-1)^kn, (-1)^km \equiv 0, 3\, (\mathrm{mod } \,\,4)\). Then

$$\begin{aligned} \begin{aligned}&\frac{\Gamma (\kappa - 1)}{(4\pi )^{\kappa - 1}} \sum _j \frac{c_j(n) \overline{c_j(m)}}{\Vert h_j \Vert ^2 ( \sqrt{nm})^{\kappa -1}} \\&\quad = \frac{2}{3}\left( \delta _{m=n} + 2 \pi e(-\kappa /4) \sum _{c} \frac{K^+_{\kappa }(n, m, c)}{c} J_{\kappa - 1}\left( \frac{4\pi \sqrt{mn}}{c}\right) \right) . \end{aligned} \end{aligned}$$

For a positive integer k we denote by \(S^{(2)}_k\) the space of Siegel cusp forms of degree 2 of weight k for the symplectic group \(\mathrm{Sp}_4(\mathbb {Z})\) with Fourier expansion

$$\begin{aligned} F(Z) = \sum _{T \in \mathcal {P}(\mathbb {Z})} a(T) e(\text {tr}(TZ)) \end{aligned}$$
(2.5)

for \(Z = X + iY \in \mathbb {H}^{(2)}\) on the Siegel upper half plane, where \(\mathcal {P}(\mathbb {Z})\) is the set of symmetric, positive definite 2-by-2 matrices with integral diagonal elements and half-integral off-diagonal elements. This is a finite-dimensional Hilbert space with respect to the inner product

$$\begin{aligned} \langle F, G \rangle = \int \limits _{\mathrm{Sp}_4(\mathbb {Z})\backslash \mathbb {H}^{(2)}} F(Z) \overline{G(Z)} (\det Y)^k \frac{dX \, dY}{(\det Y)^3}. \end{aligned}$$

Remark: In the generic case, the above norm may be used to determine the associated adjoint L-function at \(s=1\) by a recent work of Chen and Ichino [17]. However Siegel cusp forms are not globally generic, albeit that they are equivalent to a generic form everywhere but the archimedean place. Nevertheless, their Petersson norm may be expressed in terms of its adjoint L-function via Böcherer’s conjecture (now a theorem due to the breakthrough result of Furusawa and Morimoto [29] alongside the explicit formulation in [23]).

There is a special family of Siegel cusp forms that are derived from elliptic cusp forms (Saito–Kurokawa lifts or Maaß Spezialschar). Let k be an even positive integer. Let \(h \in S^+_{k-1/2}(4)\) be a Hecke eigenform of weight \(k-1/2\) with Fourier expansion as in (2.1), and let \(f_h \in S_{2k-2}\) denote the corresponding Shimura lift. The Saito–Kurokawa lift associates to h (or \(f_h\)) a Siegel cusp form \(F_h\) of weight k for \(\mathrm{Sp}_4(\mathbb {Z})\) with Fourier expansion (2.5), where

$$\begin{aligned} a(T) = \sum _{d \mid (n, r, m)}d^{k-1} c_h \left( \frac{4 \det T}{d^2}\right) , \quad T = \left( \begin{matrix} n &{} r/2\\ r/2 &{} m\end{matrix}\right) \in \mathcal {P}(\mathbb {Z}), \end{aligned}$$
(2.6)

see e.g. [27, §6]. If \(L (f_h, s)\) is the standard L-function of \(f_h\) (normalized so that the functional equation sends s to \(1-s\)), then the norms of \(F_h\) and h are related by ( [53, p. 551], [14, Lemma 4.2 & 5.2 with \(M=1\)])

$$\begin{aligned} \Vert F_h \Vert ^2 = \Vert h \Vert ^2 \frac{\Gamma (k) L(f_h, 3/2)}{144\pi ^k}. \end{aligned}$$
(2.7)

Remarks: (1) This inner product relation was generalized to Ikeda lifts in [48]. Their case \(n=2\) is consistent with (2.7) taking into account the different normalization of the inner product (2.2) with an additional factor 1/6 imported from [54].

(2) Note that the formula three lines after (4) in [53] is off by a factor of 2 (and also based on a different inner product). The proof of [14, Lemma 5.2] contains a number of typos (the powers of \(\pi \) in (10) and the preceding display seem to be incorrect as well as the normalizing factor after (10)), but the final result for \(M=1\) is independent of this and consistent with (2.7).

(3) For future reference we note that for \(\mathfrak {R}s > 1\) we have

$$\begin{aligned} \frac{1}{L(f_h, s)} = \prod _p \left( 1 - \frac{\lambda (p)}{p^s} + \frac{1}{p^{2s}}\right) = \sum _{(n, m) = 1} \frac{\lambda (n) \mu (n)\mu ^2(m)}{n^sm^{2s}} \end{aligned}$$
(2.8)

if \(\lambda (n)\) denotes the n-th Hecke eigenvalue of \(f_h\).

3 Non-holomorphic automorphic forms

We recall the spectral decomposition of \(L^2(\Gamma \backslash \mathbb {H})\) with \(\Gamma = \mathrm{SL}_2(\mathbb {Z})\), consisting of the constant function \(u_0 = \sqrt{3/\pi }\), a countable orthonormal basis \(\{u_j, j = 1, 2, \ldots \}\) of Hecke–Maaß cusp forms and Eisenstein series \(E(., 1/2 + it)\), \(t \in \mathbb {R}\). As in the introduction we call the collection of these functions \(\Lambda \) and the subset of even members \(\Lambda _{\text {ev}}\), and we write \(\int _{\Lambda }\) resp. \(\int _{\Lambda _{\text {ev}}}\) for the corresponding spectral averages. We also introduce the notation \(\int ^{*}_{\Lambda _{\text {ev}}} d\mathtt{u}\) for a spectral average without the residual spectrum which in this case consists only of the constant function. We use the general notational convention that an element in \(\Lambda \) or \(\Lambda _{\text {ev}}\) is denoted by \(\mathtt{u}\) while a cusp form is usually denoted by u.

For \(t \in \mathbb {R}\) let \(U_t^{\text {ev}}\) denote the space of even weight zero Maaß cusp forms for \(\Gamma \) with Laplacian eigenvalue \(1/4 + t^2\). It is equipped with the inner product

$$\begin{aligned} \langle u_1, u_2 \rangle = \int \limits _{\Gamma \backslash \mathbb {H}} u_1(z) \overline{u_2(z)} \frac{dx \, dy}{y^2}. \end{aligned}$$
(3.1)

We write the Fourier expansion as

$$\begin{aligned} u(z) = \sum _{n \not = 0} a(n) W_{0, it}(4 \pi |n| y) e(nx) \end{aligned}$$

with \(a(-n) = a(n)\), where \(W_{0, it}(4\pi y) = 2 y^{1/2} K_{it}(2\pi y)\) is the Whittaker function. The Hecke operators T(n), normalized as in [47, (1.1)], act on \(U_t^{\text {ev}}\) as a commutative family of normal operators. We call \(t = t_u\) the spectral parameter of u. The Eisenstein series

$$\begin{aligned} E(z, s) = \sum _{\gamma \in {\overline{\Gamma }}_{\infty } \backslash {\overline{\Gamma }}} (\mathfrak {I}\gamma z)^s = \sum _{\begin{array}{c} (c, d)\in \mathbb {Z}^2/\{\pm 1\}\\ \mathrm{gcd}(c, d) = 1 \end{array}} \frac{y^s}{|cz+d|^{2s}} \end{aligned}$$

for \({\overline{\Gamma }} = \mathrm{PSL}_2(\mathbb {Z})\) are eigenfunctions of all T(n) with eigenvalue

$$\begin{aligned} \rho _s(n) := \sum _{ab = n} (a/b)^{s - 1/2} = n^{s - 1/2} \sigma _{1 - 2s}(n), \quad \sigma _s(n) = \sum _{d \mid n} d^s, \end{aligned}$$
(3.2)

and an eigenfunction of the Laplacian with eigenvalue \(s(1-s)\). We call \((s - 1/2)/i\) the spectral parameter of E(., s). If \(\mathtt{u}\) is an Eisenstein series or a Hecke–Maaß cusp form with Hecke eigenvalues \(\lambda _\mathtt{u}(n)\) we define the corresponding L-function \(L(\mathtt{u}, s) = \sum _n \lambda _\mathtt{u}(n) n^{-s}\). In particular

$$\begin{aligned} L(E(., 1/2 + it), s) = \zeta (s + it) \zeta (s - it). \end{aligned}$$
(3.3)

If \(u \in U_t^{\text {ev}}\) is a cuspidal Hecke eigenform with eigenvalues \(\lambda (n)\), then \(|n|^{1/2}a(n) = a(1) \lambda (|n|)\), and by Rankin–Selberg theory (and [33, 6.576.4] with \(a = b = 4\pi \), \(\nu = \mu = it\))

$$\begin{aligned} \begin{aligned} \Vert u \Vert ^2&= \frac{\pi }{3} \underset{s=1}{\text {res} }\langle |u|^2, E(., s) \rangle = \frac{2\pi }{3} \underset{s=1}{\text {res} } \sum _{n> 0} \frac{|a(n)|^2}{|n|^{s-1}} \int \limits _0^{\infty } W_{0, it}(4 \pi y)^2 y^{s-2} dy\\&= \frac{2\pi |a(1)|^2}{3} \underset{s=1}{\text {res} } \sum _{n > 0} \frac{|\lambda (n)|^2}{|n|^{s}} \frac{\pi ^{1/2} \Gamma (s/2) \Gamma (s/2 - it)\Gamma (s/2 + it)}{(2\pi )^s \Gamma ((1 + s)/2)} \\&= \frac{2 |a(1)|^2 L(\text {sym}^2 u, 1)}{\cosh (\pi t)}. \end{aligned} \end{aligned}$$
(3.4)

We recall the Kuznetsov formula [55] and combine directly the “same sign” and the “opposite sign” formula to obtain a version for the even part of the spectrum. The conversion between Hecke eigenvalues and Fourier coefficients in the cuspidal case follows from (3.4).

Lemma 7

Let \(n, m \in \mathbb {N}\). Let h be an even holomorphic function in \(|\mathfrak {I}t| \leqslant 2/3\) with \(h(t) \ll (1 + |t|)^{-3}\). For non-constant \(\mathtt{u} \in \Lambda \) let \(\mathcal {L}(\mathtt{u}) = L(\text {{ sym}}^2 \mathtt{u}, 1)\) if \(\mathtt{u}\) is cuspidal andFootnote 2\(\mathcal {L}(\mathtt{u}) = \frac{1}{2}|\zeta (1 + 2it)|^2\) if \(\mathtt{u} = E(., 1/2 + it)\) is Eisenstein.Footnote 3 Then

$$\begin{aligned} \begin{aligned} \int \limits _{\Lambda _{\text {{ ev}}}}^{*} \frac{\lambda _\mathtt{u}(n) \lambda _\mathtt{u}(m) }{\mathcal {L}(\mathtt{u})} h(t_\mathtt{u})d\mathtt{u}=&\delta _{n= m} \int \limits _{-\infty }^{\infty } h(t) t \tanh (\pi t) \frac{dt}{4\pi ^2} \\&+ \sum _c \frac{S(m, n, c)}{c}h^*\Big ( \frac{\sqrt{nm}}{c}\Big )\\&+ \sum _c \frac{S(m, -n, c)}{c} h^{**}\Big ( \frac{\sqrt{nm}}{c}\Big ) \end{aligned} \end{aligned}$$
(3.5)

where

$$\begin{aligned}&h^{*}(x) = 2i \int \limits _{-\infty }^{\infty } \frac{J_{2it}(4 \pi x)}{\sinh (\pi t)} h(t) t \tanh (\pi t) \frac{dt}{4\pi }, \nonumber \\&h^{**}(x) = \frac{4}{\pi }\int \limits _{-\infty }^{\infty } K_{2it}(4 \pi x)\sinh (\pi t) h(t) t \frac{dt}{4\pi }. \end{aligned}$$
(3.6)

We turn to half-integral weight forms. Let \(V_t^+(4)\) denote the (“Kohnen”) space of weight 1/2 Maaß cusp forms for \(\Gamma _0(4)\) with eigenvalue \(1/4 + t^2\) with respect to the weight 1/2 Laplacian and Fourier expansion

$$\begin{aligned} v(z) = \sum _{ \begin{array}{c} n\not = 0 \\ n \equiv 0, 1 \, (\text {mod } 4) \end{array}} b(n) W_{\frac{1}{4} \text {sgn}(n), it}(4 \pi |n|y) e(nx). \end{aligned}$$
(3.7)

The congruence condition on the indices can be encoded in an eigenvalue equation: the functions \(v \in V_t^+(4)\) are invariant under the operator L defined in [47, (0.7), (0.8)], cf. also [5, (A.1)]. The space \(V_t^{+}(4)\) is a finite-dimensional Hilbert space with respect to the inner product

$$\begin{aligned} \langle v_1, v_2 \rangle = \int \limits _{\Gamma _0(4)\backslash \mathbb {H}} v_1(z) \overline{v_2(z)} \frac{dx\, dy}{y^2}. \end{aligned}$$
(3.8)

The Hecke operators \(T(p^2)\), p prime, act on \(V^+_t(4)\) as a commutative family of normal operators that commute with the weight 1/2 Laplacian (again we use Kohnen’s modification for T(4) in order to treat all primes uniformly). Explicitly, if \(T(p^2) v = \lambda (p) v\), then (see [47, (1.3)]) the Fourier coefficients of v satisfy

$$\begin{aligned} \lambda (p) b(n) = p b(np^2) + p^{-1/2} \chi _n(p) b(n) + p^{-1} b(n/p^2) \end{aligned}$$
(3.9)

for all primes p and all \(n \in \mathbb {Z} \setminus \{0\}\) with \(n \equiv 0, 1\) (mod 4) with the convention \(b(x) = 0\) for \(x \not \in \mathbb {Z}\). If \(v \in V_t^+(4)\) is an eigenfunction of all Hecke operators \(T(p^2)\) with eigenvalues \(\lambda (p)\), the relation (3.9) can be captured in the identity

$$\begin{aligned} \sum _{f=1}^{\infty } \frac{b(\Delta f^2 )}{f^{s-1}} = b(\Delta ) \prod _p \frac{1 - \chi _{\Delta }(p)p^{-s-1/2}}{1 - \lambda (p) p^{-s} + p^{-2s}} \end{aligned}$$

for a fundamental discriminant \(\Delta \). Extending \(\lambda (p)\) to all n by the usual Hecke relations, we see that the denominator is just \(\sum _{\nu } \lambda (p^{\nu })p^{-\nu s}\), so that

$$\begin{aligned} f b(\Delta f^2) = b(\Delta ) \sum _{d \mid f} \mu (d) \chi _{\Delta }(d) \lambda (f/d) d^{-1/2} \end{aligned}$$
(3.10)

for a fundamental discriminant \(\Delta \) and \(f \in \mathbb {N}\).

4 Period formulae

Let \(v \in V_t^+(4)\). Katok and Sarnak proved in [47, Proposition 4.1] that there is a linear map (a theta lift) \({\mathscr {S}}\) sending v to a non-zero element in \(U_{2t}^{\text {ev}}\) if \(b(1)\not = 0\) and to 0 otherwise. A calculation [47, pp. 221–223] shows that if v is an eigenform of \(T(p^2)\), then \({\mathscr {S}} v\) is an eigenform of T(p) with the same eigenvalue, and this computation works verbatim for \(p=2\), too. Conversely, given an eigenform \(u\in U_{2t}^{\text {ev}}\) with Hecke eigenvalues \(\lambda (p)\), by [4, Theorem 1.2]Footnote 4 there is a unique (up to scaling) \(v \in V_t^+(4)\) having eigenvalues \(\lambda (p)\) for \(T(p^2)\), \(p > 2\), (and then automatically also for T(4), since T(4) commutes with the other operators) which may or may not satisfy \(b(1) \not = 0\). In particular, for a given eigenform \(u\in U_{2t}^{\text {ev}}\) there is at most one eigenform \(v \in V_t^+\) (up to scaling) with \({\mathscr {S}}v = u \in U_{2t}^{\text {ev}}\). If it exists, we normalize it to be \(L^2\)-normalized and denote its Fourier coefficients b(n) as inFootnote 5 (3.7). If no such v exists, we define b(n) to be 0.

If \(\mathtt{u}\) is a Hecke–Maaß cusp form or an Eisenstein series, the absolute square of the periods \(P(D; \mathtt{u})\) can be expressed in terms of central L-functions. We introduce the relevant notation. For a discriminant \(D = \Delta f^2\) with a fundamental discriminant \(\Delta \) let

$$\begin{aligned} L(D, s) := L(\chi _{\Delta }, s) \sum _{d \mid f} \mu (d) \chi _{\Delta }(d) \sigma _{1-2s}(f/d) d^{-s}=: \sum _{n=1}^{\infty } \frac{\varepsilon _D(n)}{n^s}. \end{aligned}$$
(4.1)

With \(\rho _s\) as in (3.2) we can re-write this as

$$\begin{aligned} L(D, s) = L(\chi _{\Delta }, s) f^{1/2 - s} \sum _{d \mid f} \mu (d) \chi _{\Delta }(d) \rho _{s}(f/d) d^{-1/2}. \end{aligned}$$
(4.2)

Since \(\rho _s = \rho _{1-s}\), we see that L(Ds) satisfies the same type of functional equation as \(L(\Delta , s)\) namely

$$\begin{aligned} \Lambda (D, s) := L(D, s) |D|^{s/2} \Gamma \Big (\frac{s+\mathfrak {a}}{2}\Big ) \pi ^{-s/2} = \Lambda (D, 1-s) \end{aligned}$$
(4.3)

with \(\mathfrak {a} = 1\) if \(D < 0\) and \(\mathfrak {a} = 0\) if \(D > 0\). For a Hecke–Maaß cusp form or an Eisenstein series \(\mathtt{u} \) define

$$\begin{aligned} L(\mathtt{u}, D, s) = \sum _{n=1}^{\infty } \frac{\varepsilon _D(n) \lambda _\mathtt{u}(n)}{n^s}. \end{aligned}$$
(4.4)

The key point is that

$$\begin{aligned} L(\mathtt{u}, \Delta f^2, 1/2) = L(\mathtt{u}, \Delta , 1/2) \Bigl (\sum _{d \mid f} \mu (d) \chi _{\Delta }(d) \lambda _\mathtt{u}(f/d) d^{-1/2}\Bigr )^2 \end{aligned}$$
(4.5)

as one can check by a formal computation with Euler products using the Hecke relation for the eigenvalues \(\lambda _\mathtt{u}\) (which are identical for Maaß forms and Eisenstein series), see [54, p. 188-189]. For later purposes we record the simple bound

$$\begin{aligned} \Bigl (\sum _{d \mid f} \mu (d) \chi _{\Delta }(d) \lambda _\mathtt{u}(f/d) d^{-1/2}\Bigr )^2 \ll f^{1/3} \end{aligned}$$
(4.6)

uniformly in \(\Delta \) and \(\mathtt{u}\), which follows from the Kim-Sarnak bound with \( 2 \cdot 7/64 < 1/3\).

From (4.2), the fact that \(|L(\chi _{\Delta }, 1/2 + it)|^2 = L(E(., 1/2 + it), \Delta , 1/2)\) and (4.5) we have

$$\begin{aligned} \begin{aligned}&|L(\Delta f^2, 1/2+it)|^2 \\ {}&\quad = |L(\chi _{\Delta }, 1/2+it)|^2 \Bigl |\sum _{d \mid f} \mu (d) \chi _{\Delta }(d) \lambda _{E(., 1/2 + it)}(f/d) d^{-1/2}\Bigr |^2\\&\quad = L(E(., 1/2 + it), \Delta f^2, 1/2). \end{aligned} \end{aligned}$$
(4.7)

The next key lemma expresses the periods P(Du) defined in (1.5) for cusp forms u as half-integral weight Fourier coefficients, and then their squares as L-functions. The first formula (4.8) is essentially a formula of Katok-Sarnak [47, (0.16) & (0.19)], the passage from squares of metaplectic Fourier coefficients to L-functions in (4.9) is a Kohnen-Zagier type formula of Baruch-Mao [4, Theorem 1.4]. The combination (4.10) of these two is a special case of a formula of Zhang [76, Theorem 1.3.2] or [77, Theorem 7.1], derived independently by a different method.

Lemma 8

If \({ u} \in U_{2t}^{\text {{ ev}}}\) is an even Hecke–Maaß cusp form and \(D_1, D_2 <0\) are two discriminants, then

$$\begin{aligned}&\frac{P(D_1; { u})\overline{P(D_2; { u})} \Vert { u}\Vert ^{-2} }{|D_1D_2|^{1/4}} \nonumber \\&\quad = \frac{3}{\pi } L({ u}, 1/2) \Gamma (1/4 + it)\Gamma (1/4 - it) |D_1D_2|^{1/2}b(D_1) \overline{b(D_2)}. \end{aligned}$$
(4.8)

For a discriminant D of either sign we have

$$\begin{aligned}&|b(D)|^2\nonumber \\&\quad = \dfrac{1}{24\pi } \dfrac{L({ u}, D, 1/2)}{L(\mathrm {{ sym}}^2 { u}, 1)} \dfrac{\cosh (2 \pi t)\Gamma ( \frac{1}{2} - \frac{1}{4} \mathrm {sgn}(D)+ it)\Gamma ( \frac{1}{2} - \frac{1}{4} \mathrm {sgn}(D)- it)}{ |D|}.\nonumber \\ \end{aligned}$$
(4.9)

For \(D < 0\) we have

$$\begin{aligned} \frac{|P(D; { u})|^2 \Vert { u}\Vert ^{-2} }{|D|^{1/2}} = \frac{L({ u}, 1/2) L({ u}, D, 1/2)}{4L({\mathrm {sym}}^2 { u}, 1)}. \end{aligned}$$
(4.10)

Remark: The exact shape of these formulas is an unexpectedly subtle matter, and the attentive reader might well be confused by the various and slightly contradictory versions in the literature. There are at least four sources of possible conflict:

  • the Whittaker functions can be normalized in different ways;

  • the inner products can be normalized in different ways;

  • the translation from adelic language to classical can cause problems;

  • there can be ambiguities related to the groups \(\mathrm{GL}(2)\) vs. \(\mathrm{SL}(2)\) vs. \(\mathrm{PSL}(2)\).

The Katok-Sarnak formula exists in the literature with proofs given in at least in three different versions: [47, (0.16)], [6, Theorem A1] and [25, Theorem 4]. The original version of Katok-Sarnak was carefully revised by Biró, but the latter seems to be still off by a factor 2 compared to the version in Duke-Imamoğlu-Toth, which was checked numerically.

The Baruch-Mao formula [4, Theorem 1.4] is quoted in [25, (5.17)] with an additional factor 2. Zhang’s result [77, Theorem 7.1] (and also the remark after [76, Theorem 1.3.2], the theorem itself being correct) is missing the stabilizer \(\epsilon (z)\) in the period P(Du). This formula is slightly incorrectly reproduced in [58] and several follow-up papers, based on a different normalization of the Whittaker function. Finally, neither combination of one of the three Katok-Sarnak formulae with the Baruch-Mao formula in [4, Theorem 1.4] coincides with Zhang’s formula.

We therefore feel that these beautiful and important results should be stated with correct constants and normalizations. For the proof of Theorem 2 and its connection to the mass equidistribution conjecture this is absolutely crucial. As [25, Theorem 4] was checked numerically by the authors, we follow their version of the Katok-Sarnak formula. This gives (4.8). We verified and confirmed the constant in Zhang’s formula independently by proving an averaged version in Appendix A. This gives (4.10). By backwards engineering, we established the numerical constant in the Baruch-Mao formula, which gives (4.9) and coincides with [25, (5.17)].

Note that (4.10) is essentially universal: the right hand side of (4.10) is independent of any normalization, the left hand side depends only on the normalization of the inner product (3.1) which is standard.

Proof

We start with the formula [47, (0.16)] for a general discriminant \(D < 0\), but use the numerical constants as in [25, Theorem 4] (proved only for fundamental discriminants there). This formula expresses P(Du) for an arbitrary discriminant \(D < 0\) as a sum over Fourier coefficients of all v with \({\mathscr {S}}v = { u}\). By the above remarks, there is at most one such v. If there is none, then both sides of (4.8) and (4.10) vanish by [47, (0.16), (0.19)] and our convention that \(b(n) = 0\) in this case, and there is nothing to prove. Also note that the left hand side of (4.8) and both sides of (4.10) are independent of the normalization of u, so without loss of generality we may assume that u is Hecke-normalized as in [47]. We obtain

$$\begin{aligned} \frac{P(D_1; { u})\overline{P(D_2; { u})} \Vert { u}\Vert ^{-2} }{|D_1D_2|^{1/4}} = 6 |D_1D_2|^{1/2} b(D_1)\overline{b (D_2)} |b(1)|^2 \Vert { u}\Vert ^2. \end{aligned}$$

Next we insert [47, (0.19)] (again keeping in mind the different normalization of (3.8) and observing that this is coincides with the numerically checked version of [25, Theorem 4]) getting (4.8).

If D is a fundamental discriminant, then (4.9) follows from [25, (5.17)] together with (3.4) with \(a(1) = 1\) and 2t in place of t. By (3.10) and (4.5) this remains true for arbitrary discriminants. The formula (4.10) is a direct consequence of (4.8), (4.9) and well-known properties of the gamma function, and was proved independently by Zhang [76, Theorem 1.3.2]. \(\square \)

Remark: The argument at the beginning of this proof shows that the u-sum in Proposition 4(a), up to terms of size 0, can be replaced with the v-sum in (1.10), using (4.9). This completes the proof of (1.10).

A similar result holds for Eisenstein series. If \(aX^2 + bXY + cY^2\) is an integral quadratic form of discriminant \(D = b^2 -4ac < 0\) with Heegner point \(z = (\sqrt{|D|}i - b)/(2a)\), then

$$\begin{aligned} E(z, s) = \frac{1}{ \zeta (2s)} \sum _{(u, v) \in (\mathbb {Z}^2 \setminus (0, 0))/\{\pm 1\}} \frac{(\sqrt{|D|}/2)^s}{(au^2 - buv + cv^2)^s}. \end{aligned}$$

Hence

$$\begin{aligned} P(D; E(., s)) = \frac{1}{ \zeta (2s)} \Big (\frac{\sqrt{|D|}}{2}\Big )^s \zeta (D, s) \end{aligned}$$

where \(\zeta (D, s)\) is definedFootnote 6 in [75, (6)]. By [75, Proposition 3 iii] (or [25, Theorem 3]) we obtain the following lemma in analogy to Lemma 8.

Lemma 9

If \(D < 0\) is a discriminant, then

$$\begin{aligned} P(D; E(., s)) = \frac{1}{ \zeta (2s)} \Big (\frac{\sqrt{|D|}}{2}\Big )^s \zeta (s) L(D, s), \end{aligned}$$
(4.11)

and hence

$$\begin{aligned} \frac{|P(D; E(., 1/2 + it))|^2}{|D|^{1/2}} = \frac{L(E(., 1/2 + it), 1/2) L(E(., 1/2 + it), D, 1/2)}{ 2|\zeta (1 + 2 it)|^2} .\nonumber \\ \end{aligned}$$
(4.12)

Remarks: (1) The second formula follows from the first by (3.3) and (4.7).

(2) Here the verification of the numerical constants is much easier than in the cuspidal case. Taking residues at \(s=1\) in (4.11) for a fundamental discriminant \(\Delta < 0\) returns the class number formula for \(\mathbb {Q}(\sqrt{\Delta })\), which confirms the numerical constants.

(3) For future reference we recall the standard bounds

$$\begin{aligned} \zeta (1 + it) \gg |t|^{-\varepsilon }, \quad |t_{ u}|^{\varepsilon } \gg L(\text {sym}^2 { u}, 1) \gg |t_{ u}|^{-\varepsilon } \end{aligned}$$
(4.13)

for \(\varepsilon > 0\). This is in particular relevant to obtain upper bounds in (4.12) and (4.10).

We close this section by stating a standard approximate functional equation [44, Theorem 5.3] for the L-functions occurring in the previous period formulae. For \(u \in U_t^{\text {ev}}\) and a fundamental discriminant \(\Delta \) (possibly \(\Delta = 1\)) we have

$$\begin{aligned} L(u, \Delta , 1/2) = L(u \times \chi _{\Delta }, 1/2) = 2\sum _n \frac{\lambda (n)\chi _{\Delta }(n)}{n^{1/2}} W_{t}\Bigg (\frac{n}{|\Delta |}\Bigg ) \end{aligned}$$
(4.14)

where

$$\begin{aligned} W_{t}(n) = \frac{1}{2\pi i} \int \limits _{(2)} \frac{\Gamma (\frac{1}{2}(\frac{1}{2}+ \mathfrak {a} + s + it))\Gamma (\frac{1}{2}(\frac{1}{2} + \mathfrak {a}+ s - it))}{\Gamma (\frac{1}{2}(\frac{1}{2} + \mathfrak {a} + it))\Gamma (\frac{1}{2}(\frac{1}{2} + \mathfrak {a} - it)) \pi ^{s} }e^{s^2} n^{-s} \frac{ds}{s} \end{aligned}$$
(4.15)

with \(\mathfrak {a} = 1\) if \(\Delta < 0\) and \(\mathfrak {a} = 0\) if \(\Delta > 0\). Note that \(W_t\) depends on \(\Delta \) only in terms of its sign. If we want to emphasize this we write \(W_t^+\) and \(W_t^-\) with \(\pm = \text {sgn}(\Delta )\).

A similar expression holds for \(E(., 1/2 + it)\) in place of u except that in the case \(\Delta = 1\) we have \(L(E(., 1/2 + it), 1, s) = \zeta (s+it)\zeta (s- it)\) and there is an additional polar termFootnote 7. We have

$$\begin{aligned} \begin{aligned} L(E(., 1/2 + it), \Delta , 1/2)&= 2\sum _n \frac{\rho _{1/2 + it}(n) \chi _{\Delta }(n)}{n^{1/2}} W_{t}\Big (\frac{n}{|\Delta |}\Big )\\&-\delta _{\Delta = 1} \sum _{\pm } \frac{\zeta (1 \pm 2it)\Gamma (\frac{1}{2} \pm it)\pi ^{\mp it} e^{(1/2 \pm it)^2}}{(\frac{1}{2} \pm i t)\Gamma (\frac{1}{4} + \frac{it}{2})\Gamma (\frac{1}{4} - \frac{it}{2})} \end{aligned}\nonumber \\ \end{aligned}$$
(4.16)

with \(\rho _{1/2 + it}\) as in (3.2).

5 Half-integral weight summation formulae

In this section we compile the Voronoi summation and the Kuznetsov formula for half-integral weight forms in the plus space.

5.1 Voronoi summation

As before let

$$\begin{aligned} v(z) = \sum _{ n\not = 0 } b(n) W_{\frac{k}{2} \text {{ sgn}}(n), it}(4 \pi |n|y) e(nx) \end{aligned}$$
(5.1)

be a Maaß form in the plus space of weight \(k \in \{1/2, 3/2\}\) and spectral parameter t for \(\Gamma _0(4)\) with respect to the usual theta multiplier. We start with the Voronoi summation formula [16, Theorem 3].

Lemma 10

Let \(c\in \mathbb {N}\), \(4 \mid c\), \((a, c) = 1\). Let \(\phi \) be a smooth function with compact support in \((-\infty , 0) \cup (0, \infty )\) and for \(y > 0\) define

$$\begin{aligned} \Phi (\pm y) = \int \limits _0^{\infty } \mathcal {J}^{\pm , +}(ty) \phi (t) + \mathcal {J}^{\pm , -}(ty) \phi (-t) dt, \end{aligned}$$
(5.2)

where

$$\begin{aligned} \begin{aligned} \mathcal {J}^{\pm , \pm }(x)&= \frac{\cos (\pi k/2 \mp i \pi r)}{\sin (2\pi i r)} J_{-2 ir}(2\sqrt{x}) - \frac{\cos (\pi k/2\pm i \pi r)}{\sin (2\pi i r)} J_{2 ir}(2\sqrt{x}) \\&= - \frac{F(2 \sqrt{x}, 2r, \mp k)}{\sin (2\pi i r)},\\ \mathcal {J}^{\pm , \mp }(x)&= \frac{2 K_{2ir}(2\sqrt{x})}{\Gamma (1/2 \pm k/2 + ir)\Gamma (1/2 \pm k/2 - ir)} \end{aligned} \end{aligned}$$

with F as in (1.6). Then

$$\begin{aligned} \sum _{n \not = 0} b(n)\sqrt{|n|} e\Big (\frac{an}{c}\Big ) \phi (n) = \Big (\frac{-c}{a}\Big ) \epsilon ^{2k}_a e\Big (\frac{k}{4}\Big ) \sum _{n \not = 0} b(n) \sqrt{|n|} \frac{2\pi }{c} e\Big (-\frac{{\bar{a}}n}{c}\Big ) \Phi \Big (\frac{(2\pi )^2 n}{c^2}\Big ) \end{aligned}$$

with \(\epsilon _a\) as in (1.8).

The proof of the Voronoi formula (Lemma 10) follows from a certain vector-valued functional equation satisfied by the L-functions with coefficients \(b(\pm n) e(\pm an/c)\). The same functional equation holds if v is not cuspidal (this is clear from general principles and worked out explicitly in [22] along the same lines), but in this case the L-functions are not entire; they have various poles. We use this observation for two non-cuspidal modular forms. The first is a half-integral weight Eisenstein series

$$\begin{aligned} \begin{aligned} E^{*}\Big (z, \frac{1}{2} + it\Big ) =&\frac{ 2^{1 + 2it} \pi ^{-it} \Gamma (1/2 + 2it) \zeta (1+4it) }{\Gamma (3/4 + it)\Gamma (1/4 + it)} y^{1/2 + it} \\&\quad + \frac{2^{1 - 2it} \pi ^{3it} \Gamma (1/2 - 2it) \zeta (1-4it)}{\Gamma (3/4 + it)\Gamma (1/4 + it)} y^{1/2 - it} \\&+ \sum _{D } \frac{L(D,1/2 + 2it) |D|^{it} }{|D|^{1/2} }\frac{W_{\frac{1}{4} \text {sgn}(D), it}(4 \pi |D|y)}{\Gamma (\frac{1}{2} + \frac{1}{4} \text {sgn}(D) + it)}e(Dx)\\ \end{aligned} \end{aligned}$$
(5.3)

which transforms under \(\Gamma _0(4)\) as a weight 1/2 automorphic form with theta multiplier; see [25, p. 964]. As usual, D runs over all discriminants. The other is Zagier’s weight 3/2 Eisenstein seriesFootnote 8

$$\begin{aligned} \begin{aligned} \mathcal {H}(z) =&\sum _{D < 0} \frac{H(D)}{|D|^{3/4}} e(|D|x) W_{3/4, 1/4}(4\pi |D|y) - \frac{(4\pi y)^{3/4}}{12} \\&+ \frac{1}{4\sqrt{\pi }} \sum _{n = \square } \frac{e(-nx)}{n^{1/4}} W_{-3/4, 1/4}(4\pi n y)+ \frac{y^{1/4}}{\sqrt{8} \pi ^{1/4}} \end{aligned} \end{aligned}$$
(5.4)

which transforms under \(\Gamma _0(4)\) as a weight 3/2 automorphic form with theta multiplier. As before H(D) is the Hurwitz class number. For \(\epsilon \in \{\pm 1\}\), \((a, c) = 1\), \(4\mid c\), the Dirichlet series

$$\begin{aligned} \sum _{\epsilon D > 0} \frac{L(D, 1/2 + 2it)e(aD/c) |D|^{it}}{|D|^{1/2 + w}} \end{aligned}$$

has possible poles at \(w = 1/2 \pm it\) with certain residues \(R_{\epsilon }(\pm t, a/c)\), say (cf. [7, Lemma 2] in the case \(c=1\), the general case being analogous). Consequently we obtain the following analogue of Lemma 10.

Lemma 11

Let \(c\in \mathbb {N}\), \(4 \mid c\), \((a, c) = 1\), \(t \in \mathbb {R} \setminus \{0\}\). Let \(\phi \) be a smooth function with compact support in \((-\infty , 0) \cup (0, \infty )\) and for \(y > 0\) define \(\Phi \) as in (5.2). Then

$$\begin{aligned} \begin{aligned}&\sum _{D \not = 0}\frac{L(D, 1/2 + 2it)|D|^{it} }{\Gamma (\frac{1}{2} + it + \frac{1}{4} \text {{ sgn}}(D))} e\Big (\frac{aD}{c}\Big ) \phi (D) \\&\quad = \Bigg (\frac{-c}{a}\Bigg ) \epsilon _a e\Bigg (\frac{1}{8}\Bigg )\Bigg [\sum _{\epsilon \in \{\pm 1\}} \sum _{\pm } \frac{R_{\epsilon }(\pm t, a/c)}{\Gamma (\frac{1}{2} + it + \frac{1}{4}\epsilon )}\int \limits _0^{\infty } \phi (\epsilon x) x^{ \pm it} dx \\&\qquad + \sum _{D \not = 0}\frac{L(D, 1/2 + 2it)|D|^{it} }{\Gamma (\frac{1}{2} + it + \frac{1}{4} \text {{ sgn}}(D))} \frac{2\pi }{c} e\Bigg (-\frac{{\bar{a}}D}{c}\Bigg ) \Phi \Bigg (\frac{(2\pi )^2 D}{c^2}\Bigg ) \Bigg ]. \end{aligned} \end{aligned}$$

For \(t=0\) one combines the ±-terms and takes the limit as \(t \rightarrow 0\). In our application, the values \(R_{\epsilon }(t, a/c)\) are irrelevant (as long as they are polynomial in c and t) since we apply the formula with a function \(\phi \) that oscillates much more strongly that \(x^{\pm it}\) so that the integral is negligible.

We obtain a similar summation formula for Hurwitz class numbers. Although we do not need it for the present result, we compute in Appendix B the residues explicitly and get the following handsome formula.

Lemma 12

Let \(c\in \mathbb {N}\), \(4 \mid c\), \((a, c) = 1\). Let \(\phi \) be a smooth function with compact support in \((0, \infty ) \). Then

$$\begin{aligned} \begin{aligned}&\sum _{D< 0}\frac{H(D)}{|D|^{1/4}} e\Bigg (\frac{a|D|}{c}\Bigg ) \phi (|D|) \\&\quad = \Bigg (\frac{-c}{a}\Bigg ) {\bar{\epsilon }}_a e\Bigg (\frac{3}{8}\Bigg )\Bigg [ \sum _{D <0} \frac{H(D)}{|D|^{1/4}} \frac{2\pi }{c} e\Bigg (-\frac{{\bar{a}}|D|}{c}\Bigg ) \int \limits _0^{\infty } \mathcal {J}^+ \Bigg (t \frac{(2\pi )^2 |D|}{c^2}\Bigg ) \phi (t) dt\\&\qquad \qquad \qquad + \frac{1}{4\sqrt{\pi }} \sum _{ n = \square } n^{1/4} \frac{2\pi }{c} e\Bigg (\frac{{\bar{a}}n}{c}\Bigg ) \int \limits _0^{\infty } \mathcal {J}^{-}\Bigg (t \frac{(2\pi )^2 n}{c^2}\Bigg ) \phi (t) dt \\&\qquad \qquad \qquad + \int \limits _0^{\infty } \phi (x) \Bigg ( \frac{1}{\sqrt{8}c^{1/2}} x^{-1/4}- \frac{\sqrt{2}\pi }{3 c^{3/2}} x^{1/4} \Bigg ) dx \Bigg ] \end{aligned} \end{aligned}$$

where

$$\begin{aligned} \mathcal {J}^+(x) = \frac{\sin (2\sqrt{x}) }{\sqrt{\pi } x^{1/4}}, \quad \mathcal {J}^-(x) = \frac{2e^{-2\sqrt{x}}}{x^{1/4}}. \end{aligned}$$
(5.5)

Remark: Observing that for negative \(D \equiv 0, 1\) (mod 4) we have

$$\begin{aligned} e(|D|/4) + e(3|D|/4) = 2 \delta _{D \equiv 0 \, (\text {mod } 4)}, \quad -e(|D|/4) + e(3|D|/4) = 2i \delta _{D \equiv 1 \, (\text {mod } 4)}, \end{aligned}$$

it is a straightforward exercise to conclude

$$\begin{aligned} \sum _{\begin{array}{c} -X< D < 0\\ D\equiv \delta \, (\text {mod } 4) \end{array}} H(D) = \frac{\pi }{36} X^{3/2} - \frac{1}{8} X + O(X^{3/4}) \end{aligned}$$

for \(\delta = 0, 1\). Further congruence conditions on D can be imposed, and the error term can be improved by a more careful treatment of the dual term in the Voronoi formula. See [72] for the corresponding result for the ordinary class number h(d). The following table provides some numerical results (here we combined the cases \(\delta = 0\) and \(\delta = 1\)).

X

1000

2000

4000

6000

8000

10,000

\(\displaystyle \sum ^{\begin{array}{c} \quad \\ \quad \end{array}}_{D \leqslant X} H(D)\)

5280.5

15,131.3

43,189.5

79,685.7

122,967

172,106

\(\displaystyle \frac{\pi }{18} \overset{\begin{array}{c} \quad \\ \quad \end{array}}{X^{3/2}} - \frac{1}{4}X\quad \)

5269.22

15,110.7

43,153.7

79,615.6

122,885.6

\(\underset{\begin{array}{c} \quad \\ \quad \\ \quad \end{array}}{172,032.9}\)

5.2 The Kuznetsov formula

The Kuznetsov formula was generalized by Proskurin [66] to arbitrary weights and by Andersen–Duke [2] to Kohnen’s subspace. Interestingly, only the direction from Kloosterman sums to spectral sums appears to be in the literature, but no complete version in the other direction. Biró [5, p. 151] has a version only valid for test functions on the spectral side whose spectral mean value is 0, Ahlgren–Andersen [1, Sect. 3] use an approximate version.

We take this opportunity to state and prove the relevant Kuznetsov formula both for the full space of half-integral weight forms and for Kohnen’s subspace. Starting with the former, for \(\kappa \in \{1/2, 3/2\}\) the relevant Kloosterman sums are

$$\begin{aligned} K_{\kappa }(n, m, c) = \sum _{\begin{array}{c} d\, (\text {mod }c)\\ (d, c) = 1 \end{array}} \epsilon ^{2\kappa }_d \left( \frac{c}{d}\right) e\left( \frac{nd + m{\bar{d}}}{c}\right) \end{aligned}$$
(5.6)

for \(4 \mid c\). The Eisenstein series belong to the two essential cusps \(\mathfrak {a} = \infty , 0\). We normalize and denote their Fourier coefficients by \(\phi _{\mathfrak {a}m}(1/2 + it) = \phi ^{(\kappa )}_{\mathfrak {a}m}(1/2 + it)\) as in [66, (12)–(14)]. We denote by \(\left. \sum \right. ^{(\kappa )}\) a sum over an orthonormal basis of the space of cusp forms of weight \(\kappa \) and label the members by \(v_j\), \(j = 1, 2, \ldots \) with Fourier coefficients \(b_j(n)\) as in (5.1) and spectral parameters by \(t_j\). We recall the definition of F from (1.6).

Proposition 13

Let \(\kappa \in \{1/2, 3/2\}\), \(m, n > 0\). Let h be an even function, holomorphic in \(|\mathfrak {I}t| < 2/3\) with \(h(t) \ll (1 + |t|)^{-4}\). Then

$$\begin{aligned} \begin{aligned}&\left. \sum _j \right. ^{(\kappa )}\frac{\sqrt{mn}\overline{b_j(m)} b_j(n)}{\cosh (\pi t_j)} h(t_j) \\ {}&\quad + \sum _{\mathfrak {a}} \int \limits _{-\infty }^{\infty } \Bigg (\frac{n}{m}\Bigg )^{it} \frac{ \overline{\phi ^{(\kappa )}_{\mathfrak {a}m}(1/2 + it)} \phi ^{(\kappa )}_{\mathfrak {a}n}(1/2 + it)}{4\cosh (\pi t) \Gamma (\frac{1+\kappa }{2} + it)\Gamma (\frac{1+\kappa }{2}- it)} h(t) dt \\&\quad = \delta _{n=m}\int \limits _{-\infty }^{\infty } h(t) t \sinh (\pi t)\Gamma \Big ( \frac{1-\kappa }{2} + it\Big )\Gamma \Big ( \frac{1-\kappa }{2} - it\Big ) \frac{dt}{4\pi ^3} \\&\qquad + e\Big (\frac{1-\kappa }{4}\Big )\sum _c \frac{K_{\kappa }(m, n, c)}{c} \int \limits _0^{\infty } \frac{F( 4\pi \sqrt{nm}/c, 2t, -\kappa )}{\cosh (\pi t)} \\&\qquad \qquad \Gamma \Big ( \frac{1-\kappa }{2} + it\Big )\Gamma \Big ( \frac{1-\kappa }{2} - it\Big ) h(t) t\, \frac{dt}{2\pi ^2} \end{aligned} \end{aligned}$$

if in addition \(h(\pm i/4) = 0\). Moreover, regardless of the value of \(h(\pm i/4)\) we have

$$\begin{aligned}&\left. \sum _j\right. ^{(\kappa )} \frac{\sqrt{mn}\overline{b_j(-m)} b_j(-n)}{\cosh (\pi t_j)} h(t_j) \\&\qquad + \sum _{\mathfrak {a}} \int \limits _{-\infty }^{\infty } \Big (\frac{n}{m}\Big )^{it} \frac{ \overline{\phi ^{(\kappa )}_{\mathfrak {a}, -m}(1/2 + it)} \phi ^{(\kappa )}_{\mathfrak {a}, -n}(1/2 + it)}{4\cosh (\pi t)\Gamma (\frac{1-\kappa }{2} + it)\Gamma (\frac{1-\kappa }{2}- it)} h(t) dt \\&\quad = \delta _{n=m}\int \limits _{-\infty }^{\infty } h(t) t \sinh (\pi t)\Gamma \Big (\frac{1+\kappa }{2} + it\Big )\Gamma \Big (\frac{1+\kappa }{2}- it\Big ) \frac{dt}{4\pi ^3} \\&\qquad + e\Big (\frac{1+\kappa }{4}\Big )\sum _c \frac{K_{-\kappa }(m, n, c)}{c} \int \limits _0^{\infty } \frac{F( 4\pi \sqrt{nm}/c, 2t, \kappa )}{\cosh (\pi t)}\\&\qquad \Gamma \Big (\frac{1+\kappa }{2} + it\Big )\Gamma \Big (\frac{1+\kappa }{2}- it\Big ) h(t) t\, \frac{dt}{2\pi ^2}. \end{aligned}$$

Remark: Note that the space of weight 1/2 Maaß forms v with spectral parameter i/4 are in the kernel of the Maaß lowering operator. Hence \(y^{-1/4}v\) is holomorphic, so that v has no non-vanishing negative Fourier coefficients. This is consistent with the fact that the Eisenstein contribution vanishes in this case because of the gamma factors in the denominator.

Proof

By [66, Lemma 3] with \(\sigma = 1\), \(t = 2\tau \in \mathbb {R}\) and the first formula in [66, Lemma 6] we have the “pre-Kuznetsov” formula

$$\begin{aligned} \begin{aligned}&-\sum _c \frac{K_{\kappa }(m, n, c)}{c^2} x^{-\kappa }\frac{\pi }{\sinh (2\pi \tau )} \int \limits _0^{x} F(y, 2\tau , 1-\kappa )y^{\kappa - 1} dy+ \frac{\delta _{n=m}e((1+\kappa )/4)}{4\pi (n+m)} \\&\quad = \frac{\pi ^2e((1+\kappa )/4)}{2\Gamma (1 - \frac{\kappa }{2} + i\tau )\Gamma (1 - \frac{\kappa }{2} - i\tau )}\Bigg (\sum _j \frac{\overline{b_j}(m)b_j(n) }{\cosh (\pi (t_j - \tau ))\cosh (\pi (t_j + \tau ))}\\&\quad +\! \frac{1}{4\sqrt{nm}} \sum _{\mathfrak {a}} \int \limits _{-\!\infty }^{\infty } \Big (\frac{m}{n}\Big )^{-it} \frac{\overline{\phi _{\mathfrak {a}m}(1/2 \!+\! it)}\phi _{\mathfrak {a}n}(1/2 \!+\! it) }{\Gamma (\frac{1\!+\!\kappa }{2} \!+\! it) \Gamma (\frac{1\!+\!\kappa }{2} \!-\! it) \cosh (\pi (t\!-\! \tau ))\cosh (\pi (t\!+\! \tau ))} dt\Bigg ). \end{aligned} \end{aligned}$$

where

$$\begin{aligned} x = 4\pi \sqrt{mn}/c. \end{aligned}$$

Note that taking \(\sigma = 1\) is admissible in the present situation because we have the same Weil-type bounds for the Kloosterman sums \(K_{\kappa }(n, m, c)\) as for \(K^+_{\kappa }(n, m, c)\) in (1.9). Also note that there is a typo in [66, Lemma 6] in the upper limit of the integral.

For h as in the lemma and \(t \in \mathbb {R}\) we have the following inversion formula

$$\begin{aligned} \int \limits _{-\infty }^{\infty } \big (h(\tau + i/2)+ h(\tau - i/2)\big ) \frac{\cosh (\pi \tau )}{\cosh (\pi (\tau - t)) \cosh (\pi (\tau + t))} d\tau = \frac{2 h(t)}{\cosh (\pi t)}. \end{aligned}$$

This is the lemma on p. 327 of [55]Footnote 9 which is readily proved by residue calculus. We now integrate the pre-Kuznetsov formula against

$$\begin{aligned} \big (h(\tau + i/2)+ h(\tau - i/2)\big ) \cosh (\pi \tau ) \Gamma (1 - \kappa /2 + i\tau ) \Gamma (1 - \kappa /2 - i\tau ). \end{aligned}$$

Our assumptions on h ensure absolute convergence and the possibility to shift the contour up and down to \(\mathfrak {I}t = \pm 1/2\) without crossing poles. In this way the \(\delta \)-term becomes

$$\begin{aligned} \delta _{m=n} \frac{e((1+\kappa )/4)}{4\pi (m+n)}\int \limits _{-\infty }^{\infty } h(\tau ) \Gamma (1/2 - \kappa /2 + i\tau )\Gamma (1/2 - \kappa /2 - i\tau ) 2\tau \sinh (\pi \tau ) d\tau . \end{aligned}$$

For the Kloosterman term we insert the definition in (1.6) getting

$$\begin{aligned} \begin{aligned}&- \sum _c \frac{K_{\kappa }(m, n, c)}{c^2}\frac{\pi i}{2 x^{\kappa }} \int \limits _{-\infty }^{\infty }\int \limits _0^x h(\tau ) \frac{\Gamma ((1-\kappa )/2 + i\tau )\Gamma ((1-\kappa )/2 - i\tau )}{\cosh (\pi \tau )} \\&\quad \sum _{\epsilon _1, \epsilon _2 \in \{\pm 1\}} J_{\epsilon _1 + \epsilon _2 2 i \tau }(y) \cos (\pi (\kappa /2 + \epsilon _2 i \tau )) ((1 - \kappa )/2+ \epsilon _1\epsilon _2 i \tau ) y^{\kappa - 1} dy \, d\tau . \end{aligned} \end{aligned}$$

We note that

$$\begin{aligned} \begin{aligned} y^{1-\kappa }\frac{d}{dy} \Big (\frac{J_{2i\tau }(y)}{y^{1-\kappa }}\Big )&= J'_{2i\tau }(y) - \frac{(\kappa - 1)J_{2i\tau }(y)}{y} \\&= \frac{J_{2i\tau +1}(y)(i\tau + (1-\kappa )/2) + J_{2i\tau -1}(y)((1 - \kappa )/2 - i\tau )}{-2i\tau } \end{aligned} \end{aligned}$$

where the last equality follows from the recurrence relations [33, 8.471.1&2]. Substituting this, we can evaluate the y-integral by the fundamental theorem of calculus, arriving at

$$\begin{aligned} -\sum _c \frac{K_{\kappa }(m, n, c)}{c^2} \frac{\pi }{ x } \int \limits _{-\infty }^{\infty } \tau h(\tau ) \frac{\Gamma ((1-\kappa )/2 + i\tau )\Gamma ((1-\kappa )/2 - i\tau )}{\cosh (\pi r)} F(x, 2\tau , -\kappa ) d\tau \end{aligned}$$

after some elementary manipulations. We multiply the resulting expression by \(\sqrt{mn}\) to obtain the first formula. Note that the c-sum is absolutely convergent by the power series expansion of the Bessel function contained in \(F(x, 2t, -\kappa )\) and the fact that \(h(\pm i/4) = 0\), as we can shift the t-contour up and down to \(|\mathfrak {I}t| = 1/2 - \varepsilon \).

There are two ways to derive the second formula from the first. We can either observe that in Proskurin’s notation we can compute \(\langle \overline{\mathcal {U}_m(., s_1)}, \overline{\mathcal {U}_n(., {\bar{s}}_2)}\rangle \) instead of \(\langle \mathcal {U}_m(., s_1), \mathcal {U}_n(., {\bar{s}}_2)\rangle \). This changes the signs of the coefficients in the spectral expansion and has the effect of changing \(\kappa \) into \(-\kappa \). Note that in this case we do not need the extra condition \(h(\pm i/4) = 0\) to shift contours. Alternatively, we use the following fact (cf. [26, (4.17),(4.18),(4.27),(4.28),(4.64), p. 507, p. 509]): the map

$$\begin{aligned} T_{\kappa } = \Big (\Big (\textstyle \frac{\kappa - 1}{2}\Big )^2 + t^2\Big ) X\Lambda _{\kappa } \end{aligned}$$

with \(X : f(z) \mapsto f(-{\bar{z}})\) and \(\Lambda _{\kappa } = \kappa /2 + y(i\partial _x - \partial _y)\) the weight lowering operator is a bijective isometry between weight \(\kappa \) and weight \(2-\kappa \) that exchanges positive and negative Fourier coefficients:

$$\begin{aligned} \begin{aligned}&T_{\kappa } \Bigg (\sum _{n \not =0} b(n) e(nx)W_{\text {sgn}(n)\frac{\kappa }{2}, it}(4 \pi |n|y) \Bigg ) \\&\quad = \sum _{n \not = 0} b(-n) \text {sgn}(n) \Big ( \Big (\frac{\kappa - 1}{2}\Big )^2+t^2\Big )^{-\frac{1}{2}\text {sgn}(n)} e(nx)W_{\text {sgn}(n)\frac{2-\kappa }{2}, it}(4 \pi |n|y). \end{aligned} \end{aligned}$$

This yields again the second formula from the first. \(\square \)

In order to get a corresponding formula for the Kohnen space, we apply the L operator

$$\begin{aligned} \frac{1}{2(1 + i^{2\kappa })} \sum _{w \, \text {mod } 4} \left( \begin{matrix} 1+w &{} 1/4\\ 4w &{} 1\end{matrix}\right) \end{aligned}$$

to the formula. As in the case of the Petersson formula (Lemma 6), this has the effect that

  • the cuspidal term is restricted to forms in the Kohnen space;

  • the \(\delta \)-term is multiplied by 2/3; the reason for the number 2/3 is that the dimension of the Kohnen space is 1/3 of the full space, but only half of the coefficients appear;

  • the Kloosterman sums (5.6) are replaced with the Kloosterman sums (1.7) and the Kloosterman term is also multiplied by 2/3.

The hardest part is to compute the Eisenstein coefficients. All of this has been worked out in detail in [2, Sect. 5]. The corresponding formula [2, Theorem 5.3] can be inverted in the same way. In the following lemma let \(\sum ^+\) denote a sum over an orthonormal basis of weight 1/2 Maaß cusp forms in Kohnen’s space. We recall the definition (4.1) and (4.2) of L(Ds) for a discriminant D.

Lemma 14

Let \(\kappa = 1/2\) and let \(n, m \in \mathbb {Z}\) that are congruent 0 or 1 modulo 4. Let h be an even function, holomorphic in \(|\mathfrak {I}t| < 2/3\) with \(h(t) \ll (1 + |t|)^{-4}\). Then

$$\begin{aligned} \begin{aligned}&\left. \sum _j \right. ^{+}\frac{\sqrt{mn}\overline{b_j(m)} b_j(n)}{\cosh (\pi t_j)} h(t_j) \\&\qquad + \frac{1}{12}\int \limits _{-\infty }^{\infty } \Big (\frac{n}{m}\Big )^{it} \frac{L(m, 1/2 - 2it)L(n, 1/2 + it) }{|\zeta (1 + 4it)|^2\cosh (\pi t) \Gamma (\frac{1+\kappa }{2} + it)\Gamma (\frac{1+\kappa }{2}- it)} h(t) dt \\&\quad = \frac{2}{3}\delta _{n=m}\int \limits _{-\infty }^{\infty } h(t) t \sinh (\pi t)\Gamma \Big ( \frac{1-\kappa }{2} + it\Big )\Gamma \Big ( \frac{1-\kappa }{2} - it\Big ) \frac{dt}{4\pi ^3} \\&\qquad + \frac{2}{3}e\Big (\frac{1-\kappa }{4}\Big )\sum _c \frac{K^+_{\kappa }(m, n, c)}{c} \int \limits _0^{\infty } \frac{F( 4\pi \sqrt{nm}/c, 2t, -\kappa )}{\cosh (\pi t)} \\&\qquad \qquad \Gamma \Big ( \frac{1-\kappa }{2} + it\Big )\Gamma \Big ( \frac{1-\kappa }{2} - it\Big ) h(t) t\, \frac{dt}{2\pi ^2} \end{aligned} \end{aligned}$$

for \(n, m > 0\) if in addition \(h(\pm i/4) = 0\). Moreover, regardless of the value of \(h(\pm i/4)\) we have

$$\begin{aligned} \begin{aligned}&\left. \sum _j\right. ^{(+)} \frac{\sqrt{|mn|} \, \overline{b_j(m)} b_j(n)}{\cosh (\pi t_j)} h(t_j) \\&\qquad + \frac{1}{12}\int \limits _{-\infty }^{\infty } \Big (\frac{|n|}{|m|}\Big )^{it} \frac{L(m, 1/2 - 2it)L(n, 1/2 + it) }{|\zeta (1 + 4it)|^2\cosh (\pi t)\Gamma (\frac{1-\kappa }{2} + it)\Gamma (\frac{1-\kappa }{2}- it)} h(t) dt \\&\quad = \frac{2}{3} \delta _{n=m}\int \limits _{-\infty }^{\infty } h(t) t \sinh (\pi t)\Gamma \Big (\frac{1+\kappa }{2} + it\Big )\Gamma \Big (\frac{1+\kappa }{2}+ it\Big ) \frac{dt}{4\pi ^3} \\&\qquad + \frac{2}{3}e\Big (\frac{1+\kappa }{4}\Big )\sum _c \frac{K^+_{-\kappa }(|m|, |n|, c)}{c} \int \limits _0^{\infty } \frac{F( 4\pi \sqrt{|nm|}/c, 2t, \kappa )}{\cosh (\pi t)}\\&\qquad \qquad \Gamma \Big (\frac{1+\kappa }{2} + it\Big )\Gamma \Big (\frac{1+\kappa }{2}- it\Big ) h(t) t\, \frac{dt}{2\pi ^2} \end{aligned} \end{aligned}$$

if \(n, m < 0\).

6 Harmonic analysis on positive definite matrices

Here we prove Proposition 1. We identify the Hilbert spaces

$$\begin{aligned} (\mathbb {H}, y^{-2} dx\, dy) \times (\mathbb {R}_{>0}, r^{-1} dr) \cong (\mathcal {P}(\mathbb {R}), (\det Y)^{-3/2} dY) \end{aligned}$$
(6.1)

via

$$\begin{aligned} \iota : (x + iy, r) \mapsto \sqrt{r}\left( \begin{matrix} y^{-1} &{} -xy^{-1}\\ -x y^{-1} &{} y^{-1} (x^2 + y^2)\end{matrix}\right) . \end{aligned}$$

Note that for \( Y = \iota (x+iy, r)\) with \( r = \det Y\) we have

$$\begin{aligned} \Big |\det \frac{dY}{d(r, x, y)} \Big | = \frac{\sqrt{r}}{y^2}, \end{aligned}$$

so that the measures coincide. The group \({\overline{\Gamma }} = \mathrm{PSL}_2(\mathbb {Z})\) acts faithfully on \(\mathcal {P}(\mathbb {R})\) and \(\mathcal {P}(\mathbb {Z})\) (as defined after (2.5)) by \(T \mapsto U^{\top } T U\) for \(U \in {\overline{\Gamma }}\). This is compatible with the action of \({\overline{\Gamma }}\) on \(\mathbb {H}\) by Möbius transforms. Every smooth function \(f \in L^2(\Gamma \backslash \mathbb {H})\) has a spectral decomposition

$$\begin{aligned} f(z)= & {} \sum _{j \geqslant 0} \langle f, u_j \rangle u_j(z) + \int \limits _{-\infty }^{\infty } \langle f, E(., 1/2 + it)\rangle E(z, 1/2 + it) \frac{dt}{4\pi } \\= & {} \int \limits _{\Lambda } \langle f, \mathtt{u} \rangle \mathtt{u}(z) d\mathtt{u}. \end{aligned}$$

We recall the notion of the spectral parameter \(t_\mathtt{u}\) for \(\mathtt{u} \in \Lambda \); the constant function has spectral parameter i/2. Combining the spectral decomposition on \(\Gamma \backslash \mathbb {H}\) with Mellin inversion, we conclude that, for a smooth function \(\Phi \in L^2(\Gamma \backslash \mathcal {P}(\mathbb {R}))\), the spectral decomposition

$$\begin{aligned} \Phi (Y) = \Phi (\iota (x + iy, r)) = \int \limits _{(0)} \int \limits _{\Lambda } \langle {\widehat{\Phi }}(s), \mathtt{u} \rangle \mathtt{u}(x + iy) d \mathtt{u} \,\, r^{-s} \frac{ds}{2\pi i} \end{aligned}$$

holds provided \(\Phi \) is sufficiently rapidly decaying as \(r\rightarrow 0\) and \(r \rightarrow \infty \). Here,

$$\begin{aligned} {\widehat{\Phi }}(s)(x+iy) = \int \limits _0^{\infty } \Phi (\iota (x + iy, r)) r^{s} \frac{dr}{r} \end{aligned}$$

is the Mellin transform with respect to the r-variable. This gives the Parseval formula

$$\begin{aligned} \Vert \Phi (Y) \Vert ^2 = \int \limits _{\Gamma \backslash \mathcal {P}(\mathbb {R})} |\Phi (Y)|^2 \frac{dY}{(\det Y)^{3/2}} = \int \limits _{-\infty }^{\infty } \int \limits _{\Lambda } |\langle {\widehat{\Phi }}(it), \mathtt{u} \rangle |^2 d\mathtt{u}\, \frac{dt }{2\pi }. \end{aligned}$$
(6.2)

For an automorphic form \(\mathtt{u} \in \Lambda \) and a Siegel cusp form \(F \in S^{(2)}_k\) with Fourier expansion (2.5) we define the twisted Koecher–Maaß series by

$$\begin{aligned} L(F \times \mathtt{u}, s) := \sum _{T\in \mathcal {P}(\mathbb {Z})/{\overline{\Gamma }}} \frac{a(T)}{\epsilon (T)( \det T)^{s + (k-1)/2} }{} \mathtt{u}\left( (\det T)^{-1/2}T\right) \end{aligned}$$
(6.3)

where \(\epsilon (T) = \{U \in {\overline{\Gamma }} \mid U^{\top } T U = T\}\) is the stabilizer and \(\mathfrak {R}s\) is (initially) sufficiently large. This series is often defined in terms of \(\mathrm{GL}_2(\mathbb {Z})\)-equivalence instead of \({\overline{\Gamma }}\)-equivalence, but for us the present version is more convenient. This function has no Euler product, but it does have a functional equation. Let

$$\begin{aligned} G(F \times \mathtt{u}, s) := 4(2\pi )^{-k+1-2s}\prod _{\pm } \Gamma \left( \frac{k-1}{2} +s - \frac{1}{4} \pm \frac{it_\mathtt{u}}{2}\right) . \end{aligned}$$
(6.4)

Let us assume that k is even. Then for all even \(\mathtt{u}\) (including Eisenstein series and the constant function), the function \(L(F \times \mathtt{u}, s)\) has an analytic continuation to \(\mathbb {C}\) that is bounded in vertical strips and satisfies the functional equation [39, Theorem 3.5]

$$\begin{aligned} L(F \times \mathtt{u}, s) G(F \times \mathtt{u}, s) = L(F \times \mathtt{u}, 1-s) G(F \times \mathtt{u}, 1-s). \end{aligned}$$

The functional equation is a consequence of the following period formula. For \(\mathfrak {R}s\) sufficiently large we have (cf. [39, pp. 927–928])

$$\begin{aligned} \begin{aligned}&\int \limits _0^{\infty } \langle F(\iota (., r)), \mathtt{u}\rangle r^{\frac{k-1}{2} + s} \frac{dr}{r} = \int _{{\overline{\Gamma }} \backslash \mathbb {H}} \int \limits _0^{\infty } F(\iota (z, r)) r^{\frac{k-1}{2} + s} \frac{dr}{r} \overline{\mathtt{u}}(z) \frac{dx \,dy}{y^2}\\&\quad = \int \limits _{{\overline{\Gamma }} \backslash \mathcal {P}(\mathbb {R})} \sum _{T \in \mathcal {P}(\mathbb {Z})} a(T) e^{-2\pi \text {tr}(YT)} (\det Y)^{\frac{k-1}{2} + s}\overline{\mathtt{u}}\left( (\det Y)^{-1/2}Y\right) \frac{dY}{(\det Y)^{3/2}}. \end{aligned} \end{aligned}$$

Now splitting the T-sum into equivalence classes modulo \({\overline{\Gamma }}\) and unfolding the integral, this equals

$$\begin{aligned} \sum _{T\in \mathcal {P}(\mathbb {Z})/{\overline{\Gamma }}} \frac{a(T)}{\epsilon (T) } \int \limits _{ \mathcal {P}(\mathbb {R})} e^{-2\pi \text {tr}(YT)} (\det Y)^{\frac{k-1}{2} + s} \overline{\mathtt{u}}\left( (\det Y)^{-1/2}Y \right) \frac{dY}{(\det Y)^{3/2}}. \end{aligned}$$

Note that it is important that the action of \({\overline{\Gamma }}\) is faithful. The last integral over \(\mathcal {P}(\mathbb {R})\) was evaluated by Maaß [60, p. 85 and p. 94]:

$$\begin{aligned}&\int \limits _{ \mathcal {P}(\mathbb {R})} e^{- \text {tr}(YT)} (\det Y)^{ s} \overline{\mathtt{u}}\left( (\det Y)^{-1/2}Y \right) \frac{dY}{(\det Y)^{3/2}} \\&\quad = \frac{\pi ^{1/2}}{(\det T)^{s}} \overline{\mathtt{u}}\left( (\det T)^{-1/2} T\right) \prod _{\pm } \Gamma \Big (s - \frac{1}{4} \pm \frac{it_\mathtt{u}}{2}\Big ) \end{aligned}$$

for any \(\mathtt{u} \in \Lambda \). Thus we obtain

$$\begin{aligned} \int \limits _0^{\infty } \langle F(\iota (., r)), \mathtt{u}\rangle r^{\frac{k-1}{2} + s} \frac{dr}{r} = \frac{\sqrt{\pi }}{4} L(F \times \overline{\mathtt{u}}, s) G(F \times \overline{\mathtt{u}}, s), \end{aligned}$$

initially for \(\mathfrak {R}s\) sufficiently large, but then by analytic continuation for all \(s \in \mathbb {C}\). For odd \(\mathtt{u}\), the left hand side vanishes, since \(\langle F(\iota (., r)), \mathtt{u}\rangle = 0\) for every r. The Parseval formula (6.2) now implies Proposition 1 in the introduction.

In the special case where F is a Saito–Kurokawa lift, the Koecher–Maaß series simplifies.

Lemma 15

If k is even and \(F = F_h \in S_k^{(2)}\) is a Saito–Kurokawa lift with Fourier expansion as in (2.5) and (2.6) and \(\mathtt{u} \in \Lambda \), then

$$\begin{aligned} L(F_h \times \mathtt{u}, s) = 4^{s + \frac{k-1}{2}} \zeta (2s) \sum _{\begin{array}{c} D< 0\\ D \equiv 0, 1 \, (\text {{ mod }}4) \end{array}} \frac{c_h(|D|)P(D; \mathtt{u}) }{|D|^{s + \frac{k-1}{2}}} \end{aligned}$$

for \(\mathfrak {R}s\) sufficiently large and \(P(D; \mathtt{u})\) as in (1.5).

Remark: One would expect that \(c_h(|D|)\) is roughly of size \(|D|^{\frac{k}{2} - \frac{3}{4}}\) and that \(P(D; \mathtt{u})\) is roughly of size \(|D|^{\frac{1}{4}}\) (for non-constant \(\mathtt{u}\)) so that typically \(c_h(|D|)P(D; \mathtt{u})|D|^{-\frac{k-1}{2}}\) is roughly of constant size (with respect to D). Using trivial bounds for \(P(D; \mathtt{u})\) and \(c_h(|D|)\), the quantity \(c_h(|D|)P(D; \mathtt{u})|D|^{-\frac{k-1}{2}}\) is certainly \(\ll |D|^{3/4+\varepsilon }\).

Proof

We copy the argument from [12, p. 22]. Let \(\Delta \) be a negative fundamental discriminant, \(D = \Delta f^2\) a negative discriminant and \(T \in \mathcal {P}(\mathbb {Z})/{\overline{\Gamma }}\). For such \(T = \left( {\begin{matrix} n &{} r/2\\ r/2 &{} m\end{matrix}}\right) \) we write \(e(T) = (n, r, m)\) for the greatest common divisor of nmr. It follows from (2.6) that

$$\begin{aligned} \begin{aligned} L(F_h \times \mathtt{u}, s)&= 4^{s + \frac{k-1}{2}} \sum _{D = \Delta f^2} \sum _{t \mid f} \frac{1}{|D|^{s + \frac{k-1}{2}}} \sum _{\begin{array}{c} \text {det}(T) = - D/4\\ e(T) = t \end{array}} \frac{a(T)}{\epsilon (T)} \mathtt{u}((\det T)^{-1/2} T)\\&= 4^{s + \frac{k-1}{2}} \sum _{D = \Delta f^2} \sum _{d \mid t \mid f} \frac{d^{k-1} c_h(|D|/d^2)}{|D|^{s + \frac{k-1}{2}}} \sum _{\begin{array}{c} \text {det}(T) = - D/4\\ e(T) = t \end{array}} \frac{ \mathtt{u}((\det T)^{-1/2} T)}{\epsilon (T)} . \end{aligned} \end{aligned}$$

Writing \(t = t'd\) with \(t' \mid f/d\), we can evaluate the \(t'\)-sum getting

$$\begin{aligned} \begin{aligned} L(F_h \times \mathtt{u}, s)&= 4^{s + \frac{k-1}{2}} \sum _{D = \Delta f^2} \sum _{d \mid f} \frac{d^{k-1} c_h(|D|/d^2)}{|D|^{s + \frac{k-1}{2}}} P(D/d^2, \mathtt{u}) \\&= 4^{s + \frac{k-1}{2}} \zeta (2s) \sum _{D} \frac{c_h(|D|)P(D; \mathtt{u}) }{|D|^{s + \frac{k-1}{2}}} \end{aligned} \end{aligned}$$

as desired. \(\square \)

We combine Proposition 1 and Lemma 15 with (2.7) and use the notation of these formulas to derive the following basic spectral formula for the restricted norm \(\mathcal {N}(F_h)\) of a Saito–Kurokawa lift \(F_h \in S_k^{(2)}\).

Proposition 16

Let k be even and let \(F = F_h \in S_k^{(2)}\) be a Saito–Kurokawa lift with Fourier expansion as in (2.5) and (2.6). Let \(f_h \in S_{2k-2}\) denote the corresponding Shimura lift of h. Then

$$\begin{aligned} \mathcal {N}(F_h) = \frac{\pi ^2}{90 } \cdot \frac{9\sqrt{\pi }}{ L(f_h, 3/2)} \int \limits _{-\infty }^{\infty } \int \limits _{\Lambda _{\text { ev}}} |\mathcal {G}(k, t_{ \mathtt{u}}, 1/2 + it)\mathcal {L}(h, \overline{\mathtt{u}}, 1/2 + it)|^2 d\mathtt{u} \, dt, \end{aligned}$$

where

$$\begin{aligned} \begin{aligned} \mathcal {G}(k, t_\mathtt{u}, s)&= \pi ^{ - 2s} \frac{2^k\Gamma (\frac{k-1}{2} + s - \frac{1}{4} + \frac{i t_\mathtt{u}}{2})\Gamma (\frac{k-1}{2} + s - \frac{1}{4} - \frac{i t_\mathtt{u}}{2})}{(\Gamma (k) \Gamma (k-3/2))^{1/2}} \end{aligned} \end{aligned}$$
(6.5)

and \(\mathcal {L}(h, \mathtt{u}, s) \) is the analytic continuation of

$$\begin{aligned} \mathcal {L}(h, \mathtt{u}, s) = \left( \frac{\Gamma (k - 3/2)}{(4\pi )^{k-3/2}}\right) ^{1/2} \zeta (2s) \sum _{\begin{array}{c} D< 0\\ D \equiv 0, 1 \, (\text {{ mod }}4) \end{array}} \frac{c_h(|D|)P(D; \mathtt{u}) }{ \Vert h \Vert ^2 \cdot |D|^{s + \frac{k-1}{2}}} \end{aligned}$$
(6.6)

for \(\mathfrak {R}s\) sufficiently large.

The renormalized functions still satisfy the functional equation

$$\begin{aligned} \mathcal {L}(h,\overline{ \mathtt{u}} , s) \mathcal {G}(k, t_{\mathtt{u}}, s) = \mathcal {L}(h ,\overline{\mathtt{u}}, 1-s) \mathcal {G}(k, t_{ \mathtt{u}}, 1-s). \end{aligned}$$

The inclusion of the gamma factor in (6.6) is motivated by the formula in Lemma 6.

From the Dirichlet series expansion and the functional equation we obtain an approximate functional equation, cf. [44, Theorem 5.3].

Lemma 17

Let \(F = F_h\in S_k^{(2)}\) be a Saito–Kurokawa lift and \(\mathtt{u}\in \Lambda \) with spectral parameter \(t_\mathtt{u}\). For \(t, x \in \mathbb {R}\) let

$$\begin{aligned} V_t(x; k, t_\mathtt{u}) := \frac{1}{2\pi i}\int \limits _{(3)} e^{v^2} \mathcal {G}(k, t_\mathtt{u}, v + 1/2 + it) \mathcal {G}(k, t_\mathtt{u}, v + 1/2 - it) x^{-v} \frac{dv}{v}.\nonumber \\ \end{aligned}$$
(6.7)

Then

$$\begin{aligned} \begin{aligned}&|\mathcal {G}(k, t_\mathtt{u}, 1/2 + it)\mathcal {L}(h, \mathtt{u}, 1/2 + it)|^2 \\&\quad =2 \frac{\Gamma (k - 3/2)}{(4\pi )^{k-3/2}} \sum _{f_1, f_2} \sum _{D_1, D_2 < 0} \frac{c_h(|D_1|)c_h(|D_2|)P(D_1; \mathtt{u}) \overline{P(D_2; \mathtt{u}) }}{ \Vert h \Vert ^2 \cdot f_1^{1 +2it}f_2^{1-2it}|D_1|^{ k/2 + it}|D_2|^{ k/2 - it}}\\&\qquad V_{ t}(|D_1D_2| (f_1f_2)^2; k, t_\mathtt{u}). \end{aligned} \end{aligned}$$

Combining Proposition 16, Lemma 17 and (2.8) we obtain the following basic formula:

$$\begin{aligned} \begin{aligned} \mathcal {N}(F_h)&= \frac{\pi ^2}{90} \cdot 9\sqrt{\pi }\cdot 2\sum _{(n, m) = 1} \frac{\lambda (n) \mu (n)\mu ^2(m)}{n^{3/2}m^{3}} \int \limits _{-\infty }^{\infty } \int \limits _{\Lambda _{\text { ev}}} \frac{\Gamma (k - 3/2)}{(4\pi )^{k-3/2} \Vert h \Vert ^2} \\&\sum _{f_1, f_2, D_1, D_2} \frac{c(|D_1|) c(|D_2|) P(D_1; \mathtt{u})\overline{P(D_2; \mathtt{u})}}{f_1f_2 |D_1D_2|^{k/2}} \Big (\frac{|D_2|f_2^2}{|D_1|f_1^2}\Big )^{it}\\&\qquad V_{t}(|D_1D_2|(f_1f_2)^2; k, t_\mathtt{u}) d\mathtt{u} \, dt. \end{aligned} \end{aligned}$$
(6.8)

7 A relative trace formula

In this section we prove a slightly more general formula than that stated in Theorem 3. Let \(D_1 = \Delta _1f_1^2, D_2 = \Delta _2f_2^2 < 0\) be two arbitrary negative discriminants and h as specified in Theorem 3. Combining (4.8) (with t/2 in place of t) and (4.11) we have

$$\begin{aligned} \begin{aligned}&\frac{1}{|D_1D_2|^{1/4}} \int \limits _{\Lambda _{\text {ev}}} P(D_1; \mathtt{u}) \overline{P(D_2; \mathtt{u})} h(t_\mathtt{u}) d\mathtt{u} = \frac{3}{\pi } \frac{H(D_1) H(D_2)}{|D_1D_2|^{1/4}} h(i/2) \\&\quad +\!\!\!\!\!\!\!\!\! \sum _{u \text { cuspidal, even}} \frac{3}{\pi } L(u, 1/2) \Gamma (1/4 \!+\! it_u/2)\Gamma (1/4 \!-\! it_u/2) |D_1D_2|^{1/2} b(D_1)\overline{b(D_2)} h(t_u)\\&\quad + \int \limits _{-\infty }^{\infty }\left( \frac{|D_1|}{|D_2|}\right) ^{it/2} |\zeta (1/2 + it)|^2 \frac{L(D_1, 1/2 + it)L(D_2, 1/2 - it)}{2|\zeta (1 + 2it)|^2} h(t) \frac{dt}{4\pi }. \end{aligned} \end{aligned}$$

By the argument of the proof of Lemma 8 we can re-write the sum over even cusp forms u as a sum over weight 1/2 cusp forms v in Kohnen’s space. Thus the last two terms of the preceding display become

$$\begin{aligned} \begin{aligned}&\left. \sum _{j}\right. ^{(+)} \frac{3}{\pi } L(u_j, 1/2) \Gamma (1/4 + it_j)\Gamma (1/4 - it_j) |D_1D_2|^{1/2} b_j(D_1)\overline{b_j(D_2)} h(2t_j)\\&\quad + \int \limits _{-\infty }^{\infty }\left( \frac{|D_1|}{|D_2|}\right) ^{it} |\zeta (1/2 + 2it)|^2 \frac{L(D_1, 1/2 + 2it)L(D_2, 1/2 - 2it)}{2|\zeta (1 + 4it)|^2} h(2t) \frac{dt}{2\pi }. \end{aligned} \end{aligned}$$

Here, as in Lemma 14, \(\sum ^{(+)}\) indicates a sum over an orthonormal basis of weight 1/2 cusp forms \(v_j\) in Kohnen’s space with spectral parameter \(t_j\) and Fourier coefficients \(b_j(D)\), and \(u_j\) is the corresponding Shimura lift with spectral parameter \(2t_j = t_u\). If \(\lambda _j(n)\) are the Hecke eigenvalues of \(u_j\), then by the approximate functional equations (4.14) and (4.16) with \(\Delta = 1\) we can write

$$\begin{aligned} L(u_j, 1/2) = 2\sum _n \frac{\lambda _j(n)}{n^{1/2}} W_{2t_j}(n) \end{aligned}$$

and

$$\begin{aligned}&|\zeta (1/2 + 2it)|^2 \\&\quad = 2\displaystyle \sum _n \dfrac{\rho _{1/2 + 2it}(n)}{n^{1/2}} W_{2t}(n) -\displaystyle \sum _{\pm } \dfrac{\zeta (1 \pm 4it)\Gamma (\frac{1}{2} \pm 2it)\pi ^{\mp 2it} e^{(1/2 \pm 2 it)^2}}{(\frac{1}{2} \pm 2i t)\Gamma (\frac{1}{4} + it)\Gamma (\frac{1}{4} - it)} \end{aligned}$$

with \(W_t\) as in (4.15) with \(\mathfrak {a} = 0\). Note that \(W_{2t}(x)\) is even and holomorphic in \(|\mathfrak {I}t | <2/3\), satisfying the uniform bound \(W_{2t}(x)\ll (1+|t|^2)/x^2 \) in this region (by trivial bounds). Moreover \(W_{2t}(x)\) vanishes at \(t = \pm i/4\). We first deal with residue term in the formula for \(|\zeta (1/2 + 2it)|^2\) and substitute this back into the Eisenstein term. This gives

$$\begin{aligned}&- \sum _{\pm } \int \limits _{-\infty }^{\infty } \left( \frac{|D_1|}{|D_2|}\right) ^{it} \frac{ \Gamma (\frac{1}{2} \pm 2it)\pi ^{\mp 2it} e^{(1/2 \pm 2 it)^2}}{(\frac{1}{2} \pm 2i t)\Gamma (\frac{1}{4} + it)\Gamma (\frac{1}{4} - it)} \\&\quad \frac{L(D_1, 1/2 + 2it)L(D_2, 1/2 - 2it)}{2\zeta (1 \mp 4it)} h(2t) \frac{dt}{2\pi }. \end{aligned}$$

We can slightly simplify this by applying in the plus-term the functional equation for \(L(D_1, 1/2 + 2it)\) and changing t to \(-t\), and in the minus-term the functional equation (4.3) for \(L(D_2, 1/2 - 2 i t)\). In this way we see that the two terms are equal and after some simplification we obtain

$$\begin{aligned} 2 \int \limits _{-\infty }^{\infty } |D_1D_2|^{ it} \frac{ 2^{-\frac{3}{2} - 2 i t}\Gamma (-\frac{1}{4} + it) e^{(1/2- 2 it)^2}}{ \sqrt{\pi } \Gamma (\frac{1}{4} + i t)} \frac{L(D_1, 1/2 + 2it)L(D_2, 1/2 + 2it)}{2\zeta (1+ 4it)} h(2t) \frac{dt}{2\pi }. \end{aligned}$$

Our next goal is to use the half-integral weight Hecke relations to combine \(\lambda _j(n) b_j(D_1)\). For notational simplicity let us define \(\tilde{b}_j(D_1) = \sqrt{|D_1|}b_j(D_1)\). From (3.10) we obtain

$$\begin{aligned} \begin{aligned} \lambda (n) \tilde{b}_j(D_1)&= \tilde{b}_j(D_1) = \tilde{b}(\Delta _1) \sum _{d \mid f_1} \frac{\mu (d) \chi _{\Delta _1}(d)}{d^{1/2}} \lambda \Big (\frac{f_1}{d}\Big ) \lambda (n)\\&= \tilde{b}_j(\Delta _1) \sum _{\begin{array}{c} d_1rs = f_1\\ r \mid n \end{array}} \frac{\mu (d_1) \chi _{\Delta _1}(d_1)}{d_1^{1/2}} \lambda \Big (\frac{sn}{r}\Big ) \\&= \sum _{\begin{array}{c} d_1rs = f_1\\ r \mid n \end{array}} \frac{\mu (d_1) \chi _{\Delta _1}(d_1)}{d_1^{1/2}} \sum _{m \mid sn/r} \frac{\chi _{\Delta _1}(m)}{\sqrt{m}} \tilde{b}_j\Big (\Delta _1 \Big (\frac{sn}{rm}\Big )^2\Big ). \end{aligned} \end{aligned}$$

In the last step we used (3.10) again together with Möbius inversion. This yields

$$\begin{aligned} \begin{aligned}&\sum _n \frac{\lambda _j(n)}{n^{1/2}} W_{2t}(n)\tilde{b}_j(D_1)\\ {}&\quad = \sum _{ d_1rs = f_1 }\frac{\mu (d_1) \chi _{\Delta _1}(d_1)}{d_1^{1/2}} \sum _n \frac{W_{2t}(rn)}{\sqrt{rn}} \sum _{m \mid sn} \frac{\chi _{\Delta _1}(m)}{\sqrt{m}} \tilde{b}_j\Big (\Delta _1 \Big (\frac{sn}{m}\Big )^2\Big ) \\&\quad = \sum _{ d_1rs = f_1 }\frac{\mu (d_1) \chi _{\Delta _1}(d_1)}{d_1^{1/2}} \sum _{n, m} \frac{W_{2t}(rn m/(m, s))}{\sqrt{rn m/(m, s)}} \frac{\chi _{\Delta _1}(m)}{\sqrt{m}} \tilde{b}_j\Big (\Delta _1 \Big (\frac{sn}{(m, s)}\Big )^2\Big ) \\&\quad = \sum _{ d_1rs = f_1 }\frac{\mu (d_1) \chi _{\Delta _1}(d_1)}{d_1^{1/2}} \sum _{\tau u = s} \sum _{n}\sum _{(m, u) = 1} \frac{W_{2t}(rn m)}{\sqrt{rn m }} \frac{\chi _{\Delta _1}(m\tau )}{\sqrt{m\tau }} \tilde{b}_j(\Delta _1 (un)^2)\\&\quad = \sum _{ d_1rs = f_1 }\frac{\mu (d_1) \chi _{\Delta _1}(d_1)}{d_1^{1/2}} \sum _{\tau u = s} \sum _{n, m} \sum _{v\mid u} \mu (v) \frac{W_{2t}(rn vm)}{\sqrt{rn vm }} \frac{\chi _{\Delta _1}(vm\tau )}{\sqrt{vm\tau }} \tilde{b}_j(\Delta _1 (un)^2)\\&\quad = \sum _{ d_1r\tau vw = f_1 }\sum _{n, m} \frac{\mu (d_1)\mu (v) \chi _{\Delta _1}(d_1vm\tau )}{\sqrt{d_1rn\tau } vm} W_{2t}(rn vm) \tilde{b}_j(\Delta _1 (vwn)^2). \end{aligned} \end{aligned}$$

Comparing (3.10) and (4.2), we see that the same Hecke relations hold for Eisenstein series, and we therefore have

$$\begin{aligned} \begin{aligned}&\sum _n \frac{\rho _{1/2 + 2it}(n)}{n^{1/2}} W_{2t}(n) |D_1|^{it} L(D_1, 1/2 + 2 it) \\&\quad = \sum _{ d_1r\tau vw = f_1 }\sum _{n, m} \frac{\mu (d_1)\mu (v) \chi _{\Delta _1}(d_1vm\tau )}{\sqrt{d_1rn\tau } vm} W_{2t}(rn vm) (\Delta _1(vwn)^2)^{it} \\&\qquad L(\Delta _1 (vwn)^2, 1/2 + 2it). \end{aligned} \end{aligned}$$

We are now in a position to apply the second Kohnen-Kuznetsov formula in Lemma 14 with

$$\begin{aligned} \frac{6}{\pi } \Gamma (1/4 + it)\Gamma (1/4 - it) \cosh (\pi t) W_{2t}(rnvm) h(2t) \end{aligned}$$

in place of h(t). This function satisfies the hypotheses of that formula (and decays rapidly enough in n and m), recall that \(W_{2t}(n)\) vanishes at \(t = \pm i/4\). The diagonal exists only if \(\Delta _1 = \Delta _2\) and \(vwn = f_2\). For a function H we introduce the integral transform

$$\begin{aligned} H^{\dagger }(x) = \int \limits _{-\infty }^{\infty } \frac{F(x, t, 1/2)}{\cosh (\pi t)} H(t) t \frac{dt}{\pi } \end{aligned}$$
(7.1)

with F as in (1.6).

Theorem 18

Let \(D_1 = \Delta _1 f_1^2, D_2 = \Delta _2f^2_2\) be negative discriminants and let h be an even function, holomorphic in \(|\mathfrak {I}t | < 2/3\) with \(h(t) \ll (1+|t|)^{-10}\). Define \(W_t\) as in (4.15), L(Ds) as in (4.1) and \(K^+_{3/2}(a, b, c)\) as in (1.7). Then

$$\begin{aligned} \begin{aligned}&\frac{1}{|D_1D_2|^{1/4}}\int \limits _{\Lambda _{\text {ev}}} P(D_1; \mathtt{u}) \overline{P(D_2; \mathtt{u})} h(t_\mathtt{u}) d\mathtt{u} = \frac{3}{\pi } \frac{H(D_1)H(D_2)}{|D_1D_2|^{1/4}} h(i/2)\\&\quad + \int \limits _{-\infty }^{\infty } \Big |\frac{D_1D_2}{4}\Big |^{ it/2} \frac{ \Gamma (-\frac{1}{4} + \frac{it}{2}) e^{(1/2- it)^2}}{ \sqrt{8\pi } \Gamma (\frac{1}{4} + \frac{i t}{2})} \frac{L(D_1, 1/2 + it)L(D_2, 1/2 + it)}{ \zeta (1+ 2it)} h(t) \frac{dt}{4\pi }\\&\quad + \delta _{\Delta _1= \Delta _2} \sum _{\begin{array}{c} d_1r \tau v w = f_1\\ vwn = f_2 \end{array}} \sum _m \frac{\mu (d_1)\mu (v) \chi _{\Delta _1}(d_1vm\tau )}{\sqrt{d_1rn\tau } vm} \int \limits _{-\infty }^{\infty } W_{t}( rnvm) h(t) t \tanh (\pi t) \frac{dt}{4\pi ^2} \\&\quad + e(3/8)\sum _{ d_1r\tau vw = f_1 }\sum _{n, c, m} \frac{\mu (d_1)\mu (v) \chi _{\Delta _1}(d_1vm\tau )}{\sqrt{d_1rn\tau } vm} \\&\qquad \qquad \frac{ K_{3/2}^+(|\Delta _1|(vwn)^2, |D_2|, c)}{ c} H_{ rnvm}^{\dagger }\Big (\frac{4\pi vwn\sqrt{|\Delta _1D_2|}}{c}\Big )\\ \end{aligned} \end{aligned}$$

where \(H_{b}(t) = h(t)W_{t}(b)\) and \(H^{\dagger }\) is given by (7.1).

Remarks:

(1) Specializing \(f_1 = f_2 = 1\) we obtain Theorem 3.

(2) Recall again that \(W_t(x) = 0\) for \(t = \pm i/2\), so that contour shifts in the t-integral ensure that the cn-sum is absolutely convergent.

(3) The first term on the right hand side corresponds to the constant function and is obviously indispensable. In all practical applications, the t-integral in the second term is of bounded length due to the factor \(\exp ((1/2 - it)^2)\), so that by subconvexity bounds for \(L(D, 1/2 + it)\) this term is dominated by the class number term. The last term can be analyzed in the same way as a typical off-diagonal term in the Kuznetsov formula except that it contains an extra n-sum of length \(\approx |t|\) from the approximate functional equation, cf. (9.17) below. Contrary to its appearance, the diagonal term is symmetric in \(f_1, f_2\) (as it should be) and can be written as

$$\begin{aligned}&\delta _{\Delta _1 = \Delta _2} \int \limits _{-\infty }^{\infty } \int \limits _{(2)} \frac{\Gamma (\frac{1}{2}(\frac{1}{2} + s +2 it))\Gamma (\frac{1}{2}(\frac{1}{2} + s - 2it))}{\Gamma (\frac{1}{4}+it)\Gamma (\frac{1}{4}-it) \pi ^{s} }\frac{e^{s^2} }{s} L(\chi _{\Delta _1}, s)\\&\quad P(f_1, f_2, s) h(t) t \tanh (\pi t) \frac{ds}{2\pi i} \frac{dt}{4\pi ^2} \end{aligned}$$

where

$$\begin{aligned} P(f_1, f_2, s) = \prod _p \frac{p^{-\alpha _p(s + 1/2)} - p^{(\beta _p - 2)(s + 1/2)} - \chi _{\Delta _1}(p)p^{2s-1/2}(p^{-\alpha _p(s+1/2)} - p^{-\beta _p(s+1/2)} ) }{1 - p^{2s + 1}} \end{aligned}$$

with \(\alpha _p = \max (v_p(f_1), v_p(f_2))\) and \(\beta _p = \min (v_p(f_1), v_p(f_2))\) for the usual p-adic valuation \(v_p\).

8 Mean values of L-functions

This section is devoted to the proof of Proposition 4. To begin with, we recall Heath-Brown’s large sieve in two variations [34, Corollaries 3 & 4]Footnote 10

Lemma 19

(a) Let \(N, Q \geqslant 1\), let S(Q) denote the set of real primitive characters of conductor up to Q and let \((a_n)\) be a sequence of complex numbers with \(|a_n| \leqslant 1\). Then

$$\begin{aligned} \sum _{\chi \in S(Q)} \Big |\sum _{n \leqslant N} a_n\chi (n)\Big |^2 \ll N(Q+N) (QN)^{\varepsilon } \end{aligned}$$

for every \(\varepsilon > 0\).

(b) Let \(D, N \geqslant 1\), \((a_n), (b_{\Delta })\) be two sequences of complex numbers with \(|a_m|, |b_{\Delta }| \leqslant 1\), where \(b_{\Delta }\) is supported on the set of fundamental discriminants \(\Delta \). Then

$$\begin{aligned} \sum _{|\Delta | \leqslant D} \sum _{n \leqslant N}a_n b_{\Delta } \chi _{\Delta }(n) \ll (DN)^{1+\varepsilon } (D^{-1/2} + N^{-1/2}). \end{aligned}$$

We start with part (a) of the proposition. As mentioned in the introduction, \(L(u \times \chi , 1/2) = 0\) if u is odd for root number reasons. For even u we use the approximate functional equation (4.14) and write

$$\begin{aligned} L({ u} \times \chi _{\Delta }, 1/2 ) = \frac{1}{2\pi i}\int \limits _{(2)} \sum _{n} \frac{\lambda _{ u}(n) \chi _{\Delta }(n)}{n^{1/2 + s}} |\Delta |^s G(s, t_{ u} ) ds \end{aligned}$$
(8.1)

with

$$\begin{aligned} G(s, t_{ u} ) = \frac{2 e^{s^2}\Gamma ((1/2 + \mathfrak {a} + s + it_{ u})/2)\Gamma ((1/2 + \mathfrak {a} + s - it_{ u})/2)}{\Gamma ((1/2 + \mathfrak {a}+ it_{ u})/2)\Gamma ((1/2 + \mathfrak {a}- it_{ u})/2)\pi ^s s} \end{aligned}$$

where \(\mathfrak {a} = 1\) if \(\Delta < 0\) and \(\mathfrak {a} = 0\) if \(\Delta > 0\). We can treat positive and negative discriminants separately, so that we may assume that \(G(s, t_{ u} ) \) is independent of \(\Delta \). Eventually we would like to apply the Cauchy-Schwarz inequality, the spectral large sieve inequality and Heath-Brown’s large sieve for quadratic characters. The latter requires that the n-sum is restricted to odd squarefree integers. Therefore we uniquely factorise \(n = 2^{\alpha } n_1n_2^2\) with \(n_1, n_2\) odd, \(n_1\) squarefree and use the Hecke relations to write

$$\begin{aligned} \begin{aligned} \sum _{n }\frac{\lambda _{ u}(n) \chi _{\Delta }(n)}{n^{1/2 + s}} =&\sum _{\alpha }\frac{\lambda _{ u}(2^{\alpha }) \chi _{\Delta }(2^{\alpha })}{2^{\alpha (1/2 + s)}} \sum _{2 \not \mid n_1 } \frac{\mu ^2(n_1)\lambda _{ u}(n_1) \chi _{\Delta }(n_1)}{n_1^{1/2 + s}} \\&\sum _{(n_2, 2\Delta ) = 1 } \frac{ \lambda _{ u}(n_2^2) }{n_2^{1 + 2s}} \sum _{2 \not \mid d} \frac{\mu (d) \chi _{\Delta }(d)}{d^{3/2 + 3s}}.\\ \end{aligned} \end{aligned}$$

We use Möbius inversion to detect the condition \((n_2, \Delta ) = 1\) and we observe that the \(\alpha \)-sum depends only on \(\Delta \) modulo 8. Therefore

$$\begin{aligned} \begin{aligned}&\sum _{ |\Delta | \leqslant \mathcal {D}} \sum _{n } \frac{\lambda _{ u}(n) \chi _{\Delta }(n)}{n^{1/2 + s}} |\Delta |^s \\&\quad = \sum _{2 \not \mid d f} \frac{\mu (d)\mu (f) \chi _f(d)}{d^{3/2 +3s}f^{1+s}} \sum _{\delta \in \{0, 1, 4, 5\}} P(s; { u}, \delta , f) \\&\qquad \sum _{ \begin{array}{c} |\Delta '| \leqslant \mathcal {D}/f\\ \Delta ' \equiv {\bar{f}}\delta \, (\text {mod } 8) \end{array}} \sum _{ 2 \not \mid n_1 } \frac{\mu ^2(n_1) \chi _f(n_1)\lambda _{ u}(n_1) (\frac{\Delta '}{n_1d})}{n_1^{1/2 + s}} |\Delta '|^s \end{aligned} \end{aligned}$$

where \(\Delta ' f\) is restricted to negative fundamental discriminants and

$$\begin{aligned} P(s; { u}, \delta , f) := \sum _{\alpha }\frac{\lambda _{ u}(2^{\alpha }) \chi (\delta , 2^{\alpha })}{2^{\alpha (1/2 + s)}} \sum _{2 \not \mid n_2 } \frac{ \lambda _{ u}(f^2n_2^2) }{n_2^{1 + 2s}} \ll f^{2\theta +\varepsilon } \end{aligned}$$

uniformly in \(\mathfrak {R}s \geqslant \varepsilon \) for \(\theta = 7/64\) by the Kim-Sarnak bound. In the above formula we define \(\chi (\delta , 2^{\alpha }) := \chi _{\Delta }(2^{\alpha })\) for any \(\Delta \equiv \delta \) (mod 8).

We substitute this back into (8.1). Shifting the contour to the far right, we can truncate the \(n_1\)-sum at \(n_1 \leqslant ( \mathcal {D}\mathcal {T})^{1+\varepsilon } \) for \(|t_u| \leqslant \mathcal {T}\) at the cost of a negligible error. Having done this, we shift the contour back to \(\mathfrak {R}s = \varepsilon \), truncate the integral at \(|\mathfrak {I}s| \leqslant ( \mathcal {D}\mathcal {T})^{\varepsilon }\), again with a negligible error, so that

$$\begin{aligned} \begin{aligned}&\sum _{t_{ u} \leqslant \mathcal {T}} \sum _{\begin{array}{c} |\Delta | \leqslant \mathcal {D}\\ \Delta \text { fund. discr.} \end{array}} \alpha (u) L({u} \times \chi _{\Delta }, 1/2) \ll ( \mathcal {D}\mathcal {T})^{O(\varepsilon )} \sup _{ \begin{array}{c} N \leqslant ( \mathcal {D}\mathcal {T})^{1+\varepsilon }\\ \mathfrak {R}s = \varepsilon \end{array}} \sum _{2 \not \mid df} \frac{\mu ^2(d)}{d^{3/2+\varepsilon }f^{1-2\theta }} \\&\quad \times \sum _{t_{ u} \leqslant \mathcal {T}} \Bigg | \alpha (u) \sum _{\begin{array}{c} N \leqslant n_1 \leqslant 2N\\ 2 \not \mid n_1 \end{array} } \frac{\mu ^2(n_1) \chi _f(n_1)\lambda _{ u}(n_1)}{n_1^{1/2 + s}} \sum _{ \begin{array}{c} |\Delta '| \leqslant \mathcal {D}/f\\ \Delta ' \equiv {\bar{f}}\delta \, (\text {mod } 8) \end{array}}\Big (\frac{\Delta '}{n_1d}\Big ) |\Delta '|^s \Bigg | . \end{aligned} \end{aligned}$$

A priori, the right hand side is restricted to even u, but by positivity we can extend it to all u. Next we apply the Cauchy-Schwarz inequality. In the second factor we artificially insert \(1/L(\text {sym}^2{ u}, 1)\) at the cost of a factor of \(\mathcal {T}^{\varepsilon }\) (by (4.13)) to convert the Hecke eigenvalues into Fourier coefficients and apply the spectral large sieve inequality [21, Theorem 2]. This leaves us with bounding

$$\begin{aligned} \begin{aligned}&( \mathcal {D}\mathcal {T})^{O(\varepsilon )} \Big (\sum _{t_u \leqslant \mathcal {T}} |\alpha (u)|^2\Big )^{1/2} \sum _{2 \not \mid df} \frac{\mu ^2(d)}{d^{3/2+\varepsilon }f^{1-2\theta }} \\&\quad \Bigg ( \frac{\mathcal {T}^2 + N}{N} \sum _{\begin{array}{c} N \leqslant n_1 \leqslant 2N \\ 2 \not \mid n_1 \end{array}} \mu ^2(n_1) \Big | \sum _{ \begin{array}{c} |\Delta '| \leqslant \mathcal {D}/f\\ \Delta ' \equiv {\bar{f}}\delta \, (\text {mod } 8) \end{array}} \Big (\frac{\Delta '}{n_1d}\Big )|\Delta '|^s \Big |^2\Bigg )^{1/2} \end{aligned} \end{aligned}$$
(8.2)

for \(N \leqslant ( \mathcal {D}\mathcal {T})^{1+\varepsilon }\).

For a given odd, squarefree \(d \in \mathbb {N}\), the \(n_1\)-sum equals

$$\begin{aligned} \begin{aligned}&\sum _{ r_1r_2 = d } \sum _{\begin{array}{c} N/r_1 \leqslant n_1 \leqslant 2N/r_1\\ ( n_1, 2 r_2) = 1 \end{array}} \mu ^2(r_1n_1) \Bigg | \sum _{ \begin{array}{c} |\Delta '| \leqslant \mathcal {D}/f\\ \Delta ' \equiv {\bar{f}}\delta \, (\text {mod } 8)\\ (\Delta ', r_1) = 1 \end{array}} \Big (\frac{\Delta '}{n_1r_2}\Big ) |\Delta '|^s \Bigg |^2\\&\quad \leqslant \sum _{ r_1r_2 = d } \sum _{\begin{array}{c} n \leqslant 2Nr_2\\ 2 \not \mid n \end{array}} \tau (n) \mu ^2(n) \Bigg | \sum _{ \begin{array}{c} |\Delta '| \leqslant \mathcal {D}/f\\ \Delta ' \equiv {\bar{f}}\delta \, (\text {mod } 8)\\ (\Delta ', r_1) = 1 \end{array}} \Big (\frac{\Delta '}{n}\Big ) |\Delta '|^s \Bigg |^2. \end{aligned} \end{aligned}$$

For odd squarefree \(n \not = 1\), the map \(\Delta ' \mapsto (\frac{\Delta '}{n})\) is a primitive quadratic character of conductor n, so that by Heath-Brown’s large sieve for quadratic characters (Lemma 19a) this expression is bounded by

$$\begin{aligned} \ll (\mathcal {D}\mathcal {T})^{\varepsilon }\Big (Nd + \frac{\mathcal {D}}{f}\Big ) \frac{\mathcal {D}}{f}. \end{aligned}$$

Putting everything together, we complete the proof of Proposition 4(a).

The proof of part (b) is almost identical except that the spectral large sieve is replaced with the standard bound [44, Theorem 9.1] for Dirichlet polynomials. Here we use the approximate functional equation

$$\begin{aligned} L( \chi _{\Delta }, 1/2 + i t )^2= & {} \frac{1}{2\pi i}\int \limits _{(2)} \Big ( \sum _{n} \frac{\tau (n) \chi _{\Delta }(n)}{n^{1/2 + it + s}} |\Delta |^s \tilde{G}(s, t ) \\&+ \epsilon (t)\sum _{n} \frac{\tau (n) \chi _{\Delta }(n)}{n^{1/2 - it + s}} |\Delta |^s \tilde{G}(s, -t ) \Big ) ds \end{aligned}$$

where \(|\epsilon (t)| = 1\) and

$$\begin{aligned} \tilde{G}(s, t) = \frac{ e^{s^2}\Gamma (1/2 +\mathfrak {a} + s + it/2)^2}{\Gamma (1/2+\mathfrak {a} + it/2)^2 \pi ^s s} \frac{1}{(\frac{1}{4} + t^2)^2} \prod _{\epsilon _1, \epsilon _2 \in \{\pm 1\}} \Big (\epsilon _1 s - \Big (\frac{1}{2} +\epsilon _2 it\Big )\Big ). \end{aligned}$$

We included the polynomial in order to counteract the pole at \(s=1/2 - it\) of \(L(\chi _{\Delta }, s + 1/2 + it)^2\) for \(\Delta = 1\), so that no residual term arises in the approximate functional equation. The function \(\tilde{G}\) has similar analytic properties as G above, and the divisor function \(\tau \) satisfies the same Hecke relations as \(\lambda _u\). The proof is now almost literally the same, except that the factor \((\mathcal {T}^2 + \mathcal {N})/\mathcal {N}\) in (8.2) is \((\mathcal {T} + \mathcal {N})/\mathcal {N}\). Thus the proof of Proposition 4 is concluded.

9 Interlude: special functions and oscillatory integrals

In this rather technical section we compile various sums and integrals over Bessel functions and other oscillatory integrals that we need as a preparation for the proof of Theorem 2. To start with, the following lemma is a half-integral weight version of [42, Lemma 5.8], but with a somewhat different proof.

Lemma 20

Let \(x > 0\) \( A \geqslant 0\), \(K > 1\). Let w be a smooth function with support in [1, 2] satisfying \(w^{(j)}(x) \ll _{\varepsilon , j} K^{j\varepsilon }\) for \(j \in \mathbb {N}_0\). Then there exist smooth functions \(w_0, w_+, w_-\) such that for every \(j \in \mathbb {N}_0\) we have

$$\begin{aligned} w_0(x) \ll _A K^{-A}, \end{aligned}$$
$$\begin{aligned} \frac{d^j}{dx^j}w_{\pm }(x) \ll _{j, A } \Big (1 + \frac{K^2}{x}\Big )^{-A} \frac{1}{x^j} \end{aligned}$$
(9.1)

and

$$\begin{aligned} \sum _{k\text {even}} i^k w\left( \frac{k}{K}\right) J_{k-3/2}(x) = \sum _{\pm } e^{\pm ix} w_{\pm }(x) + w_0(x). \end{aligned}$$
(9.2)

The implied constants in (9.1) depend on the B-th Sobolev norm of w for a suitable \(B= B(A, j)\). The functions \(w_{\pm }\) are explicitly given in (9.3) and (9.5).

Proof

We denote the left hand side of (9.2) by W(x). For \(k \in \mathbb {N}\), by [33, 8.411.13] we have

$$\begin{aligned} J_{k - 3/2}(x) = \int \limits _{-1/2}^{1/2} e(k \theta ) e(-3\theta /2) e^{-ix \sin (2\pi \theta )} d\theta - \frac{(-1)^k}{\pi } \int \limits _0^{\infty } e^{-(k - 3/2)\theta - x \sinh \theta } d\theta . \end{aligned}$$

We put

$$\begin{aligned} W_1(x)= & {} - \sum _{k\text {even}} i^k w\left( \frac{k}{K}\right) \frac{1}{\pi } \int \limits _0^{\infty } e^{-(k - 3/2)\theta - x \sinh \theta } d\theta ,\\ W_1^{\pm }(x)= & {} \frac{1}{2}e^{\mp i x} \sum _{k \in \mathbb {Z}} (\pm i)^k w\left( \frac{k}{K}\right) \int \limits _{-1/2}^{1/2} e(k \theta ) e(-3\theta /2) e^{-ix \sin (2\pi \theta )} d\theta . \end{aligned}$$

Applying Poisson summation modulo 4, we have

$$\begin{aligned} \sum _{k\text { even}} i^k w\left( \frac{k}{K}\right) e^{-k\theta } = \frac{1}{4} \sum _{\begin{array}{c} \kappa \, (\text {mod }4)\\ \kappa \equiv 0, 2 \, (\text {mod } 4) \end{array}} i^{\kappa } \sum _{h \in \mathbb {Z}} e\left( \frac{h\kappa }{4}\right) \int \limits _{-\infty }^{\infty } w\left( \frac{y}{K}\right) e^{-y\theta } e\left( \frac{y h}{4}\right) dy. \end{aligned}$$

The \(h = 0\) term vanishes (as do all even h), and by partial integration the other terms are bounded by \(O_n( K |h|^{-n}( K^{-(1-\varepsilon )n} + \theta ^n) e^{-K\theta })\) for any \(n \in \mathbb {N}\), so that

$$\begin{aligned} W_1(x) \ll _n K \int \limits _0^{\infty } (K^{-(1-\varepsilon )n} + \theta ^n) e^{-K\theta } e^{-x \sinh \theta } d\theta \ll _n K^{-(1-\varepsilon )n}. \end{aligned}$$

Again by Poisson summation we have

$$\begin{aligned} \begin{aligned} W^+_1(x)&=\frac{1}{2}e^{- i x} \int \limits _{-1/2}^{1/2} e(-3\theta /2) e^{-ix \sin (2\pi \theta )} \sum _{h \in \mathbb {Z}} \int \limits _{-\infty }^{\infty } e\left( \frac{y}{4}\right) w\left( \frac{y}{K}\right) e(y\theta ) e(-hy) dy \, d\theta \\&= \frac{e(3/8)}{2}e^{- i x} \int \limits _{-1/4}^{3/4} e(-3\theta /2) e^{ix \cos (2\pi \theta )} \sum _{h \in \mathbb {Z}} \int \limits _{-\infty }^{\infty } w\left( \frac{y}{K}\right) e(y\theta ) e(-hy) dy \, d\theta . \end{aligned} \end{aligned}$$

Since \(-1/4 < \theta \leqslant 3/4\), we see by partial integration in the y-integral that the contribution of \(h \not = 0\) is \(O_A(K^{-A})\). Let v be a smooth function with compact support in \([-2, 2]\), identically equal to 1 on \([-1, 1]\). Then for \(h = 0\) we can smoothly truncate the \(\theta \)-integral by inserting the function \(v(\theta K^{9/10})\), the error being again \(O_A(K^{-A})\) by partial integration. We obtain \(W_1^+(x) = W_2^+(x) + W_2(x)\), where \(W_2(x) \ll _A K^{-A}\) and after changing variables

$$\begin{aligned} \begin{aligned} W_2^+(x)&= \frac{e(3/8)}{2}e^{- i x} \int \limits _{-\infty }^{\infty } v(\theta K^{-1/10}) e\Big (\frac{-3\theta }{2K}\Big ) e^{ix \cos (2\pi \theta /K)} \\&\quad \int \limits _{-\infty }^{\infty } w(y) e(y\theta ) dy \, d\theta . \end{aligned} \end{aligned}$$
(9.3)

Then for \(j \in \mathbb {N}_0\) we have

$$\begin{aligned} \begin{aligned}&\frac{d^j}{dx^j}W_2^+(x) \\&\quad = \frac{e(3/8)}{2} \int \limits _{-\infty }^{\infty } w(y) \int \limits _{-\infty }^{\infty } v(\theta K^{-1/10}) e^{i \phi ( \theta ; x, y)} (i(\cos (2\pi \theta /K) - 1))^j d\theta \, dy \end{aligned} \end{aligned}$$
(9.4)

with \(\phi (\theta ; x, y) = -3\pi \theta /K+ 2\pi \theta y + x ( \cos (2\pi \theta /K)-1)\) satisfying

$$\begin{aligned} \frac{d}{d\theta } \phi (\theta ; x, y) = -\frac{3\pi }{K} + 2\pi y + 2\pi \frac{x}{K} \sin \Big (2\pi \frac{\theta }{K}\Big ) \quad \text {and} \quad \frac{d^j}{d\theta ^j} \phi (\theta ; x, y) \ll \frac{x}{K^j}, \,\,j \geqslant 2. \end{aligned}$$

In the following we frequently use the Taylor expansions \(\sin (t) = t + O(t^3)\) and \(\cos (t) = 1 - t^2/2 + O(t^4)\).

We first extract smoothly the range \(|\theta | \leqslant \frac{1}{100} K^2/x\). Here we observe that the derivative \(\frac{d}{d\theta } \phi (\theta ; x, y)\) cannot be too small (it is important that w is supported on [1, 2], not on [0, 1]), and we apply [11, Lemma 8.1] with

$$\begin{aligned} \beta - \alpha \ll \frac{K^2}{x}, \quad X \!=\! \Big (\frac{K}{x}\Big )^{2j}, \quad U \!=\! \min (K^{1/10}, K^2/x), \quad R \!=\! 1 , \quad Y \!=\! x, \quad Q \!=\! K. \end{aligned}$$

In this way we obtain a contribution of

$$\begin{aligned}&\ll _n (\beta - \alpha )X[(QR/\sqrt{Y})^{-n} + (RU)^{-n}] \\&\quad \ll \frac{1}{x^j} \Big (\frac{K^2}{x}\Big )^{1 + j} \Big ( \Big (\frac{K}{\sqrt{x}}\Big )^{-n} + \Big (\frac{K^2}{x}\Big )^{-n} + K^{- n/10}\Big ) \end{aligned}$$

to (9.4) for every \(n \geqslant 0\). This is easily seen to be

$$\begin{aligned} \ll _{j, A} \frac{1}{x^j} \Big (1 + \frac{K^2}{x}\Big )^{-A} \end{aligned}$$

for every \(A > 0\). For the portion \(|\theta | \gg K^2/x\) we integrate by parts in the y integral and apply trivial estimates to obtain a bound

$$\begin{aligned} \ll _{j, A} \int \limits _{|\theta | \gg K^2/x} (1 + \theta )^{-A} \Big (\frac{\theta }{K}\Big )^{2j} d\theta \end{aligned}$$

which is easily seen to be

$$\begin{aligned} \ll _{j, A} \min \Big (\Big (\frac{K^2}{x}\Big )^{-A} \frac{1}{x^j}, \frac{1}{K^{2j}}\Big ) \ll \frac{1}{x^j} \Big (1 + \frac{K^2}{x}\Big )^{-A}. \end{aligned}$$

The same analysis works for \(W_1^-(x) = W_2^-(x) + \tilde{W}_2(x)\) where

$$\begin{aligned} \begin{aligned} W_2^-(x)&= \frac{e(-3/8)}{2}e^{+ i x} \int \limits _{-\infty }^{\infty } v(\theta K^{-1/10}) e\Big (\frac{-3\theta }{2K}\Big ) e^{-ix \cos (2\pi \theta /K)} \\&\quad \int \limits _{-\infty }^{\infty } w(y) e(y\theta ) dy \, d\theta . \end{aligned} \end{aligned}$$
(9.5)

We put \(w_{\pm } = W_2^{\pm }\) and \(w_0 = W_1 + W_2 + \tilde{W}_2\), and the lemma follows on noting that \(\frac{1}{2}(i^k + (-i)^k) = i^k \delta _{2\mid k}\). \(\square \)

Remarks: (1) It is clear from the proof that if w depends on other parameters in a real- or complex-analytic way with control on derivatives, then \(w_{\pm } = W_2^{\pm }\), defined in (9.3), depends on these parameters in the same way. We will use this observation in Sects. 10.2 and 14.

(2) The bound (9.1) remains true for \(A \geqslant -1/2\). In the case, the claim follows for \(x \geqslant K^2\) from the asymptotic formula [33, 8.451.1 & 7 & 8]. We state this for completeness, but we do not need it here.

We need a similar formula for the transforms occurring in (3.6) and (7.1).

Lemma 21

Let \(A, T \geqslant 2\) and let \(\mathtt{h}\) be a smooth function with support in [T, 2T] satisfying \(\mathtt{h}^{(j)}(t) \ll T^{-j}\) for \(j \in \mathbb {N}_0\).

(a) We have

$$\begin{aligned} \begin{aligned}&\mathtt{h}^*(x) = \frac{T^2}{\sqrt{x}} \Big (1 + \frac{T^2}{x}\Big )^{-A} \sum _{\pm } e(\pm x) H^{\pm }_A(x) + K^{\pm }_A(x)\\ \end{aligned} \end{aligned}$$

where \(K^{\pm }_A(x) \ll _A (T+x)^{-A}\) and \(x^j \partial _x^j H^{\pm }_A(x) \ll _{A, j} 1\). An analogous asymptotic formula holds for \(\mathtt{h}^{\dagger }(x)\).

(b) We have

$$\begin{aligned} h^{**}(x) = T \Big (\frac{x}{T} + \frac{T}{x}\Big )^{-A} H_A(x) + \tilde{K}_A(x) \end{aligned}$$

where \(\tilde{K}_A(x) \ll _A (T+ x)^{-A}\) and \(x^j \partial _x^j H_A(x) \ll _{A, j} 1\).

Proof

(a) For the first part we recall the uniform asymptotic formula [28, 7.13.2(17)].

$$\begin{aligned} \frac{\pi i}{\cosh (\pi t)} J_{2 it}(x) = \sum _{\pm } \frac{ e^{\pm ix \mp i \omega (x, t)}}{x^{1/2} } f^{\pm }_M(x, t) + O_M((|t| + x)^{-M} ) \end{aligned}$$

where \(\omega (x, t) = |t| \cdot \text {arcsinh} (|t|/x) - \sqrt{t^2 + x^2} + x\) and

$$\begin{aligned} x^i |t|^j\frac{\partial ^i}{\partial x^i} \frac{\partial ^j}{\partial t^j} f^{\pm }_{M}(x, t) \ll _{i, j, M} 1 \end{aligned}$$
(9.6)

for every \(M \geqslant 0\). The error term in [28] is \(O(x^{M })\), but for small x the error term \(O(|t|^{-M} )\) follows from the power series expansion [33, 8.440]. Partial integration in the form of [11, Lemma 8.1] with \(U = T\), \(Y = Q = T+x\), \(R= \text {arcsinh}(T/x) \gg T/x\) shows that

$$\begin{aligned} x^j \frac{\partial ^j}{\partial x^j} \int \limits _{\mathbb {R}} e^{ \mp i \omega (x, t)} f^{\pm }_{ M}(x, t) h(t) t \frac{dt}{4\pi ^2} \ll _{j, A, M} T^2 \Big ( 1 + \frac{T^2}{x}\Big )^{-A} \end{aligned}$$

and the claim follows.

(b) For the proof of the second part we distinguish 3 ranges. For \(x > 10 T\) the claim follows easily from the rapid decay of the Bessel K-function and its derivatives. For \(x < T/10\) we use the uniform asymptotic expansion [28, 7.13.2(19)] (along with the power series expansion [33, 8.485, 8.445] for very small x)

$$\begin{aligned}&\cosh (\pi t) {K}_{2it}(x) = \sum _{\pm } e^{\pm i {\tilde{\omega }}(x, t)} \tilde{f}^{\pm }_M(x, t) + O(|t|^{-M}), \\&\quad {\tilde{\omega }}(x, t) = |t| \cdot \text {arccosh} \frac{|t|}{x} - \sqrt{t^2 - x^2} \end{aligned}$$

where \(\tilde{f}^{\pm }_M\) satisfies the analogous bounds in (9.6). Again integration by parts ( [11, Lemma 8.1] with \(U = Y = Q = T\), \(R= \text {arccosh}(T/x) \geqslant 1\)) confirms the claim in this range. Finally, for \(x \asymp T\) we use the integral representation [33, 8.432.4]

$$\begin{aligned} \cosh (\pi t) K_{2it}(x) = \frac{\pi }{2} \int \limits _{-\infty }^{\infty } \cos (x \sinh \pi u) e(tu) du. \end{aligned}$$

This integral is not absolutely convergent, but partial integration shows that the tail is very small, and we can in fact truncate the integral at \(|u| \leqslant \varepsilon \log T\) at the cost of an admissible error \(O(T^{-A})\). Thus we are left with bounding

$$\begin{aligned} \begin{aligned}&\frac{d^j}{dx^j} \int \limits _{-\infty }^{\infty } \int \limits _{-\varepsilon \log T}^{\varepsilon \log T} \cos (x \sinh \pi u) e(tu) h(t) t \, du \, dt \\&\quad \ll \int \limits _{T \leqslant |t| \leqslant 2T} \int \limits _{-\varepsilon \log T}^{\varepsilon \log T} |\sinh (\pi u)|^j (1+| u|T)^{-B} t \, du\, dt \ll T.\\ \end{aligned} \end{aligned}$$

if B is chosen sufficiently large with respect to j. \(\square \)

For large arguments, the Bessel function \(J_{ir}(y)\) behaves like an exponential. More precisely, by [33, 8.451.1 & 7 & 8] we have an asymptotic expansion which we will need later:

$$\begin{aligned} \begin{aligned}&\sum _{\pm } (\mp ) \frac{J_{ir}(2\pi x) \cos (\pi /4 \pm \pi i r/2)}{\sin (\pi i r)} \\&\quad = \sum _{\pm } \frac{e(\pm x)}{2\pi \sqrt{x}}\sum _{k=0}^{n-1} \frac{i^k(\pm 1)^k}{(4\pi x)^{k}} \frac{\Gamma (ir + k + 1/2)}{k! \Gamma (ir - k + 1/2)} + O\Big (\Big (\frac{|r|^2}{x}\Big )^{-n}\Big ) \end{aligned} \end{aligned}$$
(9.7)

for \(r \in \mathbb {R}\), \(x \geqslant 1\) and fixed \(n \in \mathbb {N}\). This is useful as soon as \(x \geqslant r^2\).

The following lemma is essentially an application of Stirling’s formula.

Lemma 22

Let \(k \geqslant 1\), \(s = \sigma + it \in \mathbb {C}\) with \(k + \sigma \geqslant 1/2\), \(M \in \mathbb {N}\). Then

$$\begin{aligned} \frac{\Gamma (k+s)}{\Gamma (k) }= k^s G_{M, \sigma }(k, t) + O_{\sigma , M}((k + |t|)^{-M}) \end{aligned}$$

where

$$\begin{aligned} k^{\frac{i}{2} + j} \frac{d^{i}}{dt^{i}} \frac{d^{j} }{dk^{j}} G_{M, \sigma }(k, t) \ll _{M, \sigma , i, j} \Big ( 1 + \frac{t^2}{k}\Big )^{-M} \end{aligned}$$
(9.8)

for \(i, j \in \mathbb {N}_0\). Moreover,

$$\begin{aligned} \frac{\Gamma (k+\sigma + it)}{\Gamma (k) }= k^s \exp \Big (-\frac{t^2}{2k}\Big )\Big (1 + O_{\sigma }\Big (\frac{|t|}{k} + \frac{t^4}{k^3}\Big )\Big ). \end{aligned}$$
(9.9)

Proof

This is a standard application of Stirling’s formula. First of all, since

$$\begin{aligned} \frac{\Gamma (k+s)}{\Gamma (k) } k^{-s}= \frac{\Gamma (k+\sigma )}{\Gamma (k) }k^{-\sigma } \frac{\Gamma (k+\sigma + it)}{\Gamma (k + \sigma ) } (k+\sigma )^{-it} (1 + \sigma /k)^{it} \end{aligned}$$

with

$$\begin{aligned} \frac{d^{j_1}}{dk^{j_2}} \frac{d^{j_1} }{dt^{j_2}}(1 + \sigma /k)^{it} \ll _{\sigma , j_1, j_2} \frac{1}{k^{j_1+j_2}} \Big (1 + \frac{|t|}{k}\Big )^{j_1}, \quad (1 + \sigma /k)^{it} = 1 + O_{\sigma }(|t|/k),\nonumber \\ \end{aligned}$$
(9.10)

it suffices for both statements to treat the two cases \(s= \sigma \in \mathbb {R}\) fixed and \(s = it \in i\mathbb {R}\). The first case is very simple, so we display the details for the second case. We have

$$\begin{aligned} \frac{\Gamma (k+it)}{\Gamma (k) } k^{-it} = \exp \big (\alpha (k, t) + i\beta (k, t)\big ) \Big (\tilde{G}_{M }(k, t) + O_{M }((k+|t|)^{-M})\Big ) \end{aligned}$$

where \(\tilde{G}_{M }\) satisfies

$$\begin{aligned} (k+|t|)^{j_1+j_2} \frac{d^{j_1}}{dk^{j_1}} \frac{d^{j_2} }{dt^{j_2}} \tilde{G}_{M }(k, t) \ll _{M, j_1, j_2} 1, \quad \tilde{G}_{M }(k, t) = 1 + O((k+|t|)^{-1})\nonumber \\ \end{aligned}$$
(9.11)

and

$$\begin{aligned} \begin{aligned} \alpha (k, t)&= - t \arctan \frac{t}{k } + \frac{k - 1/2}{2} \log \Big (1 + \frac{ t^2}{k^2}\Big ),\\ \beta (k, t)&= t \Big (\log \sqrt{1 + \frac{ t^2}{k^2}} - 1\Big ) + \Big (k - \frac{1}{2}\Big ) \arctan \frac{t}{k }. \end{aligned} \end{aligned}$$

It is not hard to see that

$$\begin{aligned} \alpha (k, t) \leqslant - c \min \Big (\frac{t^2}{k}, |t|\Big ) \end{aligned}$$

for some absolute constant c (in fact, \(c = (\pi - \log 4)/4 = 0.438\ldots \) is the optimal constant). In particular, \(\Gamma (k+it)/\Gamma (k)\) is exponentially decreasing as soon as \(|t| \geqslant k^{1/2}\). Moreover, by a Taylor argument we have

$$\begin{aligned} \alpha (k, t) = -\frac{t^2}{2k} + O\Big (\frac{t^2}{k^2} + \frac{t^4}{k^3}\Big ), \quad \beta (k, t) \ll \frac{|t|}{k} + \frac{|t|^3}{k^2}. \end{aligned}$$

This proves (9.9). To prove (9.8), we need to bound the derivatives of \(\alpha \) and \(\beta \) which is most quickly done by using Cauchy’s integral formula. Note that both \(\alpha \) and \(\beta \) have a branch cut at the two rays \(\pm t/k \in [ i, i \infty )\). We assume that k is sufficiently large (otherwise there is noting to prove) and we choose a circle \(C_1\) about k of radius k/100 and a circle \(C_2\) about t of radius \(\sqrt{k}/10\). Then w/z is away from the branch cuts for \(z \in C_1\), \(w \in C_2\), and we have

$$\begin{aligned} \alpha (z, w) \ll \frac{|w|^2}{|z|} + |w| \ll \frac{|t|^2 +k}{k}, \quad \beta (z, w) \ll \frac{|w|}{|z|} + \frac{|w|^3}{|z|^2} \ll \frac{|t| }{k} + \frac{|t|^3}{k^2} + \frac{1}{k^{1/2}}. \end{aligned}$$

for \(z \in C_1\), \(w\in C_2\). From Cauchy’s integral formula we conclude

$$\begin{aligned}&\frac{d^{i}}{dt^{i}} \frac{d^{j} }{dk^{j}}\alpha (k, t)\ll _{i, j} \Big (1 + \frac{t^2}{k}\Big )k^{-\frac{i}{2} - j} , \nonumber \\&\frac{d^{i}}{dt^{i}} \frac{d^{j} }{dk^{j}}\beta (k, t)\ll _{i, j} \Big (1 + \frac{t^2}{k}\Big )^2k^{-\frac{i}{2} - j} \end{aligned}$$
(9.12)

for \(i, j \in \mathbb {N}_0\). Combining (9.10), (9.11), (9.12) completes the proof of (9.8). \(\square \)

We apply this to the function \(\mathcal {G}(k, t_\mathtt{u}, s)\) defined in (6.5).

Corollary 23

Let \(A \geqslant 0\), \( \sigma \geqslant -1/4\) and let \(t \in \mathbb {R}\), \(t_\mathtt{u} \in \mathbb {R} \cup [-i/2, i/2]\), \(k \in 2\mathbb {N}\). Then

$$\begin{aligned} \mathcal {G}(k, t_\mathtt{u}, \sigma + 1/2 + it) \ll _{A, \sigma } k^{-1/4 + 2\sigma } \left( 1 + \frac{|t|^2 + |t_\mathtt{u}|^2}{k} \right) ^{-A} . \end{aligned}$$
(9.13)

Moreover, for \(v \in \mathbb {C}\) we have

$$\begin{aligned} \mathcal {G}(k, t_\mathtt{u}, v + 1/2 + it)\mathcal {G}(k, t_\mathtt{u}, v + 1/2 - it) = \mathtt{G}_M(k, t_\mathtt{u}, t, v) + O_{\mathfrak {R}v, \mathfrak {R}w, M}(k^{-M}) \end{aligned}$$

with

$$\begin{aligned} \begin{aligned}&k^{j_1 + \frac{j_2}{2} + \frac{j_3}{2}} \frac{d^{j_1}}{dk^{j_1}} \frac{d^{j_2} }{dt^{j_2}}\frac{d^{j_3} }{d\tau ^{j_3}} \mathtt{G}_M(k,\tau , t, v, w) \\&\quad \ll _{ \mathbf{j }, \mathfrak {R}v, \mathfrak {R}w, M} k^{-1/2 +2 \mathfrak {R}v + 2\mathfrak {R}w} (1 + |\mathfrak {I}v|)^{j_1} \end{aligned} \end{aligned}$$
(9.14)

for \(\mathbf{j } \in \mathbb {N}_0^3\). Finally, for \(t, \tau \ll k^{2/3}\) we have

$$\begin{aligned}&\mathcal {G}(k, \tau , 1/2 + it) \mathcal {G}(k, \tau , 1/2 - it) \nonumber \\&\quad = \frac{16}{\pi k^{1/2}} \exp \Big (-\frac{2(t + \tau /2)^2+ 2(t - \tau /2)^2}{k}\Big ) \Big (1 + O(k^{-1/3})\Big ). \end{aligned}$$
(9.15)

Recalling the definition (6.7) of \(V_t(x; k, t_\mathtt{u})\) we conclude from (9.13) and appropriate contour shifts the uniform bounds

$$\begin{aligned} \begin{aligned}&k^{j_1 + \frac{j_2}{2} + \frac{j_3}{2}}x^{j_4} \frac{d^{j_1}}{dk^{j_1}} \frac{d^{j_2} }{dt^{j_2}}\frac{d^{j_3} }{d\tau ^{j_3}}\frac{d^{j_4}}{dx^{j_4}} V_t(x; k, \tau ) \\&\quad \ll _{A, \mathbf{j }} k^{-1/2} \Big (1 + \frac{x}{k^4}\Big )^{-A} \Big (1 + \frac{|t|^2 + |\tau |^2}{k} \Big )^{-A} \end{aligned} \end{aligned}$$
(9.16)

for \(A > 0\), \(\mathbf{j } \in \mathbb {N}_0^4\).

In a similar, but simpler fashion we also apply this to the weight function \(W_t\) defined in (4.15) and state the bound

$$\begin{aligned} (1+|t|)^{j_1} x^{j_2} \frac{d^{j_1}}{dt^{j_1}}\frac{d^{j_2}}{dx^{j_2}} W_t(x) \ll _{A, j_1, j_2} \Big (1 + \frac{x}{1 + |t|}\Big )^{-A} \end{aligned}$$
(9.17)

for \(A \geqslant 0\), \(j_1, j_2 \in \mathbb {N}_0\).

10 A weak version of Theorem 2

In this section we present a relatively soft argument that provides the upper bound \(\mathcal {N}_{\text {av}}(K) \ll K^{\varepsilon }\). This will useful later in order to estimate certain error terms. By (1.3) and (6.8) we have

$$\begin{aligned} \begin{aligned}&\mathcal {N}_{\text {av}}(K) \ll \frac{1}{K^2}\sum _{k \in 2\mathbb {N}} W\Big (\frac{k}{K}\Big ) \sum _{h \in B_{k-1/2}^+(4)} \int \limits _{-\infty }^{\infty } \int \limits _{\Lambda _{\text { ev}}} \frac{\Gamma (k-3/2)}{(4\pi )^k \Vert h \Vert ^2} \sum _{f_1, f_2} \frac{1}{f_1f_2}\\&\quad \sum _{D_1, D_2 < 0} \frac{c_h(|D_1|)c_h(|D_2|)P(D_1; \mathtt{u}) \overline{P(D_2; \mathtt{u})} }{ |D_1D_2|^{ k/2 }} \Big (\frac{|D_2|f_2^2}{|D_1|f_1^2}\Big )^{it}V_{ t}(|D_1D_2|(f_1f_2)^2 ; k, t_\mathtt{u}) d\mathtt{u} \, dt. \end{aligned} \end{aligned}$$

By (9.16) we have \(t, t_\mathtt{u} \ll K^{1/2 + \varepsilon }\) (up to a negligible error). We insert a smooth partition of unity into the \(t_u\)-integral and attach a factor \(w(|t_\mathtt{u}|/\mathcal {T}_{\text {spec}})\) where w has support in [1, 2] unless \(\mathcal {T}_{\text {spec}} = 1\), in which case w has support in [0, 2]. Let

$$\begin{aligned} \begin{aligned}&\mathcal {N}_{\text {av}}(K ; \mathcal {T}_{\text {spec}}):=\frac{1}{K^2}\sum _{k \in 2\mathbb {N}} W\Big (\frac{k}{K}\Big ) \sum _{h \in B_{k-1/2}^+(4)} \int \limits _{-\infty }^{\infty } \int \limits _{\Lambda _{\text { ev}}} \frac{\Gamma (k-3/2)}{(4\pi )^k \Vert h \Vert ^2} w\Big ( \frac{|t_\mathtt{u}|}{\mathcal {T}_{\text {spec}}}\Big ) \sum _{f_1, f_2} \frac{1}{f_1f_2}\\&\quad \sum _{D_1, D_2 < 0} \frac{c_h(|D_1|)c_h(|D_2|)P(D_1; \mathtt{u}) \overline{P(D_2; \mathtt{u})} }{ |D_1D_2|^{ k/2 }} \Big (\frac{|D_2|f_2^2}{|D_1|f_1^2}\Big )^{it}V_{ t}(|D_1D_2|(f_1f_2)^2 ; k, t_\mathtt{u}) d\mathtt{u} \, dt. \end{aligned} \end{aligned}$$

for \(\nu = 0, 1, 2, \ldots \) and \( \mathcal {T}_{\text {spec}} = 2^{\nu }\ll K^{1/2 + \varepsilon }\). This section is then devoted to the proof of the bound

$$\begin{aligned} \mathcal {N}_{\text {av}}(K; \mathcal {T}_{\text {spec}}) \ll _{\varepsilon } 1 + \frac{\mathcal {T}_{\text {spec}}^2}{K^{1-\varepsilon }} \end{aligned}$$
(10.1)

for \(\varepsilon >0\). The constant function will need special treatment, and to this end we prove the following simple lemma.

Lemma 24

For \(x \geqslant 1\) we have

$$\begin{aligned} \sum _{D \leqslant x} H(D)^2 \ll x^2. \end{aligned}$$

Proof

Let h(D) denote the usual class number. Since

$$\begin{aligned} H(D) \leqslant \sum _{n^2 \mid D} h(D/n^2) \end{aligned}$$

we have

$$\begin{aligned} \sum _{|D| \leqslant x} H(D)^2 \leqslant \sum _{n_1, n_2} \sum _{[n_1^2, n_2^2] \mid |D| < x} h\left( \frac{D}{n_1^2}\right) h\left( \frac{D}{n_2^2}\right) \leqslant \sum _{n_1, n_2, m} \sum _{|D| \leqslant \frac{x}{n_1^2n_2^2m^2} } h(n_2^2D) h(n_1^2D). \end{aligned}$$

Since \(h(\Delta n^2) = h(\Delta ) n \prod _{p \mid n} (1 - \chi _{\Delta }(p)/p) \leqslant h(\delta ) n\tau (n)\) for a fundamental discriminant \(\Delta \), we get from bounds for moments of the ordinary class number [3] that

$$\begin{aligned} \begin{aligned} \sum _{|D| \leqslant x} H(D)^2&\leqslant \sum _{n_1, n_2, m, f} \sum _{|\Delta | \leqslant x/(n_1 n_2 m f )^2 } h(\Delta )^2 n_1n_2f^2 \tau (n_1)\tau (n_2)\tau (f)^2\\&\ll x^2\sum _{n_1, n_2, m, f} \frac{n_1n_2f^2 \tau (n_1)\tau (n_2)\tau (f)^2}{(n_1n_2mf)^4} \ll x^2. \end{aligned} \end{aligned}$$

\(\square \)

Having this out of the way, we proceed to estimate \(\mathcal {N}_{\text {av}}(K; \mathcal {T}_{\text {spec}})\). We first sum over h using Lemma 6. This yields a diagonal term and an off-diagonal term that we treat separately in the following two subsections. Throughout, the letter D, with or without subscripts, shall always denote a negative discriminant unless stated otherwise. The letter A shall denote an arbitrarily large fixed constant, not necessarily the same on every occurrence.

10.1 The diagonal term

The contribution to \(\mathcal {N}_{\text {av}}(K; \mathcal {T}_{\text {spec}})\) of the diagonal term from Lemma 6 is bounded by

$$\begin{aligned} \begin{aligned}&\ll \frac{1}{K }\int \limits _{-\infty }^{\infty } \int \limits _{ \Lambda _{\text { ev}} }w\Big ( \frac{|t_\mathtt{u}|}{\mathcal {T}_{\text {spec}}}\Big ) \sum _{f_1,f_2} \frac{1}{f_1f_2} \sum _{D} \frac{ |P(D ; \mathtt{u})|^2 }{ |D|^{3/2}} \sup _{k \ll K} |V_t((|D|f_1f_2)^2; k, t_\mathtt{u}) |d\mathtt{u} \, dt . \end{aligned} \end{aligned}$$

This can be bounded without too much effort by Corollary 5 for the cuspidal part, Proposition 4b) for the Eisenstein part and Lemma 24 for the constant function.

Indeed, for the constant function \(\mathtt{u} = \sqrt{3/\pi }\) we have \(P(D; \sqrt{3/\pi }) \ll H(D)\). Recalling (9.16) and Lemma 24, this gives a total contribution of

$$\begin{aligned}&\ll \frac{1}{K } \int \limits _{-\infty }^{\infty } \sum _{f_1 ,f_2} \frac{1}{f_1f_2} \sum _D \frac{H(D)^2}{|D|^{3/2}} \Big ( 1 + \frac{|D|f_1 f_2}{K^2}\Big )^{-10} \Big (1 + \frac{|t|^2}{K}\Big )^{-10}dt \\&\quad \ll \sum _{f_1 ,f_2} \frac{1}{(f_1f_2)^{3/2}} \ll 1 \end{aligned}$$

if \(\mathcal {T}_{\text {spec}} = 1\) and otherwise the contribution vanishes.

Similarly, by (4.12), (3.3), (4.7) and (4.13), the Eisenstein spectrum contributes

$$\begin{aligned} \begin{aligned}&\ll \max _{1 \leqslant R \leqslant K^{2+\varepsilon }} \frac{1}{RK^{1-\varepsilon }} \int \limits _{|\tau | \ll \mathcal {T}_{\text {spec}}} |\zeta (1/2 + i\tau )|^2 \sum _{R \leqslant |\Delta | \leqslant 2R} |L(\chi _{\Delta }, 1/2 + i\tau )|^2 d\tau . \end{aligned} \end{aligned}$$

We recall our convention that \(\Delta \) denotes a negative fundamental discriminant, \(D = \Delta f^2\) an arbitrary negative discriminant (where f here has nothing to do with \(f_1, f_2\) above). In the above bound we have already executed the sum over f. By Proposition 4(b) and a standard bound for the fourth moment of the Riemann zeta-function this is \(O(K^{-1/2 + \varepsilon })\).

By (4.10), (4.5), (4.6) and (4.13), the contribution of the cuspidal spectrum is at most

$$\begin{aligned} \begin{aligned}&\ll \max _{1 \leqslant R \leqslant K^{2+\varepsilon }} \frac{1}{R K^{1-\varepsilon }} \sum _{t_{ u} \ll \mathcal {T}_{\text {spec}}} L({ u}, 1/2) \sum _{ R \leqslant |\Delta | \leqslant 2R} L({ u} \times \chi _{\Delta }, 1/2 ) \ll \mathcal {T}^2_{\text {spec}}K^{\varepsilon -1}. \end{aligned} \end{aligned}$$

by Corollary 5. All of these bounds are consistent with (10.1).

10.2 The off-diagonal term: generalities

We now consider the off-diagonal term in Lemma 6 from the sum over h. Here we need to bound

$$\begin{aligned} \begin{aligned}&\frac{1}{K^2}\sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) i^k \int \limits _{-\infty }^{\infty } \int \limits _{\Lambda _{\text { ev}}} w\Big ( \frac{|t_\mathtt{u}|}{\mathcal {T}_{\text {spec}}}\Big ) \sum _{f_1, f_2} \sum _{D_1, D_2 } \frac{P(D_1; \mathtt{u})\overline{P(D_2; \mathtt{u})} }{ f_1f_2 |D_1 D_2|^{ 3/4 }} \Big (\frac{|D_2|f_2^2}{|D_1|f_1^2}\Big )^{it}\\&\quad V_t(|D_1D_2|(f_1f_2)^2, k, t_\mathtt{u}) \sum _{4 \mid c} \frac{K^+_{3/2}(|D_1|, |D_2|, c)}{c} J_{k-3/2}\Big (\frac{4\pi \sqrt{|D_1D_2|}}{c}\Big ) d\mathtt{u} \, dt . \end{aligned} \end{aligned}$$

By (9.16) and the rapid decay of the Bessel function near 0 for large k, up to a negligible error all sums are effectively bounded by a power of K. We first sum over k using Lemma 20. Up to a negligible error, we obtain

$$\begin{aligned} \begin{aligned}&\frac{1}{K^2} \int \limits _{-\infty }^{\infty } \int \limits _{\Lambda _{\text { ev}}} w\Big ( \frac{|t_\mathtt{u}|}{\mathcal {T}_{\text {spec}}}\Big ) \sum _{f_1, f_2} \sum _{D_1, D_2 } \frac{P(D_1; \mathtt{u})\overline{P(D_2; \mathtt{u})} }{ f_1f_2 |D_1 D_2|^{ 3/4 }} \Big (\frac{|D_2|f_2^2}{|D_1|f_1^2}\Big )^{it}\\&\quad \sum _{4 \mid c} \frac{K^+_{3/2}(|D_1|, |D_2|, c)}{c} e\Big (\!\pm \! \frac{2\sqrt{|D_1D_2|}}{c}\Big ) \tilde{V}\Big (|D_1D_2|(f_1f_2)^2, \frac{\sqrt{|D_1D_2|}}{c}, t, t_\mathtt{u}\Big ) d\mathtt{u} \, dt \end{aligned} \end{aligned}$$

where

$$\begin{aligned} \begin{aligned}&y^{j_1} K^{\frac{1}{2}(j_2+j_3)} x^{j_4} \frac{d^{j_1}}{dy^{j_1}} \frac{d^{j_2} }{dt^{j_2}}\frac{d^{j_3} }{d\tau ^{j_3}}\frac{d^{j_4}}{dx^{j_4}} \tilde{V}(x, y, t, \tau ) \\&\quad \ll _{A, \mathbf{j }} K^{-1/2} \Big (1 + \frac{x}{K^4}\Big )^{-A} \Big (1 + \frac{|t|^2 + |\tau |^2}{K} \Big )^{-A} \Big (1 + \frac{K^2}{y}\Big )^{-A} \end{aligned} \end{aligned}$$
(10.2)

for any \(A \geqslant 0\), \(\mathbf{j } \in \mathbb {N}_0^4\), cf. (9.16) and the remark after Lemma 20. In order to apply Voronoi summation, we open the Kloosterman sum and are left with bounding

$$\begin{aligned} \begin{aligned}&\frac{1}{K^2}\sum _{4 \mid c} \underset{\begin{array}{c} d\,(\text {mod }c)\\ (d, c) = 1 \end{array}}{\max }\Big | \int \limits _{\Lambda _{\text { ev}}} w\Big ( \frac{|t_\mathtt{u}|}{\mathcal {T}_{\text {spec}}}\Big ) \sum _{f_1, f_2} \sum _{D_1, D_2 } \frac{P(D_1; \mathtt{u})\overline{P(D_2; \mathtt{u})} }{ f_1f_2 |D_1 D_2|^{ 3/4 }} \\&\quad e\Big (\pm \frac{2\sqrt{|D_1D_2|}}{c}\Big ) e\Big ( \frac{|D_1|d + |D_2|{\bar{d}}}{c}\Big )V^{*}\Big (|D_1|f_1^2, |D_2|f_2^2, \frac{\sqrt{|D_1D_2|}}{c}, t, t_\mathtt{u}\Big ) d\mathtt{u} \Big | \end{aligned}\nonumber \\ \end{aligned}$$
(10.3)

where

$$\begin{aligned} V^{*}(x_1, x_2, y, \tau ) = \int \limits _{-\infty }^{\infty } \Big (\frac{x_2}{x_1}\Big )^{it} \tilde{V}(x_1x_2, y, t, \tau ) dt. \end{aligned}$$
(10.4)

Integration by parts shows that

$$\begin{aligned} \begin{aligned}&y^{j_1} K^{\frac{1}{2}j_2} x_1^{j_3}x_2^{j_4} \frac{d^{j_1}}{dy^{j_1}} \frac{d^{j_2} }{d\tau ^{j_2}}\frac{d^{j_3} }{dx_1^{j_3}}\frac{d^{j_4}}{dx_2^{j_4}} V^*(x_1, x_2, y, \tau ) \\&\quad \ll _{A, \mathbf{j }} \Big (1 + \frac{x_1x_2}{K^4}\Big )^{-A} \Big (1 + \frac{ |\tau |^2}{K} \Big )^{-A} \Big (1 + \frac{K^2}{y}\Big )^{-A}\Big (1 + K^{1/2}|\log x_2/x_1|\Big )^{-A} \end{aligned}\nonumber \\ \end{aligned}$$
(10.5)

for any \(A \geqslant 0\), \(\mathbf{j } \in \mathbb {N}_0^4\). The first and third factor on the right hand side of (10.5) imply \(|D_1 D_2| = K^{4+o(1)}\) and \(c, f_1, f_2 = K^{o(1)}\) up to a negligible error. On the other hand, the last factor implies \(D_1f_1^2 =D_2f_2^2(1 + O(1/K^{1/2}))\), so that in effect \(D_1, D_2 = K^{2+o(1)}\).

In the following we treat the cuspidal part, the Eisenstein part and the constant function separately. In principle we could treat them on equal footing and we will do this in Sect. 14, but for now we keep the prerequisites as simple as possible.

10.3 The Eisenstein contribution

We start with the contribution of the Eisenstein spectrum to (10.3). As this is much smaller in size than the cuspidal spectrum, very simple bounds suffice. By (4.11), (4.13) and (10.5) we obtain a contribution of

$$\begin{aligned} \frac{K^{\varepsilon } }{K^{4} } \int \limits _{-2\mathcal {T}_{\text {spec}}}^{2\mathcal {T}_{\text {spec}}} \sum _{\begin{array}{c} D_1f_1^2 = D_2 f_2^2 (1 + O(K^{\varepsilon -1/2} ))\\ |D_1|, |D_2| = K^{2 + o(1)}\\ f_1, f_2 \ll K^{\varepsilon } \end{array}} |\zeta (1/2 + it)|^2 |L(D_1, 1/2 + it)L(D_2, 1/2 + it)| dt. \end{aligned}$$

We use the basic inequality \(|L(D_1, 1/2 + it)L(D_2, 1/2 + it)| \leqslant \frac{1}{2}( |L(D_1, 1/2 + it)|^2 + |L(D_2, 1/2 + it)|^2) \). For fixed \(f_1, f_2, D_1\) there are \(O( K^{3/2+\varepsilon } )\) values of \(D_2\) satisfying the summation condition. Thus we obtain the bound

$$\begin{aligned} \frac{K^{\varepsilon } }{K^{5/2 } } \int \limits _{-2\mathcal {T}_{\text {spec}}}^{2\mathcal {T}_{\text {spec}}} \sum _{ |D| = K^{2 +o(1)}} |\zeta (1/2 + it)|^2 |L(D, 1/2 + it)|^2 dt. \end{aligned}$$

By (4.1) and Proposition 4(b) along with a bound for the fourth moment of the Riemann zeta function we obtain the desired bound

$$\begin{aligned} \frac{K^{\varepsilon } }{K^{5/2 } } \int \limits _{-2\mathcal {T}_{\text {spec}}}^{2\mathcal {T}_{\text {spec}}} \sum _{ |\Delta | \leqslant K^{2+\varepsilon }} |\zeta (1/2 + it)|^2 |L(\Delta , 1/2 + it)|^2 dt \ll \frac{\mathcal {T}_{\text {spec}}}{K^{1/2 - \varepsilon }}. \end{aligned}$$

10.4 The cuspidal contribution

Next we consider the cuspidal contribution to (10.3). The key step is an application of the metaplectic Voronoi formula (Lemma 10). With this in mind, we consider the following portion

$$\begin{aligned}&\frac{\overline{P(D_2; u)}}{|D_2|^{ 3/4 }}\sum _{D_1 } \frac{P(D_1; u)}{|D_1|^{3/4 }} e\Big ( \frac{|D_1|d}{c}\Big ) e\Big ( \pm \frac{2\sqrt{|D_1D_2|}}{c}\Big ) \nonumber \\&\quad V^{*}\Big (|D_1|f_1^2, |D_2| f_2^2, \frac{\sqrt{|D_1D_2|}}{c}, t_\mathtt{u}\Big ) \end{aligned}$$
(10.6)

of (10.3), i.e. we freeze \(c, f_1, f_2\) and u for the moment. For notational simplicity we consider only the plus case, the minus case may be treated similarly. We insert (4.8) with \(t = t_u/2\) and re-write (10.6) as

$$\begin{aligned} \begin{aligned}&\frac{3}{\pi }\overline{b(D_2)}\Big |\Gamma \Big (\frac{1}{4} + \frac{it_u}{2}\Big )\Big |^2 L(u, 1/2) \sum _{D_1 } b(D_1)e\Big (- \frac{D_1d}{c}\Big ) e\Big ( \frac{2\sqrt{|D_1D_2|}}{c}\Big )\\&\quad V^{*}\Big (|D_1|f_1^2, |D_2|f_2^2, \frac{\sqrt{|D_1D_2|}}{c}, t_u\Big ) . \end{aligned} \end{aligned}$$

To the \(D_1\)-sum we apply the Voronoi formula (Lemma 10) with weight function

$$\begin{aligned} \phi (x)= & {} \phi _{c, f_1, f_2}(x; t, t_u, D_2)\nonumber \\= & {} \frac{1}{ |x|^{1/2 }} e\Big ( \frac{2\sqrt{|xD_2|}}{c}\Big )V^{*}\Big (|x|f_1^2, |D_2|f_2^2, \frac{\sqrt{|xD_2|}}{c}, t_u\Big ) \end{aligned}$$
(10.7)

for \(x < 0\) and \(\phi (x) = 0\) for \(x > 0\). We recall that \(c, f_1, f_2 \ll K^{\varepsilon }\) are essentially fixed from the decay conditions of \(V^{*}\), but we need to be uniform in \(|D_2| = K^{2+o(1)}\). We define

$$\begin{aligned} \Phi (\pm y) = \Phi _{c, f_1, f_2}(\pm y; t, t_u, D_2) = \int \limits _0^{\infty } \mathcal {J}^{\pm , -}(x y) \phi (-x) dx \end{aligned}$$

as in (5.2) with \(r = t_u/2\) and obtain that (10.6) is equal to

$$\begin{aligned} \begin{aligned}&\frac{3}{\pi } \overline{b(D_2)}\Big |\Gamma \Big (\frac{1}{4} + \frac{it_u}{2}\Big )\Big |^2 L(u, 1/2) \frac{2\pi }{c} \left( \frac{-c}{-d}\right) \epsilon _{-d} e\left( \frac{1}{8}\right) \\&\quad \sum _{D} b(D) \sqrt{|D|}e\left( \frac{{\bar{d}}D}{c}\right) \Phi \left( \frac{(2\pi )^2 D}{c^2}\right) , \end{aligned} \end{aligned}$$
(10.8)

where only in the above sum do we allow D to be either positive or negative. If \(D > 0\), then the integral transform \(\Phi ((2\pi )^2 D/c^2 )\) contains a factor

$$\begin{aligned} \frac{K_{ i t_u} ( 4\pi \sqrt{|xD|}/c) }{\Gamma (3/4 + it_u/2)\Gamma (3/4 - it_u/2)}, \end{aligned}$$
(10.9)

and we recall that \(|x| = K^{2+o(1)}\), \(c \ll K^{\varepsilon }\) up to a negligible error. Thus the argument of the Bessel function is \(\gg K^{2-\varepsilon }\), while the index is \(\ll K^{1/2+\varepsilon }\). By the rapid decay of the Bessel K-function this contribution is easily seen to be negligible (we use (4.9) and bound b(D) trivially), and we may restrict from now on to \(D< 0\). In this case

$$\begin{aligned} \begin{aligned} \Phi \left( \frac{(2\pi )^2 D}{c^2}\right)&= \int \limits _0^{\infty } \sum _{\pm } (\mp ) \frac{\cos (\pi /4 \pm \pi i t_u/2)}{\sin (\pi i t_u)} J_{\pm i t_u}\Big ( \frac{4\pi \sqrt{|Dx|}}{c}\Big ) e\Big ( \frac{2\sqrt{|xD_2|}}{c}\Big )\\&\quad V^{*}\Big (xf_1^2, |D_2|f_2^2, \frac{\sqrt{|xD_2|}}{c}, t_u\Big ) \frac{dx}{ x^{1/2 }}. \end{aligned} \end{aligned}$$

Using (9.7), up to a negligible error we can write

$$\begin{aligned} \begin{aligned} \Phi \left( \frac{(2\pi )^2 D}{c^2}\right)&= \frac{c^{1/2}}{|D|^{1/4}} \sum _{\pm } \int \limits _0^{\infty } e\Big ( \frac{2 \sqrt{x} (\sqrt{|D_2|} \pm \sqrt{|D|})}{c}\Big )\\&\quad f^{\pm }\Big (\frac{2 \sqrt{|Dx|}}{c}, t_u\Big ) V^{*}\Big (xf_1^2, |D_2|f_2^2, \frac{\sqrt{|xD_2|}}{c}, t_u\Big ) \frac{dx}{ x^{3/4 }} \end{aligned} \end{aligned}$$

with

$$\begin{aligned} x^j \frac{\partial ^j}{\partial x^j} f^{\pm }(x, r) \ll _{j} 1 \end{aligned}$$
(10.10)

for any \( j \in \mathbb {N}_0\). We substitute this back into (10.8) which equals (10.6). We substitute this back into (10.3). In this way we see that the cuspidal contribution to (10.3) is at most

$$\begin{aligned} \begin{aligned}&\frac{1}{K^2}\sum _{4 \mid c} \frac{1}{c^{1/2}} \sum _{u \text { even}} w\Big ( \frac{|t_\mathtt{u}|}{\mathcal {T}_{\text {spec}}}\Big ) \sum _{f_1, f_2} \frac{1}{f_1f_2} \\&\quad \sum _{D, D_2} \overline{|b(D_2)|}\Big |\Gamma \Big (\frac{1}{4} + \frac{it_u}{2}\Big )\Big |^2 L(u, 1/2) |b(D)| |D|^{1/4} | \Psi _{c, f_1, f_2}( D, D_2, t_u)| \end{aligned} \end{aligned}$$
(10.11)

with

$$\begin{aligned} \begin{aligned} \Psi _{c, f_1, f_2}( D, D_2, t_u)&= \int \limits _0^{\infty } e\Big ( \frac{2\sqrt{x} (\sqrt{|D_2|} \pm \sqrt{|D|})}{c}\Big ) f^{\pm }\Big (\frac{2 \sqrt{|Dx|}}{c}, t_u\Big )\\&\qquad V^{*}\Big (xf_1^2, |D_2|f_2^2, \frac{\sqrt{|xD_2|}}{c}, t_u\Big ) \frac{dx}{ x^{3/4 }} \\&= 2 \int \limits _0^{\infty } e\Big ( \frac{2x (\sqrt{|D_2|} \pm \sqrt{|D|})}{c}\Big ) f^{\pm }\Big (\frac{2 \sqrt{|Dx^2|}}{c}, t_u\Big ) \\&\qquad V^{*}\Big (x^2f_1^2, |D_2|f_2^2, \frac{\sqrt{|x^2D_2|}}{c}, t_u\Big ) \frac{dx}{ x^{1/2 }}. \end{aligned} \end{aligned}$$

By (10.5) and (10.10), each integration by parts with respect to x introduces an additional factor

$$\begin{aligned} \frac{c K^{1/2}}{x(\sqrt{|D_2|} \pm \sqrt{|D|})}, \end{aligned}$$
(10.12)

and we conclude that

$$\begin{aligned} \begin{aligned}&\Psi _{c, f_1, f_2}( D, D_2, t_u) \ll _A \Big (1 + \frac{ |t_\mathtt{u}|^2}{K} \Big )^{-A} \int \limits _0^{\infty } \Big ( 1 + \frac{x(\sqrt{|D_2|} \pm \sqrt{|D|})}{c K^{1/2}}\Big )^{-A} \\&\quad \qquad \quad \qquad \Big (1+K^{1/2}\log \frac{f_2^2 |D_2|}{f_1^2 x^2} \Big )^{-A} \Big (1 + \frac{|D_2|(x f_1f_2)^2}{K^4}\Big )^{-A} \\&\quad \qquad \quad \qquad \Big (1 + \frac{K^2c}{x |D_2|^{1/2}}\Big )^{-A} \frac{dx}{ x^{1/2 }} \end{aligned} \end{aligned}$$
(10.13)

for every \(A \geqslant 0\). Here only the negative part in the ± sign is relevant, since otherwise the expression is trivially negligible. The limiting factor for the size of the x-integral is the first factor in the second line of (10.13), so that we obtain

$$\begin{aligned} \begin{aligned}&\Psi _{c, f_1, f_2}( D, D_2, t_u)\\&\quad \ll _A \frac{f_2 ^{1/2}|D_2|^{1/4} }{f_1^{1/2}K^{1/2}} \Big (1 + \frac{ |t_\mathtt{u}|^2}{K} \Big )^{-A} \Big ( 1 + \frac{f_2|D_2|^{1/2}(\sqrt{|D_2|}- \sqrt{|D|})}{f_1cK^{1/2}}\Big )^{-A}\\&\qquad \quad \Big (1 + \frac{|D_2|f_2^2}{K^2}\Big )^{-A} \Big (1 + \frac{K^2f_1c}{ |D_2|f_2}\Big )^{-A} \end{aligned} \end{aligned}$$

for every \(A \geqslant 0\). It is not hard to see that this can be simplified as

$$\begin{aligned} \begin{aligned}&\Psi _{c, f_1, f_2}( D, D_2, t_u)\\&\quad \ll _A (1 + f_1f_2c)^{-A} \Big (1 + \frac{ |t_\mathtt{u}|^2}{K} \Big )^{-A} \Big (1 + \frac{|D_2|}{K^2}\Big )^{-A} \Big ( 1 + \frac{ |D_2| - |D|}{K^{1/2}}\Big )^{-A}. \end{aligned} \end{aligned}$$

With this bound we return to (10.11), apply the simple bound \(|b(D)b(D_2)| \leqslant |b(D)|^2 + |b(D_2)|^2\) together with (4.9), getting an upper bound of the shape

$$\begin{aligned} \begin{aligned}&\frac{1}{K^2}\sum _{4 \mid c} \frac{1}{c^{1/2}} \sum _{u \text { even}} w\Big ( \frac{|t_\mathtt{u}|}{\mathcal {T}_{\text {spec}}}\Big ) \sum _{f_1, f_2} \sum _{D, D_2} \\&\quad \frac{ |D|^{1/4} }{ f_1f_2|D_2|} \frac{L(u, 1/2)L(u, D_2, 1/2)}{L(\text {sym}^2 u, 1)} | \Psi _{c, f_1, f_2}( D, D_2, t_u)| \end{aligned} \end{aligned}$$

plus a similar expression that with L(uD, 1/2)/|D| in place of \(L(u, D_2, 1/2)/|D_2|\) which can be treated in the same way. We sum over \(D, f_1, f_2, c\) and end up with (after changing the value of A)

$$\begin{aligned} \begin{aligned} \frac{1}{K^{3}}&\sum _{u \text { even}}w\Big ( \frac{|t_\mathtt{u}|}{\mathcal {T}_{\text {spec}}}\Big ) \Big (1 + \frac{ |t_\mathtt{u}|^2}{K} \Big )^{-A} \sum _ { D_2} \Big (1 + \frac{|D_2| }{K^2}\Big )^{-A} \frac{L(u, 1/2)L(u, D_2, 1/2)}{L(\text {sym}^2 u, 1)}. \end{aligned} \end{aligned}$$

We write \(D_2 = \Delta f^2\) with a fundamental discriminant \(\Delta \) and use (4.5), (4.6). Summing over f, we obtain

$$\begin{aligned} \begin{aligned} \frac{1}{K^{3}}&\sum _{u \text { even}}w\Big ( \frac{|t_\mathtt{u}|}{\mathcal {T}_{\text {spec}}}\Big ) \Big (1 + \frac{ |t_\mathtt{u}|^2}{K} \Big )^{-A} \sum _ { \Delta } \frac{K^{4/3}}{|\Delta |^{2/3} } \Big (1 + \frac{|\Delta | }{K^2}\Big )^{-A} \frac{L(u, 1/2)L(u, \Delta , 1/2)}{L(\text {sym}^2 u, 1)} . \end{aligned} \end{aligned}$$

We estimate the denominator \(L(\text {sym}^2 u, 1)\) by (4.13) and apply Corollary 5 to finally obtain the upper bound \(\mathcal {T}_{\text {spec}}^2 K^{\varepsilon -1}\) in agreement with (10.1).

10.5 The constant function

This is very similar to the preceding subsection, so we can be brief. In short, we win a factor \(\mathcal {T}_{\text {spec}} \ll K^{1+\varepsilon }\) from the fact that the spectrum is reduced to one element, and we lose a factor \(|D|^{1/2} \ll K^{1+\varepsilon }\) since each class number is a factor \(|D|^{1/4}\) bigger than the generic period P(Du). The key point is that we end up with a pure bound without a \(K^{\varepsilon }\)-power. This \(K^{\varepsilon }\)-power is unavoidable when we apply Corollary 5, but for a sum over class numbers H(D) alone we can apply Lemma  24 below which avoids a \(K^{\varepsilon }\)-power. The analogue of (10.6) is

$$\begin{aligned} \frac{3}{\pi } \frac{\overline{H(D_2)}}{|D_2|^{ 3/4 }}\sum _{D_1 } \frac{H(D_1)}{|D_1|^{3/4 }} e\Big ( \frac{|D_1|d}{c}\Big ) e\Big ( \pm \frac{2\sqrt{|D_1D_2|}}{c}\Big ) V^{*}\Big (|D_1|f_1^2, |D_2|f_2^2, \frac{\sqrt{|D_1D_2|}}{c}, t_\mathtt{u}\Big ). \end{aligned}$$

We apply the Voronoi formula (Lemma 12) to the \(D_1\)-sum as before. Due to the oscillatory behaviour of \(\phi \) in (10.7) the main terms are easily seen to be negligible, and as in the previous argument also one of the osciallatory terms is negligible due to the exponential decay of \(\mathcal {J}^-\) in (5.5). The behaviour of \(\mathcal {J}^+\) similar, but much simpler, as no asymptotic formula of a Bessel function is necessary. The analogue of (10.11) then becomes

$$\begin{aligned} \begin{aligned} \frac{1}{K^2}\sum _{4 \mid c} \frac{1}{c^{1/2}}&\sum _{f_1, f_2} \sum _{D, D_2} \frac{H(D_2) H(D) |D|^{1/4} }{ |DD_2|^{3/4} f_1f_2} | \Psi _{c, f_1, f_2}( D, D_2, t_u)|. \end{aligned} \end{aligned}$$

In the same way as above this leads to

$$\begin{aligned} \begin{aligned} \frac{1}{K^{3}}&\sum _ { D} \Big (1 + \frac{D }{K^2}\Big )^{-A} \frac{H(D)^2}{|D|^{1/2}} \ll 1. \end{aligned} \end{aligned}$$
(10.14)

The last step is justified by Lemma 24. The bound (10.14) is in agreement with, and completes the proof of, (10.1).

We conclude this section with a brief discussion. The bound (10.1) along with \(\mathcal {T}_{\text {spec}} \ll K^{1/2 + \varepsilon }\) (from the decay of \(V_t\)) implies immediately the upper bound \(\mathcal {N}_{\text {av}}(K) \ll K^{\varepsilon }\). The \(\varepsilon \)-power is unavoidable at this point because of the use of Heath-Brown’s large sieve in the proof of Proposition 4. Except for the spectral large sieve implicit in proof of Proposition 4, we have not touched the spectral \(\mathtt{u}\)-sum, so any further improvement must involve a treatment of this sum. This is precisely the purpose of the relative trace formula for Heegner periods given in Theorem 3 resp. Theorem 18. The weaker result (10.1) is nevertheless useful: it allows us to discard small eigenvalues \(t_\mathtt{u} \ll K^{1/2 - \varepsilon }\), most importantly the constant function, and it allows us to estimate efficiently some error terms later. The following sections are devoted to the proof of Theorem 2.

11 Proof of Theorem 2: the preliminary argument

By (1.3) and (6.8) we have

$$\begin{aligned} \begin{aligned} \mathcal {N}_{\text {av}}(K) =&\, \frac{12}{\omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \sum _{h \in B_{k-1/2}^+(4)} \frac{\pi ^2}{90} \cdot 9\sqrt{\pi }\cdot 2\\&\sum _{(n, m) = 1} \frac{\lambda (n) \mu (n)\mu ^2(m)}{n^{3/2}m^{3}} \int \limits _{-\infty }^{\infty } \int \limits _{\Lambda _{\text { ev}}} \frac{\Gamma (k - 3/2)}{(4\pi )^{k-3/2} \Vert h \Vert ^2} \\&\qquad \qquad \sum _{f_1, f_2, D_1, D_2} \frac{c(|D_1|) c(|D_2|) P(D_1; \mathtt{u})\overline{P(D_2; \mathtt{u})}}{f_1f_2 |D_1D_2|^{k/2}}\Big (\frac{|D_2|f_2^2}{|D_1|f_1^2}\Big )^{it}\\&\qquad \qquad V_t(|D_1D_2|(f_1f_2)^2; k, t_\mathtt{u}) d\mathtt{u} \, dt. \end{aligned} \end{aligned}$$

Throughout we agree on the convention that D (with or without indices) denotes a negative discriminant and \(\Delta \) denotes a negative fundamental discriminant. We make two immediate manipulations. Fix some \(0< \eta < 1/100\) such that \(10^6/\eta \in 2\mathbb {Z}\). By the concluding remark of the preceding section we can insert the function

$$\begin{aligned} \omega (t_\mathtt{u}) = 1 - e^{-(t_\mathtt{u}/K^{1/2- \eta })^{10^6/\eta }} \end{aligned}$$
(11.1)

(not to be confused with the constant \(\omega \) in the previous display) into the \(\mathtt{u}\)-integral, and we can truncate the nm-sum at

$$\begin{aligned} n,m \ll K^{\eta }. \end{aligned}$$

Both transformations induce an admissible error, the former due to that \(\omega (t_\mathtt{u}) - 1 \ll _A K^{-A}\) for every \(A > 0\) and \(t_\mathtt{u} \gg K^{\frac{1}{2} - \frac{\eta }{2}}\). Note that \(\omega \) is even, holomorphic, within [0, 1] for \(t_\mathtt{u} \in \mathbb {R} \cup \{i/2, -i/2\}\) and satisfies

$$\begin{aligned} \begin{aligned} \omega (t_\mathtt{u})&\ll K^{-10^6}, \quad |t_\mathtt{u}| \leqslant K^{\frac{1}{2} - 2\eta },\\ |t_\mathtt{u}|^j \frac{d^j}{dt^j_\mathtt{u}} \omega (t_\mathtt{u})&\ll _j 1 \end{aligned} \end{aligned}$$
(11.2)

for \(j \in \mathbb {N}_0\). In particular, up to a negligible error we may ignore the constant function \(\mathtt{u} = \sqrt{3/\pi }\) with \(t_\mathtt{u} = i/2\). As before we denote by \(\int _{\Lambda _{\text {ev}}}^{*}\) a spectral sum/integral over the non-residual spectrum, i.e. everything except the constant function.

Note that \(\lambda (n)\) depends on h, as it is a Hecke eigenvalue of \(f_h\). Before we can sum over h using Lemma 6, we must first combine \(\lambda (n)\) with \(c(|D_2|)\). To this end we recall (2.4) and recast \(\mathcal {N}_{\text {av}}(K)\), up to a small error coming from the truncation of the nm-sum and the \(\mathtt{u}\)-integral, as

$$\begin{aligned} \begin{aligned}&\frac{12}{ \omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \sum _{h \in B_{k-1/2}^+(4)} \frac{\pi ^2}{90} \cdot 9\sqrt{\pi }\cdot 2\sum _{\begin{array}{c} (n, m) = 1\\ n, m \leqslant K^{\eta } \end{array}} \frac{ \mu (n)\mu ^2(m)}{n^{3/2}m^{3}} \\&\quad \int \limits _{-\infty }^{\infty } \int \limits ^{*}_{\Lambda _{\text { ev}}} \omega (t_\mathtt{u}) \frac{\Gamma (k - 3/2)}{(4\pi )^{k-3/2} \Vert h \Vert ^2} \sum _{f_1, f_2, D_1, D_2} \sum _{\begin{array}{c} d_1 \mid d_2 \mid n\\ (d_1d_2)^2 \mid n^2D_2 \end{array}} \left( \frac{d_1}{d_2} \right) ^{1/2} \chi _{ D_2}\Big (\frac{d_2}{d_1}\Big )\\&\qquad \left( \frac{n}{d_1d_2}\right) ^{3/2 - k} \frac{c(|D_1|) c(|D_2|n^2/(d_1d_2)^2) P(D_1; \mathtt{u})\overline{P(D_2; \mathtt{u})}}{f_1f_2 |D_1D_2|^{k/2}} \Big (\frac{|D_2|f_2^2}{|D_1|f_1^2}\Big )^{it} \\&\qquad V_t(|D_1D_2|(f_1f_2)^2; k, t_\mathtt{u}) d\mathtt{u} \, dt . \end{aligned} \end{aligned}$$
(11.3)

We can now sum over h using Lemma 6, and we start with an analysis of the diagonal term which is given by

$$\begin{aligned} \begin{aligned}&\mathcal {N}^{\text {diag}}(K) = \frac{12}{\omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \frac{\pi ^2}{90} \cdot 9\sqrt{\pi } \cdot 2\cdot \frac{2}{3} \sum _{\begin{array}{c} (n, m) = 1\\ n, m \leqslant K^{\eta } \end{array}} \frac{ \mu (n)\mu ^2(m)}{n^{3/2}m^{3}}\\&\quad \int \limits _{-\infty }^{\infty } \int \limits ^{*}_{\Lambda _{\text { ev}}} \omega (t_\mathtt{u}) \sum _{f_1, f_2, D} \sum _{\begin{array}{c} d_1 \mid d_2 \mid n\\ (d_1d_2)^2 \mid n^2D \end{array}} \left( \frac{d_1}{d_2} \right) ^{1/2} \chi _{ D}\\&\quad \Big (\frac{d_2}{d_1}\Big ) \frac{ P(Dn^2/(d_1d_2)^2; \mathtt{u})\overline{P(D; \mathtt{u})}}{f_1f_2 (|D|n/(d_1d_2))^{3/2}}\Big (\frac{d_1d_2f_2}{nf_1}\Big )^{2it} V_t\Big (\Big (\frac{|D|nf_1f_2}{d_1d_2}\Big )^2;\\&\quad k, t_\mathtt{u}\Big ) d\mathtt{u} \, dt . \end{aligned} \end{aligned}$$

While the upper bound \(K^{\varepsilon }\) for the diagonal term is fairly easy to obtain, cf. Sect. 10.1, the asymptotic analysis of \( \mathcal {N}^{\text {diag}}(K)\) is extremely involved and occupies this and the following two sections. We will eventually show that \( \mathcal {N}^{\text {diag}}(K) = 4\log K + O(1)\). The discussion of the off-diagonal term is postponed to Sect. 14.

We write \(d_2 = d_1\delta \), \(n = d_1\delta \nu \), so that \(d_1^2 \mid \nu ^2 D\). Since n is squarefree, this implies \(d_1^2 \mid D\). We write \(d_1 = d\) and \(D d^2\) in place of D. With this notation we recast \( \mathcal {N}^{\text {diag}}(K)\) as

$$\begin{aligned} \begin{aligned}&\frac{12}{ \omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \frac{\pi ^2}{90} \cdot 9\sqrt{\pi }\cdot 2 \cdot \frac{2}{3}\sum _{\begin{array}{c} (d\delta \nu , m) = 1\\ d\delta \nu , m \leqslant K^{\eta } \end{array}} \frac{ \mu (d\delta \nu )\mu ^2(m)}{(d\delta \nu )^{3/2}m^{3}} \\&\quad \int \limits _{-\infty }^{\infty } \int \limits ^{*}_{\Lambda _{\text { ev}}} \omega (t_\mathtt{u}) \sum _{f_1, f_2, D} \frac{\chi _D(\delta )}{\delta ^{1/2}} \frac{ P(D\nu ^2; \mathtt{u})\overline{P(Dd^2; \mathtt{u})}}{f_1f_2 (d|D|\nu )^{3/2}} \Big (\frac{df_2}{\nu f_1}\Big )^{2it} \\&\quad \qquad V_t ( ( |D|\nu df_1f_2 )^2; k, t_\mathtt{u} ) d\mathtt{u} \, dt. \end{aligned} \end{aligned}$$

From the Katok-Sarnak formula in combination with (3.10) in the cuspidal case and from (4.11) in combination with (4.2) in the Eisenstein case we concludeFootnote 11

$$\begin{aligned} P(\Delta f^2, \mathtt{u}) = P(\Delta , \mathtt{u})\alpha _\mathtt{u}(f), \quad \alpha _\mathtt{u}(f) = f^{1/2} \sum _{d \mid f} \mu (d) \chi _{\Delta }(d) \lambda _\mathtt{u}(f/d) d^{-1/2} \end{aligned}$$

for a fundamental discriminant \(\Delta \) where \(\alpha _\mathtt{u}(f)\) depends also on \(\Delta \), which we suppress from the notation. Using this notation along with (4.10) in the cuspidal case and (4.12) in the Eisenstein case we obtain

$$\begin{aligned} \begin{aligned} \mathcal {N}^{\text {diag}}(K)&= \frac{12}{ \omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \frac{\pi ^2}{90} \cdot 9\sqrt{\pi }\cdot 2 \cdot \frac{2}{3} \cdot \frac{1}{4}\\&\quad \sum _{\begin{array}{c} (d\delta \nu , m) = 1\\ d\delta \nu , m \leqslant K^{\eta } \end{array}} \frac{ \mu (d\delta \nu )\mu ^2(m)}{(d\delta \nu )^{3/2}m^{3}} \int \limits _{-\infty }^{\infty } \int \limits ^{*}_{\Lambda _{\text { ev}}} \omega (t_\mathtt{u})\\&\quad \sum _{f_1, f_2}\sum _{\begin{array}{c} D = \Delta f^2\\ (\delta , f) = 1 \end{array}} \frac{\chi _{\Delta }(\delta ) \alpha _\mathtt{u} (f\nu )\overline{ \alpha _\mathtt{u}(f d) } }{\delta ^{1/2}f_1f_2 (df^2\nu )^{3/2}|\Delta |} \frac{L(\mathtt{u}, 1/2) L(\mathtt{u}, \Delta , 1/2)}{\mathcal {L}(\mathtt{u})} \Big (\frac{df_2}{\nu f_1}\Big )^{2it} \\&\quad \quad V_t ( ( |D|\nu df_1f_2 )^2; k, t_\mathtt{u} ) d\mathtt{u} \, dt \end{aligned} \end{aligned}$$

where \(\mathcal {L}(\mathtt{u}) = L(\text {sym}^2 \mathtt{u}, 1)\) if \(\mathtt{u}\) is cuspidal and \(\mathcal {L}(\mathtt{u}) = \frac{1}{2}|\zeta (1 + 2 i t)|^2\) if \(\mathtt{u} = E(., 1/2 + it)\) is Eisenstein (with the obvious interpretation in the case \(t = 0\)). With later transformations in mind, we also restrict the f-sum to \(f \leqslant K^{\eta }\). By trivial estimates along with Corollary 5 and (9.16), this induces an error of \(O(K^{\varepsilon - \eta })\). By the usual Hecke relations we have

$$\begin{aligned}&\alpha _\mathtt{u} (f\nu )\overline{ \alpha _\mathtt{u}(f d)} \\&\quad = f (d\nu )^{1/2} \sum _{\begin{array}{c} d_1 \mid fd\\ d_2 \mid f\nu \end{array}} \sum _{d_3 \mid (\frac{fd}{d_1}, \frac{f\nu }{d_2}) }\frac{\mu (d_1)\chi _{\Delta }(d_1) \mu (d_2)\chi _{\Delta }(d_2) }{\sqrt{d_1d_2}} \lambda _\mathtt{u}(f^2 d\nu /(d_1d_2d_3^2)) . \end{aligned}$$

We summarize the previous discussion as

$$\begin{aligned} \begin{aligned}&\mathcal {N}^{\text {diag}}(K)\\&\quad = \frac{12}{ \omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \frac{\pi ^2}{90} \cdot 9\sqrt{\pi }\cdot 2 \cdot \frac{2}{3} \cdot \frac{1}{4}\sum _{\begin{array}{c} (d\delta \nu , m) = 1\\ d\delta \nu , m \leqslant K^{\eta } \end{array}} \frac{ \mu (d\delta \nu )\mu ^2(m)}{(d\delta \nu )^{3/2}m^{3}} \\&\quad \int \limits _{-\infty }^{\infty } \sum _{f_1, f_2, \Delta }\sum _{\begin{array}{c} f\leqslant K^{\eta }\\ (\delta , f) = 1 \end{array}} \frac{\chi _{\Delta }(\delta ) }{\delta ^{1/2}f_1f_2 df^2\nu |\Delta | }\Big (\frac{df_2}{\nu f_1}\Big )^{2it} \\&\quad \sum _{\begin{array}{c} d_1 \mid fd\\ d_2 \mid f\nu \end{array}} \sum _{d_3 \mid (\frac{fd}{d_1}, \frac{f\nu }{d_2}) }\frac{\mu (d_1)\chi _{\Delta }(d_1) \mu (d_2)\chi _{\Delta }(d_2) }{\sqrt{d_1d_2}} \mathcal {I}\Big (\Delta , t, k, \frac{f^2 d \nu }{d_1d_2d_3^2}\Big ) dt + O(K^{\varepsilon - \eta }) \end{aligned}\nonumber \\ \end{aligned}$$
(11.4)

where

$$\begin{aligned} \mathcal {I}(\Delta , t,k, r) = \int \limits ^{*}_{\Lambda _{\text { ev}}} \frac{L(\mathtt{u}, 1/2) L(\mathtt{u}, \Delta , 1/2)}{\mathcal {L}(\mathtt{u})} \lambda _\mathtt{u}(r) h(t_\mathtt{u}) d\mathtt{u} \end{aligned}$$

with

$$\begin{aligned} h(\tau ) = \omega (\tau ) V_t ( ( |\Delta |f^2\nu df_1f_2 )^2; k,\tau ) . \end{aligned}$$
(11.5)

The expression \(\mathcal {I}\) depends also on \(f^2 \nu d f_1f_2\), but we suppress this from the notation. We insert the approximate functional equations (4.14) and (4.16) getting

$$\begin{aligned} \begin{aligned} \mathcal {I}(\Delta , t,k, r) =&\ 4\int \limits ^{*}_{\Lambda _{\text { ev}}}\sum _{\mathtt{n},\mathtt{m}} \frac{\lambda _\mathtt{u}(\mathtt{n}) \lambda _\mathtt{u}(\mathtt{m}) \chi _{\Delta }(\mathtt{m})\lambda _\mathtt{u}(r)}{(\mathtt{n}{} \mathtt{m})^{1/2}}W^+_{t_\mathtt{u}}(\mathtt{n}) W^-_{t_\mathtt{u}}\Big (\frac{\mathtt{m}}{|\Delta |}\Big ) \frac{1}{\mathcal {L}(\mathtt{u})} h(t_\mathtt{u}) d\mathtt{u}\\&- \int \limits _{-\infty }^{\infty } \sum _{\pm } \frac{\zeta (1 \pm 2i\tau )\Gamma (\frac{1}{2} \pm i\tau )\pi ^{\mp i\tau } e^{(1/2 \pm i\tau )^2}}{(\frac{1}{2} \pm i \tau )\Gamma (\frac{1}{4} + \frac{i\tau }{2})\Gamma (\frac{1}{4} - \frac{i\tau }{2})}\\&\quad \qquad \frac{|L(\chi _{\Delta }, 1/2 + i\tau )|^2}{|\zeta (1 + 2i\tau )|^2} \rho _{1/2 + i\tau }(r) h(\tau ) \frac{d\tau }{2\pi }. \end{aligned} \end{aligned}$$

Since the \(\tau \)-integral is rapidly converging, it is easy to see that the polar term contributes at most \(O(K^{\varepsilon - 1})\) to (11.4), so from now on we focus on the first term of the preceding display. By the Hecke relations we can recast it as

$$\begin{aligned} 4 \sum _{d \mid r} \int \limits ^{*}_{\Lambda _{\text { ev}}}\sum _{\mathtt{n},\mathtt{m}} \frac{\lambda _\mathtt{u}(\mathtt{n}r/d) \lambda _\mathtt{u}(\mathtt{m}) \chi _{\Delta }(\mathtt{m}) }{(d\mathtt{n}{} \mathtt{m})^{1/2}} W^+_{t_\mathtt{u}}(d\mathtt{n}) W^-_{t_\mathtt{u}}\Big (\frac{\mathtt{m}}{|\Delta |}\Big ) \frac{1}{\mathcal {L}(\mathtt{u})} h(t_\mathtt{u}) d\mathtt{u} . \end{aligned}$$
(11.6)

This is now in shape to apply the Kuznetsov formula for the even spectrum, Lemma 7. We treat the three terms on the right hand side of (3.5) separately and start with the diagonal term to which the next section is devoted. The two off-diagonal terms are treated in Sect. 13. (In the simpler analysis of Sect. 10.1 the Kuznetsov formula is hidden in the spectral large sieve in the proof of Proposition 4. The precise asymptotic analysis requires us to deal with the two off-diagonal terms in Lemma 7 explicitly.)

12 The diagonal diagonal term

The diagonal contribution to (11.6) equals

$$\begin{aligned} \mathcal {I}^{\text {diag}}(\Delta , t, k, r) = 4 \sum _{d \mid r} \sum _{\mathtt{n}} \frac{ \chi _{\Delta }(\mathtt{n}r/d) }{\mathtt{n}r^{1/2}} \int \limits _{-\infty }^{\infty } W^+_{\tau }(d\mathtt{n}) W^-_{\tau }\Big (\frac{\mathtt{n}r/d}{|\Delta |}\Big ) \tau \tanh (\pi \tau ) h(\tau ) \frac{d\tau }{4\pi ^2} . \end{aligned}$$

Opening up the Mellin transform in the definition (4.15), this equals

$$\begin{aligned} \begin{aligned} \frac{1}{\sqrt{r}} \int \limits _{-\infty }^{\infty }&h(\tau ) \int \limits _{(2)} \int \limits _{(2)} \prod _{\pm }\Big ( \frac{\Gamma (\frac{1}{2}(\frac{1}{2} + s_1 \pm i\tau ))\Gamma (\frac{1}{2}(\frac{3}{2} + s_2 \pm i\tau ))}{\Gamma (\frac{1}{2}(\frac{1}{2} \pm i\tau ))\Gamma (\frac{1}{2}(\frac{3}{2} \pm i\tau )) } \Big ) |\Delta |^{s_2} \\&L( \chi _{\Delta }, 1 + s_1 + s_2)\sum _{r_1r_2 = r} \frac{\chi _{\Delta }(r_2) }{r_1^{s_1} r_2^{s_2}} \frac{e^{s_2^2 +s_1^2}}{\pi ^{s_1+s_2}s_1s_2} \frac{ds_1 \, ds_2}{(2\pi i)^2} \tau \tanh (\pi \tau ) \frac{d\tau }{\pi ^2}. \end{aligned} \end{aligned}$$

We shift the \(s_1, s_2\)-contours to \(\mathfrak {R}s_1 = \mathfrak {R}s_2 = -1/4\) getting

$$\begin{aligned} \begin{aligned} \mathcal {I}^{\text {diag}}&(\Delta , t, k, r) = \frac{1}{\sqrt{r}} L( \chi _{\Delta }, 1) \sum _{r_1r_2 = r} \chi _{\Delta }(r_2) \int \limits _{-\infty }^{\infty } h(\tau ) \tau \tanh (\pi \tau ) \frac{d\tau }{\pi ^2} \\&+\! O\Bigg (\int \limits _{-\infty }^{\infty } |h(\tau )| |\tau |^{3/4} d\tau \int \limits _{-\infty }^{\infty } e^{\xi ^2}\Bigg (\frac{| L(\chi _{\Delta }, 1/2 \!+\! i\xi )|}{|\Delta |^{1/4}} \!+\!| L(\chi _{\Delta }, 3/4 \!+\! i\xi )|\Bigg ) d\xi \Bigg ) . \end{aligned}\nonumber \\ \end{aligned}$$
(12.1)

We first deal with the error term and substitute it back into (11.4). Roughly speaking the factor \(|\tau |^{3/4}\) saves a factor \(K^{1/8}\) from the trivial bound, while on average over \(\Delta \) the L-values on the lines 1/2 and 3/4 are still bounded. More precisely, recalling (9.16) the error term gives a total contribution of at most

$$\begin{aligned}&\frac{1}{K^{3/2}} \int \limits _{-\infty }^{\infty } \int \limits _{-\infty }^{\infty } \int \limits _{-\infty }^{\infty } \sum _{\Delta } \Big (\frac{| L(\chi _{\Delta }, 1/2 + i\xi )|}{|\Delta |^{5/4}} +\frac{| L(\chi _{\Delta }, 3/4 + i\xi )|}{|\Delta |} \Big )\\&\quad \Big ( 1 + \frac{|t|^2 + |\tau |^2}{K}\Big )^{-10} e^{\xi ^2} d\xi \, |\tau |^{3/4}d\tau \, dt. \end{aligned}$$

By a standard mean value bound for the \(\Delta \)-sum (e.g. [34, Theorem 2]), the previous display can be bounded by \(\ll K^{-1/8 + \varepsilon }\). We substitute the main term in (12.1) into (11.4) getting

$$\begin{aligned} \begin{aligned}&\mathcal {N}^{\text {diag}, \text {diag}}(K) := \dfrac{12}{ \omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \dfrac{\pi ^2}{90} \cdot 9\sqrt{\pi }\cdot 2 \cdot \frac{2}{3} \cdot \dfrac{1}{4}\\&\sum _{\begin{array}{c} (d\delta \nu , m) = 1 d\delta \nu , m \leqslant K^{\eta } \end{array}} \dfrac{ \mu (d\delta \nu )\mu ^2(m)}{(d\delta \nu )^{3/2}m^{3}} \sum _{f_1, f_2, \Delta }\sum _{\begin{array}{c} f \leqslant K^{\eta }\\ (\delta , f) = 1 \end{array}} L( \chi _{\Delta }, 1) \int \limits _{-\infty }^{\infty } \sum _{\begin{array}{c} d_1 \mid fd\\ d_2 \mid f\nu \end{array}} \sum _{d_3 \mid (\frac{fd}{d_1}, \frac{f\nu }{d_2}) }\\&\sum _{r_1r_2 = \frac{f^2 d \nu }{d_1d_2d_3^2}} \dfrac{\chi _{\Delta }(\delta ) \mu (d_1)\chi _{\Delta }(d_1) \mu (d_2)\chi _{\Delta }(d_2) d_3 \chi _{\Delta }(r_2) }{\delta ^{1/2}f_1f_2 (df^2\nu )^{3/2} |\Delta |(f_1\nu /(f_2d))^{\pm 2it} } \int \limits _{-\infty }^{\infty } h(\tau ) \tau \tanh (\pi \tau ) \dfrac{d\tau }{\pi ^2} dt \end{aligned} \end{aligned}$$

where we recall that \(h(\tau )\) is given by (11.5) and depends in particular on t, k and \(\Delta \) (as well as on \(f, f_1, f_2, d, \nu \)). A trivial estimate at this point using (9.16) shows

$$\begin{aligned} \begin{aligned}&\mathcal {N}^{\text {diag}, \text {diag}}(K)\ll \frac{1}{K^2}\sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \sum _{f_1, f_2,\Delta } \frac{L(\chi _{\Delta }, 1)}{|\Delta | f_1f_2}\\&\int \limits _{-\infty }^{\infty } \int \limits _{-\infty }^{\infty }\frac{1}{k^{1/2}} \Big (1 + \frac{|\Delta | (f_1f_2)^2}{k^4}\Big )^{-A}\Big (1 + \frac{|t|^2 + |\tau |^2}{k} \Big )^{-A} |\tau | d\tau \, dt\\&\ll \log K, \end{aligned} \end{aligned}$$
(12.2)

(by standard mean value results for \(L(\chi _{\Delta }, 1)\)), but eventually we want an asymptotic formula, not an upper bound.

Our next goal is to show that the t-integral forces \(f_1\nu = f_2d\), up to a negligible error. To make this precise, we first observe that by the same computation as in (12.2) the portion \(|t| \leqslant K^{2/5}\) contributes at most \(O(K^{-1/10 + \varepsilon })\) to \( \mathcal {N}^{\text {diag}, \text {diag}}(K) \). We can therefore insert a smooth weight function that vanishes on \(|t| \leqslant \frac{1}{2} K^{2/5}\) and is one on \(|t| \geqslant K^{2/5}\). Integrating by parts sufficiently often using (9.16), we can then restrict to

$$\begin{aligned} f_1\nu = f_2d (1 + O(K^{\varepsilon - 2/5})) \end{aligned}$$

up to a negligible error. It is then easy to see that the terms \(f_1 d \not = f_2 \nu \) contribute \(O(K^{\varepsilon - 2/5})\) to \( \mathcal {N}^{\text {diag}, \text {diag}}(K) \). Having excluded these, we re-insert the portion \(|t| \leqslant K^{2/5}\) to the t-integral, again at the cost of an error \(O(K^{\varepsilon -1/10})\). Finally we complete the \(d, \delta , \nu , m, f\)-sum at the cost of an error \(O(K^{\varepsilon -\eta })\). Since \((\nu , d) = 1\), the equation \(f_1d = f_2 \nu \) implies \(f_2 = dg\), \(f_1 = \nu g\) for some \(g\in \mathbb {N}\). Substituting all this, we recast \(\mathcal {N}^{\text {diag}, \text {diag}}(K) \) as

$$\begin{aligned} \begin{aligned}&\frac{12}{ \omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \frac{\pi ^2}{90} \cdot 9\sqrt{\pi }\cdot 2 \cdot \frac{2}{3} \cdot \frac{1}{4}\sum _{ (d\delta \nu , m) = 1 } \frac{ \mu (d\delta \nu )\mu ^2(m)}{(d\delta \nu )^{3/2}m^{3}} \sum _{\begin{array}{c} g, f, \Delta \\ (\delta , f) = 1 \end{array}} L( \chi _{\Delta }, 1) \\&\quad \int \limits _{-\infty }^{\infty } \sum _{\begin{array}{c} d_1 \mid fd\\ d_2 \mid f\nu \end{array}} \sum _{d_3 \mid (\frac{fd}{d_1}, \frac{f\nu }{d_2}) } \sum _{r_1r_2 = \frac{f^2 d \nu }{d_1d_2d_3^2}} \frac{\chi _{\Delta }(\delta ) \mu (d_1)\chi _{\Delta }(d_1) \mu (d_2)\chi _{\Delta }(d_2) d_3 \chi _{\Delta }(r_2) }{\delta ^{1/2}g^2d\nu (df^2\nu )^{3/2} |\Delta |}\\&\quad \int \limits _{-\infty }^{\infty } h(\tau ) \tau \tanh (\pi \tau ) \frac{d\tau }{\pi ^2} dt \end{aligned} \end{aligned}$$

up to an error of \(O(K^{\varepsilon -\eta })\), where in the definition (11.5) of h we replace \(f_2 = dg\), \(f_1 = \nu g\). We substitute this modified version of (11.5) and open the Mellin transform (6.7), so that the previous display becomes

$$\begin{aligned} \begin{aligned}&\frac{12}{ \omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \frac{\pi ^2}{90} \cdot 9\sqrt{\pi }\cdot 2 \cdot \frac{2}{3} \cdot \frac{1}{4} \int \limits _{(3)} \frac{e^{v^2 }}{v} {\mathscr {L}}(2v) \\&\int \limits _{-\infty }^{\infty } \int \limits _{-\infty }^{\infty } \mathcal {G}(k, \tau , v + 1/2 + it) \mathcal {G}(k, \tau , v + 1/2 - it) \omega (\tau ) \tau \tanh (\pi \tau ) \frac{d\tau }{\pi ^2} dt \frac{dv }{2\pi i} \end{aligned} \end{aligned}$$
(12.3)

where

$$\begin{aligned} \begin{aligned} {\mathscr {L}}(v)&= \sum _{ (d\delta \nu , m) = 1 } \sum _{\begin{array}{c} g, f, \Delta \\ (f, \delta ) = 1 \end{array}} \sum _{\begin{array}{c} d_1 \mid fd\\ d_2 \mid f\nu \end{array}} \sum _{d_3 \mid (\frac{fd}{d_1}, \frac{f\nu }{d_2}) }\\&\quad \sum _{r_1r_2 = \frac{f^2 d \nu }{d_1d_2d_3^2}} \frac{ \mu (d\delta \nu )\mu ^2(m) \mu (d_1)\mu (d_2) \chi _{\Delta }(\delta d_1 d_2r_2) d_3 }{(d\nu )^{4 + 2v}( \delta g) ^{2+2v}f^{3+2v} m^3 |\Delta |^{1+v}} L( \chi _{\Delta }, 1) . \end{aligned} \end{aligned}$$

Recall our general assumption that \(\Delta \) runs over negative fundamental discriminants. The main term will come from the residue at \(v = 0\) and we need to analytically continue \({\mathscr {L}}\) to \(\mathfrak {R}v < 0\) and compute the residue at \(v = 0\). The critical portion is the \(\Delta \)-sum which we analyze in the following lemma.

Lemma 25

Let \(\alpha \in \mathbb {N}\) and uniquely write \(\alpha = \alpha _1^2 \alpha _2\) with \(\mu ^2(\alpha _2) = 1\). Then

$$\begin{aligned} \sum _{-X \leqslant \Delta < 0} \chi _{\Delta }(\alpha ) L( \chi _{\Delta }, 1)= & {} \frac{\zeta (2) X}{2\alpha _2} \prod _{p \mid \alpha } \Big (1 + \frac{1}{p} - \frac{1}{p^{3}}\Big )^{-1} \prod _{p }\Big ( 1 - \frac{1}{p^{2}} - \frac{1}{p^{3}} + \frac{1}{p^{4}}\Big ) \\&+ O\big (X^{13/18}\alpha ^{1/4} (X\alpha )^{\varepsilon }\big ). \end{aligned}$$

In particular, the Dirichlet series

$$\begin{aligned} {\mathscr {K}}(v; \alpha ) = \sum _{\Delta < 0} \frac{\chi _{\Delta }(\alpha ) L( \chi _{\Delta }, 1)}{|\Delta |^{1+v}} \end{aligned}$$

has analytic continuation to \(\mathfrak {R}v > -5/18\) except for a simple pole at \(v=0\) with residue

$$\begin{aligned} \frac{\zeta (2)}{2\alpha _2} \prod _{p \mid \alpha } \Big (1 + \frac{1}{p} - \frac{1}{p^{3}}\Big )^{-1} \prod _{p }\Big ( 1 - \frac{1}{p^{2}} - \frac{1}{p^{3}} + \frac{1}{p^{4}}\Big ) \end{aligned}$$

and is bounded by \(O_{\varepsilon }(|v| \alpha ^{1/4+\varepsilon })\) in the region \(\mathfrak {R}v \geqslant -5/18 + \varepsilon \), \(|v| \geqslant \varepsilon \).

Remark: The computation of the leading constant in Lemma 25 seems to be a new result even in the case \(\alpha = 1\) and features an interesting Euler product. See [46] for similar Euler products for averages at the point 1/2. The case \(\alpha = 1\) can be read off from [31].

Proof

Let w be a fixed smooth function that is equal to 1 on [0, 1] and vanishes on \([2, \infty )\). Let \(Y \geqslant 1\). We have

$$\begin{aligned} \sum _n\frac{\chi _{\Delta }(n)}{n} w\left( \frac{n}{Y}\right) = \int \limits _{(2)} L(\chi _{\Delta }, 1+s) \widehat{w}(s)Y^s \frac{ds}{2\pi i} = L( \chi _{\Delta }, 1) + O(Y^{-1/2} |\Delta |^{1/6 + \varepsilon }) \end{aligned}$$

where \(\widehat{w}\) in the present case denotes the Mellin transform and the left hand side comes from a contour shift to \(\mathfrak {R}s = -1/2\) and the Conrey-Iwaniec [20] subconvexity bound for real characters. We obtain

$$\begin{aligned} \sum _{-X \leqslant \Delta< 0} \chi _{\Delta }(\alpha ) L( \chi _{\Delta }, 1)= \sum _n \frac{1}{n}w\left( \frac{n}{Y}\right) \sum _{-X \leqslant \Delta < 0} \chi _{\Delta }(\alpha n) + O(X^{7/6+\varepsilon } Y^{-1/2}).\nonumber \\ \end{aligned}$$
(12.4)

We decompose the main term as \(S_{\square } + S_{\not = \square }\) depending on whether \(\alpha n\) is a square or not. We first consider the portion \(S_{\square }\) where n is restricted to \(n = \alpha _2k^2\) with \(k \in \mathbb {N}\). This gives

$$\begin{aligned} \begin{aligned} S_{\square }&= \sum _k \frac{1}{\alpha _2 k^2} w\left( \frac{\alpha _2k^2}{Y}\right) \sum _{\begin{array}{c} -X \leqslant \Delta< 0\\ (\Delta , \alpha k) = 1 \end{array}} 1 = \sum _k \frac{1}{\alpha _2 k^2} \sum _{\begin{array}{c} -X \leqslant \Delta < 0\\ (\Delta , \alpha k) = 1 \end{array}} 1 + O\Big (\frac{X}{Y}\Big ). \end{aligned} \end{aligned}$$
(12.5)

We decompose the main term as \( S_{\square }^{\text {odd}} + S_{\square }^{\text {even, 4}} + S_{\square }^{\text {even, 8}}\) depending on whether \(\Delta \) is odd, exactly divisible by 4 or exactly divisible by 8. We have

$$\begin{aligned} S_{\square }^{\text {odd}} = \frac{1}{2\alpha _2} \sum _k \frac{1}{k^2} \sum _{\begin{array}{c} m \leqslant X\\ (m, \alpha k) = 1 \end{array}} \mu ^2(m)(\chi _0(m) - \chi _{-4}(m)) \end{aligned}$$

where \(\chi _0\) is the trivial character modulo 4 and \(\chi _{-4}\) the non-trivial character modulo 4. For \(\chi \in \{\chi _0, \chi _{-4}\}\) we consider the Dirichlet series

$$\begin{aligned} \begin{aligned}&\frac{1}{2\alpha _2}\sum _k \frac{1}{k^2} \sum _{ (m, \alpha k) = 1} \frac{\mu ^2(m)\chi (m)}{m^s} = \frac{\zeta (2)}{2\alpha _2} \prod _{p \not \mid \alpha } \Big (1 + \frac{\chi (p)}{p^s} - \frac{\chi (p)}{p^{s+2}}\Big ) \\&\quad = \frac{\zeta (2)}{2\alpha _2} \prod _{p \mid \alpha } \Big (1 + \frac{\chi (p)}{p^s} - \frac{\chi (p)}{p^{s+2}}\Big )^{-1} L(\chi , s) \prod _p\Big ( 1 - \frac{\chi (p)^2}{p^{2s}} - \frac{\chi (p)}{p^{s+2}} + \frac{\chi (p)^2}{p^{2s+2}}\Big ). \end{aligned} \end{aligned}$$

A standard application of Perron’s formula (e.g. [71, Corollary II.2.4]) shows now that

$$\begin{aligned} S_{\square }^{\text {odd}}= & {} \frac{\zeta (2) X}{4\alpha _2} \prod _{\begin{array}{c} p \mid \alpha \\ p \not \mid 2 \end{array}} \Big (1 + \frac{1}{p} - \frac{1}{p^{3}}\Big )^{-1} \prod _{p \not \mid 2}\Big ( 1 - \frac{1}{p^{2}} - \frac{1}{p^{3}} + \frac{1}{p^{4}}\Big ) \nonumber \\&+ O\Big ( \frac{X^{1/2}}{\alpha _2}(\alpha _2 X)^{\varepsilon }\Big ). \end{aligned}$$
(12.6)

We have \(S_{\square }^{\text {even, 4}} \not = 0\) and \(S_{\square }^{\text {even, 8}} \not = 0\) only if \(\alpha \) is odd, which we assume from now on. Then

$$\begin{aligned} S_{\square }^{\text {even, 4}}= & {} \frac{1}{\alpha _2} \sum _{(k, 2) = 1} \frac{1}{k^2} \sum _{\begin{array}{c} m \leqslant X/4\\ (m, \alpha k) = 1\\ m \equiv 1 (\text {mod } 4) \end{array}} \mu ^2(m) \\= & {} \frac{1}{2\alpha _2} \sum _{(k, 2) = 1} \frac{1}{k^2} \sum _{\begin{array}{c} m \leqslant X/4\\ (m, \alpha k) = 1 \end{array}} \mu ^2(m)(\chi _0(m) + \chi _{-4}(m)) \end{aligned}$$

and by the same computation we obtain

$$\begin{aligned} S_{\square }^{\text {even, 4}}= & {} \frac{\zeta (2) X}{16\alpha _2} \Big (1 - \frac{1}{4}\Big ) \prod _{p \mid \alpha } \Big (1 + \frac{1}{p} - \frac{1}{p^{3}}\Big )^{-1} \prod _{p \not \mid 2}\Big ( 1 - \frac{1}{p^{2}} - \frac{1}{p^{3}} + \frac{1}{p^{4}}\Big ) \\&+ O\Big ( \frac{X^{1/2}}{\alpha _2}(\alpha _2 X)^{\varepsilon }\Big ). \end{aligned}$$

Finally,

$$\begin{aligned} S_{\square }^{\text {even, 8}} = \frac{1}{\alpha _2} \sum _{(k, 2) = 1} \frac{1}{k^2} \sum _{\begin{array}{c} m \leqslant X/8\\ (m, \alpha k) = 1\\ m \equiv 1 (\text {mod } 2) \end{array}} \mu ^2(m) = \frac{1}{\alpha _2} \sum _{(k, 2) = 1} \frac{1}{k^2} \sum _{\begin{array}{c} m \leqslant X/8\\ (m, \alpha k) = 1 \end{array}} \mu ^2(m)\chi _0(m) \end{aligned}$$

where now \(\chi _0\) is the unique character modulo 2, and we get the same main term for \(S_{\square }^{\text {even, 8}} \). Putting everything together, we obtain for \(\alpha _2\) odd that

$$\begin{aligned} \begin{aligned} S_{\square }&= \frac{\zeta (2) X}{\alpha _2} \prod _{p \mid \alpha } \Big (1 + \frac{1}{p} - \frac{1}{p^{3}}\Big )^{-1} \prod _{p }\Big ( 1 - \frac{1}{p^{2}} - \frac{1}{p^{3}} + \frac{1}{p^{4}}\Big ) \cdot \frac{16}{11} \Big ( \frac{1}{4} + \frac{1}{16} \cdot \frac{3}{4} \cdot 2\Big ) \\&\quad + O\Big (\frac{X}{Y}+ \frac{X^{1/2}}{\alpha _2}(\alpha _2 X)^{\varepsilon }\Big )\\&= \frac{\zeta (2) X}{2\alpha _2} \prod _{p \mid \alpha } \Big (1 + \frac{1}{p} - \frac{1}{p^{3}}\Big )^{-1} \prod _{p }\Big ( 1 - \frac{1}{p^{2}} - \frac{1}{p^{3}} + \frac{1}{p^{4}}\Big ) \\&\quad + O\Big (\frac{X}{Y}+ \frac{X^{1/2}}{\alpha _2}(\alpha _2 X)^{\varepsilon }\Big ) \end{aligned} \end{aligned}$$

and for \(\alpha _2\) even that

$$\begin{aligned} \begin{aligned} S_{\square }&= \frac{\zeta (2) X}{\alpha _2} \prod _{p \mid \alpha } \Big (1 + \frac{1}{p} - \frac{1}{p^{3}}\Big )^{-1} \prod _{p }\Big ( 1 - \frac{1}{p^{2}} - \frac{1}{p^{3}} + \frac{1}{p^{4}}\Big ) \cdot \frac{16}{11}\cdot \frac{1}{4}\Big (1 + \frac{1}{2} -\frac{1}{8} \Big ) \\&\quad + O\Big (\frac{X}{Y}+ \frac{X^{1/2}}{\alpha _2}(\alpha _2 X)^{\varepsilon }\Big )\\&= \frac{\zeta (2) X}{2\alpha _2} \prod _{p \mid \alpha } \Big (1 + \frac{1}{p} - \frac{1}{p^{3}}\Big )^{-1} \prod _{p }\Big ( 1 - \frac{1}{p^{2}} - \frac{1}{p^{3}} + \frac{1}{p^{4}}\Big ) \\&\quad + O\Big (\frac{X}{Y}+ \frac{X^{1/2}}{\alpha _2}(\alpha _2 X)^{\varepsilon }\Big ). \end{aligned} \end{aligned}$$

Note how beautifully the constants fit together.

We return to (12.4) and study \(S_{\not =\square }\) where the n-sum is restricted to \(\alpha n \not = \square \). The function \(D \mapsto \chi _D(\alpha n) = (D/\alpha n)\) is a 4n-periodic, non-trivial, completely multiplicative function, defined on non-zero integers \(D \equiv 0, 1\) (mod 4). If n is odd, this function is naturally defined on all D and in fact n-periodic. If n is even, it can be extended (using the supplementary laws of quadratic reciprocity) to a not necessarily primitive, but non-trivial Dirichlet character modulo 4n. Thus it suffices to bound

$$\begin{aligned} \sum _{m \leqslant X'} \mu ^2(m) \psi (m) \end{aligned}$$

for a character \(\psi \) of conductor \(\ll \alpha Y\) and \(X' \leqslant X\). Writing \(\mu ^2 (m) = \sum _{d^2 \mid m} \mu (d)\) and using the Pólya-Vinogradov inequality, we bound the previous display by

$$\begin{aligned} \ll \sum _{d \leqslant X} \min \Big (\frac{X}{d^2}, (\alpha Y)^{1/2+\varepsilon }\Big ) \ll (X^{1/2}( \alpha Y)^{1/4})^{1+\varepsilon }. \end{aligned}$$
(12.7)

Collecting error terms in (12.4), (12.5), (12.6), (12.7), the total error becomes

$$\begin{aligned} \ll \Big (\frac{X^{7/6}}{Y^{1/2}} + \frac{X}{Y} + \frac{X^{1/2}}{\alpha _2} + X^{1/2}(\alpha Y)^{1/4}\Big )(Xy\alpha )^{\varepsilon }. \end{aligned}$$

We choose \(Y = X^{8/9}\alpha ^{-1/3} + 1\) to recover a total error of \((X^{13/18} \alpha ^{1/6} + X^{1/9} \alpha ^{1/3} + X^{1/2} \alpha ^{1/4})(X\alpha )^{1+\varepsilon }\). This completes the proof of the asymptotic formula. The claim on the Dirichlet series \({\mathscr {K}}(v; \alpha )\) follows by partial summation. \(\square \)

With the notation of the previous lemma we can write

$$\begin{aligned} {\mathscr {L}}(v)= & {} \sum _{ (d\delta \nu , m) = 1 } \sum _{\begin{array}{c} g, f\\ (f, \delta ) = 1 \end{array}} \sum _{\begin{array}{c} d_1 \mid fd\\ d_2 \mid f\nu \end{array}} \sum _{d_3 \mid (\frac{fd}{d_1}, \frac{f\nu }{d_2}) } \sum _{r_1r_2 = \frac{f^2 d \nu }{d_1d_2d_3^2}} \\&\frac{ \mu (d\delta \nu )\mu ^2(m) \mu (d_1)\mu (d_2) d_3 }{(d\nu )^{4 + 2v}( \delta g) ^{2+2v}f^{3+4v} m^3 } {\mathscr {K}}(v, \delta d_1 d_2r_2 ), \end{aligned}$$

and we conclude that \({\mathscr {L}}\) has analytic continuation to \(\mathfrak {R}v > -13/18\) except for a simple pole at \(v = 0\) and polynomial (in fact linear) bounds on vertical lines. If \(\text {rad}(n)\) denotes the squarefree kernel of n, then

$$\begin{aligned} \begin{aligned}&\underset{v=0}{\text {res}} {\mathscr {L}}(v) = \frac{\zeta (2)^2}{2}\prod _{p }\Big ( 1 - \frac{1}{p^{2}} - \frac{1}{p^{3}} + \frac{1}{p^{4}}\Big ) \\&\quad \sum _{ (d\delta \nu , m) = 1 } \sum _{ (f, \delta ) = 1} \sum _{\begin{array}{c} d_1 \mid fd\\ d_2 \mid f\nu \end{array}} \sum _{d_3 \mid (\frac{fd}{d_1}, \frac{f\nu }{d_2}) } \sum _{r_1r_2 = \frac{f^2 d \nu }{d_1d_2d_3^2}} \\&\quad \frac{ \mu (d\delta \nu )\mu ^2(m) \mu (d_1)\mu (d_2) d_3 }{(d\nu )^{4 }\delta ^2 f^{3 } m^3 \text {rad}(\delta d_1 d_2r_2) } \prod _{p \mid \delta d_1 d_2r_2} \Big (1 + \frac{1}{p} - \frac{1}{p^3}\Big )^{-1} \end{aligned} \end{aligned}$$
(12.8)

where we have implicitly computed the g-sum in the definition of \({\mathscr {L}}(v)\) as \(\zeta (2)\). Now a massive computation with Euler products, best performed with a computer algebra system, shows gigantic cancellation, and we obtain the beautiful formula

$$\begin{aligned} \underset{v=0}{\text {res}} {\mathscr {L}}(v) = \frac{\zeta (2)^2}{2\zeta (4)}. \end{aligned}$$

With this we return to (12.3) and shift the v-contour to \(\mathfrak {R}v = -1/10\). By (9.13) and trivial bounds the remaining integral expression is bounded by

$$\begin{aligned} \ll \frac{1}{K^2} \sum _{K \leqslant k \leqslant 2K} K^{-\frac{1}{2} - \frac{4}{10}} \int \limits _{-\infty }^{\infty } \int \limits _{-\infty }^{\infty } \Big (1 + \frac{|t|^2 + |\tau |^2}{K}\Big ) |\tau | d\tau \, dt \ll K^{-4/10}. \end{aligned}$$

It remains to deal with the double pole at \(v = 0\) whose residue is given by

$$\begin{aligned} \begin{aligned} \mathcal {R} =&\frac{12}{ \omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \frac{\pi ^2}{90} \cdot 9\sqrt{\pi }\cdot 2 \cdot \frac{2}{3} \cdot \frac{1}{4} \\&\int \limits _{-\infty }^{\infty } \int \limits _{-\infty }^{\infty } \underset{v=0}{\text {res}}\Big ( \frac{e^{v^2 }}{v} {\mathscr {L}}(2v) \mathcal {G}(k, \tau , v+ 1/2 + it) \\&\mathcal {G}(k, \tau , v + 1/2 - it)\Big ) \omega (\tau ) \tau \tanh (\pi \tau ) \frac{d\tau }{\pi ^2} dt . \end{aligned} \end{aligned}$$

We can remove the factor \(\omega (\tau )\tanh (\pi \tau )\) at the cost of an error \(O(K^{-\eta /2})\), cf. the definition (11.1). Using the definition (6.5), at \(v=0\) we have the following Taylor expansion

$$\begin{aligned} \begin{aligned}&\mathcal {G}(k, \tau , v+ 1/2 + it) \mathcal {G}(k, \tau , v + 1/2 - it)\\&\quad = \mathcal {G}(k, \tau , 1/2 + it) \mathcal {G}(k, \tau , 1/2 - it) \\&\qquad \Bigg \{1 + v\Big (\sum _{\pm , \pm } \frac{\Gamma '}{\Gamma }\Bigg ( \frac{k-1/2}{2} \pm it \pm \frac{i\tau }{2}\Big ) - 4\log \pi \Bigg ) + O(v^2)\Bigg \}. \end{aligned} \end{aligned}$$

We have \(\frac{\Gamma '}{\Gamma }(z) = \log z +O(|z|^{-1})\) (for \(\mathfrak {R}z \geqslant 1\), say) and so

$$\begin{aligned} \sum _{\pm } \frac{\Gamma '}{\Gamma }\Big ( \frac{k-1/2}{2} - it \pm \frac{i\tau }{2}\Big ) - 4\log \pi = 4 \log k + O(1) \end{aligned}$$

for \(t, \tau \ll k^{2/3}\), say (the t and \(\tau \) integrals are negligible outside this region). In this range we can insert (9.15) to conclude that

$$\begin{aligned} \begin{aligned} \mathcal {R} =&\frac{12}{\omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \frac{\pi ^2}{90} \cdot 9\sqrt{\pi } \cdot 2 \cdot \frac{2}{3} \cdot \frac{1}{4} \cdot \frac{1}{2} \cdot \\&4\log k \int \limits _{-\infty }^{\infty } \int \limits _{-\infty }^{\infty } \frac{\zeta (2)^2}{2\zeta (4)}\frac{16}{\pi k^{1/2}} e^{-(4t^2 + \tau ^2)/k} | \tau | \frac{d\tau }{\pi ^2} dt + O(1). \end{aligned} \end{aligned}$$

We evaluate the two integrals, sum over k (by Poisson, for instance) and recall the definition of \(\omega \) just before (1.3) getting

$$\begin{aligned} \begin{aligned} \mathcal {R}&= \frac{12}{\omega K^2} \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \frac{\pi ^2}{90} \cdot 9\sqrt{\pi } \cdot 2\cdot \frac{2}{3} \cdot \frac{1}{4} \cdot \frac{1}{2} \cdot 4\log k \frac{\zeta (2)^2}{2\zeta (4)}\frac{16}{\pi k^{1/2}} k \cdot \frac{\sqrt{\pi k}}{2} \frac{1}{\pi ^2} + O(1)\\&= \frac{12}{2} \cdot \frac{\pi ^2}{90} \cdot 9 \sqrt{\pi } \cdot 2 \cdot \frac{2}{3} \cdot \frac{1}{4} \cdot \frac{1}{2} \cdot 4 \log K \cdot \frac{\zeta (2)^2}{2\zeta (4)}\frac{16}{\pi } \cdot \frac{\sqrt{\pi }}{2} \frac{1}{\pi ^2} + O(1) = 4 \log K + O(1). \end{aligned} \end{aligned}$$

We have now detected the main term and we conclude this section by stating that

$$\begin{aligned} \mathcal {N}^{\text {diag}, \text {diag}}(K) = \mathcal {R} + O(1) = 4\log K + O(1). \end{aligned}$$

13 The diagonal off-diagonal term

13.1 Preparing the stage

We return to (11.6) and consider the off-diagonal terms on the right hand side of (3.5). We treat the first off-diagonal term in detail in the following three subsections. In Sect. 13.4 we show the minor modifications to treat the second off-diagonal term. The first off-diagonal term is given by

$$\begin{aligned} \begin{aligned}&\mathcal {I}^{\text {off-diag,1}}(\Delta , t,k, r) := 8i \sum _{d \mid r} \sum _{\mathtt{n},\mathtt{m}} \dfrac{ \chi _{\Delta }(\mathtt{m}) }{(d\mathtt{n}{} \mathtt{m})^{1/2}} \sum _c \dfrac{S(\mathtt{m}, \mathtt{n}r/d, c)}{c} \\&\quad \int \limits _{-\infty }^{\infty } \dfrac{J_{2i\tau }(4\pi \sqrt{(\mathtt{m}\mathtt{n}r/d)}/c)}{\sinh (\pi \tau )} W^+_{\tau }(d\mathtt{n}) W^-_{\tau }\Big (\dfrac{\mathtt{m}}{|\Delta |}\Big )h(\tau ) \tau \tanh (\pi \tau ) \dfrac{d\tau }{4\pi } \end{aligned} \end{aligned}$$

where h was defined in (11.5) and depends in particular on t, k and \(\Delta \). This needs to be inserted into (11.4) with \(r = f^2d\nu /(d_1 d_2 d_3^2) \leqslant K^{4\eta }\). In (11.4) we apply a smooth partition of unity to the \(\Delta \)-sum and consider a typical portion

$$\begin{aligned} \mathcal {J}^{(1)}(X, t,k, r) := \sum _{\Delta }w\Big ( \frac{|\Delta |}{X}\Big ) \mathcal {I}^{\text {off-diag,1}}(\Delta , t,k, r) \end{aligned}$$

for a smooth function w with compact support in [1, 2]. Our aim in this section is to prove the bound

$$\begin{aligned} \mathcal {J}^{(1)}(X, t,k, r) \ll X K^{1/2 - \eta } \end{aligned}$$
(13.1)

uniformly in \(k \asymp K\), \(t \leqslant K^{1/2 + \varepsilon }\),

$$\begin{aligned} X \leqslant K^{2+\varepsilon }, \quad r \leqslant K^{4\eta } \end{aligned}$$
(13.2)

and \(f, f_1, f_2, d, \nu \in \mathbb {N}\) which are implicit in the definition (11.5). Taking (13.1) for granted, we estimate (11.4) trivially to obtain a contribution of \(O(K^{\varepsilon - \eta })\), which is admissible. So it remains to show (13.1), and to this end we start with some initial discussion.

The c-sum in \(\mathcal {I}^{\text {off-diag,1}}(\Delta , t,k, r)\) is absolutely convergent, as can be seen by using the Weil bound for the Kloosterman sum and shifting the t-contour to \(\mathfrak {R}i\tau = 1/3\), say, without crossing any poles. By the power series expansion for the Bessel function [33, 8.440] we have

$$\begin{aligned} J_{2i\tau }(x) \ll _{\mathfrak {I}\tau } x^{-2\mathfrak {I}\tau }e^{\pi |\tau |} (1+|\tau |)^{-1/2}, \quad x \leqslant 1 \end{aligned}$$

and we can therefore truncate the c-sum at \(c \leqslant K^{10^6}\), say, at the cost of a very small error. Having done this, we can sacrifice holomorphicity of the integrand in the \(\tau \)-integral, and we insert a smooth partition of unity into the \(\tau \)-integral restricting to \(\tau \asymp T\), say, with

$$\begin{aligned} K^{1/2 - 2\eta } \leqslant T \leqslant K^{1/2+\varepsilon }, \end{aligned}$$
(13.3)

otherwise \(h(\tau )\) is negligible by (11.5), (9.16) and (11.2). We insert smooth partitions of unity into the \(\mathtt{n}, \mathtt{m}, c\)-sums and thereby restrict to \(\mathtt{n} \asymp N\), \(\mathtt{m} \asymp M\), \(c \asymp C\), say, where

$$\begin{aligned} N \leqslant T^{1+\varepsilon } , M \leqslant X T^{1 + \varepsilon } \end{aligned}$$
(13.4)

by (9.17) and initially \(C \leqslant K^{10^6}\). Next we want to evaluate asymptotically the \(\tau \)-integral. To this end we use Lemma 21 with the weight function \(\mathtt{h} = \mathtt{h}_{\mathtt{n}, \mathtt{m}, \Delta }\) given by

$$\begin{aligned}&W^+_{\tau }(d\mathtt{n}) W^-_{\tau }\Big (\frac{\mathtt{m}}{|\Delta |}\Big )h(\tau ) w\Big ( \frac{|\tau |}{T}\Big ) \\&\quad = W^+_{\tau }(d\mathtt{n}) W^-_{\tau }\Big (\frac{\mathtt{m}}{|\Delta |}\Big )\omega (\tau ) V_{ t}((|\Delta |f^2f_1f_2d\nu )^2; k, \tau ) w\Big ( \frac{|\tau |}{T}\Big ) \end{aligned}$$

where w is the weight function occurring in the smooth partition of unity of the \(\tau \)-integral. By (9.17), (11.2) and (9.16), the function \(\mathtt{h}\) is “flat” in all variables, i.e.

$$\begin{aligned} \frac{d^{j_1}}{d\mathtt{n}^{j_1}}\frac{d^{j_2}}{d\mathtt{m}^{j_2}}\frac{d^{j_3}}{d\Delta ^{j_3}} \frac{d^j}{dt^j}{} \mathtt{h}_{\mathtt{n}, \mathtt{m}, \Delta }(t) \ll _{\mathbf{j }} K^{-1/2} T^{-j}N^{-j_1} M^{-j_2} X^{-j_3} \end{aligned}$$

for \(k \asymp K\), \(|\Delta | \asymp X\), \(\mathtt{n} \asymp N\), \(\mathtt{m} \asymp M\) and \(\mathbf{j } \in \mathbb {N}_0^4\), uniformly in all other variables. Lemma 21a implies that we can restrict, up to a negligible error, to

$$\begin{aligned} C \leqslant \frac{\sqrt{NMr_2}}{T^2} K^{\varepsilon }, \end{aligned}$$
(13.5)

where \(r_2 = r/d\), and up to a negligible error we are left with bounding

$$\begin{aligned} \begin{aligned}&{\mathscr {J}}^{(1)}_r(X, N, M, C, T) := \frac{K^{\varepsilon }T^2}{(NM)^{3/4}(KC)^{1/2}}\sum _{r_1r_2=r} \frac{1}{(rr_1)^{1/4}} \\&\qquad \sum _{\Delta , \mathtt{n} , \mathtt{m}, c} \chi _{\Delta }(\mathtt{m}) S(\mathtt{m}, \mathtt{n} r_2, c) e\Big ( \pm 2 \frac{\sqrt{\mathtt{n} \mathtt{m} r_2}}{ c}\Big ) W\Big ( \frac{|\Delta |}{X}, \frac{\mathtt{n}}{N}, \frac{\mathtt{m}}{M}, \frac{c}{C}\Big ) \end{aligned} \end{aligned}$$
(13.6)

for a smooth function W with compact support in \([1, 2]^4\) and bounded Sobolev norms with variables XNMCT satisfying (13.2), (13.4), (13.5), (13.3), respectively.

The basic strategy is now to apply Poisson summation first in the \(\mathtt{n}\)-sum and then in the \(\mathtt{m}\)-sum in Sect. 13.2. This shortens the variables in generic ranges, so that a trivial bound turns out to be of size \(XK^{1/2 + 2\eta +\varepsilon }\). This is very close to our target (13.1). In Sect. 13.3 we will extract a character sum from this expression where the Pólya-Vinogradov inequality produces the final saving, at least in generic ranges of the variables. In order to also treat non-generic ranges where some of the variables are relatively short (and hence Poisson summation is less effective), at each step we also apply trivial bounds along with Heath-Brown’s large sieve. In particular, by Lemma 19b) we can bound (13.6) by

$$\begin{aligned} \begin{aligned} {\mathscr {J}}^{(1)}_r(X, N, M, C, T)&\ll \frac{K^{\varepsilon }T^2}{(NM)^{3/4}(KC)^{1/2}} X NMC^{3/2} \Big ( \frac{1}{X^{1/2}} + \frac{1}{M^{1/2}}\Big ) \\&= \frac{K^{\varepsilon }T^2}{ K^{1/2}} CN^{1/4} \Big (M^{1/4} X^{1/2} + \frac{X}{M^{1/4}} \Big ). \end{aligned} \end{aligned}$$
(13.7)

13.2 Poisson summation

Now we open the Kloosterman sum in (13.6) and apply Poisson summation in \(\mathtt{n}\) in residue classes modulo c. In this way we re-write \({\mathscr {J}}^{(1)}_r(X, N, M, C, T) \) as

$$\begin{aligned} \begin{aligned}&\frac{K^{\varepsilon }T^2}{(NM)^{3/4}(KC)^{1/2}}\sum _{r_1r_2 = r} \frac{1}{(rr_1)^{1/4}} \sum _{\Delta , \mathtt{m}, c} \chi _{\Delta }(\mathtt{m}) \underset{\gamma \, (\text {mod } c)}{\left. \sum \right. ^{*}}e\Big (\frac{\mathtt{m}\gamma }{c}\Big ) \sum _{\nu \, (\text {mod } c)}e\Big ( \frac{{\bar{\gamma }}\nu r_2}{ c}\Big )\\&\quad \frac{1}{c} \sum _{n \in \mathbb {Z}}e\Big (\frac{n \nu }{c}\Big ) \int \limits _{0}^{\infty } e\Big ( \pm 2 \frac{\sqrt{x \mathtt{m} r_2}}{ c}\Big ) W\Big ( \frac{|\Delta |}{X}, \frac{x}{N}, \frac{\mathtt{m}}{M}, \frac{c}{C}\Big ) e\Big ( - \frac{x n}{c}\Big ) dx. \end{aligned} \end{aligned}$$
(13.8)

We consider the character sum

$$\begin{aligned} \frac{1}{c}\underset{\gamma \, (\text {mod } c)}{\left. \sum \right. ^{*}}e\Big (\frac{\mathtt{m}\gamma }{c}\Big ) \sum _{\nu \, (\text {mod } c)}e\Big ( \frac{{\bar{\gamma }}\nu r_2}{ c}\Big )e\Big (\frac{n \nu }{c}\Big ) = \underset{\begin{array}{c} \gamma \, (\text {mod } c)\\ {\bar{\gamma }}r_2 \equiv -n\, (\text {mod } c) \end{array}}{\left. \sum \right. ^{*}}e\Big (\frac{\mathtt{m}\gamma }{c}\Big ). \end{aligned}$$
(13.9)

This is non-zero only if \((n, c) = (r_2, c)\). We write \((r_2, c) = \delta \), \(r_2 = \delta r_2'\), \(c = \delta c'\), \(n = \delta n'\) with \((n'r_2', c') = 1\) and recast (13.9) as

$$\begin{aligned} \underset{\begin{array}{c} \gamma \, (\text {mod } c)\\ \gamma \equiv -r_2'\overline{n'}\, (\text {mod } c') \end{array}}{\left. \sum \right. ^{*}}e\Big (\frac{\mathtt{m}\gamma }{c}\Big ). \end{aligned}$$

We decompose \(\delta = \delta _1 \delta _2\) with \(\delta _2\) maximal so that \((\delta _2, c') = 1\). Note that \(r_2' \bar{n'}\) is coprime to \(c'\), so the condition \((c, \gamma ) = 1\) is equivalent to \((\delta _2, \gamma ) = 1\). We factor \(c = c'\delta _1 \cdot \delta _2\) with \((c'\delta _1, \delta _2) = 1\) and apply the Chinese Remainder Theorem to see that the previous display vanishes unless \(\delta _1 \mid \mathtt{m}\), say \(\mathtt{m} = \delta _1\mathtt{m}'\), in which case it equals

$$\begin{aligned} \delta _1 R_{\delta _2}(\mathtt{m}') e\Big ( -\frac{\mathtt{m}'r_2' \overline{n' \delta _2}}{c'}\Big ) \end{aligned}$$

where R denotes the Ramanujan sum.

Next we consider the x-integral in (13.8). The phase has a unique stationary point at \(x = r_2\mathtt{m}/n^2\) if \(\text {sgn}(n) = \pm \) and no stationary point if \(\text {sgn}(n) = \mp \). If \(N \leqslant r_2\mathtt{m}/n^2 \leqslant 2N\) and \(\text {sgn}(n) = \pm \), we can apply the stationary phase lemma [11, Proposition 8.2] with \(X=1\), \(V = V_1 = Q = N\), \(Y = \sqrt{NMr_2}/C \geqslant T^2K^{-\varepsilon } \geqslant K^{1/2 - \varepsilon }\) to see that the integral is given by

$$\begin{aligned} \Big (\frac{cr_2\mathtt{m}}{|n|^3}\Big )^{1/2} e\Big ( \pm \frac{r_2\mathtt{m}}{c|n|}\Big )W_1\Big ( \frac{|\Delta |}{X}, \frac{r_2\mathtt{m}}{n^2N}, \frac{\mathtt{m}}{M}, \frac{c}{C}\Big ) \end{aligned}$$

for a smooth function \(W_1\) with compact support in \([1, 2]^4\) and bounded Sobolev norms, up to a negligible error from truncating the series in [11, (8.9)]. Otherwise we apply integration by parts in the form of [11, Lemma 8.1] with \(X = 1\), \(U = Q = N\), \(Y = R = \sqrt{NMr_2}/C\) to conclude that the integral is negligible.

Noting that with our previous notation

$$\begin{aligned} e\Big ( \pm \frac{r_2\mathtt{m}}{c|n|}\Big ) = e\Big ( \frac{d'_2\mathtt{m}' }{c'n' \delta _2}\Big ) \end{aligned}$$

for \(\text {sgn}(n) = \pm \), we can now apply the additive reciprocity formula \(e(1/ab) = e({\bar{a}}/b)e({\bar{b}}/a)\) for \((a, b) = 1\) to conclude that \({\mathscr {J}}^{(1)}_r(X, N, M, C, T) \) equals, up to a negligible error term,

$$\begin{aligned} \begin{aligned}&\frac{K^{\varepsilon }T^2}{(NM)^{3/4}(KC)^{1/2}}\sum _{r_1\delta _1\delta _2 d'_2 = r} \frac{1}{(rr_1)^{1/4}} \underset{\begin{array}{c} (c', n'r_2'\delta _2) = 1\\ \delta _1 \mid (c')^{\infty } \end{array}}{\sum _{\Delta , \mathtt{m}', c'} \sum _{\pm n' \in \mathbb {N}}} \chi _{\Delta }(\mathtt{m}'\delta _1) \delta _1 R_{\delta _2}(\mathtt{m}') e\Big ( \frac{\mathtt{m}'r_2' \overline{c'}}{n' \delta _2}\Big ) \\&\quad \Big (\frac{c'd'_2\mathtt{m}'}{\delta _2|n'|^3}\Big )^{1/2}W_1\Big ( \frac{|\Delta |}{X}, \frac{d'_2\mathtt{m}'}{\delta _2 (n')^2N}, \frac{\mathtt{m}'\delta _1}{M}, \frac{c'\delta _1\delta _2}{C}\Big ). \end{aligned} \end{aligned}$$
(13.10)

Here we recall the notation conventions from Sect. 1.5 regarding expressions \(\delta \mid c^{\infty }\) etc. For easier readability we remove all the dashes at the variables, and we define

$$\begin{aligned} W_2(x, y, z, w) = w^{1/2} y^{-3/2} z^{1/2} W_1(x, z/y^2, z, w). \end{aligned}$$

We also open the Ramanujan sum \(R_{\delta _2}(\mathtt{m}) = \sum _{\delta _3 \mid (\delta _2, \mathtt{m})} \delta _3\mu (\delta _2/\delta _3)\), write \(\delta _2 = \delta _3\delta _4\) and replace m with \(m\delta _3\). Finally we drop the ±-sign in the summation condition on n (both cases are identical). With this notation we can re-write (13.10) as

$$\begin{aligned} \begin{aligned}&\frac{K^{\varepsilon }T^2}{M K^{1/2}}\sum _{r_1\delta _1\delta _3\delta _4 r_2 = r} \frac{\delta _1^{3/4} \delta _3 \mu (\delta _4)}{(rr_1r_2 \delta _4)^{1/4} } \\&\quad \underset{\begin{array}{c} (c, nr_2\delta _3\delta _4) = 1\\ \delta _1 \mid c^{\infty } \end{array}}{\sum _{\Delta , \mathtt{m}, c, n} } \chi _{\Delta }(\mathtt{m}\delta _1\delta _3) e\Big ( \frac{\mathtt{m} r_2 {\overline{c}}}{n \delta _4}\Big ) W_2\Big ( \frac{|\Delta |}{X}, \frac{n\delta _3 \sqrt{N \delta _1\delta _4}}{\sqrt{Mr_2}}, \frac{\mathtt{m}\delta _1\delta _3}{M}, \frac{c\delta _1\delta _3\delta _4}{C}\Big ). \end{aligned} \end{aligned}$$
(13.11)

Before we continue to transform this expression, we estimate trivially with the large sieve (Lemma 19b)

$$\begin{aligned} \begin{aligned}&{\mathscr {J}}^{(1)}_r(X, N, M, C, T) \\&\quad \ll \! \frac{K^{\varepsilon }T^2}{M K^{1/2}}\sum _{r_1\delta _1\delta _3\delta _4 r_2 \!=\! r} \frac{\delta _1^{3/4}\delta _3}{(rr_1r_2\delta _4)^{1/4} } X \frac{\sqrt{Mr_2} }{\delta _3\sqrt{N\delta _1\delta _4}} \frac{M}{\delta _1\delta _3} \frac{C}{\delta _1\delta _3\delta _4} \Big ( \Big (\frac{\delta _1}{M}\Big )^{1/2}\! +\! X^{\!-\!1/2}\Big ) \\&\quad \ll \frac{K^{\varepsilon } T^2 C}{(KN)^{1/2}} (X + (XM)^{1/2}). \end{aligned} \end{aligned}$$
(13.12)

Our next goal is to apply Poisson summation in \(\mathtt{m}\) restricted to residue classes \(\delta _4 n |\Delta |\). For \(m \in \mathbb {Z}\), this leads to the character sum

$$\begin{aligned} \sum _{\mu \, (\text {mod } \delta _4 n |\Delta |)} \chi _{\Delta }(\mu ) e\Big ( \frac{\mu r_2 {\overline{c}}}{n \delta _4}\Big ) e\Big (\frac{\mu m}{\delta _4 n|\Delta |}\Big ) = \sum _{\mu \, (\text {mod } \delta _4 n |\Delta |)} \chi _{\Delta }(\mu ) e\Big ( \frac{\mu ( r_2 {\overline{c}}|\Delta | + m)}{ \delta _4n|\Delta |}\Big ) . \end{aligned}$$

We decompose both n and \(\delta _4\) according to their common divisor with \(\Delta \). We write \(n = n_1 n_2\) and \(\delta _4 = \delta _5 \delta _6\) where \(n_1\delta _5 \mid \Delta ^{\infty }\), \((n_2\delta _6, \Delta ) = 1\). We obtain by the Chinese Remainder Theorem that the above character sum equals

$$\begin{aligned} \begin{aligned}&\sum _{\mu \, (\text {mod } \delta _6 n_2)} e\Big ( \frac{\mu \overline{\delta _5 n_1|\Delta |} ( r_2 {\overline{c}}|\Delta | + m)}{n_2 \delta _6 }\Big )\sum _{\mu \, (\text {mod } \delta _5 n_1 |\Delta |)} \chi _{\Delta }(\mu ) e\Big ( \frac{\mu \overline{\delta _6n_2}( r_2 {\overline{c}}|\Delta | + m)}{ \delta _5n_1|\Delta |}\Big ). \end{aligned} \end{aligned}$$

The first sum vanishes unless \(n_2\delta _6 \mid r_2|\Delta | + m c\) in which case it equals \(n_2\delta _6\). Since \(\Delta \) is a negative fundamental discriminant, the second sum vanishes unless \(n_1\delta _5 \mid r_2|\Delta | + m c\) in which case it equals

$$\begin{aligned} i\sqrt{|\Delta |} n_1 \delta _5\chi _{\Delta }\Big ( n_2\delta _6 \frac{ r_2 {\bar{c}}|\Delta | + m}{n_1\delta _5}\Big ). \end{aligned}$$

Having this evaluation available, the Poisson summation formula transforms (13.11) into

$$\begin{aligned} \begin{aligned}&\dfrac{K^{\varepsilon }T^2}{M K^{1/2}}\sum _{r_1\delta _1\delta _3\delta _5\delta _6 r_2 = r} \dfrac{\delta _1^{3/4} \delta _3 \mu (\delta _5\delta _6)}{(rr_1r_2 \delta _5\delta _6)^{1/4} } \\&\quad \underset{\begin{array}{c} (c,n_1n_2r_2\delta _3\delta _5\delta _6) = 1\\ \delta _1 \mid c^{\infty }, n_1\delta _5 \mid \Delta ^{\infty }, (n_2 \delta _6, \Delta ) = 1\\ n_1n_2\delta _5\delta _6 \mid r_2|\Delta | + mc \end{array}}{\sum _{\Delta , c, n_1, n_2} \sum _{ m\in \mathbb {Z}}} \chi _{\Delta }( \delta _1\delta _3) \dfrac{\chi _{\Delta }\Big ( n_2\delta _6 \dfrac{ r_2 {\bar{c}}|\Delta | + m}{n_1\delta _5}\Big )}{ |\Delta |^{1/2}} \\&\quad \int \limits _0^{\infty } W_2\Big ( \dfrac{|\Delta |}{X}, \frac{n_1n_2 \delta _3\sqrt{N \delta _1 \delta _5\delta _6}}{\sqrt{Mr_2}}, \dfrac{x\delta _1\delta _3}{M}, \dfrac{c\delta _1\delta _3\delta _5\delta _6}{C}\Big ) e\Big (- \dfrac{mx}{n_1n_2\delta _5\delta _6 |\Delta |}\Big )dx, \end{aligned} \end{aligned}$$
(13.13)

up to a factor i. The above integral is just the Fourier transform of \(W_2\) with respect to the third variable which we write as

$$\begin{aligned} \frac{M}{\delta _1\delta _3}W_3\Big ( \frac{|\Delta |}{X}, \frac{n_1n_2 \delta _3\sqrt{N \delta _1\delta _5\delta _6}}{\sqrt{Mr_2}}, \frac{mM }{n_1n_2\delta _5\delta _6 |\Delta |\delta _1\delta _3}, \frac{c\delta _1\delta _3\delta _5\delta _6}{C}\Big ) . \end{aligned}$$

Defining \(W_4(x, y, z, w) = W_3(x, y, z/(xy), w)\) we recast the previous display as

$$\begin{aligned} \frac{M}{\delta _1\delta _3}W_4\Big ( \frac{|\Delta |}{X}, \frac{n_1n_2\delta _3 \sqrt{N \delta _1\delta _5\delta _6}}{\sqrt{Mr_2}}, \frac{m\sqrt{NM } }{ (r_2\delta _1 \delta _5\delta _6 )^{1/2}X}, \frac{c\delta _1\delta _3\delta _5\delta _6}{C}\Big ) . \end{aligned}$$

The function \(W_4\) is compactly supported in the first, second and fourth variable and rapidly decaying in the third. We first estimate the \(m=0\) contribution to be

$$\begin{aligned} \begin{aligned}&\ll \frac{K^{\varepsilon }T^2}{M K^{1/2}}\sum _{r_1\delta _1\delta _3\delta _5\delta _6 r_2 = r} \frac{\delta _1^{3/4} \delta _3 }{(rr_1r_2 \delta _5\delta _6)^{1/4} } \frac{M}{\sqrt{X}\delta _1\delta _3} X \frac{C}{\delta _1\delta _3\delta _5\delta _6} \\&\quad \ll K^{\varepsilon } \frac{X^{1/2}CT^2}{K^{1/2} } \ll K^{\varepsilon } \frac{(XNM)^{1/2}}{K^{1/2} } \ll XK^{\varepsilon } \end{aligned} \end{aligned}$$

by (13.5), (13.4), (13.2), (13.3) and a divisor estimate for \(n_1n_2\). This is clearly admissible for (13.1), so from now on we assume \(m\not = 0\). By the same argument, we obtain for the \(m \not = 0\) contribution the bound

$$\begin{aligned} \begin{aligned}&\frac{K^{\varepsilon }T^2}{M K^{1/2}}\sum _{r_1\delta _1\delta _3\delta _5\delta _6 r_2 = r} \frac{\delta _1^{3/4} \delta _3 }{(rr_1r_2 \delta _5\delta _6)^{1/4} } \frac{M}{\sqrt{X}\delta _1\delta _3} X \frac{C}{\delta _1\delta _3\delta _5\delta _6} \frac{(r_2\delta _1 \delta _5\delta _6 )^{1/2}X}{\sqrt{NM } } \\&\quad \ll K^{\varepsilon } \frac{X^{3/2}CT^2}{(MNK)^{1/2} }. \end{aligned} \end{aligned}$$
(13.14)

By (13.5) and (13.2), this is only a factor \(K^{3\eta + \varepsilon }\) away from our target (13.1), so a very small additional saving suffices to win. For easier readability we consider only the case \(m > 0\), the other case being entirely analogous.

13.3 The endgame

Up until now we have not touched the long \(\Delta \)-sum, which we will now use to obtain some additional saving. Before we do this, we must exclude the case that C is very small. To this end we combine (13.14) and (13.12) to obtain

$$\begin{aligned} {\mathscr {J}}^{(1)}_r(X, N, M, C, T)\ll K^{\varepsilon } \frac{T^2C}{(NK)^{1/2}}\min \Big (\frac{X^{3/2}}{M^{1/2}} , X + (XM)^{1/2}\Big ) \ll K^{\varepsilon } \frac{T^2C}{(NK)^{1/2}}X. \end{aligned}$$

Similarly we can combine (13.14) and (13.7) to obtain

$$\begin{aligned} \begin{aligned} {\mathscr {J}}^{(1)}_r(X, N, M, C, T)&\ll K^{\varepsilon } \frac{T^2C}{K^{1/2}}\min \Big ( \frac{X^{3/2}}{(MN)^{1/2}}, (MN)^{1/4} X^{1/2} + \Big (\frac{N}{M}\Big )^{1/4} X\Big ) \\&\leqslant K^{\varepsilon } \frac{T^2CX}{K^{1/2}} \Big ( \frac{1}{(MN)^{1/8}}+ \Big (\frac{N}{M}\Big )^{1/4} \Big ) \\&\ll K^{\varepsilon } \frac{T^2CX}{K^{1/2}} \Big ( \frac{r^{1/8}}{C^{1/4}T^{1/2}}+ \frac{r^{1/4}N^{1/2}}{C^{1/2}T}\Big ) \end{aligned} \end{aligned}$$

using (13.5). Combining the previous two bounds we finally obtain

$$\begin{aligned} {\mathscr {J}}^{(1)}_r(X, N, M, C, T) \ll K^{\varepsilon } \frac{T^2CX}{K^{1/2}} \cdot \frac{r^{1/8}}{C^{1/4}T^{1/2}} \ll XK^{\frac{1}{4} + \frac{1}{2}\eta + \varepsilon } C^{\frac{3}{4}} \end{aligned}$$

by (13.3) and (13.2) which meets our target (13.1) unless

$$\begin{aligned} C \geqslant K^{1/3 - 3\eta } \end{aligned}$$

which we assume from now on. We recall that c is automatically coprime to \(n_1n_2 r_2\delta _3\delta _5\delta _6\). For fixed \(k \in \mathbb {N}\) let \({\mathscr {S}}(k) = \{k_1 x^2 : k_1 \mid k, x \in \mathbb {N}\}\) be the set of square classes of all divisors of k. From (13.13) we remove all \(c\in {\mathscr {S}}(2r_1\delta _1m)\). Since C is large, the \(O(K^{\varepsilon })\) square classes are only a thin subset of all c and by the same computation as in (13.14), they contribute no more than

$$\begin{aligned} \begin{aligned}&\ll K^{\varepsilon } \frac{X^{3/2}C^{1/2}T^2}{(MNK)^{1/2} } \ll r^{1/2}XK^{1/2 + 2\eta + \varepsilon } C^{-1/2} \ll XK^{1/3 + 6\eta } \end{aligned} \end{aligned}$$
(13.15)

to\( {\mathscr {J}}^{(1)}_r(X, N, M, C, T) \) which for \(\eta < 1/40\) is admissible.

With this we return to (13.13) and explain the idea how to obtain additional savings. Ignoring (for the purpose of these heuristic remarks) the secondary variables \(\delta _1, \delta _3, \delta _5, \delta _6, r_2, n_1\), we have to sum

$$\begin{aligned} \sum _{n_2 \mid |\Delta | + mc} \chi _{\Delta }(n_2m) \end{aligned}$$

We \(|\Delta | + m c = n_2 s\) for \(s \in \mathbb {N}\) and rewrite the sum to be taken over \(m, s, c, n_2\) where now \(|\Delta |\) is determined by the other variables. Assuming also for simplicity that \(n_2, m\) are odd, we obtain a sum over

$$\begin{aligned} \Big ( \frac{-sn_2 + mc}{n_2m}\Big )= & {} \Big ( \frac{-sn_2 + mc}{n_2 }\Big ) \Big ( \frac{-sn_2 + mc}{m }\Big ) = \Big ( \frac{ mc}{n_2 }\Big ) \Big ( \frac{-sn_2 }{m }\Big ) \\= & {} \Big ( \frac{ m}{n_2 }\Big )\Big ( \frac{n_2 }{m }\Big ) \cdot \Big ( \frac{ c}{n_2 }\Big ) \Big ( \frac{-s }{m }\Big ) \end{aligned}$$

where \(-n_2s +mc\) is essentially restricted to squarefree numbers. By quadratic reciprocity, the first two factors are essentially constant. Since c is not a square, the map \(n_2 \mapsto (\frac{c}{n_2})\) is a non-trivial character, and since typically the length of \(n_2\) is much longer than the length of c, the \(n_2\)-sum has some saving from the Pólya-Vinogradov inequality (here we also need to deal with the squarefree condition). We now make this precise. For clarity, we repeat (13.13) with the small amendments we have made so far:

$$\begin{aligned} \begin{aligned}&\dfrac{K^{\varepsilon }T^2}{(XK)^{1/2}}\sum _{r_1\delta _1\delta _3\delta _5\delta _6 r_2 = r}\dfrac{ \ \mu (\delta _5\delta _6)}{(rr_1r_2 \delta _1\delta _5\delta _6)^{1/4} } \\&\quad \underset{\begin{array}{c} (c,n_1n_2r_2\delta _3\delta _5\delta _6) = 1\\ \delta _1 \mid c^{\infty },n_1\delta _5 \mid \Delta ^{\infty }, (n_2 \delta _6, \Delta ) = 1\\ n_1n_2\delta _5\delta _6 \mid r_2|\Delta | + mc \end{array}}{\sum _{\Delta , n_1,n_2, m} \sum _{ c\not \in {\mathscr {S}}(2r_1\delta _1m)} }\chi _{\Delta }\Big ( \delta _1\delta _3 n_2\delta _6 \frac{ r_2 {\bar{c}}|\Delta | + m}{n_1\delta _5}\Big ) \\&\quad W_5\Big ( \dfrac{|\Delta |}{X}, \dfrac{n_1n_2 \delta _3\sqrt{N \delta _1\delta _5\delta _6}}{\sqrt{Mr_2}}, \dfrac{m\sqrt{NM } }{ (r_2\delta _1 \delta _5\delta _6 )^{1/2}X}, \dfrac{c\delta _1\delta _3\delta _5\delta _6}{C}\Big ) \end{aligned} \end{aligned}$$
(13.16)

where \(W_5(x, y, z, w) = x^{-1/2} W_4(x, y, z, w)\). We define s through the equation

$$\begin{aligned} n_1n_2 \delta _5\delta _6 s = r_2|\Delta | + mc. \end{aligned}$$
(13.17)

Note that, up to a negligible error,

$$\begin{aligned} m c \ll K^{\varepsilon }\frac{CX r_2 ^{1/2}}{\sqrt{NM\delta _1\delta _5\delta _6}\delta _3 } \ll K^{\varepsilon } \frac{r_2 X}{T^2} \end{aligned}$$
(13.18)

by (13.5), so that by (13.3) we conclude that mc is substantially smaller than \(| r_2\Delta |\). In particular, \(n_1n_2 \delta _5\delta _6 s \asymp r_2 X\), so that

$$\begin{aligned} s \asymp \frac{ X\delta _3 \sqrt{N \delta _1r_2}}{\sqrt{M\delta _5\delta _6} }. \end{aligned}$$
(13.19)

We first argue that we can truncate the \(n_1\)-sum in (13.13) at \(n_1 \leqslant K^{4\eta }\). Indeed, since \((n_1, c) = 1\), but \(n_1 \mid \Delta ^{\infty }\), the squarefree kernel \(\text {rad}(n_1)\) must divide m. Summing trivially over \(n_1, n_2, s, c, m\) in (13.13) as in (13.14), the portion \(n_1 \geqslant Y\) contributes at most

$$\begin{aligned} \begin{aligned}&K^{\varepsilon } \frac{T^2}{(XK)^{1/2}} \sum _{r_1\delta _1\delta _3\delta _5\delta _6 r_2 = r} \frac{ 1 }{(rr_1r_2 \delta _1\delta _5\delta _6)^{1/4} } \\&\quad \times \sum _{n_1 \geqslant Y} \frac{\sqrt{Mr_2}}{\delta _3\sqrt{N\delta _1\delta _5\delta _6}n_1} \frac{ X\delta _3 \sqrt{N \delta _1r_2}}{\sqrt{M\delta _5\delta _6} } \frac{C}{\delta _1\delta _3\delta _5\delta _6} \frac{X(r_2\delta _1\delta _5\delta _6)^{1/2}}{ \sqrt{NM } \text {rad}(n_1)} \\&\quad \ll K^{\varepsilon } \frac{X^{3/2} CT^2}{(MNK)^{1/2} Y^{1-\varepsilon }} \end{aligned} \end{aligned}$$
(13.20)

by applying Rankin’s trick and using that \(\sum _n \text {rad}(n)^{-1} n^{-\sigma }\) is absolutely convergent for \(\sigma > 0\). If \(Y \geqslant K^{4\eta }\), this is \(\ll X K^{1/2-2\eta + \varepsilon }\) by (13.5) and (13.2), hence admissible for (13.1). Having truncated the \(n_1\)-sum, we decompose \(\Delta = \Delta _1\Delta _2\) into two fundamental discriminants of suitable signs where \((\Delta _2, 2n_1\delta _5) = 1\) and \(\Delta _1 \mid 8n_1 \delta _5 \), in particular \(|\Delta _1| \leqslant 8K^{8\eta }\) and \((\Delta _1, cn_2\delta _6) = 1\). With this notation and recalling (13.17) we can write

$$\begin{aligned} \chi _{\Delta }\Big ( \delta _1\delta _3 n_2\delta _6 \frac{ r_2 {\bar{c}}|\Delta | + m}{n_1\delta _5}\Big ) = \chi _{\Delta _1}(\delta _1\delta _3cs) \chi _{\Delta _2}(\delta _1\delta _3\delta _5\delta _6 n_1n_2m). \end{aligned}$$

Next we make \(n_2m\) coprime to \(2r_2\Delta _1\) by factoring \(n_2 = n_2'n_2''\) and \(m=m'm''\) with \((n_2'm', 2r_2\Delta _1) = 1\), \(n_2''m'' \mid (2r_2\Delta _1)^{\infty } \mid (2r_2n_1\delta _5)^{\infty }\) so that the previous display equals

$$\begin{aligned} \begin{aligned}&\chi _{\Delta _1}(\delta _1\delta _3cs) \chi _{\Delta _2}(\delta _1\delta _3\delta _5\delta _6 n_1 n_2''m'') \chi _{ (n_1n_2\delta _5\delta _6 s - mc)( r_2|\Delta _1|)} (n_2'm') \\&\quad = \chi _{\Delta _1}(\delta _1\delta _3cs) \chi _{\Delta _2}(\delta _1\delta _3\delta _5\delta _6 n_1 n_2''m'') \Big (\frac{- r_2|\Delta _1|mc}{n_2'}\Big ) \Big (\frac{ r_2|\Delta _1|n_1n_2\delta _5\delta _6 s}{m'}\Big )\\&\quad = \chi _{\Delta _1}(\delta _1\delta _3cs) \chi _{\Delta _2}(\delta _1\delta _3\delta _5\delta _6 n_1 n_2''m'')\\&\qquad \Big (\frac{ r_2|\Delta _1|n_1n''_2\delta _5\delta _6 s}{m'}\Big ) \Big (\frac{- r_2|\Delta _1|m'' }{n_2'}\Big )\Big (\frac{m'}{n_2'}\Big ) \Big (\frac{n_2'}{m'}\Big ) \Big (\frac{c}{n_2'}\Big ). \end{aligned} \end{aligned}$$
(13.21)

By a computation similar to (13.20), this time using that

$$\begin{aligned} \sum _{\begin{array}{c} a \mid b^{\infty }\\ a \leqslant X \end{array}} 1 \ll (bX)^{\varepsilon } \end{aligned}$$

for \(X \geqslant 1\), \(b \in \mathbb {N}\) (which follows in the same way by Rankin’s trick), we can assume \(n_2'', m'' \leqslant K^{4\eta }\), the remaining portion to (13.13) being \(\ll XK^{1/2 - 2\eta + \varepsilon }\). We are left with short (i.e. \(\ll K^{4\eta }\)) variables

$$\begin{aligned} r_1, \delta _1, \delta _3, \delta _5, \delta _6, r_2, n_1, n_2'', m'', \Delta _1 \end{aligned}$$
(13.22)

and potentially long variables

$$\begin{aligned} \Delta _2, c, n_2', m', s \end{aligned}$$

subject to \(c \not \in {\mathscr {S}}(2r_1\delta _1m'm'')\) as well as

$$\begin{aligned} \begin{aligned}&(c, n_1n_2'n_2'' r_2 \delta _3\delta _5\delta _6) = 1, \quad \delta _1 \mid c^{\infty } , \quad n_1\delta _5 \mid (\Delta _1\Delta _2)^{\infty }, \\&\quad (n_2'n_2'' \delta _6, \Delta _1\Delta _2) = 1,\quad \Delta _1 \mid 8n_1\delta _5,\\&(\Delta _2, 2n_1\delta _5) = 1, \quad (n_2'm', 2r_2\Delta _1) = 1, \quad n_2''m'' \mid (2r_2\Delta _1)^{\infty }, \\&\quad n_1n_2'n_2'' \delta _5\delta _6s = r_2 \Delta _1\Delta _2 + mc. \end{aligned} \end{aligned}$$

We can eliminate \(\Delta _2\) from the last equation, so that a congruence

$$\begin{aligned} n_1n_2'n_2'' \delta _5\delta _6s = mc \, (\text {mod } r_2\Delta _1) \end{aligned}$$

remains. Then the conditions \((\Delta _2, 2n_1\delta _5) = (n_2'n_2''\delta _6, \Delta _2) = 1\) are re-phrased as

$$\begin{aligned} (n_1n_2'n_2'' \delta _5\delta _6s - mc , 2r_2n_1\delta _5n_2' n_2'' \delta _6) = r_2 \end{aligned}$$

which is equivalent to

$$\begin{aligned} (n_1n_2'n_2'' \delta _5\delta _6, mc) = r_2', \quad (2r_2, n_1n_2'n_2'' \delta _5\delta _6s - mc) = r_2'', \quad r_2'r_2'' = r_2. \end{aligned}$$

The condition \(n_1\delta _5 \mid (\Delta _1\Delta _2)^{\infty }\) reads

$$\begin{aligned} \text {rad}(n_1\delta _5) \mid \frac{n_1n_2'n_2'' \delta _5\delta _6s - mc}{r_2}. \end{aligned}$$

All of these conditions on \(n_2'\) can be detected by congruences modulo “short” variables in (13.22) (and some powers of 2) as well as \((n_2', m) = 1\). Finally we need to remember that \(\Delta _1\Delta _2\) is a fundamental discriminant. To this end we split into residue classes \(\Delta _1\Delta _2 \equiv 1, 5, 8, 9, 12, 13\) (mod 16) and insert a factor \(\mu ^2((n_1n_2'n_2'' \delta _5\delta _6s - mc)/(\alpha r_2))\) with \(\alpha \in \{1, 4\}\). We use the convolution formula

$$\begin{aligned} \mu ^2\Big (\frac{n_1n_2'n_2'' \delta _5\delta _6s - mc}{\alpha r_2}\Big )= \sum _{y^2 \mid \frac{n_1n_2'n_2'' \delta _5\delta _6s - mc}{\alpha r_2}} \mu (y), \end{aligned}$$

and insert all of this back into (13.16). We claim that we can restrict \(y \leqslant K^{A\eta }\) for some constant A. Indeed, summing over all short variables, as well as \( c, m'\), we get a congruence for \(n_2's\) modulo \(y^2\), so that the portion \(y > Y\) contributes at most

$$\begin{aligned} K^{O(\eta )} \sum _{y \geqslant Y}\frac{T^2}{(XK)^{1/2}} C \frac{X}{\sqrt{NM}} \frac{X}{y^2} \ll \frac{XK^{1/2+ O(\eta )}}{Y} \end{aligned}$$

which is acceptable if \(Y = K^{A\eta }\) for A sufficiently large. Note that (13.18) implies that \(n_1n_2'n_2'' \delta _5\delta _6s - mc \) never vanishes, so there is no “\(1+\)” in the congruence count. In addition, for fixed y we also remove all \(c \in {\mathscr {S}}(y^2)\) at the cost of an error \(XK^{1/3+ O(\eta )}\) as in (13.15).

We are finally ready to return to (13.21) and split the sum over \(n_2'\) into residue classes modulo \(\nu \) modulo \(H := 32 r_1\delta _1\delta _3\delta _5\delta _6r_2n_1n_2''m''\Delta _1 y^2 = K^{O(\eta )}\). By assumption, c is not in a square class of any divisor of H. Thus we consider

$$\begin{aligned} \sum _{\begin{array}{c} n'_2 \equiv \nu \, (\text {mod } H)\\ (n'_2, m') = 1 \end{array}}\Big (\frac{c}{n_2'}\Big )W\Big (\frac{n'_2}{R}\Big ) \end{aligned}$$

for \(\nu \) odd, \(c \ll C\) and \(R \ll \sqrt{M/N} K^{O(\eta )}\). We can detect the congruence condition by characters, none of which conspires with \(n_2' \mapsto (\frac{c}{n_2'})\) to become the trivial character. By the Pólya-Vinogradov inequality, we can bound the previous display by \(C^{1/2} K^{O(\eta )}\), and by trivial estimates over \(c, m', s\) and the present estimate for the sum over \(n_2'\) we obtain the final bound

$$\begin{aligned} K^{O(\eta )} \frac{T^2}{(XK)^{1/2}} C \frac{X}{\sqrt{NM}}\frac{X\sqrt{N}}{\sqrt{M}} C^{1/2}\ll & {} K^{O(\eta )} \frac{N^{3/4} X^{3/2}}{K^{1/2}TM^{1/4}} \\\ll & {} K^{O(\eta )}\frac{X^{3/2}}{K^{1/2}T^{1/4}} \ll XK^{3/8+ O(\eta )} \end{aligned}$$

by (13.5), (13.4), (13.2) and (13.3). For sufficiently small \(\eta \) this is in agreement with (13.1) and completes the analysis of the first off-diagonal term in (11.6).

13.4 The second off-diagonal term

The analysis of the second off-diagonal term in (3.5) is structurally very similar (although the numerology is a little different), so we can be brief. Here we need to consider

$$\begin{aligned} \begin{aligned}&\mathcal {I}^{\text {off-diag,2}}(\Delta , t,k, r):= \frac{16}{\pi } \sum _{d \mid r} \sum _{\mathtt{n},\mathtt{m}} \frac{ \chi _{\Delta }(\mathtt{m}) }{(d\mathtt{n}{} \mathtt{m})^{1/2}} \sum _c \frac{S(\mathtt{m}, \mathtt{n}r/d, c)}{c} \\&\int _{-\infty }^{\infty } K_{2i\tau }(4\pi \sqrt{(\mathtt{m}\mathtt{n}r/d)}/c) \sinh (\pi \tau ) W^+_{\tau }(d\mathtt{n}) W^-_{\tau }\Big (\frac{\mathtt{m}}{|\Delta |}\Big )h(\tau ) \tau \frac{d\tau }{4\pi } \end{aligned} \end{aligned}$$

with h as in (11.5). This needs to be inserted into (11.4) with \(r = f^2d\nu /(d_1 d_2 d_3^2) \leqslant K^{4\eta }\). Under the same size restrictions (13.2) as before we want to show that

$$\begin{aligned} \mathcal {J}^{(2)}(X, t,k, r) := \sum _{\Delta }w\Big ( \frac{|\Delta |}{X}\Big ) \mathcal {I}^{\text {off-diag,2}}(\Delta , t,k, r) \ll XK^{1/2 - \eta }. \end{aligned}$$

As before we first use holomorphicity to ensure absolute convergence of the c-sum and obtain a very coarse truncation. Then we apply smooth partitions of unity restricting to \(\tau \asymp T\) satisfying (13.3), \(n \asymp N\), \(m \asymp M\) satisfying (13.4) and \(c\asymp C\). This time we use Lemma 21b to conclude that

$$\begin{aligned} C \leqslant K^{\varepsilon } \frac{\sqrt{NM}}{T}, \end{aligned}$$
(13.23)

and by an analogue of (13.6) we need to bound the quantity

$$\begin{aligned} \begin{aligned}&{\mathscr {J}}^{(2)}_r(X, N, M, C, T) \\&\quad := \frac{K^{\varepsilon }T}{(NMK)^{1/2}C}\sum _{r_1r_2=r} \frac{1}{(rr_1)^{1/4}} \sum _{\Delta , \mathtt{n} , \mathtt{m}, c} \chi _{\Delta }(\mathtt{m}) S(\mathtt{m}, \mathtt{n} r_2, c) W\Big ( \frac{|\Delta |}{X}, \frac{\mathtt{n}}{N}, \frac{\mathtt{m}}{M}, \frac{c}{C}\Big ) \end{aligned} \end{aligned}$$

where W satisfies the same properties as in (13.6). The trivial bound using the large sieve (Lemma 19) is now

$$\begin{aligned} \begin{aligned} {\mathscr {J}}^{(2)}_r(X, N, M, C, T)&\ll \frac{K^{\varepsilon }T}{(NMK)^{1/2}C} XNMC^{3/2}\Big ( \frac{1}{X^{1/2}} + \frac{1}{M^{1/2}}\Big )\\&= \frac{K^{\varepsilon }T}{ K^{1/2}} (XNC)^{1/2} ( X^{1/2} + M^{1/2} ). \end{aligned} \end{aligned}$$
(13.24)

Next we apply Poisson summation in \(\mathtt{n}\) in residue classes modulo c which is simpler than before because there is no exponential \(e(\pm 2\sqrt{\mathtt{n}{} \mathtt{m}r_2}/c)\). This transforms \( {\mathscr {J}}^{(2)}_r(X, N, M, C, T)\) into

$$\begin{aligned} \begin{aligned}&\frac{K^{\varepsilon }T}{(NMK)^{1/2}C}\sum _{r_1r_2=r} \frac{1}{(rr_1)^{1/4}} \sum _{\Delta , \mathtt{m}, c} \chi _{\Delta }(\mathtt{m}) N \\&\quad \sum _{n \in \mathbb {Z}} \underset{\begin{array}{c} \gamma \, (\text {mod }c)\\ r_2{\bar{\gamma }} \equiv -n \, (\text {mod } c) \end{array}}{\left. \sum \right. ^{*}} e\Big ( \frac{\mathtt{m} \gamma }{c}\Big ) W_1\Big ( \frac{|\Delta |}{X}, \frac{nN}{C}, \frac{\mathtt{m}}{M}, \frac{c}{C}\Big ) \end{aligned} \end{aligned}$$

for a weight function \(W_1\) that is compactly supported in the first, third and fourth variable and rapidly decaying in the second. This term contains the same character sum as in (13.9). By the same manipulation we obtain

$$\begin{aligned} \begin{aligned} {\mathscr {J}}^{(2)}_r(X, N, M, C, T) =&\frac{K^{\varepsilon }TN^{1/2}}{(MK)^{1/2}C}\sum _{r_1\delta _1\delta _3\delta _4 r_2 = r} \frac{(\delta _1 \delta _3)^{3/4}\mu (\delta _4)}{(rr_1r_2 \delta _4)^{1/4} } \\&\underset{\begin{array}{c} (c, nr_2\delta _3\delta _4) = 1\\ \delta _1 \mid c^{\infty } \end{array}}{\sum _{\Delta , \mathtt{m}, c} \sum _{n\in \mathbb {Z}}} \chi _{\Delta }(\mathtt{m}\delta _1\delta _3) e\Big ( -\frac{\mathtt{m}r_2 \overline{n\delta _2}}{c}\Big )\\&W_1\Big ( \frac{|\Delta |}{X}, \frac{n\delta _1\delta _2 N}{C}, \frac{\mathtt{m}\delta _1}{M}, \frac{c\delta _1\delta _2}{C}\Big ). \end{aligned} \end{aligned}$$
(13.25)

This is arithmetically analogous to (13.11) except that the roles of \(\delta _2n\) and c are reversed in the exponential. This makes good sense since in generic ranges we have \(c \asymp K^{1/2}\), \( n \asymp K\) in (13.11), but \(c \asymp K\), \(n \asymp K^{1/2}\) in (13.25). The large sieve now gives the bound

$$\begin{aligned} {\mathscr {J}}^{(2)}_r(X, N, M, C, T)\ll & {} \frac{K^{\varepsilon }TN^{1/2}}{(MK)^{1/2}C} X\frac{C}{N}MC\Big (\frac{1}{\sqrt{X}} + \frac{1}{\sqrt{M}}\Big )\nonumber \\= & {} \frac{K^{\varepsilon }TX^{1/2} C }{(NK)^{1/2}} ( \sqrt{X} +\sqrt{M} ). \end{aligned}$$
(13.26)

Next we apply Poisson summation in \(\mathtt{m}\) in residue classes modulo \(|\Delta | c\). In the character sum

$$\begin{aligned} \sum _{\mu \, (\text {mod }c|\Delta |)} \chi _{\Delta }(\mu ) e\Big (\frac{\mu (m- r_2\overline{n\delta _2}|\Delta |)}{c|\Delta |}\Big ) \end{aligned}$$

we decompose \(c = c_1 c_2\) where \(c_1 \mid \Delta ^{\infty }\), \((c_2, \Delta ) = 1\). The character sum vanishes unless \(c_1c_2 \mid mn\delta _2 - r_2 |\Delta |\) in which case it equals

$$\begin{aligned} i \sqrt{|\Delta |} c_1 \chi _{\Delta }\Big (c_2 \frac{m- r_2 \overline{n\delta _2}|\Delta |}{c_1}\Big ). \end{aligned}$$

Estimating trivially at this point yields

$$\begin{aligned} {\mathscr {J}}^{(2)}_r(X, N, M, C, T)\ll & {} K^{\varepsilon }\frac{T(MN)^{1/2}C^2 X^2 }{C(XK)^{1/2}MN} = \frac{X^{3/2}CT}{(KNM)^{1/2}} \nonumber \\\ll & {} X K^{1/2 +2 \eta + \varepsilon } \end{aligned}$$
(13.27)

by (13.23) and (13.2), matching the bound in (13.14). With the roles of c and n reversed, we now want to make sure that \(n \ll C(N\delta _1\delta _2)^{-1}\) is large enough. By the trivial bound (13.27) we can assume that \(n \geqslant C(N\delta _1\delta _2)^{-1} K^{-4\eta }\). Now combining (13.27) and (13.24) we obtain

$$\begin{aligned} {\mathscr {J}}^{(2)}_r(X, N, M, C, T)\ll & {} K^{\varepsilon } \frac{(CX)^{1/2} T }{K^{1/2} }\min \Big (\frac{XC^{1/2}}{(NM)^{1/2}} , (NX)^{1/2} + (NM)^{1/2}\Big ) \\\leqslant & {} K^{\varepsilon } \frac{TXC^{1/2}}{K^{1/2}}(N^{1/2} + C^{1/4}). \end{aligned}$$

Combining (13.27) and (13.26) we obtain

$$\begin{aligned} {\mathscr {J}}^{(2)}_r(X, N, M, C, T) \ll K^{\varepsilon } \frac{CTX^{1/2}}{(MNK)^{1/2}}\min (\sqrt{MX} + M, X)\ll K^{\varepsilon } \frac{CTX }{(NK)^{1/2}} . \end{aligned}$$

Combining the previous two bounds, we obtain

$$\begin{aligned} {\mathscr {J}}^{(2)}_r(X, N, M, C, T) \ll K^{\varepsilon }\frac{TXC^{3/4}}{K^{1/2}} = K^{\varepsilon }\frac{TXN^{3/4}}{K^{1/2}} \Big ( \frac{C}{N}\Big )^{3/4} \ll XK^{1/4+\varepsilon } \Big (\frac{C}{N}\Big )^{3/4} \end{aligned}$$

by (13.4) and (13.3). This is acceptable unless

$$\begin{aligned} C/N \geqslant K^{1/3 - 2\eta } \quad \text {and} \quad C \geqslant K^{2/3 - 2\eta } \end{aligned}$$

which we assume from now on, so that in particular \(n \gg C(N\delta _1\delta _2)K^{-4\eta } \gg N^{1/3 -10\eta }\). By the same argument as in the previous subsection we can now extract certain square classes in the n-sum and then save from the Pólya-Vinogradov inequality. In effect, we replace the factor C from a trivial bound of the \(c_2\)-sum by a factor \( K^{O(\eta )}\sqrt{N/C}\) of the square root of the conductor of \(c_2 \mapsto (\frac{n}{c_2})\). This leads to the final bound

$$\begin{aligned} {\mathscr {J}}^{(2)}_r(X, N, M, C, T) \ll K^{O(\eta )} \frac{X^{3/2} T \sqrt{N/C}}{(KNM)^{1/2}} \leqslant K^{O(\eta )} \frac{X^{3/2} T }{K^{1/2}C^{1/2}} \ll XK^{1/6 +O(\eta )} \end{aligned}$$

by (13.2), (13.3) and our assumption \(C \geqslant K^{2/3 - 2\eta }\). This is in agreement with (13.1) and completes the analysis of the the second diagonal off-diagonal term, hence the analysis of the complete diagonal term.

14 The off-diagonal term

14.1 Initial steps

We return to (11.3) and analyze the off-diagonal term in Lemma 6 applied to the h-sum. Here we are only interested in upper bounds, so dropping all numerical constants it suffices to estimate

$$\begin{aligned} \begin{aligned} \frac{1}{ K^2}&\sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \sum _{\begin{array}{c} (n, m) = 1\\ n, m \leqslant K^{\eta } \end{array}} \frac{ \mu (n)\mu ^2(m)}{n^{3/2}m^{3}} \int \limits _{-\infty }^{\infty } \int \limits ^{*}_{\Lambda _{\text { ev}}} \omega (t_\mathtt{u}) \sum _{f_1, f_2, D_1, D_2} \\&\sum _{\begin{array}{c} d_1 \mid d_2 \mid n\\ (d_1d_2)^2 \mid n^2D_2 \end{array}} \left( \frac{d_1}{d_2} \right) ^{1/2} \chi _{ D_2}\Big (\frac{d_2}{d_1}\Big ) \frac{ P(D_1; \mathtt{u})\overline{P(D_2; \mathtt{u})}}{f_1f_2 |D_1D_2|^{3/4}} \Big (\frac{|D_2|f_2^2}{|D_1|f_1^2}\Big )^{it} i^k\\&\sum _c \frac{K_{\kappa }^+(|D_1|, |D_2|n^2/(d_1d_2)^2, c)}{c} J_{k-3/2}\Big ( \frac{ 4\pi \sqrt{|D_1D_2|}n}{cd_1d_2}\Big )\\&V_{t}(|D_1D_2|(f_1f_2)^2; k, t_\mathtt{u}) d\mathtt{u} \, dt, \end{aligned} \end{aligned}$$

and our target bound is \(K^{-\eta }\). We recall that \(V_t(x, k, \tau )\) was defined in (6.7) and besides the decay properties it is important to note that \(V_t(x, k, \tau )\) is holomorphic in, say, \(|\mathfrak {I}\tau | \leqslant 1\). Since we want to apply the trace formula (Theorem 18) to the spectral sum later, we must not destroy holomorphicity in the third variable.

As in Sect. 11 we write \(d_2 = d_1\delta \), \(n = d_1\delta \nu \). Then \(d_1^2 \mid \nu ^2 D_2\) and \(d_1^2 \mid D_2\) since n is squarefree. Again we write \(d_1 = d\) and \(D_2 d^2\) in place of \(D_2\) and bound the preceding display as

$$\begin{aligned} \begin{aligned}&\frac{1}{ K^2} \sum _{ d\delta \nu , m \leqslant K^{\eta }} \frac{ \mu ^2(d\delta \nu m) }{d^3 \delta ^2 \nu ^{3/2} m^3 }\Big | \sum _{k \in 2\mathbb {N}} W\left( \frac{k}{K}\right) \int \limits _{-\infty }^{\infty } \int \limits ^{*}_{\Lambda _{\text { ev}}} \omega (t_\mathtt{u}) \\&\quad \sum _{f_1, f_2, D_1, D_2} \frac{\chi _{D_2}(\delta ) P(D_1; \mathtt{u})\overline{P(D_2d^2; \mathtt{u})}}{f_1f_2 |D_1D_2|^{3/4}} \Big (\frac{|D_2|(df_2)^2}{|D_1| f_1^2}\Big )^{it} i^k\sum _c \frac{K_{3/2}^+(|D_1|, |D_2|\nu ^2 , c)}{c} \\&\quad J_{k-3/2} \Big ( \frac{ 4\pi \sqrt{|D_1D_2|}\nu }{c }\Big ) V_{t}(|D_1D_2|( d f_1f_2)^2; k, t_\mathtt{u}) d\mathtt{u} \, dt\Big |. \end{aligned} \end{aligned}$$

We sum over k using Lemma 20 and open the Kloosterman sum. As in Sect. 10.2, up to a negligible error we obtain the upper bound

$$\begin{aligned} \begin{aligned}&\sum _{ d\delta \nu , m \leqslant K^{\eta }} \sum _{4 \mid c} \sum _{f_1, f_2} \frac{ \mu ^2(d\delta \nu m) }{d^3 \delta ^2 \nu ^{3/2} m^3 cf_1f_2 }\underset{\begin{array}{c} \gamma \, (\text {mod } c)\\ (\gamma , c) = 1 \end{array}}{\max } | \mathcal {I}^{\text {off}}(K)| \end{aligned} \end{aligned}$$

where \(\mathcal {I}^{\text {off}}(K) = \mathcal {I}_{d, \delta , \nu , m, c, f_1, f_2, \gamma }^{\text {off}}(K)\) is given by

$$\begin{aligned} \begin{aligned} \mathcal {I}^{\text {off}}(K) =&\frac{1}{K^2} \int \limits _{-\infty }^{\infty } \int \limits ^{*}_{\Lambda _{\text { ev}}} \omega (t_\mathtt{u}) \sum _{ D_1, D_2} \frac{ \chi _{D_2}(\delta )P(D_1; \mathtt{u})\overline{P(D_2d^2; \mathtt{u})}}{ |D_1D_2|^{3/4}} \Big (\frac{|D_2|(df_2)^2}{|D_1| f_1^2}\Big )^{it} \\&e\Big ( \frac{|D_1|\gamma + |D_2|\nu ^2{\bar{\gamma }}}{c}\Big ) e\Big (\pm \frac{ 2 \sqrt{|D_1D_2|}\nu }{c }\Big )\\&\tilde{V}\Big (|D_1D_2|(df_1f_2)^2, \frac{\sqrt{|D_1D_2|}\nu }{c}, t, t_\mathtt{u}\Big ) d\mathtt{u} \, dt; \end{aligned} \end{aligned}$$

here \(\tilde{V}\) satisfies (10.2) and is holomorphic in \(|\mathfrak {I}t_\mathtt{u}| \leqslant 1\). The bounds contained in (10.2) imply in particular \(c, f_1, f_2 \leqslant K^{\eta }\) up to a negligible error. For notation simplicity we consider only the plus-case, the minus case being entirely similar.

As in Sect. 11 we start with a Voronoi step, but in the present situation (since we have already excluded the constant function that requires a very careful treatment) we can afford to lose small powers of K on the way. We introduce the notation

$$\begin{aligned} A \preccurlyeq B \quad :\Longleftrightarrow \quad A \ll K^{c\eta } B \end{aligned}$$

for some constant c, not necessarily the same on every occasion. We always assume that \(\eta \) is sufficiently small.

To begin with, we integrate over t which by the properties of (10.2) induces the condition \(|D_1| f_1^2 - |D_2|(df_2)^2 \preccurlyeq K^{1/2}\) up to a negligible error. This now implies \(K^2 \preccurlyeq D_1, D_2 \preccurlyeq K^{2 }\), up to a negligible error. In \(\tilde{V}\) we can separate the variables \(D_1, D_2\) from \(t_\mathtt{u}\) by Mellin inversion (keeping holomorphicity in \(t_\mathtt{u}\)). Since \(\tilde{V}\) is of size \(K^{-1/2}\) and we also get a factor \(K^{1/2}\) from the t-integration, we are left with bounding

$$\begin{aligned} \begin{aligned} \tilde{\mathcal {I}}^{\text {off}}(K) =&\frac{1}{K^2} \int \limits ^{*}_{\Lambda _{\text { ev}}} \Omega (t_\mathtt{u}) \sum _{ D_1, D_2} \frac{ \chi _{D_2}(\delta )P(D_1; \mathtt{u})\overline{P(D_2d^2; \mathtt{u})}}{ |D_1D_2|^{3/4}} V_1\Big (\frac{|D_1|}{K^2}\Big ) V_2\Big (\frac{|D_2|}{K^2}\Big ) \\&V_3\Big (K^{1/2} \log \frac{|D_2|(df_2)^2}{|D_1| f_1^2}\Big ) e\Big ( \frac{|D_1|\gamma + |D_2|\nu ^2{\bar{\gamma }}}{c}\Big ) e\Big ( \frac{ 2 \sqrt{|D_1D_2|}\nu }{c }\Big ) d\mathtt{u} \end{aligned} \end{aligned}$$

where \(V_1, V_2\) have support in \([K^{-O(\eta )}, K^{O(\eta )}]\) with Sobolev norms bounded by \( \preccurlyeq 1\), \(V_3\) is rapidly decaying, and \(\Omega (\tau )\) is holomorphic in \(|\mathfrak {I}\tau | \leqslant 1\), satisfies the conditions (11.2) and is non-negligible only in the range \(K^{1/2} \preccurlyeq |\tau | \preccurlyeq K^{1/2}\).

14.2 Metaplectic Voronoi summation

We now consider the \(D_1\)-sum

$$\begin{aligned}&\sum _{ D_1} \frac{ P(D_1; \mathtt{u})\overline{P(D_2d^2; \mathtt{u})}}{ |D_1D_2|^{3/4}} V_1\Big (\frac{|D_1|}{K^2}\Big )\nonumber \\&\quad V_3\Big (K^{1/2} \log \frac{|D_2|(df_2)^2}{|D_1| f_1^2}\Big ) e\Big ( \frac{|D_1|\gamma }{c}\Big ) e\Big ( \frac{ 2 \sqrt{|D_1D_2|}\nu }{c }\Big ) \end{aligned}$$
(14.1)

and insert (4.8) with \(t = t_\mathtt{u}/2\) if \(\mathtt{u}\) is cuspidal and (4.11) if \(\mathtt{u} = E(., 1/2 + it_\mathtt{u})\) is Eisenstein. For clarity we recall that

$$\begin{aligned} \begin{aligned}&\frac{ P(D_1; \mathtt{u}) \overline{P(D_2d^2; \mathtt{u})}}{|D_1D_2 |^{3/4}} = \frac{d^{1/2}}{|D_1|^{1/2}|D_2|^{3/4}}\\&\times \quad {\left\{ \begin{array}{ll} b(D_1) \sqrt{|D_1|} A(D_2d^2, \mathtt{u}), &{} \mathtt{u} \text { cuspidal},\\ L(D_1, 1/2 + it_\mathtt{u}) |D_1|^{it_\mathtt{u}/2} A(D_2, \mathtt{u}), &{} \mathtt{u} = E(., 1/2 + it_\mathtt{u}),\end{array}\right. } \end{aligned} \end{aligned}$$

where

$$\begin{aligned} A(D, \mathtt{u}) = {\left\{ \begin{array}{ll} \displaystyle \frac{3}{\pi } L(\mathtt{u}, 1/2) \Gamma \Big (\frac{1}{4} + \frac{it_\mathtt{u}}{2}\Big )\Gamma \Big (\frac{1}{4} - \frac{it_\mathtt{u}}{2}\Big )b(D) \sqrt{|D|}, &{} \mathtt{u} \text { cuspidal},\\ [0.2cm] \displaystyle \frac{\zeta (1/2 + it_\mathtt{u})\zeta (1/2 - it_\mathtt{u}) L(D, 1/2 - it_\mathtt{u}) |D|^{-it_\mathtt{u}/2}}{2|\zeta (1 + 2 it_\mathtt{u})|^2}, &{} \mathtt{u} = E(., 1/2 + it_\mathtt{u}).\end{array}\right. } \end{aligned}$$

Even though the normalization in the cuspidal and the Eisenstein case is quite different, the Voronoi formulae in Lemma 10 (with \(r = t_\mathtt{u}/2)\) and 11 (with \(t = t_\mathtt{u}/2\)) can deal in the same fashion with the sums

$$\begin{aligned} \sum _{D_1 < 0} \left\{ \begin{array}{l} b(D_1) \sqrt{|D_1|} \\ L(D_1, 1/2 + it_\mathtt{u}) |D_1|^{it_\mathtt{u}/2}\end{array} \right\} e\Big ( \frac{|D_1|\gamma }{c}\Big ) \phi (D_1) \end{aligned}$$
(14.2)

with

$$\begin{aligned} \phi (x) = \frac{1}{|x|^{1/2}}V_1\Big (\frac{|x|}{K^2}\Big ) V_3\Big (K^{1/2} \log \frac{|D_2|(df_2)^2}{|x| f_1^2}\Big ) e\Big ( \frac{ 2 \sqrt{|xD_2|}\nu }{c }\Big ) \end{aligned}$$

for \(x < 0\) and \(\phi (x) = 0\) for \(x > 0\). It is easy to see that with this choice of \(\phi \) and for \(t \ll K^{1/2 + \varepsilon }\) the two polar terms in Lemma 11 are negligible, due to the strong oscillatory behaviour of the exponential \(e(\pm 2\sqrt{|xD_2|}\nu /c)\) for \(K^2 \preccurlyeq x, D_2 \preccurlyeq K^{2 }\), \(c \preccurlyeq 1\). By the same argument as in Sect. 10.4, see in particular (10.9), the terms with \(D > 0\) on the right hand side of the Voronoi summation formula are negligible. Hence, up to a negligible error, (14.2) becomes

$$\begin{aligned} \begin{aligned} \Big ( \frac{-c}{\gamma }\Big )&\epsilon _{\gamma } e(1/8) \frac{2\pi }{c}\sum _{D_1 < 0} \left\{ \begin{array}{l} b(D_1) \sqrt{|D_1|} \\ L(D_1, 1/2 + it_\mathtt{u}) |D_1|^{it_\mathtt{u}/2}\end{array} \right\} e\Big (- \frac{|D_1|{\bar{\gamma }}}{c}\Big ) \int \limits _0^{\infty }V_1\Big (\frac{|x|}{K^2}\Big ) \\&\sum _{\pm } (\mp ) \frac{\cos (\pi /4 \pm \pi i t_u/2)}{\sin (\pi i t_u)} J_{\pm i t_u}\Big ( \frac{4\pi \sqrt{|D_1x|}}{c}\Big )\\&\qquad V_3\Big (K^{1/2} \log \frac{|D_2|(df_2)^2}{|x| f_1^2}\Big ) e\Big ( \frac{2\sqrt{|xD_2|}\nu }{c}\Big ) \frac{dx}{ x^{1/2 }}. \end{aligned} \end{aligned}$$

Using (9.7) we approximate the Bessel J-function for \(t_\mathtt{u} \ll K^{1/2 + \varepsilon }\) by an exponential and replace up to a negligible error the preceding display by

$$\begin{aligned} \begin{aligned} \Big ( \frac{-c}{\gamma }\Big )&\epsilon _{\gamma } e(1/8) \frac{2\pi }{c} \sum _{D_1 < 0} \left\{ \begin{array}{l} b(D_1) \sqrt{|D_1|} \\ L(D_1, 1/2 + it_\mathtt{u}) |D_1|^{it_\mathtt{u}/2}\end{array} \right\} \\&e\Big ( -\frac{|D_1|{\bar{\gamma }}}{c}\Big ) \sum _{\pm } \int \limits _0^{\infty } \frac{c^{1/2}}{|D_1|^{1/4}} V_1\Big (\frac{|x|}{K^2}\Big ) \\&f^{\pm }\Big ( \frac{2\sqrt{|D_1x|}}{c}, t_\mathtt{u}\Big ) V_3\Big (K^{1/2} \log \frac{|D_2|(df_2)^2}{|x| f_1^2}\Big ) e\Big ( \frac{2\sqrt{|xD_2|}\nu \pm 2 \sqrt{|D_1x|}}{c}\Big ) \frac{dx}{ x^{3/4 }} \end{aligned} \end{aligned}$$

with

$$\begin{aligned} f^{\pm }(x, \tau ) = \frac{ 1}{2\pi }\sum _{k=0}^{n-1} \frac{i^k(\pm 1)^k}{(4\pi x)^{k}} \frac{\Gamma (i\tau + k + 1/2)}{k! \Gamma (i\tau - k + 1/2)} \end{aligned}$$

for n sufficiently large, but fixed. In particular \(f^{\pm }\) satisfies (10.10), and we see from the asymptotic expansion (9.7) that \(f^{\pm }\) is holomorphic in the second variable in, say, \(|\mathfrak {I}\tau | < 1\). For notational simplicity we consider only the leading term \(k=0\), the lower order terms being completely analogous (but easier).

We restore the periods \(P(D; \mathtt{u})\), so that the leading term of (14.1) has the shape

$$\begin{aligned} \begin{aligned} \sum _{\pm } \Big ( \frac{-c}{\gamma }\Big )&\epsilon _{\gamma } e(1/8) \frac{2\pi }{c^{1/2}}\sum _{D_1 < 0} \frac{P(D_1; \mathtt{u}) \overline{P(D_2d^2; \mathtt{u})}}{|D_2|^{3/4}|D_1|^{1/2}} e\Big (- \frac{|D_1|{\bar{\gamma }}}{c}\Big ) \frac{1}{2\pi }\int \limits _0^{\infty } V_1\Big (\frac{|x|}{K^2}\Big ) \\&V_3\Big (K^{1/2} \log \frac{|D_2|(df_2)^2}{|x| f_1^2}\Big ) e\Big ( \frac{2\sqrt{|xD_2|}\nu \pm 2 \sqrt{|D_1x|}}{c}\Big ) \frac{dx}{ x^{3/4 }} \end{aligned} \end{aligned}$$

with lower order terms of similar form. Recall that \(K^2 \preccurlyeq D_2 \preccurlyeq K^{2 }\). Integrating by parts, we see as in (10.12)–(10.13) that only the minus-term in the exponential is relevant (the plus-term is negligible) and the x-integral restricts to \(\sqrt{|D_2|}\nu - \sqrt{|D_1|} \preccurlyeq K^{-1/2}\). We therefore introduce a new variable \(h \in \mathbb {Z}\) by

$$\begin{aligned} |D_1| = |D_2|\nu ^2 + h \end{aligned}$$

with \(h \preccurlyeq K^{1/2 }\). Changing variables in the x-integral, we obtain

$$\begin{aligned} \begin{aligned}&\Big ( \frac{-c}{\gamma }\Big )\epsilon _{\gamma } e(1/8) \frac{1 }{c^{1/2}}\sum _{h \preccurlyeq K^{1/2}} \frac{P(-|D_2|\nu ^2 - h, \mathtt{u}) \overline{P(D_2d^2; \mathtt{u})} }{|D_2|^{1/2}(|D_2|\nu ^2 + h)^{1/2}} e\Big ( -\frac{(|D_2|\nu ^2 + h){\bar{\gamma }}}{c}\Big ) \\&\quad \int \limits _0^{\infty } V_1\Big (\frac{|xD_2|}{K^2}\Big ) V_3\Big (K^{1/2} \log \frac{ (df_2)^2}{|x| f_1^2}\Big ) e\Big ( \frac{2 \sqrt{x D_2}(\sqrt{|D_2|}\nu - \sqrt{(|D_2|\nu ^2 + h)})}{c}\Big ) \frac{dx}{ x^{3/4 }} \end{aligned} \end{aligned}$$

where h is restricted to numbers such that \(-(|D_2|\nu ^2 + h)\) is a negative discriminant. The weight function \(V_3\) forces \(x \preccurlyeq 1\) and more precisely

$$\begin{aligned} x - (df_2/f_1)^2 \preccurlyeq K^{-1/2}. \end{aligned}$$
(14.3)

By a Taylor expansion we can write

$$\begin{aligned} e\Big ( \frac{2 \sqrt{x|D_2|}(\sqrt{|D_2|}\nu - \sqrt{(|D_2|\nu ^2 + h)})}{c}\Big ) = e\Big ( -\frac{\sqrt{x}h}{c\nu }\Big ) F(D_2) \end{aligned}$$

where

$$\begin{aligned} F(D) = F_{x, h, \nu , c}(D) = 1 + \frac{i\pi \sqrt{x} h^2}{2 |D| \nu ^3 c} - \frac{i\pi \sqrt{x}h^3}{4|D|^2 \nu ^5 c} +\cdots \end{aligned}$$

Again we only keep the leading term (the lower order terms being similar, but easier). We substitute all of this back into \(\tilde{\mathcal {I}}^{\text {off}}(K)\) and pull the x-integration outside which is subject to (14.3), in particular \(x \preccurlyeq 1\). In this way we see that it suffices to bound

$$\begin{aligned} \begin{aligned}&\mathcal {I}_1^{\text {off}}(K)\\&:= \frac{1}{K^{5/2}} \int \limits ^{*}_{\Lambda _{\text { ev}}} \Omega (t_\mathtt{u}) \sum _{ D_2} \sum _{h \preccurlyeq K^{1/2}} \frac{P(-|D_2|\nu ^2 - h, \mathtt{u}) \overline{P(D_2d^2; \mathtt{u})}}{|D_2|^{1/2} (|D_2|\nu ^2 + h)^{1/2}}\chi _{D_2}(\delta ) \\&V_x\Big (\frac{|D_2|}{K^2}\Big ) e\Big ( -\frac{ h{\bar{\gamma }}}{c} -\frac{\sqrt{x}h}{c\nu }\Big )d\mathtt{u} \end{aligned} \end{aligned}$$
(14.4)

where \(V_x(z) = V_2(z) V_1(xz)\), uniformly in

$$\begin{aligned} x, \nu , c, \delta , d \preccurlyeq 1, \quad (\gamma , c) = 1. \end{aligned}$$

A trivial bound using Cauchy-Schwarz and Proposition 4 gives \( \mathcal {I}_1^{\text {off}}(K) \preccurlyeq 1\), as in Section 10. In order to make progress and get additional savings, we must now treat the \(\mathtt{u}\)-integral non-trivially. This is where the trace formula has its appearance.

14.3 Application of the trace formula

We now apply Theorem 18 to the spectral expression

$$\begin{aligned} \begin{aligned}&\int \limits ^{*}_{\Lambda _{\text { ev}}} \Omega (t_\mathtt{u}) \frac{P(-|D_2|\nu ^2 - h, \mathtt{u}) \overline{P(D_2d^2; \mathtt{u})}}{|D_2|^{1/4} (|D_2|\nu ^2 + h)^{1/4}} d\mathtt{u} \\&\quad = \int \limits _{\Lambda _{\text { ev}}} \Omega (t_\mathtt{u}) \frac{P(-|D_2|\nu ^2 - h, \mathtt{u}) \overline{P(D_2d^2; \mathtt{u})}}{|D_2|^{1/4} (|D_2|\nu ^2 + h)^{1/4}} d\mathtt{u} - \frac{3}{\pi } \frac{H(D_2d^2)H(-|D_2|\nu ^2 - h)}{|D_2|^{1/4} (|D_2|\nu ^2 + h)^{1/4}} \Omega (i/2). \end{aligned} \end{aligned}$$

We discuss the four terms on the right hand side of the trace formula.

(1) The class number term gets immediately cancelled.

(2) The t-integral in the polar term is rapidly decaying and by a Burgess-type subconvexity bound \(L(D, 1/2 + it) \ll |D|^{3/16+\varepsilon }(|1+|t|)^{10}\), say, its contribution to (14.4) is at mostFootnote 12

$$\begin{aligned} \preccurlyeq \frac{1}{K^{5/2}} \sum _{ D_2 \preccurlyeq K^2} \sum _{h \preccurlyeq K^{1/2}} \frac{1}{|D_2|^{1/16} (|D_2|\nu ^2 + h)^{1/16 }} \preccurlyeq K^{-1/4}. \end{aligned}$$

(3) For the diagonal term we observe that \(\sum _m m^{-1} \int |\Omega (t)W_{t}(rnvm)t| dt \preccurlyeq K\) uniformly in nrv by (9.17). If the fundamental discriminants underlying \(D_2d^2\) and \(-|D_2|\nu ^2 - h\) coincide, we have at most \(\preccurlyeq K^{1/4}\) choices for h (in most cases much fewer), so the diagonal term contributes at most

$$\begin{aligned} \preccurlyeq \frac{1}{K^{5/2}} K \sum _{ D_2\preccurlyeq K^2} \frac{K^{1/4}}{|D_2|^{1/2} } \preccurlyeq K^{-1/4} \end{aligned}$$

to (14.4).

(4) It remains to deal with the fourth term, and to this end we write \(D_2 = \Delta _2 f_2\) with a fundamental discriminant \(\Delta _2\). Then the Kloosterman term can be bounded by

$$\begin{aligned} \begin{aligned} \mathcal {I}_1^{\text {off}, \text {off}}(K)=&\frac{1}{K^{5/2}} \sum _{h \preccurlyeq K^{1/2}} \Big | \sum _{ D_2 = \Delta _2 f_2^2} \frac{ \chi _{D_2}(\delta ) }{|D_2|^{1/4} (|D_2|\nu ^2 + h)^{1/4}} V_x\Big (\frac{|D_2|}{K^2}\Big ) \\&\sum _{ d_1r\tau vw = f_2 }\sum _{n, c, m} e\Big ( -\frac{h{\bar{\gamma }}}{c}\Big ) \\&\frac{\mu (d_1)\mu (v) \chi _{\Delta _2}(d_1vm\tau )}{\sqrt{d_1rn\tau } vm} \frac{ K_{3/2}^+(|\Delta _2|(vwn)^2, |D_2|\nu ^2 + h, c)}{ c} \\&\quad \times \int \limits _{-\infty }^{\infty } \frac{F(4\pi vwn\sqrt{|\Delta _2|(|D_2|\nu ^2 + h)}/c, t, 1/2)}{\cosh (\pi t)} \Omega (t) W_{t}( rnvm) t \frac{dt}{\pi }\Big |. \end{aligned} \end{aligned}$$

(Here we exchanged the roles of \(D_1\) and \(D_2\) in Theorem 18.) The general strategy is now as follows: We evaluate the t-integral by Lemma 21. The application of the trace formula was a gambit in the sense that the trivial bound is now only \(\preccurlyeq K^{1/2}\). It is not immediately clear how to make further progress. By using suitable Taylor expansions we observe the lucky coincidence that we obtain rational phases in the exponentials. We are then ready to apply Poisson summation in the long \(\Delta _2\)-sum which will eventually give enough savings. We now make these ideas precise.

We recall that \(\Omega \) satisfies the conditions stated in (11.2) and is negligible for \(|t| \gg K^{1/2+\varepsilon }\). The nm-sum is absolutely convergent by (9.17), and we can truncate it at \(rnvm \preccurlyeq K^{1/2}\) at the cost of a negligible error. We split the nm-sum into dyadic ranges \(N \leqslant n \leqslant 2N\), \(M \leqslant m \leqslant 2M\) where

$$\begin{aligned} NM \preccurlyeq (rv)^{-1}K^{1/2}. \end{aligned}$$
(14.5)

By the remark after Theorem 18 and the properties of \(\Omega \), the integrand of the t-integral is holomorphic in, say, \(|\mathfrak {I}t| < 2/3\), so by contour shifts, Weil’s bound (1.9) and the power series expansion of the Bessel J-function we see that the c-sum is absolutely convergent and can be truncated at \(c \ll K^{10^6}\), say, at the cost of a negligible error. Having truncated the c-sum in this very coarse way, we can sacrifice holomorphicity and include a smooth partition of unity into the t-integral, where a typical portion is weighted by w(|t|/T) with a smooth compactly function w localizing \(|t| \asymp T\) with \(K^{1/2-2\eta } \ll T \ll K^{1/2+\varepsilon }\). We apply Lemma 21a) to evaluate asymptotically the t-integral which in particular restricts the size of c. Splitting also the c-sum into dyadic ranges \(c \asymp C\), we can assume, up to a negligible error,

$$\begin{aligned} C \preccurlyeq \frac{vwn \sqrt{|\Delta _2|(|D_2|\nu ^2 + h)}}{T^2} \preccurlyeq \frac{KN}{d_1r\tau }. \end{aligned}$$
(14.6)

Having recorded these conditions, we can write the t-integral (as usual, up to a negligible error) as

$$\begin{aligned}&\sum _{\pm } \frac{T^2c^{1/2}}{\sqrt{vwn} |\Delta _2|^{1/4}(|D_2|\nu ^2 + h)^{1/4}} e\Big (\pm \frac{2 vwn\sqrt{|\Delta _2|(|D_2|\nu ^2 + h)}}{c}\Big )\\&\quad H^{\pm }\Big ( \frac{2 vwn\sqrt{|\Delta _2|(|D_2|\nu ^2 + h)}}{c}\Big ) \end{aligned}$$

for a flat function H, i.e. \(x^j\frac{d^j}{dx^j} H^{\pm }(x) \ll _j 1\) for \(j \in \mathbb {N}_0\). Substituting back, it remains to bound

$$\begin{aligned} \begin{aligned}&\frac{1}{K^{3/2}} \sum _{h \preccurlyeq K^{1/2}} \sum _{ d_1,r,\tau ,v,w } \sum _{\begin{array}{c} n \asymp N\\ m \asymp M \end{array}} \sum _{c \asymp C} \Big | \sum _{ \Delta _2 } \frac{ \chi _{D_2}(\delta ) }{|D_2|^{1/2} (|D_2|\nu ^2 + h)^{1/2}} V_x\Big (\frac{|D_2|}{K^2}\Big ) \frac{ \chi _{\Delta _2}(d_1vm\tau )}{nvm} \\&\quad \frac{ K_{3/2}^+(|\Delta _2|(vwn)^2, |D_2|\nu ^2 + h, c)}{ c^{1/2}} e\Big (\pm \frac{2 vwn\sqrt{|\Delta _2|(|D_2|\nu ^2 + h)}}{c}\Big ) \\&\quad H^{\pm }\Big ( \frac{2 vwn\sqrt{|\Delta _2|(|D_2|\nu ^2 + h)}}{c}\Big )\Big |. \end{aligned} \end{aligned}$$
(14.7)

where for given \(r, v, d_1, \tau \) the parameters NMC are subject to (14.5) and (14.6) and \(D_2 = \Delta _2 (d_1r\tau vw )^2\). Estimating trivially at this point using the Weil bound (1.9), we obtain the bound

$$\begin{aligned} \preccurlyeq \frac{1}{K^{3/2}} K^{1/2} C \preccurlyeq K^{1/2}. \end{aligned}$$
(14.8)

We see that applying the trace formula was a gambit in the sense that the trivial bound is now roughly a factor \(K^{1/2}\) off our target. On the other hand, all automorphic information is now gone, and we may hope to get enough saving from the long character sums. In particular, we can assume that \(C \geqslant K^{1 - a\eta }\) for some sufficiently large constant a, otherwise the trivial bound (14.8) suffices. For such C, we can use a Taylor expansion

$$\begin{aligned} e\Big (\pm \frac{2 vwn\sqrt{|\Delta _2|(|D_2|\nu ^2 + h)}}{c}\Big ) = e\Big (\pm \frac{2 vwn|\Delta _2d_1r\tau vw\nu }{c} \pm \frac{vwnh}{d_1r\tau vw\nu c}\Big )\Phi (\Delta _2) \end{aligned}$$

with

$$\begin{aligned} \Phi (\Delta ) - 1 \ll \frac{nh^2}{c|D_2|} \preccurlyeq K^{-3/2} \end{aligned}$$

in the current range of variables. The error term contributes \(\preccurlyeq K^{-1}\) to (14.7). Similarly, we also have

$$\begin{aligned} \frac{H^{\pm }( 2 vwn\sqrt{|\Delta _2|(|D_2|\nu ^2 + h)}/c) }{|D_2|^{1/2} (|D_2|\nu ^2 + h)^{1/2}} = \frac{H^{\pm }( 2 vwn |\Delta _2|d_1r\tau vw\nu /c)}{|D_2|\nu } + O\Big (\frac{h}{|D_2|^2}\Big ) \end{aligned}$$

and again the error term contributes \(\preccurlyeq K^{-1}\) to (14.7). Defining \(\tilde{V}_x(z) = z^{-1} V_x(z)\), we are left with bounding

$$\begin{aligned} \begin{aligned} \frac{1}{K^{7/2}}&\sum _{h \preccurlyeq K^{1/2}} \sum _{ (d_1r\tau vw, \delta ) = 1 } \sum _{\begin{array}{c} n \asymp N\\ m \asymp M \end{array}} \sum _{c \asymp C} \Big | \sum _{ \Delta _2 } \tilde{V}_x\Big (\frac{|\Delta _2|(d_1r\tau vw)^2}{K^2}\Big ) \frac{ \chi _{\Delta _2}(\delta d_1vm\tau )}{nvmc^{1/2}} \\&K_{3/2}^+(|\Delta _2|(vwn)^2, |\Delta _2|(d_1r\tau vw\nu )^2 + h, c) e\Big (\pm \frac{2 (vw)^2n |\Delta _2|d_1r\tau \nu }{c}\Big )\\&H^{\pm }\Big ( \frac{2 (vw)^2n |\Delta _2|d_1r\tau \nu }{c}\Big )\Big |. \end{aligned} \end{aligned}$$

Note the very fortunate fact that the algebraic phase \( e(\pm 2 vwn\sqrt{|\Delta _2|(|D_2|\nu ^2 + h)}/c) \) in (14.7) has become a rational phase. As usual, the \(\Delta _2\)-sum runs over negative fundamental discriminants, and we split the sum into residue classes \(\Delta _2 \equiv 1, 5, 8, 9, 12, 13\) (mod 16) and insert a factor \(\mu ^2(\Delta _2/\alpha )\) with \(\alpha \in \{1, 4\}\) to detect squarefreeness. For notational simplicity let us treat the case of odd \(\Delta \), the case of even \(\Delta \) being similar. Using the well-known convolution formula for \(\mu ^2\), this leaves us with bounding

$$\begin{aligned} \begin{aligned}&\frac{1}{K^{7/2}} \sum _{h \preccurlyeq K^{1/2}} \sum _{ (d_1r\tau vw, \delta ) = 1 } \sum _{(d_2, \delta d_1vm\tau ) = 1} \sum _{\begin{array}{c} n \asymp N\\ m \asymp M \end{array}} \sum _{c \asymp C} \frac{1}{vnmc^{1/2}}\\&\Big | \sum _{ \Delta _2 } \psi (\Delta _2) \tilde{V}_x\Big (\frac{|\Delta _2|(d_2d_1r\tau vw)^2}{K^2}\Big ) \Big ( \frac{\Delta _2}{\delta d_1vm\tau }\Big )\\&K_{3/2}^+(|\Delta _2|(d_2vwn)^2, |\Delta _2|(d_2d_1r\tau vw\nu )^2 + h, c) \\&e\Big (\pm \frac{2 (vw)^2nd_2^2 |\Delta _2|d_1r\tau \nu }{c}\Big ) H^{\pm }\Big ( \frac{2 (vwd_2)^2n |\Delta _2|d_1r\tau \nu }{c}\Big )\Big |. \end{aligned} \end{aligned}$$
(14.9)

for a character \(\psi \) modulo 4. Recall that the Kloosterman sum is nonzero only if \(4 \mid c\). Estimating trivially at this point (using (1.9)), we can assume that

$$\begin{aligned} d_2d_1r\tau v w \preccurlyeq C/K \preccurlyeq K^{1/2} \end{aligned}$$

by (14.6) and (14.5), the remaining portion being \(O(K^{-\eta })\) if the \(K^{O(\eta )}\) factor in the previous \( \preccurlyeq \) sign is sufficiently large. We now open the Kloosterman sum and apply Poisson summation in \(\Delta _2\) in residue classes modulo \( c \delta d_1vm\tau \). If \(\mathtt{D}\) denotes the dual variable, this yields the character sum

$$\begin{aligned} \begin{aligned}&\sum _{\Delta _2 \, (\text {mod } c \delta d_1vm\tau )} \psi (\Delta _2) \Big ( \frac{\Delta _2}{\delta d_1vm\tau }\Big ) e\Big ( \pm \frac{2 (vw)^2nd_2^2 |\Delta _2|d_1r\tau \nu }{c}\Big ) \\&\sum _{\begin{array}{c} \gamma \, (\text {mod }c)\\ (\gamma , c) = 1 \end{array}} \epsilon ^{2\kappa }_{\gamma } \left( \frac{c}{\gamma }\right) e\left( \frac{|\Delta _2|(d_2vwn)^2\gamma + (|\Delta _2|(d_2d_1r\tau vw\nu )^2 + h){\bar{\gamma }}}{c}\right) e\Big ( \frac{\Delta _2 \mathtt{D}}{c \delta d_1vm\tau }\Big ). \end{aligned}\nonumber \\ \end{aligned}$$
(14.10)

We write \(c = c_1c_2\) where \((c_1, 2\delta d_1vm\tau ) = 1\) and \(c_2 \mid (2\delta d_1vm\tau )^{\infty }\). Then both sums split off a sum modulo \(c_1\) given by

$$\begin{aligned} \begin{aligned}&\sum _{\Delta _2 \, (\text {mod } c_1)} e\Big ( \pm \frac{2 (vw)^2nd_2^2 |\Delta _2|d_1r\tau \nu {\bar{c}}_2}{c_1}\Big ) \\&\sum _{\begin{array}{c} \gamma \, (\text {mod }c_1)\\ (\gamma , c_1) = 1 \end{array}} \left( \frac{\gamma }{c_1}\right) e\left( \frac{(|\Delta _2|(d_2vwn)^2\gamma + (|\Delta _2|(d_2d_1r\tau vw\nu )^2 + h){\bar{\gamma }}){\bar{c}}_2}{c_1}\right) e\Big ( \frac{\Delta _2 \mathtt{D} \overline{c_2 \delta d_1vm\tau }}{c_1 }\Big ), \end{aligned} \end{aligned}$$

cf. [40, Lemma 2] for the treatment of the theta-multiplier. Summing over \(\Delta _2\) bounds this double sum modulo \(c_1\) by

$$\begin{aligned} \begin{aligned}&\leqslant c_1\#\{ \gamma \in (\mathbb {Z}/c_1\mathbb {Z}_1)^{*} \mid (d_2vwn)^2\gamma + (d_2d_1r\tau vw\nu )^2 {\bar{\gamma }} \\&\qquad \quad \pm 2 (vw)^2nd_2^2 d_1r\tau \nu + \mathtt{D} \overline{ \delta d_1vm\tau } = 0 \}\\&\qquad \ll _{\varepsilon } c_1^{1+\varepsilon } (c_1, (d_2vwn, d_2d_1r\tau vw\nu )^2). \end{aligned} \end{aligned}$$

We estimate the remaining part of the character sum (14.10) trivially by \(c_2^2\delta d_1vm\tau \). By the properties of the (essentially non-oscillating) weight functions \(\tilde{V}_x\) and \(H^{\pm }\), the dual variable \(\mathtt{D}\) can be truncated at

$$\begin{aligned} \mathtt{D} \preccurlyeq \frac{ c \delta d_1vm\tau }{K^2/(d_2d_1r\tau vw)^2}, \end{aligned}$$

and so the \(\Delta _2\)-sum in (14.9) can be bounded by

$$\begin{aligned} \begin{aligned}&\preccurlyeq \Big (\frac{K^2/(d_2d_1r\tau vw)^2}{ c \delta d_1vm\tau } + 1\Big ) c^{1+\varepsilon } (c_1, (d_2vwn, d_2d_1r\tau vw\nu )^2) c_2\delta d_1vm\tau \\&= \Big ( \frac{K^2c^{\varepsilon }}{ (d_2d_1r\tau vw)^2 } + c^{1+\varepsilon } \delta d_1vm\tau \Big ) \Big (c, (d_2w)^2( n, r \nu )^2 (2\delta d_1vm\tau )^{\infty }\Big ) \end{aligned} \end{aligned}$$

using the notation explained in Sect. 1.5. The first term in the first parenthesis accounts for the zero frequency in the Poisson summation formula. We substitute this back into (14.9) getting the (generous) upper bound

$$\begin{aligned}&\preccurlyeq \frac{1}{K^{3}} \sum _{d_2 d_1r\tau v w\preccurlyeq K^{1/2} } \sum _{\begin{array}{c} n \asymp N\\ m \asymp M \end{array}} \sum _{c \asymp C} \frac{ (c, (2d_2 d_1r\tau v wnm)^{\infty })}{vnmc^{1/2}}\nonumber \\&\quad \Big ( \frac{K^2c^{\varepsilon }}{ (d_2d_1r\tau vw)^2 } + c^{1+\varepsilon } d_1vm\tau \Big ). \nonumber \\ \end{aligned}$$
(14.11)

Here we dropped the variable \(\delta \preccurlyeq 1\). The rest is book-keeping. By Rankin’s trick we have

$$\begin{aligned} \sum _{c \asymp C} (c, x^{\infty }) \ll C\sum _{\begin{array}{c} d \ll C\\ d \mid x^{\infty } \end{array}} 1 \ll C\sum _{ d \mid x^{\infty }} \Big ( \frac{C}{d} \Big )^{\varepsilon } \ll C(Cx)^{\varepsilon } \end{aligned}$$

for every \(\varepsilon > 0\) and \(x \in \mathbb {N}\). Using (14.6) and (14.5), the bound (14.11) becomes

$$\begin{aligned} \begin{aligned}&\preccurlyeq \frac{1}{K^{3}} \sum _{d_2 d_1r\tau v w\preccurlyeq K^{1/2} } \frac{C^{1/2}}{v }\Big ( \frac{K^2 }{ (d_2d_1r\tau vw)^2 } + C M d_1v\tau \Big ) \\&\preccurlyeq \frac{1}{K^{3}} \sum _{d_2 d_1r\tau v w\preccurlyeq K^{1/2} } \frac{(KN)^{1/2}}{(d_1r\tau )^{1/2}v }\Big ( \frac{K^2 }{ (d_2d_1r\tau vw)^2 } +\frac{ KN M v }{r}\Big )\\&\preccurlyeq \frac{1}{K^{3}} \sum _{d_2 d_1r\tau v w\preccurlyeq K^{1/2} } \frac{K^{3/4}}{(d_1r^2v\tau )^{1/2} }\Big ( \frac{K^2 }{ v (d_2d_1r\tau vw)^2 } +\frac{ K^{3/2} }{r^2v}\Big ) \preccurlyeq K^{-1/4}. \end{aligned} \end{aligned}$$

This is the desired power saving and completes the proof of Theorem 2.