Keywords

2010 Mathematics subject classification:

1 Introduction

In about 1900 Landau calculated the cardinality of sums of two squares in a long interval [1, x]. With \(\mathcal{S} =\{ n \in \mathbb{N}\mid n = a^{2} + b^{2}\}\) he proved in [3] the asymptotic formula

$$\displaystyle\begin{array}{rcl} \sum _{{ n\leq x \atop n\in \mathcal{S}} }1 = C \frac{x} {\sqrt{\log x}} + \mathcal{O}\left ( \frac{x} {(\log x)^{3/2}}\right ),& &{}\end{array}$$
(1.1)

where \(C:= \frac{1} {\sqrt{2}}\prod _{p\equiv 3(4)}(1 - p^{-2})^{-1/2}\).

It is possible to diversify the summation condition in a lot of ways. In this paper we want to consider the situation where each of the two squares is again a sum of two squares.

We define some notation. Let \(\tilde{\mathcal{S}}=\{ n \in \mathbb{N}\mid p\vert n \Rightarrow p\not\equiv 3(4)\} \subset \mathcal{S}\), and let

$$\displaystyle\begin{array}{rcl} R(n)& =& \#\{a,b \in \mathcal{S}\mid n = a^{2} + b^{2}\}, {}\\ \tilde{R}(n)& =& \#\{a,b \in \tilde{\mathcal{S}} \mid n = a^{2} + b^{2}\}. {}\\ \end{array}$$

Finally we write

$$\displaystyle\begin{array}{rcl} S_{i}(x) =\!\sum _{n\leq x}R(n)^{i}& & {}\\ \end{array}$$

for i​ = ​ 0, 1, 2 with the convention 00​ = ​ 0, and analogously

$$\displaystyle\begin{array}{rcl} \tilde{S}_{i}(x) =\sum _{n\leq x}\tilde{R} (n)^{i}.& & {}\\ \end{array}$$

Our aim is to estimate these quantities from above and below. We start with the following which can be obtained from (1.1) by partial summation.

Theorem 1.1

For x ≥ 3 we have the asymptotic formula

$$\displaystyle\begin{array}{rcl} S_{1}(x) = \frac{\pi } {4}\prod _{p\equiv 3(4)}(1 - p^{-2})^{-1}\frac{x} {\log x} + \mathcal{O}\Big( \frac{x} {(\log x)^{2}}\Big).& & {}\\ \end{array}$$

An analogous asymptotic formula (with a different constant) can be proved for \(\tilde{S}_{1}(x)\).

Our next aim is an upper bound for \(\tilde{S}_{2}(x)\). As a preparation we define the function

$$\displaystyle\begin{array}{rcl} \varphi _{s}(n):=\prod \limits _{p\vert n}\big(1 - p^{-s}\big).& &{}\end{array}$$
(1.2)

Then we prove the following

Theorem 1.2

Let q j , \(r_{j} \in \mathbb{Z}\) for j = 1,…,k with \(\mathcal{Q} =\prod \limits _{j}q_{j}\prod \limits _{i\neq j}\vert q_{i}r_{j} - q_{j}r_{i}\vert \neq 0\) . Then

$$\displaystyle\begin{array}{rcl} & & \#\{n \leq x\mid q_{j}n + r_{j} \in \tilde{\mathcal{S}} \ \forall j = 1,\ldots,k\} {}\\ \leq \frac{x} {(\log x)^{k/2}}& & \frac{\varGamma (k/2 + 1)2^{k}} {F^{k}(1)} \frac{1} {\varphi _{1}^{k}(\mathcal{Q})}\Bigg(1 + \mathcal{O}\Big(\Big( \frac{\log \mathcal{Q}} {\varphi _{1}^{k}(\mathcal{Q})} +\varphi _{ 1-\delta '}^{-2k}(\mathcal{Q})\Big)\frac{1} {\log x}\Big)\Bigg), {}\\ \end{array}$$

for a constant δ′ > 0 and F k (1) given by the convergent Euler product

$$\displaystyle\begin{array}{rcl} \prod \limits _{p}\Big(1 -\frac{\chi _{-4}(\,p)} {p} \Big)^{k/2}\prod \limits _{ p\equiv 3(4)}\Big(1 +\sum \limits _{ l=2}^{k}\tbinom{k}{l}p^{-l}\Big)\big(1 - p^{-2}\big)^{-k/2}.& & {}\\ \end{array}$$

This furnishes an upper bound for numbers such that k arithmetic progressions are not divisible by a prime congruent to 3 modulo 4.

To prove this theorem we use Selberg’s sieve which requires a calculation that is reminiscent of the Selberg-Delange method. Having this bound available, we will prove the following theorem.

Theorem 1.3

For x ≥ 3 we have the upper bound

$$\displaystyle\begin{array}{rcl} \tilde{S}_{2}(x) \ll \frac{x} {\log x}.& &{}\end{array}$$
(1.3)

We see that \(\tilde{S} _{1}(x)\) and \(\tilde{S} _{2}(x)\) have the same order of magnitude, thus with the Cauchy-Schwarz inequality we get a good lower bound for \(\tilde{S}_{0}(x)\). Furthermore we have the inequality \(\tilde{S} _{0}(x) \leq S_{0}(x)\), so we get a lower bound for S 0(x). This gives us our final result.

Theorem 1.4

For x ≥ 3 we have

$$\displaystyle\begin{array}{rcl} \frac{x} {\log x} \ll S_{0}(x) \leq C_{o}\frac{x} {\log x}\Big(1 + \mathcal{O}\Big(\frac{1} {\log x}\Big)\Big)& & {}\\ \end{array}$$

with \(C_{o} = \frac{\pi } {4}\prod \limits _{p\equiv 3(4)}(1 - p^{-2})^{-1}\) .

In other words, the number of sums of two squares of sums of two squares is of order of magnitude \(\frac{x} {\log x}\).

2 Useful Lemmas

First we will prove three lemmas which are useful to prove the theorems.

Lemma 2.1

For fixed \(n,m \in \mathbb{N}\) we get

$$\displaystyle{ -\int \limits _{0}^{\sqrt{x}} \frac{t} {\sqrt{\log t}^{m}} \frac{d} {dt}\Big( \frac{\sqrt{x - t^{2}}} {\sqrt{\log (x - t^{2 } )}^{n}}\Big)dt = \frac{\sqrt{2}^{m}\pi } {4} \frac{x} {\sqrt{\log x}^{n+m}}\Big(1 + \mathcal{O}\Big(\frac{1} {\log x}\Big)\Big). }$$

Proof

Let \(X = \frac{\sqrt{x}} {(\log x)^{(m+n+2)/2}}\). We consider the two integrals over [0, X] and \([X,\sqrt{x}]\) separately, and denote them by I e (x) and I m (x), respectively.

In the integrand of I e (x) the derivative is bounded by

$$\displaystyle\begin{array}{rcl} \frac{d} {dt}\Big( \frac{\sqrt{x - t^{2}}} {\sqrt{\log (x - t^{2 } )}^{n}}\Big) \ll \frac{X} {\sqrt{x - X^{2}}\sqrt{\log (x - X^{2 } )}^{n}} \ll \frac{X} {\sqrt{x - X^{2}}}.& & {}\\ \end{array}$$

Using this and the estimate \(\frac{t} {\sqrt{\log t}^{m}} \ll X\) we obtain

$$\displaystyle\begin{array}{rcl} I_{e}(x) \ll \int \limits _{0}^{X} \frac{X^{2}} {\sqrt{x - X^{2}}}dt \ll \frac{X^{3}} {\sqrt{x}} \ll \frac{x} {(\log x)^{(m+n+2)}}.& & {}\\ \end{array}$$

For the integrand of I m (x) we use Taylor’s formula around \(t = \sqrt{x}\)

$$\displaystyle\begin{array}{rcl} \frac{1} {\sqrt{\log t}^{m}} = \frac{\sqrt{2}^{m}} {\sqrt{\log x}^{m}} + \mathcal{O}\Big( \frac{t -\sqrt{x}} {\sqrt{x}\sqrt{\log x}^{m+2}}\Big).& & {}\\ \end{array}$$

For the integral over the error term we compute the derivative term and use trivial bounds for the factors

$$\displaystyle\begin{array}{rcl} \int \limits _{X}^{\sqrt{x} } \frac{(\sqrt{x} - t)t^{2}} {\sqrt{x - t^{2}}\sqrt{\log (x - t^{2 } )}^{n}}\vert n -\log (x - t^{2})^{-1}\vert dt \frac{1} {\sqrt{x}\sqrt{\log x}^{m+2}} \ll \frac{x} {\sqrt{\log x}^{m+n+2}}.& & {}\\ \end{array}$$

In the remaining integral for the main term \(\big(\frac{2} {\log x}\big)^{m/2}\) of Taylor’s formula we expand the lower bound to zero. With partial integration and the substitution y = xt 2 we get an integral similar to the one above, whence

$$\displaystyle\begin{array}{rcl} \int \limits _{X}^{\sqrt{x} }t \frac{d} {dt}\Big( \frac{\sqrt{x - t^{2}}} {\sqrt{\log (x - t^{2 } )}^{n}}\Big)dt =\int \limits _{ 0}^{x} \frac{\sqrt{y}} {2\sqrt{x - y}\sqrt{\log y}^{n}}dy + \mathcal{O}\Big( \frac{x} {\sqrt{\log x}^{n+2}}\Big).& & {}\\ \end{array}$$

We need to compute the integral. Again we split it into two parts [0, Z] and [Z, x] with \(Z = \frac{x} {(\log x)^{n/2+1}}\) and repeat the estimates to get

$$\displaystyle\begin{array}{rcl} \int \limits _{0}^{x} \frac{\sqrt{y}} {2\sqrt{x - y}\sqrt{\log y}^{n}}dy = \frac{1} {\sqrt{\log x}^{n}}\int _{0}^{x} \frac{\sqrt{y}} {2\sqrt{x - y}}dy\Big(1 + \mathcal{O}\Big(\frac{1} {\log x}\Big)\Big).& & {}\\ \end{array}$$

The remaining integral \(\int _{0}^{x} \frac{\sqrt{y}} {\sqrt{x-y}}dy\) can be computed exactly with the result \(\frac{x\pi } {2}\) and our claim follows.

Lemma 2.2

The map

$$\displaystyle\begin{array}{rcl} \{(k,l,m,n) \in \mathbb{N}^{4}\mid kl = mn\}& \longleftrightarrow & \{(s,t,u,v) \in \mathbb{N}^{4}\mid (s,u) = 1\}, {}\\ (k,l,m,n)& \longmapsto & \Big( \frac{k} {(k,m)},(k,m), \frac{m} {(k,m)}, \frac{n(k,m)} {k} \Big), {}\\ (st,uv,tu,sv)& \longmapsto & (s,t,u,v) {}\\ \end{array}$$

is a bijection.

The proof is straightforward.

Lemma 2.3

Let \(k \in \mathbb{N}\) and s > 1∕2. Then for x ≥ 3 we have

$$\displaystyle\begin{array}{rcl} \sum _{n\leq x} \frac{1} {n}\varphi _{s}^{-k}(n) \ll \log x.& & {}\\ \end{array}$$

Proof

The case s = 1 and k = 1 was proved by Landau (c.f. [2]). Note that 1(n) is Euler’s phi function.

The expression \(\frac{1} {\varphi _{s}(n)}\) can be rewritten as

$$\displaystyle\begin{array}{rcl} \frac{1} {\varphi _{s}(n)} =\prod _{p\vert n}\big(1 - \frac{1} {p^{s}}\big)^{-1} =\prod _{ p\vert n}\big(1 + \frac{1} {p^{s} - 1}\big) =\sum _{d\vert n} \frac{\mu ^{2}(d)} {d^{s}\varphi _{s}(d)}& & {}\\ \end{array}$$

where μ is the Möbius function. We insert this in our summation to get

$$\displaystyle\begin{array}{rcl} & & \sum _{n\leq x} \frac{1} {n}\varphi _{s}^{-k}(n) =\sum _{ n\leq x} \frac{1} {n}\Big(\sum _{d\vert n} \frac{\mu ^{2}(d)} {d^{s}\varphi _{s}(d)}\Big)^{k} {}\\ & & =\sum _{{ d_{j}\leq x \atop j=1,\ldots,k} } \frac{\mu ^{2}(d_{1})\cdots \mu ^{2}(d_{k})} {d_{1}^{s}\varphi _{s}(d_{1})\cdots d_{k}^{s}\varphi _{s}(d_{k})} \frac{1} {\mathop{\mathrm{lcm}}\nolimits _{i}(d_{i})}\sum _{m\leq \frac{x} {\mathop{\mathrm{lcm}}\nolimits _{i}(d_{i})} } \frac{1} {m} {}\\ \ll & &\sum _{{ d_{j}\leq x \atop j=1,\ldots,k} }\Big\vert \frac{\mu ^{2}(d_{1})\cdots \mu ^{2}(d_{k})} {d_{1}^{s}\varphi _{s}(d_{1})\cdots d_{k}^{s}\varphi _{s}(d_{k})}\Big\vert \frac{1} {\mathop{\mathrm{lcm}}\nolimits _{i}(d_{i})} \cdot \log x. {}\\ \end{array}$$

We complete the remaining sum into an infinite sum and see

$$\displaystyle\begin{array}{rcl} \sum _{{ d_{j}=1 \atop j=1,\ldots k} }^{\infty }\Big\vert \frac{\mu ^{2}(d_{ 1})\cdots \mu ^{2}(d_{ k})} {d_{1}^{s}\varphi _{s}(d_{1})\cdots d_{k}^{s}\varphi _{s}(d_{k})}\Big\vert \frac{1} {\mathop{\mathrm{lcm}}\nolimits _{i}(d_{i})} \ll \prod _{p}\Big(1 + \frac{1} {p(\,p^{s} - 1)}\Big)^{k}.& & {}\\ \end{array}$$

This product converges absolutely for s > 1∕2.

3 Numbers in \(\tilde{\mathcal{S}}\) in Arithmetic Progressions

In this section we prove Theorem 1.2. For simplification we assume k ≥ 2, since in the case k = 1 we can apply the proof of (1.1) with a different constant. In addition, if (q j , r j ) has a divisor which is congruent to 3 (mod 4) there are no solutions, hence the inequality is true. If (q j , r j ) has a prime divisor p ≡ 1 (mod 4), we can simply divide it out without changing the condition \(q_{j}n + r_{j} \in \tilde{\mathcal{S}}\). Hence we assume without loss of generality that (q j , r j ) = 1. We use Selberg’s sieve, c.f. [1, Theorem 6.4, p. 10]. Let

$$\displaystyle\begin{array}{rcl} \mathcal{P}& =& \prod _{{ p\equiv 3(4) \atop k<p\leq x} }p\qquad \text{ and } {}\\ Q(t)& =& (q_{1}t + r_{1})\ldots (q_{k}t + r_{k}). {}\\ \end{array}$$

Then the cardinality of \(\{n \leq x\mid (Q(n),\mathcal{P}) = 1\}\) is an upper bound for the quantity we want to bound.

Consider the function ρ(d) = #{a (mod d)∣Q(a) ≡ 0 (mod d)}. We see that ρ( p) ≤ min{k, p} for \(p\mid \mathcal{P}\). In particular it is ρ( p) = k if \((\,p,\mathcal{Q}) = 1\). By the Chinese remainder theorem, ρ is multiplicative. Hence we get

$$\displaystyle\begin{array}{rcl} \sum \limits _{{ n\leq x \atop d\mid Q(n)} }1 = \frac{x} {d}\rho (d) + \mathcal{O}(\tau _{k-1}(d)),& & {}\\ \end{array}$$

where τ k is the k-th iterated divisor function \(\sum _{a_{1}\cdots a_{k}=n}1\).

We define the multiplicative function g by \(g(\,p) = \frac{\rho (\,p)} {p-\rho (\,p)}\) for primes \(p\mid \mathcal{P}\), g( p) = 0 for \(p \nmid \mathcal{P}\) and g( p ν) = 0 for all p and all ν ≥ 2. For a parameter z to be chosen later let \(Z =\sum \limits _{d\leq z}g(d)\). Therefore by Selberg’s sieve

$$\displaystyle\begin{array}{rcl} \sum _{{ n\leq x \atop (Q(n),\mathcal{P})=1} }1 \leq \frac{x} {Z} + \mathcal{O}\bigg(\sum _{{ d\leq z^{2} \atop p\vert \mathcal{P}} }\tau _{3}(d)\tau _{k-1}(d)\bigg).& &{}\end{array}$$
(3.1)

Hence we need to find a lower bound for Z to get the information we want. Writing

$$\displaystyle\begin{array}{rcl} Z' =\sum _{d\leq z}\mu ^{2}(d)\prod _{{ { p\vert d \atop p\mid \mathcal{Q}} \atop p\equiv 3(4)} }g(\,p)\prod _{{ { p\vert d \atop p\nmid \mathcal{Q}} \atop p\equiv 3(4)} } \frac{\tau _{k-1}(\,p)} {p},& & {}\\ \end{array}$$

it is easy to see that Z ≥ Z′.

For the sum Z′ we use Perron’s formula to find a lower bound. It will be useful to use a refined version due to Liu and Ye [4]. Consider the Dirichlet series of Z′, given by the Euler product

$$\displaystyle\begin{array}{rcl} D(s):& =& \prod _{{ { p\mid \mathcal{Q} \atop p\equiv 3(4)} \atop p>k} }\Big(1 + \frac{g(\,p)} {p^{s}} \Big)\Big(1 + \frac{\tau _{k-1}(\,p)} {p^{s+1}} \Big)^{-1}\prod _{ p\equiv 3(4)}\Big(1 + \frac{\tau _{k-1}(\,p)} {p^{s+1}} \Big) {}\\ & =& D'(s) \cdot \zeta ^{k/2}(s + 1)L^{-k/2}(s + 1,\chi _{ -4})H(s), {}\\ \end{array}$$

where

$$\displaystyle\begin{array}{rcl} D'(s) =\prod _{{ { p\mid \mathcal{Q} \atop p\equiv 3(4)} \atop p>k} }\big(1 + \frac{g(\,p)} {p^{s}} \big)\big(1 + \frac{\tau _{k-1}(\,p)} {p^{s+1}} \big)^{-1}.& & {}\\ \end{array}$$

The function H(s) is holomorphic and nonzero in \(\mathrm{Re}\,s> -\frac{1} {2}\). The finite product D′(s) also is a holomorphic function and bounded by

$$\displaystyle\begin{array}{rcl} \varphi _{1+\mathrm{Re}\,s}^{2k}(\mathcal{Q}) \ll \left \vert D'(s)\right \vert \ll \frac{1} {\varphi _{1+\mathrm{Re}\,s}^{2k}(\mathcal{Q})},& & {}\\ \end{array}$$

where φ s is as in (1.2). Define F 2(s + 1) = ζ(s + 1)L −1(s + 1, χ −4)H 2∕k(s)s, then F is holomorphic in the zero-free region of the L-function as in [6, II §5.4] and we get D(s) = F k(s + 1)s k∕2 D′(s).

Let 2 ≤ T < z be a parameter which we choose later. For the error terms in Perron’s formula we need to bound the quantity

$$\displaystyle\begin{array}{rcl} \sum _{\vert z-n\vert \leq \frac{z} {\sqrt{T}} }g(n)& \ll & \sum _{\vert z-n\vert \leq \frac{z} {\sqrt{T}} }\mu ^{2}(n)\tau _{ k-1}(n)\prod _{{ p\vert n \atop k<p,p\mid \mathcal{Q}} } \frac{1} {p - k}\prod _{{ p\vert n \atop p\nmid \mathcal{Q}} }\frac{1} {p} {}\\ & \ll & \ \varphi _{1}^{-k}(\mathcal{Q})\sum _{ \vert z-n\vert \leq \frac{z} {\sqrt{T}} }\mu ^{2}(n)\frac{\tau _{k-1}(n)} {n} \ll \varphi _{1}^{-k}(\mathcal{Q})\frac{(\log (z))^{k-2}} {\sqrt{T}}. {}\\ \end{array}$$

The last bound follows by [5, Theorem 2]. The second part of the error term is given by

$$\displaystyle\begin{array}{rcl} \frac{z^{b}B(b)} {\sqrt{T}} & \ll & \frac{z^{b}} {\sqrt{T}}\sum _{n}\frac{\vert g(n)\vert } {n^{b}} \ll \frac{\zeta ^{k}(1 + \frac{1} {\log z})} {\sqrt{T}} {}\\ & \ll & \frac{(\log z)^{k}} {\sqrt{T}}, {}\\ \end{array}$$

where we choose \(b = \frac{1} {\log z}\).

By applying Perron’s formula in the version of [4, Corollary 2.2] we get

$$\displaystyle\begin{array}{rcl} Z' = \frac{1} {2\pi i}\int \limits _{\frac{1} {\log z}-iT}^{\frac{1} {\log z}+iT}\frac{F^{k}(s + 1)} {s^{k/2}} D'(s)z^{s}\frac{ds} {s} + \mathcal{O}\Big(\varphi _{1}^{-k}(\mathcal{Q})\frac{(\log (z))^{k-2}} {\sqrt{T}} + \frac{(\log z)^{k}} {\sqrt{T}} \Big).& &{}\end{array}$$
(3.2)

Now we integrate over the same contour as in Tenenbaum [6, II §5.4] but shifted to zero, so that the order of the singularity at 0 is \(\frac{k} {2} + 1\).

We split the contour into various pieces

$$\displaystyle\begin{array}{rcl} \gamma _{1},\gamma _{7}& =& \Big[c \mp iT,- \frac{\delta } {2\log (2 + T)} \mp iT\Big], {}\\ \gamma _{2},\gamma _{6}& =& - \frac{\delta } {2\log (2 + \vert t\vert )} + it,\text{for }t \in [-T,0],t \in [0,T], {}\\ \gamma _{4}& =& \partial B_{r}(0), {}\\ \gamma _{3}& =& \Big[- \frac{\delta } {2\log 2},-r\Big], {}\\ \gamma _{5}& =& \Big[-r,- \frac{\delta } {2\log 2}\Big], {}\\ \end{array}$$

with \(r = \frac{1} {\log z}\) and δ > 0 is chosen so small that

$$\displaystyle\begin{array}{rcl} \frac{1} {L(s,\chi _{-4})} \ll \log \vert t\vert,\qquad \zeta (s) \ll \log \vert t\vert,& & {}\\ \end{array}$$

for \(\sigma> 1 - \frac{\delta } {2\log (2+\vert t\vert )}\) (see [6, p. 262]).

For the parts γ i with i = 1, 2, 6, 7 an upper bound for D′(s) is given by the function \(\varphi _{1-\delta '}^{-2k}(\mathcal{Q})\) with \(\delta ' = \frac{\delta } {2\log 2}\). We get for γ 1 and analogously for γ 7 the bound

$$\displaystyle{ \begin{array}{rl} &\int \limits _{\gamma _{1}} \frac{F^{k}(s+1)} {s^{k/2}} D'(s)z^{s}\frac{ds} {s} \ll \frac{(\log T)^{k}} {\varphi _{1-\delta '}^{2k}(\mathcal{Q})}\int \limits _{- \frac{\delta } {2\log (2+T)} }^{ \frac{1} {\log z} }z^{\sigma } \frac{d\sigma } {T} \\ \ll &\ \varphi _{1-\delta '}^{-2k}(\mathcal{Q})\frac{(\log T)^{k}} {T} \int \limits _{- \frac{\delta } {2\log (2+T)} }^{ \frac{1} {\log z} }z^{\sigma }d\sigma \ll \ \varphi _{1-\delta '}^{-2k}(\mathcal{Q})\frac{(\log T)^{k}} {T}. \end{array} }$$
(3.3)

For the parts γ 2 and γ 6 the bound is given by

$$\displaystyle{ \begin{array}{rl} &\int \limits _{\gamma _{2}} \frac{F^{k}(s+1)} {s^{k/2}} D'(s)z^{s}\frac{ds} {s} \\ \ll \ &\varphi _{1-\delta '}^{-2k}(\mathcal{Q})(\log T)^{k}z^{-\delta /(2\log T)}\int \limits _{0}^{T}\big\vert \frac{\delta }{2\log T} - it\big\vert ^{-1}dt \\ \ll \ &\varphi _{1-\delta '}^{-2k}(\mathcal{Q})z^{-\delta /(2\log T)}\frac{2(\log T)^{1+k}} {\delta }. \end{array} }$$
(3.4)

We choose \(T =\exp ( \frac{\delta }{2}\sqrt{\log z})\) to optimize the error term composed from (3.2), (3.3) and (3.4).

By writing Υ′ = γ 3 γ 4 γ 5 for the contribution not yet considered we get with the bounds from (3.2), (3.3) and (3.4) the asymptotic formula

$$\displaystyle\begin{array}{rcl} Z' = \frac{1} {2\pi i}\int \limits _{\varUpsilon '}\frac{F^{k}(s + 1)} {s^{k/2}} D'(s)z^{s}\frac{ds} {s} + \mathcal{O}\bigg(\big(\varphi _{1-\delta '}^{-2k}(\mathcal{Q}) +\varphi _{ 1}^{-k}(\mathcal{Q})\big) \frac{(\log z)^{k}} {\exp (\delta \sqrt{\log z})}\bigg).& &{}\end{array}$$
(3.5)

The remaining integral does not have an explicit solution, but by using the Taylor expansion

$$\displaystyle\begin{array}{rcl} F^{k}(s + 1)D'(s) = F^{k}(1)D'(0) + \mathcal{O}\Big(\varphi _{ 1}^{-k}(\mathcal{Q})\log \mathcal{Q}\cdot \vert s\vert \Big)& & {}\\ \end{array}$$

we obtain

$$\displaystyle\begin{array}{rcl} & & \quad \Big\vert \frac{1} {2\pi i}\int \limits _{\varUpsilon '}\frac{F^{k}(s + 1)} {s^{k/2}} D'(s)z^{s}\frac{ds} {s} \Big\vert {}\\ & &\geq \ \varphi _{1}^{k}(\mathcal{Q})F^{k}(1)\Big\vert \frac{1} {2\pi i}\int \limits _{\varUpsilon '}s^{-k/2}z^{s}\frac{ds} {s} \Big\vert + \mathcal{O}\Big(\varphi _{1}^{k}(\mathcal{Q})\log \mathcal{Q}\Big\vert \int \limits _{\varUpsilon '} \frac{\vert s\vert } {s^{k/2}}z^{s}\frac{ds} {s} \Big\vert \Big) = I_{h}(z) + I_{e}(z). {}\\ \end{array}$$

The product D′(0) is bounded from below by \(\varphi _{1}^{k}(\mathcal{Q})\). Now we change I h (z) by the substitution \(s = \frac{w} {\log z}\) into the form of Theorem 5.2 from [6, II §5.2]. Let Υ be the resulting contour from Υ′. Applying Corollary 2.1 of [6, II §5.2], for Hankel’s contour we get

$$\displaystyle\begin{array}{rcl} I_{h}(z)& \geq & F^{k}(1)\varphi _{ 1}^{k}(\mathcal{Q})(\log z)^{k/2}\Big\vert \frac{1} {2\pi i}\int \limits _{\varUpsilon }e^{w}w^{-(k/2+1)}dw\Big\vert {}\\ & =& F^{k}(1)\varphi _{ 1}^{k}(\mathcal{Q})(\log z)^{k/2}\Big( \frac{1} {\varGamma (k/2 + 1)} + \mathcal{O}(z^{-\nu })\Big), {}\\ \end{array}$$

for some ν > 0.

To compute the integral I e (z) we use trivial bounds on the circle and on the lines separately to get \(I_{e} \ll \varphi _{1}^{-k}(\mathcal{Q})\log \mathcal{Q}(\log z)^{k/2-1}\). Combining the obtained results we get a lower bound for Z′ and hence for Z. The error terms from Perron’s formula and from the other pieces of the contour (3.5) combine with I e (x) to give

$$\displaystyle{ \begin{array}{rl} &\varphi _{1}^{-k}(\mathcal{Q})\log \mathcal{Q}(\log z)^{k/2-1} +\big (\varphi _{1-\delta '}^{-2k}(\mathcal{Q}) +\varphi _{ 1}^{-k}(\mathcal{Q})\big) \frac{(\log z)^{k}} {\exp (\delta \sqrt{\log z})} \\ \ll \ &\big(\varphi _{1}^{-k}(\mathcal{Q})\log \mathcal{Q} +\varphi _{ 1-\delta '}^{-2k}(\mathcal{Q})\big)(\log z)^{k/2-1}. \end{array} }$$
(3.6)

The error terms in Eqs. (3.1) and (3.6) are optimized by choosing \(z = \frac{x^{1/2}} {(\log x)^{d}}\) with \(d = \frac{1} {2}(\frac{k} {2} + 1 + 3^{k})\) and we get

$$\displaystyle{ \begin{array}{rl} &\#\{n \leq x\mid q_{j}n + r_{j} \in \tilde{\mathcal{S}}\ \forall j = 1,\ldots,k\} \\ \leq \ & \frac{x} {(\log x)^{k/2}} \frac{\varGamma (k/2+1)2^{k/2}} {F^{k}(1)} \frac{1} {\varphi _{1}^{k}(\mathcal{Q})}\Big(1 + \mathcal{O}\Big(\Big( \frac{\log \mathcal{Q}} {\varphi _{1}^{k}(\mathcal{Q})} +\varphi _{ 1-\delta '}^{-2k}(\mathcal{Q})\Big)\frac{1} {\log x}\Big)\Big). \end{array} }$$
(3.7)

4 Proof of Theorem 1.1

In this section we find an asymptotic formula for S 1(x).

Let r 0(n) be the characteristic function on the numbers that can be written as a sum of two squares. By rewriting the sum in terms of r 0(n) and (1.1) we get

$$\displaystyle\begin{array}{rcl} S_{1}(x) =\sum _{a\leq \sqrt{x}}r_{0}(a)C\frac{\sqrt{2}\sqrt{x - a^{2}}} {\sqrt{\log (x - a^{2 } )}} \Big(1 + \mathcal{O}\big((\log (x - a^{2}))^{-1}\big)\Big).& & {}\\ \end{array}$$

By applying partial summation and once more (1.1) we get the integrals

$$\displaystyle\begin{array}{rcl} S_{1}(x)& =& -C^{2}\sqrt{2}\int \limits _{ 0}^{\sqrt{x}} \frac{t} {\sqrt{\log t}} \frac{d} {dt}\Big( \frac{\sqrt{x - t^{2}}} {\sqrt{\log (x - t^{2 } )}}\Big)dt {}\\ & & +\sum _{n\leq \sqrt{x}}\!r_{0}(n)\lim \limits _{a\rightarrow \sqrt{x}} \frac{\sqrt{x - a^{2}}} {\sqrt{\log (x - a^{2 } )}}\big(1 + \frac{1} {\log (x - a^{2})}\big) {}\\ & & +\mathcal{O}\Bigg(\int \limits _{0}^{\sqrt{x}} \frac{t} {\sqrt{\log t}^{3}} \frac{d} {dt}\Big( \frac{\sqrt{x - t^{2}}} {\sqrt{\log (x - t^{2 } )}}\Big)dt +\int \limits _{ 0}^{\sqrt{x}} \frac{t} {\sqrt{\log t}} \frac{d} {dt}\Big( \frac{\sqrt{x - t^{2}}} {\sqrt{\log (x - t^{2 } )}^{3}}\Big)dt\Bigg) {}\\ & =:& M(x) + 0 + E(x). {}\\ \end{array}$$

The boundary expression vanishes since \(\lim \limits _{ a\rightarrow \sqrt{x}} \frac{\sqrt{x-a^{2}}} {\sqrt{\log (x-a^{2 } )}}\big(1 + (\log (x - a^{2}))^{-1}\big) = 0\). With Lemma 2.1 at our disposal the computation of M(x) and E(x) is simple.

For M(x) we have m = n = 1 and hence

$$\displaystyle\begin{array}{rcl} M(x) = C^{2}\sqrt{2}\frac{\sqrt{2}\pi } {4} \frac{x} {\log x} + \mathcal{O}\Big( \frac{x} {(\log x)^{2}}\Big).& & {}\\ \end{array}$$

The error term E(x) has two integrals, where in the first one we have m = 3, n = 1 and in the second one m = 1, n = 3. Since Lemma 2.1 is symmetric in n and m it yields \(E(x) \ll \frac{x} {(\log x)^{2}}\).

Combining these two terms we conclude that

$$\displaystyle\begin{array}{rcl} S_{1}(x) = C^{2} \frac{\pi } {2} \frac{x} {\log x} + \mathcal{O}\Big( \frac{x} {(\log x)^{2}}\Big).& &{}\end{array}$$
(4.1)

The asymptotic formula for \(\tilde{S} _{1}(x)\) is almost the same as S 1(x), and for x ≥ 3 we get

$$\displaystyle\begin{array}{rcl} \tilde{S}_{1}(x) = \frac{\pi } {4}\prod _{p\equiv 3(4)}(1 - p^{-2})\frac{x} {\log x} + \mathcal{O}\Big( \frac{x} {(\log x)^{2}}\Big).& & {}\\ \end{array}$$

5 Proof of Theorem 1.3

The upper bound of \(\tilde{S} _{2}(x)\) requires a bit more work. Opening the square we have

$$\displaystyle\begin{array}{rcl} \tilde{S}_{2}(x) =\sum _{{ a,b,c,d\in \tilde{\mathcal{S}} \atop a^{2}+b^{2}=c^{2}+d^{2}\leq x} }1.& & {}\\ \end{array}$$

We need to understand the summation condition a 2 + b 2 = c 2 + d 2. The diagonal term is \(\tilde{S} _{1}(x)\) which we have bound above. Hence we can assume that {a, b} ≠ {c, d} and the condition a 2 + b 2 = c 2 + d 2 is equivalent to (a + d)(ad) = (c + b)(cb). Using Lemma 2.2 this can be rewritten with \(s,t,u,v \in \mathbb{N}\) with (s, u) = 1 as

$$\displaystyle\begin{array}{rcl} a + d = st,\quad a - d = uv,\quad c + b = tu,\quad c - b = sv.& & {}\\ \end{array}$$

Without loss of generality we can assume that a > b and c > d, then the condition \(a,b,c,d \in \tilde{\mathcal{S}}\) changes to st + uv, stuv, ut + sv, \(ut - sv \in \tilde{\mathcal{S}}\). It follows that

$$\displaystyle\begin{array}{rcl} \tilde{S}_{2}(x) \leq \sum _{{ st,uv,ut,sv\leq 2\sqrt{x} \atop st\pm uv,ut\pm sv\in \tilde{\mathcal{S}}} }1.& & {}\\ \end{array}$$

Now we want to apply Theorem 1.2. We fix u, t, v and think of s as our variable. In accordance with Theorem 1.2, we define \(\mathcal{Q} = tv(t - v)(t + v)(t^{2} + v^{2})\).

In the case t = v our conditions imply that t(s ± u) > 0 and t(u ± s) > 0 which is obviously impossible.

In the following let tv, so that \(\mathcal{Q}\neq 0\). Isolating the sum over s we get

$$\displaystyle\begin{array}{rcl} \sum _{{ st,uv,ut,sv\leq 2\sqrt{x} \atop st\pm uv,ut\pm sv\in \tilde{\mathcal{S}}} }1 =\sum _{tu,uv\leq 2\sqrt{x}}\sum _{{ s\leq \min \{\frac{ut} {v},\frac{2\sqrt{x}} {t},\frac{2\sqrt{x}} {v} \} \atop st\pm uv,ut\pm sv\in \tilde{\mathcal{S}}} }1.& & {}\\ \end{array}$$

We use Theorem 1.2 to calculate the inner sum, and obtain

$$\displaystyle\begin{array}{rcl} \sum _{{ s\leq \min \{\frac{ut} {v},\frac{2\sqrt{x}} {t},\frac{2\sqrt{x}} {v} \} \atop st\pm uv,ut\pm sv\in \tilde{\mathcal{S}}} }1 \ll \frac{ut} {v} \frac{1} {(\log \frac{ut} {v} )^{2}} \frac{1} {\varphi _{1}^{4}(\mathcal{Q})}\Big(1 +\Big ( \frac{\log \mathcal{Q}} {\varphi _{1}^{4}(\mathcal{Q})} +\varphi _{ 1-\delta '}^{-8}(\mathcal{Q})\Big) \frac{1} {\log \frac{ut} {v} }\Big),& & {}\\ \end{array}$$

with δ′ defined in Sect. 3. For the sum over t, u, v we get the condition v < t, since \(\frac{uv} {t} <\frac{ut} {v}\). Furthermore in the term \(\varphi _{1}^{4}(\mathcal{Q})\) we split the product \(\mathcal{Q}\). To this end a short look at the definition shows that φ s (nm) ≥ φ s (n)φ s (m) and with the Hölder inequality it follows that

$$\displaystyle{ \begin{array}{rl} &\sum _{{ uv<ut \atop ut<2\sqrt{x}} }\frac{ut} {v} \frac{1} {(\log \frac{ut} {v} )^{2}} \Big( \frac{1} {\varphi _{1}(t)} \frac{1} {\varphi _{1}(v)} \frac{1} {\varphi _{1}(t-v)} \frac{1} {\varphi _{1}(t+v)} \frac{1} {\varphi _{1}(t^{2}+v^{2})}\Big)^{4} \\ & \ll \Big (\sum _{{ uv<ut \atop ut<2\sqrt{x}} }\frac{ut} {v} \frac{1} {(\log \frac{ut} {v} )^{2}} \frac{1} {\varphi _{1}^{20}(v)}\Big)^{4/5}\Big(\sum _{{ u<2\sqrt{x} \atop n<\frac{2x} {u^{2}}} } \frac{u} {(\log u)^{2}} \frac{r(n)} {\varphi _{1}^{20}(n)}\Big)^{1/5}, \end{array} }$$
(5.1)

where r(n) counts the number of solutions a 2 + b 2 = n.

First we compute the sum over v and use \((\log \frac{ut} {v} )^{-2} <(\log u)^{-2}\). Using Lemma 2.3 to compute the remaining sum over v we get

$$\displaystyle\begin{array}{rcl} \sum _{ut\leq 2\sqrt{x}}\sum _{v\leq t}\frac{ut} {v} \frac{1} {(\log u)^{2}} \frac{1} {\varphi _{1}^{4}(v)} \ll \sum _{ut\leq 2\sqrt{x}} \frac{u} {(\log u)^{2}}t\log t.& & {}\\ \end{array}$$

With partial integration we get for the sum over tlogt the upper bound

$$\displaystyle\begin{array}{rcl} \sum _{t\leq \frac{2\sqrt{x}} {u} }t\log t \ll \frac{x} {u^{2}}\Big(\log \frac{2\sqrt{x}} {u} - 1\Big).& & {}\\ \end{array}$$

There remains the sum over u for which once again we use partial summation. We obtain

$$\displaystyle\begin{array}{rcl} \sum _{u\leq 2\sqrt{x}} \frac{1} {u(\log u)^{2}}\log \frac{2\sqrt{x}} {u} \ll \frac{1} {\log x}.& & {}\\ \end{array}$$

Hence the first factor of (5.1) is computed.

Using r(n) =  d | n χ −4(d) the second factor of (5.1) can be transformed similarly as in Lemma 2.3 and it follows that

$$\displaystyle\begin{array}{rcl} \sum _{n\leq \frac{2x} {u^{2}} } \frac{r(n)} {\varphi _{1}^{20}(n)} \ll \frac{x} {u^{2}}.& & {}\\ \end{array}$$

And the sum over u can be computed as above to get

$$\displaystyle\begin{array}{rcl} \sum _{{ u<2\sqrt{x} \atop n<2 \frac{x} {u^{2}}} } \frac{u} {(\log u)^{2}} \frac{r(n)} {\varphi _{1}^{20}(n)} \ll \frac{x} {\log x}.& & {}\\ \end{array}$$

Combining these two results we get

$$\displaystyle\begin{array}{rcl} \sum _{{ uv<ut \atop ut<2\sqrt{x}} }\frac{ut} {v} \frac{1} {(\log \frac{ut} {v} )^{2}} \frac{1} {\varphi _{1}^{4}(\mathcal{Q})} \ll \frac{x} {\log x}.& & {}\\ \end{array}$$

For the sums over \(\frac{\log \mathcal{Q}} {\varphi _{1}^{4}(\mathcal{Q})}\) and \(\varphi _{1-\delta '}^{-8}(\mathcal{Q})\) the argument is the same and it follows in the same way that

$$\displaystyle\begin{array}{rcl} \sum _{uv<ut<2\sqrt{x}}\frac{ut} {v} \frac{1} {(\log \frac{ut} {v} )^{3}} \frac{\log \mathcal{Q}} {\varphi _{1}^{8}(\mathcal{Q})} \ll \sum _{uv<ut<2\sqrt{x}}\frac{ut} {v} \frac{1} {(\log \frac{ut} {v} )^{3}} \frac{\log t} {\varphi _{1}^{8}(\mathcal{Q})} \ll \frac{x} {\log x}& & {}\\ \end{array}$$

and

$$\displaystyle\begin{array}{rcl} \sum _{uv<ut<2\sqrt{x}}\frac{ut} {v} \frac{1} {(\log \frac{ut} {v} )^{3}}\varphi _{1-\delta '}^{-8}(\mathcal{Q})\varphi _{ 1}^{-4}(\mathcal{Q}) \ll \frac{x} {(\log x)^{2}}.& & {}\\ \end{array}$$

Combining these two results we get the final bound

$$\displaystyle\begin{array}{rcl} \tilde{S}_{2}(x) \ll \frac{x} {\log x}.& & {}\\ \end{array}$$

6 Final Result

Theorem 1.4 is now a consequence of the Cauchy-Schwarz inequality. We have

$$\displaystyle{ \tilde{S}_{1}(x) \leq \Big (\sum _{n\leq x}\tilde{R} (n)^{0}\Big)^{1/2}\Big(\sum _{ n\leq x}\tilde{R} (n)^{2}\Big)^{1/2} = \tilde{S} _{ 0}(x)^{1/2}\tilde{S} _{ 2}(x)^{1/2}. }$$

Thus

$$\displaystyle\begin{array}{rcl} S_{0}(x) \geq \tilde{S} _{0}(x) \geq \frac{\tilde{S} _{1}^{2}(x)} {\tilde{S} _{2}(x)}.& & {}\\ \end{array}$$

By replacing \(\tilde{S} _{2}(x)\) with (1.3) and \(\tilde{S} _{1}(x)\) with (4.1) we get the lower bound stated in Theorem 1.4.

On the other hand we have S 0(x) ≤ S 1(x), which yields the upper bound.