# Additive problems with almost prime squares

Valentin Blomer  ,  Junxian Li  and  Simon L. Rydin Myerson  Mathematisches
Institut, Endenicher Allee 60, 53115 Bonn<EMAIL_ADDRESS><EMAIL_ADDRESS>Mathematics Institute, Zeeman Building. University of
Warwick, Coventry CV4 7AL<EMAIL_ADDRESS>
###### Abstract.

Assuming GRH, we show that every sufficiently large integer is a sum of a
prime and two almost prime squares, and also a sum of a smooth number and two
almost prime squares. The number of such representations is of the expected
order of magnitude. The methods involve a combination of analytic, automorphic
and algebraic arguments.

###### Key words and phrases:

additive problems, almost primes, smooth numbers, sieves, binary quadratic
forms

###### 2010 Mathematics Subject Classification:

Primary: 11N36, 11N75, 11P32, 11E16

The first two authors were supported in part by DFG grants BL 915/2-2 and BL
915/5-1 and Germany’s Excellence Strategy grant EXC-2047/1 - 390685813. The
second and third author acknowledge support of the Max Planck Institute for
Mathematics.

##  1\. Introduction

###  1.1. Statement of results

In his first paper, Hooley [Ho1] gave a proof, conditional upon the
Generalized Riemann Hypothesis, of a conjecture made by Hardy and Littlewood
some 30 years before [HL]: the number of representations of an integer $n$ in
the form

(1.1) $n=p+x_{1}^{2}+x_{2}^{2}$

in primes $p$ and non-zero integers $x_{1},x_{2}$ as $n\rightarrow\infty$ is
asymptotic to

(1.2) $\pi\,\mathfrak{S}(n){\rm Li}(n),\quad\text{ where
}\mathfrak{S}(n)=\prod_{p}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}\prod_{p\mid
n}\frac{(p-1)(p-\chi_{-4}(p))}{p^{2}-p+\chi_{-4}(p)}.$

In particular every sufficiently large number is representable in this form.
The Generalized Riemann Hypothesis (GRH) was removed a few years later by
Linnik [Li] who used his dispersion method to obtain the first unconditional
proof of the Hardy-Littlewood problem. The proof could be greatly streamlined
and simplified once the Bombieri-Vinogradov theorem became available, cf. e.g.
[EH]. The best error term in the asymptotic formula was recently established
by Assing and the first two authors [ABL] by invoking in addition the theory
of automorphic forms.

In his last paper, Hooley [Ho2] returned to this topic and considered a
refined version. He showed that every sufficiently large number is
representable as a sum of a prime and two squares of _squarefree_ numbers and
gave a lower bound for the number of such representations of the expected
order of magnitude. At first sight this appears to be easy – squarefree
numbers can be detected by zero-dimensional sieve, so only a little bit of
inclusion-exclusion is required. On second thought, a major issue emerges: to
sieve out even a fixed number of squares of primes, one needs an asymptotic
formula for (1.1) with $d_{1}\mid x_{1}$, $d_{2}\mid x_{2}$. However, the
quadratic form $d_{1}^{2}x_{1}^{2}+d_{2}^{2}x_{2}^{2}$ fails to have class
number one, in fact very soon it even fails to have one class per genus, and
hence there is no convolution formula for the number of ways it represents a
given integer. Without such a formula, all approaches to the Hardy-Littlewood
problem and its variations become very problematic. Hooley finds an ingenious
(but rather ad hoc) way to circumvent this issue altogether for the particular
problem at hand.

In this paper, we continue on this avenue and introduce a general sieve
process into the problem with the goal of showing that every sufficiently
large integer is a sum of a prime and two squares of _almost primes_.
Obviously, the application of a sieve to make $x_{1},x_{2}$ almost prime
requires the coefficients $d_{1}$ and $d_{2}$ to be some power of $n$, and so
quite likely we need technology that can deal with (1.1) with a power-saving
error term. This makes the use of GRH, at least at the present state of
knowledge, unavoidable.

######  Theorem 1.1.

Assume GRH. Then there exists a constant $C>0$ such that every sufficiently
large integer $n\not\equiv 2\,(\textup{mod}\,3)$ can be represented in the
form (1.1) with a prime $p$ and integers $x_{1},x_{2}$ having at most $C$
prime factors. The number of such representations is $\gg\mathfrak{S}(n)n(\log
n)^{-3}$ with $\mathfrak{S}(n)$ as in (1.2).

We have made no effort to compute and optimize the value of $C$, although an
upper bound of size $C\leq 10^{6}$, say, can easily be obtained by careful
book-keeping.

From a multiplicative point of view, complementary to primes are smooth
numbers (“entiers friables” in French) all of whose prime factors are small.
The smallness is measured in terms of a parameter $y$, and following the usual
notation we let $\Psi(x,y)=\\#S(x,y)$ where $S(x,y)$ denotes the set of
positive integers $m\leq x$ such that $p\mid m$ implies $m\leq y$ for all
primes $p$. Smooth numbers appear quite frequently (with positive density if
$\log x\asymp\log y$), yet additive problems with smooth numbers are often
surprisingly difficult, see e.g. [Ba, BBD, KMS]. The present case is no
exception, and the proof of Theorem 1.2 below turns out to be rather
intricate. As a variation of (1.1) we consider the equation

(1.3) $n=m+x_{1}^{2}+x_{2}^{2}$

where $x_{1},x_{2}$ are almost primes and $m$ is $y$-smooth with
$y\geq\exp((\log\log n)^{2})$. We prove the following.

######  Theorem 1.2.

Assume GRH. There exists a constant $C>0$ such that for any function $g$ with
$\exp((\log\log n)^{2})\leq g(n)\leq n$, every sufficiently large integer $n$
can be represented in the form (1.3) with $m\in S(n,g(n))$ and integers
$x_{1},x_{2}$ having at most $C$ prime factors. The number of such
representations is $\gg\Psi(n,g(n))(\log n)^{-2}$.

In fact, in the representations we construct, $m$ will in addition be a
squarefree number times a power of 2. For orientation we remark that

(1.4) $\Psi(x,y)\asymp x\rho(u)\asymp x\exp\big{(}-u(\log u+O(\log\log
u)\big{)},\quad u=\frac{\log x}{\log y}$

with $\rho(u)$ being the Dickman function for $y\geq\exp((\log\log x)^{2})$
(see e.g. [Hi, Theorem 1]).

Our method to prove Theorems 1.1 and 1.2 can be generalized to deal with
general fixed quadratic forms $F(x_{1},x_{2})$ (of fundamental discriminant)
instead of $x_{1}^{2}+x_{2}^{2}$, at the cost of slightly more work.

###  1.2. Methods and ideas

While the statements of Theorems 1.1 and 1.2 are purely arithmetic, the proofs
combine a variety of different methods. We need the algebraic structure theory
of orders in quadratic number fields, the full machinery of automorphic forms
including some higher rank $L$-functions, and of course the toolbox of
analytic number theory. Starting with the latter, the obvious approach to
almost primes is the application of a sieve. Thus, for the proof of both
theorems we need to analyze quite accurately the quantity

(1.5) $\sum_{\ell}r_{d_{1},d_{2}}(n-\ell),\quad
r_{d_{1},d_{2}}(n)=\\#\\{(x,y)\in\mathbb{Z}^{2}\mid
d_{1}^{2}x_{1}^{2}+d_{2}^{2}x_{2}^{2}=n\\}$

for squarefree integers $d_{1},d_{2}$ where $\ell$ runs either over primes or
over smooth numbers. As mentioned above, in general there is no closed
convolution formula for $r_{d_{1},d_{2}}$, since there is typically more than
one class per genus. For fixed $d_{1},d_{2}$ one can lift the necessary
ingredients to analyze (1.5) from [Iw1] or [Vi], but for almost primes we need
strong uniformity where $d_{1},d_{2}$ can be as large as some small power of
$n$.

A robust substitute that may also be useful in other situations is as follows.
Let $F$ be a primitive binary quadratic form of discriminant $D=D_{0}f^{2}<0$
(with $D_{0}$ fundamental) and let
$\mathcal{O}_{D}\subseteq\mathbb{Q}(\sqrt{D})$ be the (not necessarily
maximal) order of discriminant $D$. The set of equivalence classes of
primitive forms of discriminant $D$ is in bijection with the proper (i.e.
invertible) ideal classes $\mathcal{C}_{D}$ of $\mathcal{O}_{D}$ (see [Co,
Section 7]), and we denote by $C_{F}\in\mathcal{C}_{D}$ the class
corresponding to $F$. Then for $(n,f)=1$ we have the exact formula

(1.6) $\\#\\{(x_{1},x_{2})\in\mathbb{Z}^{2}\mid
F(x_{1},x_{2})=n\\}=w\sum_{\chi\in\widehat{\mathcal{C}}_{D}}\bar{\chi}(C_{F})\sum_{\begin{subarray}{c}N\mathfrak{a}=n\\\
\mathfrak{a}\subseteq\mathcal{O}_{K}\end{subarray}}\chi(\mathfrak{a})$

where $w$ is the number of units in $\mathcal{O}_{D}$. The key point is now to
split the outer sum into two parts: class group characters $\chi$ of order at
most two are genus characters and can be computed explicitly by some kind of
convolution identity. For a character of order three or more, the inner sum is
the $n$-th Hecke eigenvalue of a cusp form of weight 1 and level $|D|$. In
this way, the theory of automorphic forms enters, and (1.6) can be seen as a
version of Siegel’s mass formula.

The upshot is that – at least morally – we need to understand a sum as in
(1.5) in two cases: when the arithmetic function in question is a Fourier
coefficients of some cusp form and when the arithmetic function is a Dirichlet
convolution of two characters, in other words the Fourier coefficient of an
Eisenstein series. In particular, this is yet another example where the
originally purely arithmetic problem of representing $n$ in the form (1.1) or
(1.3) is intimately linked to the theory of automorphic forms.

As an aside we remark that there is a different way to build a bridge to
automorphic forms. Instead of applying the algebraic identity (1.6), one could
model the left hand side by a suitably truncated expression coming from a
formal application of the circle method. More rigorously, one could apply a
$\delta$-symbol method à la Heath-Brown [HB] and Duke-Friedlander-Iwaniec
[DFI], followed by Poisson summation. This leads to sum of Kloosterman sums
which after an application of the Kuznetsov formula returns a similar
expression of cuspidal and non-cuspidal Fourier coefficients. An application
of (1.6), however, seems more direct.

To understand (1.5) when $r_{d_{1},d_{2}}$ is replaced by a cuspidal Fourier
coefficient, we refine methods and results established in [ABL, Theorem 1.3]
to obtain a power saving _unconditionally_ with the required degree of
uniformity. The Eisenstein contribution does not allow an unconditional
treatment, at the very least we would have to deal with Siegel zeros [Dr2].

Returning to the re-interpretation of quadratic forms in terms of ideal
classes, we observe that in our case the underlying quadratic field is fixed:
for all $d_{1},d_{2}$ we obtain the Gaußian number field $\mathbb{Q}(i)$, but
the discriminant of the order increases with $d_{1},d_{2}$, in particular the
order is highly non-maximal. This is technically challenging and leads to
involved computations of the corresponding main terms.

We close the introduction with some comments on the proof of Theorem 1.2. The
arithmetic of smooth numbers is rather subtle, and it turns out that leading
term in a suitable asymptotic formula of (1.5) for $\ell\in S(n,g(n))$ is not
multiplicative in $d_{1},d_{2}$. Multiplicativity does not fail by a lot, but
we obtain secondary terms involving derivatives of Euler products. This makes
the application of a sieve perhaps not impossible, but at least seriously
problematic. There are some ways to handle non-multiplicative main terms
without developing the theory in full generality (see [FI, p. 37]). But the
fact that we have two variables to sieve makes the monotonicity principle, in
particular [FI, Corollary 5.4/5.5], not applicable. We therefore take a
different route and incorporate the sieve weights directly into the analysis.
A prototype of this idea can be found in the proof of [FT96, Theorem 4], but
such a strategy in the context of additive problems seems to be new. There are
a number of interesting more technical details that we will discuss at the
appropriate places.

Roadmap for the rest of the paper: In Section 2, we give the explicit formula
for $r_{d_{1},d_{2}}$ (see Lemma 2.2), which consists of a cuspidal part and
an Eisenstein part. To deal with the cuspidal part, in Section 3 we prove
general bounds for linear forms in Hecke eigenvalues over prime numbers
(Theorem 3.3) and smooth numbers (Theorem 3.4) assuming a bilinear estimate
(Proposition 3.1) and a $\tau_{3}$-type estimate (Proposition 3.2) with Hecke
eigenvalues, whose proofs are given in Section 4. The proofs of Theorems 1.1
and 1.2 are given in Sections 5 and 6 respectively. The most involved part is
the rather subtle analysis of the main term in the sieving process, which
covers Subsections 5.2 – 5.3 in the prime number case and Subsections 6.4 –
6.7 in the smooth number case.

##  2\. Algebraic considerations

We recall the classical theory on binary quadratic forms. For $f\in\mathbb{N}$
let $\mathcal{O}_{f}=\mathbb{Z}+f\mathbb{Z}[i]\subseteq\mathbb{Z}[i]$ be the
unique order of discriminant $-4f^{2}$ (the notation is slightly different
than in Section 1.2). We have $\mathcal{O}_{f}^{\ast}=\\{\pm 1\\}$ unless
$f=1$ in which case $\mathcal{O}_{f}^{\ast}=\\{\pm 1,\pm i\\}$. We write
$w_{f}=\\#\mathcal{O}_{f}^{\ast}$. Its class group $\mathcal{C}_{f}$ is the
set of proper (= invertible) fractional $\mathcal{O}_{f}$-ideals $I_{f}$
modulo principal ideals $P_{f}$. This is a finite group of cardinality [Co,
Theorem 7.24]

(2.1) $h_{f}=f\prod_{p\mid
f}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}\begin{cases}1/2,&f>1,\\\
1,&f=1.\end{cases}$

We have a sequence of isomorphisms. Let $\tilde{\mathcal{C}}_{f}$ be the set
of primitive binary quadratic forms with discriminant $-4f^{2}$ modulo the
action of ${\rm SL}_{2}(\mathbb{Z})$. Let $I^{*}_{f}$ be the set of fractional
$\mathcal{O}_{f}$-ideals coprime to $f$ (these are automatically proper [Co,
Lemma 7.18(ii)]) and $P^{*}_{f}$ the subgroup of its principal ideals. Let
$I^{\ast}$ be the set of fractional $\mathcal{O}_{1}=\mathbb{Z}[i]$-ideals
coprime to $f$ and $P^{\ast}$ the set of principal $\mathbb{Z}[i]$-ideals with
a generator $\alpha\in\mathcal{O}_{f}$ coprime to $f$. Then we have ([Co,
Theorem 7.7(ii), Exercise 7.17(a), Propositions 7.19, 7.20, 7.22])

(2.2)
$\begin{array}[]{ccccccc}\tilde{\mathcal{C}}_{f}&\cong&\mathcal{C}_{f}=I_{f}/P_{f}&\cong&I^{*}_{f}/P^{*}_{f}&\cong&I^{\ast}/P^{\ast}\\\
\frac{N(\alpha x+\beta
y)}{N\mathfrak{a}}&\leftarrow&\mathfrak{a}=[\alpha,\beta]&\leftarrow&\mathfrak{a}&&\\\
ax^{2}+bxy+cy^{2}&\rightarrow&[a,\frac{1}{2}(-b+\sqrt{-4f^{2}})]&&\mathfrak{a}&\rightarrow&\mathfrak{a}\mathbb{Z}[i]\\\
&&&&\mathfrak{a}\cap\mathcal{O}_{f}&\leftarrow&\mathfrak{a}\end{array}$

The last isomorphism is norm-preserving ([Co, Proposition 7.20]). For a
positive integer $m$ and a primitive binary form $F$ with corresponding ideal
class $C_{F}$, the first isomorphism induces a bijection ([Co, Theorem
7.7(iii)]) between

(2.3) $\\{(x_{1},x_{2})\mid
F(x_{1},x_{2})=m\\}/\mathcal{O}_{f}^{\ast}\longleftrightarrow\\{\mathfrak{a}\text{
integral }\mathcal{O}_{f}\text{-ideal in the class }C_{F}\mid
N\mathfrak{a}=m\\}.$

If $(m,f)=1$, then the last isomorphism in (2.2) shows

(2.4) $\sum_{\begin{subarray}{c}N\mathfrak{a}=m\\\
\mathfrak{a}\subseteq\mathcal{O}_{f}\end{subarray}}1=\sum_{\begin{subarray}{c}N\mathfrak{a}=m\\\
\mathfrak{a}\subseteq\mathbb{Z}[i]\end{subarray}}1=\sum_{d\mid
m}\chi_{-4}(d)=r(m)$

where $r(m)=\textbf{1}\ast\chi_{-4}$ is the usual sums-of-two-squares
function.

The elements of order 2 in $\mathcal{C}_{f}$ are well-understood by genus
theory. In particular, for squarefree $f$ the real characters $\chi$ of
$\widehat{\mathcal{C}}_{f}$ are parametrized by odd divisors $D\mid f$, and
for an ideal $\mathfrak{a}\in I_{f}^{\ast}$ (i.e. coprime to $f$) and a real
character associated with the divisor $D$ we have

(2.5) $\chi(\mathfrak{a})=\chi_{D^{\ast}}(N\mathfrak{a}),\quad
D^{\ast}:=\chi_{-4}(D)D\in\\{\pm D\\}.$

We write

(2.6) $G_{f}=\tau(f/(f,2))$

for the number of genera.

From now on we focus on the form $F_{a,b}=a^{2}x_{1}^{2}+b^{2}x_{2}^{2}$. We
write $C_{a,b}\in\mathcal{C}_{ab}$ to denote the class corresponding to the
form $F_{a,b}$. We will give an explicit formula for $r_{d_{1},d_{2}}$ defined
in (1.5). We first notice that we can compute the real characters of
$\tilde{\mathcal{C}}_{ab}$ explicitly for the class $C_{a,b}$.

######  Lemma 2.1.

Let $a,b\in\mathbb{N}$ be coprime and squarefree. Let $F_{a,b}$ be as above
and let $\chi$ be a real character of $\tilde{\mathcal{C}}_{ab}$. Then
$\chi(C_{a,b})=1$.

Proof. Then $F_{a,b}$ is equivalent to the form
$(a^{2}+b^{2})x_{1}^{2}+2b^{2}x_{1}x_{2}+b^{2}x_{2}^{2}$, which under the
isomorphism (2.2) corresponds to an ideal of norm $a^{2}+b^{2}$ coprime to
$ab$, so if $\chi$ belongs to the divisor $D\mid ab$, then by (2.5) we have

$\chi(C_{a,b})=\chi_{D^{\ast}}(a^{2}+b^{2})=1.$

_Remark:_ Alternatively one can explicitly compute the class group structure
from the exact sequence [Co, (7.25), (7.27), Exercise 7.30]

$1\longrightarrow\\{\pm
1\\}\overset{}{\longrightarrow}(\mathbb{Z}/f\mathbb{Z})^{\ast}\times\\{\pm
1,\pm
i\\}\longrightarrow(\mathbb{Z}[i]/f\mathbb{Z}[i])^{\ast}\longrightarrow\mathcal{C}_{f}\longrightarrow
1.$

For instance, if $f$ is even, one can conclude that
$\text{rk}_{2}(\mathcal{C}_{f})=\text{rk}_{4}(\mathcal{C}_{f})$, so that all
real characters are trivial on elements of order 2 (and hence a fortiori on
diagonal forms).

From Lemma 2.1 we can give the explicit formula for $r_{d_{1},d_{2}}$ in
(1.5). We recall the notation (2.1) and (2.6).

######  Lemma 2.2.

Let $d_{1},d_{2}$ be two squarefree numbers, and write
$\delta=(d_{1},d_{2}),d_{1}^{\prime}=d_{1}/\delta$, and
$d_{2}^{\prime}=d_{2}/\delta$. Let $\mathcal{L}\subseteq\mathbb{N}$ be a
finite set and define

$\mathcal{S}:=\sum_{l\in\mathcal{L}}r_{d_{1},d_{2}}(l).$

Then $\mathcal{S}=\mathcal{S}_{\leq 2}+\mathcal{S}_{\geq 3}$ where we have

(2.7) $\mathcal{S}_{\leq
2}=\sum_{\delta_{1}\delta_{1}^{\prime}=d_{1}^{\prime}}\sum_{\delta_{2}\delta_{2}^{\prime}=d_{2}^{\prime}}\frac{w_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}{h_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}G_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\sum_{w\in\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}\sum_{\begin{subarray}{c}l\equiv
0\,(\text{{\rm mod }}(\delta\delta_{1}\delta_{2})^{2})\\\ l\equiv
w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\\\
l\in\mathcal{L}\end{subarray}}r\Big{(}\frac{l}{\delta^{2}\delta_{1}^{2}\delta_{2}^{2}}\Big{)}.$

with

(2.8)
$\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}=\big{\\{}w\in(\mathbb{Z}/\delta_{1}^{\prime}\delta_{2}^{\prime}\mathbb{Z})^{\ast}:\chi_{p^{*}}(n)=1\text{
for all }2\nmid p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}\big{\\}},$

and

(2.9) $\mathcal{S}_{\geq
3}=\sum_{\delta_{1}\delta_{1}^{\prime}=d_{1}^{\prime}}\sum_{\delta_{2}\delta_{2}^{\prime}=d_{2}^{\prime}}\frac{w_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}{h_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}\sum_{\begin{subarray}{c}\chi\in\widehat{\mathcal{C}}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\\\
\text{{\rm ord}}\chi\geq
3\end{subarray}}\bar{\chi}(C_{\delta_{1}^{\prime},\delta^{\prime}_{2}})\sum_{\begin{subarray}{c}l\equiv
0\,(\text{{\rm mod }}(\delta\delta_{1}\delta_{2})^{2})\\\
(l,\delta_{1}^{\prime}\delta_{2}^{\prime})=1\\\
l\in\mathcal{L}\end{subarray}}\lambda_{\chi}\Big{(}\frac{l}{\delta^{2}\delta_{1}^{2}\delta_{2}^{2}}\Big{)}$

with a Hecke eigenvalue $\lambda_{\chi}$ of some holomorphic cuspidal newform
of weight $1$, character $\chi_{-4}$ and level dividing $4d_{1}^{2}d_{2}^{2}$.

Proof. Since $\delta,d_{1}^{\prime},d_{2}^{\prime}$ are pairwise coprime and
squarefree, we have

(2.10)
$\begin{split}\mathcal{S}:=\sum_{l\in\mathcal{L}}r_{d_{1},d_{2}}(l)&=\sum_{\delta^{2}\mid
l\in\mathcal{L}}r_{d^{\prime}_{1},d^{\prime}_{2}}\Big{(}\frac{l}{\delta^{2}}\Big{)}=\sum_{\delta_{1}\delta_{1}^{\prime}=d_{1}^{\prime}}\sum_{\delta_{2}\delta_{2}^{\prime}=d_{2}^{\prime}}\sum_{\begin{subarray}{c}(\delta\delta_{1}\delta_{2})^{2}\mid
l\in\mathcal{L}\\\
(l,\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}r_{\delta^{\prime}_{1},\delta_{2}^{\prime}}\Big{(}\frac{l}{\delta^{2}\delta_{1}^{2}\delta_{2}^{2}}\Big{)}.\end{split}$

Note that $(\delta_{1}^{\prime},\delta_{2}^{\prime})=1$, so the form
$(\delta_{1}^{\prime})^{2}x_{1}^{2}+(\delta_{2}^{\prime})^{2}x_{2}^{2}$ is
primitive and $f=\delta_{1}^{\prime}\delta_{2}^{\prime}$ is squarefree.
Moreover, the argument of $r_{\delta^{\prime}_{1},\delta_{2}^{\prime}}$ is
coprime to $\delta_{1}^{\prime}\delta_{2}^{\prime}$. We have by (2.3) and
orthogonality of characters

$r_{a,b}(m)=\frac{w_{ab}}{h_{ab}}\sum_{\chi\in\widehat{\mathcal{C}}_{ab}}\bar{\chi}(C_{a,b})\sigma(\chi,m),\quad\sigma(\chi,m)=\sum_{N\mathfrak{a}=m}\chi(\mathfrak{a}).$

If $\chi$ is real and belongs to the odd divisor
$D\mid\delta_{1}^{\prime}\delta_{2}^{\prime}$, then by (2.5) and (2.4) for
$(m,\delta_{1}^{\prime}\delta_{2}^{\prime})=1$ we have

$\sigma(\chi,m)=\chi_{D^{\ast}}(m)\\#\\{N\mathfrak{a}=m\\}=\chi_{D^{\ast}}(m)r(m).$

Combining this with Lemma 2.1, we obtain

(2.11) $\mathcal{S}_{\leq
2}=\sum_{\delta_{1}\delta_{1}^{\prime}=d_{1}^{\prime}}\sum_{\delta_{2}\delta_{2}^{\prime}=d_{2}^{\prime}}\frac{w_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}{h_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}\sum_{2\nmid
D\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\sum_{\begin{subarray}{c}l\equiv
0\,(\text{{\rm mod }}(\delta\delta_{1}\delta_{2})^{2})\\\
(l,\delta_{1}^{\prime}\delta_{2}^{\prime})=1\\\
l\in\mathcal{L}\end{subarray}}\chi_{D^{\ast}}\Big{(}\frac{l}{\delta^{2}\delta_{1}^{2}\delta_{2}^{2}}\Big{)}r\Big{(}\frac{l}{\delta^{2}\delta_{1}^{2}\delta_{2}^{2}}\Big{)},$

which yields (2.7) after summing over $2\nmid
D\mid\delta_{1}^{\prime}\delta_{2}^{\prime}$.

If $\text{ord}(\chi)\geq 3$, it remains to show that $\sigma(\chi,m)$ is a
normalized Hecke eigenvalue of a weight 1 newform form of level dividing
$4d_{1}^{2}d_{2}^{2}$ and character $\chi_{-4}$. To see this, we observe first
that by splitting into ideal classes we have that

$f_{\chi}(z)=\sum_{\mathfrak{a}\subseteq\mathcal{O}_{d_{1}d_{2}}}\chi(\mathfrak{a})e(N\mathfrak{a}\cdot
z)$

is a linear combination of theta series corresponding to forms
$F\in\tilde{\mathcal{C}}_{d_{1}d_{2}}$ and hence by [Iw4, Theorem 10.9] a
modular form of weight 1, character $\chi_{-4}$ and level $4(d_{1}d_{2})^{2}$.
Since $\text{ord}(\chi)\geq 3$, it is a cusp form. This is a classical fact
that can be proved in several ways: by the parametrization of Eisenstein
series, a modular form is non-cuspidal if and only if the associated Dirichlet
series factorizes into two Dirichlet $L$-functions, and this happens if and
only if its Rankin-Selberg square $L$-function has a double pole at $s=1$. The
Rankin-Selberg square of a class group character $\chi$ is, up to finitely
many Euler factors, $\zeta(s)L(s,\chi^{2})$ which has a double pole at $s=1$
if and only if $\text{ord}(\chi)\leq 2$. Using (2.2), one can check from the
definition of the Hecke operators $T_{m}$ that

$T_{m}f_{\chi}(z)=\sigma(\chi,m)f_{\chi}(z)$

for $(m,d_{1}d_{2})=1$. Hence by strong multiplicity one, $f_{\chi}$ belongs
to the space generated by some newform of level dividing
$4d_{1}^{2}d_{2}^{2}$, and for $(m,d_{1}d_{2})=1$ the numbers $\sigma(\chi,m)$
coincide with the Hecke eigenvalues. This completes the proof of the lemma.

Remark: The formula (2.7) depends on Lemma 2.1. For general quadratic forms
not covered by Lemma 2.1 the summation over $D$ can be carried out in the same
way. This yields an expression similar to (2.7) with a set
$\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}$ which may be different
from the one defined in (2.8) but which has the same cardinality, namely
$\phi(\delta_{1}^{\prime}\delta_{2}^{\prime})/G_{\delta_{1}^{\prime}\delta_{2}^{\prime}}$.
This is a consequence of the fact that numbers coprime to the order can only
be represented in one genus. More precisely, the Chinese Remainder Theorem
induces a bijection
$\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\cong\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\mathcal{G}_{p}$
where $\mathcal{G}_{p}\subseteq(\mathbb{Z}/p\mathbb{Z})^{\ast}$ has
cardinality $\phi(p)/2$ for odd $p$ and cardinality 1 for $p=2$. This is all
the information needed in the subsequent arguments. In this way, our main
results generalize to other quadratic forms than sums of two squares, although
some extra care may be necessary at the last step of (2.10).

##  3\. Additive problems in cusp forms

In this section we deal with the innermost sum of (2.9) when the set
$\mathcal{L}$ consists of numbers $n-\ell$ where $\ell$ is either prime or
smooth. We generally consider a holomorphic or Maaß cuspidal Hecke newform
$\phi$ of level $4\mid N$, character $\chi_{-4}$ and Hecke eigenvalues
$\lambda(n)$ whose archimedean parameter (weight or spectral parameter) we
denote by $\mu$. We start with two auxiliary results.

######  Proposition 3.1.

Let $M,X,Z\geq 1$, $\Delta\in\mathbb{N},$ and
$f,\sigma\in\mathbb{Z}\setminus\\{0\\}$. Let $\alpha_{m},\beta_{n}$ be
sequences supported on $[M,2M]$, $[X,2X]$ respectively. Suppose that
$|\alpha_{m}|\ll m^{\epsilon}$ for any $\epsilon>0$ and $\alpha_{m}\beta_{n}$
vanishes unless $\sigma mn+f$ is in some dyadic interval $[\Xi,2\Xi]$ with
$|\sigma|MX/Z\ll\Xi\ll|\sigma|MX+|f|$. Then

$\begin{split}\underset{\Delta\mid\sigma
mn+f}{\sum\sum}\alpha_{m}\beta_{n}\lambda\Big{(}\frac{\sigma
mn+f}{\Delta}\Big{)}&\ll
P^{A}\|\beta\|\big{(}M^{11/14}X^{1/2}+M^{5/4}X^{3/8}\big{)}^{1+\varepsilon}\end{split}$

for some absolute constant $A>0$ and any $\varepsilon>0$, where
$P=\Delta|\sigma|(1+|\mu|)NZ(1+|f|/MX)$.

######  Proposition 3.2.

Let $\Delta,q,d\in\mathbb{N},r,f\in\mathbb{Z}\setminus\\{0\\}$,
$Z,X_{1},X_{2},X_{3}\geq 1/2$. Suppose $(\Delta,q)=1$ and that at least one of
$r,f$ is positive. Let $G$ be a function with support on
$\bigtimes[X_{j},2X_{j}]$ and
$G^{(\nu_{1},\nu_{2},\nu_{3})}\ll_{{\bm{\nu}}}Z^{\nu_{1}+\nu_{2}+\nu_{3}}X_{1}^{-\nu_{1}}X_{2}^{-\nu_{2}}X_{3}^{-\nu_{3}}$
for all $\bm{\nu}\in\mathbb{N}_{0}^{3}$. Write $X=|r|X_{1}X_{2}X_{3}$ and
suppose that $G(k,l,m)$ vanishes unless $rklm+f$ is in some dyadic interval
$[\Xi,2\Xi]$ with $X/Z\ll\Xi\ll X+|f|$. Then

(3.1) $\displaystyle\sum_{\begin{subarray}{c}k,l,m\\\
rklm\equiv-f\,(\textup{mod}\,\Delta)\\\ rklm\equiv
d\,(\textup{mod}\,q)\end{subarray}}G(k,l,m)\lambda\Big{(}\frac{rklm+f}{\Delta}\Big{)}\ll
P^{A}X^{1-1/54+\varepsilon}$

for some absolute constant $A$ and any $\varepsilon>0$, where
$P=qr\Delta(1+|\mu|)NZ(1+|f|/X)$.

Better bounds could be obtained with more work, but these bounds suffice for
our purpose. We postpone the proofs to the next section and state the two main
results of this section. As usual, $\Lambda$ denotes the von Mangoldt
function.

######  Theorem 3.3.

There exist absolute constants $A,\eta>0$ with the following property. Let
$\sigma,f\in\mathbb{Z}\setminus\\{0\\}$, $X,Z\geq$, $\Delta,q,d\in\mathbb{N}$
with $(\sigma q,\Delta)=1$. Let $G$ be a smooth function supported on $[X,2X]$
with $G^{(\nu)}\ll_{\nu}(X/Z)^{-\nu}$ for $\nu\in\mathbb{N}_{0}$. Suppose that
$G(n)$ vanishes unless $\sigma n+f$ is in some dyadic interval $[\Xi,2\Xi]$
with $|\sigma|X/Z\ll\Xi\ll|\sigma|X+|f|$. Then

(3.2) $\displaystyle\sum_{\begin{subarray}{c}\sigma
n\equiv-f\,(\textup{mod}\,\Delta)\\\ n\equiv
d\,(\textup{mod}\,q)\end{subarray}}\lambda\Big{(}\frac{\sigma
n+f}{\Delta}\Big{)}\Lambda(n)G(n)\ll P^{A}X^{1-\eta}$

where $P=q|\sigma|\Delta(1+|\mu|)NZ(1+|f|/|\sigma|X)$.

Proof. Based on Propositions 3.1 and 3.2, this could be proved similarly as in
[ABL, Prop. 9.1] which in turn is the argument of [Pi, Section 9]. The proof
in [Pi] uses Vaughan’s identity to decompose $\Lambda$ iteratively three
times. This is slightly cumbersome, but has the advantage that we only need
$\alpha_{m}$ to be supported on squarefree integers in the bilinear estimate
in Proposition 3.1, which could yield better error terms numerically. Here we
give a shorter independent proof at the cost of slightly weaker error terms.
Instead of using Vaughan’s identity as in [Pi], we apply Heath-Brown’s
identity in the form

(3.3)
$\displaystyle\Lambda(n)=\sum_{j=1}^{4}(-1)^{j-1}\binom{j}{4}\sum_{m_{1},\dots,m_{j}\leq
X^{1/4}}\prod_{i=1}^{j}\mu(m_{i})\sum_{m_{1}\cdots m_{j}n_{1}\cdots
n_{j}=n}\log n_{1}$

for $1\leq n\leq X$. Next we apply a smooth partition of unity to the
variables $m_{i},n_{i}$. To be precise, let $0<\mathcal{Z}\leq 1$ be a
parameter to be chosen later and let $\psi(x)$ be a smooth function supported
on $[-1-\mathcal{Z},1+\mathcal{Z}]$ that equals $1$ on $[-1,1]$ and satisfies
$\psi^{(j)}(t)\ll\mathcal{Z}^{j}$. Let
$\mathcal{D}=\\{(1+\mathcal{Z})^{m},m\geq 0\\}$. Then we have the smooth
partition of unity

(3.4) $\displaystyle 1=\sum_{N\in\mathcal{D}}\psi_{N}(n)$

for any natural number $n$, where
$\psi_{N}(n)=\psi(n/N)-\psi((1+\mathcal{Z})n/N)$. Here we can choose
$\mathcal{Z}=1$ (later parts of the paper we use the same argument with
different choices of $\mathcal{Z}$) so that

(3.5) $\displaystyle\sum_{\begin{subarray}{c}\sigma
n\equiv-f\,(\textup{mod}\,\Delta)\\\ n\equiv
d\,(\textup{mod}\,q)\end{subarray}}\lambda\Big{(}\frac{\sigma
n+f}{\Delta}\Big{)}\Lambda(n)G(n)\ll{(\log
X)}^{8}\max_{\begin{subarray}{c}M_{1},\dots,M_{j}\\\
N_{1},\dots,N_{j}\end{subarray}}|S|$

where

(3.6) $\displaystyle
S=\sum_{\begin{subarray}{c}\sigma\prod_{i=1}^{j}m_{i}n_{i}\equiv-f\,(\textup{mod}\,\Delta)\\\
\prod_{i=1}^{j}m_{i}n_{i}\equiv d\,(\textup{mod}\,q)\end{subarray}}$
$\displaystyle\prod_{i=1}^{j}\mu(m_{i})\psi_{M_{i}}(m_{i})\log(n_{1})\psi_{N_{1}}(n_{1})\prod_{i=2}^{j}\psi_{N_{i}}(n_{i})$
(3.7)
$\displaystyle\times\lambda\Big{(}\frac{\sigma\prod_{i=1}^{j}m_{i}n_{i}+f}{\Delta}\Big{)}G\Big{(}\prod_{i=1}^{j}m_{i}n_{i}\Big{)}.$

Therefore it is enough to show that there exist some absolute constants
$A,\eta>0$ such that

(3.8) $\displaystyle S\ll P^{A}X^{1-\eta}.$

We distinguish two cases. If there exists some $i$ such that $X^{\eta_{0}}\leq
M_{i}\text{ (or $N_{i}$)}\leq X^{1/4+\eta_{0}}$ for some $\eta_{0}>0$, then we
can split $m_{i}$ or $n_{i}$ into residue classes modulo $q$, use Mellin
inversion to separate variables $m_{i},n_{i}$ (see e.g. [Pi, Section 7]) and
then apply Proposition 3.1 to obtain

(3.9) $\displaystyle S\ll
P^{A}X^{\varepsilon}\big{(}{X}^{1-3\eta_{0}/14}+X^{31/32+3\eta_{0}/8}\big{)}.$

Otherwise, we must have

$R:=\prod_{\begin{subarray}{c}i:M_{i}\leq X^{\eta_{0}},N_{i}\leq
X^{\eta_{0}}\end{subarray}}M_{i}N_{i}\leq X^{8\eta_{0}}$

and

$\\#\\{1\leq i\leq j:N_{i}\geq X^{1/4+\eta_{0}}\\}\leq 3,\quad 1\leq j\leq 4,$

in which case we can apply Proposition 3.2 to obtain

(3.10) $\displaystyle S\ll P^{A}X^{1-1/54+8A\eta_{0}+\varepsilon}.$

Combining the bounds in these two cases and chossing $\eta_{0}$ suitably, we
complete the proof of (3.8).

Our second main result treats the case of smooth numbers. As usual, $P^{+}(n)$
denotes the largest prime factor of $n$ with the convention $P^{+}(1)=1$.

######  Theorem 3.4.

There exist absolute constants $A,\eta>0$ with the following property. Let
$\sigma,f\in\mathbb{Z}\setminus\\{0\\}$, $X,Z,y\geq 1$,
$\Delta,q,d\in\mathbb{N}$ with $(\sigma q,\Delta)=1$. Let $G$ be a smooth
function supported on $[X,2X]$ with $G^{(\nu)}\ll_{\nu}(X/Z)^{-\nu}$. Suppose
that $G(n)$ vanishes unless $\sigma n+f$ is in some dyadic interval
$[\Xi,2\Xi]$ with $|\sigma|X/Z\ll\Xi\ll|\sigma|X+|f|$. Then

(3.11) $\displaystyle\sum_{\begin{subarray}{c}\sigma
n\equiv-f\,(\textup{mod}\,\Delta)\\\ n\equiv d\,(\textup{mod}\,q)\\\
P^{+}(n)\leq y\end{subarray}}\lambda\Big{(}\frac{\sigma
n+f}{\Delta}\Big{)}G(n)\ll P^{A}X^{1-\eta}.$

where $P=q|\sigma|\Delta(1+|\mu|)NZ(1+|f|/|\sigma|X)$.

Proof. The proof follows along the lines in [FT90, Lemme 2.1] on averages of
smooth numbers in arithmetic progressions to large moduli, which we also
generalize (see Proposition 6.1). Throughout the proof, we use $A$ to denote
some absolute positive constant, not necessarily the same at each occurrence.
For $t\geq 1$ let $g_{t}(n)$ be the characteristic function on numbers $n$
with $P^{+}(n)\leq t$. The starting point is Buchstab’s identity that we
iterate. For $y\geq 1$ we have

(3.12) $\displaystyle g_{y}(n)=1-\sum_{\begin{subarray}{c}p\mid n\\\
p>y\end{subarray}}g_{p}\Big{(}\frac{n}{p}\Big{)}=1+\sum_{j=1}^{3}(-1)^{j}\sum_{\begin{subarray}{c}p_{1}\cdots
p_{j}\mid n\\\
y<p_{1}<\cdots<p_{j}\end{subarray}}1+\sum_{\begin{subarray}{c}p_{1}\cdots
p_{4}\mid n\\\
y<p_{1}<\cdots<p_{4}\end{subarray}}g_{p_{4}}\Big{(}\frac{n}{p_{1}\cdots
p_{4}}\Big{)}.$

Thus

(3.13) $\displaystyle\sum_{\begin{subarray}{c}\sigma
n\equiv-f\,(\textup{mod}\,\Delta)\\\ n\equiv d\,(\textup{mod}\,q)\\\
P^{+}(n)\leq y\end{subarray}}\lambda\Big{(}\frac{\sigma
n+f}{\Delta}\Big{)}G(n)=\sum_{\begin{subarray}{c}\sigma
n\equiv-f\,(\textup{mod}\,\Delta)\\\ n\equiv
d\,(\textup{mod}\,q)\end{subarray}}\lambda\Big{(}\frac{\sigma
n+f}{\Delta}\Big{)}g_{y}(n)G(n)=S_{0}+\sum_{i=1}^{3}(-1)^{i}S_{i}+\overline{S},$

say, where

(3.14) $\displaystyle S_{0}=\sum_{\begin{subarray}{c}\sigma
n\equiv-f\,(\textup{mod}\,\Delta)\\\ n\equiv
d\,(\textup{mod}\,q)\end{subarray}}\lambda\Big{(}\frac{\sigma
n+f}{\Delta}\Big{)}G(n),$ (3.15) $\displaystyle
S_{i}=\sum_{\begin{subarray}{c}\sigma n\equiv-f\,(\textup{mod}\,\Delta)\\\
y<p_{1}<\cdots<p_{i}\\\ p_{1}\cdots p_{i}m\equiv
d\,(\textup{mod}\,q)\end{subarray}}\lambda\Big{(}\frac{\sigma p_{1}\cdots
p_{i}m+f}{\Delta}\Big{)}G(p_{1}\cdots p_{i}m),$ (3.16)
$\displaystyle\overline{S}=\sum_{\begin{subarray}{c}\sigma
n\equiv-f\,(\textup{mod}\,\Delta)\\\ y<p_{1}<\cdots<p_{4}\\\ p_{1}\cdots
p_{4}m\equiv d\,(\textup{mod}\,q)\end{subarray}}\lambda\Big{(}\frac{\sigma
p_{1}\cdots p_{4}m+f}{\Delta}\Big{)}g_{p_{4}}(m)G(p_{1}\cdots p_{4}m).$

For $S_{0}$, we apply [ABL, Corollary 7.6] to obtain

(3.17) $\displaystyle S_{0}=\sum_{k\equiv\bar{\Delta}(f+\sigma d)\,(\text{mod
}q)}\lambda(k)G\Big{(}\frac{\Delta k-f}{\sigma}\Big{)}\ll P^{A}.$

For $\overline{S}$, we localize $p_{i}$ in intervals $(P_{j},P_{j+1}]$ where
$P_{j}=y(1+\mathcal{Z})^{j}$ with some $\mathcal{Z}\leq 1$ to be chosen later
and $0\leq j\leq J=1+\lfloor\frac{\log(X/y)}{\log(1+\mathcal{Z})}\rfloor$.
Then

(3.18) $\displaystyle\overline{S}$
$\displaystyle=\sum_{\begin{subarray}{c}0\leq i_{1}\leq i_{2}\leq i_{3}\leq
i_{4}\leq J\\\ p_{k}\in(P_{i_{k}},P_{i_{k}+1}]\\\ \sigma p_{1}\cdots
p_{4}m\equiv-f\,(\textup{mod}\,\Delta)\\\ p_{1}\cdots p_{4}m\equiv
d\,(\textup{mod}\,q)\end{subarray}}\lambda\Big{(}\frac{\sigma p_{1}\cdots
p_{4}m+f}{\Delta}\Big{)}g_{p_{4}}(m)G(p_{1}\cdots
p_{4}m)+O\Big{(}P^{A}X^{1+\varepsilon}\mathcal{Z}^{1/2}\Big{)}.$

To justify this, we see that $\overline{S}$ and the sum in (3.18) differ only
by integers $n$ that lie in $[X(1+\mathcal{Z})^{-4},X(1+\mathcal{Z})^{4}]$ or
have at least two prime factors $p_{i},p_{j}$ with
$p_{i}<p_{j}<(1+\mathcal{Z})p_{i}$. The contribution from these integers can
be bounded by

(3.19)
$\displaystyle\Big{(}\sum_{\begin{subarray}{c}X(1+\mathcal{Z})^{-4}<n\leq
X(1+\mathcal{Z})^{4}\end{subarray}}+\sum_{\begin{subarray}{c}p_{i}<p_{j}<(1+\mathcal{Z})p_{i}\\\
p_{i}p_{j}\mid n\\\ n\ll
X\end{subarray}}\Big{)}\Big{|}\lambda\Big{(}\frac{\sigma
n+f}{\Delta}\Big{)}\Big{|}$ (3.20)
$\displaystyle\ll\Bigg{(}\Big{(}\sum_{\begin{subarray}{c}X/(1+\mathcal{Z})^{-4}<n\leq
X(1+\mathcal{Z})^{4}\end{subarray}}1\Big{)}^{1/2}+\Big{(}\sum_{\begin{subarray}{c}n\ll
X\\\ p_{i}p_{j}\mid n\\\
p_{i}<p_{j}\leq(1+\mathcal{Z})p_{i}\end{subarray}}1\Big{)}^{1/2}\Bigg{)}\Big{(}\sum_{\begin{subarray}{c}n\ll
X\\\ \sigma
n\equiv-f\,(\textup{mod}\,\Delta)\end{subarray}}\Big{|}\lambda\Big{(}\frac{\sigma
n+f}{\Delta}\Big{)}\Big{|}^{2}\Big{)}^{1/2}$ (3.21) $\displaystyle\ll
P^{A}X^{1+\varepsilon}\mathcal{Z}^{1/2}.$

Since $y<P_{i_{1}}\ll X^{1/4}$, we can apply Proposition 3.1 with
$\mathbb{m}=p_{1}$ and $\mathbb{n}=|\sigma|p_{2}\cdots p_{4}m$ to the main
term in (3.18) by splitting $\mathbb{m},\mathbb{n}$ into residue classes
modulo $q$ to obtain

(3.22)
$\overline{S}\ll\mathcal{Z}^{-4}X^{\varepsilon}P^{A}\Big{(}\frac{X}{y^{3/14}}+X^{31/32}\Big{)}+P^{A}X^{1+\varepsilon}\mathcal{Z}^{1/2}\ll
P^{A}X^{1+\varepsilon}\max(y^{-1/42},X^{-1/288})$

upon choosing $\mathcal{Z}=\max(y^{-1/21},X^{-1/144})$.

For $S_{k}$, $1\leq k\leq 3$, we first replace the characteristic function on
primes with the von Mangoldt function $\Lambda$. As above, we see that the
contribution of higher prime powers is at most

$\ll P^{A}X^{1+\varepsilon}y^{-1/2}$

which can be absorbed in the existing bounds. Now similar to the proof of
Theorem 3.8, we use Heath-Brown’s identity (3.3) to decompose the prime
variables. Again we split all variables into short intervals using the smooth
partition (3.4) for some parameter $\mathcal{Z}$ to be chosen later. We first
bound

(3.23)
$\displaystyle\begin{split}\tilde{S}=\sum_{m}\sum_{m_{i}}&\sum_{\begin{subarray}{c}n_{i}\\\
\sigma mm_{1}\cdots m_{r}n_{1}\cdots n_{s}\equiv-f\,(\textup{mod}\,\Delta)\\\
mn_{1}\cdots m_{r}n_{1}\cdots n_{s}\equiv
d\,(\textup{mod}\,q)\end{subarray}}\psi_{M}(m)\prod_{i=1}^{r}\mu(m_{i})\psi_{M_{i}}(m_{i})\prod_{j=1}^{s}\psi_{N}(n_{j})\\\
&\lambda\Big{(}\frac{\sigma mm_{1}\cdots m_{r}n_{1}\cdots
n_{s}+f}{\Delta}\Big{)}G(mm_{1}\cdots m_{r}n_{1}\cdots n_{s})\end{split}$

where $1\leq r,s\leq 12$, $M\prod_{i=1}^{r}M_{i}\prod_{j=1}^{s}N_{j}\asymp X$
and $M_{i}\ll X^{1/4}$. Again we distinguish two cases.

If there exists a subset $\mathcal{I}\subset\\{M,M_{i},N_{j}\\}$ such that
$K:=\prod_{I\in\mathcal{I}}I$ such that $X^{\eta_{0}}<K\leq X^{1/4+\eta_{0}}$,
then we can apply Proposition 3.1 to obtain

(3.24) $\displaystyle\tilde{S}\ll
P^{A}X^{\varepsilon}\big{(}{X^{1-3\eta_{0}/14}}+X^{31/32+3\eta_{0}/8}\big{)}.$

If such $\mathcal{I}$ does not exist, then all the $M_{i}$’s and possibly some
of the $M$, $N_{j}$’s can be combined into $R\ll X^{\eta_{0}}$ and the number
of $M$,$N_{j}$’s of size $\gg X^{1/4+\eta_{0}}$ is less than, or equal to
three. So it is enough to bound

(3.25) $\displaystyle\sum_{r\ll
R|\sigma|}\Big{|}\sum_{\begin{subarray}{c}k,l,m\\\
rklm\equiv-f\,(\textup{mod}\,\Delta)\\\ rklm\equiv
d\,(\textup{mod}\,q)\end{subarray}}\alpha_{r}\lambda\Big{(}\frac{rklm+f}{\Delta}\Big{)}\psi_{K}(k)\psi_{L}(l)\psi_{M}(m)G(rklm)\Big{|}$

which by Proposition 3.2 is

(3.26) $\displaystyle\ll P^{A}X^{1-1/54+A\eta_{0}+\varepsilon}$

for some absolute constant $A>0$. Then by the same argument as above we see
that

$S_{i}\ll
P^{A}X^{\varepsilon}(\mathcal{Z}^{-24}X^{1-1/54+A\eta_{0}+\varepsilon}+X\mathcal{Z}^{1/2}),\quad
1\leq i\leq 3$

and hence by choosing $\mathcal{Z}=X^{\eta_{1}}$ for some suitable
$\eta_{1}>0$ we obtain

(3.27) $S_{i}\ll P^{A}X^{1-\eta_{2}},\quad 1\leq i\leq 3$

for some $\eta_{2}>0$. Combining (3.17), (3.22) and (3.27), we have shown that
there exist some absolute constants $A,\eta>0$ such that

(3.28) $\displaystyle\sum_{\begin{subarray}{c}\sigma
n\equiv-f\,(\textup{mod}\,\Delta)\\\ n\equiv d\,(\textup{mod}\,q)\\\
P^{+}(n)\leq y\end{subarray}}\lambda\Big{(}\frac{\sigma
n+f}{\Delta}\Big{)}G(n)\ll
P^{A}X^{\varepsilon}\big{(}X^{1-\eta}+Xy^{-\eta}\big{)}.$

On the other hand, when $y$ is very small we can do better using the flexible
factorization of smooth numbers to create some bilinear structure so that
Proposition 3.1 can be applied directly. Recall [FT96, Lemme 3.1]: for any
$M\geq 1$, every $n\geq M$ with $P^{+}(n)\ll y$ has a unique representation in
the form

(3.29) $\displaystyle n=lm,\quad P^{+}(l)\leq P^{-}(m),\quad M\leq m\leq yM.$

We can separate $l$ and $m$ in the condition $P^{+}(l)\leq P^{-}(m)$ using
[Dr1, eq. (3.37)] with an acceptable error. Thus by the same argument as
before, we can localize $m$ into short intervals and apply Proposition 3.1 to
obtain

(3.30) $\displaystyle\sum_{\begin{subarray}{c}\sigma
n\equiv-f\,(\textup{mod}\,\Delta)\\\ n\equiv d\,(\textup{mod}\,q)\\\
P^{+}(n)\leq y\end{subarray}}\lambda\Big{(}\frac{\sigma
n+f}{\Delta}\Big{)}G(n)$ $\displaystyle\ll
P^{A}X^{\varepsilon}\big{(}\mathcal{Z}^{-1}(XM^{-3/14}+(My)^{3/8}X^{7/8})+X\mathcal{Z}^{1/2}\big{)}$
(3.31) $\displaystyle\ll P^{A}X^{1-1/66+\varepsilon}y^{1/22}$

by choosing $M=X^{7/33}y^{-7/11},\mathcal{Z}=X^{1/33}y^{-1/11}$. Applying
(3.28) when $y\geq X^{\eta}$ and (3.30) when $y\leq X^{\eta}$ for some
suitable $\eta>0$ we obtain the theorem.

Remark Similar to the proof of Theorem 3.3 and 3.4, we can replace
$\Lambda(n)$ or $\mathds{1}_{P^{+}(n)\leq y}$ by $\tau_{k}(n)$ and obtain an
unconditional power saving bound uniformly in all parameters.

##  4\. Proofs of Propositions 3.1 and 3.2

We still owe the proofs of Propositions 3.1 and 3.2. Recall that $P$ is the
product of the “unimportant” parameters which has slightly different meanings
in Proposition 3.1 and Proposition 3.2. For notational simplicity we write

(4.1) $R\preccurlyeq S\quad:\Longleftrightarrow\quad R\ll
X^{\varepsilon}P^{A}S$

for some sufficiently small $\varepsilon>0$ and some sufficiently large $A>0$,
not necessarily the same at each occurrence.

###  4.1. Proof of Proposition 3.1

This is an extension of [ABL, Proposition 8.1] where we relax the condition
$\alpha_{m}$ supported on squarefree numbers at the cost of slightly weaker
bounds. Let $\mathscr{B}(\alpha,\beta)$ denote the $m,n$-sum we want to bound.
We use the notation (4.1) with $P=\Delta|\sigma|(1+|\mu|)NZ(1+|f|/MX)$. Note
that we can assume without loss of generality that $\sigma=\\{\pm 1\\}$ as
otherwise we can set $\tilde{\beta}_{n}=\beta_{n}\mathds{1}_{\sigma\mid n}$.
When $\alpha_{m}$ is supported on squarefree numbers, then a straightforward
extension of [ABL, Proposition 8.1] (replacing the $F$ in the definition of
set of moduli $\mathcal{Q}$ by $[N_{1},D^{2}]\Delta_{1}$, with the notation
$\Delta=\Delta_{1}\Delta_{2}$ and $\Delta_{2}=(\Delta,(m_{3}m_{4})^{\infty})$
to accommodate the new parameter $\Delta$) shows

(4.2)
$\mathscr{B}(\alpha,\beta)\preccurlyeq\|\beta\|\big{(}(XM)^{1/2}+X^{1/4}M^{3/2}+X^{3/8}M^{5/4}\big{)}.$

To deduce the result for general sequences, we write

$\displaystyle\mathscr{B}(\alpha,\beta)=\underset{\Delta\mid\sigma
l^{2}mn+f}{\sum\sum}\mu^{2}(m)\alpha_{ml^{2}}\beta_{n}\lambda\Big{(}\frac{\sigma
ml^{2}n+f}{\Delta}\Big{)}.$

We choose a parameter $L>1$. By Hölder’s inequality, we see that the
contribution from $l\geq L$ gives

$\displaystyle\ll\Big{(}\sum_{L\leq l\ll M^{1/2}}\sum_{m\ll
M/l^{2}}\sum_{n\asymp
X}|\alpha_{ml^{2}}\beta_{n}|^{2}\Big{)}^{3/4}\Big{(}\sum_{L\leq l\ll
M^{1/2}}\sum_{m\ll M/l^{2}}\sum_{n\asymp X}|\lambda\Big{(}\frac{\sigma
ml^{2}n+f}{\Delta}\Big{)}|^{4}\Big{)}^{1/4}$
$\displaystyle\preccurlyeq\Big{(}\sum_{L\leq l\ll M^{1/2}}\sum_{m\ll
M/l^{2}}1\Big{)}^{3/4}\Big{(}\sum_{n}|\beta_{n}|^{2}\Big{)}^{1/2}\Big{(}\sum_{n\asymp
X}1\Big{)}^{1/4}(MX)^{1/4}\ll\|\beta\|\frac{MX^{1/2}}{L^{3/4}}$

using the well-known bound for the fourth moment of Hecke eigenvalues

$\sum_{n\leq Y}|\lambda(n)|^{4}\preccurlyeq Y.$

Indeed, the Dirichlet series $\sum_{n}\lambda_{\phi}(n)^{4}n^{-s}$ equals
$L(s,\text{sym}^{2}\phi\times\text{sym}^{2}\phi)L(s,\text{sym}^{2}\phi)^{2}\zeta(s)$
up to an Euler product that is absolutely convergent in $\Re s>1/2+2\theta$
where $\theta\leq 7/64$ is an admissible exponent for the Ramanujan-Petersson
conjecture. Hence if $C_{\phi}$ denotes the conductor of $\phi$, then we
conclude from the convexity bound and standard bounds for $L$-functions at
$s=1$ [XLi] the estimate

(4.3) $\displaystyle\sum_{m\leq x}|\lambda_{\phi}(m)|^{4}\ll
x(xC_{\phi})^{\varepsilon}+x^{1/2+2\theta+\varepsilon}C_{\phi}^{O(1)}.$

On the other hand, for $l\leq L$ we combine $n$ and $l^{2}$ to one variable
and apply (4.2) with
$\tilde{\beta}^{(l)}_{n}=\beta_{n/l^{2}}\mathds{1}_{l^{2}\mid n}$ to obtain

$\displaystyle\sum_{l\leq L}\sum_{m\asymp M/l^{2}}\sum_{n\asymp
Xl^{2}}\mu^{2}(m)\alpha_{ml^{2}}\tilde{\beta}_{n}^{(l)}\lambda\Big{(}\frac{\sigma
mn+f}{\Delta}\Big{)}$ $\displaystyle\preccurlyeq\sum_{l\leq
L}\|\tilde{\beta}^{(l)}\|\Big{(}(MX)^{1/2}+(Xl^{2})^{3/4}(M/l^{2})^{3/2}+(M/l^{2})^{5/4}(Xl^{2})^{3/8}\Big{)}$
$\displaystyle\ll\|\beta\|\big{(}L(MX)^{1/2}+X^{3/4}M^{3/2}+M^{5/4}X^{3/8}\big{)}.$

With $L=M^{2/7}$, we obtain

$\mathscr{B}(\alpha,\beta)\preccurlyeq\|\beta\|(X^{1/2}M^{11/14}+X^{1/4}M^{3/2}+M^{5/4}X^{3/8}).$

Here we can drop the middle term, because if it dominates the last term, then
$M>X^{1/2}$ in which case the claim is trivially true. This completes the
proof.

###  4.2. Proof of Proposition 3.2

This result has a precursor in [ABL, Theorem 2.5], but it turns out that here
the extra congruence conditions modulo $q$ and $\Delta$ are somewhat subtle
and not completely straightforward to implement due to well-known difficulties
in the Voronoi summation formula for general moduli. We therefore modify the
proof, the biggest difference being that we replace the delta-symbol method
([ABL, Lemma 7.3]) of Duke-Friedlander-Iwaniec with Jutila’s circle
method.111As an aside we remark that we could also follow Munshi’s strategy
[Mu2], but note that his Lemma 6 needs to be corrected by a factor $q_{1}$
when $q_{1}=\tilde{q}_{1}$.

Let us denote by $\mathscr{S}$ the $k,l,m$-sum that we want to bound and
recall that $P$ is the product of the “unimportant” parameters (keeping in
mind that the definition of $P$ differs slightly from the previous proof).
Assume without loss of generality $X_{1}\geq X_{2}\geq X_{3}$.

By Voronoi summation (cf. [ABL, Corollary 7.7]) it is easy to see that

(4.4) $\mathscr{S}\preccurlyeq(X/X_{1})^{3/2}.$

We can also write

$\displaystyle\mathscr{S}=\sum_{\begin{subarray}{c}k,l,m\\\ rklm\equiv
d\,(\text{mod
}q)\end{subarray}}\sum_{n}G(k,l,m)g(n)\lambda(n)\int_{0}^{1}e\big{(}\alpha(rklm+f-\Delta
n)\big{)}d\alpha.$

where the redundant function $g(n)$ has support on $\frac{1}{2}\Xi/\Delta\leq
n\leq 3\Xi/\Delta$ and satisfies $g(n)=1$ for $\Xi/\Delta\leq n\leq
2\Xi/\Delta$ and $g^{(\nu)}(n)\ll(\Xi/\Delta)^{-\nu}$ for all
$\nu\in\mathbb{N}_{0}$. We now employ Jutila’s circle method as in the
corollary to [Ju, Lemma 1], i.e. we insert the constant function into the
$\alpha$-integral and approximate it by a step function of small rational
intervals. This device will simplify the argument especially with respect to
the extra congruence condition on $q$. Let $C$ be a large parameter and
$\mathcal{C}\subset[C,2C]$ be the set of moduli which are coprime to $\Delta
Nq$. Define

$L=\sum_{c\in\mathcal{C}}\phi(c)\gg C^{2}(\Delta NqC)^{-\varepsilon}$

and let $\delta$ be a real number such that $C^{-2}\ll\delta\ll C^{-1}.$ Then
we have (bounding the error term with Cauchy-Schwarz and Rankin-Selberg)

$\displaystyle\mathscr{S}=\tilde{\mathscr{S}}+O\Big{(}\frac{(X\Xi/\Delta)^{1/2}}{\delta^{1/2}C}(XC)^{\varepsilon}\Big{)}$

where

$\displaystyle\tilde{\mathscr{S}}=\sum_{\begin{subarray}{c}k,l,m\\\ rklm\equiv
d\,(\text{mod
}q)\end{subarray}}\sum_{n}G(k,l,m)g(n)\lambda(n)\frac{1}{L}\sum_{c\in\mathcal{C}}\underset{a\,(\text{mod
}c)}{\left.\sum\right.^{\ast}}\frac{1}{2\delta}\int_{-\delta}^{\delta}e\Big{(}\Big{(}\frac{a}{c}+\alpha\Big{)}(rklm+f-\Delta
n)\Big{)}d\alpha.$

We now apply Voronoi summation [KMV, Theorem A.4] to the $n$-sum and note that
by construction $(\Delta N,c)=1$ (this flexibility is the main advantage of
the present set-up). We obtain

$\sum_{n}g(n)e(\alpha\Delta
n)\lambda(n)e\Big{(}\frac{a\Delta}{c}n\Big{)}=\frac{\xi}{c\sqrt{N}}\sum_{\pm}\chi_{-4}(\mp
c)\sum_{n}\lambda(n)e\Big{(}\mp\frac{\overline{a\Delta
N}}{c}n\Big{)}\mathcal{G}^{\pm}\Big{(}\frac{n}{c^{2}N}\Big{)}$

for $(a,c)=1$ , some constant $\xi\in S^{1}$ depending only on the cusp form
$\phi$ and functions $\mathcal{G}^{\pm}$ which by [ABL, Lemma 7.5] satisfy the
bound

$\displaystyle
y^{\nu}\frac{d^{\nu}\mathcal{G^{\pm}}(y)}{dy^{\nu}}\ll_{A,\nu}\frac{\Xi}{\Delta}\Big{(}1+\frac{1}{(y\Xi/\Delta)^{2\tau+\varepsilon}}\Big{)}\Big{(}(1+|\mu|)\Big{(}1+\sqrt{\frac{y\Xi}{\Delta}}\Big{)}\Big{)}^{\nu}\Big{(}1+\frac{y\Xi/\Delta}{(\delta\Xi/\Delta+1)^{2}}+\frac{y\Xi/\Delta}{(1+|\mu|)^{2}}\Big{)}^{-A}$

where $\tau=0$ if $\phi$ is holomorphic and $\tau=\Im t_{\phi}$ if $\phi$ is
Maaß with spectral parameter $t_{\phi}$. We choose

$\delta=1/X.$

With this choice we can truncate the $n$-sum at $\preccurlyeq C^{2}/X$ and
obtain

$\begin{split}\mathscr{S}\preccurlyeq\frac{X}{L}&\sum_{\pm}\sum_{c\in\mathcal{C}}\sum_{n\preccurlyeq
C^{2}/X}\frac{|\lambda(n)|}{c}\Big{(}1+\frac{C^{2}}{nX}\Big{)}^{2\tau}\Big{|}\sum_{k,l,m}G(k,l,m)e\Big{(}\Big{(}\alpha+\frac{b}{q}\Big{)}rklm\Big{)}S(rklm+f,\pm\overline{\Delta}n,c)\Big{|}+\frac{X^{3/2}}{C}.\end{split}$

The factor $e(\alpha rklm)$ can be incorporated into $G$ at essentially no
cost, since $\alpha rklm\ll\delta X=1$. When $X_{1}\ll C$, we can bound the
$k,l,m$-sum using [ABL, Lemma 7.2] to obtain

$\preccurlyeq\frac{X(c,f,n)^{1/2}}{c^{1/2}}+\Big{(}(c,f)^{1/2}c^{7/4}+X_{1}^{1/2}c^{3/2}+(X_{2}X_{3})^{1/2}c^{5/4}+X_{1}(X_{2}X_{3})^{1/2}c^{1/2}\Big{)}c_{\square}^{1/4}$

where $c_{\square}$ is the squarefull part of $c$. We can now evaluate the
sums over $n$ (cf. [ABL, (7.1)]) and $c$ (with Rankin’s trick, cf. two
displays after [ABL, (8.3)]) getting

$\begin{split}\mathscr{S}&\preccurlyeq\frac{X}{C^{1/2}}+C^{7/4}+X_{1}^{1/2}C^{3/2}+X^{1/3}C^{5/4}+X_{1}^{1/2}X^{1/2}C^{1/2}+\frac{X^{3/2}}{C}\\\
\end{split}$

(recall that $X_{1}\geq X_{2}\geq X_{3}$). At this point we make the
admissible choice $C=X^{1/2+1/54}$ getting

(4.5) $\begin{split}\mathscr{S}\preccurlyeq
X^{53/54}+X_{1}^{1/2}X^{7/9}.\end{split}$

Then the claim follows from (4.5) when $X^{1/3}\leq X_{1}\leq X^{2/5}$ and
from (4.4) when $X_{1}\geq X^{2/5}$.

##  5\. Proof of Theorem 1.1

###  5.1. Primes in arithmetic progressions

Before we start with the analysis of the main term, we recall [ABL, Theorem
2.1] on equidistribution of primes in long arithmetic progressions under GRH.

######  Proposition 5.1.

Assume GRH. There exists some absolute constant $\varpi>0$ with the following
property. Let $x\geq 2$, $c,d\in\mathbb{N}$, $d\mid c^{\infty}$,
$c_{0},d_{0}\in\mathbb{Z}$, $(d_{0},d)=(c_{0},c)=1$,
$a_{1},a_{2}\in\mathbb{Z}\setminus\\{0\\}$ such that for

$Q\leq x^{1/2+\varpi},\quad|a_{1}|\leq x^{1+\varpi},\quad|a_{2}|\leq
x^{\varpi},\quad c,d\leq x^{\varpi}$

we have

$\displaystyle\sum_{\begin{subarray}{c}q\leq Q\\\ (q,a_{1}a_{2})=1\\\ q\equiv
c_{0}\,(\text{{\rm mod
}}c)\end{subarray}}\Big{(}\sum_{\begin{subarray}{c}n\leq x\\\ n\equiv
a_{1}\overline{a_{2}}\,(\text{{\rm mod }}q)\\\ n\equiv d_{0}(\text{{\rm mod
}}d)\end{subarray}}\Lambda(n)-\frac{1}{\phi(qd)}\sum_{\begin{subarray}{c}n\leq
x\\\ (n,qd)=1\end{subarray}}\Lambda(n)\Big{)}\ll x^{1-\varpi}.$

It is easy to see that we can replace the von Mangoldt function by the
characteristic function on primes.

###  5.2. Preparing for the sieve

In this section, we use $\kappa$ to denote a sufficiently small (depending on
$\varpi$ in Proposition 5.1 and $A,\eta$ as in Theorem 3.3) positive constant.
We use $\varepsilon$ to denote an arbitrarily small positive constant.

Let $\textbf{d}=(d_{1},d_{2})$ denote a pair of two squarefree numbers with
$d_{1},d_{2}\leq n^{\kappa}$. In preparation for a sieve we define

$\mathcal{A}_{\textbf{d}}(n)=\\{(p,x_{1},x_{2})\mid
p+d_{1}^{2}x_{1}^{2}+d_{2}^{2}x_{2}^{2}=n\\}$

(where of course $p$ denotes a prime). As usual, we denote by $c_{p}(n)$ the
Ramanujan sum. The key input for the sieve is the following:

######  Proposition 5.2.

Assume GRH. With the above notation, there exists some absolute constant
$\kappa>0$ such that uniformly for $d_{1},d_{2}\leq n^{\kappa}$ we have

$\\#\mathcal{A}_{\textbf{d}}(n)=\operatorname{Li}(n)\mathfrak{S}_{d_{1},d_{2}}(n)+O(n^{1-\kappa})$

where the singular series $\mathfrak{S}_{d_{1},d_{2}}(n)$ is given by

(5.1)
$\frac{\pi}{d_{1}d_{2}}\prod_{\begin{subarray}{c}p\mid(d_{1},d_{2})\end{subarray}}\Big{(}1-\frac{c_{p}(n)}{p-1}\Big{)}\prod_{\begin{subarray}{c}p\mid
d_{1}d_{2}\\\ p\nmid(d_{1},d_{2})\\\ p\nmid
2n\end{subarray}}\Big{(}1-\frac{(\frac{n}{p})}{p-1}\Big{)}\prod_{p\nmid
d_{1}d_{2}n}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}\prod_{\begin{subarray}{c}p\mid
n\\\ p\nmid 2d_{1}d_{2}\end{subarray}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}.$

_Remark:_ One can check that this matches the main term coming from a formal
application of the circle method. In particular, we see that
$\mathfrak{S}_{d_{1},d_{2}}(n)=0$ if $(d_{1},d_{2},n)>1$ as it should.

Proof. Let
$\delta=(d_{1},d_{2}),d_{1}^{\prime}=d_{1}/\delta,d_{2}^{\prime}=d_{2}/\delta$
as in Lemma 2.2. By Lemma 2.2 and Theorem 3.3 (with $\kappa$ sufficiently
small depending on the constants $A,\eta$) we have

(5.2)
$\\#\mathcal{A}_{\textbf{d}}(n)=\sum_{\delta_{1}\delta_{1}^{\prime}=d_{1}^{\prime}}\sum_{\delta_{2}\delta_{2}^{\prime}=d_{2}^{\prime}}\frac{w_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}{h_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}G_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\sum_{w\in\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}\sum_{\begin{subarray}{c}p\equiv
n\,(\textup{mod}\,(\delta\delta_{1}^{\prime}\delta_{2}^{\prime})^{2})\\\
n-p\equiv
w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\end{subarray}}r\left(\frac{n-p}{\delta\delta_{1}^{2}\delta_{2}^{2}}\right)+O(n^{1-\kappa})$

where
$\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\subseteq(\mathbb{Z}/\delta_{1}^{\prime}\delta_{2}^{\prime}\mathbb{Z})^{\ast}$
is as in (2.8) and $r=\textbf{1}\ast\chi_{-4}$ as before. From (2.1) we obtain

(5.3)
$\displaystyle\frac{w_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}{h_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}=\frac{4}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1}$

in all cases, including $\delta_{1}^{\prime}\delta_{2}^{\prime}=1$. We apply
the Dirichlet’s hyperbola method to the $r$-function so that the innermost
$p$-sum in (5.2) can for some parameter $Y>0$ be written as

(5.4) $\displaystyle\sum_{Y\leq p\leq
n}\sum_{\begin{subarray}{c}ab=(n-p)/\delta^{2}\delta_{1}^{2}\delta_{2}^{2}\\\
n-p\equiv
w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime}),\end{subarray}}\chi_{-4}(b)+O(Y^{1+\varepsilon})=S_{1}+S_{2}+O(Y^{1+\varepsilon}),$

say, where

(5.5) $\displaystyle S_{1}$
$\displaystyle=\sum_{\begin{subarray}{c}a\leq\sqrt{n}\\\
(a,\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}\sum_{\begin{subarray}{c}Y\leq
p\leq n\\\ p\equiv
n\,(\textup{mod}\,a\delta^{2}\delta_{1}^{2}\delta_{2}^{2})\\\ n-p\equiv
w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\end{subarray}}\chi_{-4}\Big{(}\frac{n-p}{a\delta^{2}\delta_{1}^{2}\delta_{2}^{2}}\Big{)},$
(5.6) $\displaystyle S_{2}$
$\displaystyle=\sum_{\begin{subarray}{c}b\leq\frac{n-Y}{\sqrt{n}\delta^{2}\delta_{1}^{2}\delta_{2}^{2}}\\\
(b,\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}\sum_{\begin{subarray}{c}Y\leq
p\leq n-b\sqrt{n}\delta^{2}\delta_{1}^{2}\delta_{2}^{2}\\\ p\equiv
n\,(\textup{mod}\,b\delta^{2}\delta_{1}^{2}\delta_{2}^{2})\\\ n-p\equiv
w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\end{subarray}}\chi_{-4}(b).$

We choose $Y=n^{1-2\kappa}$ so that the error term is acceptable. We will
evaluate $S_{1}$ and $S_{2}$ by Proposition 5.1. This requires some
preparation. It turns out that the contribution from $S_{1}$ will be
negligible, but as there are some complications from the powers of two, we
start with a detailed treatment for $S_{1}$.

We use the notation

$r_{2}=(\delta\delta_{1}\delta_{2},2^{\infty}),\quad
d=\frac{\delta\delta_{1}\delta_{2}}{r_{2}},\quad
d^{\prime}=\frac{\delta_{1}^{\prime}\delta_{2}^{\prime}}{(\delta_{1}^{\prime}\delta_{2}^{\prime},2)},\quad
a_{2}=(a,2^{\infty}),\quad a_{d}=(a,d^{\infty}).$

We see that $S_{1}$ equals

(5.7) $\displaystyle\sum_{\begin{subarray}{c}a_{2}\mid 2^{\infty}\\\
(a_{2},\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}\\\
(a,2\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}\sum_{\begin{subarray}{c}Y\leq
p\leq n\\\ p\equiv n\,(\textup{mod}\,aa_{2}r_{2}^{2}d^{2})\\\ n-p\equiv
w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\end{subarray}}\chi_{-4}(a)\chi_{-4}\Big{(}\frac{n-p}{a_{2}r_{2}^{2}}\Big{)}$
(5.8) $\displaystyle=$ $\displaystyle\sum_{\begin{subarray}{c}a_{2}\mid
2^{\infty}\\\
(a_{2},\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}\sum_{a_{d}\mid
d^{\infty}}\chi_{-4}(a_{d})\underset{u\,(\text{mod
}4)}{\left.\sum\right.^{\ast}}\chi_{-4}(u)\sum_{v\,(\textup{mod}\,4)}\chi_{-4}(v)\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}a_{d}\\\
(a,2d_{1}d_{2})=1\\\ a\equiv
u\,(\textup{mod}\,4)\end{subarray}}\sum_{\begin{subarray}{c}Y\leq p\leq n\\\
p\equiv n\,(\textup{mod}\,aa_{2}a_{d}r_{2}^{2}d^{2})\\\ n-p\equiv
w\,(\textup{mod}\,d^{\prime})\\\ n-p\equiv a_{2}r_{2}^{2}v\,(\text{mod
}4a_{2}r_{2}^{2})\end{subarray}}1.$

Here we have used the fact that if
$2\mid\delta_{1}^{\prime}\delta_{2}^{\prime}$ then we must have $a_{2}r_{2}=1$
and $(w,2)=1$. The contribution when one of $a_{2},a_{d}$ is at least
$n^{4\kappa}$ can be bounded by

(5.9) $\displaystyle\sum_{\begin{subarray}{c}a\mid(2d)^{\infty}\\\ a\geq
n^{4\kappa}\end{subarray}}\sum_{q\leq\sqrt{n}/a}\frac{n}{\phi(a)\phi(q)}\ll
n^{1-2\kappa+\varepsilon},$

so from now on we restrict to $a_{2},a_{d}\leq n^{4\kappa}$ (note that
$r_{2},d^{\prime},d$ are automatically at most $n^{2\kappa}$). Splitting into
further residue classes, the $a,p$-sum equals

$\underset{\lambda\,(\textup{mod}\,dd^{\prime})}{\left.\sum\right.^{\ast}}\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}a_{d}\\\
(a,n)=1\\\ a\equiv u\,(\textup{mod}\,4)\\\
a\equiv\lambda\,(\textup{mod}\,dd^{\prime})\end{subarray}}\sum_{\begin{subarray}{c}Y\leq
p\leq n\\\ p\equiv n\,(\textup{mod}\,a)\\\ p\equiv
n-w\,(\textup{mod}\,d^{\prime})\\\ p\equiv
n-va_{2}r_{2}^{2}\,(\textup{mod}\,4a_{2}r_{2}^{2})\\\ p\equiv
n\,(\textup{mod}\,a_{d}d^{2})\end{subarray}}1+O(n^{1/2+\varepsilon})$

where the error term comes from the artificially added condition $(a,n)=1$.
For the same reason we can restrict to $(n,d)=(n-w,d^{\prime})=1$. We are now
in a position to apply Proposition 5.1 (since $\kappa$ is sufficiently small
in terms of $\varpi$) together with the prime number theorem to the two
innermost sums and recast the previous display as

(5.10)
$\displaystyle\mathds{1}_{(n-w,d^{\prime})=(n,d)=1}\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}a_{d}\\\
a\equiv u\,(\textup{mod}\,4)\\\
(a,2d_{1}d_{2}n)=1\end{subarray}}\frac{\operatorname{Li}(n)}{\phi(a)\phi(d^{\prime})\phi(4a_{2}a_{d}r_{2}^{2}d^{2})}+O(n^{1-\kappa}).$

Plugging back, we obtain

(5.11) $\displaystyle S_{1}=$
$\displaystyle\mathds{1}_{(n-w,d^{\prime})=(n,d)=1}\sum_{\begin{subarray}{c}a_{2}\mid
2^{\infty}\\\ a_{2}\leq
n^{4\eta}\end{subarray}}\sum_{\begin{subarray}{c}a_{d}\mid d^{\infty}\\\
a_{d}\leq
n^{4\eta}\end{subarray}}\sum_{\begin{subarray}{c}v\,(\textup{mod}\,4)\\\
(n-va_{2}r_{2}^{2},4)=1\end{subarray}}\chi_{-4}(v)\underset{u\,(\textup{mod}\,4)}{\left.\sum\right.^{\ast}}\chi_{-4}(u)$
(5.12)
$\displaystyle\quad\quad\quad\quad\quad\times\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}a_{d}\\\
a\equiv u\,(\textup{mod}\,4)\\\
(a,2d_{1}d_{2}n)=1\end{subarray}}\frac{\operatorname{Li}(n)}{\phi(a)\phi(d^{\prime})\phi(4a_{2}a_{d}r_{2}^{2}d^{2})}+O(n^{1-\kappa}).$

But now the $v$-sum vanishes: with $h=a_{2}r_{2}^{2}\mid 2^{\infty}$ we have

$\sum_{\begin{subarray}{c}v\,(\textup{mod}\,4)\\\
(n-vh,4)=1\end{subarray}}\chi_{-4}(v)=\sum_{\ell\mid
4}\mu(\ell)\sum_{\begin{subarray}{c}v\,(\text{mod }4)\\\ vh\equiv
n\,(\text{mod }\ell)\end{subarray}}\chi_{-4}(v).$

Since $\chi_{-4}$ is primitive, by [IK, (3.9)] the inner sum vanishes, unless
$4\mid\ell/(\ell,h)$ (which can only happen if $h=1$), but then the Möbius
function vanishes. We conclude $S_{1}\ll n^{1-\kappa}$, as announced before.

We now turn to $S_{2}$ where the calculation is similar, and we obtain

(5.13) $\displaystyle S_{2}$
$\displaystyle=\sum_{b_{d}\mid{(\delta\delta_{1}\delta_{2})^{\infty}}}\chi_{-4}(b_{d})\sum_{\begin{subarray}{c}b\leq\frac{n-Y}{\sqrt{n}(\delta\delta_{1}\delta_{2})^{2}b_{d}}\\\
(b,d_{1}d_{2})=1\end{subarray}}\chi_{-4}(b)\sum_{\begin{subarray}{c}Y\leq
p\leq n-bb_{d}\sqrt{n}\delta^{2}\delta_{1}^{2}\delta_{2}^{2}\\\ p\equiv
n\,(\textup{mod}\,b_{d}\delta^{2}\delta_{1}^{2}\delta_{2}^{2})\\\ p\equiv
n\,(\textup{mod}\,b)\\\ n-p\equiv
w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\end{subarray}}1$
(5.14) $\displaystyle=\underset{u\,(\text{mod
}4)}{\left.\sum\right.^{\ast}}\chi_{-4}(u)\sum_{b_{d}\mid{(\delta\delta_{1}\delta_{2})^{\infty}}}\chi_{-4}(b_{d})\sum_{\begin{subarray}{c}b\leq\frac{n-Y}{\sqrt{n}(\delta\delta_{1}\delta_{2})^{2}b_{d}}\\\
b\equiv u\,(\textup{mod}\,4)\\\
(b,d_{1}d_{2})=1\end{subarray}}\sum_{\begin{subarray}{c}Y\leq p\leq
n-bb_{d}\sqrt{n}\delta^{2}\delta_{1}^{2}\delta_{2}^{2}\\\ p\equiv
n\,(\textup{mod}\,b_{d}\delta^{2}\delta_{1}^{2}\delta_{2}^{2})\\\ p\equiv
n\,(\textup{mod}\,b)\\\ p\equiv
n-w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\end{subarray}}1.$

As before we restrict to $b_{d}\leq n^{4\kappa}$ at the cost of an error of
$O(x^{1-\kappa})$. The contribution from $(\delta\delta_{1}\delta_{2},n)>1$ is
also negligible, so let us from now on assume
$(\delta\delta_{1}\delta_{2},n)=1$. Before we can apply Proposition 5.1 to the
$b,p$-sum, we must first separate variables in the summation condition. To
this end, we split the $p$-sum into intervals of the form $((1-\Delta)P,P]$
with $\Delta=n^{-2\kappa}$. There are $O(\Delta^{-1}\log n)$ such intervals.
The condition $p\leq n-bb_{d}\sqrt{n}\delta^{2}\delta_{1}^{2}\delta_{2}^{2}$
interferes in at most one such interval, whose contribution we estimate by the
Brun-Titchmarsh inequality at the cost of an admissible error
$O(n^{1-\kappa})$. For all other intervals we can apply Proposition 5.1 on GRH
in combination with the prime number theorem. Assembling the main term, we
recast $S_{2}$, up to an error of $O(n^{1-\kappa})$, as

(5.15) $\displaystyle\underset{u\,(\text{mod
}4)}{\left.\sum\right.^{\ast}}\chi_{-4}(u)\sum_{\begin{subarray}{c}b_{d}\mid{(\delta\delta_{1}\delta_{2})^{\infty}}\\\
b_{d}\leq
n^{4\kappa}\end{subarray}}\chi_{-4}(b_{d})\sum_{\begin{subarray}{c}b\leq\frac{n-Y}{\sqrt{n}(\delta\delta_{1}\delta_{2})^{2}b_{d}}\\\
b\equiv u\,(\textup{mod}\,4)\\\
(b,d_{1}d_{2}n)=1\end{subarray}}\sum_{\begin{subarray}{c}Y\leq p\leq
n-bb_{d}\sqrt{n}\delta^{2}\delta_{1}^{2}\delta_{2}^{2}\\\
(p,b_{d}\delta^{2}\delta_{1}^{2}\delta_{2}^{2})=1\\\ (p,b)=1\\\
(p,\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}\frac{\mathds{1}_{(n-w,\delta_{1}^{\prime}\delta_{2}^{\prime})=(n,\delta\delta_{1}\delta_{2})=1}}{\phi(b)\phi(b_{d}\delta^{2}\delta_{1}^{2}\delta_{2}^{2})\phi(\delta_{1}^{\prime}\delta_{2}^{\prime})}$
(5.16)
$\displaystyle=\operatorname{Li}(n)\sum_{\begin{subarray}{c}b_{d}\mid{(\delta\delta_{1}\delta_{2})^{\infty}}\\\
b_{d}\leq
n^{4\kappa}\end{subarray}}\frac{\chi_{-4}(b_{d})}{\phi(b_{d}\delta^{2}\delta_{1}^{2}\delta_{2}^{2})}\sum_{\begin{subarray}{c}b\leq\frac{n-Y}{\sqrt{n}(\delta\delta_{1}\delta_{2})^{2}b_{d}}\\\
(b,d_{1}d_{2}n)=1\end{subarray}}\frac{\chi_{-4}(b)}{\phi(b)}\frac{\mathds{1}_{(n-w,\delta_{1}^{\prime}\delta_{2}^{\prime})=(n,\delta\delta_{1}\delta_{2})=1}}{\phi(\delta_{1}^{\prime}\delta_{2}^{\prime})}.$

As a last step, we compute the $b$-sum using [ABL, Lemma 5.2] and complete the
sum over $b_{d}$, and recast the previous display up to an admissible error as

$\operatorname{Li}(n)L(1,\chi_{-4})\prod_{p}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}\mathfrak{c}(d_{1}d_{2}n)\sum_{b_{d}\mid{(\delta\delta_{1}\delta_{2})^{\infty}}}\frac{\chi_{-4}(b_{d})}{\phi(b_{d}\delta^{2}\delta_{1}^{2}\delta_{2}^{2})}\frac{\mathds{1}_{(n-w,d^{\prime})=(n,\delta\delta_{1}\delta_{2})=1}}{\phi(\delta_{1}^{\prime}\delta_{2}^{\prime})}$

where

(5.17) $\mathfrak{c}(f)=\prod_{p\mid
f}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}^{-1}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}.$

This finishes the analysis of $S_{2}$.

We now return to (5.2) and summarize that there exists some absolute constant
$\kappa>0$ such that uniformly for $d_{1},d_{2}\leq n^{\kappa}$ we have

$\\#\mathcal{A}_{\textbf{d}}=\operatorname{Li}(n)\mathfrak{S}_{d_{1},d_{2}}(n)+O(n^{1-\kappa}),$

where the singular series $\mathfrak{S}_{d_{1},d_{2}}(n)$ is given by

$\begin{split}\mathfrak{S}_{d_{1},d_{2}}(n)=&\underset{(\delta\delta_{1}\delta_{2},n)=1}{\sum_{\delta_{1}\delta_{1}^{\prime}=d_{1}^{\prime}}\sum_{\delta_{2}\delta_{2}^{\prime}=d_{2}^{\prime}}}\frac{4}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1}\frac{G_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}{\phi(\delta_{1}^{\prime}\delta_{2}^{\prime})}\sum_{\begin{subarray}{c}w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\\\
(n-w,\delta_{1}^{\prime}\delta_{2}^{\prime})=1\\\
w\in\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\end{subarray}}1\\\
&\times\sum_{b_{d}\mid{(\delta\delta_{1}\delta_{2})^{\infty}}}\frac{\chi_{-4}(b_{d})}{\phi(b_{d}\delta^{2}\delta_{1}^{2}\delta_{2}^{2})}L(1,\chi_{-4})\prod_{p}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}\mathfrak{c}(d_{1}d_{2}n).\end{split}$

The sum over $w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})$ can
be computed using (2.8) as

$\prod_{\begin{subarray}{c}p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}\\\
p\nmid
2n\end{subarray}}\Big{(}\frac{p-1}{2}-\frac{\chi_{p^{*}}(n)+1}{2}\Big{)}\prod_{\begin{subarray}{c}p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}\\\
p\mid
n\end{subarray}}\Big{(}\frac{p-1}{2}\Big{)}\mathds{1}_{(n-1,\delta_{1}^{\prime}\delta_{2}^{\prime},2)=1}.$

It is now a straightforward exercise with Euler products, noting that
$\chi_{p^{\ast}}(n)=(n/p)$ for odd $p$ and $L(1,\chi_{-4})=\pi/4$, to obtain
the expression (5.1). This completes the proof.

###  5.3. Completion of the proof

With Proposition 5.2 available, Theorem 1.1 follows now easily from a sieve.
Let $\mathcal{A}=(a_{k})$ be a finite sequence of non-negative real numbers.
We introduce the notation

(5.18) $\displaystyle
S(\mathcal{A},z)=\sum_{\begin{subarray}{c}(k,P_{1}(z))=1\end{subarray}}a_{k},\quad
P_{q}(z)=\prod_{\begin{subarray}{c}p\leq z,p\nmid q\end{subarray}}p,\quad
A_{c}=\sum_{\begin{subarray}{c}k\equiv
0\,(\textup{mod}\,c)\end{subarray}}a_{k},\quad A=A_{1}.$

With these notation, we recall the following lemma from sieve theory (see e.g.
[Iw2, Theorem 1]).

######  Lemma 5.3.

Let $\gamma,L>0$ be some fixed constants. Let $\Omega(c)$ be a multiplicative
function satisfying $0\leq\Omega(p)<p$ and

(5.19) $\displaystyle\prod_{w\leq p\leq
w^{\prime}}\Big{(}1-\frac{\Omega(p)}{p}\Big{)}^{-1}\leq\Big{(}\frac{\log
w^{\prime}}{\log w}\Big{)}^{\gamma}\Big{(}1+\frac{L}{\log w}\Big{)}$

for all $2\leq w\leq w^{\prime}$. Then we have

(5.20) $\displaystyle S(\mathcal{A},z)\geq A\prod_{p\leq
z}\Big{(}1-\frac{\Omega(p)}{p}\Big{)}\Big{(}f_{\gamma}(s)-\frac{e^{\sqrt{L}}Q(s)}{(\log\mathcal{D})^{1/3}}\Big{)}-\sum_{\begin{subarray}{c}c\leq\mathcal{D}\\\
c\mid P_{1}(z)\end{subarray}}\Big{|}A_{c}-\frac{\Omega(c)}{c}A\Big{|},$

where $s=\log\mathcal{D}/\log z$, $Q(s)<\exp(-s\log s+s\log\log 3s+O(s))$, and
$f_{\gamma}(s)$ is some continuous function such that $0<f_{\gamma}(s)<1$ and
$f(s)=1+O(e^{-s})$ as $s\rightarrow\infty$.

We are going to sieve the sequence $\mathcal{A}=\mathcal{A}(n)=(a_{k})$ where
$a_{k}=\\#\\{k=x_{1}x_{2}:p+x_{1}^{2}+x_{2}^{2}=n\\}$. Then from Proposition
5.2, there exists some $\kappa>0$ such that for $c\leq n^{\kappa}$ with
$\mu^{2}(c)=1$ we have

(5.21) $\displaystyle A_{c}=\mu(c)\sum_{\begin{subarray}{c}\textbf{d}\\\ p\mid
d_{1}d_{2}\Leftrightarrow p\mid
c\end{subarray}}\mu(d_{1})\mu(d_{2})\frac{\omega(\textbf{d})}{d_{1}d_{2}}\mathfrak{S}(n)\operatorname{Li}(n)+O(cn^{1-\kappa+\epsilon})$

where

(5.22) $\displaystyle\mathfrak{S}(n)$ $\displaystyle=\pi\prod_{p\nmid
n}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}\prod_{\begin{subarray}{c}p\mid
n\end{subarray}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)},$ (5.23)
$\displaystyle\omega(\textbf{d})$
$\displaystyle=\prod_{\begin{subarray}{c}p\mid(d_{1},d_{2})\end{subarray}}\Big{(}1-\frac{c_{p}(n)}{p-1}\Big{)}\prod_{\begin{subarray}{c}p\mid
d_{1}d_{2}\\\ p\nmid(d_{1},d_{2})\\\ p\nmid
2n\end{subarray}}\Big{(}1-\frac{(\frac{n}{p})}{p-1}\Big{)}\prod_{\begin{subarray}{c}p\nmid
n\\\ p\mid
d_{1}d_{2}\end{subarray}}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}^{-1}\prod_{\begin{subarray}{c}p\mid
n\\\ p\mid
2d_{1}d_{2}\end{subarray}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1}$ (5.24)
$\displaystyle:=\prod_{p^{\nu}\parallel d_{1}d_{2}}\omega_{\nu}(p).$

For odd $p$ we compute explicitly

(5.25) $\displaystyle\omega_{1}(p)$
$\displaystyle=\begin{cases}\displaystyle\Big{(}1-\frac{(n/p)}{p-1}\Big{)}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}^{-1},&p\nmid
n,\\\ \displaystyle\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1},&p\mid
n,\end{cases}$

and

(5.26) $\displaystyle\omega_{2}(p)$
$\displaystyle=\begin{cases}\displaystyle\Big{(}1-\frac{c_{p}(n)}{p-1}\Big{)}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}^{-1},&p\nmid
n,\\\ \displaystyle\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1},&p\mid
n,\end{cases}$

and for $p=2$ we have

(5.27)
$\displaystyle\omega_{1}(2)=1,\quad\omega_{2}(2)=1-\frac{c_{2}(n)}{p-1}.$

Let $\Omega(n)$ be the multiplicative function defined by

$\Omega(p)=2\omega_{1}(p)-\omega_{2}(p)p^{-1}$

so that we have from (5.21) that

(5.28)
$\displaystyle\sum_{c\leq\mathcal{D}}\mu^{2}(c)\Big{|}A_{c}-\frac{\Omega(c)}{c}A\Big{|}\ll\mathcal{D}^{2}n^{1-\kappa+\epsilon}$

where $A=\mathfrak{S}(n)\operatorname{Li}(n)$. For $n\not\equiv
2\,(\textup{mod}\,3)$, we also have

$0\leq\Omega(p)<3,\quad\Omega(p)=2+O(1/p).$

Thus there exists some absolute constant $L$ such that (5.19) holds for
$\gamma=2$. We choose $\mathcal{D}=n^{\kappa_{0}}$ for some absolute small
constant $\kappa_{0}$ (e.g. $\kappa_{0}=\kappa/3$) and choose
$C=C(\kappa_{0})$ sufficiently large such that $f_{2}(C\kappa_{0})>0$. Then it
follows from Lemma 5.3 that for $n\not\equiv 2\,(\textup{mod}\,3)$ we have

(5.29) $\displaystyle S(\mathcal{A},n^{1/C})$
$\displaystyle\geq\mathfrak{S}(n)\operatorname{Li}(n)\prod_{p\leq
z}\Big{(}1-\frac{\Omega(p)}{p}\Big{)}\Big{(}f_{2}(C\kappa_{0})-\frac{e^{\sqrt{L}}Q(C\kappa_{0})}{(\log\mathcal{D})^{1/3}}\Big{)}-O(n^{1-\kappa_{0}/2})$
(5.30) $\displaystyle\gg\mathfrak{S}(n)\operatorname{Li}(n)(\log n)^{-2}.$

This completes the proof of Theorem 1.1.

##  6\. Proof of Theorem 1.2

The rest of the paper is devoted to the proof of Theorem 1.2. The basic idea
is similar to the preceding proof, but it is technically and structurally
substantially much more involved. Again we start with the distribution of
smooth numbers in arithmetic progressions to large moduli.

###  6.1. Smooth numbers in arithmetic progressions

Denote

$\Psi(x,y)=\sum_{\begin{subarray}{c}m\in
S(x,y)\end{subarray}}1,\quad\Psi_{q}(x,y)=\sum_{\begin{subarray}{c}m\in
S(x,y)\\\ (m,q)=1\end{subarray}}1.$

We have the following analogue of Proposition 5.1 for smooth numbers under
GRH.

######  Proposition 6.1.

Assume GRH. There exists some absolute constant $\varpi>0$ with the following
property. Let $x,y\geq 2$, $c,d\in\mathbb{N}$, $d\mid c^{\infty}$,
$c_{0},d_{0}\in\mathbb{Z}$, $(d_{0},d)=(c_{0},c)=1$,
$a_{1},a_{2}\in\mathbb{Z}\setminus\\{0\\}$ such that for

$Q\leq x^{1/2+\varpi},\quad|a_{1}|\leq x^{1+\varpi},\quad c,d,|a_{2}|\leq
x^{\varpi},\quad y\gg(\log\log x)^{2}$

we have

$\displaystyle\sum_{\begin{subarray}{c}q\leq Q\\\ (q,a_{1}a_{2})=1\\\ q\equiv
c_{0}\,(\textup{mod}\,c)\end{subarray}}\Big{(}\sum_{\begin{subarray}{c}m\in
S(x,y)\\\ m\equiv a_{1}\overline{a_{2}}\,(\textup{mod}\,q)\\\ m\equiv
d_{0}\,(\textup{mod}\,d)\end{subarray}}1-\frac{1}{\phi(qd)}\Psi_{qd}(x,y)\Big{)}\ll
x^{1-\varpi}.$

As a preparation for the proof we need the following lemma.

######  Lemma 6.2.

Let $A>0$. Assume GRH, $\log y\gg(\log\log x)^{2}$ and $1<q\leq x^{A}$. Then
for any non-principal Dirichlet character $\chi\,(\textup{mod}\,q)$ and any
$\varepsilon>0$, we have

(6.1) $\displaystyle\sum_{\begin{subarray}{c}m\in
S(x,y)\end{subarray}}\chi(m)\ll x^{1/2+\varepsilon}.$

_Remark:_ Any bound of the shape $x^{1-\eta}$ would suffice, and this can be
obtained by applying a result of Harper [Ha, Proposition 1] with
$H=x^{d},\epsilon=\alpha/2$ in the proof of [Ha, (3.1)], as we assume GRH, and
the condition $\epsilon\geq 40\log\log(qyH)/\log y$ is satisfied if $\log
y\gg(\log\log x)^{2}$. Since the situation is much simpler under GRH, we give
an independent proof along the lines of [FT91, Théorème 4].

Proof. Let $s=\sigma+it$ with $\sigma>0$ and let $L(s,\chi,y)=\prod_{p\leq
y}(1-\chi(p)p^{-s})^{-1}$ be the Dirichlet series for $y$-smooth numbers
weighted by $\chi$. Then for any $\alpha>0$ we have from Perron’s formula

(6.2) $\displaystyle\sum_{m\in S(x,y)}\chi(m)=\frac{1}{2\pi i}\int_{\alpha-
iT}^{\alpha+iT}L(s,\chi,y)\frac{x^{s}}{s}ds+O\Big{(}x^{\alpha}\sum_{P^{+}(m)\leq
y}\frac{1}{m^{\alpha}}\min\Big{(}1,\frac{1}{T|\log(x/m)|}\Big{)}\Big{)}.$

We take $\alpha=1+1/\log x$ so that $O$-term is bounded by

(6.3) $\displaystyle\frac{x^{\alpha}\zeta(\alpha)}{T}+\sum_{|m-x|\ll
x/T}1\ll\frac{x\log x}{T}.$

For the first term, we would like to approximate $L(s,\chi,y)$ by $L(s,\chi)$
and shift the contour to the left. Similarly as in [FT91, Lemme 6.3], we can
show that under GRH for any $\sigma>1/2$ and $|t|\leq T$ we have

(6.4) $\displaystyle
L(s,\chi,y)=L(s,\chi)\exp\big{(}O(y^{1/2-\sigma}\log(qyT)^{3})\big{)}.$

To prove (6.4), we first note that for any $\sigma>1/2$ (cf. [FT91, (6.19)])

(6.5) $\displaystyle-\frac{L^{\prime}(s,\chi,y)}{L(s,\chi,y)}=\sum_{m\leq
y}\frac{\Lambda(m)\chi(m)}{m^{s}}+O(y^{1/2-\sigma}).$

The $m$-sum can be estimated again using Perron’s formula (see [FT91, (6.20)])

(6.6) $\displaystyle\sum_{m\leq
y}\frac{\Lambda(m)\chi(m)}{m^{s}}=\frac{1}{2\pi i}\int_{1-\sigma+1/\log
y-iY}^{1-\sigma+1/\log
y+iY}-\frac{L^{\prime}(s+w,\chi)}{L(s+w,\chi)}\frac{y^{w}}{w}ds+O(y^{1-\sigma}Y^{-1}\log^{2}y)$

for a parameter $Y>1$. Shifting the line to $1/2-\sigma+1/\log y$, we only
encounter the pole at $w=0$ (assuming GRH). The contribution from the
horizontal lines of the contour can be bounded by $y^{1-\sigma}Y^{-1}(\log
qTY)^{2}$ and the contribution from the vertical line of the contour can be
bounded by $y^{1/2-\sigma}(\log qTY)^{3}$. Therefore choosing $Y=y^{1/2}$, we
obtain

$-\frac{L^{\prime}(s,\chi,y)}{L(s,\chi,y)}=-\frac{L^{\prime}(s,\chi)}{L(s,\chi)}+O\big{(}y^{1/2-\sigma}(\log
qTy)^{3}\big{)},$

and hence (6.4) by integrating along the line $\\{s+t,t\geq 0\\}$.

Now we can shift the line of integration in (6.2) to
$\sigma_{0}=1/2+\epsilon_{0}$ with any $\epsilon_{0}>0$ under GRH. Taking
$T=x^{1/2}$, we see that $y^{1/2-\sigma_{0}}(\log qyT)^{3}\ll 1$ since $\log
y\gg(\log\log x)^{2}$ and $q\leq x^{A}$. On GRH, it follows that

(6.7) $\displaystyle\int_{\alpha-iT}^{\alpha+iT}L(s,\chi,y)\frac{x^{s}}{s}ds$
$\displaystyle=\int_{\sigma_{0}+iT}^{\sigma_{0}+iT}L(s,\chi,y)\frac{x^{s}}{s}ds+O\Big{(}\frac{x(qT)^{\varepsilon}}{T}\Big{)}\ll
x^{1/2+\varepsilon}.$

Combining (6.3) and (6.7), we complete the proof of the lemma.

Proof of Proposition 6.1: The proof follows by combining the proofs of [FT90,
Lemme 2.1] and [ABL, Theorem 2.1]. We use $\varepsilon$ as an arbitrary
positive constant, not necessarily the same at each occurrence. For a
parameter $R>1$ (which eventually will be chosen as a small power of $x$)
denote

(6.8) $\displaystyle u_{R}(m;q)=\mathds{1}_{m\equiv
1\,(\textup{mod}\,q)}-\frac{1}{\phi(q)}\sum_{\begin{subarray}{c}\chi\,(\textup{mod}\,q)\\\
\operatorname{cond}(\chi)\leq
R\end{subarray}}\chi(m)=\frac{1}{\phi(q)}\sum_{\begin{subarray}{c}\chi\,(\textup{mod}\,q)\\\
\operatorname{cond}\chi>R\end{subarray}}\chi(m),$

so that we can write (note the assumptions imply $(q,d)=1$)

(6.9) $\displaystyle\sum_{\begin{subarray}{c}q\leq Q\\\ (q,a_{1}a_{2})=1\\\
q\equiv c_{0}\,(\textup{mod}\,c)\end{subarray}}\sum_{\begin{subarray}{c}m\in
S(x,y)\\\ m\equiv a_{1}\overline{a_{2}}\,(\textup{mod}\,q)\\\ m\equiv
d_{0}\,(\textup{mod}\,d)\end{subarray}}1=\mathcal{S}_{1}+\mathcal{S}_{2},$

where

(6.10) $\displaystyle\mathcal{S}_{1}=\sum_{\begin{subarray}{c}q\leq Q\\\
(q,a_{1}a_{2})=1\\\ q\equiv
c_{0}\,(\textup{mod}\,c)\end{subarray}}\frac{1}{\phi(d)}\sum_{\psi\,(\textup{mod}\,d)}\sum_{m\in
S(x,y)}\frac{1}{\phi(q)}\sum_{\begin{subarray}{c}\chi\,(\textup{mod}\,q)\\\
\operatorname{cond}(\chi)\leq
R\end{subarray}}\chi(m\overline{a_{1}}a_{2})\psi(m\overline{d_{0}}),$ (6.11)
$\displaystyle\mathcal{S}_{2}=\sum_{\begin{subarray}{c}q\leq Q\\\
(q,a_{1}a_{2})=1\\\ q\equiv
c_{0}\,(\textup{mod}\,c)\end{subarray}}\frac{1}{\phi(d)}\sum_{\psi\,(\textup{mod}\,d)}\sum_{m\in
S(x,y)}u_{R}(m\overline{a_{1}}a_{2};q)\psi(m\overline{d_{0}}).$

For the contribution from non-principal characters in $\mathcal{S}_{1}$, we
use Lemma 6.2 to conclude that

(6.12) $\displaystyle\sum_{\begin{subarray}{c}q\leq Q\\\ (q,a_{2}a_{2})=1\\\
q\equiv
c_{0}\,(\textup{mod}\,c)\end{subarray}}\frac{1}{\phi(qd)}\sum_{\psi\,(\textup{mod}\,d)}\sum_{\begin{subarray}{c}\chi\,(\textup{mod}\,q)\\\
\operatorname{cond}\chi\leq R\\\
\operatorname{cond}\chi\psi>1\end{subarray}}\sum_{m\in
S(x,y)}\chi(m\overline{a_{1}}a_{2})\psi(m\overline{d_{0}})\ll
Rx^{1/2+\varepsilon}$

and thus

(6.13) $\displaystyle\mathcal{S}_{1}=\sum_{\begin{subarray}{c}q\leq Q\\\
(q,a_{2}a_{2})=1\\\ q\equiv
c_{0}\,(\textup{mod}\,c)\end{subarray}}\frac{1}{\phi(q)\phi(d)}\Psi_{qd}(x)+O(Rx^{1/2+\varepsilon}).$

Similar to the proof of Theorem 3.4, we now complete the argument by showing
that there exists some absolute $\varpi>0$ such that

(6.14) $\displaystyle\mathcal{S}_{2}\ll x^{1-\varpi}.$

To prove (6.14), we consider separately the cases $y\geq x^{\eta}$ and
$y<x^{\eta}$ for some sufficiently small $\eta>0$.

When $y\geq x^{\eta}$, we use the Buchstab’s identity (3.12) to write

(6.15)
$\displaystyle\mathcal{S}_{2}=S_{0}+\sum_{i=1}^{3}(-1)^{i}S_{i}+\overline{S},$

where

(6.16) $\displaystyle S_{0}$ $\displaystyle=\sum_{\begin{subarray}{c}q\leq
Q\\\ (q,a_{1}a_{2})=1\\\ q\equiv
c_{0}\,(\textup{mod}\,c)\end{subarray}}\frac{1}{\phi(d)}\frac{1}{\phi(q)}\Big{(}\sum_{\psi\,(\textup{mod}\,d)}\sum_{\begin{subarray}{c}m\equiv\overline{a_{1}}a_{2}\\\
m\leq x\end{subarray}}1-\sum_{\begin{subarray}{c}\chi\,(\textup{mod}\,q)\\\
\operatorname{cond}(\chi)\leq
R\end{subarray}}\chi(m\overline{a_{1}}a_{2})\Big{)}\psi(m\overline{d_{0}}),$
(6.17) $\displaystyle S_{j}$ $\displaystyle=\sum_{\begin{subarray}{c}q\leq
Q\\\ (q,a_{1}a_{2})=1\\\ q\equiv
c_{0}\,(\textup{mod}\,c)\end{subarray}}\frac{1}{\phi(d)}\sum_{\psi\,(\textup{mod}\,d)}\sum_{\begin{subarray}{c}y<p_{1}<\dots<p_{j}\\\
mp_{1}\cdots p_{j}\leq x\end{subarray}}u_{R}(mp_{1}\cdots
p_{j}\overline{a_{1}}a_{2};q)\psi(mp_{1}\cdots p_{j}\overline{d_{0}}),$ (6.18)
$\displaystyle\overline{S}$ $\displaystyle=\sum_{\begin{subarray}{c}q\leq Q\\\
(q,a_{1}a_{2})=1\\\ q\equiv
c_{0}\,(\textup{mod}\,c)\end{subarray}}\frac{1}{\phi(d)}\sum_{\psi\,(\textup{mod}\,d)}\sum_{\begin{subarray}{c}y<p_{1}<\dots<p_{4}\\\
mp_{1}\cdots p_{4}\leq x\end{subarray}}u_{R}(mp_{1}\cdots
p_{4}\overline{a_{1}}a_{2};q)g_{p_{4}}(m)\psi(mp_{1}\cdots
p_{4}\overline{d_{0}}).$

Consider $\overline{S}$ first. Note that we can assume $y<p_{1}\ll x^{1/4}$
since otherwise the sum is empty. Similar to the proof of Theorem 3.4, we
localize $m$ and $p_{i}$ into intervals $m\in(M,M(1+\mathcal{Z})]$ and
$p_{i}\in(P_{j},P_{j+1}]$ with $P_{j}=y(1+\mathcal{Z})^{j}$ and with
$\mathcal{Z}=x^{-\eta_{0}}$ for some $\eta_{0}>0$ so that

(6.19) $\displaystyle\overline{S}\ll\mathcal{Z}^{-4}(\log
x)^{O(1)}\sup_{M,P_{j_{i}}}|\tilde{\mathcal{S}}|+x(\log x)^{O(1)}\mathcal{Z}$

where

(6.20) $\displaystyle\tilde{\mathcal{S}}=\sum_{\begin{subarray}{c}q\leq Q\\\
(q,a_{1}a_{2})=1\\\ q\equiv
c_{0}\,(\textup{mod}\,c)\end{subarray}}\frac{1}{\phi(d)}\sum_{\psi\,(\textup{mod}\,d)}\sum_{\begin{subarray}{c}p_{i}\in(P_{j_{i}},(1+\mathcal{Z})P_{j_{i}}]\\\
m\in(M,M(1+\mathcal{Z})]\\\ 1\leq i\leq
4\end{subarray}}g_{p_{4}}(m)u_{R}(mp_{1}\cdots
p_{4}\overline{a_{1}}a_{2})\psi(mp_{1}\cdots p_{4}\overline{d_{0}}).$

If $M\prod_{i=1}^{4}P_{j_{i}}\leq x^{1-\eta/2}$, we can bound
$\tilde{\mathcal{S}}\ll x^{1-\eta/2+\epsilon}$ trivially. Otherwise, we can
apply the bilinear estimate [ABL, Proposition 4.1] with $\bm{m}=p_{1}$ to
$\tilde{\mathcal{S}}$ since $x^{\eta}\leq y\leq P_{j_{1}}\ll
x^{1/4}\ll(M\prod_{i=1}^{4}P_{j_{i}})^{1/4+\eta}$. We obtain

(6.21) $\displaystyle\overline{S}\ll\mathcal{Z}^{-4}cx(\log
x)^{O(1)}R^{-1}+x(\log x)^{O(1)}\mathcal{Z}$

as long as

(6.22) $\displaystyle Q\leq x^{1/2+\varpi_{0}},\quad c,R,|a_{2}|\leq
x^{\varpi_{0}},\quad a_{1}\leq x^{1+\varpi_{0}}$

for some absolute constant $\varpi_{0}>0$. Since $R$ is a small power of $x$,
this suffices for the bound $\overline{S}\ll x^{1-\varpi}$ by choosing a
suitable $\eta_{0}$.

For $S_{k}$, $1\leq k\leq 3$, we can replace the characteristic function of
the primes by the von Mangoldt function, apply Heath-Brown’s identity (3.3) to
each prime variable $p_{i}$ and then localize the new variables so that we
have

(6.23) $\displaystyle S_{k}\ll\mathcal{Z}^{-24}(\log
x)^{O(1)}\sup_{\begin{subarray}{c}M,M_{i},N_{j}\\\ 1\leq r\leq 12\\\ 1\leq
s\leq 12\end{subarray}}|\dot{\mathcal{S}}|+x(\log x)^{(1)}\mathcal{Z},$

where

(6.24) $\displaystyle\dot{\mathcal{S}}=\sum_{\begin{subarray}{c}q\leq Q\\\
(q,a_{1}a_{2})=1\\\ q\equiv
c_{0}\,(\textup{mod}\,c)\end{subarray}}\frac{1}{\phi(d)}$
$\displaystyle\sum_{\psi\,(\textup{mod}\,d)}\sum_{m\in(M,(1+\mathcal{Z})M]}\sum_{m_{i}\in(M_{i},(1+\mathcal{Z})M_{i}]}\sum_{n_{j}\in(N_{j},(1+\mathcal{Z})N_{j}]}$
(6.25)
$\displaystyle\prod_{i=1}^{r}\mu(m_{i})u_{R}\Big{(}m\prod_{i=1}^{r}m_{i}\prod_{j=1}^{s}n_{j}\overline{a_{1}}a_{2};q\Big{)}\psi\Big{(}m\prod_{i=1}^{r}m_{i}\prod_{j=1}^{s}n_{j}\overline{d_{0}}\Big{)}$

with

$M\prod_{i=1}^{r}M_{i}\prod_{j=1}^{s}N_{j}\ll x,\quad M_{i}\leq x^{1/4}.$

As before, we can assume $M\prod_{i=1}^{r}M_{i}\prod_{j=1}^{s}N_{j}\geq
x^{1-\eta/2}$ since otherwise we can bound $\dot{\mathcal{S}}\ll
x^{1-\eta/2+\varepsilon}$ trivially. Now we argue similarly as in the proof of
Theorem 3.4. If there is a subset $\mathcal{I}\subseteq\\{M,M_{i},N_{j}\\}$
such that $K:=\prod_{I\in\mathcal{I}}I$ such that $x^{\eta}\leq K\leq
x^{1/4+\eta}$, then we can apply [ABL, Proposition 4.1] with $\bm{m}=k$ to
obtain

$\dot{\mathcal{S}}\ll cx(\log x)^{O(1)}R^{-1}$

as long as (6.22) is satisfied. Otherwise, it is enough to show there exists
some absolute constant $\varpi>0$ such that

(6.26) $\displaystyle\sum_{\begin{subarray}{c}q\leq Q\\\ (q,a_{1}a_{2})=1\\\
q\equiv
c_{0}\,(\textup{mod}\,c)\end{subarray}}\operatornamewithlimits{\sum\sum\sum}_{\begin{subarray}{c}m\asymp
M,k\asymp K,l\asymp L\\\ rmkl\equiv
d_{0}\,(\textup{mod}\,d)\end{subarray}}\alpha_{r}u_{R}(rmkl\overline{a_{1}}a_{2};q)\ll
x^{1-\varpi}$

for $r\leq x^{\eta},x^{1-\eta/2}\ll rMKL\leq x$ and $\alpha_{r}\ll
r^{\varepsilon}$. This can be rewritten and then estimated in the same way as
in [ABL, eq. (4.5)], where ultimately Deligne’s estimates for exponential sums
over algebraic varieties over finite fields are used. By choosing
$\mathcal{Z}$ suitably, we see that there exists some $\varpi>0$ such that
$S_{k}\ll x^{1-\varpi}$ for $1\leq k\leq 3$.

We can also treat $S_{0}$ by (6.26), which completes the proof of (6.14) when
$y\geq x^{\eta}$.

When $y\leq x^{\eta}$, we can apply [FT96, Lemme 3.1] in the form of (3.29) so
that it is enough to show that there exists some absolute constant $\varpi>0$
such that

(6.27) $\displaystyle\sum_{\begin{subarray}{c}q\leq Q\\\ (q,a_{1}a_{2})\\\
q\equiv c_{0}\,(\textup{mod}\,c)\end{subarray}}\sum_{\begin{subarray}{c}lm\leq
x\\\ lm\equiv d_{0}\,(\textup{mod}\,d)\\\ P^{+}(l)\leq P^{-}(m)\\\ M\leq m\leq
yM\end{subarray}}g_{y}(l)g_{y}(m)u_{R}(lm\overline{a_{1}}a_{2};q)\psi(lm\overline{d_{0}})\ll
x^{1-\varpi}.$

After splitting $l,m$ into residue classes modulo $d$, separating variables
$l$ and $m$ as in [Dr1, eq. (3.37)] and localizing $l,m$ into short intervals
$l\asymp L$ and $m\asymp M$, we can apply [ABL, Proposition 4.1] to obtain
(6.27), as long as $x^{\eta_{1}}\leq M$ and $My\leq(LM)^{1/4+\eta_{1}}$, which
can be satisfied by choosing $M=x^{\eta_{2}}$ for some suitable $\eta_{2}>0$
when $LM\geq x^{1-\eta_{3}}$. If $LM\leq x^{1-\eta_{3}}$, we can obtain (6.27)
trivially, and this complete the proof of (6.14) when $y\leq x^{\eta}$.

###  6.2. Implementing sieve weights

The most straightforward approach to Theorem 1.2 would be to use Proposition
6.1 to evaluate

$\sum_{m\in S(x,y)}r_{d_{1},d_{2}}(n-m)$

for squarefree numbers $d_{1},d_{2}$, and then apply a sieve. Unfortunately
the main term in the asymptotic formula is not a multiplicative function of
$d_{1}d_{2}$. As mentioned in the introduction, this makes it problematic to
implement a sieve, so instead we will work with the sieve weights directly. We
recall [Iw3, Lemma 3].

######  Lemma 6.3.

Let $\gamma,L>0$ be some fixed constants. Then there exists a sequence
$\lambda_{c}^{-}$ supported on squarefree integers less than $\mathcal{D}$
such that

$\lambda_{1}^{-}=1,\quad|\lambda_{c}^{-}|\leq 1,\quad\mu*1\geq\lambda^{-}*1$

and that for all multiplicative functions $w$ satisfying $0\leq w(p)<1$ and

(6.28) $\displaystyle\prod_{w\leq p\leq
w^{\prime}}(1-w(p))^{-1}\leq\Big{(}\frac{\log w^{\prime}}{\log
w}\Big{)}^{\gamma}\Big{(}1+\frac{L}{\log w}\Big{)}$

for all $2\leq w\leq w^{\prime}$ we have

(6.29) $\displaystyle\sum_{\begin{subarray}{c}c\mid
P(z)\end{subarray}}\lambda_{c}^{-}w(c)\geq\prod_{p\leq
z}(1-w(p))\Big{(}f_{\gamma}(s)+O\Big{(}\frac{e^{\sqrt{L}-s}}{(\log\mathcal{D})^{1/3}}\Big{)}\Big{)},\quad
s=\frac{\log\mathcal{D}}{\log z}\geq 2,$

where $f_{\gamma}(s)$ is some continuous function such that
$0<f_{\gamma}(s)<1$ and $f_{\gamma}(s)=1+O(e^{-s})$ as $s\rightarrow\infty$.

The idea is to estimate the sieve weights $\lambda_{c}^{-}$ with
multiplicative factors $w(c)$ first to get a lower bound using Lemma 6.3, and
then sum over the smooth numbers $m$. In order to avoid major technical
difficulties, we need to prepare the set-up very carefully.

  * •

Many estimates are sensitive to the prime factorization of $m$, and it
simplifies our life to restrict $m$ to be squarefree. On the other hand, if
$n\equiv 2$ (mod 4), we will need $4\mid m$ in order to represent $n$ by $m$
and two odd integer squares. Thus we only restrict $m$ to have an odd
squarefree part. This restriction will not change the order of the number of
solutions, but the fact that squarefree numbers are not equidistributed among
all residue classes will leads to different constants for different $n$.

  * •

It turns out that a factor $\chi_{-4}(h)$ with $h\mid(n,m)$ appears in the
main term. It is convenient to force $\chi_{-4}(h)>0$ (so that a lower bound
suffices), and thus we also restrict $m$ to be coprime to all primes $p\equiv
3$ (mod 4) dividing $n$. Since $n-m$ is a sum of two squares, this is a
harmless maneuver and affects only square factors, but it makes an important
difference for the computation if we implement this. Note that we could
simplify the computations by restricting $m$ to be coprime to $n$, but this
could lose some order of magnitude for certain cases of $n$, e.g. when $n$ is
the product of the first few primes that are $1\,(\textup{mod}\,4)$.

  * •

Finally, the sieve weights behave a bit erratically for small primes, so we
sieve them out directly by Möbius inversion.

With these general remarks in mind, we fix the following notation. We write

$\mathfrak{N}=\prod_{\begin{subarray}{c}p\mid n\\\ p\equiv
3\,(\textup{mod}\,4)\end{subarray}}p,\quad
m_{o}=\prod_{\begin{subarray}{c}p^{\nu}\parallel m\\\
p>2\end{subarray}}p^{\nu}=\frac{m}{(m,2^{\infty})}.$

Recall the notation (5.18). Let

$\mathcal{A}=\mathcal{A}(n)=(a_{k}),\quad
a_{k}=\\#\Big{\\{}k=x_{1}x_{2}:\begin{array}[]{ll}m+x_{1}^{2}+x_{2}^{2}=n,\\\
P^{+}(m)\leq y,\end{array}\begin{array}[]{ll}\mu^{2}(m_{o})=1,\\\
(m,\mathfrak{N})=1\end{array}\Big{\\}}.$

Then for $c$ squarefree, we have

(6.30) $\displaystyle A_{c}=\mu(c)\sum_{\begin{subarray}{c}\mathbb{d}\\\ p\mid
d_{1}d_{2}\Leftrightarrow p\mid
c\end{subarray}}\mu(d_{1})\mu(d_{2})\sum_{\begin{subarray}{c}m\leq x\\\
P^{+}(m)\leq y\\\
\mu^{2}(m_{o})=(m,\mathfrak{N})=1\end{subarray}}r_{d_{1},d_{2}}(n-m).$

Let $\mathcal{Q}$ be some fixed absolute constant (we will later choose
$\mathcal{Q}=30$). Let $\lambda_{c}^{-}$ be some lower bound sieve weights as
in Lemma 6.3 of dimension $\gamma$, level $\mathcal{D}=n^{\kappa_{0}}$ for
some sufficiently small $\kappa_{0}$ and $z=n^{1/C}$ for some sufficiently
large $C$ so that $f_{\gamma}(C\kappa_{0})>0$. Then we have the following
lower bound for $S(\mathcal{A},z)$:

(6.31) $\displaystyle S(\mathcal{A},z)$
$\displaystyle=\sum_{\begin{subarray}{c}m\leq n\\\ P^{+}(m)\leq y\\\
\mu^{2}(m_{o})=(m,\mathfrak{N})=1\end{subarray}}\sum_{\begin{subarray}{c}x_{1}^{2}+x_{2}^{2}=n-m\\\
(x_{1}x_{2},\mathcal{Q})=1\end{subarray}}\sum_{c\mid(x_{1}x_{2},P_{\mathcal{Q}}(z))}\mu(c)$
(6.32) $\displaystyle\geq\sum_{\begin{subarray}{c}m\leq n\\\ P^{+}(m)\leq y\\\
\mu^{2}(m_{o})=(m,\mathfrak{N})=1\end{subarray}}\sum_{\begin{subarray}{c}x_{1}^{2}+x_{2}^{2}=n-m\end{subarray}}\sum_{\begin{subarray}{c}u_{1},u_{2}\mid\mathcal{Q}\\\
u_{i}\mid
x_{i}\end{subarray}}\mu(u_{1})\mu(u_{2})\sum_{c\mid(x_{1}x_{2},P_{\mathcal{Q}}(z))}\lambda_{c}^{-}$
(6.33) $\displaystyle=\sum_{u\mid\mathcal{Q}}\sum_{c\mid
P_{\mathcal{Q}}(z)}\lambda_{c}^{-}\mu(c)\sum_{\begin{subarray}{c}d_{1},d_{2}\\\
p\mid d_{1}d_{2}\Leftrightarrow p\mid
uc\end{subarray}}\mu(d_{1})\mu(d_{2})\sum_{\begin{subarray}{c}m\leq n\\\
P^{+}(m)\leq y\\\
\mu^{2}(m_{o})=(m,\mathfrak{N})=1\end{subarray}}r_{d_{1},d_{2}}(n-m).$

Our next goal is to evaluate the innermost sum using Lemma 2.2.

###  6.3. The cuspidal contribution

We first treat the contribution to the $m$-sum in (6.31) that corresponds to
(2.9). To this end we need to show that there exists some absolute constant
$\eta>0$ (which eventually will depend on the constants in Theorem 3.4) such
that

(6.34) $\displaystyle\sum_{\begin{subarray}{c}m\leq n\\\ m\equiv
n\,(\textup{mod}\,\Delta)\\\ m\equiv w\,(\textup{mod}\,q)\\\
\mu^{2}(m_{o})=(m,\mathfrak{N})=1\\\ P^{+}(m)\leq
y\end{subarray}}\lambda\Big{(}\frac{n-m}{\Delta}\Big{)}\ll n^{1-\eta}$

uniformly for $\Delta,q\leq n^{\eta}$ with $(\Delta w,q)=1$ (specifically, in
the notation of (2.9) we have $\Delta=(\delta\delta_{1}\delta_{2})^{2}$,
$q=\delta_{1}^{\prime}\delta_{2}^{\prime}$) and Hecke eigenvalues of a cusp
form $\phi$ whose conductor is less than $n^{\eta}$. By Möbius inversion, the
previous display equals

(6.35) $\displaystyle\sum_{\begin{subarray}{c}d\leq\sqrt{n}\\\
(d,2\mathfrak{N})=1\\\ P^{+}(d)\leq
y\end{subarray}}\mu(d)\sum_{\begin{subarray}{c}m\leq n/d^{2}\\\ d^{2}m\equiv
n\,(\textup{mod}\,\Delta)\\\ d^{2}m\equiv w\,(\textup{mod}\,q)\\\
(m,\mathfrak{N})=1\\\ P^{+}(m)\leq
y\end{subarray}}\lambda\Big{(}\frac{n-d^{2}m}{\Delta}\Big{)}.$

The contribution from $d\geq n^{4\eta}$ can be bounded by

(6.36) $\displaystyle\sum_{d\geq
n^{4\eta}}\Big{(}\sum_{\begin{subarray}{c}m\leq
n/d^{2}\end{subarray}}1\Big{)}^{3/4}\Big{(}\sum_{\begin{subarray}{c}m\leq
n/d^{2}\end{subarray}}\Big{|}\lambda\Big{(}\frac{n-d^{2}m}{\Delta}\Big{)}\Big{|}^{4}\Big{)}^{1/4}$
$\displaystyle\ll n^{\varepsilon}\sum_{d\geq n^{4\eta}}\frac{n}{d^{3/2}}\ll
n^{1+\varepsilon-2\eta},$

using the bound (4.3) for the fourth moment of Hecke eigenvalues and recalling
that presently the conductor $C_{\phi}\leq n^{\eta}$.

For $d\leq n^{4\eta}$, we detect the condition $(m,\mathfrak{N})=1$ using
Möbius inversion to write

(6.37) $\displaystyle\sum_{\begin{subarray}{c}m\leq n/d^{2}\\\ d^{2}m\equiv
n\,(\textup{mod}\,\Delta)\\\ d^{2}m\equiv w\,(\textup{mod}\,q)\\\
(m,\mathfrak{N})=1\\\ P^{+}(m)\leq
y\end{subarray}}\lambda\Big{(}\frac{n-d^{2}m}{\Delta}\Big{)}=\sum_{\begin{subarray}{c}\tau\mid\mathfrak{N}\\\
P^{+}(\tau)\leq y\end{subarray}}\mu(\tau)\sum_{\begin{subarray}{c}m\leq
n/d^{2}\tau\\\ d^{2}\tau m\equiv n\,(\textup{mod}\,\Delta)\\\ d^{2}\tau
m\equiv w\,(\textup{mod}\,q)\\\ P^{+}(m)\leq
y\end{subarray}}\lambda\Big{(}\frac{n-d^{2}\tau m}{\Delta}\Big{)}.$

The contribution from $\tau\geq n^{4\eta}$ can be bounded by

(6.38) $\displaystyle n^{1+\varepsilon}\sum_{\begin{subarray}{c}\tau\mid n\\\
\tau\geq
n^{4\eta}\end{subarray}}\frac{1}{\tau}\ll\frac{n^{1+\varepsilon}\tau(n)}{n^{4\eta}}\ll
n^{1+2\varepsilon-4\eta}.$

Both error terms are acceptable. Thus, for $d,\tau\leq n^{4\eta}$ and
automatically $(d\tau,q)=1$ and $d_{0}:=(d^{2}\tau,\Delta)\mid n$, we are left
with bounding

$\sum_{\begin{subarray}{c}m\leq n/d^{2}\tau\\\
m\equiv\frac{n}{d_{0}}\overline{\frac{d^{2}\tau}{d_{0}}}\,(\textup{mod}\,\frac{\Delta}{d_{0}})\\\
m\equiv w\overline{d^{2}\tau}\,(\textup{mod}\,q)\\\ P^{+}(m)\leq
y\end{subarray}}\lambda\Big{(}\frac{n-d^{2}\tau m}{\Delta}\Big{)},$

and the desired power saving as in (6.34) follows (after obvious smoothing)
from Theorem 3.4.

###  6.4. Computing the main term I – summing over arithmetic progressions

We now return to (6.31) and insert the contribution corresponding to (2.7). In
view of the bounds in the previous subsection, we have for
$\mathcal{D}=n^{\kappa_{0}}$ for sufficiently small $\kappa_{0}$ (depending on
the constants $\varpi$ in Proposition 6.1 and $\eta$ is as in (6.34))

(6.39) $\displaystyle S(\mathcal{A},z)\geq\sum_{u\mid\mathcal{Q}}\sum_{c\mid
P_{\mathcal{Q}}(z)}\lambda_{c}^{-}\mu(c)\sum_{\begin{subarray}{c}d_{1},d_{2}\\\
p\mid d_{1}d_{2}\Leftrightarrow p\mid
uc\end{subarray}}\mu(d_{1})\mu(d_{2})S_{d_{1},d_{2}}+O(n^{1-\kappa_{0}})$

where

(6.40) $\displaystyle S_{d_{1},d_{2}}$
$\displaystyle=\operatornamewithlimits{\sum\sum}_{\begin{subarray}{c}\delta=(d_{1},d_{2})\\\
d_{i}^{\prime}=d_{i}/\delta\\\ \delta_{1}\delta_{1}^{\prime}=d_{1}^{\prime}\\\
\delta_{2}\delta_{2}^{\prime}=d_{2}^{\prime}\end{subarray}}\frac{4}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}(1-\frac{\chi_{-4}(p)}{p})^{-1}G_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\sum_{w\in\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}\sum_{\begin{subarray}{c}m\equiv
n\,(\textup{mod}\,\delta^{2}\delta_{1}^{2}\delta_{2}^{2})\\\ n-m\equiv
w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\\\ P^{+}(m)\leq y\\\
\mu^{2}(m_{o})=(m,\mathfrak{N})=1\end{subarray}}r\Big{(}\frac{n-m}{\delta^{2}\delta_{1}^{2}\delta_{2}^{2}}\Big{)}.$

As in the proof of Proposition 5.2, we apply Dirichlet’s hyperbola method to
the $r$-function. Let $\eta_{0}$ be some small positive constant that will be
chosen appropriately later. Let

$x=n(1-1/Z),\quad Z=n^{\eta_{0}}$

for some $\eta_{0}>0$ to be chosen later. In particular, in terms of orders of
magnitude, $n$ and $x$ can (and will) be used interchangeably. Note that the
contribution from $m\geq x$ or $m\leq n-x$ can be bounded by
$Z^{-1}n^{1+\varepsilon}\ll n^{1-\eta_{0}/2}$. Thus we can write

$S_{d_{1},d_{2}}=:S_{1}+S_{2}+O(n^{1-\eta_{0}/2}),$

where

(6.41) $\displaystyle S_{1}$
$\displaystyle=\operatornamewithlimits{\sum\sum}_{\begin{subarray}{c}\delta=(d_{1},d_{2})\\\
d_{i}^{\prime}=d_{i}/\delta\\\ \delta_{1}\delta_{1}^{\prime}=d_{1}^{\prime}\\\
\delta_{2}\delta_{2}^{\prime}=d_{2}^{\prime}\end{subarray}}\frac{4}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1}G_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\sum_{w\in\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}\sum_{\begin{subarray}{c}a\leq\sqrt{n}\\\
(a,\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}\sum_{\begin{subarray}{c}n-x\leq
m\leq x\\\ P^{+}(m)\leq y\\\ \mu^{2}(m_{o})=(m,\mathfrak{N})=1\\\ m\equiv
n\,(\textup{mod}\,a\delta^{2}\delta_{1}^{2}\delta_{2}^{2})\\\ n-m\equiv
w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\end{subarray}}\chi_{-4}\Big{(}\frac{n-m}{a\delta^{2}\delta_{1}^{2}\delta_{2}^{2}}\Big{)},$
(6.42) $\displaystyle S_{2}$
$\displaystyle=\operatornamewithlimits{\sum\sum}_{\begin{subarray}{c}\delta=(d_{1},d_{2})\\\
d_{i}^{\prime}=d_{i}/\delta\\\ \delta_{1}\delta_{1}^{\prime}=d_{1}^{\prime}\\\
\delta_{2}\delta_{2}^{\prime}=d_{2}^{\prime}\end{subarray}}\frac{4}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1}G_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\sum_{w\in\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}\sum_{\begin{subarray}{c}b\leq\frac{x}{(\delta\delta_{1}\delta_{2})^{2}\sqrt{n}}\\\
(b,\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}\sum_{\begin{subarray}{c}n-x\leq
m\leq x\\\ m\leq n-b(\delta\delta_{1}\delta_{2})^{2}\sqrt{n}\\\ P^{+}(m)\leq
y\\\ \mu^{2}(m_{o})=(m,\mathfrak{N})=1\\\ m\equiv
n\,(\textup{mod}\,b\delta^{2}\delta_{1}^{2}\delta_{2}^{2})\\\ n-m\equiv
w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\end{subarray}}\chi_{-4}(b).$

Again we expect that $S_{1}$ gives a negligible contribution, as in the proof
of Proposition 5.2, due to a particular behaviour at the prime 2 which makes
the main term disappear, but this is not so easy to see in the present
situation. We will carry out the computation for both $S_{1}$ and $S_{2}$ and
combine them to a joint main term for which we obtain the desired lower bound.
As before, the computation of $S_{1}$ is slightly harder, so we focus on this
part in detail, while the computation of $S_{2}$ is similar, but technically
slightly easier. Our first step is to establish the asymptotic evaluations
(6.48) and (6.57) below.

We would like to choose $\eta_{0}$ sufficiently small so that we can evaluate
the inner two sums by Proposition 6.1, but this requires some preparation. We
consider $S_{1}$ first. As before we write

$r_{2}=(\delta\delta_{1}\delta_{2},2^{\infty}),\quad
d=\delta\delta_{1}\delta_{2}/r_{2},\quad a_{2}=(a,2^{\infty}),\quad
a_{d}=(a,d^{\infty}),\quad
d^{\prime}=\delta_{1}^{\prime}\delta_{2}^{\prime}/(\delta_{1}^{\prime}\delta_{2}^{\prime},2),$

so that $a,m$-sum in $S_{1}$ becomes

(6.43) $\displaystyle\sum_{\begin{subarray}{c}a_{2}\mid 2^{\infty}\\\
(a_{2},\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}\sum_{a_{d}\mid
d^{\infty}}\chi_{-4}(a_{d})\underset{u\,(\text{mod
}4)}{\left.\sum\right.^{\ast}}\chi_{-4}(u)\sum_{\begin{subarray}{c}v\,(\textup{mod}\,4)\end{subarray}}\chi_{-4}(v)\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}a_{d}\\\
(a,2d_{1}d_{2})=1\\\ a\equiv
u\,(\textup{mod}\,4)\end{subarray}}\sum_{\begin{subarray}{c}n-x\leq m\leq
x,P^{+}(m)\leq y\\\ \mu^{2}(m_{o})=(m,\mathfrak{N})=1\\\ m\equiv
n\,(\textup{mod}\,aa_{2}a_{d}r_{2}^{2}d^{2})\\\ n-m\equiv
w\,(\textup{mod}\,d^{\prime})\\\ \frac{n-m}{a_{2}r_{2}^{2}}\equiv
v\,(\textup{mod}\,4)\end{subarray}}1.$

Here we have used the fact that if
$2\mid\delta_{1}^{\prime}\delta_{2}^{\prime}$, then we must have
$r_{2}a_{2}=1$ and $(w,2)=1$ so that the condition $n-m\equiv
w\,(\textup{mod}\,2)$ is incorporated in the $v$-sum. As before, we can
restrict $a_{2},a_{d}\leq n^{\eta_{0}}$ at the cost of an error of size
$O(n^{1+\varepsilon-\eta_{0}/2})$. The $a,m$-sum in (6.43) can be written as

(6.44) $\displaystyle\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}a_{d}\\\
(a,2d_{1}d_{2})=1\\\ a\equiv
u\,(\textup{mod}\,4)\end{subarray}}\sum_{\begin{subarray}{c}n-x\leq m\leq
x,P^{+}(m)\leq y\\\ \mu^{2}(m_{o})=(m,\mathfrak{N})=1\\\ m\equiv
n\,(\textup{mod}\,a)\\\ m\equiv n\,(\textup{mod}\,a_{d}d^{2})\\\ m\equiv
n-va_{2}r_{2}^{2}\,(\textup{mod}\,4a_{2}r_{2}^{2})\\\ m\equiv
n-w\,(\textup{mod}\,d^{\prime})\end{subarray}}1.$

By the Chinese remainder theorem, the congruence conditions modulo
$a_{d}d^{2},4a_{2}r_{2}^{2},d^{\prime}$ can be written as a single congruence
condition $\frac{m}{g_{1}}\equiv c_{1}\,(\textup{mod}\,F_{1})$ with
$(c_{1},F_{1})=1$, where

(6.45) $F_{1}=\frac{4a_{2}r_{2}^{2}a_{d}d^{2}d^{\prime}}{g_{1}},\quad
g_{1}=(n-va_{2}r_{2}^{2},4a_{2}r_{2}^{2})(n-w,d^{\prime})(n,a_{d}d^{2}).$

In order for the $m$-sum to be nonempty, we must have

(6.46) $\displaystyle P^{+}(g_{1})\leq
y,\quad\mu((g_{1})_{o})^{2}=(g_{1},\mathfrak{N})=1,$

as well as

$\quad P^{+}((a,n))\leq y,\quad\mu((a,n))^{2}=(a,n,\mathfrak{N})=1,$

in which case we can re-write the $a,m$-sum in (6.44) as

(6.47) $\displaystyle\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}a_{d}\\\
(a,2d_{1}d_{2})=1\\\ a\equiv
u\,(\textup{mod}\,4)\end{subarray}}\sum_{\begin{subarray}{c}(n-x)/g_{1}\leq
m\leq x/g_{1}\\\ P^{+}(m)\leq y\\\
\mu^{2}(m_{o})=(m,(g_{1})_{o}\mathfrak{N})=1\\\ m\equiv
n\bar{g}_{1}\,(\textup{mod}\,a)\\\ m\equiv
c_{1}\,(\textup{mod}\,F_{1})\end{subarray}}1=\sum_{\begin{subarray}{c}h\mid
n\\\ (h,2d_{1}d_{2})=1\\\ \mu^{2}(h)=(h,\mathfrak{N})=1\\\ P^{+}(h)\leq
y\end{subarray}}\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}a_{d}h\\\
(a,2d_{1}d_{2})=1\\\ (a,n/h)=1\\\ a\equiv
u\bar{h}\,(\textup{mod}\,4)\end{subarray}}\sum_{\begin{subarray}{c}n-x\leq
mg_{1}h\leq x\\\ P^{+}(m)\leq y\\\
\mu^{2}(m_{o})=(m_{o},g_{1}h\mathfrak{N})=1\\\
m\equiv\frac{n}{h}\bar{g}_{1}\,(\textup{mod}\,a)\\\ m\equiv
c_{1}\bar{h}\,(\textup{mod}\,F_{1})\end{subarray}}1.$

Note that from the construction of the sieve weights we have
$d_{1},d_{2}\leq\mathcal{Q}\mathcal{D}\ll n^{\kappa_{0}}$ and thus we
automatically have $g_{1}\ll n^{2\eta_{0}+4\kappa_{0}}$, a small power of $n$.
Also note that $g_{1}\mid(2d_{1}d_{2})^{\infty}$, so that automatically
$(g_{1},h)=1$.

We can again restrict $h\leq n^{\eta_{0}}$ with a total error of size
$O(n^{1+\varepsilon-\eta_{0}/2})$. Finally we detect the conditions
$\mu^{2}(m_{o})=1$ and $(m_{o},g_{1}h\mathfrak{N})=1$ by Möbius inversion. We
summarize that the $a,m$-sum in (6.43) can, up to an admissible error of size
$O(n^{1+\varepsilon-\eta_{0}/2})$, be replaced with

$\sum_{\begin{subarray}{c}h\mid n\\\ (h,2d_{1}d_{2})=1\\\
\mu^{2}(h)=(h,\mathfrak{N})=1\\\ P^{+}(h)\leq y\\\ h\leq
n^{\eta_{0}}\end{subarray}}\sum_{\begin{subarray}{c}k\leq\sqrt{x}\\\
(k,2ag_{1}hF_{1}\mathfrak{N})=1\\\ P^{+}(k)\leq
y\end{subarray}}\mu(k)\sum_{\begin{subarray}{c}\lambda\mid
g_{1}h\mathfrak{N}\\\ P^{+}(\lambda)\leq y\\\
(\lambda,2aF_{1})=1\end{subarray}}\mu(\lambda)\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}a_{d}h\\\
(a,2d_{1}d_{2})=1\\\ (a,n/h)=1\\\ a\equiv
u\bar{h}\,(\textup{mod}\,4)\end{subarray}}\sum_{\begin{subarray}{c}n-x\leq
mg_{1}hk^{2}\lambda\leq x\\\ P^{+}(m)\leq y\\\
m\equiv\frac{n}{h}\overline{\lambda g_{1}k^{2}}\,(\textup{mod}\,a)\\\ m\equiv
c_{1}\overline{\lambda hk^{2}}\,(\textup{mod}\,F_{1})\end{subarray}}1,$

where $a_{2},a_{d}\ll n^{\eta_{0}},g_{1}\ll n^{2\eta_{0}+4\kappa_{0}}$ are
sufficiently small powers of $n$. As before, we may also restrict $\lambda$
and $k$ up to $n^{\eta_{0}}$, up to an admissible error of size
$O(n^{1+\varepsilon-\eta_{0}})$.

After splitting $a$ into further residue classes modulo $4d_{1}d_{2}$ to
detect the coprimality condition and also so that we have
$F_{1}\mid(4d_{1}d_{2})^{\infty}$, we are finally in a position to apply
Proposition 6.1 to the $a,m$-sum of the previous display to obtain (under GRH
with $\eta_{0},\kappa_{0}$ sufficiently small) that

$\sum_{\begin{subarray}{c}h\mid n\\\ (h,2d_{1}d_{2})=1\\\
\mu^{2}(h)=(h,\mathfrak{N})=1\\\ P^{+}(h)\leq y\\\ h\leq
n^{\eta_{0}}\end{subarray}}\sum_{\begin{subarray}{c}(k,2d_{1}d_{2}n)=1\\\
P^{+}(k)\leq y\\\ k\leq
n^{\eta_{0}}\end{subarray}}\mu(k)\sum_{\begin{subarray}{c}\lambda\mid
g_{1}h\mathfrak{N}\\\ P^{+}(\lambda)\leq y\\\ (\lambda,2aF_{1})=1\\\
\lambda\leq
n^{\eta_{0}}\end{subarray}}\mu(\lambda)\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}a_{d}h\\\
(a,2d_{1}d_{2})=1\\\ (a,kn/h)=1\\\ a\equiv
u\bar{h}\,(\textup{mod}\,4)\end{subarray}}\sum_{\begin{subarray}{c}n-x\leq
m\lambda g_{1}hk^{2}\leq x\\\ P^{+}(m)\leq y\\\
(m,aF_{1})=1\end{subarray}}\frac{1}{\phi(a)\phi(F_{1})},$

up to a total error of size $O(n^{1+\varepsilon-\eta_{0}/2})$. We can now
complete the $\lambda,k$-sums in the same way as we truncated them, and
incorporate them back into the $a$, $m$-sum. Substituting back into (6.43) and
evaluating the $u$-sum, we obtain (writing the condition (6.46) on $g_{1}$ in
terms of the remaining variables and noting that
$\mu^{2}(d^{\prime})=1,a_{d}\mid d^{\infty}$) the expression

(6.48)
$S_{1}=\sum_{\delta_{1}\delta_{1}^{\prime}=d_{1}^{\prime}}\sum_{\delta_{2}\delta_{2}^{\prime}=d_{2}^{\prime}}\frac{4}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1}G_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\mathcal{M}_{1}+O(n^{1+\varepsilon-\eta_{0}/2}),$

where

(6.49) $\displaystyle\mathcal{M}_{1}=$
$\displaystyle\sum_{\begin{subarray}{c}a_{2}\mid 2^{\infty}\\\
(a_{2},\delta_{1}^{\prime}\delta_{2}^{\prime})=1\\\ a_{2}\leq
n^{\eta_{0}}\end{subarray}}\sum_{\begin{subarray}{c}a_{d}\mid
d^{\infty},a_{d}\leq n^{\eta_{0}}\\\ P^{+}((n,a_{d}d^{2}))\leq y\\\
\mu^{2}((n,a_{d}d^{2}))=1\\\
(n,d,\mathfrak{N})=1\end{subarray}}\chi_{-4}(a_{d})\sum_{\begin{subarray}{c}v\,(\textup{mod}\,4)\end{subarray}}\chi_{-4}(v)$
(6.50)
$\displaystyle\times\sum_{\begin{subarray}{c}w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\\\
(w,\delta_{1}^{\prime}\delta_{2}^{\prime})=1\\\
w\in\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\\\
P^{+}((n-w,d^{\prime}))\leq y\\\
(n-w,d^{\prime},\mathfrak{N})=1\end{subarray}}\sum_{\begin{subarray}{c}h\mid
n\\\ (h,2d_{1}d_{2}\mathfrak{N})=1\\\ P^{+}(h)\leq y\\\ \mu^{2}(h)=1\\\ h\leq
n^{\eta_{0}}\end{subarray}}\chi_{-4}(h)\sum_{\begin{subarray}{c}a\leq\sqrt{n}/a_{2}a_{d}h\\\
(a,2d_{1}d_{2})=1\\\ (a,n/h)=1\end{subarray}}\sum_{\begin{subarray}{c}m\leq
x/g_{1}h\\\ P^{+}(m)\leq y\\\ (m,aF_{1}(g_{1})_{o}h\mathfrak{N})=1\\\
\mu^{2}(m_{o})=1\end{subarray}}\frac{\chi_{-4}(a)}{\phi(a)\phi(F_{1})}.$

Next we change the summation order of $m$ and $a$, evaluate the $a$-sum by
[ABL, Lemma 5.2] and then complete the $a_{2},a_{d},h$-sums with an admissible
error to finally obtain (with e.g. $\eta_{0}=10\kappa_{0}$), uniformly for
$d_{1},d_{2}\ll n^{\kappa_{0}}$ (with $\kappa_{0}$ sufficiently small), that

(6.51) $\displaystyle\mathcal{M}_{1}=$
$\displaystyle\frac{\pi}{4}\prod_{p}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}\sum_{\begin{subarray}{c}a_{2}\mid
2^{\infty}\\\
(a_{2},\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}\sum_{\begin{subarray}{c}a_{d}\mid
d^{\infty}\\\ P^{+}((n,a_{d}d^{2}))\leq y\\\ \mu^{2}((n,a_{d}d^{2}))=1\\\
(n,d,\mathfrak{N})=1\end{subarray}}\chi_{-4}(a_{d})\sum_{\begin{subarray}{c}v\,(\textup{mod}\,4)\end{subarray}}\chi_{-4}(v)$
(6.52)
$\displaystyle\times\sum_{\begin{subarray}{c}w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\\\
w\in\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\\\
P^{+}((n-w,d^{\prime}))\leq y\\\
(n-w,d^{\prime},\mathfrak{N})=1\end{subarray}}\sum_{\begin{subarray}{c}h\mid
n\\\ (h,2d_{1}d_{2}\mathfrak{N})=1\\\ P^{+}(h)\leq y\\\
\mu^{2}(h)=1\end{subarray}}\chi_{-4}(h)\sum_{\begin{subarray}{c}m\leq
x/g_{1}h\\\ P^{+}(m)\leq y\\\ (m,F_{1}(g_{1})_{o}h\mathfrak{N})=1\\\
\mu^{2}(m_{o})=1\\\
\end{subarray}}\frac{\mathfrak{c}(2d_{1}d_{2}mn/h)}{\phi(F_{1})}+O(n^{1-3\kappa_{0}})$

with $\mathfrak{c}(f)$ as in (5.17). (The error term ensures that even after
summing over $d_{1},d_{2}$ it is still acceptable.)

The same strategy can be applied to $S_{2}$. We give a sketch of the
manipulations highlighting the differences from those for $S_{1}$. To begin
with, we do not need to separate $r_{2}$ from $\delta\delta_{1}\delta_{2}$, so
that the $b,m$-sum in $S_{2}$ becomes

(6.53)
$\displaystyle\sum_{b_{d}\mid(\delta\delta_{1}\delta_{2})^{\infty}}\chi_{-4}(b_{d})\underset{u\,(\text{mod
}4)}{\left.\sum\right.^{\ast}}\chi_{-4}(u)\sum_{\begin{subarray}{c}b\leq\frac{x}{b_{d}(\delta\delta_{1}\delta_{2})^{2}\sqrt{n}}\\\
(b,d_{1}d_{2})=1\\\ b\equiv
u\,(\textup{mod}\,4)\end{subarray}}\sum_{\begin{subarray}{c}n-x\leq m\leq
x,P^{+}(m)\leq y\\\ m\leq n-bb_{d}(\delta\delta_{1}\delta_{2})^{2}\sqrt{n}\\\
\mu^{2}(m_{o})=(m,\mathfrak{N})=1\\\ m\equiv
n\,(\textup{mod}\,bb_{d}(\delta\delta_{1}\delta_{2})^{2})\\\ n-m\equiv
w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\end{subarray}}1.$

We can restrict $b_{d}\leq n^{\eta_{0}}$ with an error of size
$O(n^{1+\varepsilon-\eta_{0}/2})$. After splitting $m$ into residue classes
modulo $d_{1}d_{2}$, using the Chinese remainder theorem to rewrite the
congruence condition modulo
$b_{d}(\delta\delta_{1}\delta_{2})^{2}\delta_{1}^{\prime}\delta_{2}^{\prime}$
as $m\equiv c_{2}\,(\textup{mod}\,F_{2})$ with

(6.54) $\displaystyle
F_{2}=\frac{b_{d}(\delta\delta_{1}\delta_{2})^{2}\delta_{1}^{\prime}\delta_{2}^{\prime}}{g_{2}},\
g_{2}=(n-w,\delta_{1}^{\prime}\delta_{2}^{\prime})(n,b_{d}\delta^{2}\delta_{1}^{2}\delta_{2}^{2})$

and then extracting $(b,n)$, we can write the $b,m$-sum in (6.53) as

(6.55) $\displaystyle\mathds{1}_{\begin{subarray}{c}P^{+}(g_{2})\leq y\\\
(g_{2},\mathfrak{N})=1\\\
\mu^{2}((g_{2})_{o})=1\end{subarray}}\sum_{\begin{subarray}{c}h\mid n\\\
(h,d_{1}d_{2}\mathfrak{N})=1\\\ P^{+}(h)\leq y\\\
\mu^{2}(h)=1\end{subarray}}\chi_{-4}(h)\sum_{\begin{subarray}{c}b\leq\frac{x}{b_{d}(\delta\delta_{1}\delta_{2})^{2}\sqrt{n}h}\\\
(b,d_{1}d_{2})=1\\\ (b,n/h)=1\\\ b\equiv
u\,(\textup{mod}\,4)\end{subarray}}\sum_{\begin{subarray}{c}n-x\leq
mg_{2}h\leq x,P^{+}(m)\leq y\\\ mg_{2}h\leq
n-bb_{d}(\delta\delta_{1}\delta_{2})^{2}\sqrt{n}\\\
\mu^{2}(m_{o})=(m_{o},g_{2}h\mathfrak{N})=1\\\
m\equiv\frac{n}{h}\overline{g}_{2}\,(\textup{mod}\,b)\\\ m\equiv
c_{2}\overline{h}\,(\textup{mod}\,F_{2})\end{subarray}}1.$

We can again restrict $h\leq n^{\eta_{0}}$ with a total error of size
$O(n^{1+\varepsilon-\eta_{0}/2})$. Additionally, we need to separate $b,m$ in
the summation condition in order to apply Proposition 6.1. As usual, this can
be achieved by splitting $m$ into intervals of the form $[M,(1+\Delta)M]$ with
$\Delta=n^{-\eta_{0}}$ so that at most one interval interferes with the
condition $mg_{2}h\leq n-bb_{d}\sqrt{n}(\delta\delta_{1}\delta_{2})^{2}$, in
which case the contribution can be bounded by $O(n^{1+\epsilon-\eta_{0}})$
trivially. After Möbius inversion and splitting $b$ into residue classes
modulo $d_{1}d_{2}$, we can finally apply Proposition 6.1 so that the
$b,m$-sum in the last display can be evaluated, up to an admissible error, as

(6.56)
$\displaystyle\sum_{\begin{subarray}{c}b\leq\frac{x}{b_{d}(\delta\delta_{1}\delta_{2})^{2}\sqrt{n}h}\\\
(b,d_{1}d_{2})=1\\\ (b,n/h)=1\\\ b\equiv
u\,(\textup{mod}\,4)\end{subarray}}\sum_{\begin{subarray}{c}n-x\leq
mg_{2}h\leq x,P^{+}(m)\leq y\\\ mg_{2}h\leq
n-bb_{d}(\delta\delta_{1}\delta_{2})^{2}\sqrt{n}\\\
\mu^{2}(m_{o})=(m,\mathfrak{N})=1\\\
(m,bF_{2}(g_{2})_{o}h\mathfrak{N})=1\end{subarray}}\frac{1}{\phi(b)\phi(F_{2})}.$

After changing the order of summation, evaluating the $b$-sum by [ABL, Lemma
5.2] (note that the upper limit for $b_{d}$ is always $\gg n^{1/2-\eta_{0}}$
unless $|n-mg_{2}h|\leq n^{1-\eta_{0}}$ whose contribution can be bounded by
$O(n^{1-\eta_{0}/2})$) and completing the $b_{d},h$-sums, we obtain, uniformly
for $d_{1},d_{2}\leq n^{\kappa_{0}}$, that

(6.57) $\displaystyle
S_{2}=\sum_{\delta_{1}\delta_{1}^{\prime}=d_{1}^{\prime}}\sum_{\delta_{2}\delta_{2}^{\prime}=d_{2}^{\prime}}\frac{4}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}(1-\frac{\chi_{-4}(p)}{p})^{-1}G_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\mathcal{M}_{2}+O(n^{1-3\kappa_{0}}),$

where

(6.58)
$\displaystyle\mathcal{M}_{2}=\frac{\pi}{4}\prod_{p}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}\sum_{\begin{subarray}{c}b_{d}\mid(\delta\delta_{1}\delta_{2})^{\infty}\\\
P^{+}((n,b_{d}(\delta\delta_{1}\delta_{2})^{2}))\leq y\\\
\mu^{2}((n,b_{d}(\delta\delta_{1}\delta_{2})^{2})_{o})=1\\\
(n,\delta\delta_{1}\delta_{2},\mathfrak{N})=1\end{subarray}}\chi_{-4}(b_{d})$
(6.59)
$\displaystyle\times\sum_{\begin{subarray}{c}w\,(\textup{mod}\,\delta_{1}^{\prime}\delta_{2}^{\prime})\\\
w\in\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\\\
P^{+}((n-w,\delta_{1}^{\prime}\delta_{2}^{\prime}))\leq y\\\
(n-w,\delta_{1}^{\prime}\delta_{2}^{\prime},\mathfrak{N})=1\end{subarray}}\sum_{\begin{subarray}{c}h\mid
n\\\ (h,d_{1}d_{2})=1\\\ P^{+}(h)\leq y\\\ \mu^{2}(h)=1\\\
(h,\mathfrak{N})=1\end{subarray}}\chi_{-4}(h)\sum_{\begin{subarray}{c}m\leq
x/g_{2}h\\\ P^{+}(m)\leq y\\\ (m,F_{2}(g_{2})_{o}h\mathfrak{N})=1\\\
\mu^{2}(m_{o})=1\\\
\end{subarray}}\frac{\mathfrak{c}(d_{1}d_{2}mn/h)}{\phi(F_{2})}+O(n^{1-3\kappa_{0}}).$

###  6.5. Computing the main term II – Euler products

We substitute (6.48) and (6.57) back into (6.39). By choosing
$\mathcal{D}=n^{\kappa_{0}}$ sufficiently small, it follows from (6.31)
together with (6.34) that

(6.60)
$S(\mathcal{A},z)\geq\pi\prod_{p}\Big{(}1+\frac{\chi_{-4}(p)}{p(p-1)}\Big{)}(S_{1}^{-}+S_{2}^{-})+O(n^{1-\kappa_{0}}),$

where

(6.61) $\displaystyle S_{1}^{-}$
$\displaystyle=\sum_{u\mid\mathcal{Q}}\sum_{\begin{subarray}{c}c\mid
P_{\mathcal{Q}}(z)\end{subarray}}\lambda_{c}^{-}\mu(c)\sum_{\begin{subarray}{c}d_{1},d_{2}\\\
p\mid d_{1}d_{2}\Leftrightarrow p\mid
uc\end{subarray}}\mu(d_{1})\mu(d_{2})\operatornamewithlimits{\sum\sum}_{\begin{subarray}{c}\delta=(d_{1},d_{2})\\\
\delta_{i}\delta_{i}^{\prime}=d_{i}^{\prime}=d_{i}/\delta\\\
r_{2}d=\delta\delta_{1}\delta_{2},r_{2}\mid 2,(d,2)=1\\\
d^{\prime}=\delta_{1}^{\prime}\delta_{2}^{\prime}/(\delta_{1}^{\prime}\delta_{2}^{\prime},2)\end{subarray}}\frac{1}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1}$
(6.62) $\displaystyle\times\sum_{\begin{subarray}{c}a_{2}\mid 2^{\infty}\\\
(a_{2},\delta_{1}^{\prime}\delta_{2}^{\prime})=1\end{subarray}}\sum_{\begin{subarray}{c}a_{d}\mid
d^{\infty}\\\ P^{+}((n,a_{d}d^{2}))\leq y\\\ \mu^{2}((n,a_{d}d^{2}))=1\\\
(n,d,\mathfrak{N})=1\end{subarray}}\chi_{-4}(a_{d})\sum_{\begin{subarray}{c}v\,(\textup{mod}\,4)\end{subarray}}\chi_{-4}(v)$
(6.63) $\displaystyle\times
G_{d^{\prime}}\sum_{\begin{subarray}{c}w\,(\textup{mod}\,d^{\prime})\\\
w\in\mathcal{G}_{d^{\prime}}\\\ P^{+}((n-w,d^{\prime}))\leq y\\\
(n-w,d^{\prime},\mathfrak{N})=1\end{subarray}}\sum_{\begin{subarray}{c}h\mid
n\\\ (h,2d_{1}d_{2}\mathfrak{N})=1\\\ P^{+}(h)\leq y\\\
\mu^{2}(h)=1\end{subarray}}\chi_{-4}(h)\sum_{\begin{subarray}{c}m\leq
x/g_{1}h\\\ P^{+}(m)\leq y\\\ (m,F_{1}(g_{1})_{o}h\mathfrak{N})=1\\\
\mu^{2}(m_{o})=1\end{subarray}}\frac{\mathfrak{c}(2d_{1}d_{2}mn/h)}{\phi(F_{1})}$

with $F_{1},g_{1}$ as in (6.45), and

(6.64) $\displaystyle S_{2}^{-}$
$\displaystyle=\sum_{u\mid\mathcal{Q}}\sum_{c\mid
P_{\mathcal{Q}}(z)}\lambda_{c}^{-}\mu(c)\sum_{\begin{subarray}{c}d_{1},d_{2}\\\
p\mid d_{1}d_{2}\Leftrightarrow p\mid
uc\end{subarray}}\mu(d_{1})\mu(d_{2})\operatornamewithlimits{\sum\sum}_{\begin{subarray}{c}\delta=(d_{1},d_{2})\\\
\delta_{i}\delta_{i}^{\prime}=d_{i}^{\prime}=d_{i}/\delta\\\
d=\delta\delta_{1}\delta_{2}\\\
d^{\prime}=\delta_{1}^{\prime}\delta_{2}^{\prime}\end{subarray}}\frac{1}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1}$
(6.65) $\displaystyle\times G_{d^{\prime}}\sum_{\begin{subarray}{c}b_{d}\mid
d^{\infty}\\\ P^{+}((n,b_{d}d^{2}))\leq y\\\ \mu^{2}((n,b_{d}d^{2})_{o})=1\\\
(n,d,\mathfrak{N})=1\end{subarray}}\chi_{-4}(b_{d})\sum_{\begin{subarray}{c}w\,(\textup{mod}\,d^{\prime})\\\
w\in\mathcal{G}_{d^{\prime}}\\\ P^{+}((n-w,d^{\prime}))\leq y\\\
(n-w,d^{\prime},\mathfrak{N})=1\end{subarray}}\sum_{\begin{subarray}{c}h\mid
n\\\ (h,d_{1}d_{2}\mathfrak{N})=1\\\ P^{+}(h)\leq y\\\
\mu^{2}(h)=1\end{subarray}}\chi_{-4}(h)\sum_{\begin{subarray}{c}m\leq
x/g_{2}h\\\ P^{+}(m)\leq y\\\ (m,F_{2}(g_{2})_{o}h\mathfrak{N})=1\\\
\mu^{2}(m_{o})=1\end{subarray}}\frac{\mathfrak{c}(d_{1}d_{2}mn/h)}{\phi(F_{2})}$

with $F_{2},g_{2}$ as in (6.54). Now we rename $mg_{i}$ as $m$, change the
order of summation and evaluate $S_{1}^{-},S_{2}^{-}$ in roughly the form

$\sum_{\begin{subarray}{c}h\mid n\\\
(\cdots)\end{subarray}}\sum_{\begin{subarray}{c}m\leq x/h\\\
(\cdots)\end{subarray}}\sum_{\begin{subarray}{c}u\mid\mathcal{Q}\\\
(u,h)=1\end{subarray}}\sum_{\begin{subarray}{c}c\mid P(z)\\\
(c,\mathcal{Q}h)=1\end{subarray}}\lambda_{c}^{-}w_{m,n,h}(c)$

for some multiplicative function $w_{m,n,h}(c)$. In particular, we postpone
the summation over $m$ to the last moment. Precisely, we write

(6.66) $\begin{split}S_{1}^{-}&=\sum_{\begin{subarray}{c}h\mid n\\\
P^{+}(h)\leq y\\\ \mu^{2}(h)=1\\\
(h,\mathfrak{N})=1\end{subarray}}\chi_{-4}(h)\sum_{\begin{subarray}{c}m\leq
x/h\\\ (m,\mathfrak{N})=1\\\ P^{+}(m)\leq y\\\
\mu^{2}(m_{o}h)=1\end{subarray}}\sum_{\begin{subarray}{c}u\mid\mathcal{Q}\\\
(u,h)=1\end{subarray}}\sum_{\begin{subarray}{c}c\mid P(z)\\\
(c,\mathcal{Q}h)=1\end{subarray}}\lambda_{c}^{-}\mu(c)\sum_{\begin{subarray}{c}d_{1},d_{2}\\\
p\mid d_{1}d_{2}\Leftrightarrow p\mid
uc\end{subarray}}\mu(d_{1})\mu(d_{2})\mathfrak{c}\Big{(}2d_{1}d_{2}\frac{n}{h}m\Big{)}\\\
&\operatornamewithlimits{\sum\sum}_{\begin{subarray}{c}\delta=(d_{1},d_{2}),\delta_{i}\delta_{i}^{\prime}=d_{i}^{\prime}=d_{i}/\delta\\\
r_{2}d=\delta\delta_{1}\delta_{2},r_{2}\mid 2,(d,2)=1\\\
d^{\prime}=\delta_{1}^{\prime}\delta_{2}^{\prime}/(\delta_{1}^{\prime}\delta_{2}^{\prime},2)\end{subarray}}\frac{G_{d^{\prime}}}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1}\operatornamewithlimits{\sum\sum\sum\sum}_{\begin{subarray}{c}a_{2},a_{d},v,w\\\
(a_{2},a_{d},v,w)\in\mathcal{R}_{1}\end{subarray}}\frac{\chi_{-4}(a_{d})\chi_{-4}(v)}{\phi(F_{1})}\end{split}$

where $\mathfrak{c}(f)$ is as in (5.17), $F_{1}$ is as in (6.45), and

$\mathcal{R}_{1}=\left\\{\begin{array}[]{cc}a_{2}\mid 2^{\infty},a_{d}\mid
d^{\infty}\\\
v\,(\textup{mod}\,4),w\,(\textup{mod}\,d^{\prime})\end{array}:\begin{array}[]{cc}(a_{2},\delta_{1}^{\prime}\delta_{2}^{\prime})=1\\\
(m,4a_{2}r_{2}^{2})=(n-va_{2}r_{2}^{2},4a_{2}r_{2}^{2})\\\
(m,a_{d}d^{2})=(n,a_{d}d^{2})\end{array}\begin{array}[]{cc}w\in\mathcal{G}_{d^{\prime}}\\\
(w,d^{\prime})=1\\\ (m,d^{\prime})=(n-w,d^{\prime})\end{array}\right\\}.$

To see this, we recall the conditions (6.46) and observe that after replacing
$mg_{1}$ with $m$, the new conditions $P^{+}(m)\leq y$, $\mu^{2}(m_{o})=1$,
$(m,\mathfrak{N})=1$ take care of the old conditions
$P^{+}((n,a_{d}d^{2}))\leq y$, $P^{+}((n-w,d^{\prime}))\leq y$,
$\mu^{2}((n,a_{d}d^{2}))=(n,a_{d}d^{2},\mathfrak{N})=(n-w,d^{\prime},\mathfrak{N})=1$.
Moreover, the old condition $(m,F_{1})=1,mg_{1}\leq x/h$ is equivalent to the
new condition $(m,4a_{2}r_{2}^{2}a_{d}d^{2}d^{\prime})=g_{1},m\leq x/h$ after
replacing $mg_{1}$ with $m$. Note also that
$\mathcal{G}_{\delta_{1}^{\prime}\delta_{2}^{\prime}}\simeq\mathcal{G}_{d^{\prime}}$.
Similarly, we write

(6.67) $\begin{split}S_{2}^{-}&=\sum_{\begin{subarray}{c}h\mid n\\\
P^{+}(h)\leq y\\\ \mu^{2}(h)=1\\\
(h,\mathfrak{N})=1\end{subarray}}\chi_{-4}(h)\sum_{\begin{subarray}{c}m\leq
x/h\\\ (m,\mathfrak{N})=1\\\ P^{+}(m)\leq y\\\
\mu^{2}(m_{o}h)=1\end{subarray}}\sum_{\begin{subarray}{c}u\mid\mathcal{Q}\\\
(u,h)=1\end{subarray}}\sum_{\begin{subarray}{c}c\mid P(z)\\\
(c,\mathcal{Q}h)=1\end{subarray}}\lambda_{c}^{-}\mu(c)\sum_{\begin{subarray}{c}d_{1},d_{2}\\\
p\mid d_{1}d_{2}\Leftrightarrow p\mid
uc\end{subarray}}\mu(d_{1})\mu(d_{2})\mathfrak{c}\Big{(}d_{1}d_{2}\frac{n}{h}m\Big{)}\\\
&\operatornamewithlimits{\sum\sum}_{\begin{subarray}{c}\delta=(d_{1},d_{2})\\\
\delta_{i}\delta_{i}^{\prime}=d_{i}^{\prime}=d_{i}/\delta\\\
d=\delta\delta_{1}\delta_{2}\\\
d^{\prime}=\delta_{1}^{\prime}\delta_{2}^{\prime}\end{subarray}}\frac{G_{d^{\prime}}}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1}\operatornamewithlimits{\sum\sum}_{\begin{subarray}{c}b_{d},w\\\
(b_{d},w)\in\mathcal{R}_{2}\end{subarray}}\frac{\chi_{-4}(b_{d})}{\phi(F_{2})}\end{split}$

where $F_{2}$ is as in (6.54) and

$\mathcal{R}_{2}=\left\\{\begin{array}[]{cc}b_{d}\mid d^{\infty}\\\
w\,(\textup{mod}\,d^{\prime})\end{array}:\begin{array}[]{cc}(m,b_{d}d^{2})=(n,a_{d}d^{2})\\\
w\in\mathcal{G}_{d^{\prime}}\end{array}\begin{array}[]{cc}(w,d^{\prime})=1\\\
(m,d^{\prime})=(n-w,d^{\prime})\end{array}\right\\}.$

Our next aim is to write the second line in (6.66) as an Euler product which
will be given in (6.72) below. The $v$-sum modulo $4$ in (6.66) contributes

(6.68) $\displaystyle\sum_{\begin{subarray}{c}v\,(\textup{mod}\,4)\\\
(n-va_{2}r_{2}^{2},4a_{2}r_{2}^{2})=(m,4a_{2}r_{2}^{2})\end{subarray}}\frac{\chi_{-4}(v)}{\phi(\frac{4a_{2}r_{2}^{2}}{(n-va_{2}r_{2}^{2},4a_{2}r_{2}^{2})})}=\mathds{1}_{2a_{2}r_{2}^{2}\mid
m}\mathds{1}_{a_{2}r_{2}^{2}\parallel
n}\chi_{-4}\Big{(}\frac{n}{a_{2}r_{2}^{2}}\Big{)}\times\begin{cases}-1&4a_{2}r_{2}^{2}\nmid
m,\\\ 1&4a_{2}r_{2}^{2}\mid m.\end{cases}$

In particular, we see that for each $r_{2}$, only one $a_{2}$ with
$(a_{2},\delta_{1}^{\prime}\delta_{2}^{\prime})=1$ gives a non-zero
contribution. The $w$-sum together with $G_{d^{\prime}}$ can be evaluated as
(treat each prime $p\mid d^{\prime}$ at a time)

(6.69)
$G_{d^{\prime}}\sum_{\begin{subarray}{c}w\,(\textup{mod}\,d^{\prime})\\\
w\in\mathcal{G}_{d^{\prime}}\\\
(n-w,d^{\prime})=(m,d^{\prime})\end{subarray}}\frac{1}{\phi\big{(}d^{\prime}/(n-w,d^{\prime})\big{)}}=\mathds{1}_{(d^{\prime},m,n)=1}\prod_{\begin{subarray}{c}p\mid
d^{\prime}\\\ p\mid
mn\end{subarray}}(1+\chi_{p^{*}}(n))\prod_{\begin{subarray}{c}p\mid
d^{\prime}\\\ p\nmid
mn\end{subarray}}\Big{(}1-\frac{1+\chi_{p^{*}}(n)}{p-1}\Big{)}.$

Finally, the sum over $a_{d}\mid d^{\infty}$ gives

(6.70) $\displaystyle\sum_{\begin{subarray}{c}a_{d}\mid d^{\infty}\\\
(n,a_{d}d^{2})=(m,a_{d}d^{2})\end{subarray}}\frac{\chi_{-4}(a_{d})}{\phi(a_{d}d^{2}/(n,a_{d}d^{2}))}=\prod_{p\mid
d}\mathfrak{d}(p;m,n)$

where

(6.71)
$\displaystyle\mathfrak{d}(p;m,n)=\begin{cases}\frac{1}{(p-1)(p-\chi_{-4}(p))},&p\nmid
mn,\\\ \frac{p}{(p-1)(p-\chi_{-4}(p))},&\nu_{p}(m)=\nu_{p}(n)=1,\\\
0,&\text{else}.\end{cases}$

Here we use crucially that (the odd part of) $m$ is squarefree. For more
general $m$, the formula would look much more complicated, in particular the
contribution could be much larger which would create considerable technical
problems in apply Lemma 6.3.

We summarize: the second line in (6.66) can be written as an Euler product

(6.72)
$\displaystyle\sum_{\begin{subarray}{c}\delta_{1}^{\prime}\delta_{1}=d_{1}^{\prime}\\\
\delta_{2}^{\prime}\delta_{2}=d_{2}^{\prime}\end{subarray}}\frac{G_{\delta_{1}^{\prime}\delta_{2}^{\prime}}}{\delta_{1}^{\prime}\delta_{2}^{\prime}}\prod_{p\mid\delta_{1}^{\prime}\delta_{2}^{\prime}}\Big{(}1-\frac{\chi_{-4}(p)}{p}\Big{)}^{-1}\sum_{a_{2},a_{d},v,w}(\dots)=:\prod_{p^{\nu}\parallel
d_{1}d_{2}}\mathfrak{f}_{1}(p,\nu;m,n)$

where the Euler factor is composed of (6.68), (6.69) and (6.70).

We compute $\mathfrak{f}_{1}(2,\nu;m,n)$ explicitly using (6.68). If $2\nmid
d_{1}d_{2}$, then $r_{2}=1$ and only $a_{2}=2^{\nu_{2}(n)}$ contributes. If
$2\parallel d_{1}d_{2}$, then we have two cases: when
$2\parallel\delta_{1}^{\prime}\delta_{2}^{\prime}$, we have $r_{2}=1$ and only
$a_{2}=1$ contributes (since we require
$(a_{2},\delta_{1}^{\prime}\delta_{2}^{\prime})=1$); and when
$2\parallel\delta_{1}\delta_{2}$, we have $r_{2}=2$ and only
$a_{2}=2^{\nu_{2}(n)-2}$ contributes. If $2\mid(d_{1},d_{2})$, then $r_{2}=2$
and only $a_{2}=2^{\nu_{2}(n)-2}$ contributes. Precisely, we have

(6.73)
$\mathfrak{f}_{1}(2,\nu;m,n)=\begin{cases}\mathds{1}_{2^{\nu_{2}(n)+1}\mid
m}\chi_{-4}(n_{o})(-1)^{\mathds{1}_{2^{\nu_{2}(n)+2}\nmid m}},&\nu=0,\\\
\frac{1}{2}\mathds{1}_{2\mid m}\chi_{-4}(n)(-1)^{\mathds{1}_{4\nmid
m}}+\mathds{1}_{2^{\nu_{2}(n)+1}\mid m}\mathds{1}_{4\mid
n}\chi_{-4}(n_{o})(-1)^{\mathds{1}_{2^{\nu_{2}(n)+2}\nmid m}},&\nu=1,\\\
\mathds{1}_{2^{\nu_{2}(n)+1}\mid m}\mathds{1}_{4\mid
n}\chi_{-4}(n_{o})(-1)^{\mathds{1}_{2^{\nu_{2}(n)+2}\nmid
m}},&\nu=2.\end{cases}$

We can also compute $\mathfrak{f}_{1}(p,\nu;m,n)$ for $2\nmid p$ using (6.69)
and (6.70) as

(6.74) $\mathfrak{f}_{1}(p,\nu;m,n)=\begin{cases}1,&\nu=0,\\\
\frac{1}{(p-1)(p-\chi_{-4}(p))}+\frac{1}{p}(1-\frac{\chi_{-4}(p)}{p})^{-1}(1-\frac{1+\chi_{p^{*}}(n)}{p-1}),&p\nmid
mn,\nu=1,\\\
\frac{1}{p}(1-\frac{\chi_{-4}(p)}{p})^{-1}\big{(}1+\chi_{p^{*}}(n)\big{)},&p\mid
mn,p\nmid(m,n),\nu=1,\\\ \frac{p}{(p-1)(p-\chi_{-4}(p))},&p\mid(m,n),\nu=1,\\\
\mathfrak{d}(p;m,n),&\nu=2.\end{cases}$

For $S_{2}^{-}$, we have analogous results with $\mathfrak{f}_{1}$ replaced by
$\mathfrak{f}_{2}$ where

(6.75) $\mathfrak{f}_{2}(2,\nu;m,n)=\begin{cases}1,&\nu=0,\\\
\frac{1}{2}\mathds{1}_{2\mid
mn,2\nmid(m,n)}+\mathds{1}_{(m,4)=(n,4)}\frac{1}{\phi(4/(n,4))},&\nu=1,\\\
\mathds{1}_{(m,4)=(n,4)}\frac{1}{\phi(4/(n,4))},&\nu=2,\end{cases}$

(noting that if $2\mid\delta_{1}^{\prime}\delta_{2}^{\prime}$ then the $w$-sum
is zero unless $2|mn,2\nmid(m,n)$; and if $2\mid\delta\delta_{1}\delta_{2}$
then the $2$-part in the $b_{d}$-sum becomes
$\frac{1}{\phi(4/(n,4))}\mathds{1}_{(m,4)=(n,4)}$), and for $2\nmid p$ we have

(6.76) $\mathfrak{f}_{2}(p,\nu;m,n)=\mathfrak{f}_{1}(p,\nu;m,n).$

###  6.6. Computation of the main term III – the sieve weights

We are now prepared to further evaluate $S_{1}^{-}$ and $S_{2}^{-}$. We will
bound $S_{1}^{-}+S_{2}^{-}$ from below by (6.82) using properties of the lower
bound sieve weights in Lemma 6.3.

To begin with, we substitute (6.72) into (6.66). We still keep $h$ and $m$
fixed and consider the $u,c,d_{1},d_{2}$-sum in (6.66) which now equals

$\sum_{\begin{subarray}{c}u\mid\mathcal{Q}\\\
(u,h)=1\end{subarray}}\sum_{\begin{subarray}{c}c\mid P(z)\\\
(c,\mathcal{Q}h)=1\end{subarray}}\lambda_{c}^{-}\mu(c)\sum_{\begin{subarray}{c}d_{1},d_{2}\\\
p\mid d_{1}d_{2}\Leftrightarrow p\mid
uc\end{subarray}}\mu(d_{1})\mu(d_{2})\mathfrak{c}\Big{(}2d_{1}d_{2}\frac{n}{h}m\Big{)}\prod_{p^{\nu}\parallel
d_{1}d_{2}}\mathfrak{f}_{1}(p,\nu;m,n).$

We recast this as (noting $\mathfrak{c}(2)=1$)

$\mathfrak{c}\Big{(}\frac{n}{h}m\Big{)}\sum_{\begin{subarray}{c}u\mid\mathcal{Q}\\\
(u,h)=1\end{subarray}}\sum_{\begin{subarray}{c}c\mid P(z)\\\
(c,\mathcal{Q}h)=1\end{subarray}}\lambda_{c}^{-}\mu(c)\sum_{\begin{subarray}{c}d_{1},d_{2}\\\
p\mid d_{1}d_{2}\Leftrightarrow p\mid
uc\end{subarray}}\mu(d_{1})\mu(d_{2})\prod_{\begin{subarray}{c}p^{\nu}\parallel
d_{1}d_{2}\\\ p\nmid
2\end{subarray}}\mathfrak{w}(p,\nu;m,n,h)\prod_{2^{\nu}\parallel
d_{1}d_{2}}\mathfrak{f}_{1}(2,\nu;m,n)$

(of course each of the product over primes has only one factor, since $\nu$ is
unique) where

(6.77)
$\displaystyle\mathfrak{w}(p,\nu;m,n,h)=\begin{cases}\mathfrak{c}(p)\mathfrak{f}_{1}(p,\nu;m,n),&p\nmid
2\frac{n}{h}m,\\\ \mathfrak{f}_{1}(p,\nu;m,n),&2\nmid
p\mid\frac{n}{h}m.\end{cases}$

We observe that the sum over $d_{1},d_{2}$ gives

(6.78)
$\displaystyle\tilde{\mathfrak{f}}_{1}(2;m,n;u)\prod_{\begin{subarray}{c}p\mid
uc\\\ p\nmid
2\end{subarray}}(-2\mathfrak{w}(p,1;m,n,h)+\mathfrak{w}(p,2;m,n,h))$

where

(6.79)
$\tilde{\mathfrak{f}}_{1}(2;m,n;u)=\begin{cases}-2\mathfrak{f}_{1}(2,1;m,n)+\mathfrak{f}_{1}(2,2;m,n),&2\mid
u,\\\ \mathfrak{f}_{1}(2,0;m,n),&2\nmid u.\end{cases}$

Using the formulas (6.75) and (6.76) instead of (6.73) and (6.74), the same
computation evaluates the corresponding $u,c,d_{1},d_{2}$-sums of $S_{2}^{-}$
in (6.67) as

$\displaystyle\sum_{\begin{subarray}{c}u\mid\mathcal{Q}\\\
(u,h)=1\end{subarray}}\sum_{\begin{subarray}{c}c\mid P(z)\\\
(c,\mathcal{Q}h)=1\end{subarray}}\lambda_{c}^{-}\mu(c)\sum_{\begin{subarray}{c}d_{1},d_{2}\\\
p\mid d_{1}d_{2}\Leftrightarrow p\mid
uc\end{subarray}}\mu(d_{1})\mu(d_{2})\mathfrak{c}\Big{(}d_{1}d_{2}\frac{n}{h}m\Big{)}\prod_{p^{\nu}\parallel
d_{1}d_{2}}\mathfrak{f}_{2}(p,\nu;m,n)$ (6.80)
$\displaystyle=\mathfrak{c}\Big{(}\frac{n}{h}m\Big{)}\sum_{\begin{subarray}{c}u\mid\mathcal{Q}\\\
(u,h)=1\end{subarray}}\sum_{\begin{subarray}{c}c\mid P(z)\\\
(c,\mathcal{Q}h)=1\end{subarray}}\lambda_{c}^{-}\mu(c)\tilde{\mathfrak{f}}_{2}(2;m,n;u)\prod_{2\nmid
p\mid uc}(-2\mathfrak{w}(p,1;m,n,h)+\mathfrak{w}(p,2;m,n,h))$

where $\tilde{\mathfrak{f}}_{2}(2;m,n;u)$ is defined in the same way as
(6.79), replacing the index $1$ with the index 2. Combining the above
calculations, we have shown

$\begin{split}S_{1}^{-}+S_{2}^{-}=&\sum_{j=1}^{2}\sum_{\begin{subarray}{c}h\mid
n\\\ P^{+}(h)\leq y\\\
\mu^{2}(h)=(h,\mathfrak{N})=1\end{subarray}}\chi_{-4}(h)\sum_{\begin{subarray}{c}hm\leq
x\\\ P^{+}(m)\leq y\\\