1 Introduction

A positive, integral, symmetric \(k \times k\) matrix A with even diagonal elements gives rise to a quadratic form \(q(x):= \frac{1}{2} x^{t} A x\). It is a central problem of number theory to study the representation function

$$\begin{aligned} r(q,n) := \# \left\{ x \in {\mathbb Z}^{k} \, | \, q(x) = n \right\} . \end{aligned}$$

One way to do so is by examining the theta series

$$\begin{aligned} \theta (q,z) := \sum _{x \in {\mathbb Z}^{k}} e(q(x)z) = \sum _{n = 0}^{\infty } r(q,n) e(nz) \end{aligned}$$

which is a modular form of (generally) half-integral weight of level N, where N is the level of q. To understand r(qn), decompose \(\theta (q,z)\) into an Eisenstein series and a cusp form. To treat the cusp form contribution, one may apply the results from the late eighties from Iwaniec [7], Duke [3] and Duke–Schulze-Pillot [4]. Let \(f(z) = \sum _{n \ge 1} a(n)e(nz)\) be a holomorphic cusp form of half-integral weight \(k/2,\,k\ge 3\) for the group \(\Gamma = \Gamma _0(N)\), normalised with respect to

$$\begin{aligned} \langle f,g \rangle = \int _{\Gamma \backslash {\mathbb H}} f(z) \overline{g(z)} y^{k} \frac{\mathrm{d}x\, \mathrm{d}y}{y^2}. \end{aligned}$$
(1)

Then, it was shown in [3, 7] that, for squarefree n,

$$\begin{aligned} a(n) \ll n^{k/4-2/7+{\epsilon }}. \end{aligned}$$
(2)

The aim of this paper is threefold: we extend the bound (2) to arbitrary n, we include forms of level N with arbitrary nebentypus and improve the bound with respect to N. For the second point we need to bear in mind that the Weil–Estermann bound does not necessarily hold for twisted Kloosterman sums for prime power moduli (cf. [10, Example 9.9]). The main strategy follows the work of Duke and Iwaniec [3, 7] with the extensions of Blomer [1].

Let U be the subspace of theta functions of \(S_{3/2}(N,\chi )\) of type \(\sum _{n \ge 1} \psi (n) n e(tn^2z)\) for some real character \(\psi \) and 4t|N, so that for all \(f \in U^{\bot }\) the Shimura lift of f is cuspidal. If d divides a power of x, we write \(d | x^{\infty }\), and we denote the squarefree kernel by \( rad (n)\).

Theorem 1

Fix an orthonormal basis \(\{\varphi _{j}=\sum _{n\ge 1} a_{j}(n) e(nz)\}_{j=1}^{d}\) of \(S_{k/2}(N,\chi )\) for odd \(k \ge 5\) and of \(U^{\bot }\) for \(k=3\). Then it holds for \(n= t v^2 w^2\) with t squarefree, \(v | N^{\infty }\), \((w,N)=1\) and quadratic \(\chi \) that

$$\begin{aligned} \nonumber \sum _{j=1}^{d} {|{a_j(n)}|}^2 \ll n^{k/2-1} \left( \frac{t^{3/7}v^{6/7}}{N^{2/7}(n,N)^{1/7}} + \frac{t^{3/8}v^{3/4}}{N^{1/8}(n,N)^{1/4}}+ \frac{v(n,N)}{N}+1 \right) (nN)^{{\epsilon }}. \end{aligned}$$

For arbitrary \(\chi \), the last term within the bracket changes to \(\frac{v (n,N)}{N } \left( c_{\chi } rad (c_\chi ) \right) ^{1/4}\), where \(c_\chi \) is the conductor of \(\chi \).

Theorem 1 is ultimately based on Iwaniec’s method of bounding sums of half-integral weight Kloosterman sums. By a very different approach, based on Waldspurger’s theorem and subconvexity, one can bound \(a_j(n)\) by \(\mathcal {O}(n^{k/4-5/16})\) cf. [2, Corollary 2] which is slightly better in terms of n. However, the implied constant depends quite strongly on N. For many applications involving families of cusp forms, such as the one presented below, Theorem 1 leads therefore to stronger results.

We singled out the case of quadratic \(\chi \) because this is the relevant case for quadratic forms and the main application that we proceed to present. It has been investigated by Wooley [21] under which conditions on the exponents \(k_j,\, j=1,\ldots ,t\) the Diophantine equation

$$\begin{aligned} x_{1}^2 + x_{2}^2+ x_{3}^3 + x_{4}^3 + \sum _{j=1}^{t} y_{j}^{k_j} = n \end{aligned}$$
(3)

has solutions for all sufficiently large n. His proof is based, among other things, on a result of Golubeva [5, Theorem 2] which we can improve by Theorem 1 as follows.

Theorem 2

Let \(P\ne 3\) be an odd prime, \((n,6P)=1\) and \(n=tv^2\) with t squarefree. Then

$$\begin{aligned} n = x^2 + y^2 +6 P z^2 \end{aligned}$$

is solvable for \((x,y,z) \in {\mathbb N}^{3}\) if \(P^{1+{\epsilon }} \le \mathrm {min}(n^{1/17}v^{12/17},n^{1/11}v^{6/11},n^{1/3})\). This holds, in particular, if \(nv^{28/3}>P^{17 + {\epsilon }}\).

In [5], the bound is \(nv^{12} > P^{21+{\epsilon }}\). For \(k_i \in {\mathbb N}\) and \(2 \le k_1 \le \ldots \le k_t\) set

$$\begin{aligned} \gamma (k) = \prod _{i=1}^{t} \left( 1- \frac{1}{k_i} \right) \quad \text {and} \quad \tilde{\gamma }(k) = \left( 1- \frac{1}{k_t} \right) \prod _{i=1}^{t-2} \left( 1- \frac{1}{k_i} \right) . \end{aligned}$$

Theorem 3

Assume the Riemann hypothesis for all L-functions associated with Dirichlet characters. Then, provided that \(\gamma (k) < \frac{28}{39}\), all sufficiently large numbers n are represented in the form of (3). The same conclusions hold without the assumption of the Riemann hypothesis if

  1. 1.

    \(t \ge 2\) and \(\tilde{\gamma }(k) < \frac{58}{81}\) or

  2. 2.

    \(\gamma (k) < \frac{58}{81}\) and the exponents \(k_1,\ldots ,k_t\) are not all even.

The original bounds in [21, Theorem 1.2] are \(\gamma (k) < 12/17\) with the assumption of the Riemann hypothesis, \(\tilde{\gamma }(k) < 74/105\) for (i) and \(\gamma (k) < 74/105\) for (ii). As a consequence, it follows that every sufficiently large number n is represented in the form

$$\begin{aligned} x_{1}^2+ x_{2}^2 + x_{3}^3 + x_{4}^3 + \sum _{j=1}^{t} x_{j}^{3t} = n, \end{aligned}$$

with odd \(t \le 81\), or in the form

$$\begin{aligned} x_{1}^2+ x_{2}^2 + x_{3}^3 + x_{4}^3 + x_{5}^{8}+ x_{6}^{12}+x_{7}^{16}+x_8^{20} =n \end{aligned}$$

if the truth of the Riemann hypothesis is assumed.

2 Shimura’s lift and Maaß forms

We follow the exposition of [1]. For \(0 \ne z \in {\mathbb C}\) and \(v \in {\mathbb R}\) define \(z^v\) by

$$\begin{aligned} z^v = {|{z}|}^v \text {exp}(iv \text { arg}(z)), \text { where } \text {arg}(z) \in (-\pi ,\pi ]. \end{aligned}$$

For a holomorphic function on the upper half plane \(f: {\mathbb H}\rightarrow {\mathbb C}\) and \(\gamma = \begin{pmatrix} a &{} b \\ c &{} d \end{pmatrix} \in \Gamma _0(4)\) set

$$\begin{aligned} f|[\gamma ]_{k/2}(z) = \left( {\epsilon }_{d}^{-1} \left( \frac{c}{d} \right) \right) ^{-k} (cz+d)^{-k/2} f(\gamma z), \end{aligned}$$

where \(\left( \frac{c}{d} \right) \) is the extended Kronecker symbol (cf. [19, p. 442]) and \({\epsilon }_d = \left( \frac{-1}{d} \right) ^{1/2}\). From now on, \(\chi \) will always denote a character mod N and 4|N. For odd k, we denote the spaces of modular forms and cusp forms of half-integral weight k / 2 for \(\Gamma _0(N)\) and transformation behaviour \(f|[\gamma ]_{k/2}(z) = \chi (d) f(z)\) by \(M_{k/2}(N,\chi )\) and \(S_{k/2}(N,\chi )\). For \(f,g \in S_{k/2}(\Gamma , \chi ) \), the inner product is defined by (1). For \((n,N) =1\), let \(T(n): M_k(N,\chi ) \rightarrow M_k(N,\chi )\) be the Hecke operator (cf. [11, Chapter 4.3]).

For \(f=\sum _{n \ge 1} c(n)e(nz) \in S_{k/2}(N,\chi )\), \(k \ge 3\) odd, \(\varepsilon =(-1)^{(k-1)/2}\) and t without square factors (other than 1) prime to N, define \(C_t(n)\) by the formal identity

$$\begin{aligned} \sum _{n=1}^{\infty } C_t(n) n^{-s} = L(s-k/2+3/2,\chi _{4 \varepsilon t}\chi )\sum _{n=1}^{\infty } c(t n^2) n^{-s}. \end{aligned}$$

Then \(F_t(z) = \sum _{n=1}^{\infty } C_t(n) e(nz) \in M_{k-1}(N/2,\chi ^{2})\) is called the t-Shimura lift. If f is an eigenform for all Hecke operators \(T(p^2),~p \not \mid N\) with eigenvalues \(\lambda _p\), then \(F_t\), if it is not equal to 0, is an eigenform for all \(T_p, p \not \mid N\) with the same eigenvalues, and it holds for \((n,N)=1\) that [19, Corollary 1.8]

$$\begin{aligned} C_t(n)= c(t) \cdot \lambda _n. \end{aligned}$$

There exists an orthonormal basis of \(U^{\bot }\) and of \(S_{k/2}(N,\chi ), k \ge 5\), of simultaneous eigenforms for all \(T(p^2), p \not \mid N\). Consequently, if the t-Shimura lift of f is cuspidal, it follows by Deligne’s bound for integral-weight modular forms for \((w,N)=1\) that

$$\begin{aligned} \big | c (t w^2) \big | = \Big | c(t) \sum _{d | w} \mu (d) \chi _{4 {\epsilon }t}\chi (d) d^{k/2-3/2} \lambda _{w/m} \Big | \le {|{c(t)}|} w^{k/2-1} \tau (w)^2. \end{aligned}$$
(4)

For \(k \ge 5\) the Shimura lift is always cuspidal. However, for \(k=3\) the t-Shimura lift is cuspidal for all squarefree t if and only if \(f \in U^{\bot }\), i.e. f does not live in the subspace of theta functions.

The theory of Maaß forms with general weights was introduced by Selberg [18]. For \(\gamma \in \Gamma _0(4)\) and \(k \in {\mathbb Z}\) set

$$\begin{aligned} f|[\gamma ]_{k/2} (z) = \left( {\epsilon }_{d}^{-1} \left( \frac{c}{d} \right) \right) ^{-k} e^{-i (k/2) \text {arg}(cz+d)} f(\gamma z). \end{aligned}$$

We call a function \(f:~ {\mathbb H}\rightarrow {\mathbb C}\) an automorphic form of weight k / 2 if it satisfies for all \( \gamma \in \Gamma \) the transformation rule

$$\begin{aligned} f|[\gamma ]_{k/2} (z) = \chi (d) f(z), \end{aligned}$$

and \(f(z) \ll y^{\sigma } + y^{1-\sigma }\) for some \(\sigma >0\). A Maaß form is an automorphic form that is an eigenfunction of

$$\begin{aligned} \Delta _{k/2} = - y^2 \left( \frac{\partial ^2}{\partial x^2} + \frac{\partial ^2}{\partial y^2} \right) + i (k/2) y \frac{\partial }{\partial x}, \end{aligned}$$

with eigenvalue \(\lambda = s (1-s)\). We denote the space of such forms by \(\mathcal {A}_s(\Gamma {\setminus } {\mathbb H},k/2,\chi ).\) Their inner product is defined by

$$\begin{aligned} \langle f,g \rangle = \int _{\Gamma \backslash {\mathbb H}} f(z) \overline{g(z)} \frac{\mathrm{d}x \mathrm{d}y}{y^2}. \end{aligned}$$
(5)

Every form f in \(\mathcal {A}_s(\Gamma {\setminus } {\mathbb H},k/2,\chi )\) has a Fourier expansion at the cusp \(\infty \) given by

$$\begin{aligned} f(z)&=\rho ^{+} y^s + \rho ^{-} y^{s-1} + \sum _{n \in {\mathbb Z}, n \ne 0} \rho (n) W_{ \text {sgn}(n)k/4 ,s-1/2} (4 \pi {|{n}|}y)e(nx), \end{aligned}$$
(6)

where \(W_{\alpha ,\beta }(z)\) denotes the standard Whittaker function [12, p. 295]. If the zero coefficient of \(f \in \mathcal {A}_s(\Gamma {\setminus } {\mathbb H},k/2,\chi ) \) vanishes at every cusp, then it is called a Maaß cusp form and the space of such forms is denoted by \(\mathcal {C}_s(\Gamma {\setminus } {\mathbb H},k/2,\chi )\).

3 Proof of Theorem 1

Let \(\{\varphi _{j}=\sum _{n\ge 1} a_{j}(n) e(nz)\}_{j=1}^{d}\) be an orthonormal basis of \(S_{k/2}(N,\chi )\) for odd \(k \ge 5\) and of \(U^{\bot }\) for \(k=3\). Set \(n=tv^2w^2\) with \(\mu ^2(t)=1\), \(v | N^{\infty }\) and \((w,N)=1\). The square part of n coprime to N, w, can be easily handled by (4) since \(({|{a_j(n)}|}^2 \ll w^{k/2-1+\epsilon } {|{a_j(tv^2)}|}^2)\). Therefore, it is sufficient to prove that

$$\begin{aligned} \sum _{j=1}^{d} {|{a_j(n)}|}^2 \ll n^{k/2-1} \left( \frac{t^{3/7}v^{6/7}}{N^{2/7}(n,N)^{1/7}} + \frac{t^{3/8}v^{3/4}}{N^{1/8}(n,N)^{1/4}}+ \frac{v(n,N)}{N}+1 \right) (nN)^{{\epsilon }} \end{aligned}$$

for \(n=tv^2\), with \(\mu ^2(t)=1\) and v arbitrary.

The proof follows the Iwaniec–Duke approach very closely and we assume some familiarity with the article [7]. For \(k\ge 5\), we directly apply the Petersson formula while for \(k=3\), we first embed the weight 3 / 2 cusp forms into the space of Maaß cusp forms of weight 3 / 2 via \(f(x+iy) \mapsto y^{3/4}f(x+iy)\) and then apply the Kuznetsov formula. The Petersson formula for half-integral weights states that [16, p. 89]

$$\begin{aligned} \frac{\Gamma (k/2-1)}{(4 \pi n)^{k/2-1} } \sum _{j=1}^{d} {|{a_j(n)}|}^2 = 1+2 \pi i^{-k/2} \sum _{N | c} c^{-1} J_{k-1}\left( \frac{4 \pi n}{c} \right) K_{\chi }^{k}(n,n;c), \end{aligned}$$

where \(J_{k/2-1}\) is the Bessel function of order \(k/2-1\) and

$$\begin{aligned} K_{\chi }^{k}(m,n;c) = \mathop {\sum \!{\phantom {\sum }}^\prime }_{{d}(\text {mod}\,{c)}} {\epsilon }_d^{-k} \chi (d) \left( \frac{c}{d} \right) e\left( \frac{md + n\bar{d}}{c} \right) \end{aligned}$$
(7)

is a twisted Kloosterman sum. If f(z) is a normalised cusp form for \(\Gamma _0(N)\) with respect to (1), then \([\Gamma _0(Q):\Gamma _0(N)]^{-1/2}f(z)\) is a normalised cusp for \(\Gamma _0(Q)\) provided that N|Q. Instead of applying the Petersson formula for the level N, we use it for higher levels \(Q= pN\) with primes \(p \in \mathcal {P}=\{p\, | \, P< p \le 2P, p \not \mid 2nN \}\). Since \([\Gamma _0(pN):\Gamma _0(N)] \le p+1\), this yields (cf. [7, p. 400])

$$\begin{aligned} \sum _{j=1}^{d} {|{a_j(n)}|}^2 \ll n^{k/2-1} \Bigg ( P + \sum _{p \in \mathcal {P}} \Bigg | \sum _{(pN) | c} c^{-1} K_{\chi }^{k}(n,n;c) J_{k/2-1} \left( \frac{4 \pi n}{c} \right) \Bigg | \text {log}P \Bigg ), \end{aligned}$$
(8)

where we choose \(P > 1+ (\text {log} 2nN)^2\) to ensure that \(\# \mathcal {P} \asymp P (\text {log}P)^{-1}\). After expressing the Bessel function by means of its asymptotic formula and applying partial summation, it remains to find a bound for sums of the type \(\sum _{Q \in {\mathbb Q}} |K_Q(x)|\), where

$$\begin{aligned} K_Q(x) := \sum _{c \le x,\, Q | c} c^{-1/2} K_{\chi }^{k}(m,n;c) e\left( \frac{2\nu n}{c} \right) \end{aligned}$$
(9)

with \(-1 \le \nu \le 1\) and \(Q \in \mathcal {Q} = \{pN \, | \, p \in \mathcal {P} \}\).

First, we factor the modulus c into qr, where q is coprime to 2nN and \(r | (2nN)^{\infty }\). This way, (7) decomposes into a Kloosterman sum of modulus r and a Salié sum of modulus q which is explicitly computable. Very similar to [7, Lemma 6], we obtain

$$\begin{aligned} K_{\chi }^{k}(n,n;c)= & {} q^{1/2} \sum _{\begin{array}{c} s (\text {mod } r/2)\\ 2 \not \mid s \end{array}} {\epsilon }_s^{-2k} f_r(2s,\chi ) \left[ (1+i^s)\left( \frac{nr}{q} \right) + (1-i^s)\left( \frac{-nr}{q} \right) \right] \nonumber \\&\times \sum _{ab=q} e\left( 2n \left( \frac{\overline{ar}}{b}- \frac{\overline{br}}{a} + \frac{s \overline{ab}}{r} \right) \right) . \end{aligned}$$
(10)

The main difference is that

$$\begin{aligned} \nonumber f_r(2s,\chi ) = \sum _{\begin{array}{c} d (\text {mod } r)\\ d+\bar{d}\equiv 2s (\text {mod}\,r) \end{array}} \left( \frac{r}{d} \right) \chi (d). \end{aligned}$$

Lemma 4

For quadratic \(\chi \), one has the following bound

$$\begin{aligned} {|{K_{\chi }^{k}(n,n;c)}|} \le \tau (c) (n,c)^{1/2} c^{1/2}, \end{aligned}$$

while, for arbitrary \(\chi \) one gets an additional factor of \((c_\chi rad (c_\chi ))^{1/4}\) on the right-hand side.

Proof

If we split the sum for \(c=r q, r | 2^{\infty }, (2,q)=1\) we obtain

$$\begin{aligned} K_{\chi }^{k}(n,n;c) = K_{\chi _r}^{k-q+1}(n\bar{q},n\bar{q};r) S_{\chi _{q}} \left( n \bar{r}, n \bar{r} ,q \right) , \end{aligned}$$
(11)

where \(\chi _r\) and \(\chi _q\) are characters modulo r and q, respectively, and the latter sum

$$\begin{aligned} S_{\chi }(n,n;q)= \mathop {\sum \!{\phantom {\sum }}^\prime }_{{d}(\text {mod}\,{q)}} \chi (d) \left( \frac{d}{q} \right) e \left( \frac{n (d+ \bar{d})}{q} \right) \end{aligned}$$

is a Kloosterman sum twisted by a character. For arbitrary \(\chi \), we apply [10, Theorem 9.3] and get \({|{S_{\chi }(n,n;q)}|} \le \tau (q) (n,q)^{1/2} q^{1/2} (q_\chi rad (q_\chi ))^{1/4}\). Since the conductor of a real character with odd modulus is always squarefree, we obtain the Weil bound for real \(\chi \) by applying [10, Proposition 9.4, 9.7 and 9.8], i.e. \({|{S_{\chi }(n,n;q)}|} \le \tau (q ) (n,q)^{1/2} q^{1/2}\). To bound the first term on the right-hand side of (11), we modify [8, Lemma 12.2 and Lemma 12.3]. Therefore, we set \(r=2^{\alpha }\) and assume that \({\alpha }\ge 4\) to ensure that \({\epsilon }_r = {\epsilon }_a\) for \(r = a + b\, 2^{{\beta }}\), where \({\mathbb N}\ni {\beta }= \frac{{\alpha }}{2}\) or \(\frac{{\alpha }-1}{2}\), respectively. By following the argument of Iwaniec very closely, we obtain

$$\begin{aligned} |K_{\chi }^{k}(n,n;2^{{\alpha }})| \le 2^{{\beta }} M, \end{aligned}$$

where M is the number of solutions modulo \(2^{{\beta }}\) of \(-n a^2 + Ba +n \equiv 0~ \text {mod}\, 2^{{\beta }}\) for B defined as in [8, Lemma 12.2 and Lemma 12.3]. To bound M, we proceed as in [10, Lemma 9.6, Proposition 9.7 and Proposition 9.8] obtaining \(|K_{\chi }^{k}(n,n;r)| \le \tau (r) (n,r)^{1/2}r^{1/2}\). \(\square \)

We split \(K_Q(x)\) according to whether t|c. By applying Lemma 4 we get, for quadratic \(\chi \), that

$$\begin{aligned} {|{K_{[t,Q]}(x)}|}&\ll \frac{x(t,Q)(n,[t,Q])^{1/2}}{tQ} \tau (tQ) (xn)^{{\epsilon }} \\ \nonumber&\le \frac{x(t,Q)(v^{2},Q/(Q,t))^{1/2}}{t^{1/2}Q} \tau (tQ) (xn)^{{\epsilon }} \le \frac{x v (n,Q)}{n^{1/2}Q} \tau (tQ) (xn)^{{\epsilon }} \end{aligned}$$

since \((t,Q)^{2} (v^{2},Q/(Q,t))\) divides both \(Q^{2}\) and \(n^{2}\). In particular, one has

$$\begin{aligned} \sum _{Q \in \mathcal {Q}} {|{K_{[t,Q]}(x)}|} \ll xv(n,N) n^{-1/2}N^{-1} (xnN)^{{\epsilon }}. \end{aligned}$$
(12)

For general \(\chi \), we get an additional factor of \((c_{\chi }\text {rad}(c_{\chi }))^{1/4}\) on the right-hand side. The remaining part of \(K_Q(x)\) can be reduced to partial sums of the type

$$\begin{aligned} \nonumber K_Q^{\star }(y) = \sum _{\begin{array}{c} y < c \le 2y \\ t \not \mid c, \,Q | c \end{array}} c^{-1/2} K_{\chi }^{k}(n,n;c)e\left( \frac{2 \nu n}{c} \right) \end{aligned}$$

with \(4 \le y \le x\). There are \(\mathcal {O}( log (x))\) such partial sums. For even t, we trivially estimate \(|K_{[t/2,Q]}(x)|\) and assume that \(K_Q^{\star }(y)\) runs over c with \(\frac{t}{2} \not \mid c\) to ensure that n / (nr) is not a perfect square. By (10) we conclude that

$$\begin{aligned} K_Q^{\star }(y) = \sum _{r \in \mathfrak {R}} r^{-1/2} \sum _{\begin{array}{c} s (\text {mod } r/2)\\ 2 \not \mid s \end{array}} {\epsilon }_s^{-k} f_r(2s) \left[ (1+i^s) F_{r,s}^{+}(p) + (1-i^s)F_{r,s}^{-}(p) \right] , \end{aligned}$$
(13)

where \(\mathfrak {R} = \{r\, ; \, N | r | (2nN)^{\infty } ,\, t \not \mid r \}\) and

$$\begin{aligned} F_{r,s}^{\pm }(p) = \mathop {\sum \sum }_{\begin{array}{c} y < abr \le 2y \\ (a,b)=1, p | ab \end{array}} \left( \frac{\pm nr}{ab} \right) e\left( 2n \left( \frac{\overline{ar}}{b}- \frac{\overline{br}}{a} + \frac{s \overline{ab}}{r} + \frac{\nu }{abr} \right) \right) \end{aligned}$$
(14)

with \((ab,2nN)=1\). We treat \(F_{r,s}^{\pm }(p)\) according to the values of a and b and split it into dyadic ranges \(A < a \le 2A\) and \(B < b \le 2B\) with \(y < rAB \le 2y\) and \(A,B \ge \frac{1}{2}\) which we denote by F(ABp).

For either A or B small, we apply the Weil bound for the Kloosterman sum and estimate trivially. Following [7, p.396] word by word, we get

$$\begin{aligned} F(A,B;p) \ll \left( 1+\frac{n}{y} \right) \sum _{\begin{array}{c} B< b \le 2B \\ (b,2nN)=1 \end{array}} \bigg | \sum _{\begin{array}{c} A_1 < a \le A_2 \\ (a,b)=1 \end{array} } \left( \frac{\pm nr}{a} \right) e\left( 2 n m \frac{\bar{a}}{br} \right) \bigg |, \end{aligned}$$
(15)

with m defined by \(m p_b \equiv r \bar{r} + 1 + s b \bar{b} ( mod\, br)\) and \(A_1,A_2\) such that \(Ap_b = A_1 < A_2 \le 2 A p_b\), where \(p_b := p / (b,p)\). Set \(\delta _1 = \frac{n}{(n,r)}\) and \(\delta _2 = \frac{r}{(n,r)}\). At this point, we cannot proceed as in Iwaniec [7, Section 5] because \(8 | \delta _2\) is generally not satisfied. To solve this, we distinguish three cases:

  • \( 2 \not \mid \delta _1\). Set \(\Delta _1 = \delta _1\) and \(\Delta _2 = 16 \delta _2\).

  • \(\text {ord}_2(\delta _1)=1\) or 2. Set \(\Delta _1 = 2^{-\text {ord}_2(\delta _1)} \delta _1 \) and \(\Delta _2 = 2^{2+\text {ord}_2(\delta _1)}\delta _2\).

  • \(8 | \delta _1 \). Set \(\Delta _1 = \delta _1\) and \(\Delta _2 = \delta _2\).

In each case \(\Delta _1\) and \(\Delta _2\) satisfy that \(\left( \frac{ \pm nr}{a} \right) = \left( \frac{\pm \Delta _1 \Delta _2}{a} \right) \), either \(8 | \Delta _1\) or \(8 | \Delta _2\) and \(\Delta _1, \Delta _2\) and b are pairwise coprime. Set \(2 \frac{n}{r} = 2^{j} \frac{\Delta _1}{\Delta _2}\), where \(j=5\), \(j=3 + 2 \, \text {ord}_2(\delta _1)\) or \(j=1\) according to the corresponding case. Thus, the innermost sum of (15) is equal to

$$\begin{aligned} \sum _{a} := \sum _{A_1 < a \le A_2 } \left( \frac{\pm \Delta _1 \Delta _2}{a} \right) e \left( 2^{j} m\frac{\Delta _1 \bar{a}}{\Delta _2 b} \right) . \end{aligned}$$

By applying [7, (3.14)] it follows for \(D=\Delta _1 \Delta _2 b\) that

$$\begin{aligned} \bigg | \sum _{a} \bigg | \le \sum _{1 \le {|{d}|} \le D/2} \frac{1}{2 {|{d}|}} \Bigg | \sum _{x (\text {mod}D)} \left( \frac{\pm \Delta _1 \Delta _2}{x} \right) e \left( 2^{j} m\frac{\Delta _1 \bar{x}}{\Delta _2 b} + \frac{\mathrm{d}x}{D} \right) \Bigg |. \end{aligned}$$

The sum modulo D can be factored into three sums in the same manner as in [7, p. 396]. Note that \(\Delta _1\) is not a perfect square because there exists an odd prime divisor of t which, by definition of \(\mathfrak {R}\), does not divide r. Therefore, \(x \mapsto \left( \frac{\Delta _1}{x} \right) \) is not the trivial character. By following Iwaniec step by step and making use of \((n,r) ^{-1} \le (n,N)^{-1}\) since N|r, we get

$$\begin{aligned} F(A,B;p) \ll B^{3/2} \left( 1+ \frac{n}{y} \right) (nr)^{1/2} (n,N)^{-1} \tau ^2(r) \text { log}(ny) \end{aligned}$$
(16)

and

$$\begin{aligned} F(A,B;p) \ll A^{3/2} \left( 1+ \frac{n}{y} \right) (nr)^{1/2} (n,N)^{-1} \tau ^2(r) \text { log}(ny). \end{aligned}$$
(17)

If both A and B are large, we make use of the flexibility gained through the averaging over the levels. We want to estimate

$$\begin{aligned} F_P(A,B) = \sum _{p \in \mathcal {P}} |F(A,B;p)|. \end{aligned}$$

Setting \(\lambda _P := \text {sgn} F(A,B;p)\) we get

$$\begin{aligned} F_P(A,B) = \sum _{\begin{array}{c} A<a\le 2A \\ y< abr \le 2y \end{array}} \sum _ {\begin{array}{c} B<b\le 2B \\ (a,b)=1 \end{array}} \sum _{\begin{array}{c} P < p \le 2P \\ p | ab \end{array}} \lambda _P \left( \frac{\pm nr}{ab} \right) e\left( 2n \left( \frac{\overline{ar}}{b}- \frac{\overline{br}}{a} + \frac{s \overline{ab}}{r} + \frac{\nu }{abr} \right) \right) . \end{aligned}$$

To bound this, we follow [7, Section 6] step by step. First, we split the sum according to whether p|a or p|b. In each case we interchange the sums, apply Cauchy–Schwarz to the square and change the sums back. Hence, we have two p-sums. If the summands of both p-sums coincide, we trivially estimate, otherwise we apply the Weil bound. Since [7, Lemma 7] does not hold, we cannot use \((n,r) \le r^{1/2}\) for [7, (6.1)]. Instead, we use \((n,N) \le (n,r) \le r\) and (6.3) from Iwaniec changes to

$$\begin{aligned} F_P(A,B)\ll & {} y r^{-1} P^{-1/2} + \left( 1+\frac{n}{y} \right) ^{1/2} (s^2-1,r)^{1/2} \tau (r)\, \text {log}\,y\nonumber \\&\times \left( y^{7/8}r^{-5/8}P^{3/8} (n,N)^{-1/4} + (A^{-1/2} + B^{-1/2}) y r^{-1} \right) . \end{aligned}$$
(18)

In particular, we lose a factor of \(r^{-1/4}\) in the second term within the bracket. To bound \(K_Q(y)\), we modify [7, Section 7] accordingly and apply (16) and (17) in case that either A or B is

$$\begin{aligned} \le \left( 1+ \frac{n}{y} \right) ^{-1/4} n^{-1/4} r^{-3/4} y^{1/2} P^{-1/2} (n,N)^{1/2}, \end{aligned}$$

respectively, and (18) otherwise and obtain

$$\begin{aligned} \sum _{p \in \mathcal {P}} {|{F_{r,s}^{\pm }(A,B;p)}|}\ll & {} y r^{-1} P^{-1/2} + \left( y + n \right) ^{5/8} r^{-5/8} (n,N)^{-1/4} \\&\times (s^2-1,r)^{1/2} \tau ^2(r) \,(\text {log}\,ny) \left( y^{1/4} P^{3/8} + n^{1/8}y^{1/8}P^{1/4} \right) . \end{aligned}$$

According to (13), it remains to sum this inequality over \(s~(\text {mod}~r/2)\) and \(r \in \mathfrak {R}\). The more general form of \(f_r(2s,\chi )\) does not affect [7, (7.2) and (7.3)]. Hence,

$$\begin{aligned} \sum _{s(\text {mod}\,r/2)} |f_r(2s,\chi )| (s^2-1,r)^{1/2} \ll r \tau ^2(r) \text { and } \sum _{r \in \mathfrak {R}} r^{-1/8} \tau ^4(r) \ll \tau (nN) N^{-1/8}. \end{aligned}$$

Combining this with (12), we conclude, for quadratic \(\chi \), that

$$\begin{aligned} \sum _{Q \in \mathcal {Q}} {|{K_{Q}(x)}|}\ll & {} \Big ( xv (n,N) n^{-1/2} N^{-1} + x P^{-1/2} N^{-1/2}\nonumber \\&+\, (x+n)^{5/8} \big (x^{1/4}P^{3/8} + n^{1/8} x^{1/8} P^{1/4}\big ) N^{-1/8} (n,N)^{-1/4} \Big ) (nxN)^{{\epsilon }}\nonumber \\ \end{aligned}$$
(19)

which is an improvement of [7, Theorem 3]. By (8), we infer

$$\begin{aligned} \sum _j^d {|{a_j(n)}|}^2 \ll n^{k/2-1} \bigg ( \frac{v (n,N)}{N} + P + \frac{n^{1/2}}{P^{1/2} N^{1/2}} + \frac{n^{3/8} P^{3/8}}{N^{1/8} (n,N)^{1/4}} \bigg ) (nNP)^{{\epsilon }}. \end{aligned}$$

Choosing \(P = n^{1/7} (n,N)^{2/7} / N^{3/7} + (nN)^{{\epsilon }}\) yields, for real \(\chi \), that

$$\begin{aligned} \sum _j^d {|{a_j(n)}|}^2 \ll n^{k/2-1} \bigg ( \frac{v (n,N)}{N} + 1 + \frac{n^{3/7}}{(n,N)^{1/7} N^{2/7}} + \frac{n^{3/8}}{N^{1/8} (n,N)^{1/4}} \bigg )(nN)^{{\epsilon }}, \end{aligned}$$

while, for an arbitrary character \(\chi \), the first term changes to \( \frac{v (n,N)}{N} (c_\chi \text {rad}(c_\chi ))^{1/4}. \) This concludes the proof for \(k \ge 5\).

To prove the case \(k=3\) we follow [3, Sections 3 and 5], but include an arbitrary nebentypus \(\chi \). The map \(f(z) \mapsto y^{3/4} f(z)\) induces an injective mapping \(S_{3/2}(N,\chi ) \mapsto C_{3/4}(N,3/2,\chi )\) and one has \(a(n)=(4\pi n)^{3/4} \rho (n)\), where a(n) denote the Fourier coefficients of f and \(\rho (n)\) the coefficients, see (6), of the corresponding Maaß cusp form. Let \(u_i(z)\) be an orthonormal basis of Maaß cusp forms of weight 3 / 2 with eigenvalues \(\lambda _j\) and Fourier coefficients \(\rho _j(n)\) and let \(\{f_{ij}= \sum _{n \ge 1} a_{ij}(n) e(nz)\}_{i=1}^{d_j} \) be an orthonormal basis of \(S_{3/2+2j}(N,\chi )\). Then it holds, by Proskurin’s variant [14, p. 3888] of the Kuznetsov formula, that

$$\begin{aligned} \sum _{N | c} \frac{K_{\chi }^{1}(n,n;c)}{ c} \varphi (4 \pi n / c)= & {} 4n \sum _{\lambda _j >0} \frac{{|{\rho _j(n)}|}^{2}}{\text {cosh}(\pi t_j)} \hat{\varphi }(t_j) \nonumber \\&+\, \sum _{{\mathfrak a}} \int _{-\infty }^{\infty } \frac{{|{\phi _{{\mathfrak a},n}(1/2+it))}|}^{2}}{\text {cosh}(\pi t) {|{\Gamma (1/2+3/4 +it}|}^{2}} \hat{\varphi }(t) dt \nonumber \\&+\, 4 \sum _{j \ge 1} \frac{\Gamma (3/2+2j) e(3/8+j/2) \tilde{\varphi }(3/2+2j)}{(4 \pi )^{3/2+2j} n^{1/2+2j}} \sum _{i=1}^{d_j} {|{a_{ij}(n)}|}^{2}.\nonumber \\ \end{aligned}$$
(20)

Here, \(\varphi (x)\) is a suitable test function, \(\sum _{{\mathfrak a}}\) refers to the summation over the non-equivalent non-singular cusps of \(\Gamma _0(N)\), \(t_j\) is defined by \(s_j = 1/2 + i t_j\) and \(\phi _{{\mathfrak a},n}\) are the coefficients of an Eisenstein series (cf. [14, p. 3876]). Similar to the choice in [4, p. 51], we set \(\varphi (x) = c_0 x^{-7/2} J_{13/2}(x)\) for \(c_0= - 2^{4} e(-3/8) \pi ^{-2} \Gamma (9/2)^{-1}\) and \(J_k(z)\) to denote the Bessel function of order k. This choice fulfils all requirements for the Kuznetsov formula and by means of the Weber–Schafheitlin integral [6, (6.574.2)] it is straightforward to calculate

$$\begin{aligned} \hat{\varphi }(t) = \frac{t^2 + 1/4}{ \text {cosh}(2 \pi t)\Gamma (-1/4+it) \Gamma (-1/4-it) \Gamma \left( 6+it \right) \Gamma \left( 6-it \right) }. \end{aligned}$$

Observe that \(\hat{\varphi }(t) >0\) for \(t \in {\mathbb R}\) and for \(t \in [-i/4 ,i/4]\), the value at \(it=1/4\) defined by

$$\begin{aligned} \lim \limits _{t \rightarrow \pm i /4} \hat{\varphi }(t) = \frac{3}{64 \pi ^{3/2} \Gamma (23/4) \Gamma (25/4)}. \end{aligned}$$

Thus, we may drop all terms of the first sum on the right-hand side of (20) which represent eigenvalues distinct to 3 / 16 as well as the contribution from the continuous spectrum (the integral over the Eisenstein coefficients). Since the weights of \(f_{ij}\) are greater than or equal to 5 / 2, we can use our previous results to bound the last term of (20). As before, we apply Iwaniec’s method of averaging over the levels. If u(z) is a normalised Maaß cusp form for \(\Gamma _0(N)\), then \([\Gamma _0(Q):\Gamma _0(N)]^{-1/2} u(z)\) is a normalised Maaß cusp form for \(\Gamma _0(Q)\), \(Q \in \mathcal {Q}\). Hence, by applying the Kuznetsov formula for every level \(Q \in \mathcal {Q}\), it follows

$$\begin{aligned} n \sum _{\lambda _j=3/16} {|{p_j(n)}|}^{2}\ll & {} \text {log} P \sum _{Q \in \mathcal {Q}} \bigg | \sum _{Q | c} \frac{K_{\chi }^{1}(n,n,c)}{ c} \left( \frac{c}{n} \right) ^{7/2} J_{13/2}\left( \frac{4 \pi n}{c} \right) \bigg | \nonumber \\&+ \left( P+ \frac{n^{1/2}}{P^{1/2} N^{1/2}} + \frac{v (n,N)}{N} + \frac{n^{3/8} P^{3/8}}{N^{1/8} (n,N)^{1/4}} \right) (nNP)^{{\epsilon }}.\nonumber \\ \end{aligned}$$
(21)

Since 13 / 2 is half integral and since for \(x>n\)

$$\begin{aligned} n^{-7/2} \left( x^3 J_{13/2}\left( \frac{4 \pi n}{x} \right) \right) ' \ll n x^{-5/2}, \end{aligned}$$

the right-hand side of (21) can be treated exactly as in [7, Section 8] taking into account (19) and our choice of P. This concludes the proof of Theorem 1.

4 An application

Finally, we give an application of Theorem 1, particularly an improvement of [21, Theorem 1.2]. For this purpose, let A be a positive, integral, symmetric \(k \times k\) matrix with even diagonal elements, let \(q(x) := \frac{1}{2} x^{t} A x\) be the corresponding quadratic form and let N be the level of A, i.e. the smallest integer such that \(N A^{-1}\) is integral with even diagonal. This section aims at finding a lower bound for the Fourier coefficients \(r(q,n) = \# \{x \in {\mathbb Z}^{k} |\, q(x)=n \}\) of \(\theta (q,z)\) to conclude that n is represented by q. By direct computation, one can show that \(\theta (q,z) \in M_{k/2}(N, \chi _{(-1)^{k} \text {det}A} )\) [19, p. 456].

Two positive quadratic forms are in the same genus if they are equivalent over all \({\mathbb Z}_p\). Define the theta series of the genus \(\theta (\text {gen}\,q,z) = \sum _{n = 0}^{\infty } r(\text {gen}\,q,n) e(nz)\) by

$$\begin{aligned} r(\text {gen}\,q,n) = \sum _{\tilde{q}\in \text {gen}\,q} w(\tilde{q}) r(\tilde{q},n) \text { with }w(\tilde{q}) = \left( \sum _{\tilde{q} \in \text {gen}\,q} \frac{1}{\# O_{{\mathbb Z}}(\tilde{q})} \right) ^{-1} \frac{1}{\# O_{{\mathbb Z}}(\tilde{q})}, \end{aligned}$$
(22)

where the summation is taken over a set of representative classes in the genus. Let \(S(z) = \theta (q,z) - \theta (\text {gen}\,q,z)\). Then S(z) is the orthogonal projection of \(\theta (q,z)\) onto the subspace of cusp forms and \(\theta (\text {gen}\,q,z)\) is an Eisenstein series [17, Korollar 1]. Consequently, write

$$\begin{aligned} \theta (q,z) = \theta (\text {gen}\,q,z) + S(z) =: \sum _{n=0}^{\infty } r(\text {gen}\,q,n) e(nz) + \sum _{n=1}^{\infty } a(q,n) e(nz). \end{aligned}$$

We would like to treat \(r(\text {gen}\,q,n)\) as the main term for r(qn) and a(qn) as the error term. To compute the Eisenstein coefficients \(r(\text {gen}\,q,n) \), we use Siegel’s formula [20]. From now on, let \(k=3\). Then

$$\begin{aligned} r(\text {gen}\,q,n) = \frac{2\pi }{\sqrt{\Delta / 8}} n^{1/2} \prod _p r_p(q,n), \end{aligned}$$
(23)

where \(\Delta \) is the determinant of A and \(r_p(q,n)\) are the p-adic densities defined by

$$\begin{aligned} r_p(q,n):= \lim \limits _{\nu \rightarrow \infty } \frac{1}{p^{2\nu }} \# \left\{ x \in ({\mathbb Z}/p^{\nu }{\mathbb Z})^3~ |~ q(x) \equiv n ~(\text {mod\,}p^{\nu })~ \right\} . \end{aligned}$$

Apart from a finite number of cases, \((p,Nn) \ne 1\), the densities are easy to compute [20, Hilfssatz 12]

$$\begin{aligned} r_p(q,n) = 1+ \frac{\chi _{-2n\Delta }}{p}, \quad p \not \mid nN. \end{aligned}$$

The space of theta functions U poses a problem since their Fourier coefficients grow like \(\asymp n^{1/2}\) which is roughly the same size as \(r(\text {gen}\,q,n)\). Thus, to show that n can be represented by a quadratic form q using Theorem 1, it is necessary that the n-th coefficient of the projection of \(\theta (q,z)\) onto U vanishes.

For a ring R let \(O_{R}(q) := \{ S \in GL_{2k}(R) | S^{t}AS = A \}\) be the finite set of R-automorphs of q. Two quadratic forms \(A_1,A_2\) in the same genus with \(A_1 = S^{t} A_2 S\) for \(S \in GL_{k}({\mathbb Z})\) belong to the same spinor genus, if \(S \in O_{Q}(A_2) \bigcap _{p} O'_{Q_p}(A_2)GL_{k}({\mathbb Z}_p)\), where \(O'_{Q_p}(A)\) is the subgroup of p-adic automorphs \(O_{Q_p}(A)\) of determinant and spinor norm 1 (cf. [13, Section 55]). Define the theta series of the spinor genus \(\theta (\text {spn}\,q,z) = \sum _{n = 0}^{\infty } r(\text {spn}\,q,n) e(nz)\) by

$$\begin{aligned} r(\text {spn}\,q,n) = \sum _{\tilde{q} \in \text {spn}\,q} w(\tilde{q}) r(\tilde{q},n) \text { with }w(\tilde{q}) = \left( \sum _{\tilde{q} \in \text {spn}\,q} \frac{1}{\# O_{{\mathbb Z}}(\tilde{q})} \right) ^{-1} \frac{1}{\# O_{{\mathbb Z}}(\tilde{q})}, \end{aligned}$$
(24)

where the summation is taken over a set of representative classes in the spinor genus of q. Schulze-Pillot [17] has shown that the orthogonal projection of \(\theta (q,z)\) onto the subspace of \(U^{\bot }\) is \(\theta (q,z)-\theta (\text {spn}\,q,z)\). Therefore, write

$$\begin{aligned} \theta (q,z) = \theta (\text {gen}\,q,z) + H(z) + f(z), \end{aligned}$$

with \(H(z)= \theta (\text {spn}\,q,z) - \theta (\text {gen}\,q,z)\in U\) and \(f \in U^{\bot }\). The contribution from the Fourier coefficients of f is easy to handle by Theorem 1. If \(r(\text {gen}\,q,n) = r(\text {spn}\,q,n)\), then the n-the Fourier coefficient of H(z) vanishes. This obviously holds when \(n \notin \{ tm^2: 4t | N, m \in {\mathbb N}\}\) since the coefficients of the theta functions vanish. According to the definitions (22) and (24) it follows that \(r(\text {spn}\,q, n) = r(\text {gen}\,q, n)\) is satisfied if

$$\begin{aligned} r(\text {spn}\,q, n) = r(\text {spn}\,q', n) \end{aligned}$$

for all \(q'\) in the same genus as q. According to Schulze-Pillot [17, Korollar 2.3 (ii)] it holds for any \(q,q'\) in the same genus and squarefree t that

$$\begin{aligned} r(\text {spn}\,q, tm^2) = r(\text {spn}\,q', tm^2) \end{aligned}$$

if \(N= 4 t\, t'\, h^2\) with squarefree \(t'\) and h|m. In particular, if N / 4 is squarefree, one has \(\theta (\text {gen}\,q,z) = \theta (\text {spn}\,q,z)\).

Proof of Theorem 2

Let \(\theta (q,z)\) be the theta series of the quadratic form \(q=x^2 + y^2 + 6 P z^2\). Then, \(\theta (q,z) \in M_{3/2}(24P, \chi )\) for a quadratic character \(\chi \) and since 6P is squarefree, it holds that \(\theta (\text {gen}\,q,z) = \theta (\text {spn}\,q,z)\). Thus, the orthogonal projection of \(\theta (q,z)\) onto the subspace of cusp forms is in \(U^{\bot }\). Let \(\{\varphi _j(z)= \sum _{n \ge 1 } a_j(n) e(nz) \}_{j=1}^{d}\) be an orthonormal basis of \(U^{\bot }\). Then

$$\begin{aligned} r(q,n) = r(\text {gen}\,q,n) + \sum _{j=1}^{d} c_j a_j(n) = r(\text {gen}\,q,n) + \mathcal {O}\left( \sqrt{\sum _{j=1}^{d} c_{j}^{2}} \sqrt{\sum _{j=1}^{d} {|{a_j(n)}|}^2}\right) . \end{aligned}$$

From \(\sqrt{\sum _{j=1}^{d} c_{j}^{2}} = \mathcal {O}(P^{1/4+{\epsilon }})\) (cf. [5, Theorem 3]) and Theorem 1, we conclude that

$$\begin{aligned} r(q,n) = r(\text {gen}\,q,n) + \mathcal {O}\left( v^{1/2}\left( t^{13/28}P^{3/28}+t^{7/16} P^{3/16}+ t^{1/4}P^{1/4} \right) \right) (Pn)^{\epsilon }. \end{aligned}$$
(25)

To bound \(r(\text {gen}\,q,n)\) from below, we apply (23), Siegel’s formula. If \(p \not \mid 6P\), it holds by [20, Hilfssatz 16] that

$$\begin{aligned} 1- \frac{1}{p} \le r_p(q,n) \le 1 + \frac{1}{p}. \end{aligned}$$

To treat the remaining densities, \(r_2(n,q),r_3(n,q)\) and \(r_P(n,q)\), we rely on Hensel’s lemma (cf. also [9, Section 15]). \(\square \)

Lemma 5

Assume that \(P \in {\mathbb Z}[x_1,\ldots ,x_d]\) and \(\alpha \in {\mathbb Z}^d\) satisfy \(P(\alpha ) \equiv 0 \mathrm {~mod~} p^{k}\). If it holds for at least one \(x_j\) that

$$\begin{aligned} \frac{\partial f}{\partial x_j}({\alpha }) \ne 0 \mathrm {~mod~}p^{l}\, \text { for some }\, l \le \frac{k+1}{2}, \end{aligned}$$

then \(P(x) \equiv 0 \mathrm {~mod~} p^{k+m}\) has \(p^{m(d-1)}\) integer solutions. Each of these solutions \({\beta }\) satisfies that \( {\beta }_j \equiv \alpha _j {\text {mod}} p^{k-l+1}\) and \({\beta }_i \equiv \alpha _i {\text {mod}} p^{k}\) for all \(i \ne j\).

Proof

The case \(d=1\) is proven in [15, p. 48]. Assume \(j=1\). For each choice \({\beta }_2,\ldots ,{\beta }_d\) mod \(p^{k+m}\) with \({\beta }_i \equiv {\alpha }_1\) mod \(p^k\), we can apply the one-variable case to find \({\beta }_1\) such that \( P({\beta }) \equiv 0 \text { mod } p^{k+m}\). \(\square \)

For \(p=2\), consider the congruence

$$\begin{aligned} x^2 + y^2 + 6 P z^2 \equiv n \text { mod } 8 \end{aligned}$$
(26)

for arbitrary odd n. For each \(x \equiv 1,3 {\text {mod}}4 \ (y \equiv 1,3 {\text {mod}}4)\), there are two possible choices for \(y {\text {mod}}8 \ (x {\text {mod}}8)\) and four possibilities for \(z {\text {mod}} 8\) to solve (26). It follows by Lemma 5 that

$$\begin{aligned} r_2(n,q) \ge \lim \limits _{\nu \rightarrow \infty }{\frac{32 \cdot 2^{2 (\nu -3)}}{2^{2\nu } } } = \frac{1}{2}. \end{aligned}$$

If p is a prime, then \({\mathbb Z}\slash p{\mathbb Z}\) is a finite field. In a finite field of odd order q, every element unequal to zero can be expressed as the sum of two squares in \(q-1\) ways. Hence, for , there exist \(P^2 -P\) solutions of

$$\begin{aligned} x^2 + y^2 + 6 P z^2 \equiv n \text { mod } P, \end{aligned}$$
(27)

with . By Lemma 5 we infer \(r_3(n,q) \ge 2/3\) and \(r_P(n,q) \ge 1 - \frac{1}{P}\). It follows \(r(\text {gen}\,q,n) \gg \frac{n^{1/2-{\epsilon }}}{ P^{1/2}}. \) Thus, the main term of (25) dominates the error term as soon as

$$\begin{aligned} P \le \text {min}(v^{14/17}t^{1/17}, v^{8/11} t^{1/11} ,v^{2/3}t^{1/3})^{1-{\epsilon }} . \end{aligned}$$

If this holds true, it follows that \(x^2+y^2+6Pz^2=n\) has a solution in \({\mathbb Z}^{3}\). Furthermore, we may assume that xy and z are natural numbers since the number of integer solutions of \(x^2+y^2=n\) is \(\mathcal {O} (n^{{\epsilon }})\).

Proof of Theorem 3

We keep the notation from Wooley [21, Section 3] and modify only the parts concerning the bound of Golubeva’s theorem. The necessary requirements to apply Theorem 2, \((i)\, NM^{12}> p^{17}, (ii)\,NM^6 > p^{11}\) and \((iii)\, N>p^{3}\), are fulfilled provided that (cf. [21, p. 14])

  1. (i)

    \(\gamma _0(6/c+1) - 4/c - {\epsilon }> 17 \gamma _0 - 34/3 + {\epsilon },\)

  2. (ii)

    \(\gamma _0(3/c+1) - 2/c - {\epsilon }> 11 \gamma _0 - 22/3 + {\epsilon }\) and

  3. (iii)

    \(\gamma _0 - {\epsilon }> 3 \gamma _0 - 2 + {\epsilon }. \)

These inequalities yield the following conditions

$$\begin{aligned} (\mathrm{i}) ~\gamma _0< \frac{34 c -12 -6 c {\epsilon }}{48c-18}, ~ (\mathrm{ii})~ \gamma _0< \frac{22c - 6 -6 c {\epsilon }}{30c-9} \text { and } (\mathrm{iii})~ \gamma _0 <1 - 2 {\epsilon }. \end{aligned}$$

Assuming the Riemann hypothesis, Wooley chooses \(c=2+2{\epsilon }\) (cf. [21, p.15]). With this choice and \({\epsilon }\) sufficiently small, the conditions are satisfied as long as \(\gamma _0 < 28/39= \mathrm {min}(28/39,38/51,1)\). Otherwise, without assuming the Riemann hypothesis, the choice is \(c=\frac{12}{5}+2 {\epsilon }\), and it follows \(\gamma _0 < 58/81 = \mathrm {min}(58/81,26/35,1)\). The rest of the proof can be conducted exactly as in [21, Section 3]. \(\square \)