1 Introduction

Throughout this paper, we let \( k\ge 1 \) and \( N\ge 4 \) be integers and \( 4\mid N \). We denote by \( S_{k+1/2}(N,\psi ) \) the space of cusp forms of weight \( k+1/2 \) for the group \( \Gamma _{0}(N) \) with a Dirichlet character \( \psi \) modulo N and \( S_{3/2}^{*}(N,\psi ) \) the orthogonal complement with respect to the Petersson scalar product of the subspace \( U(N,\psi ) \) generated by unary theta functions. We also set \( S^{*}_{k+1/2}(N,\psi )=S_{k+1/2}(N,\psi ) \) for \( k\ge 2 \).

Each \( \mathfrak {f}\in S_{k+1/2}^{*}(N,\psi ) \) has a Fourier expansion given by

$$\begin{aligned} \mathfrak {f}(z)=\sum \limits _{n=1}^{\infty }\mathfrak {a}_{\mathfrak {f}}(n)q^{n}, \end{aligned}$$

where \( q:=e^{2\pi iz} \) with \( z\in \mathbb {H} \), the complex upper half-plane. Under the assumption that \(\mathfrak {a}_{\mathfrak {f}}(n)\in \mathbb {R}\), many authors have studied the change of signs \({\text {sgn}}\left( \mathfrak {a}_{\mathfrak {f}}(n)\right) \) as n runs through natural sequences (see for instance [3, 9, 11, 13, 15]). For example, in [14, Theorem 1] it was shown that for a squarefree positive integer t, if \(\mathfrak {a}_{\mathfrak {f}}(t)\ne 0\) for some \(\mathfrak {f}\in S_{k+1/2}^*(N,\psi )\), then there are infinitely many sign changes in the sequence

$$\begin{aligned} \left( \mathfrak {a}_{\mathfrak {f}}\left( tp_n^2\right) \right) _{n=1}^{\infty }, \end{aligned}$$
(1.1)

where \(p_n\) is the n-th prime. Formally, given a real sequence \( \{a(n)\}_{n=1}^{\infty } \), we say that \( \{a(n)\}_{n=1}^{\infty } \) exhibits or has a sign change at \(n_0\in \mathbb {N}\) (or between \(n_0\) and \(n_0+1\)) if \( a(n_{0})a(n_{0}+1)<0\). Letting \(K:=\mathbb {Q}\left( \sqrt{D}\right) \) be a quadratic extension of \(\mathbb {Q}\), where \(1\ne D\in \mathbb {Z}\) is a fundamental discriminant, it is natural to ask whether there are infinitely many sign changes when the sequence (1.1) is restricted to the subsequence \(\mathfrak {a}_{\mathfrak {f}}\left( tp^2\right) \) with p running over all split (resp. inert) primes in the ring of integers \(\mathcal {O}_{K}\), or even more generally in arithmetic progressions \(p\equiv m\pmod {M}\) for some fixed m and M. Since p is split (resp. inert) in \(\mathcal {O}_K\) if and only if \(\chi _D(p)=1\) (resp. \(\chi _D(p)=-1\)), where \(\chi _D(n):=(D/n)\) denotes the Kronecker–Jacobi–Legendre symbol, we let \(p_{D,n,+}\) denote the n-th prime which is split in \(\mathcal {O}_K\) and \(p_{D,n,-}\) denote the n-th prime which is inert in \(\mathcal {O}_K\). For each \(\varepsilon \in \{\pm \}\), we investigate sign changes across the sequences

$$\begin{aligned} \left( \mathfrak {a}_{\mathfrak {f}}\left( tp_{D,n,\varepsilon }^2\right) \right) _{n=1}^{\infty }. \end{aligned}$$
(1.2)

Theorem 1.1

Let \( k\ge 1 \) be an integer, \( N\ge 4 \) an integer divisible by 4, and \( \psi \) be a Dirichlet character modulo N. Suppose that \(\mathfrak {f}\in S_{k+1/2}^*(N,\psi )\) has real Fourier coefficients and \(t\ge 1\) is a squarefree integer such that \(\mathfrak {a}_{\mathfrak {f}}(t)\ne 0\). If D is a fundamental discriminant for which there exists an odd prime \(\ell \mid D\) with \(\ell \not \mid N\), then there are infinitely many sign changes in both of the sequences

$$\begin{aligned} \left( \mathfrak {a}_{\mathfrak {f}}\left( tp_{D,n,+}^2\right) \right) _{n=1}^{\infty } \end{aligned}$$

and

$$\begin{aligned} \left( \mathfrak {a}_{\mathfrak {f}}\left( tp_{D,n,-}^2\right) \right) _{n=1}^{\infty }. \end{aligned}$$

More specifically, there exists a small constant \( \delta =\delta _{\mathfrak {f},t,D}>0 \) such that for sufficiently large x, there is a sign change with \(p_{D,n,\varepsilon }\) in the interval \([x^{\delta },x]\).

In order to describe the existence or non-existence of sign changes when every odd prime dividing D also divides the level of the cusp form \(\mathfrak {f}\in S_{k+1/2}^*(N,\psi )\), we require the Shimura lift [17]. For a squarefree positive integer t, \( \mathfrak {f} \) can be lifted to a cusp form \( f_{t}\in S_{2k}(N/2,\psi ^{2}) \)

$$\begin{aligned} f_{t}(z)=\sum \limits _{n=1}^{\infty }a_{f_{t}}(n)q^{n} \end{aligned}$$

by the t-th Shimura correspondance. Here the n-th coefficient \( a_{f_{t}}(n)\) of \( f_{t} \) is given by

$$\begin{aligned} a_{f_{t}}(n)=\sum \limits _{d\mid n}\psi _{t,N}(d)d^{k-1}\mathfrak {a}_{\mathfrak {f}}(t\dfrac{n^{2}}{d^{2}}), \end{aligned}$$
(1.3)

where \( \psi _{t,N} \) denotes the character

$$\begin{aligned} \psi _{t,N}(d):=\psi (d)\left( \dfrac{(-1)^{k}t}{d}\right) . \end{aligned}$$

Thus in particular

$$\begin{aligned} a_{f_t}(p)=\psi _{t,N}(p) p^{k-1}\mathfrak {a}_{\mathfrak {f}}(t)+\mathfrak {a}_{\mathfrak {f}}\left( tp^2\right) . \end{aligned}$$
(1.4)

We also require some properties of quadratic twists of modular forms. For a modular form f with Fourier expansion (\(q:=e^{2\pi i z}\))

$$\begin{aligned} f(z)=\sum _{n\ge 1}a_f(n) q^n \end{aligned}$$

and a character \(\chi \), define the twist of f by \(\chi \) by

$$\begin{aligned} (f\otimes \chi )(z):=\sum _{n\ge 1} \chi (n)a_f(n) q^n. \end{aligned}$$
(1.5)

If f is a primitive form, then \(f\otimes \chi \) is a Hecke eigenform, but not necessarily primitive. We write \(f_{\chi }^{\star }\) for the primitive form associated to the twist \(f\otimes \chi \) (see Remark 2.2 for details). Also, we say that two characters \( \chi _{1} \) and \( \chi _{2} \) are almost equal if \( \chi _{1}(p)=\chi _{2}(p) \) for all primes p not dividing their smallest positive periods and denote it by \( \chi _{1}\simeq \chi _{2} \). Otherwise, we say that \( \chi _{1} \) and \( \chi _{2} \) are not almost equal and denote it by \( \chi _{1}\not \simeq \chi _{2} \).

Theorem 1.2

Let \( k\ge 1 \) be an integer, \( N\ge 4 \) an integer divisible by 4, and \( \psi \) be a Dirichlet character modulo N. Suppose that \(\mathfrak {f}\in S_{k+1/2}^*(N,\psi )\) has real Fourier coefficients and \(t\ge 1\) is a squarefree integer such that \(\mathfrak {a}_{\mathfrak {f}}(t)\ne 0\). Let \(D\ne 1\) be a fundamental discriminant for which every odd prime dividing D also divides N. Then the following hold.

  1. (1)

    The sequence (1.2) (with \(\varepsilon =\pm \) fixed) restricted to the primes \(p\not \mid N\) does not exhibit sign changes if and only if \(\psi _{t,N}\simeq \chi _{D}^{j}\) with \( j\in \{0,1\} \) and the t-th Shimura correspondence \( f_{t} \) satisfies

    $$\begin{aligned} f_t\otimes \chi _{N^2}= \sum _{i} c_i\left( f_i-\varepsilon \left( f_i\right) _{\chi _D}^{\star }\right) \otimes \chi _{N^2} \end{aligned}$$
    (1.6)

    for some \(c_i\in \mathbb {C}\) and where \(f_i\) runs through a full set of primitive forms of level \(M\mid N\). Moreover, if (1.2) does not exhibit sign changes for \(\varepsilon \), then it does exhibit sign changes for \(-\varepsilon \). There is at most one squarefree t for which no sign changes occur and, if it exists, \(t\mid N\).

  2. (2)

    There exists a choice of N, \(t\ge 1\) squarefree, a Dirichlet character \(\psi \) modulo N, a fundamental discriminant \(D\ne 1\), and \(\mathfrak {g}\in S_{3/2}^*(N,\chi )\) such that \(\mathfrak {a}_{\mathfrak {g}}\left( tp_{D,n,\varepsilon }^2\right) \) exhibits sign changes for precisely one of \(\varepsilon =\pm \).

Remark 1.3

The twist by \(\chi _{N^2}\) in Theorem 1.2 (1) precisely annihilates the coefficients that are not relatively prime to the level, which do not affect the sign changes except for possibly finitely many primes dividing N and not dividing D.

If \(f_i\) and \(f_i^{\star }=f_j\) are both newforms of level dividing N, then the term \(f_i-\varepsilon f_i^{\star }\) occurs twice (once for i and once for j) unless \(f_i=f_i^{\star }\), in which case we say that \(f_i\) has CM by \(\chi _D\) (see (2.1)).

Note that although Theorem 1.2 (1) gives an if and only if statement, it is not immediately clear that the conditions are consistent with the assumption that \(\mathfrak {a}_{\mathfrak {f}}(t)\ne 0\). The existence of such a form is the content of Theorem 1.2 (2). The counterexample from Theorem 1.2 (2) is constructed via the theory of quadratic forms, and in particular spinor genus theory. Although we only construct one explicit example, many can be constructed in an analogous way.

We determine a precise criterion which implies alternation of the coefficients in both cases and obtain Theorem 1.1 by showing that the criterion cannot be satisfied in this case; to obtain Theorem 1.2 (1) we need to determine precisely when this criterion holds. Arguing via orthogonality of characters, one should be able to generalize the results in this paper to show that there are sign changes in arithmetic progressions \(p\equiv m\pmod {M}\) as long as \(\gcd (M,N)=1\), but the counterexample in Theorem 1.2 (2) implies that the gcd condition is necessary.

It might be interesting to investigate sign changes of Fourier coefficients of integral weight cusp forms across split or inert primes or arithmetic progressions as well.

The paper is organized as follows. In Sect. 2, we give some preliminaries and necessary information about quadratic twists. In Sect. 3 we give some useful information about the growth of convolution L-functions. In Sect. 4, we investigate the case when not every prime dividing D divides the level of the modular form, proving Theorem 1.1. In Sect. 5, we investigate the case when all of the divisors of D divide the level, proving Theorem 1.2.

2 Preliminaries

2.1 Modular Forms and Quadratic Twists

Let \( \gamma = \begin{pmatrix} a &{} b \\ c &{} d \end{pmatrix}\in {\text {SL}}_{2}(\mathbb {Z})\) and \( z\in \mathbb {H} \). A fractional linear transformation is defined by \(\gamma z:=\dfrac{az+b}{cz+d}\). Write \( j(\gamma ,z):=cz+d \). For a finite-index subgroup \( \Gamma \subseteq SL_{2}(\mathbb {Z}) \) and a weight \( w\in \mathbb {R} \), a multiplier system (we may omit the multiplier if it is trivial) is defined as a function \( \nu :\Gamma \rightarrow \mathbb {C} \) such that

$$\begin{aligned} \nu (\gamma A)j(\gamma A,z)^{w}=\nu (A)j(A,\gamma z)^{w}\nu (\gamma )j(\gamma ,z)^{w} \end{aligned}$$

for all \( \gamma ,A\in \Gamma \) and \(|\nu (\gamma )|=1\). Here and throughout we take the principal branch \(Z^w:=|Z|^w e^{iw{\text {Arg}}(Z)}\) with \(-\pi < {\text {Arg}}(Z)\le \pi \). Also, the slash operator \( |_{w,\nu } \) of weight w and multiplier system \( \nu \) is defined as

$$\begin{aligned} f|_{w,\nu }\gamma :=\nu (\gamma )^{-1}j(\gamma ,z)^{-w}f(\gamma z). \end{aligned}$$

We call elements of \(\Gamma \backslash \mathbb {Q}\cup \{i\infty \}\) the cusps of \(\Gamma \). For any cusp \(\varrho \) of \(\Gamma \), we let \(\sigma =\sigma _{\varrho }\in \mathbb {Q}\cup \{i\infty \}\) be a representative and choose a matrix \(\gamma _{\sigma }\) that sends \(i\infty \) to \(\sigma \). We say that f grows at most polynomially towards the cusp \(\varrho \) (or \(\sigma \)) if there exists \(r\in \mathbb {R}\) such that

$$\begin{aligned} {\text {Im}}(y)^rf\big |_{w}\gamma _{\sigma }(z) \end{aligned}$$

is bounded as \(y\rightarrow \infty \).

Using the above notation, we may give a general definition of modular forms that includes both integral and half-integral weight. A holomorphic modular form of weight \( w\in \mathbb {R} \) and multiplier system \( \nu \) for the subgroup \( \Gamma \) is a function \( f:\mathbb {H}\rightarrow \mathbb {C} \) satisfying the following:

  1. (1)

    f(z) is holomorphic on \( \mathbb {H} \);

  2. (2)

    \( f|_{w,\nu }\gamma =f\) for all \( \gamma \in \Gamma \);

  3. (3)

    f grows at most polynomially towards every cusp.

If moreover f vanishes at every cusp, then f is called a cusp form.

We are particularly interested in the case when w is a half-integer and \(\Gamma =\Gamma _0(L)\), where

$$\begin{aligned} \Gamma _0(L):=\left\{ \begin{pmatrix} a &{} b \\ c &{} d \end{pmatrix}\in {\text {SL}}_{2}(\mathbb {Z}): L\mid c\right\} . \end{aligned}$$

The theta multiplier is defined by

$$\begin{aligned} \nu _{\Theta }:=\frac{\Theta (\gamma z)}{j(\gamma ,z)^{\frac{1}{2}} \Theta (z)}, \end{aligned}$$

where \(\Theta \) is the usual weight 1/2 unary theta function

$$\begin{aligned} \Theta (z):=\sum _{n\in \mathbb {Z}} q^{n^2}. \end{aligned}$$

For a character \(\psi :\mathbb {Z}\rightarrow \mathbb {C}\) and \(w\in \frac{1}{2}\mathbb {Z}\), we define the multiplier system

$$\begin{aligned} \nu _{\psi ,w}(\gamma ):=\psi (d) \nu _{\Theta }^{2w} \end{aligned}$$

and call any modular form of weight w and multiplier system \(\nu _{\psi ,w}\) on \(\Gamma =\Gamma _0(L)\) a modular form of weight w with level L and Nebentypus character (or just character) \(\psi \). Let \( S_{k}(L,\psi ) \) be the space of holomorphic cusp forms of integral weight \( k\ge 2 \) and level L and Nebentypus \( \psi \). We denote by \( L^{*} \) the conductor of the character \( \psi \) and by \( S_{k}^{new}(L,\psi ) \) the orthogonal complement with respect to the Petersson inner product of the subspace generated by all forms \( g(\ell z) \), where \( g\in S_{k}(M,\psi _{M}) \) has a strictly lower level \(M\mid L \) and \( L^{*}\mid M \). If \( f\in S_{k}^{new}(L,\psi ) \) is a common eigenfunction for all Hecke operators and its first coefficient equals one, then f is called a primitive form. We denote by \( H_{k}^{*}(L,\psi ) \) the set of all primitive forms of weight k, level L and Nebentypus \( \psi \).

We require some properties of quadratic twists of modular forms. For a real character \(\chi =\chi _D\), we say that a Hecke eigenform f has CM by \(\chi \) (or CM by the field \(\mathbb {Q}(\sqrt{D})\)) if \(a_f(p)=0\) whenever p is a prime for which \(\chi (p)=-1\), or in other words if

$$\begin{aligned} f\otimes \chi =f. \end{aligned}$$
(2.1)

The following is well known, but we supply a proof for the convenience of the reader.

Proposition 2.1

Let \( \chi \) be a Dirichlet character modulo q. If \( f\in S_{k}(M,\psi ) \) is a Hecke eigenform, then \( f\otimes \chi \in S_{k}(Mq^{2},\psi \chi ^{2}) \) is also a Hecke eigenform.

Proof

Write \( a_{f}(n) \) for the n-th Fourier coefficient of f and \( T_{m} \) for the m-th Hecke operator as usual. If \( f\in S_{k}(M,\psi ) \), then \( f\otimes \chi \in S_{k}(Mq^{2},\psi \chi ^{2})\) by [12, Proposition 17 (b), p. 127]. Since f is a Hecke eigenform, we have

$$\begin{aligned} a_{f}(p^{n+1})=a_{f}(p)a_{f}(p^{n})-\psi (p)p^{k-1}a_{f}(p^{n-1}) \end{aligned}$$

for all primes p and \( n\ge 1 \). Also, \( a_{f}(d_{1}d_{2})=a_{f}(d_{1})a_{f}(d_{2}) \) for any \( d_{1},d_{2}\in \mathbb {N} \) with \( \gcd (d_{1},d_{2})=1 \), i.e., \( a_{f}(n) \) is multiplicative. Combining this with the fact that \( \psi (d)d^{k-1} \) is completely multiplicative, we furthermore have

$$\begin{aligned} \sum \limits _{d\mid \gcd (n,m)} \psi (d) d^{k-1}a_{f}\left( \dfrac{nm}{d^{2}}\right) =a_{f}(m)a_{f}(n) \end{aligned}$$

by [1, Exercises 30, 31, pp. 49–50]. Hence one can check that

$$\begin{aligned} a_{T_{m}(f\otimes \chi )}(n)&=\sum \limits _{d\mid \gcd (n,m)} (\psi \chi ^{2})(d) d^{k-1}a_{f}(\dfrac{nm}{d^{2}})\chi (\dfrac{nm}{d^{2}})\\&=\chi (mn) \sum \limits _{d\mid \gcd (n,m)} \psi (d) d^{k-1}a_{f}(\dfrac{nm}{d^{2}})\\&=\chi (m)\chi (n)a_{f}(m)a_{f}(n)\\&=\chi (m)a_{f}(m)a_{f\otimes \chi }(n) \end{aligned}$$

for all \( m\in \mathbb {N} \). \(\square \)

Remark 2.2

Given a Dirichlet character \( \chi \) modulo q, if \( f\in S_{k}(M,\psi ) \) is a primitive form, then \( f\otimes \chi \in S_{k}(Mq^{2},\psi \chi ^{2}) \) is a Hecke eigenform by Proposition 2.1. In general, \( f\otimes \chi \) may not be primitive, but there exists a unique primitive form \( f^{\star }\in S_{k}(M^{\prime },\psi ^{\star }) \) with \( M^{\prime }\mid Mq^{2} \) such that \( \psi \chi ^{2}(n)=\psi ^{\star }(n) \) and \( a_{f\otimes \chi }(n)=a_{f^{\star }}(n) \) for any n prime to \( Mq^{2} \). [8, REMARK (2), p. 133 and EXERCISE 5, p. 376].

Given a Dirichlet character \( \chi \) and a Hecke eigenform f, we denote by \( f_{\chi }^{\star } \) (or simply \( f^{\star } \), when the context is clear) the primitive form induced by a cusp form \( f\otimes \chi \) as in Remark 2.2. In particular, if \( f\otimes \chi \) is primitive, then \( f_{\chi }^{\star }=f\otimes \chi \). When \( \chi \) is real, \( (f^{\star })^{\star }=f \).

Although \(f\otimes \chi \) need not be primitive, it is primitive under certain conditions. Specifically, from [8, Proposition 14.19 and 14.20], if \( f\in H_k^{*}(M,\psi ) \) and \( \chi \) is a primitive character modulo q with \( \gcd (q,M)=1 \), then \( f\otimes \chi \in H_{k}^{*}(Mq^{2},\psi \chi ^{2}) \).

Lemma 2.3

Let \(k,M\in \mathbb {N}\) and \(\psi \) and \(\chi \) be characters such that the conductor of \(\psi \) divides M and there exists a prime \(\ell \) such that \(\ell \) divides the conductor of \(\chi \) but \(\ell \) does not divide M. Then for any \(f\in H_{k}^*(M,\psi )\), we have that \(f_{\chi }^{\star }\in H_{k}^{*}\left( M'\ell ^2,\psi \chi ^2\right) \) for some \(M'\in \mathbb {N}\).

In particular, if \(\chi \) is real, f does not have CM by \(\chi \) and if \(g\in H_{k}^*(N,\psi ')\) with \(\ell ^2\not \mid N\) or \(\psi '\ne \psi \), then \(g\ne f^{\star }\).

Proof

Note that if \(\chi =\chi _1\chi _2\), then

$$\begin{aligned} f_{\chi }^{\star }=f_{\chi _1\chi _2}^{\star }=\left( f_{\chi _1}^{\star }\right) _{\chi _2}^{\star }. \end{aligned}$$
(2.2)

Let \(\ell \mid q\) with \(\ell \not \mid M\) be given and split \(\chi =\chi _1\chi _2\) so that the conductor \(q'\) of \(\chi _1\) is relatively prime to \(\ell \) and the conductor of \(\chi _2\) is an \(\ell \)-power \(\ell ^r\). Note that since \(h:=f_{\chi _1}^{\star }\) is primitive and its level \(M_{h}\) (dividing \(M q'^2\)) is relatively prime to \(\ell \),

$$\begin{aligned} f_{\chi _1}^{\star }\otimes \chi _2 \end{aligned}$$

is primitive of level \(M_{h}\ell ^{2r}\). Since \(r\ge 1\), we see by (2.2) that

$$\begin{aligned} f_{\chi }^{\star }=\left( f_{\chi _1}^{\star }\right) _{\chi _2}^{\star }=f_{\chi _1}^{\star }\otimes \chi _2 \end{aligned}$$

has \(\ell ^2\) dividing its level. This is the first claim.

Since \(\ell ^2\not \mid M\), we immediately obtain that \(f\ne f^{\star }\), so f does not have CM by \(\chi \). Finally, if \(g\in H_{k}^{*}(N,\psi ')\) and \(\ell ^2\not \mid N\), then we immediately obtain that \(g\ne f^{\star }\), as they have different levels. If \(\psi '\ne \psi \), then they are not equal because they have different Nebentypus. \(\square \)

2.2 Quadratic Forms

Let V be a quadratic space over \( \mathbb {Q} \) associated with a symmetric bilinear map \( B:V\times V\rightarrow \mathbb {Q} \) and write \( Q(x)=B(x,x) \), \( x\in V \). We denote by O(V) the orthogonal group of V and \( O^{\prime }(V) \) the kernel of the homomorphism \( \theta :O(V)\rightarrow \mathbb {Q}^{\times }/\mathbb {Q}^{\times 2} \) as usual. Let \(O_{\mathbb {A}}(V) \) and \( O_{\mathbb {A}}^{\prime }(V) \) be the adelic groups of O(V) and \( O^{\prime }(V) \), respectively. Let L be a \( \mathbb {Z} \)-lattice on V. We define the class \( \text{ cls }\,(L) \), spinor genus \( \text{ spn }\,(L) \) and genus \( \text{ gen }\,(L) \) of L by the orbits of L under the actions of O(V) , \( O(V)O_{\mathbb {A}}^{\prime }(V) \) and \( O_{\mathbb {A}}(V) \) respectively [see [10] for more details].

For \( n\in \mathbb {N} \), if there exists some \( x_{0}\in L \) such that \( Q(x_{0})=n \), then we say that n is represented by L and denote by r(nL) the number of representation of n by L. Also, we define the number of representations of n by the genus (resp. spinor genus) of L by the Siegel–Weil average

$$\begin{aligned} r(n,\text{ gen }\,(L)):=&\left( \sum \limits _{\tiny K\in \text{ gen }\,(L)}\dfrac{1}{|O(K)|}\right) ^{-1}\sum \limits _{\tiny K\in \text{ gen }\,(L)}\dfrac{r(n,K)}{|O(K)|} \end{aligned}$$

and

$$\begin{aligned} r(n,\text{ spn }\,(L)):=&\left( \sum \limits _{\tiny K\in \text{ spn }\,(L)}\dfrac{1}{|O(K)|}\right) ^{-1}\sum \limits _{\tiny K\in \text{ spn }\,(L)}\dfrac{r(n,K)}{|O(K)|}, \end{aligned}$$

where the summuation is over a complete set of representatives of the classes in the genus (resp. spinor genus) of L. A quadratic form Q can be always associated with a lattice \( L_{Q} \) and hence we abuse the notations r(nQ) , \( r(n,\text{ gen }\,(Q)) \) and \( r(n,\text{ spn }\,(Q)) \) standing for \( r(n,L_{Q}) \), \( r(n,\text{ gen }\,(L_{Q})) \) and \( r(n,\text{ spn }\,(L_{Q})) \).

For a ternary quadratic form Q of discriminant D and level N, the theta series \( \theta _{Q} \) associated with Q is given by

$$\begin{aligned} \theta _{Q}(z):=\sum \limits _{n=0}^{\infty }r(n,Q)q^{n}, \end{aligned}$$

and \(\theta _{Q}\in M_{3/2}(N,\psi ) \) for an appropriate \(\psi \) (see for example [17, Proposition 2.1]). It is well known that the theta series can be expressed as

$$\begin{aligned} \theta _{Q}(z)=E(z)+H(z)+f(z), \end{aligned}$$
(2.3)

where \( E(z)=\sum \limits _{n=0}^{\infty }a_{E}(n,Q)q^{n} \) is in the space spanned by Eisenstein series, \( H(z)=\sum \limits _{n=0}^{\infty }a_{H}(n,Q)q^{n}\in U(N,\psi ) \) and \( f(z)=\sum \limits _{n=0}^{\infty }a_{f}(n,Q)q^{n}\in S_{3/2}^{*}(N,\psi ) \) ( [5, Lemma 4]). In the theory of quadratic forms, the coefficients \( a_{E}(n,Q) \) and \( a_{H}(n,Q) \) can be interpreted as (see for example [5, Theorem 2]),

$$\begin{aligned} a_{E}(n,Q)=r(n,\text{ gen }\,(Q))\qquad \text {and}\qquad a_{H}(n,Q)=r(n,\text{ spn }\,(Q))-r(n,\text{ gen }\,(Q)). \end{aligned}$$
(2.4)

3 Convolution L-Series

Hereafter, we assume that all the summations involving the notation p run over the specific subsets of all the primes. The following lemma follows immediately by replacing f by \(f\otimes \chi \) in [14, Lemma 2.1] and it agrees with their results when \( \chi \) is a trivial character.

Lemma 3.1

Let \(f\in H_{k}^{*}(M_{f},\psi _{f})\) and \( g\in H_{k}^{*}(M_{g},\psi _{g})\) whose n-th coefficients are \( \lambda _{f}(n)n^{(k-1)/2} \) and \( \lambda _{g}(n)n^{(k-1)/2} \). Let \( \chi \) be a primitive character modulo q and \( \gcd (q,M_{f})=1 \). Then as \( x\rightarrow \infty \), we have

$$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \end{array}}\dfrac{\chi (p)\lambda _{f}(p)}{p}=O(1) \end{aligned}$$
(3.1)

and

$$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \end{array}}\dfrac{|\lambda _{f}(p)|^{2}}{p}=\log \log x +O(1). \end{aligned}$$
(3.2)

If \( g\not =f\otimes \chi \), then as \( x\rightarrow \infty \), we have

$$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \end{array}}\dfrac{\chi (p)\lambda _{f}(p)\overline{\lambda _{g}(p)}}{p}=O(1). \end{aligned}$$
(3.3)

The implied constants in (3.1) and (3.2) depend on the form f and the character \( \chi \) and that in (3.3) depends on the forms fg and the character \( \chi \).

Although a primitive form f twisted with the character \(\chi \) may not be primitive in general, we are still able to make use of [14, Lemma 2.1] by taking \( f^{\star } \) instead of \( f\otimes \chi \) from Remark 2.2.

Lemma 3.2

Let \(f\in H_{k}^{*}(M_{f},\psi _{f})\) and \( g\in H_{k}^{*}(M_{g},\psi _{g})\) whose n-th coefficients are \( \lambda _{f}(n)n^{(k-1)/2} \) and \( \lambda _{g}(n)n^{(k-1)/2} \). Let \( \chi \) be a primitive real character modulo q and \( f^{\star }\) the primitive form induced by \( f\otimes \chi \).

  1. (1)

    As \( x\rightarrow \infty \), we have

    $$\begin{aligned} \begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \\ \chi (p)=\pm 1 \end{array}} \dfrac{\lambda _{f}(p)}{p}=O(1). \end{aligned} \end{aligned}$$
    (3.4)
  2. (2)

    If f does not have CM by \(\chi \), then as \(x\rightarrow \infty \), we have

    $$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \\ \chi (p)=\pm 1 \end{array}} \dfrac{\lambda _{f}(p)\overline{\lambda _{f}(p)}}{p}&=\dfrac{1}{2}\log \log x+O(1),\end{aligned}$$
    (3.5)
    $$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \\ \chi (p)=\pm 1 \end{array}} \dfrac{\lambda _{f}(p)\overline{\lambda _{f^{\star }}(p)}}{p}&=\pm \dfrac{1}{2}\log \log x+O(1). \end{aligned}$$
    (3.6)

    If f has CM by \(\chi \), then as \( x\rightarrow \infty \), we have

    $$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \\ \chi (p)=\pm 1 \end{array}} \dfrac{\lambda _{f}(p)\overline{\lambda _{f}(p)}}{p}= \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \\ \chi (p)=\pm 1 \end{array}} \dfrac{\lambda _{f}(p)\overline{\lambda _{f^{\star }}(p)}}{p}=\frac{1\pm 1}{2} \log \log x+O(1). \end{aligned}$$
    (3.7)

    If \( g\not =f \) and \( g\ne f^{\star } \), then as \( x\rightarrow \infty \), we have

    $$\begin{aligned} \begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \\ \chi (p)=\pm 1 \end{array}} \dfrac{\lambda _{f}(p)\overline{\lambda _{g}(p)}}{p}=O(1). \end{aligned} \end{aligned}$$
    (3.8)
  3. (3)

    Suppose that there exists an odd prime \(\ell \mid q\) such that \(\ell \not \mid M_f\). Then as \(x\rightarrow \infty \), we have

    $$\begin{aligned} \begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \\ \chi (p)=\pm 1 \end{array}} \dfrac{\lambda _{f}(p)\overline{\lambda _{f}(p)}}{p}=\dfrac{1}{2}\log \log x+O(1). \end{aligned} \end{aligned}$$
    (3.9)

    Moreover, if \( g\ne f\) and \(\ell ^2\not \mid M_g\), then as \( x\rightarrow \infty \), we have

    $$\begin{aligned} \begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \\ \chi (p)=\pm 1 \end{array}} \dfrac{\lambda _{f}(p)\overline{\lambda _{g}(p)}}{p}=O(1). \end{aligned} \end{aligned}$$
    (3.10)

The implied constants in (3.4), (3.9) and (3.6) depend on the form f and the character \( \chi \), and that in (3.8) depends on the forms fg and the character \( \chi \).

Proof

(1) By Remark 2.2, we have \(\chi (p)\lambda _{ f}(p)=\lambda _{f^{\star }}(p) \) for any prime \( p\not \mid M_{f}q \). For (3.4), by Lemma 3.1 (3.1), we have

$$\begin{aligned} 2\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \\ \chi (p)=\pm 1 \end{array}}\dfrac{ \lambda _{f}(p)}{p}&=\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \end{array}}\dfrac{ \lambda _{f}(p)}{p}\pm \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \end{array}}\dfrac{\chi (p) \lambda _{f}(p)}{p}\\&\qquad =\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \end{array}}\dfrac{ \lambda _{f}(p)}{p}\pm \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \end{array}}\dfrac{\lambda _{f^{\star }}(p)}{p}=O(1). \end{aligned}$$

(2) It is not difficult to see the relation

$$\begin{aligned} \begin{aligned} 2\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \\ \chi (p)=\pm 1 \end{array}}\dfrac{ \lambda _{f}(p)\overline{\lambda _{g}(p)}}{p}&=\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \end{array}}\dfrac{ \lambda _{f}(p)\overline{\lambda _{g}(p)}}{p}\pm \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \end{array}}\dfrac{\chi (p) \lambda _{f}(p)\overline{\lambda _{g}(p)}}{p}\\&=\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \end{array}}\dfrac{ \lambda _{f}(p)\overline{\lambda _{g}(p)}}{p}\pm \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid M_{f}q \end{array}}\dfrac{\lambda _{f^{\star }}(p)\overline{\lambda _{g}(p)}}{p} \end{aligned} \end{aligned}$$
(3.11)

and the forms f, \( f^{\star }=f_{\chi }^{\star }\) and g are primitive. By Lemma 3.1, the first term in (3.11) contributes \( \log \log x +O(1)\) if \(g=f\) and O(1) otherwise, while the second term contributes \(\pm \log \log x+O(1)\) if \(g=f^*\) and O(1) otherwise.

For \(g=f\) with f not CM by \(\chi \), the first term in (3.11) thus contributes \(\log \log x+O(1)\) and the second contributes O(1), giving (3.5).

For \(g=f^{\star }\), the second term in (3.11) always contributes \(\pm \log \log x +O(1)\) and the first term contributes \(\log \log x +O(1)\) if and only if f has CM by \(\chi \) (and O(1) otherwise), giving (3.6) and (3.7).

If \(g\ne f\) and \(g\ne f^{\star }\), then both terms in (3.11) contribute O(1), and we hence obtain (3.8).

(3) By Lemma 2.3, \(\ell \not \mid M_f\) implies that \(f\ne f_{\chi }^{\star }\). Since f does not have CM by \(\chi \), (3.5) implies (3.9).

Moreover, since \(\ell ^2\mid M_{f^{\star }}\) by Lemma 2.3 and \(\ell ^2\not \mid M_g\) in (3.10), we have \(g\ne f^{\star }\), and hence (3.10) follows immediately from (3.8). \(\square \)

4 Coefficients of Arbitrary Cusp Forms and the Proof of Theorem 1.1

Suppose that \(k,L\in \mathbb {N}\) and \(\psi \) is a character with conductor \(L_{\psi }\mid L\). Writing

$$\begin{aligned} f\big |V_{\ell }(z):=f(\ell z), \end{aligned}$$

in [2], A. Atkin and J. Lehner obtain the well-known decomposition

$$\begin{aligned} \begin{aligned} S_{k}(L,\psi )=\bigoplus _{\begin{array}{c} M\mid L\\ L_{\psi }\mid M \end{array}}\bigoplus _{f\in H_{k}^{*}(M,\psi )}\text{ Span }\,_{\mathbb {C}}\left\{ f\big |V_{\ell }: \ell \mid (L/M)\right\} . \end{aligned} \end{aligned}$$
(4.1)

Lemma 4.1

Let \( k\ge 1 \) be an integer, \( N\ge 4 \) an integer divisible by 4 and \( \psi \) a Dirichlet character modulo N. Let \(\chi \) be a primitive real character modulo q and \( \varepsilon \in \{\pm 1\} \). Suppose that \( \mathfrak {f}\in S_{k+1/2}^{*}(N,\psi ) \) and \( t\ge 1 \) is a squarefree integer such that \( \mathfrak {a}_{\mathfrak {f}}(t)\not =0 \). Assume that the sequence \( \{\mathfrak {a}_{\mathfrak {f}}(tn^{2})\}_{n\in \mathbb {N}} \) is real.

  1. (1)

    Then as \( x\rightarrow \infty \), we have

    $$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid q \\ \chi (p)=\pm 1 \end{array}} \dfrac{\mathfrak {a}_{\mathfrak {f}}(tp^{2})}{p^{k+1/2}}=O_{\mathfrak {f},t,\chi }(1). \end{aligned}$$
    (4.2)
  2. (2)

    If there exists an odd prime \(r\mid q\) such that \(r\not \mid N\), then as \( x\rightarrow \infty \), we have

    $$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid q\\ \chi (p)=\varepsilon \end{array}} \dfrac{\mathfrak {a}_{\mathfrak {f}}(tp^{2})^{2}}{p^{2k}}=C\log \log x+O(1) \end{aligned}$$
    (4.3)

    holds for some \(C>0\) for both \( \varepsilon =1 \) and \( \varepsilon =-1 \).

  3. (3)

    Suppose that every prime divisor of q divides N. The equality (4.3) holds with \(C>0\) unless the t-th Shimura correspondence \( f_{t} \) satisfies

    $$\begin{aligned} f_t\otimes \chi _{N^2} = \sum _{i} c_i\left( f_i-\varepsilon f_i^{\star }\right) \otimes \chi _{N^2}, \end{aligned}$$
    (4.4)

    where \(f_i\) run through all of the primitive forms of level dividing N and \(c_i\in \mathbb {C}\). If (4.4) holds, then \(C=0\) and moreover \(a_{f_t}(p)=0\) for every prime \(p\not \mid N\) with \(\chi (p)=\varepsilon \).

The implied constants C and those occurring in the O-symbols depend on \( \mathfrak {f} \), t, \( \chi \) and \( \varepsilon \).

Proof

Applying the Möbius inversion formula to (1.3), we have

$$\begin{aligned} \mathfrak {a}_{\mathfrak {f}}(tn^{2})=\sum \limits _{d\mid n}\mu (d)\psi _{t,N}(d)d^{k-1}a_{f_{t}}\left( \dfrac{n}{d}\right) , \end{aligned}$$

where \( a_{f_{t}}(n) \) is the n-th coefficient of \( f_{t} \). Write \( a_{f_{t}}(n)=\lambda _{f_{t}}(n)n^{k-1/2} \). Then we may rewrite the above formula as

$$\begin{aligned} \dfrac{\mathfrak {a}_{\mathfrak {f}}(tn^{2})}{n^{k-1/2}}=\sum \limits _{d\mid n}\dfrac{\mu (d)\psi _{t,N}(d)}{\sqrt{d}}\lambda _{f_{t}}\left( \dfrac{n}{d}\right) . \end{aligned}$$

Considering the special case that \( n=p \) is a prime and noting that \( \lambda _{f_{t}}(1)=\mathfrak {a}_{\mathfrak {f}}(t) \) yields

$$\begin{aligned} \dfrac{\mathfrak {a}_{\mathfrak {f}}(tp^{2})}{p^{k-1/2}}=\lambda _{f_{t}}(p)-\dfrac{\psi _{t,N}(p)}{\sqrt{p}}\mathfrak {a}_{\mathfrak {f}}(t). \end{aligned}$$
(4.5)

Applying the decomposition (4.1) to \( S_{2k}(N/2,\psi ^{2}) \), we obtain a basis

$$\begin{aligned} \bigcup \limits _{\begin{array}{c} M\mid (N/2)\\ L_{\psi ^2}\mid M \end{array}}\left\{ f\big |V_{\ell }:\ell \mid \dfrac{N/2}{M} ,f\in H_{2k}^{*}(M,\psi ^{2})\right\} . \end{aligned}$$

Hence \( f_t\in S_{2k}(N/2,\psi ^{2}) \) can be written as

$$\begin{aligned} f_t(z)=\sum \limits _{i}\sum \limits _{\ell \mid (N/(2M_{i}))}c_{i,\ell }f_{i}(\ell z), \end{aligned}$$
(4.6)

where \( f_{i}\in H_{2k}^{*}(M_{i},(\psi ^{2})_{M_{i}}) \) is primitive of level \( M_{i} \) and the \( c_{i,\ell } \) are scalars depending on f.

For any prime \( p\not \mid Nq \), the terms with \(\ell \ne 1\) do not contribute anything to the p-th Fourier coefficient, so, comparing coefficients of the functions on each side of (4.6), we see that

$$\begin{aligned} \lambda _{f_{t}}(p)=\sum \limits _{i}c_{i}\lambda _{f_{i}}(p), \end{aligned}$$

where \( c_{i}:=c_{i,1} \). Moreover, since

$$\begin{aligned} \sum \limits _{i}c_{i}=\lambda _{f_t}(1)=\mathfrak {a}_{\mathfrak {f}}(t)\ne 0 \end{aligned}$$

by assumption, not all the \( c_{i} \) are zero. Expressing \( \lambda _{f_{t}} \) by the linear combination of \( \lambda _{f_{i}} \) in (4.5), we have

$$\begin{aligned} \dfrac{\mathfrak {a}_{\mathfrak {f}}(tp^{2})}{p^{k-1/2}}=\sum \limits _{i}c_{i}\lambda _{f_{i}}(p)-\dfrac{\psi _{t,N}(p)}{\sqrt{p}}\mathfrak {a}_{\mathfrak {f}}(t). \end{aligned}$$
(4.7)

(1) Dividing (4.7) by p and summing over \( p\le x \) with \( \chi (p)=\pm 1 \) but \( p\not \mid Nq \) on (4.7) and then applying Lemma 3.2 (3.4) to \( f_{i} \) in (4.7), we deduce that

$$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\pm 1 \end{array}}\dfrac{\mathfrak {a}_{\mathfrak {f}}(tp^{2})}{p^{k+1/2}}=\sum \limits _{i}c_{i}\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\pm 1 \end{array}}\dfrac{\lambda _{f_{i}}(p)}{p}-\mathfrak {a}_{\mathfrak {f}}(t)\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\pm 1 \end{array}}\dfrac{\psi _{t,N}(p)}{p^{3/2}}=O_{\mathfrak {f},t,\chi }(1), \end{aligned}$$

thereby showing (4.2).

(2) Since \(\mathfrak {a}_{\mathfrak {f}}(tn^{2})\in \mathbb {R}\), multiplying (4.7) by it its complex conjugate yields

$$\begin{aligned} \dfrac{\mathfrak {a}_{\mathfrak {f}}(tp^{2})^{2}}{p^{2k-1}}= & {} \sum \limits _{i}|c_{i}|^{2}|\lambda _{f_{i}}(p)|^{2}+\sum \limits _{i\not =j}c_{i}\overline{c_{j}}\lambda _{f_{i}}(p)\overline{\lambda _{f_{j}}(p)}\nonumber \\&+\mathfrak {a}_{\mathfrak {f}}(t)^{2}\dfrac{|\psi _{t,N}(p)|^{2}}{p}-2{\text {Re}}\left( \sum \limits _{i}\dfrac{\overline{c_{i}\lambda _{f_{i}}(p)}\psi _{t,N}(p)}{\sqrt{p}}\mathfrak {a}_{\mathfrak {f}}(t)\right) . \end{aligned}$$
(4.8)

Dividing (4.8) by p and summing over \(p\le x\) with \(\chi (p)=\pm 1\) but \( p\not \mid Nq \) yields

$$\begin{aligned}&\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\pm 1 \end{array}}\dfrac{\mathfrak {a}_{\mathfrak {f}}(tp^{2})^{2}}{p^{2k}}=\sum \limits _{i}|c_{i}|^{2}\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\pm 1 \end{array}}\dfrac{|\lambda _{f_{i}}(p)|^{2}}{p}+\sum \limits _{i\not =j}c_{i}\overline{c_{j}}\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\pm 1 \end{array}}\dfrac{\lambda _{f_{i}}(p)\overline{\lambda _{f_{j}}(p)}}{p}\nonumber \\&\quad +\mathfrak {a}_{\mathfrak {f}}(t)^{2}\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\pm 1 \end{array}}\dfrac{|\psi _{t,N}(p)|^{2}}{p^{2}}-2 \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\pm 1 \end{array}}{\text {Re}}\left( \sum \limits _{i}\dfrac{\overline{c_{i}\lambda _{f_{i}}(p)}\psi _{t,N}(p)}{p^{3/2}}\mathfrak {a}_{\mathfrak {f}}(t)\right) .\qquad \end{aligned}$$
(4.9)

The last two terms are \( O_{\mathfrak {f},t,\chi }(1) \) from the fact that the sum \( \sum _{i}|\lambda _{f_{i}}(p)| \) is bounded [7, see Corollary 5.2]. Now consider the sum of the first and second terms.

Define the index sets \( I^{\star }:=\{i: f_{i}\;\text {has CM by}\;\chi \}\) and \( J:=\{(i,j): i\not =j\;\text {and}\; f_{j}=f_{i}^{\star }\}\). Write

$$\begin{aligned} S_{1}:=\sum \limits _{i\not \in I^{\star }}|c_{i}|^{2} \qquad S_{1}^{\star }:=\sum \limits _{i\in I^{\star }}|c_{i}|^{2} \qquad S_{2}:=\sum \limits _{(i,j)\in J}c_{i}\overline{c_{j}}. \end{aligned}$$

Clearly, not both \( S_{1} \) and \( S_{1}^{\star } \) are zero. For the first term in (4.9), we use (3.5) and (3.7) from Lemma 3.2 to obtain

$$\begin{aligned} \begin{aligned} \sum \limits _{i}|c_{i}|^{2}\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\varepsilon \end{array}}\dfrac{|\lambda _{f_{i}}(p)|^{2}}{p}=\dfrac{S_{1}+(\varepsilon +1) S_{1}^{\star }}{2}\log \log x+O_{\mathfrak {f},t,\chi }(1). \end{aligned} \end{aligned}$$
(4.10)

For the second term in (4.9), since \( f_{i}\not =f_{j} \) for \( i\not =j \), (3.6) implies

$$\begin{aligned} \begin{aligned} \sum \limits _{(i,j)\in J}c_{i}\overline{c_{j}}\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\varepsilon \end{array}}\dfrac{\lambda _{f_{i}}(p)\overline{\lambda _{f_{j}}(p)}}{p}=\dfrac{\varepsilon S_{2}}{2}\log \log x+O_{\mathfrak {f},t,\chi }(1). \end{aligned} \end{aligned}$$
(4.11)

If \(i\ne j\) and \((i,j)\notin J\), then \(f_j\ne f_i\) and \(f_j\ne f_i^{\star }\) (if \(f_i\) has CM by \(\chi \), then \(f_i^{\star }=f_i\), so \(f_j\ne f_i\) implies that \(f_j\ne f_i^{\star }\)). Hence for the remaining terms in (4.9) we may use (3.8) to obtain

$$\begin{aligned} \begin{aligned} \sum \limits _{\begin{array}{c} i\ne j\\ (i,j)\notin J \end{array}}c_{i}\overline{c_{j}}\sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\varepsilon \end{array}}\dfrac{\lambda _{f_{i}}(p)\overline{\lambda _{f_{j}}(p)}}{p}=O_{\mathfrak {f},t,\chi }(1). \end{aligned} \end{aligned}$$
(4.12)

Combining (4.10), (4.11), and (4.12), the sum of the first and second terms in (4.9) is given by

$$\begin{aligned} \dfrac{S_{1}+\varepsilon S_{2}+(\varepsilon +1)S_{1}^{\star }}{2}\log \log x+O_{\mathfrak {f},t,\chi }(1). \end{aligned}$$
(4.13)

If there exists an odd prime \(r\mid q\) such that \(r\not \mid N\), then Lemma 2.3 implies that \(r^2\mid M_{f_i^{\star }}\). Since \(r^2\not \mid N\) and \(M_{j}\mid N\) for every j (including \(j=i\)), \(f_{i}^{\star }\ne f_j\) for every j and hence \( I^{\star }=J=\emptyset \) and \(S_2= S_{1}^{\star }=0 \) in this case. Since \(S_1+S_1^*>0\), we furthermore obtain that \( S_{1}>0 \). Hence (4.13) becomes

$$\begin{aligned} \frac{S_{1}}{2}\log \log x+O_{\mathfrak {f},t,\chi }(1) \end{aligned}$$

with \(S_1>0\). This yields the claim for the case that such an odd prime \(\ell \) exists.

(3) We write

$$\begin{aligned} S_1+\varepsilon S_2+(\varepsilon +1)S_1^{\star }=:Ce^{i\theta } \end{aligned}$$

with \(C\ge 0\) and \(-\pi <\theta \le \pi \) and note that since the left-hand side of (4.3) is a sum of nonnegative real numbers, if \(C\ne 0\) then we must have \(\theta =0\) (otherwise the limit in (4.13) would diverge to \(+e^{i\theta }\infty \) as \(x\rightarrow \infty \) while for each x it equals a nonnegative real number, a contradiction).

Writing \(a_i:={\text {Re}}(c_i)\) and \(b_i:={\text {Im}}(c_i)\), we conclude that

$$\begin{aligned} S_1+\varepsilon S_2+(\varepsilon +1)S_1^{\star }={\text {Re}}\left( S_1+\varepsilon S_2+(\varepsilon +1)S_1^{\star }\right) \end{aligned}$$

and hence

$$\begin{aligned} C= & {} S_1+\varepsilon S_2+(\varepsilon +1)S_1^{\star }=\sum _{i\notin I^{\star }} \left( a_i^2+b_i^2\right) \nonumber \\&+\varepsilon \sum _{(i,j)\in J} \left( a_ia_j + b_ib_j\right) + \left( \varepsilon +1\right) \sum _{i\in I^{\star }}\left( a_i^2+b_i^2\right) . \end{aligned}$$
(4.14)

Consider the set

$$\begin{aligned} I_J:=\{ i: \exists j\;\text { s.t. } (i,j)\in J\} \end{aligned}$$

and note that if \((i,j)\in J\) then \((j,i)\in J\), but since \(\left( f_i^{\star }\right) ^{\star }=f_i\), the tuples in J appear in pairs, and hence there does not exist \(j'\ne j\) such that \((i,j')\in J\). Thus (4.14) becomes

$$\begin{aligned} C&=\sum _{i\notin \left( I^{\star }\cup I_J\right) } \left( a_i^2+b_i^2\right) + \sum _{(i,j)\in J} \frac{1}{2}\left( a_i^2+b_i^2+a_j^2+b_j^2\right) +\varepsilon \left( a_ia_j + b_ib_j\right) \nonumber \\&\qquad + \left( \varepsilon +1\right) \sum _{i\in I^{\star }}\left( a_i^2+b_i^2\right) \nonumber \\&=\sum _{i\notin \left( I^{\star }\cup I_J\right) } \left( a_i^2+b_i^2\right) + \frac{1}{2}\sum _{(i,j)\in J} \left( \left( a_i+\varepsilon a_j\right) ^2 +\left( b_i+\varepsilon b_j\right) ^2\right) + \left( \varepsilon +1\right) \sum _{i\in I^{\star }}\left( a_i^2+b_i^2\right) . \end{aligned}$$
(4.15)

Hence we conclude that \(C>0\) unless all of the following hold:

  • If \(i\notin \left( I^{\star }\cup I_J\right) \), then \(c_i=0\).

  • If \((i,j)\in J\), then \(c_i=-\varepsilon c_j\).

  • If \(\varepsilon =1\), then \(c_i=0\) for every \(i\in I^{\star }\).

Noting that, since \(\chi _{N^2}\) annihilates \(f_i\big |V_{\ell }\) for every \(\ell >1\),

$$\begin{aligned} f_t\otimes \chi _{N^2} = \sum _{i} c_i f_i\otimes \chi _{N^2} \end{aligned}$$

and writing \(f_i=\frac{1}{2}\left( f_i+f_i^{\star }\right) \) for \(i\in I^{\star }\), these three conditions are equivalent to (4.4).

Finally note that if (4.4) holds, then for \(p\not \mid N\) with \(\chi (p)=\varepsilon \) we have

$$\begin{aligned} a_{f_t}(p)= & {} \sum _{i} c_i\left( a_{f_i}(p)-\varepsilon a_{f_i^{\star }}(p)\right) =\sum _{i} c_i\left( a_{f_i}(p)-\varepsilon \chi (p)a_{f_i}(p)\right) \\= & {} \sum _{i} c_i\left( a_{f_i}(p)-a_{f_i}(p)\right) =0, \end{aligned}$$

where we used the fact that

$$\begin{aligned} a_{f_i^{\star }}(p)=a_{f_i\otimes \chi }(p)=\chi (p)a_{f_i}(p). \end{aligned}$$

\(\square \)

Proof of Theorem 1.1

We claim that if

$$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ p\not \mid Nq\\ \chi (p)=\varepsilon \end{array}}\dfrac{\mathfrak {a}_{\mathfrak {f}}(tp^{2})^{2}}{p^{2k}}=C_{\mathfrak {f},t,\chi ,\varepsilon }\log \log x+O_{\mathfrak {f},t,\chi ,\varepsilon }(1), \end{aligned}$$
(4.16)

for some \( C_{\mathfrak {f},t,\chi ,\varepsilon }>0 \), then the assertion is true for \( \chi (p)=\varepsilon \). By Deligne’s bound [4], \( |\lambda _{f_{i}}(p)|\le 2\) (as \( |a_{f_{i}}(p)|\le 2p^{k-1/2} \)). Then (4.7) implies

$$\begin{aligned} |\mathfrak {a}_{\mathfrak {f}}(tp^{2})p^{-(k-1/2)}|\le 2\sum \limits _{i}|c_{i}|+|\mathfrak {a}_{\mathfrak {f}}(t)|=:C_{\mathfrak {f},t}. \end{aligned}$$

Suppose that \( \mathfrak {a}_\mathfrak {f}(tp^{2}) \) are of the same sign for \( y\le p\le x \) with \( p\not \mid Nq \) and \( \chi (p)=\varepsilon \). Without loss of generality, assume that \(\mathfrak {a}_\mathfrak {f}(tp^{2}) >0\). Then

$$\begin{aligned} \sum \limits _{\begin{array}{c} y\le p\le x\\ p\not \mid Nq\\ \chi (p)=\varepsilon \end{array}}\dfrac{\mathfrak {a}_{\mathfrak {f}}(tp^{2})^{2}}{p^{2k}}\le C_{\mathfrak {f},t}\sum \limits _{\begin{array}{c} y\le p\le x\\ p\not \mid Nq\\ \chi (p)=\varepsilon \end{array}} \dfrac{\mathfrak {a}_{\mathfrak {f}}(tp^{2})}{p^{k+1/2}}. \end{aligned}$$
(4.17)

The left-hand side of (4.17) is given by

$$\begin{aligned} C_{\mathfrak {f},t,\chi ,\varepsilon }\log \left( \dfrac{\log x}{\log y}\right) +O_{\mathfrak {f},t,\chi ,\varepsilon }(1) \end{aligned}$$

from the assumption (4.16). However, the right-hand side is \( O_{\mathfrak {f},t,\chi }(1) \) from Lemma 4.1 (4.2) for all \( x\ge y\ge 2 \). It is impossible if \( y=x^{\delta } \) with a sufficiently small constant \( \delta =\delta (\mathfrak {f},t,\chi ,\varepsilon )>0 \). The claim is proved. Combining the claim with (4.3) from Lemma 4.1, we are done. \(\square \)

5 Spinor Genera and the Proof of Theorem 1.2

In this section, we investigate the case when every odd prime dividing the conductor of \(\chi \) also divides the level of the modular form. To prove Theorem 1.2 (1), we require the following lemma [1, Lemma 7.5 and 7.6] for the case when \( \psi _{t,N} \) is a real character.

Lemma 5.1

Let \( \chi \) be a nonprincipal character. As \( x\rightarrow \infty \), we have

$$\begin{aligned} \sum \limits _{p\le x}\dfrac{\chi (p)\log p}{p}&=-L^{\prime }(1,\chi )\sum \limits _{n\le x}\dfrac{\mu (n)\chi (n)}{n}+O(1),\\ L(1,\chi )\sum \limits _{n\le x}\dfrac{\mu (n)\chi (n)}{n}&=O(1), \end{aligned}$$

where \( L(s,\chi )=\sum _{n=1}^{\infty }\chi (n)/n^{s} \) is the Dirichlet L-function.

Now, we begin by showing Theorem 1.2 (1).

Proof of Theorem 1.2 (1)

As in the proof of Theorem 1.1, the form exhibits sign changes whenever (4.16) holds. Hence for \(\mathfrak {f}\) such that (1.6) does not hold, Lemma 4.1 implies that (1.2) exhibits sign changes.

In the case that (1.6) holds, Lemma 4.1 implies that \(a_{f_t}(p)=0\) for every \(p\not \mid N\) with \(\chi _D(p)=\varepsilon \). Then (1.4) implies

$$\begin{aligned} 0=a_{f_t}(p)=\psi _{t,N}(p) p^{k-1}\mathfrak {a}_{\mathfrak {f}}(t)+\mathfrak {a}_{\mathfrak {f}}\left( tp^2\right) . \end{aligned}$$

Thus

$$\begin{aligned} \mathfrak {a}_{\mathfrak {f}}\left( tp^2\right) =-\psi _{t,N}(p)p^{k-1}\mathfrak {a}_{\mathfrak {f}}(t). \end{aligned}$$

Note that \( \mathfrak {a}_{\mathfrak {f}}(n) \) are all real and hence \( \psi _{t,N}(p) \) is real for any prime \( p\not \mid N \) with \( \chi _{D}(p)=\varepsilon \).

Let \( m_{1},m_{2} \) be the smallest positive periods of the characters \( \psi _{t,N} \) and \( \chi _{D} \), respectively, and \( m:=\text{ lcm }(m_{1},m_{2}) \). If \(\psi _{t,N}\simeq \chi _{D}^{j}\), then \(-\psi _{t,N}(p)=-\varepsilon ^{j}\) for any prime p not dividing m and so for any prime p with \(\chi _{D}(p)=\varepsilon \) (and so \( p\not \mid m_{1} \)) but \( p\not \mid m_{2} \). Hence we have

$$\begin{aligned} \mathfrak {a}_{\mathfrak {f}}\left( tp^2\right) = {\left\{ \begin{array}{ll} 0&{}\text {if } \chi _{D}(p)=\varepsilon { and} p\mid m_{2} , \\ -\varepsilon ^{j} p^{k-1} \mathfrak {a}_{\mathfrak {f}}(t) &{}\text {if } \chi _{D}(p)=\varepsilon \hbox { and } p\not \mid m_{2} . \\ \end{array}\right. } \end{aligned}$$

Thus there are no sign changes in this case.

If \( \psi _{t,N}\not \simeq \chi _{D}^{j} \) for \( j=0,1 \), suppose that the subsequence does not exhibit sign changes. Then one of the following holds:

  1. (a)

    \( \psi _{t,N}(p)=\chi _{D}(p)=\varepsilon \) for any prime p with \( \chi _{D}(p)=\varepsilon \);

  2. (b)

    \( \psi _{t,N}(p)=-\chi _{D}(p)=-\varepsilon \) for any prime p with \( \chi _{D}(p)=\varepsilon \).

Case I: either (a) or (b) holds with \( \varepsilon =-1 \):

Choose a prime \( p_{0} \) with \( \chi _{D}(p_{0})=-1 \) and \( p\not \mid m_{2} \). For any prime p with \( \chi _{D}(p)=1 \) and \( p\not \mid m_{2} \), we have \( \chi _{D}(pp_{0})=-1 \). Since \( \gcd (m,pp_{0})=1 \), by Dirichlet’s theorem on arithmetic progressions, there exists some prime q such that \( q\equiv pp_{0}\pmod {m} \). Hence \( \chi _{D}(q)=-1\). If the statement (a) holds, then we have

$$\begin{aligned} \psi _{t,N}(pp_{0})=\psi _{t,N}(q)=-1=\chi _{D}(q)=\chi _{D}(pp_{0}) \end{aligned}$$

and \( \psi _{t,N}(p_{0})=\chi _{D}(p_{0})=-1 \); if the statement (b) holds, then we have

$$\begin{aligned} \psi _{t,N}(pp_{0})=\psi _{t,N}(q)=1=-\chi _{D}(q)=-\chi _{D}(pp_{0}) \end{aligned}$$

and \( \psi _{t,N}(p_{0})=-\chi _{D}(p_{0})=1 \). In both cases, we conclude that \( \psi _{t,N}(p)=\chi _{D}(p) \) for any prime p with \( \chi _{D}(p)=1 \) and \( p\not \mid m_{2} \), and so for any prime p with \( p\not \mid m_{2} \). Hence \( \psi _{t,N}(p)=\chi _{D}(p) \) for any prime p not dividing \( m_{1}m_{2} \). Therefore, \( \psi _{t,N}\simeq \chi _{D} \), yielding a contradiction.

Case II: (b) holds with \( \varepsilon =1 \):

By Dirichlet’s theorem, there exists a prime q with \( q\equiv 1\pmod {m} \). Then \( \chi _{D}(q)=1 \). By (b), we have \( \psi _{t,N}(q)=-\chi _{D}(q)=-1 \). But \( \psi _{t,N}(q)=\psi _{t,N}(1)=1 \) from \( q\equiv 1\pmod {m} \). This is a contradiction.

Case III: (a) holds with \( \varepsilon =1 \):

For any prime p with \( \chi _{D}(p)\not =0\) and \( p\not \mid m \), since \( \gcd (p^{2},m)=1 \), Dirichlet’s theorem implies that there must exist a prime \( q\equiv p^{2}\pmod {m} \) and thus \( \chi _{D}(q)=\chi _{D}(p^{2})=1 \). By (a), we deduce that

$$\begin{aligned} \psi _{t,N}(p^{2})=\psi _{t,N}(q)=\chi _{D}(q)=1. \end{aligned}$$

Therefore, \( \psi _{t,N}(p)\in \mathbb {R} \) for any prime with \( \chi _{D}(p)\not =0 \) and \( p\not \mid m \). Note that \( \chi _{D}(p)=0 \) implies \( \psi _{t,N}(p)=0 \). It follows that \( \psi _{t,N}(p)\in \mathbb {R} \) for any prime p. Hence \( \psi _{t,N} \) is a real character.

From the above discussion, if the subsequence does not exhibit sign changes, then \( \psi _{t,N} \) must be real. We now suppose that \( \psi _{t,N} \) is real and \(\psi _{t,N}\not \simeq \chi _D^j\), and will prove that the sign changes do indeed occur. From \( \mathfrak {a}_{\mathfrak {f}}\left( tp^2\right) =-\psi _{t,N}(p)p^{k-1} \mathfrak {a}_{\mathfrak {f}}(t) \), it is sufficient to show that the following both occur:

  1. (c)

    there exist infinitely many primes p with \( \chi _{D}(p)=\varepsilon \) such that \( \psi _{t,N}(p)=\chi _{D}(p)=\varepsilon \);

  2. (d)

    there exist infinitely many primes p with \( \chi _{D}(p)=\varepsilon \) such that \(\psi _{t,N}(p)=-\chi _{D}(p)=-\varepsilon \).

By analytic number theory it suffices to show that for \( \varepsilon =\pm 1 \) the sum

$$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ \chi _{D}(p)=\varepsilon \,,\,\psi _{t,N}(p)=\pm \varepsilon \end{array}}\dfrac{\log p}{p} \end{aligned}$$

diverges as \(x\rightarrow \infty \). Without loss of generality, we only consider the case \( \chi _{D}(p)=1 \) and \( \psi _{t,N}(p)=-1 \). Then one can check that

$$\begin{aligned}&\sum \limits _{\begin{array}{c} p\le x\\ \chi _{D}(p)=1\,,\,\psi _{t,N}(p)=-1 \end{array}}\dfrac{\log p}{p}=\dfrac{1}{2}\left( \sum \limits _{\begin{array}{c} p\le x\\ \psi _{t,N}(p)=-1 \end{array}}\dfrac{\log p}{p}+ \sum \limits _{\begin{array}{c} p\le x\\ \psi _{t,N}(p)=-1 \end{array}}\dfrac{\chi _{D}(p)\log p}{p}\right) +O(1) \\&\quad =\dfrac{1}{4}\left( \sum \limits _{p\le x}\dfrac{\log p}{p}-\sum \limits _{p\le x}\dfrac{\psi _{t,N}(p)\log p}{p}+\sum \limits _{p\le x}\dfrac{\chi _{D}(p)\log p}{p} -\sum \limits _{p\le x}\dfrac{\psi _{t,N}(p)\chi _{D}(p)\log p}{p}\right) +O(1). \end{aligned}$$

Since \( \chi _{D}\), \(\psi _{t,N}\), and \(\psi _{t,N}\chi _{D} \) are nonprincipal and real (from the assumptions that \(\psi _{t,N}\not \simeq \chi _D^j\) and \(D\ne 1\)), the associated L-functions do not have poles at \( s=1 \). So the last three terms contribute O(1) by Lemma 5.1 and the first term contributes \( \log x+O(1) \) by the Prime Number Theorem. Hence

$$\begin{aligned} \sum \limits _{\begin{array}{c} p\le x\\ \chi _{D}(p)=1\,,\,\psi _{t,N}(p)=-1 \end{array}}\dfrac{\log p}{p}=\dfrac{1}{4}\log x+O(1), \end{aligned}$$

and the claim is proved. Thus (1.2) exhibits infinitely many sign changes when \( \psi _{t,N}\not \simeq \chi _{D}^{j} \) for \( j=0,1 \).

Finally note that (1.6) cannot hold for both \(\varepsilon \) and \(-\varepsilon \) because that would contradict the assumption that \(a_{f_t}(1)=\lambda _{f_t}(1)=\mathfrak {a}_{\mathfrak {f}}(t)\ne 0\). Moreover, the condition \(\psi _{t,N}\simeq \chi _D^j\) can occur for at most one choice of t and since \(D\mid N\) and \(\psi \) is a character modulo N, we have \(t\mid N\). \(\square \)

While Theorem 1.2 (1) should yield many examples where sign changes are not exhibited, it is not entirely obvious that the conditions \(\psi _{t,N}\simeq \chi _D^j\), \(\mathfrak {a}_{\mathfrak {f}}(t)\ne 0\), and (1.6) are simultaneously satisfied. We hence construct an explicit example where we can verify all three conditions. The construction goes through the theory of spinor genera of ternary quadratic forms.

Proof of Theorem 1.2 (2)

Consider the quadratic forms

$$\begin{aligned} Q_{1}(x,y,z)&:=x^{2}+48y^{2}+144z^{2}, \\ Q_{2}(x,y,z)&:=4x^{2}+48y^{2}+49z^{2}+4xz+48yz, \end{aligned}$$

discussed for example in [16, (4.18), p.9] and [6, §7.3 An example].

The forms \(Q_1\) and \(Q_2\) are in the same spinor genus and are moreover representatives for the only two classes in their spinor genus.

The level \( N_{Q_j} \) and the determinant \( D_{Q_j} \) of \( Q_{j} \) (\( j=1,2 \)) are \( 2^{6}3^{2} \) and \( 2^{8}3^{3} \), respectively. Schulze-Pillot found that \( t=1 \) is a primitive spinor exception and is represented by \( Q_{1} \), but not represented by \( Q_{2} \). By the theory of spinor genera, the spinor genus does not primitively represent the integers \(tp^2\), or in other words, since all representations of \(tp^2\) come from representations of t,

$$\begin{aligned} r(tp^2,Q_j)=r(t,Q_j). \end{aligned}$$

Thus in particular

$$\begin{aligned} r(tp^{2},Q_{2})=r(t,Q_2)=0 \end{aligned}$$

for any odd prime \( p\equiv -1\pmod {3} \), i.e. \((-3/p)=-1\).

Plugging in the expansion (2.3) and noting that r(tQ) is the t-th coefficient of \(\theta _Q\), (2.4) implies that

$$\begin{aligned} 0=r(t,Q_{2})=a_{E}(t,Q_{2})+a_{H}(t,Q_{2})+a_{f}(t,Q_{2})=r(t,\text{ spn }\,(Q_{2}))+a_{f}(t,Q_{2}). \end{aligned}$$

Therefore, we have

$$\begin{aligned} a_{f}(t,Q_{2})=-r(t,\text{ spn }\,(Q_{2}))\not =0. \end{aligned}$$

For any inert prime p in \( \mathbb {Q}(\sqrt{-3}) \), i.e., \( (-3/p)=-1 \), replacing t by \( tp^{2} \), we have \( a_{f}(tp^{2},Q_{2})=-r(tp^{2},\text{ spn }\,(Q_{2})) \) analogously from \( r(tp^{2},Q_{2})=0 \). Since t is represented by \( \text{ spn }\,(Q_{2}) \), \( tp^{2} \) is not primitivley represented by \( \text{ spn }\,(Q_{2}) \). Therefore,

$$\begin{aligned} r(tp^{2},\text{ spn }\,(Q_{2}))-r(t,\text{ spn }\,(Q_{2}))=r^{*}(tp^{2},\text{ spn }\,(Q_{2}))=0 , \end{aligned}$$

where \( r^{*}(n,\text{ spn }\,(Q)) \) denotes the number of primitive representation of n by Q. Namely, \( r(tp^{2},\text{ spn }\,(Q_{2}))=r(t,\text{ spn }\,(Q_{2})) \). It follows that

$$\begin{aligned} a_{f}(t,Q_{2})=-r(t,\text{ spn }\,(Q_{2}))=-r(tp^{2},\text{ spn }\,(Q_{2}))=a_{f}(tp^{2},Q_{2}). \end{aligned}$$

Hence we see that \( a_{f}(tp^{2},Q_{2}) \) has the same sign for \( t=1 \) and any prime \( p\equiv -1\pmod {3} \).

\(\square \)