# Mean values of multiplicative functions and applications to the distribution
of the sum of divisors

Akash Singha Roy  Department of Mathematics
University of Georgia
Athens, GA 30602<EMAIL_ADDRESS>
###### Abstract.

We provide uniform bounds on mean values of multiplicative functions under
very general hypotheses, detecting certain power savings missed in known
results in the literature. As an application, we study the distribution of the
sum-of-divisors function $\sigma(n)$ in coprime residue classes to moduli
$q\leq(\log x)^{K}$, obtaining extensions of results of Śliwa that are uniform
in a wide range of $q$ and optimal in various parameters. As a consequence of
our results, we obtain that the values of $\sigma(n)$ sampled over $n\leq x$
with $\sigma(n)$ coprime to $q$ are asymptotically equidistributed among the
coprime residue classes mod $q$, uniformly for odd $q\leq(\log x)^{K}$. On the
other hand, if $q$ is even, then equidistribution is restored provided we
restrict to inputs $n$ having sufficiently many prime divisors exceeding $q$.

###### Key words and phrases:

multiplicative function, mean values, equidistribution, uniform distribution,
weak equidistribution, weak uniform distribution, sum of divisors

###### 2020 Mathematics Subject Classification:

Primary 11A25; Secondary 11N36, 11N37, 11N64, 11N69

##  1\. Introduction

Mean values of multiplicative functions have been a central topic of interest
in analytic number theory. There is already a rich variety of literature on
this subject, with the classical result of Halász [9] (see [20, Corollary
III.4.12] for a precise version) providing a widely applicable general bound
on the partial sums of any multiplicative function taking values in the
(complex) unit disk, and with the analytic method of Landau–Selberg–Delange
(see [20, Chapter II.5]) providing a highly precise asymptotic formula for the
partial sums of multiplicative functions whose Dirichlet series behave like
powers of the Riemann zeta function. However in applications, situations arise
where Halász’s bound turns out to not be precise enough, while the
Landau–Selberg–Delange method despite being applicable leads to additional
error terms that become too large to yield useful information. Such situations
occur, for instance, while studying the distribution of values of
multiplicative functions in residue classes.

In an attempt to address this issue, in recent joint work with Pollack [14],
we gave an upper bound on the partial sum of a multiplicative function taking
values in the unit disk, under some natural control on the average behavior of
this function at the primes. Using this result, we studied the distribution of
the values of the Alladi-Erdős function $A(n)\coloneqq\sum_{p^{k}\parallel
n}k\cdot p$ and Euler’s totient function $\varphi(n)\coloneqq\\#\\{1\leq d\leq
n:~{}\gcd(d,n)=1\\}$ in residue classes to moduli varying uniformly in a wide
range. Our results extended those of Goldfeld [8] and Narkiewicz [12] (who
studied the corresponding questions for fixed moduli) and had error terms that
(for concrete heuristic reasons) could be expected to be essentially optimal.
A related function occurring commonly in number theory is the sum-of-divisors
function $\sigma(n)\coloneqq\sum_{d\mid n}d$, and Śliwa [19] studies the
distribution of the values of this function among the coprime residue classes
to a fixed modulus $q$, obtaining a necessary and sufficient criterion for
$\sigma(n)$ to be equidistributed among the coprime residue classes mod $q$.
Our methods in [14], however, are unable to obtain a complete uniform version
of Śliwa’s results, primarily because they are unable to detect the necessary
power savings in certain naturally-arising character sums. Motivated by this
problem, our first main result in this manuscript is one which provides a
variant of Theorem 1.1 in [14] that can detect certain power savings missed in
the referred result, and in fact also enables us to obtain a uniform version
of Śliwa’s result.

In what follows, $\pi(y)$ denotes (as usual) the number of primes up to $y$,
and $\mathbb{U}$ denotes the unit disk in the complex plane, namely, the set
$\\{s\in\mathbb{C}:|s|\leq 1\\}$. For a given real number $z$, we say that a
positive integer $n$ is $z$-smooth if it has no prime factor exceeding $z$.
The number of $z$-smooth numbers up to $x$ is denoted by $\Psi(x,z)$, a
quantity which has been studied extensively in the literature.

######  Theorem 1.1.

Let $f\colon\mathbb{N}\rightarrow\mathbb{U}$ be a multiplicative function and
$x,y,z,M$ be positive real numbers such that $M\geq 1$, $1<z<x$ and
$e^{11/2}\leq y\leq z^{1/(18\log\log z)^{2}}$. Assume that there exists a
complex number $\varrho\in\mathbb{U}$ such that for all $Y\geq y$,

(1) $\sum_{y<p\leq Y}f(p)=\varrho(\pi(Y)-\pi(y))+O(MY\mathcal{E}(y)),$

for some decreasing function
$\mathcal{E}\colon\mathbb{R}^{+}\rightarrow\mathbb{R}^{+}$ satisfying
$\lim_{X\rightarrow\infty}\mathcal{E}(X)=0$. Then

$\sum_{n\leq x}f(n)\ll\frac{|\varrho|x}{\log z}\left(\frac{\log z}{\log
y}\right)^{\mathrm{Re}(\varrho)}\exp\left(\sum_{p\leq
y}\frac{|f(p)|}{p}\right)\\\ +~{}\frac{x(\log y)^{1+|\varrho|}}{(\log
z)^{2-\mathrm{Re}(\varrho)}}\exp\left(\sum_{p\leq
y}\frac{|f(p)|}{p}\right)+\Psi(x,z)+Mx(\log
x)^{2}\left(\mathcal{E}(y)+\frac{1}{y}\right),$

where the implied constant depends at most on the implied constant in (1).

A few comments are in order. In applications, the terms involving $\Psi(x,z)$,
$\mathcal{E}(y)$ and $1/y$ often become very small, so the usefulness of the
bounds is dictated by the sizes of the first two terms. The crucial difference
between this bound and the one in Theorem 1.1 of [14] is the factor $(\log
z)^{\mathrm{Re}(\varrho)}$ in the first expression, whose analogue in [14,
Theorem 1.1] contained the larger factor $(\log x)^{|\varrho|}$. These greater
savings turn out to play a significant role in certain applications. However,
our bound above cannot entirely subsume [14, Theorem 1.1] because the
additional term with $(\log y)^{1+|\varrho|}$ (which has no analogue in [14,
Theorem 1.1]) can limit the applicability of our bound. We shall witness these
phenomena in our applications (see the remark following the proof of
Proposition 5.4).

Both Theorem 1.1 and the arguments used to prove it can be applied to study
the asymptotic distribution of multiplicative functions like the sum-of-
divisors function $\sigma(n)$ in coprime residue classes to moduli varying
uniformly in a wide range. Following Narkiewicz [12], we say that an integer-
valued arithmetic function $g$ is weakly uniformly distributed (or weakly
equidistributed) modulo $q$ if $\gcd(g(n),q)=1$ for infinitely many $n$ and,
for every _coprime_ residue class $a\bmod{q}$,

(2) $\\#\\{n\leq x:g(n)\equiv a\pmod{q}\\}\sim\frac{1}{\varphi(q)}{\\#\\{n\leq
x:\gcd(g(n),q)=1\\}},\quad\text{as $x\to\infty$}.$

In [12, Theorem I], Narkiewicz gives a criterion for deciding weak
equidistribution in a large class of multiplicative functions. As an
application, we can show that $\sigma(n)$ is weakly equidistributed mod $q$
for any $q$ coprime to $6$. This result was extended by Śliwa [19] (see also
[13, Proposition 7.9, p. 106]), who showed that $\sigma(n)$ is weakly
equidistributed to a fixed modulus $q$ precisely when $q$ is not divisible by
$6$.

As a natural analogue of the Siegel-Walfisz theorem for primes in arithmetic
progressions, it seems of some interest to investigate analogues of these
results where the modulus $q$ itself is allowed to vary uniformly in a certain
range depending on the stopping point $x$ of inputs. To formalize this, we say
that an integer-valued arithmetic function $g(n)$ is weakly equidistributed
mod $q$, uniformly for $q\leq(\log x)^{K}$, if:

  1. (i)

For every such $q$, $g(n)$ is coprime to $q$ for infinitely many $n$, and

  2. (ii)

The relation (2) holds uniformly in moduli $q\leq(\log x)^{K}$ and in coprime
residue classes $a$ mod $q$. Explicitly, this means that for any $\epsilon>0$,
there exists $X(\epsilon)>0$ such that the ratio of the left hand side of (2)
to the right hand side lies in $(1-\epsilon,1+\epsilon)$ for all
$x>X(\epsilon)$, $q\leq(\log x)^{K}$ and coprime residues $a$ mod $q$.

The weak equidistribution of certain classes of arithmetic functions to
uniformly varying moduli was investigated in [10, 15, 16]. A general theorem
established in [16] yields the weak equidistribution of $\sigma(n)$ uniformly
to moduli $q\leq(\log x)^{K}$ coprime to $6$. However, the methods in [16] are
unable to address the case when $q$ is even but not divisible by $6$ (a case
in which Śliwa is able to show that $\sigma(n)$ is weakly equdistributed mod
$q$). Moreover, the error terms that arise from the arguments in [16] are
quite weak. Our next three theorems address these defects. We first establish
an effective estimate demonstrating the weak equidistribution of $\sigma(n)$
to odd moduli $q\leq(\log x)^{K}$ and obtain a strong error term that can be
expected to be (essentially) of the correct order of magnitude.

######  Theorem 1.2.

Fix $K>0$ and $\epsilon\in(0,1)$. We have

$\\#\\{n\leq x:\sigma(n)\equiv a\pmod{q}\\}\\\
=\frac{1}{\varphi(q)}\\#\\{n\leq
x:\gcd(\sigma(n),q)=1\\}+O_{K,\epsilon}\left(\frac{x}{\varphi(q)(\log
x)^{1-\alpha(q)(1/3+\epsilon)}}\right),$

uniformly in odd moduli $q\leq(\log x)^{K}$ and coprime residue classes $a$
mod $q$, where $\alpha(q)\coloneqq\prod_{\ell\mid
q}\left(1-\frac{1}{\ell-1}\right)$. As a consequence, $\sigma(n)$ is weakly
equidistributed mod $q$, uniformly for odd moduli $q\leq(\log x)^{K}$.

To obtain uniform analogues of Śliwa’s results, we still need to address the
case when the modulus $q$ is even. Here, the first crucial difference with the
above theorem is that while studying the weak equidistribution of $\sigma(n)$
to even moduli, the set of relevant inputs $n\leq x$ is highly sparse. In
fact, elementary number theory shows that if $\sigma(n)$ is odd, then $n$ must
be of the form $2^{k}m^{2}$ for some odd $m$, which means that there are
$O(x^{1/2})$ many $n\leq x$ which have $\sigma(n)$ coprime to a given even
modulus $q$. Sparse sets like this can often present difficulties while
studying arithmetic questions about them. However, we can work around this
sparsity issue by looking at the behaviour of $\sigma(n)$ at the squares of
primes.

Another crucial difference between the situations for odd and even moduli is
that in the latter case, the positive integers $n$ with too few large prime
factors present an obstruction to uniformity in the modulus. As such, in order
to restore uniformity in the modulus $q$, it becomes necessary to restrict the
set of inputs $n$ to those having sufficiently many prime factors exceeding
$q$. To make this precise, we write $P(n)$ or $P^{+}(n)$ for the largest prime
divisor of $n$, with the convention that $P(1)=1$. We set $P_{1}(n)\coloneqq
P(n)$ and define, inductively, $P_{k}(n)\coloneqq P_{k-1}(n/P(n))$. Thus,
$P_{k}(n)$ is the $k$th largest prime factor of $n$ (counted with
multiplicity), with $P_{k}(n)=1$ if $\Omega(n)<k$.

In what follows, we set

$\widetilde{\alpha}(q)\coloneqq\frac{1}{\varphi(q)}\\#\\{v\bmod
q:\gcd(v(v^{2}+v+1),q)=1\\}=\prod_{\begin{subarray}{c}\ell\mid q\\\ \ell\equiv
1\pmod{3}\end{subarray}}\left(1-\frac{2}{\ell-1}\right),$

the last equality being true by the Chinese Remainder Theorem and the law of
quadratic reciprocity.

######  Theorem 1.3.

Fix $K>0$ and $\epsilon\in(0,1)$. We have

(3) $\\#\\{n\leq x:P_{6}(n)>q,~{}\sigma(n)\equiv a\pmod{q}\\}\\\
=\frac{1}{\varphi(q)}\\#\\{n\leq
x:P_{6}(n)>q,~{}\gcd(\sigma(n),q)=1\\}+O_{K,\epsilon}\left(\frac{x^{1/2}}{\varphi(q)(\log
x)^{1-\widetilde{\alpha}(q)(1/4+\epsilon)}}\right),$

uniformly in even moduli $q\leq(\log x)^{K}$ not divisible by $3$, and in
coprime residues $a$ mod $q$.

In subsection 6.1, we give an explicit counterexample showing that the
restriction $P_{6}(n)>q$ is optimal in the sense that it cannot be replaced by
a condition of the form “$P_{k}(n)>q$” with $k<6$, while still retainining
weak equidistribution among the corresponding set of $n$’s in the same range
of uniformity in $q$. In fact, we will show that uniformity fails to moduli
$q$ of the form $2Q^{2}$ for certain odd squarefree integers $Q$ having
several prime factors. While the proof of Theorem 1.3 relies heavily on bounds
on certain character sums modulo prime powers, the aforementioned
counterexample works due to an excess in the number of lifts of solutions to a
polynomial congruence from prime moduli to prime square moduli.

On the other hand, if we restrict our moduli $q$ to be squarefree even
integers, then we may enlarge the set of inputs $n$ to those having four (as
opposed to six) prime divisors exceeding $q$.

######  Theorem 1.4.

Fix $K>0$ and $\epsilon\in(0,1)$. We have

(4) $\\#\\{n\leq x:P_{4}(n)>q,~{}\sigma(n)\equiv a\pmod{q}\\}\\\
=\frac{1}{\varphi(q)}\\#\\{n\leq
x:P_{4}(n)>q,~{}\gcd(\sigma(n),q)=1\\}+O_{K,\epsilon}\left(\frac{x^{1/2}}{\varphi(q)(\log
x)^{1-\widetilde{\alpha}(q)(1/4+\epsilon)}}\right),$

uniformly in squarefree even moduli $q\leq(\log x)^{K}$ not divisible by $3$,
and in coprime residue classes $a$ mod $q$.

In subsection 7.1, we show that the restriction $P_{4}(n)>q$ is optimal for
squarefree even $q$ in the same sense as mentioned above. The constants
“$1/3$” (respectively, “$1/4$”) in the exponent of $\log x$ in the error terms
of Theorem 1.2 (resp., Theorems 1.3 and 1.4), arise as the maximum real part
of the averages

$\rho_{\chi}\coloneqq\frac{1}{\varphi(q)}\sum_{\begin{subarray}{c}v\bmod q\\\
\gcd(v,q)=1\end{subarray}}~{}\chi(v+1)~{}~{}~{}\text{ \Bigg{(}resp.
}\eta_{\chi}\coloneqq\frac{1}{\varphi(q)}\sum_{\begin{subarray}{c}v\bmod q\\\
\gcd(v,q)=1\end{subarray}}~{}\chi(v^{2}+v+1)\text{\Bigg{)}}$

taken over the nonprincipal Dirichlet characters $\chi$ mod $q$. These
averages play the roles of the parameter $\varrho$ in the corresponding
analogues of Theorem 1.1, when the role of the multiplicative function $f$ is
played by the functions $\chi\circ\sigma$ that arise by applying the
orthogonality of Dirichlet characters to detect the congruence
$\sigma(n)\equiv a\pmod{q}$. As we shall see in the course of our arguments,
the maximum values of $\mathrm{Re}(\rho_{\chi})$ (resp.
$\mathrm{Re}(\eta_{\chi})$) can be attained by characters $\chi$ of conductor
$15$ (resp. conductors $5$, $7$, $13$, $35$), in the case when $q$ is
divisible by the respective conductors (see the remarks at the end of the
proofs of Theorem 1.2 and Proposition 5.1). This suggests (but does not prove)
that the constants “$1/3$” and “$1/4$” in the error terms of Theorems 1.2, 1.3
and 1.4 cannot be replaced by smaller constants in general.

We conclude this introductory section with the remark that precise estimates
for the main terms in Theorems 1.2, 1.3 and 1.4 can be obtained from Theorems
A and B in work of Scourfield [18] (see [17] and [15, Proposition 2.1] for
similar results). Finally, in the course of our arguments, we shall obtain
sharp upper bounds for the character sums $\chi(\sigma(n))$ for nontrivial
Dirichlet characters $\chi$ to our moduli $q$. In the range $q\leq(\log
x)^{K}$, these can be thought of as improved analogues of work of Balasuriya,
Shparlinski and Sutantyo [3]. Related work on exponential sums involving
$\sigma(n)$ has been (implicitly) done in [4] and [5], while [2] and [1]
investigate the corresponding sums for the aliquot-divisor-sum function
$s(n)\coloneqq\sigma(n)-n=\sum_{d\mid n\colon d\neq n}d$.

### Notation and conventions:

We do not consider the zero function as multiplicative (thus, if $f$ is
multiplicative, then $f(1)=1$). As mentioned above, we shall use $P^{+}(n)$ or
$P(n)$ to denote the largest prime divisor of $n$, and $P_{k}(n)$ for the
$k$-th largest prime factor of $n$. In addition, we denote the least prime
divisor of $n$ by $P^{-}(n)$. When there is no danger of confusion, we write
$(a,b)$ instead of $\gcd(a,b)$. Throughout, the letters $p$ and $\ell$ are to
be understood as denoting primes. Implied constants in $\ll$ and $O$-notation
may always depend on any parameters declared as “fixed”; other dependence will
be noted explicitly (for example, with subscripts). We write $\log_{k}$ for
the $k$th iterate of the natural logarithm. We shall use $U_{q}$ to denote the
group of units (or the multiplicative group) modulo a positive integer $q$.

##  2\. Uniform bounds on the partial sums of multiplicative functions: Proof
of Theorem 1.1

Our arguments for Theorems 1.1 and 1.2 begin similarly to those given for [14,
Theorems 1.1 and 1.3], but we include the complete argument here in order to
keep the exposition self-contained. We first bound the contribution of the
$n\leq x$ that are either $z$-smooth or have a repeated prime factor exceeding
$y$. Since $|f(n)|\leq 1$, the contribution of the former $n$ is bounded in
absolute value by $\Psi(x,z)$, while that of the latter $n$ is bounded in
absolute value by

$\sum_{p>y}\sum_{\begin{subarray}{c}n\leq x\\\ p^{2}\mid n\end{subarray}}1\leq
x\sum_{p>y}\frac{1}{p^{2}}\ll\frac{x}{y}.$

Both of these are absorbed in the expressions given in the claimed bounds.

Let $\sum\nolimits_{n\leq x}^{*}f(n)$ denote the sum over the remaining $n$,
namely those that have $P^{+}(n)>z$ and no repeated prime factor exceeding
$y$. Any $n$ counted in this sum can be uniquely written in the form
$mP_{j}\cdots P_{1}$ for some $j\geq 1$, where $P_{1}=P^{+}(n)>z$ and
$P^{+}(m)\leq y<P_{j}<\dots<P_{1}$. As such $f(n)=f(m)f(P_{j})\cdots f(P_{1})$
and

$\displaystyle\allowdisplaybreaks\sum\nolimits_{n\leq x}^{*}f(n)$
$\displaystyle=\sum_{j\geq 1}\sum_{\begin{subarray}{c}m\leq x\\\ P^{+}(m)\leq
y\end{subarray}}f(m)\sum_{\begin{subarray}{c}P_{1},\dots,P_{j}\\\
P_{1}>z,~{}P_{j}\cdots P_{1}\leq x/m\\\
y<P_{j}<\dots<P_{1}\end{subarray}}f(P_{j})\cdots f(P_{1})$
$\displaystyle=\sum_{j\geq 1}\sum_{\begin{subarray}{c}m\leq x\\\ P^{+}(m)\leq
y\end{subarray}}f(m)\sum_{\begin{subarray}{c}P_{2},\dots,P_{j}\\\ \
P_{j}\cdots P_{2}\leq x/mz\\\ y<P_{j}<\dots<P_{2}\\\
\end{subarray}}f(P_{j})\cdots f(P_{2})\sum_{\max\\{P_{2},z\\}<P_{1}\leq
x/mP_{2}\cdots P_{j}}f(P_{1}).$

Here $\max\\{P_{2},z\\}$ is to be replaced by $z$ in the case $j=1$.

Invoking hypothesis (1) to estimate the innermost sum on $P_{1}$, we find that

(5) $\begin{split}\sum\nolimits_{n\leq x}^{*}f(n)=\varrho\sum_{j\geq
1}\frac{1}{(j-1)!}\sum_{\begin{subarray}{c}m\leq x\\\ P^{+}(m)\leq
y\end{subarray}}f(m)\sum_{z<P_{1}\leq
x/my^{j-1}}\sum_{\begin{subarray}{c}P_{2},\dots,P_{j}\in(y,P_{1})\\\
P_{2},\dots,P_{j}\text{ distinct}\\\ P_{2}\cdots P_{j}\leq
x/mP_{1}\end{subarray}}&f(P_{2})\cdots f(P_{j})\\\ &+O(Mx\mathcal{E}(y)\log
x),\end{split}$

where we have observed that the total size of the resulting error term
incurred upon an application of (1) is

$\ll Mx\mathcal{E}(y)\sum_{j\geq
1}\sum_{\begin{subarray}{c}m,P_{2},\dots,P_{j}\\\ mP_{2}\cdots P_{j}\leq
x/z\\\ P^{+}(m)\leq y<P_{j}<\dots<P_{2}\end{subarray}}\frac{1}{mP_{2}\cdots
P_{j}}\leq Mx\mathcal{E}(y)\sum_{n\leq x/z}\frac{1}{n}\ll Mx\mathcal{E}(y)\log
x.$

Now for $j\geq 2$ and each $i\in\\{2,\dots,j\\}$, estimate (1) shows that

(6) $\begin{split}\sum_{\begin{subarray}{c}y<P_{i}\leq x/mP_{1}\cdots
P_{i-1}P_{i+1}\cdots P_{j}\\\ P_{i}<P_{1},~{}r\neq i\implies P_{r}\neq
P_{i}\end{subarray}}f(P_{i})&=\sum_{\begin{subarray}{c}y<P_{i}\leq
x/mP_{1}\cdots P_{i-1}P_{i+1}\cdots P_{j}\\\
P_{i}<P_{1}\end{subarray}}f(P_{i})+O(j)\\\
&=\varrho\sum_{\begin{subarray}{c}y<P_{i}\leq x/mP_{1}\cdots
P_{i-1}P_{i+1}\cdots P_{j}\\\ P_{i}<P_{1},~{}r\neq i\implies P_{r}\neq
P_{i}\end{subarray}}1+O\left(j+\frac{Mx}{mP_{1}\cdots P_{i-1}P_{i+1}\cdots
P_{j}}\mathcal{E}(y)\right).\end{split}$

For each $j\geq 2$, we use this estimate for $i\in\\{2,\dots,j\\}$ in order to
successively remove the $f(P_{2}),\dots,f(P_{j})$ occurring in the main term
of (5). To this end, we define

$\widetilde{\mathcal{E}}\coloneqq
j\sum_{\begin{subarray}{c}P_{2},\dots,P_{j-1}\in(y,P_{1})\\\
P_{2},\dots,P_{j-1}\text{ distinct}\\\ P_{2}\cdots P_{j-1}\leq
x/myP_{1}\end{subarray}}1+\frac{Mx\mathcal{E}(y)}{mP_{1}}\sum_{\begin{subarray}{c}P_{2},\dots,P_{j-1}\in(y,P_{1})\\\
P_{2},\dots,P_{j-1}\text{ distinct}\\\ P_{2}\cdots P_{j-1}\leq
x/myP_{1}\end{subarray}}\frac{1}{P_{2}\cdots P_{j-1}},$

and write

$\displaystyle\sum_{\begin{subarray}{c}P_{2},\dots,P_{j}\in(y,P_{1})\\\
P_{2},\dots,P_{j}\text{ distinct}\\\ P_{2}\cdots P_{j}\leq
x/mP_{1}\end{subarray}}f(P_{2})\cdots f(P_{j})$
$\displaystyle=\sum_{\begin{subarray}{c}P_{3},\dots,P_{j}\in(y,P_{1})\\\
P_{3},\dots,P_{j}\text{ distinct}\\\ P_{3}\cdots P_{j}\leq
x/myP_{1}\end{subarray}}f(P_{3})\cdots
f(P_{j})\sum_{\begin{subarray}{c}y<P_{2}\leq x/mP_{1}P_{3}\cdots P_{j}\\\
P_{2}<P_{1},~{}r\neq 2\implies P_{2}\neq P_{r}\end{subarray}}f(P_{2})$
$\displaystyle=\varrho\sum_{\begin{subarray}{c}P_{2},\dots,P_{j}\in(y,P_{1})\\\
P_{2},\dots,P_{j}\text{ distinct}\\\ P_{2}\cdots P_{j}\leq
x/mP_{1}\end{subarray}}f(P_{3})\cdots f(P_{j})+O(\widetilde{\mathcal{E}}),$

where in the last step we have noted that the error term resulting from the
application of (6) for $i=2$ is, by relabelling, equal to
$\widetilde{\mathcal{E}}$. Likewise, invoking (6) for $i=3,\dots,j$, we obtain

$\sum_{\begin{subarray}{c}P_{2},\dots,P_{j}\in(y,P_{1})\\\
P_{2},\dots,P_{j}\text{ distinct}\\\ P_{2}\cdots P_{j}\leq
x/mP_{1}\end{subarray}}f(P_{2})\cdots
f(P_{j})=\varrho^{j-1}\sum_{\begin{subarray}{c}P_{2},\dots,P_{j}\in(y,P_{1})\\\
P_{2},\dots,P_{j}\text{ distinct}\\\ P_{2}\cdots P_{j}\leq
x/mP_{1}\end{subarray}}1+O(j\widetilde{\mathcal{E}}).$

Inserting this into (5) for each $j\geq 2$ incurs a total error of size

$\displaystyle\ll\sum_{j\geq 2}\frac{1}{(j-1)!}\sum_{\begin{subarray}{c}m\leq
x\\\ P^{+}(m)\leq
y\end{subarray}}\sum_{z<P_{1}\leq\frac{x}{my^{j-1}}}\Bigg{\\{}j^{2}\sum_{\begin{subarray}{c}P_{2},\dots,P_{j-1}\in(y,P_{1})\\\
P_{2},\dots,P_{j-1}\text{ distinct}\\\ P_{2}\cdots P_{j-1}\leq
x/myP_{1}\end{subarray}}1+\frac{Mxj\mathcal{E}(y)}{mP_{1}}\sum_{\begin{subarray}{c}P_{2},\dots,P_{j-1}\in(y,P_{1})\\\
P_{2},\dots,P_{j-1}\text{ distinct}\\\ P_{2}\cdots P_{j-1}\leq
x/myP_{1}\end{subarray}}\frac{1}{P_{2}\cdots P_{j-1}}\Bigg{\\}}$
$\displaystyle\ll(\log x)^{2}\sum_{j\geq
2}\sum_{\begin{subarray}{c}m,P_{1},\dots,P_{j-1}\\\ mP_{1}\cdots P_{j-1}\leq
x/y\\\ P_{1}>z,~{}P^{+}(m)\leq
y<P_{j-1}<\dots<P_{1}\end{subarray}}1~{}+~{}Mx(\log
x)\mathcal{E}(y)\sum_{\begin{subarray}{c}m,P_{1},\dots,P_{j-1}\\\ mP_{1}\cdots
P_{j-1}\leq x/y\\\ P_{1}>z,~{}P^{+}(m)\leq
y<P_{j-1}<\dots<P_{1}\end{subarray}}\frac{1}{mP_{1}\cdots P_{j-1}}$
$\displaystyle\ll(\log x)^{2}\sum_{n\leq x/y}1~{}+~{}Mx(\log
x)\mathcal{E}(y)\sum_{n\leq x/y}\frac{1}{n}\ll Mx(\log
x)^{2}\left(\mathcal{E}(y)+\frac{1}{y}\right).$

As a consequence, we obtain

(7) $\begin{split}\sum\nolimits_{n\leq x}^{*}f(n)&=\varrho\sum_{j\geq
1}\frac{\varrho^{j-1}}{(j-1)!}\sum_{\begin{subarray}{c}m\leq x\\\ P^{+}(m)\leq
y\end{subarray}}f(m)\sum_{\begin{subarray}{c}P_{1},\dots,P_{j}\\\
P_{1}>z,~{}P_{1}\cdots P_{j}\leq x/m\\\ P_{2}\cdots P_{j}\in(y,P_{1})\text{
distinct}\end{subarray}}1+O\left(Mx(\log
x)^{2}\left(\mathcal{E}(y)+\frac{1}{y}\right)\right)\\\
&=\sum_{\begin{subarray}{c}m\leq x/z\\\ P^{+}(m)\leq
y\end{subarray}}f(m)\sum_{j\geq
1}\sum_{\begin{subarray}{c}P_{1},\dots,P_{j}\\\ P_{1}>z,~{}P_{1}\cdots
P_{j}\leq x/m\\\
y<P_{j}<\dots<P_{1}\end{subarray}}\varrho^{j}~{}+~{}O\left(Mx(\log
x)^{2}\left(\mathcal{E}(y)+\frac{1}{y}\right)\right).\end{split}$

At this point, we observe that every squarefree positive integer $r\leq x/m$
having $P^{+}(r)>z$ and $P^{-}(r)>y$ can be uniquely written in the form
$P_{j}\cdots P_{1}$ with $P_{1}>z$ and $y<P_{j}<\dots<P_{1}$, and in this case
$j=\Omega(r)$. As such, the main term in the final expression in (7) is equal
to

(8) $\sum_{\begin{subarray}{c}m\leq x/z\\\ P^{+}(m)\leq
y\end{subarray}}f(m)\sum_{\begin{subarray}{c}r\leq x/m\\\ r\text{
squarefree}\\\ P^{+}(r)>z,~{}P^{-}(r)>y\end{subarray}}\varrho^{\Omega(r)}~{}.$

Ignoring the condition $P^{+}(r)>z$ incurs a total error of size

$\ll\sum_{\begin{subarray}{c}m\leq x/z\\\ P^{+}(m)\leq
y\end{subarray}}~{}~{}\sum_{\begin{subarray}{c}r\leq x/m\\\
P^{-}(r)>y,\,P^{+}(r)\leq z\end{subarray}}1\leq\sum_{\begin{subarray}{c}n\leq
x\\\ P^{+}(n)\leq z\end{subarray}}1\leq\Psi(x,z),$

which is absorbed in the bound claimed in the theorem statement. Moreover,
since any non-squarefree $r$ having $P^{-}(r)>y$ is divisible by the square of
a prime exceeding $y$, ignoring the squarefreeness condition in (8) incurs a
total error

$\ll\sum_{\begin{subarray}{c}m\leq x/z\\\ P^{+}(m)\leq
y\end{subarray}}~{}\sum_{p>y}~{}\sum_{\begin{subarray}{c}r\leq x/m\\\
p^{2}\mid r\end{subarray}}1\ll x\sum_{\begin{subarray}{c}m\leq x/z\\\
P^{+}(m)\leq
y\end{subarray}}\frac{1}{m}\sum_{p>y}\frac{1}{p^{2}}\ll\frac{x}{y\log
y}\prod_{\ell\leq y}\left(1+\sum_{v\geq
1}\frac{1}{\ell^{v}}\right)\ll\frac{x}{y},$

which is also absorbed in the claimed bound. Hence, up to a negligible error,
the expression in (8) is equal to

(9) $\sum_{\begin{subarray}{c}m\leq x/z\\\ P^{+}(m)\leq
y\end{subarray}}f(m)\sum_{r\leq
x/m}\mathbbm{1}_{P^{-}(r)>y}~{}\varrho^{\Omega(r)}.$

In order to estimate the innermost sum, we shall be making use of the lemma
below, which we will establish in the next section.

######  Lemma 2.1.

Let $X,Y,Z\geq e^{11/2}$ be positive real numbers satisfying $Y\leq
Z^{1/(18\log\log Z)^{2}}$ and $Z\leq X$. We have for all $\beta\in\mathbb{U}$,

$\sum_{n\leq X}\mathbbm{1}_{P^{-}(n)>Y}~{}\beta^{\Omega(n)}=\frac{X}{(\log
X)^{1-\beta}}\left\\{\frac{e^{-\gamma\beta}}{\Gamma(\beta)(\log
Y)^{\beta}}\left(1+O(\exp(-C_{0}\sqrt{\log y}))\right)+O\left(\frac{(\log
Y)^{1+|\beta|}}{\log Z}\right)\right\\},$

where $C_{0}>0$ is an absolute constant. In particular,

$\sum_{n\leq X}\mathbbm{1}_{P^{-}(n)>Y}~{}\beta^{\Omega(n)}\ll\frac{X}{(\log
X)^{1-\mathrm{Re}(\beta)}}\left\\{\frac{|\beta|}{(\log
Y)^{\mathrm{Re}(\beta)}}+\frac{(\log Y)^{1+|\beta|}}{\log Z}\right\\}.$

The implied constants in the above estimates are absolute.

Applying the above lemma with $X\coloneqq x/m$, $Y\coloneqq y$, $Z\coloneqq z$
and $\beta\coloneqq\varrho$, we find that the expression in (9) is

$\displaystyle\ll\sum_{\begin{subarray}{c}m\leq x/z\\\ P^{+}(m)\leq
y\end{subarray}}|f(m)|\cdot\frac{x/m}{(\log(x/m))^{1-\mathrm{Re}(\varrho)}}\left\\{\frac{|\varrho|}{(\log
y)^{\mathrm{Re}(\varrho)}}+\frac{(\log y)^{1+|\varrho|}}{\log z}\right\\}$
$\displaystyle\ll\frac{x}{(\log
z)^{1-\mathrm{Re}(\varrho)}}\left(\sum_{m:\,P^{+}(m)\leq
y}\frac{|f(m)|}{m}\right)\left\\{\frac{|\varrho|}{(\log
y)^{\mathrm{Re}(\varrho)}}+\frac{(\log y)^{1+|\varrho|}}{\log z}\right\\}.$

Finally, since $|f(n)|\leq 1$ for all $n$, the sum on $m$ is
$\ll\exp(\sum_{p\leq y}|f(p)|/p)$, yielding the estimate in the theorem. This
completes the proof of Theorem 1.1, up to the proof of Lemma 2.1.

##  3\. Proof of Lemma 2.1: the Landau–Selberg–Delange method

A comprehensive account of the method of Landau–Selberg–Delange may be found
in Tenenbaum [20, Chapter II.5]. However, we shall be using a recent
formulation of this method due to Chang and Martin [6]. This is based on
Tenenbaum’s treatment but is more explicit in the dependence on certain
parameters, a feature that shall be crucial in our current application.

###  3.1. Setup

In what follows, we write complex numbers $s$ as $s=\sigma+it$, where
$\sigma\coloneqq\mathrm{Re}(s)$ and $t\coloneqq\mathrm{Im}(s)$. (This
convention is relevant only for this section and the use of $\sigma$ will not
create any confusion with the notation for the sum-of-divisors function.) For
a non-negative $u$, we use $\log^{+}{u}$ to denote the quantity
$\max\\{0,\log{u}\\}$ (the positive part of $\log u$), with the convention
that $\log^{+}{0}=0$.

Given $\delta\in(0,1]$, a complex number $z$, and positive real numbers
$c_{0}$ and $M$, we say that the Dirichlet series $F(s)$ has property
$\mathcal{P}(z;c_{0},\delta,M)$ if the function

$G(s;z):=F(s)\zeta(s)^{-z}$

satisfies the following two conditions:

  1. (i)

$G(s;z)$ continues analytically into the region $\sigma\geq
1-c_{0}/(1+\log^{+}|t|)$, and

  2. (ii)

$|G(s;z)|\leq M(1+|t|)^{1-\delta}$ for all $s$ in this same region.

Given complex numbers $z$ and $w$, along with positive numbers $c_{0}$, $M$
and $\delta\in(0,1]$, we say that a Dirichlet series
$F(s):=\sum_{n=1}^{\infty}a_{n}n^{-s}$ has type
$\mathcal{T}(z,w;c_{0},\delta,M)$ if:

  1. (i)

$F(s)$ has property $\mathcal{P}(z;c_{0},\delta,M)$, and

  2. (ii)

there is a sequence $\\{b_{n}\\}_{n=1}^{\infty}$ of nonnegative real numbers
satisfying $|a_{n}|\leq b_{n}$ for all $n$, such that the Dirichlet series
$\sum_{n=1}^{\infty}b_{n}n^{-s}$ has property $\mathcal{P}(w;c_{0},\delta,M)$.

The following is the special case of Theorem A.13 in [6] with $N=0$.

######  Proposition 3.1.

Fix $A\geq 1$ and let $z,w$ be complex numbers satisfying $|z|,|w|\leq A$. Let
$c_{0},\delta,M$ be positive real numbers with $c_{0}\leq 2/11$ and
$\delta\leq 1$. Let $F(s)=\sum_{n=1}^{\infty}a_{n}/n^{s}$ be a Dirichlet
series of type $\mathcal{T}(z,w;c_{0},\delta,M)$. Then, uniformly for
$x\geq\exp(8^{1/A}\max\\{\delta^{-1-1/A},2/c_{0}\\})$, we have

$\sum_{n\leq
x}a_{n}=\frac{x}{(\log{x})^{1-z}}\left(\frac{G(1;z)}{\Gamma(z)}+O(MR(x))\right),$

where

$R(x)=\left(\frac{1}{\delta^{2A+3/2}}+\frac{1}{c_{0}^{2A+1}}\right)\exp\left(-\frac{1}{6}\sqrt{c_{0}\delta\log{x}}\right)+\frac{1}{c_{0}\log{x}}$

and the implied constant depends at most on $A$.

Here we have corrected some typos in [6]; the expression for $R(x)$ there has
an extra factor of $M$ throughout as well as an extra factor of $x$ in its
first term.

###  3.2. Proof of Lemma 2.1.

We claim that the Dirichlet series $F(s)\coloneqq\sum_{n\geq
1}\mathbbm{1}_{P^{-}(n)>Y}~{}\beta^{\Omega(n)}/n^{s}$ is of type
$\mathcal{T}(\beta,|\beta|;1/\log Y,1,C_{0}(\log Y)^{|\beta|})$ for some
absolute constant $C_{0}>0$. Indeed, in the half plane $\sigma>1$, we find
that

(10) $G(s)\coloneqq F(s)\zeta(s)^{-\beta}=\prod_{p\leq
Y}\left(1-\frac{1}{p^{s}}\right)^{\beta}\prod_{p>Y}\left(1-\frac{1}{p^{s}}\right)^{\beta}\left(1-\frac{\beta}{p^{s}}\right)^{-1},$

and in the same half plane

(11) $\log G(s)=\beta\sum_{p\leq
Y}\log\left(1-\frac{1}{p^{s}}\right)+\sum_{p>Y}\left\\{\beta\log\left(1-\frac{1}{p^{s}}\right)-\log\left(1-\frac{\beta}{p^{s}}\right)\right\\}.$

Now since $Y\geq e^{11/2}$, we see that if $\sigma\geq 1-1/\log Y$, then
$\sigma\geq 9/11$, so that $|\beta/p^{s}|\leq 2^{-\sigma}\leq 0.57$.
Consequently for all such $s$, the second sum in (11) is

$\sum_{p>Y}\left\\{\beta\left(-\frac{1}{p^{s}}+O\left(\frac{1}{p^{2\sigma}}\right)\right)+\left(\frac{\beta}{p^{s}}+O\left(\frac{1}{p^{2\sigma}}\right)\right)\right\\}\ll\sum_{p>Y}\frac{1}{p^{2\sigma}}\leq\sum_{p>Y}\frac{1}{p^{18/11}}\ll
1.$

This shows that the second sum in (11) converges absolutely and uniformly in
the half plane $\sigma\geq 1-1/\log Y$, thus defining a holomorphic function
in the same region. Furthermore, for all $s$ in this half plane, we have

$\displaystyle\log|G(s)|\leq|\log G(s)|$ $\displaystyle\leq|\beta|\sum_{p\leq
Y}\frac{1}{p^{\sigma}}+O(1)\leq|\beta|\sum_{p\leq
Y}\frac{1}{p}\exp\left(\frac{\log p}{\log Y}\right)+O(1)$
$\displaystyle=|\beta|\sum_{p\leq Y}\frac{1}{p}+O\left(1+\frac{1}{\log
Y}\sum_{p\leq Y}\frac{\log p}{p}\right)=|\beta|\log_{2}Y+O(1).$

We deduce that $|G(s)|\leq C_{0}(\log Y)^{|\beta|}$ for all $\sigma\geq
1-1/\log Y$, which shows that $F(s)$ has property $\mathcal{P}(\beta;1/\log
Y,1,C_{0}(\log Y)^{|\beta|})$. By invoking this very observation with
$|\beta|$ in place of $\beta$, we find that the Dirichlet series $\sum_{n\geq
1}|\beta|^{\Omega(n)}/n^{s}$ has property $\mathcal{P}(|\beta|;1/\log
Y,1,C_{0}(\log Y)^{|\beta|})$, which establishes our claim.

An application of Proposition 3.1 with $A=1$ now shows that for all $X\geq
Y^{16}=\exp(16\log Y)$, we have

$\sum_{n\leq X}\mathbbm{1}_{P^{-}(n)>Y}\beta^{\Omega(n)}=\frac{X}{(\log
X)^{1-\beta}}\left\\{\frac{G(1)}{\Gamma(\beta)}+O\left(\frac{(\log
Y)^{1+|\beta|}}{\log X}+(\log
Y)^{3+|\beta|}\exp\left(-\frac{1}{6}\sqrt{\frac{\log X}{\log
Y}}\right)\right)\right\\}.$

For $Y\leq Z^{1/(18\log_{2}Z)^{2}}$, we have $2\log_{2}Y+\log_{2}Z\leq
3\log_{2}Z\leq\frac{1}{6}\sqrt{\frac{\log Z}{\log Y}}$, which shows that

(12) $\sum_{n\leq X}\mathbbm{1}_{P^{-}(n)>Y}\beta^{\Omega(n)}=\frac{X}{(\log
X)^{1-\beta}}\left\\{\frac{G(1)}{\Gamma(\beta)}+O\left(\frac{(\log
Y)^{1+|\beta|}}{\log Z}\right)\right\\}.$

Finally,

$\sum_{p>Y}\left\\{\beta\log\left(1-\frac{1}{p}\right)-\log\left(1-\frac{\beta}{p}\right)\right\\}\ll\sum_{p>Y}\frac{1}{p^{2}}\ll\frac{1}{Y\log
Y},$

and by the prime number theorem (with the usual de la Vallée Poussin error
term), we have

$\prod_{p\leq
Y}\left(1-\frac{1}{p}\right)^{\beta}=\frac{e^{-\gamma\beta}}{(\log
Y)^{\beta}}\left(1+O(\exp(-C_{0}\sqrt{\log Y}))\right),$

for some absolute constant $C_{0}>0$. This shows that

$G(1)=\prod_{p\leq
Y}\left(1-\frac{1}{p}\right)^{\beta}\prod_{p>Y}\left(1-\frac{1}{p}\right)^{\beta}\left(1-\frac{\beta}{p}\right)^{-1}=\frac{e^{-\gamma\beta}}{(\log
Y)^{\beta}}\left(1+O(\exp(-C_{0}\sqrt{\log Y}))\right)$

which from (12) yields the first of the claimed estimates in Lemma 2.1. Since
the Gamma function has no zeros in the complex plane, we have $|\Gamma(s)|\gg
1$ for all $s$ in a fixed compact region. As a consequence,
$\beta\Gamma(\beta)=\Gamma(1+\beta)\gg 1$ for all $|\beta|\leq 1$, yielding
the second assertion of the lemma.

##  4\. Distribution of the sum-of-divisors to odd moduli: Proof of Theorem
1.2

In the rest of this section, we abbreviate $\alpha(q)$ to $\alpha$. We shall
make frequent use of the fact that $\alpha=\prod_{\ell\mid q}(1-1/(\ell-1))\gg
1/\log_{2}(3q)$ for all odd $q$. The following proposition allows us to give a
rough estimate on the count of $n\leq x$ for which $\sigma(n)$ is coprime to
$q$, uniformly in odd moduli $q\leq(\log x)^{K}$.

######  Proposition 4.1.

Fix $K>0$ and a multiplicative function $f$ for which there exists a non-
constant polynomial $F\in\mathbb{Z}[T]$ satisfying $f(p)=F(p)$ for all primes
$p$. If $x$ is sufficiently large and $q\leq(\log{x})^{K}$ with
$\alpha_{F}(q)\coloneqq\frac{1}{\varphi(q)}\\#\\{u\bmod q:(uF(u),q)=1\\}>0$,
then

(13) $\\#\\{n\leq
x:(f(n),q)=1\\}=\frac{x}{(\log{x})^{1-\alpha_{F}(q)}}\exp(O((\log\log{(3q)})^{O(1)})).$

This is Proposition 2.1 in [16]; more precise results appear in work of
Scourfield [17, 18]. By the above proposition, we obtain

(14) $\\#\\{n\leq
x:(\sigma(n),q)=1\\}=\frac{x}{(\log{x})^{1-\alpha}}\exp(O((\log\log{(3q)})^{O(1)})),$

uniformly in odd $q\leq(\log x)^{K}$. Since $\alpha\gg 1/\log_{2}(3q)$, this
shows that the second of the two assertions of Theorem 1.2 is an immediate
consequence of the first, so we need to show the first assertion of the
theorem. For this purpose, we shall also need the following estimate [16,
Lemma 2.4] on the sum of reciprocals of the primes at which a given polynomial
is coprime to a modulus $q$ that varies in a wide range.

######  Lemma 4.2.

Let $F(T)\in\mathbb{Z}[T]$ be a fixed nonconstant polynomial. For each
positive integer $q$ and each real number $x\geq 3q$,

$\sum_{p\leq
x}\frac{\mathbbm{1}_{\gcd(F(p),q)=1}}{p}=\alpha_{F}(q)\log_{2}{x}+O((\log\log{(3q)})^{O(1)}),$

where $\alpha_{F}(q)$ is as defined in Proposition 4.1.

To establish the first assertion of Theorem 1.2, we set $y\coloneqq\exp((\log
x)^{\epsilon/2})$ and $z\coloneqq x^{1/\log_{2}x}$. From the count of $n\leq
x$ having $\sigma(n)\equiv a\pmod{q}$, we first remove those that are either
$z$-smooth or have a repeated prime factor exceeding $y$. By well-known
results on smooth numbers (for instance [20, Theorem 5.13 and Corollary 5.19,
Chapter III.5]), the total contribution of such $n$ is $\ll\Psi(x,z)+x/y\ll
x/(\log x)^{(1+o(1))\log_{3}x}$, which is negligible in comparison to the
error term in the statement of Theorem 1.2.

Among the surviving $n$, we now remove those that have $P_{2}(n)\leq y$. Any
such $n$ can be written as $n=mP$, where $P=P(n)>z$, $m$ is $y$-smooth and
$\sigma(n)=\sigma(m)\sigma(P)=\sigma(m)(P+1)$. The condition $\sigma(n)\equiv
a\pmod{q}$ forces $\sigma(m)$ to be coprime to $q$ and, for each choice of
$m$, restricts $P\in(z,x/m]$ to at most one coprime residue class modulo $q$.
Hence for each choice of $m$, there are $\ll x/\varphi(q)m\log(z/q)\ll
x\log_{2}x/\varphi(q)m\log x$ many possible choices of $P$, by the Brun-
Titchmarsh theorem. Consequently, the total contribution of the surviving
$n\leq x$ that have $P_{2}(n)\leq y$ is

$\begin{split}\ll\frac{x\log_{2}x}{\varphi(q)\log
x}\sum_{\begin{subarray}{c}m:\,P^{+}(m)\leq
y\end{subarray}}\frac{\mathbbm{1}_{(\sigma(m),q)=1}}{m}&\ll\frac{x\log_{2}x}{\varphi(q)\log
x}\exp\left(\sum_{p\leq y}\frac{\mathbbm{1}_{(p+1,\,q)=1}}{p}\right)\\\
&\ll\frac{x\log_{2}x}{\varphi(q)(\log
x)^{1-\alpha\epsilon/2}}\exp((\log_{2}(3q))^{O(1)})\ll\frac{x}{\varphi(q)(\log
x)^{1-2\alpha\epsilon/3}}.\end{split}$

Here we have estimated the sum $\sum_{p\leq y}\mathbbm{1}_{(p+1,\,q)=1}/p$
using Lemma 4.2 (on the polynomial $F(T)\coloneqq T+1$) and recalled that
$\alpha\gg 1/\log_{2}(3q)\gg 1/\log_{3}x$ for all odd $q\leq(\log x)^{K}$.
Collecting estimates, we have so far shown that

$\begin{split}\sum_{\begin{subarray}{c}n\leq x\\\ \sigma(n)\equiv
a\pmod{q}\end{subarray}}1&=\sum_{\begin{subarray}{c}n\leq x\\\
P(n)>z,\,P_{2}(n)>y\\\ p>y\implies p^{2}\nmid
n\end{subarray}}\mathbbm{1}_{\sigma(n)\equiv
a\pmod{q}}+O\left(\frac{x}{\varphi(q)(\log x)^{1-2\alpha\epsilon/3}}\right)\\\
&=\sum_{\begin{subarray}{c}n\leq x\\\ P(n)>z,\,P_{2}(n)>y\\\ p>y\implies
p^{2}\nmid n\end{subarray}}\frac{1}{\varphi(q)}\sum_{\chi\bmod
q}~{}\overline{\chi}(a)\chi(\sigma(n))+O\left(\frac{x}{\varphi(q)(\log
x)^{1-2\alpha\epsilon/3}}\right),\end{split}$

where in the second line above, we have used the orthogonality of the
Dirichlet characters mod $q$ to detect the congruence $\sigma(n)\equiv
a\pmod{q}$. With $\chi_{0,q}$ denoting the principal character modulo $q$, we
may thus isolate the contribution of $\chi_{0,q}$ to obtain

(15) $\begin{split}\sum_{\begin{subarray}{c}n\leq x\\\ \sigma(n)\equiv
a\pmod{q}\end{subarray}}1=\frac{1}{\varphi(q)}&\sum_{\begin{subarray}{c}n\leq
x\\\ (\sigma(n),q)=1\end{subarray}}1\\\
&+\frac{1}{\varphi(q)}\sum_{\chi\neq\chi_{0,q}\bmod
q}\overline{\chi}(a)\sum_{\begin{subarray}{c}n\leq x\\\ P(n)>z,\,P_{2}(n)>y\\\
p>y\implies p^{2}\nmid
n\end{subarray}}\chi(\sigma(n))+O\left(\frac{x}{\varphi(q)(\log
x)^{1-2\alpha\epsilon/3}}\right).\end{split}$

The second outer sum on the right hand side above is over the non-trivial
characters $\chi$ mod $q$, and we have adapted our previous arguments to
observe that there are $O({x}/{(\log x)^{1-2\alpha\epsilon/3}})$ many $n\leq
x$ satisfying $(\sigma(n),q)=1$ but failing at least one of the three
conditions below:

  * (i)

$P(n)>z,$

  * (ii)

$p>y\implies p^{2}\nmid n,$

  * (iii)

$P_{2}(n)>y$.

Indeed, any $n$ satisfying conditions (i) and (ii) but failing condition (iii)
is of the form $mP$, where $P^{+}(m)\leq y$, $P=P^{+}(n)\in(z,x/m]$ and
$\sigma(n)=\sigma(m)(P+1)$. As such, we must have $(\sigma(m),q)=1$, and the
number of $P$ given $m$ is $\ll x/m\log z\ll x\log_{2}x/m\log x$. Summing this
expression over all possible $m$ yields the observed bound.

In order to estimate the inner sums of $\chi(\sigma(n))$ occurring in (15), we
start by modifying some of our initial arguments in the proof of Theorem 1.1.
Any $n$ with $P(n)>z$, $P_{2}(n)>y$ and without any repeated prime factor
exceeding $y$ can be uniquely written in the form $mP_{j}\cdots P_{1}$ for
some $j\geq 2$, where $P_{1}=P(n)>z$ and $P(m)\leq y<P_{j}<\dots<P_{1}$. As
such, we have

$\sum_{\begin{subarray}{c}n\leq x\\\ P(n)>z,\,P_{2}(n)>y\\\ p>y\implies
p^{2}\nmid n\end{subarray}}\chi(\sigma(n))=\sum_{j\geq
2}\sum_{\begin{subarray}{c}m\leq x\\\ P(m)\leq
y\end{subarray}}\chi(\sigma(m))\sum_{\begin{subarray}{c}P_{1},\dots,P_{j}\\\
P_{j}\cdots P_{1}\leq x/m\\\
P_{1}>z,~{}y<P_{j}<\dots<P_{1}\end{subarray}}\chi(P_{1}+1)\cdots\chi(P_{j}+1).$

Define $\rho_{\chi}\coloneqq\frac{1}{\varphi(q)}\sum_{v\bmod
q}\chi_{0,q}(v)\chi(v+1)$. By the Siegel-Walfisz Theorem, we see that

(16) $\begin{split}\sum_{y<p\leq Y}\chi(p+1)&=\sum_{\begin{subarray}{c}v\bmod
q\\\ (v,q)=1\end{subarray}}\chi(v+1)\sum_{\begin{subarray}{c}y<p\leq Y\\\
p\equiv v\pmod{q}\end{subarray}}1\\\ &=\sum_{\begin{subarray}{c}v\bmod q\\\
(v,q)=1\end{subarray}}\chi(v+1)\left\\{\frac{1}{\varphi(q)}\sum_{\begin{subarray}{c}y<p\leq
Y\end{subarray}}1+O\left(Y\exp(-C_{0}\sqrt{\log y})\right)\right\\}\\\
&=\rho_{\chi}(\pi(Y)-\pi(y))+O(\varphi(q)Y\exp(-C_{0}\sqrt{\log
y})),\end{split}$

where $C_{0}$ is a constant depending at most on $K$. Proceeding as in the
proof of Theorem 1.1, we successively remove
$\chi(P_{1}+1),\dots,\chi(P_{j}+1)$, with the input from (1) replaced by the
above estimate. This leads us to

(17) $\begin{split}\sum_{\begin{subarray}{c}n\leq x\\\ P(n)>z,\,P_{2}(n)>y\\\
p>y\implies p^{2}\nmid n\end{subarray}}\chi(\sigma(n))=\sum_{j\geq
2}\frac{(\rho_{\chi})^{j}}{(j-1)!}\sum_{\begin{subarray}{c}m\leq x\\\ P(m)\leq
y\end{subarray}}\chi(\sigma(m))&\sum_{\begin{subarray}{c}P_{1},\dots,P_{j}\\\
P_{1}>z,~{}P_{j}\cdots P_{1}\leq x/m\\\ P_{2},\dots,P_{j}\in(y,P_{1})\text{
distinct }\end{subarray}}1\\\ &+O(x\exp(-C_{1}\sqrt{\log y})),\end{split}$

for some constant $C_{1}>0$ depending at most on $K$.

Now the main term in the display above is absolutely bounded by

(18) $\displaystyle\allowdisplaybreaks|\rho_{\chi}|^{2}$
$\displaystyle\sum_{j\geq
2}\frac{|\rho_{\chi}|^{j-2}}{(j-1)!}\sum_{\begin{subarray}{c}m\leq x\\\
P(m)\leq y\\\
(\sigma(m),q)=1\end{subarray}}\sum_{\begin{subarray}{c}P_{2},\dots,P_{j}\in(y,x)\\\
P_{2}\cdots P_{j}\leq x/mz\end{subarray}}~{}\sum_{z<P_{1}\leq x/mP_{2}\cdots
P_{j}}1$ $\displaystyle\ll\frac{|\rho_{\chi}|^{2}x}{\log z}\sum_{j\geq
2}\frac{|\rho_{\chi}|^{j-2}}{(j-1)!}\sum_{\begin{subarray}{c}m\leq x\\\
P(m)\leq y\\\
(\sigma(m),q)=1\end{subarray}}\frac{1}{m}\sum_{\begin{subarray}{c}P_{2},\dots,P_{j}\in(y,x)\end{subarray}}\frac{1}{P_{2}\cdots
P_{j}}$ $\displaystyle\ll|\rho_{\chi}|^{2}\frac{x(\log_{2}x)^{2}}{\log
x}\sum_{j\geq
2}\frac{(|\rho_{\chi}|\log_{2}x)^{j-2}}{(j-2)!}\sum_{\begin{subarray}{c}m\leq
x\\\ P(m)\leq y\\\
(\sigma(m),q)=1\end{subarray}}\frac{1}{m}\ll|\rho_{\chi}|^{2}\frac{x(\log_{2}x)^{2}}{(\log
x)^{1-|\rho_{\chi}|}}\exp\Bigg{(}\sum_{\begin{subarray}{c}p\leq y\\\
(p+1,\,q)=1\end{subarray}}\frac{1}{p}\Bigg{)}.$

Invoking Lemma 4.2 to estimate the last sum in the above display, we obtain

(19) $\sum_{\begin{subarray}{c}n\leq x\\\ P(n)>z,\,P_{2}(n)>y\\\ p>y\implies
p^{2}\nmid n\end{subarray}}\chi(\sigma(n))\ll|\rho_{\chi}|^{2}\frac{x}{(\log
x)^{1-|\rho_{\chi}|-2\alpha\epsilon/3}}+x\exp(-C_{1}\sqrt{\log y}).$

In order to be able to make use of this bound, we need to better understand
the $|\rho_{\chi}|$. To this end, given a nontrivial character $\chi\bmod q$
we let $\mathfrak{f}(\chi)$ denote its conductor, so that
$\mathfrak{f}(\chi)\mid q$ and $\mathfrak{f}(\chi)>1$. We can write $\chi$
uniquely in the form $\prod_{\ell^{e}\parallel q}\chi_{\ell}$, with
$\chi_{\ell}$ denoting a character mod $\ell^{e}$ that is nontrivial precisely
when $\ell\mid\mathfrak{f}(\chi)$. Now
$\varphi(q)\rho_{\chi}=\prod_{\ell^{e}\parallel q}S_{\chi,\ell}$, where for
each prime power $\ell^{e}\parallel q$,

(20)
$S_{\chi,\ell}\coloneqq\sum_{v\bmod\ell^{e}}\chi_{0,\ell}(v)\chi_{\ell}(v+1)=\sum_{\begin{subarray}{c}v\bmod{\ell^{e}}\\\
(v,\ell)=1\end{subarray}}\chi_{\ell}(v+1)=\sum_{u\bmod{\ell^{e}}}\chi_{\ell}(u)-\sum_{\begin{subarray}{c}u\bmod{\ell^{e}}\\\
u\equiv 1\pmod{\ell}\end{subarray}}\chi_{\ell}(u).$

Here $\chi_{0,\ell}$ denotes the trivial character mod $\ell^{e}$ and we have
noted that as $v$ runs over all the coprime residues mod $\ell^{e}$, the
expression $v+1$ runs over all the residues mod $\ell^{e}$ except for those
congruent to $1$ mod $\ell$. The first sum above is
$\mathbbm{1}_{\chi_{\ell}=\chi_{0,\ell}}\varphi(\ell^{e})$. To evaluate the
second sum, we consider a primitive root $g$ mod $\ell^{e}$ (which exists as
$\ell$ is odd), and observe that the residues $\\{u\bmod{\ell^{e}}:u\equiv
1\pmod{\ell}\\}$ are a permutation of the residues
$\\{g^{(\ell-1)k}\bmod{\ell^{e}}:0\leq k<\ell^{e-1}\\}$. Hence

(21) $\sum_{\begin{subarray}{c}u\bmod{\ell^{e}}\\\ u\equiv
1\pmod{\ell}\end{subarray}}\chi_{\ell}(u)=\sum_{0\leq
k<\ell^{e-1}}\chi_{\ell}(g^{\ell-1})^{k}=\mathbbm{1}_{(\chi_{\ell})^{\ell-1}=\chi_{0,\ell}}~{}\ell^{e-1}=\mathbbm{1}_{\mathfrak{f}(\chi_{\ell})\mid\ell}~{}\ell^{e-1},$

with $\mathfrak{f}(\chi_{\ell})$ denoting the conductor of $\chi_{\ell}$.
Altogether, we find that

$S_{\chi,\ell}=\mathbbm{1}_{\chi_{\ell}=\chi_{0,\ell}}\varphi(\ell^{e})-\mathbbm{1}_{\mathfrak{f}(\chi_{\ell})\mid\ell}\ell^{e-1}=\mathbbm{1}_{\mathfrak{f}(\chi_{\ell})\mid\ell}\ell^{e-1}\left(\mathbbm{1}_{\ell\nmid\mathfrak{f}(\chi)}(\ell-1)-1\right),$

leading to

(22) $\rho_{\chi}=\prod_{\ell^{e}\parallel
q}\frac{S_{\chi,\ell}}{\varphi(\ell^{e})}=\mathbbm{1}_{\mathfrak{f}(\chi)\text{
squarefree }}\prod_{\ell^{e}\parallel
q}\left(\mathbbm{1}_{\ell\nmid\mathfrak{f}(\chi)}-\frac{1}{\ell-1}\right)=\mathbbm{1}_{\mathfrak{f}(\chi)\text{
squarefree
}}\frac{(-1)^{\omega(\mathfrak{f}(\chi))}\alpha}{\prod_{\ell\mid\mathfrak{f}(\chi)}(\ell-2)}.$

If $3\mid q$, let $\psi$ denote the unique character mod $q$ induced by the
nontrivial character mod $3$. Then for any nonprincipal character
$\chi\neq\psi$ mod $q$ for which $\rho_{\chi}\neq 0$, its conductor
$\mathfrak{f}(\chi)$ is divisible by a prime at least $5$, so that
$|\rho_{\chi}|\leq\alpha/3$ by (22). As such, (19) yields for all such $\chi$,

(23) $\sum_{\begin{subarray}{c}n\leq x\\\ P(n)>z,\,P_{2}(n)>y\\\ p>y\implies
p^{2}\nmid n\end{subarray}}\chi(\sigma(n))\ll|\rho_{\chi}|^{2}\frac{x}{(\log
x)^{1-(1/3+2\epsilon/3)\alpha}}+x\exp(-C_{1}\sqrt{\log y}).$

Since there are exactly $\prod_{\ell\mid d}(\ell-2)$ primitive characters
modulo any squarefree integer $d$, equation (22) yields

$\begin{split}\sum_{\chi\bmod
q}|\rho_{\chi}|^{2}\leq\alpha^{2}\sum_{\begin{subarray}{c}d\mid q\\\ d\text{
squarefree}\end{subarray}}\frac{1}{\prod_{\ell\mid
d}(\ell-2)^{2}}\sum_{\begin{subarray}{c}\chi\bmod q\\\
\mathfrak{f}(\chi)=d\end{subarray}}1\leq\alpha^{2}\sum_{\begin{subarray}{c}d\mid
q\\\ d\text{ squarefree}\end{subarray}}\frac{1}{\prod_{\ell\mid
d}(\ell-2)}\leq\alpha^{2}\prod_{\ell\mid
q}\frac{\ell-1}{\ell-2}=\alpha.\end{split}$

(This may be compared with the bound placed on the averages
$\frac{1}{\varphi(q)}\sum_{v\bmod q}\chi_{0,q}(v)\chi(v-1)$ in the proof of
the analogous Theorem 1.3 in [14].)

Summing the bound (23) over all nontrivial characters $\chi\neq\psi$ mod $q$,
and plugging the resulting bound into (15), we obtain

(24) $\begin{split}\sum_{\begin{subarray}{c}n\leq x\\\ \sigma(n)\equiv
a\pmod{q}\end{subarray}}1&=\frac{1}{\varphi(q)}\sum_{\begin{subarray}{c}n\leq
x\\\ (\sigma(n),q)=1\end{subarray}}1+\frac{\mathbbm{1}_{3\mid
q}\overline{\psi}(a)}{\varphi(q)}\sum_{\begin{subarray}{c}n\leq x\\\
P(n)>z,\,P_{2}(n)>y\\\ p>y\implies p^{2}\nmid
n\end{subarray}}\psi(\sigma(n))+O\left(\frac{x}{\varphi(q)(\log
x)^{1-\alpha(1/3+\epsilon)}}\right)\\\
&=\frac{1}{\varphi(q)}\sum_{\begin{subarray}{c}n\leq x\\\
(\sigma(n),q)=1\end{subarray}}1+\frac{\mathbbm{1}_{3\mid
q}\overline{\psi}(a)}{\varphi(q)}\sum_{n\leq
x}\psi(\sigma(n))+O\left(\frac{x}{\varphi(q)(\log
x)^{1-\alpha(1/3+\epsilon)}}\right).\end{split}$

Here in passing to the second line above, we have recalled our previous bound
on the count of $n\leq x$ having $\sigma(n)$ coprime to $q$ but failing one of
the conditions (i)–(iii) in the discussion following (15).

Note that the last equality in (24) already establishes the first assertion of
the theorem for moduli $q$ coprime to $6$. To complete the proof of the
theorem, it thus remains to only consider the odd moduli $q$ divisible by $3$
and deal with the sum of $\psi(\sigma(n))$ occurring in (24). This is where we
can directly apply Theorem 1.1. Indeed, since $3\mid q$, we find that a prime
$p$ satisfies $(p+1,\,q)=1$ only if $p=3$ or $p\equiv 1\pmod{3}$. Thus for all
$p>3$, we have $\psi(\sigma(p))=\psi(p+1)=-\mathbbm{1}_{(p+1,\,q)=1}$. A
straightforward calculation (analogous to (16)) by means of the Siegel-Walfisz
theorem shows that the multiplicative function $f(n)\coloneqq\psi(\sigma(n))$
satisfies the hypothesis (1) with $y,z$ as chosen in the beginning of the
section and with
$\varrho\coloneqq-\frac{1}{\varphi(q)}\sum_{\begin{subarray}{c}v\bmod q\\\
(v(v+1),q)=1\end{subarray}}1=-\alpha$, $M\coloneqq\varphi(q)$,
$\mathcal{E}(y)\coloneqq\exp(-C_{0}\sqrt{\log y})$ (for some absolute constant
$C_{0}>0$). Since by lemma $\eqref{lem:primesum}$, $\sum_{p\leq
y}|f(p)|/p=\alpha\log_{2}y+O((\log_{2}(3q))^{O(1)})$, we deduce that

$\sum_{n\leq x}\psi(\sigma(n))\ll\frac{x(\log_{2}x)^{1+\alpha}}{(\log
x)^{1+\alpha(1-\epsilon)}}\exp((\log_{2}(3q))^{O(1)})\ll\frac{x}{\log x},$

and substituting this into (24) completes the proof of the theorem.

######  Remark.

To substantiate our comment (made after the paragraph following the statement
of Theorem 1.4) on the suggested optimality of the exponent $1/3$ in the error
term of Theorem 1.2, note that by (22), we have $\rho_{\chi}=\alpha/3$ for
$\mathfrak{f}(\chi)=15$ (in the case when $15\mid q$).

##  5\. Technical Preparation for Theorems 1.3 and 1.4

In order to establish Theorems 1.3 and 1.4, we will need to study the averages

$\eta_{\chi}\coloneqq\eta_{\chi}(q)\coloneqq\frac{1}{\varphi(q)}\sum_{v\bmod
q}\chi_{0,q}(v)\chi(v^{2}+v+1)$

which will play the roles of the averages $\rho_{\chi}$ that came up in the
previous section. The following proposition will provide the key information
on these averages that will prove to be crucial in our arguments.

######  Proposition 5.1.

There exists a set $\mathcal{S}$ of eighteen (fixed) squarefree positive
integers coprime to $6$ such that for all sufficiently large integers $q$ and
all nonprincipal characters $\chi$ mod $q$, the following two properties hold
true:

  1. (i)

If $\mathfrak{f}(\chi)\not\in\mathcal{S}$, then
$|\eta_{\chi}|\leq\widetilde{\alpha}(q)/4$.

  2. (ii)

If $\mathfrak{f}(\chi)\in\mathcal{S}$, then
$\mathrm{Re}(\eta_{\chi})\leq\widetilde{\alpha}(q)/4$.

In particular, we have $\mathrm{Re}(\eta_{\chi})\leq\widetilde{\alpha}(q)/4$
for all nontrivial characters $\chi$ mod $q$, and
$|\eta_{\chi}|\leq\widetilde{\alpha}(q)/4$ for all but a bounded number of
characters $\chi$ mod $q$.

The following character sum bound, a special case of [7, Theoem 1.1], will be
useful to give a proof of Proposition 5.1.

######  Lemma 5.2.

Let $\ell$ be a prime at least $5$. Then for any integer $e\geq 2$ and any
primitive character $\chi$ mod $\ell^{e}$, we have

$\left|\sum_{v\bmod\ell^{e}}\chi(v^{2}+v+1)\right|\leq\ell^{e/2}.$

###### Proof of Proposition 5.1.

We start by factoring $\chi\eqqcolon\prod_{\ell^{e}\parallel q}\chi_{\ell}$,
where each $\chi_{\ell}$ is as usual a character mod $\ell^{e}$. This allows
us to factor $\eta_{\chi}$ as $\prod_{\ell^{e}\parallel q}\eta_{\chi,\ell}$,
where

$\eta_{\chi,\ell}\coloneqq\frac{1}{\varphi(\ell^{e})}\sum_{v\bmod\ell^{e}}\chi_{0,\ell}(v)\chi_{\ell}(v^{2}+v+1).$

Since
$\widetilde{\alpha}(\ell^{e})=\frac{1}{\varphi(\ell^{e})}\\#\\{v\bmod\ell^{e}:(v(v^{2}+v+1),\ell)=1\\}$,
it is immediate that
$|\eta_{\chi,\ell}|\leq\widetilde{\alpha}(\ell^{e})=\widetilde{\alpha}(\ell)$.
Moreover, letting $e_{\ell}\coloneqq v_{\ell}(\mathfrak{f}(\chi))$ denote the
exponent of the prime $\ell$ in the integer $\mathfrak{f}(\chi)$, we see that
$\mathfrak{f}(\chi_{\ell})=\ell^{e_{\ell}}$, so if $e_{\ell}=0$ (i.e.,
$\ell\nmid\mathfrak{f}(\chi)$), then $\chi_{\ell}=\chi_{0,\ell}$ and
$\eta_{\chi,\ell}=\widetilde{\alpha}(\ell)$.

Assume that $\chi_{2}$ is nontrivial, so that $e_{2}\geq 2$. Letting
$U_{2^{e_{2}}}$ denote the multiplicative group mod $2^{e_{2}}$ we observe
that the map $U_{2^{e_{2}}}\rightarrow U_{2^{e_{2}}}:v\mapsto v^{2}+v+1$,
being injective, is also bijective. As a consequence

$\eta_{\chi,2}=\frac{1}{\varphi(2^{e_{2}})}\sum_{\begin{subarray}{c}v\bmod
2^{e_{2}}\\\
(v,2)=1\end{subarray}}\chi_{2}(v^{2}+v+1)=\frac{1}{\varphi(2^{e_{2}})}\sum_{\begin{subarray}{c}u\bmod
2^{e_{2}}\\\ (u,2)=1\end{subarray}}\chi_{2}(u)=0,$

leading to $\eta_{\chi}=\eta_{\chi,2}\prod_{\begin{subarray}{c}\ell\mid
q:~{}\ell>2\end{subarray}}\eta_{\chi,\ell}=0$. Hence in the rest of the
argument, it suffices to consider only those characters $\chi$ mod $q$ for
which $\chi_{2}$ is trivial, that is, for which $\mathfrak{f}(\chi)$ is not a
multiple of $4$. Since $3\nmid q$ and $\chi$ is nontrivial mod $q$, it must
then be the case that $\chi_{\ell}\neq\chi_{0,\ell}$ for some prime $\ell\geq
5$ dividing $q$.

Consider a prime $\ell\geq 5$ dividing $q$ for which $\chi_{\ell}$ is
nontrivial. Letting $\chi_{\ell}$ also denote the primitive chraracter mod
$\ell^{e_{\ell}}$ that induces $\chi_{\ell}$ mod $\ell^{e}$, we find that

(25) $\displaystyle\allowdisplaybreaks\eta_{\chi,\ell}$
$\displaystyle=\frac{1}{\varphi(\ell^{e})}\cdot\ell^{e-e_{\ell}}\sum_{v\bmod\ell^{e_{\ell}}}\chi_{0,\ell}(v)\chi_{\ell}(v^{2}+v+1)=\frac{1}{\varphi(\ell^{e_{\ell}})}\sum_{v\bmod\ell^{e_{\ell}}}\chi_{0,\ell}(v)\chi_{\ell}(v^{2}+v+1)$
$\displaystyle=\frac{1}{\varphi(\ell^{e_{\ell}})}\left\\{\sum_{v\bmod\ell^{e_{\ell}}}\chi_{\ell}(v^{2}+v+1)-\sum_{\begin{subarray}{c}v\bmod\ell^{e_{\ell}}\\\
v\equiv 0\pmod{\ell}\end{subarray}}\chi_{\ell}(v^{2}+v+1)\right\\}$
$\displaystyle=\frac{1}{\varphi(\ell^{e_{\ell}})}\left\\{\sum_{v\bmod\ell^{e_{\ell}}}\chi_{\ell}(v^{2}+v+1)-\mathbbm{1}_{e_{\ell}=1}\right\\}.$

In the last equality above, we have observed that the map
$\\{v\bmod\ell^{e_{\ell}}:v\equiv
0\pmod{\ell}\\}\rightarrow\\{u\bmod\ell^{e_{\ell}}:u\equiv
1\pmod{\ell}\\}\colon v\mapsto v^{2}+v+1$ being an injection from one set to
another of the same cardinality is also a bijection. By (21), this led to

$\sum_{\begin{subarray}{c}v\bmod\ell^{e_{\ell}}\\\ v\equiv
0\pmod{\ell}\end{subarray}}\chi_{\ell}(v^{2}+v+1)=\sum_{\begin{subarray}{c}u\bmod\ell^{e_{\ell}}\\\
u\equiv
1\pmod{\ell}\end{subarray}}\chi_{\ell}(u)=\mathbbm{1}_{e_{\ell}=1}~{}\ell^{e_{\ell}-1}=\mathbbm{1}_{e_{\ell}=1}.$

If $\ell\geq 5$ and $e_{\ell}\geq 2$, then by Lemma 5.2, we have

(26)
$|\eta_{\chi,\ell}|=\frac{1}{\varphi(\ell^{e_{\ell}})}\left|\sum_{v\bmod\ell^{e_{\ell}}}\chi_{\ell}(v^{2}+v+1)\right|\leq\frac{\ell^{e_{\ell}/2}}{\varphi(\ell^{e_{\ell}})}\leq\frac{\ell^{1-e_{\ell}/2}}{\ell-1}.$

Hence if $v_{\ell}(\mathfrak{f}(\chi))=e_{\ell}\geq 2$ for some prime
$\ell\geq 5$ dividing $q$, then

$\frac{|\eta_{\chi}|}{\widetilde{\alpha}(q)}\leq\frac{|\eta_{\chi,\ell}|}{\widetilde{\alpha}(\ell)}\leq\frac{\ell^{1-e_{\ell}/2}}{\ell-1}\cdot\left(\frac{\ell-1}{\ell-3}\right)^{\mathbbm{1}_{\ell\equiv
1\pmod{3}}}\leq\frac{1}{4}.$

This shows that $|\eta_{\chi}|\leq\widetilde{\alpha}(q)/4$ for all characters
$\chi$ mod $q$ whose conductor is not squarefree.

Consider now a nontrivial character $\chi$ mod $q$ whose conductor is
squarefree. Then by (25) and the Weil bounds (see for instance, [21, Corollary
2.3]), we find that

(27)
$|\eta_{\chi,\ell}|=\frac{1}{\varphi(\ell)}\left|\sum_{v\bmod\ell}\chi_{\ell}(v^{2}+v+1)-1\right|\leq\frac{\ell^{1/2}+1}{\ell-1}.$

Applying this bound for each prime $\ell\geq 5$ dividing $q$, we find that

$\frac{|\eta_{\chi}|}{\widetilde{\alpha}(q)}\leq\prod_{\begin{subarray}{c}\ell\mid
q\\\ \ell>2\end{subarray}}\mu_{\ell},~{}~{}\text{ where
}\mu_{\ell}\coloneqq\mathbbm{1}_{\begin{subarray}{c}\ell\equiv
1\pmod{3}\end{subarray}}\left(\frac{\ell^{1/2}+1}{\ell-3}\right)+\mathbbm{1}_{\begin{subarray}{c}\ell\geq
5,~{}\ell\equiv
2\pmod{3}\end{subarray}}\left(\frac{\ell^{1/2}+1}{\ell-1}\right).$

Note that $\mu_{\ell}\in(0,1)$ for all primes $\ell\geq 5$. Since the
functions $(\ell^{1/2}+1)/(\ell-3)$ and $(\ell^{1/2}+1)/(\ell-1)$ are both
strictly decreasing, we observe the following cases in which
$|\eta_{\chi}|/\widetilde{\alpha}(q)\leq 1/4$. For $i\in\\{1,2\\}$, we let
$\omega_{i}(r)$ denote the number of distinct primes dividing an integer $r$
that are congruent to $i$ mod $3$.

  * •

If $P^{+}(\mathfrak{f}(\chi))\geq 29$, then
$|\eta_{\chi}|/\widetilde{\alpha}(q)\leq\frac{29^{1/2}+1}{29-3}<0.246$.

  * •

If $\omega(\mathfrak{f}(\chi))\geq 4$, then one of the following three
possibilities must hold:
(i) Either $\omega_{1}(\mathfrak{f}(\chi))\geq 3$, in which case
$|\eta_{\chi}|/\widetilde{\alpha}\leq\mu_{7}\mu_{13}\mu_{19}<0.141$, OR
(ii) $\omega_{2}(\mathfrak{f}(\chi))\geq 3$, in which case
$|\eta_{\chi}|/\widetilde{\alpha}\leq\mu_{5}\mu_{11}\mu_{17}<0.112$, OR
(iii) $\omega_{1}(\mathfrak{f}(\chi))=\omega_{2}(\mathfrak{f}(\chi))=2$, in
which case
$|\eta_{\chi}|/\widetilde{\alpha}\leq\mu_{7}\mu_{13}\cdot\mu_{5}\mu_{11}<0.147$.

  * •

If $\omega(\mathfrak{f}(\chi))=3$ but $\mathfrak{f}(\chi)$ does not lie in the
set $A_{0}\coloneqq\\{5\cdot 7\cdot 11,5\cdot 7\cdot 13\\}$, then

$|\eta_{\chi}|/\widetilde{\alpha}\leq\max\\{\mu_{5}\mu_{11}\mu_{13},~{}\mu_{5}\mu_{7}\mu_{17},~{}\mu_{7}\mu_{11}\mu_{13},~{}\mu_{5}\mu_{7}\mu_{19}\\}<0.247.$

  * •

If $\omega(\mathfrak{f}(\chi))=2$ but $\mathfrak{f}(\chi)$ is not a member of
the set $B_{0}\coloneqq\\{7\cdot 13,7\cdot 19\\}\cup\\{5\cdot 11,5\cdot
17\\}\cup\\{5\cdot 7,5\cdot 13,5\cdot 19,7\cdot 11,7\cdot 17\\}$, then

$|\eta_{\chi}|/\widetilde{\alpha}\leq\max\\{\mu_{13}\mu_{19},~{}\mu_{11}\mu_{17},~{}\mu_{5}\mu_{23},~{}\mu_{7}\mu_{23},~{}\mu_{11}\mu_{13}\\}<0.241.$

Hence, defining $\mathcal{S}$ to be the set $\\{5,7,11,13,17,19,23\\}\cup
A_{0}\cup B_{0}$, we have shown that
$|\eta_{\chi}|\leq\widetilde{\alpha}(q)/4$ for all characters $\chi$ mod $q$
whose conductor $\mathfrak{f}(\chi)$ does not lie in the set $\mathcal{S}$. It
thus only remains to show that for all $\chi$ mod $q$ with
$\mathfrak{f}(\chi)\in\mathcal{S}$, we have
$\mathrm{Re}(\eta_{\chi})\leq\widetilde{\alpha}(q)/4$. For such characters,
the identity (25) shows that

(28) $\begin{split}\eta_{\chi}&=\prod_{\begin{subarray}{c}\ell\mid q\\\
\ell\nmid\mathfrak{f}(\chi)\end{subarray}}\widetilde{\alpha}(\ell)\cdot\prod_{\ell\mid\mathfrak{f}(\chi)}\left(\frac{1}{\varphi(\ell)}\sum_{\begin{subarray}{c}v\bmod\ell\\\
v\not\equiv 0\bmod\ell\end{subarray}}\chi_{\ell}(v^{2}+v+1)\right)\\\
&=\frac{\widetilde{\alpha}(q)}{\prod_{\begin{subarray}{c}\ell\mid\mathfrak{f}(\chi)\\\
\ell\equiv
1\pmod{3}\end{subarray}}(\ell-3)\cdot\prod_{\begin{subarray}{c}\ell\mid\mathfrak{f}(\chi)\\\
\ell\equiv
2\pmod{3}\end{subarray}}(\ell-1)}\sum_{\begin{subarray}{c}v\bmod\mathfrak{f}(\chi)\\\
\gcd(v,\mathfrak{f}(\chi))=1\end{subarray}}\psi(v^{2}+v+1),\end{split}$

where $\psi\coloneqq\prod_{\ell\mid\mathfrak{f}(\chi)}\chi_{\ell}$ denotes the
primitive character mod $\mathfrak{f}(\chi)$ inducing $\chi$. So we need only
show that

(29) $\max_{Q\in\mathcal{S}}~{}\frac{1}{\prod_{\begin{subarray}{c}\ell\mid
Q\\\ \ell\equiv
1\pmod{3}\end{subarray}}(\ell-3)\cdot\prod_{\begin{subarray}{c}\ell\mid Q\\\
\ell\equiv
2\pmod{3}\end{subarray}}(\ell-1)}~{}\max_{\begin{subarray}{c}\psi\bmod Q\\\
\psi\text{
primitive}\end{subarray}}~{}\mathrm{Re}\left(\sum_{\begin{subarray}{c}v\bmod
Q\\\ \gcd(v,Q)=1\end{subarray}}\psi(v^{2}+v+1)\right)\leq\frac{1}{4}.$

But $\mathcal{S}$ consists of only eighteen moduli, so this can be verified by
a short Sage code. This completes the proof of Proposition 5.1. ∎

######  Remark.

The aforementioned Sage code actually shows that equality is attained in (29)
for $Q\in\\{5,7,13,35\\}\subset\mathcal{S}$. In other words, for such $Q$,
there exist primitive characters $\psi$ mod $Q$ for which

$\frac{1}{\prod_{\begin{subarray}{c}\ell\mid Q\\\ \ell\equiv
1\pmod{3}\end{subarray}}(\ell-3)\cdot\prod_{\begin{subarray}{c}\ell\mid Q\\\
\ell\equiv
2\pmod{3}\end{subarray}}(\ell-1)}\cdot\mathrm{Re}\left(\sum_{\begin{subarray}{c}v\bmod
Q\\\ \gcd(v,Q)=1\end{subarray}}\psi(v^{2}+v+1)\right)=\frac{1}{4}.$

As we shall see in the proof of Proposition 5.4 below, the averages
$\eta_{\chi}$ will play the roles of the parameter $\varrho$ from Theorem 1.1.
This supports our previous comment on the expected optimality of the exponent
$1/4$ in the error terms of Theorems 1.3 and 1.4.

We shall also need the following analogue of Proposition 4.1, which gives a
count for the main term in Theorems 1.3 and 1.4. In what follows, we
abbreviate $\widetilde{\alpha}(q)$ to $\widetilde{\alpha}$.

######  Lemma 5.3.

Fix $K>0$. We have

(30) $\\#\\{n\leq
x:(\sigma(n),q)=1\\}=\frac{x^{1/2}}{(\log{x})^{1-\widetilde{\alpha}}}\exp(O((\log\log{(3q)})^{O(1)})),$

uniformly in even $q\leq(\log x)^{K}$ such that $3\nmid q$.

###### Proof.

Our key observation is that since $q$ is even, $\sigma(n)$ is coprime to $q$
if and only if $n$ is of the form $2^{k}m^{2}$ for some integer $k\geq 0$ and
some odd integer $m$ satisfying $\gcd(\sigma(m^{2}),q)=1$; this follows from
the fact that $\sigma(n)=\prod_{p^{k}\parallel
n}\sigma(p^{k})\equiv\prod_{p^{k}\parallel n:~{}p>2}~{}(k+1)\pmod{2}$. In
particular, if $n$ is of the form $r^{2}$ for some integer $r$, then
$\gcd(\sigma(n),q)=1$. As such, the left hand side of (30) is no less than

$\sum_{\begin{subarray}{c}r\leq x^{1/2}\\\
(\sigma(r^{2}),q)=1\end{subarray}}1\geq\frac{x^{1/2}}{(\log{x})^{1-\widetilde{\alpha}}}\exp(O((\log\log{(3q)})^{O(1)})).$

Here to write the last bound above, we have invoked Proposition 4.1 with
$f(n)\coloneqq\sigma(n^{2})$ for which $F(T)\coloneqq T^{2}+T+1$ and
$\alpha_{F}(q)=\widetilde{\alpha}(q)$.

To obtain the upper bound, it suffices to show that the expression on the
right hand side of (30) bounds (from above) the number of possible tuples
$(k,m)$ of non-negative integers for which $m$ is odd, $2^{k}m^{2}\leq x$ and
$\gcd(\sigma(m^{2}),q)=1$. The contribution of those tuples for which
$k>20\log_{2}x/\log 2$ is no more than

(31) $\sum_{k>\frac{20\log\log x}{\log
2}}~{}\sum_{m\leq\sqrt{x/2^{k}}}1~{}\leq~{}x^{1/2}~{}\sum_{k>\frac{20\log_{2}x}{\log
2}}~{}\frac{1}{2^{k/2}}~{}\ll~{}\frac{x^{1/2}}{(\log x)^{10}};$

this is negligible compared to the right hand side of (30). On the other hand,
if $k\leq 20\log_{2}x/\log 2$, then $\sqrt{x/2^{k}}\geq x^{1/2}/(\log
x)^{10}\geq x^{1/3}$. Consequently
$q\leq\big{(}\log\sqrt{x/2^{k}}\big{)}^{3K}$, and another application of
Proposition 4.1 shows that given $k$, the number of possible $m$ is at most

$\sum_{\begin{subarray}{c}m\leq\sqrt{x/2^{k}}\\\
(\sigma(m^{2}),q)=1\end{subarray}}1\ll\frac{\sqrt{x/2^{k}}}{(\log\sqrt{x/2^{k}})^{1-\widetilde{\alpha}}}\exp\big{(}O\big{(}(\log_{2}(3q))^{O(1)}\big{)}\big{)}\\\
\ll\frac{x^{1/2}}{2^{k/2}(\log
x)^{1-\widetilde{\alpha}}}\exp\big{(}O\big{(}(\log_{2}(3q))^{O(1)}\big{)}\big{)}.$

Here we have noted that since $k\leq 20\log_{2}x/\log x$, we have

$\left(\log\sqrt{\frac{x}{2^{k}}}\right)^{1-\widetilde{\alpha}}=\left(\frac{1}{2}\log
x\right)^{1-\widetilde{\alpha}}\left(1+O\left(\frac{k}{\log
x}\right)\right)=\left(\frac{1}{2}\log
x\right)^{1-\widetilde{\alpha}}\left(1+O\left(\frac{\log_{2}x}{\log
x}\right)\right).$

Summing the bound in the above display over all $k\geq 0$ establishes the
upper bound in (30). ∎

To start proving Theorems 1.3 and 1.4, we set $y\coloneqq\exp((\log
x)^{\epsilon/4})$ and $z\coloneqq x^{1/\log_{2}x}$. We shall show that for
even $q\leq(\log x)^{K}$ and any coprime residue class $a$ mod $q$, the
dominant contribution to the count of $n\leq x$ satisfying $\sigma(n)\equiv
a\pmod{q}$ comes from those $n$ which have sufficiently many large prime
divisors. More precisely, these are the $n$ which have at least six prime
factors exceeding $y$ counted with multiplicity.

######  Proposition 5.4.

Fix $K>0$ and $\epsilon\in(0,1)$. We have

(32) $\sum_{\begin{subarray}{c}n\leq x:~{}P_{6}(n)>y\\\ \sigma(n)\equiv
a\pmod{q}\end{subarray}}1=\frac{1}{\varphi(q)}\sum_{\begin{subarray}{c}n\leq
x\\\ (\sigma(n),q)=1\end{subarray}}1+O\left(\frac{x^{1/2}}{\varphi(q)(\log
x)^{1-\widetilde{\alpha}(q)(1/4+\epsilon)}}\right),$

uniformly in coprime residue classes $a$ mod $q$ to moduli $q\leq(\log x)^{K}$
satisfying $\gcd(q,6)=2$.

###### Proof.

We start by bounding the contribution of the $z$-smooth $n$ to the left hand
side. By the observation made at the start of the proof of Lemma 5.3, any such
$n$ can be written in the form $2^{k}m^{2}$ for some $k\geq 0$ and some
$z$-smooth odd $m$. The number of possibilities of $k$ given $m$ is $O(\log
x)$. This in fact shows that

(33) $\sum_{\begin{subarray}{c}n\leq x:~{}P(n)\leq z\\\
\gcd(\sigma(n),q)=1\end{subarray}}1\leq\sum_{\begin{subarray}{c}m\leq
x^{1/2}\\\ P(m)\leq z\end{subarray}}\sum_{k\leq\frac{\log x}{\log 2}}1\ll\log
x\sum_{\begin{subarray}{c}m\leq x^{1/2}\\\ P(m)\leq
z\end{subarray}}1\ll\frac{x^{1/2}}{(\log x)^{(1/2+o(1))\log_{3}x}},$

where in the last step we have again invoked [20, Theorem 5.13 and Corollary
5.19, Chapter III.5]. The last expression above is negligible in comparison to
the error term in (32).

Next, we bound the contribution of those $n$ which are divisible by the fourth
power of a prime exceeding $y$. As before, any such $n$ can be written in the
form $2^{k}m^{2}$ for some $k\geq 0$ and some odd $m\leq\sqrt{x/2^{k}}$ where
(this time) $m$ is divisible by the square of a prime exceeding $y$. Given
$k$, the number of possibilities of $m$ is no more than

$\sum_{p>y}\sum_{\begin{subarray}{c}m\leq\sqrt{x/2^{k}}\\\ p^{2}\mid
m\end{subarray}}1\leq\sqrt{\frac{x}{2^{k}}}\sum_{p>y}\frac{1}{p^{2}}\ll\frac{\sqrt{x/2^{k}}}{y}.$

Summing this bound over all $k\geq 0$, we find that

(34) $\sum_{\begin{subarray}{c}n\leq x:~{}(\sigma(n),q)=1\\\ \exists p>y\text{
s.t.}~{}p^{4}\mid n\end{subarray}}1\ll\frac{\sqrt{x}}{y},$

which is also negligible compared to the error term in (32).

By (33) and (34), we may thus ignore the contribution of those $n$ to the left
hand side of (32), which are either $z$-smooth or are divisible by the fourth
power of a prime exceeding $y$. In order to complete the proof of the
proposition, it thus remains to show that

(35) $\sum_{\begin{subarray}{c}n\leq x:~{}P_{6}(n)>y\\\ P(n)>z;~{}p>y\implies
p^{4}\nmid n\\\ \sigma(n)\equiv
a\pmod{q}\end{subarray}}1=\frac{1}{\varphi(q)}\sum_{\begin{subarray}{c}n\leq
x\\\ (\sigma(n),q)=1\end{subarray}}1+O\left(\frac{x^{1/2}}{\varphi(q)(\log
x)^{1-\widetilde{\alpha}(q)(1/4+\epsilon)}}\right).$

To prove this estimate, we start by invoking the orthogonality of the
Dirichlet characters mod $q$ to write

(36) $\sum_{\begin{subarray}{c}n\leq x:~{}P_{6}(n)>y\\\ P(n)>z;~{}p>y\implies
p^{4}\nmid n\\\ \sigma(n)\equiv
a\pmod{q}\end{subarray}}1=\frac{1}{\varphi(q)}\sum_{\begin{subarray}{c}n\leq
x:~{}P_{6}(n)>y\\\ P(n)>z;~{}p>y\implies p^{4}\nmid n\\\
\gcd(\sigma(n),q)=1\end{subarray}}1+\frac{1}{\varphi(q)}\sum_{\chi\neq\chi_{0,q}\bmod
q}\overline{\chi}(a)\sum_{\begin{subarray}{c}n\leq x:~{}P_{6}(n)>y\\\
P(n)>z;~{}p>y\implies p^{4}\nmid n\end{subarray}}\chi(\sigma(n)).\\\ $

We remove the additional conditions in the first sum on the right hand side
above. To begin with, we observe that up to a negligible error, we may ignore
the condition $P_{6}(n)>y$: indeed, any $n\leq x$ which violates this
condition but satisfies all the other conditions in the first sum can be
written in the form $2^{k}m^{2}$ where $m$ is odd but not $z$-smooth, has no
repeated prime factor exceeding $y$, and satisfies $P_{6}(m^{2})\leq y$ and
$\gcd(\sigma(m^{2}),q)=1$. As such, $m$ can be written in the form $rP$ for
some prime $P>z$ and some odd $r$ coprime to $P$ which satisfies $P_{2}(r)\leq
y$ and $\gcd(\sigma(r^{2}),q)=1$. Altogether, we find that

$\displaystyle\allowdisplaybreaks\sum_{\begin{subarray}{c}n\leq
x:~{}P_{6}(n)\leq y\\\ P(n)>z;~{}p>y\implies p^{4}\nmid n\\\
\gcd(\sigma(n),q)=1\end{subarray}}1$ $\displaystyle\leq\sum_{k\geq
0}~{}\sum_{\begin{subarray}{c}r\leq x:~{}P_{2}(r)\leq y\\\
(\sigma(r^{2}),q)=1\end{subarray}}~{}\sum_{z<P\leq\sqrt{x/2^{k}r^{2}}}1$ (37)
$\displaystyle\ll\frac{x^{1/2}}{\log z}\sum_{k\geq
0}\frac{1}{2^{k/2}}~{}\sum_{\begin{subarray}{c}r\leq x:~{}P_{2}(r)\leq y\\\
(\sigma(r^{2}),q)=1\end{subarray}}\frac{1}{r}\ll\frac{x^{1/2}\log_{2}x}{\log
x}\sum_{\begin{subarray}{c}r\leq x:~{}P_{2}(r)\leq y\\\
(\sigma(r^{2}),q)=1\end{subarray}}\frac{1}{r}.$

Any $r$ counted in the above sum can be written in the form $AB$, where
$P(B)\leq y<P(A)$, so that $A$ is either $1$ or a prime and
$\sigma(r^{2})=\sigma(A^{2})\sigma(B^{2})$. Given $B$, the sum of $1/A$ over
all possible $A$ is at most $1+\sum_{p\leq x}1/p\ll\log_{2}x$. We infer that

(38) $\begin{split}\sum_{\begin{subarray}{c}r\leq x:~{}P_{2}(r)\leq y\\\
(\sigma(r^{2}),q)=1\end{subarray}}\frac{1}{r}&\ll(\log_{2}x)\sum_{\begin{subarray}{c}B\leq
x:~{}P(B)\leq y\\\
(\sigma(B^{2}),q)=1\end{subarray}}\frac{1}{B}\ll(\log_{2}x)\exp\left(\sum_{p\leq
y}\frac{\mathbbm{1}_{(p^{2}+p+1,\,q)=1}}{p}\right)\\\ &\ll(\log
x)^{\widetilde{\alpha}\epsilon/4}(\log_{2}x)\exp\big{(}O\big{(}(\log_{2}(3q))^{O(1)}\big{)}\big{)},\end{split}$

where in the last line above, we have invoked Lemma 4.2 on the polynomial
$F(T)\coloneqq T^{2}+T+1$. Inserting the above bound into (5), we obtain

(39) $\begin{split}\sum_{\begin{subarray}{c}n\leq x:~{}P_{6}(n)\leq y\\\
P(n)>z;~{}p>y\implies p^{4}\nmid n\\\
\gcd(\sigma(n),q)=1\end{subarray}}1\ll\frac{x^{1/2}(\log_{2}x)^{2}}{(\log
x)^{1-\widetilde{\alpha}\epsilon/4}}\exp\big{(}O\big{(}(\log_{2}(3q))^{O(1)}\big{)}\big{)}\ll\frac{x^{1/2}}{(\log
x)^{1-\widetilde{\alpha}\epsilon/2}},\end{split}$

whereupon from (36), it follows that

(40) $\sum_{\begin{subarray}{c}n\leq x:~{}P_{6}(n)>y\\\ P(n)>z;~{}p>y\implies
p^{4}\nmid n\\\ \sigma(n)\equiv
a\pmod{q}\end{subarray}}1=\frac{1}{\varphi(q)}\sum_{\begin{subarray}{c}n\leq
x\\\ (\sigma(n),q)=1\end{subarray}}1\\\
+\frac{1}{\varphi(q)}\sum_{\chi\neq\chi_{0,q}\bmod
q}\overline{\chi}(a)\sum_{\begin{subarray}{c}n\leq x\\\
P(n)>z,~{}P_{6}(n)>y\\\ p>y\implies p^{4}\nmid
n\end{subarray}}\chi(\sigma(n))+O\left(\frac{x^{1/2}}{\varphi(q)(\log
x)^{1-\widetilde{\alpha}\epsilon/2}}\right).$

Here we have also used (33) and (34) respectively to remove the conditions
“$P(n)>z$” and “$p>y\implies p^{4}\nmid y$” occurring in the first sum on the
right hand side of (36).

In order to estimate the inner sums on $\chi(\sigma(n))$ in (40), we proceed
analogously to our proof of Theorem 1.2. For a given nontrivial character
$\chi$ mod $q$, any $n$ counted in the aforementioned sum can be uniquely
written in the form $MP_{1}^{2}\cdots P_{j}^{2}$ for some $j\geq 3$, some
$y$-smooth $M$ and some primes $P_{1},\dots,P_{j}$, which satisfy $P_{1}>z$
and $y<P_{j}<\dots<P_{2}<P_{1}$. (Here the condition $j\geq 3$ is a
consequence of $P_{6}(n)>y$.) Proceeding as in the proof of Theorem 1.1, and
using the estimate

$\sum_{y<p\leq
Y}\chi(p^{2}+p+1)=\eta_{\chi}(\pi(Y)-\pi(y))+O(\varphi(q)Y\exp(-C_{0}\sqrt{\log
y}))$

in place of (16), we obtain the following analogue of (17)

(41) $\begin{split}\sum_{\begin{subarray}{c}n\leq x\\\ P(n)>z,~{}P_{6}(n)>y\\\
p>y\implies p^{4}\nmid n\end{subarray}}\chi(\sigma(n))=\sum_{j\geq
3}\frac{(\eta_{\chi})^{j}}{(j-1)!}\sum_{\begin{subarray}{c}M\leq x\\\ P(M)\leq
y\end{subarray}}\chi(\sigma(M))&\sum_{\begin{subarray}{c}P_{1},\dots,P_{j}\\\
P_{1}>z,~{}P_{j}\cdots P_{1}\leq\sqrt{x/M}\\\
P_{2},\dots,P_{j}\in(y,P_{1})\text{ distinct }\end{subarray}}1\\\
&+O(x^{1/2}\exp(-C_{1}\sqrt{\log y})),\end{split}$

where $C_{1}=C_{1}(K)$ is a constant. Bounding the main term above as in (18),
we deduce that

(42) $\sum_{\begin{subarray}{c}n\leq x\\\ P(n)>z,~{}P_{6}(n)>y\\\ p>y\implies
p^{4}\nmid
n\end{subarray}}\chi(\sigma(n))\ll|\eta_{\chi}|^{3}~{}\frac{x^{1/2}(\log_{2}x)^{3}}{(\log
x)^{1-|\eta_{\chi}|}}\sum_{\begin{subarray}{c}M\leq x\\\ P(M)\leq y\\\
(\sigma(M),q)=1\end{subarray}}\frac{1}{M^{1/2}}+x^{1/2}\exp(-C_{1}\sqrt{\log
y}).$

To estimate the sum on $M$ above, we recall that, by the observation made at
the start of the proof of Lemma 5.3, any $M$ counted in the sum can be
uniquely written in the form $2^{k}m^{2}$ for some $k\geq 0$ and some odd
$y$-smooth $m$ satisfying $\gcd(\sigma(m^{2}),q)=1$. We thus obtain

(43) $\begin{split}\sum_{\begin{subarray}{c}M\leq x\\\ P(M)\leq y\\\
(\sigma(M),q)=1\end{subarray}}\frac{1}{M^{1/2}}&\leq\sum_{k\geq
0}\frac{1}{2^{k/2}}\sum_{\begin{subarray}{c}m\leq\sqrt{x/2^{k}}\\\ P(m)\leq
y\\\ (\sigma(m^{2}),q)=1\end{subarray}}\frac{1}{m}\\\
&\ll\exp\left(\sum_{p\leq
y}\frac{\mathbbm{1}_{(p^{2}+p+1,\,q)=1}}{p}\right)\ll(\log
x)^{\widetilde{\alpha}\epsilon/4}\exp\big{(}O\big{(}(\log_{2}(3q))^{O(1)}\big{)}\big{)}.\end{split}$

Inserting this bound into (42) yields

$\sum_{\begin{subarray}{c}n\leq x\\\ P(n)>z,~{}P_{6}(n)>y\\\ p>y\implies
p^{4}\nmid
n\end{subarray}}\chi(\sigma(n))\ll|\eta_{\chi}|^{3}~{}\frac{x^{1/2}(\log_{2}x)^{3}}{(\log
x)^{1-|\eta_{\chi}|-\widetilde{\alpha}\epsilon/4}}\exp\big{(}O\big{(}(\log_{2}(3q))^{O(1)}\big{)}\big{)}+x^{1/2}\exp(-C_{1}\sqrt{\log
y}).$

Assume that $\mathfrak{f}(\chi)\not\in\mathcal{S}$, where $\mathcal{S}$ is the
set of eighteen positive integers considered in Proposition 5.1. Then
$|\eta_{\chi}|\leq\widetilde{\alpha}/4$, and we obtain, for all such
characters $\chi$ mod $q$,

(44) $\sum_{\begin{subarray}{c}n\leq x\\\ P(n)>z,~{}P_{6}(n)>y\\\ p>y\implies
p^{4}\nmid
n\end{subarray}}\chi(\sigma(n))\ll|\eta_{\chi}|^{3}~{}\frac{x^{1/2}}{(\log
x)^{1-\widetilde{\alpha}(1/4+\epsilon/2)}}+x^{1/2}\exp(-C_{1}\sqrt{\log y}).$

Now from the computations in (26) and (27), we see that for each nontrivial
character $\chi$ mod $q$, we have (with $e_{\ell}\coloneqq
v_{\ell}(\mathfrak{f}(\chi))$ as before),

$|\eta_{\chi}|=\prod_{\ell\mid
q}|\eta_{\chi,\ell}|\leq\prod_{\ell\mid\mathfrak{f}(\chi)}\frac{\ell^{e_{\ell}/2}+1}{\varphi(\ell^{e_{\ell}})}\leq\prod_{\ell\mid\mathfrak{f}(\chi)}\ell^{-e_{\ell}/2}\left(1+O\left(\frac{1}{\ell^{1/2}}\right)\right)\leq\mathfrak{f}(\chi)^{-1/2}\exp(O(\sqrt{\log
q})).$

Since there are no more than $d$ characters mod $q$ having conductor $d$, we
obtain

$\begin{split}\sum_{\chi\neq\chi_{0,q}\bmod q}|\eta_{\chi}|^{3}\leq\sum_{d\mid
q}d\cdot\frac{1}{d^{3/2}}\exp(O(\sqrt{\log q}))\leq\exp(O(\sqrt{\log
q})),\end{split}$

where we have noted that $\sum_{d\mid q}{d^{-1/2}}\leq\prod_{\ell\mid
q}(1+O(\ell^{-1/2}))\leq\exp(O(\sqrt{\log q}))$. Summing the bound (44) over
all nonprincipal characters $\chi$ mod $q$ having
$\mathfrak{f}(\chi)\not\in\mathcal{S}$, and invoking the bound on
$\sum_{\chi\neq\chi_{0,q}\bmod q}|\eta_{\chi}|^{3}$ obtained above, we find
that

(45) $\sum_{\begin{subarray}{c}\chi\neq\chi_{0,q}\bmod q\\\
\mathfrak{f}(\chi)\not\in\mathcal{S}\end{subarray}}\left|\sum_{\begin{subarray}{c}n\leq
x:~{}P(n)>z\\\ P_{6}(n)>y;~{}p>y\implies p^{4}\nmid
n\end{subarray}}\chi(\sigma(n))\right|\ll\frac{x^{1/2}}{(\log
x)^{1-\widetilde{\alpha}(1/4+\epsilon)}}.$

It remains to consider the characters $\chi$ mod $q$ whose conductors lie in
the set $\mathcal{S}$. For each such character, we may invoke (39), (33) and
(34) to obtain

$\sum_{\begin{subarray}{c}n\leq x\\\ P_{6}(n)>y,~{}P(n)>z\\\ p>y\implies
p^{4}\nmid n\end{subarray}}\chi(\sigma(n))=\sum_{\begin{subarray}{c}n\leq
x\end{subarray}}\chi(\sigma(n))+O\left(\frac{x^{1/2}}{(\log
x)^{1-\widetilde{\alpha}\epsilon/2}}\right).$

Recalling the observation made at the start of the proof of Lemma 5.3 along
with the bound (31), we obtain

(46) $\sum_{\begin{subarray}{c}n\leq x\\\ P_{6}(n)>y,~{}P(n)>z\\\ p>y\implies
p^{4}\nmid
n\end{subarray}}\chi(\sigma(n))=\sum_{\begin{subarray}{c}k\leq\frac{20\log\log
x}{\log
2}\end{subarray}}\chi(\sigma(2^{k}))~{}\sum_{m\leq\sqrt{x/2^{k}}}\mathbbm{1}_{2\nmid
m}~{}\chi(\sigma(m^{2}))~{}+~{}O\left(\frac{x^{1/2}}{(\log
x)^{1-\widetilde{\alpha}\epsilon/2}}\right).$

Finally, we invoke Theorem 1.1 on the multiplicative function
$m\mapsto\mathbbm{1}_{2\nmid m}~{}\chi(\sigma(m^{2}))$ to bound each of the
inner sums in the above display. Noting that $\sqrt{x/2^{k}}\geq x^{1/2}/(\log
x)^{10}>z$ and that $\eta_{\chi}$ plays the role of $\varrho$, we deduce that
the sums on $m$ in the above display are all

$\ll\frac{\sqrt{x/2^{k}}}{(\log z)^{1-\mathrm{Re}(\eta_{\chi})}}\left((\log
y)^{\widetilde{\alpha}}+\frac{(\log y)^{1+\widetilde{\alpha}}}{\log
z}\right)\exp\left(\sum_{p\leq
y}\frac{\mathbbm{1}_{(p^{2}+p+1,\,q)=1}}{p}\right)\\\
\ll\frac{x^{1/2}(\log_{2}x)^{2}}{2^{k/2}(\log
x)^{1-\widetilde{\alpha}/4-\widetilde{\alpha}\epsilon/2}}\exp\big{(}O\big{(}(\log_{2}(3q))^{O(1)}\big{)}\big{)}\ll\frac{x^{1/2}}{2^{k/2}(\log
x)^{1-\widetilde{\alpha}(1/4+\epsilon)}}.$

In the last line above, we have utilized the second assertion of Proposition
5.1 (namely that $\mathrm{Re}(\eta_{\chi})\leq\widetilde{\alpha}/4$) in
conjunction with Lemma 4.2. Summing the above bound over all $k\geq 0$ and
inserting into (46), we obtain

$\sum_{\begin{subarray}{c}n\leq x\\\ P_{6}(n)>y,~{}P(n)>z\\\ p>y\implies
p^{4}\nmid n\end{subarray}}\chi(\sigma(n))\ll\frac{x^{1/2}}{(\log
x)^{1-\widetilde{\alpha}(1/4+\epsilon)}}$

for all characters $\chi$ mod $q$ having $\mathfrak{f}(\chi)\in\mathcal{S}$.
We use this bound for each of the $O(1)$ nontrivial characters $\chi$ mod $q$
having $\mathfrak{f}(\chi)\in\mathcal{S}$ and use (45) to deal with the rest
of the characters mod $q$. Inserting these bounds into (40), we obtain the
desired estimate (35), which completes the proof of the proposition. ∎

######  Remark.

The proofs of Theorem 1.2 and Proposition 5.4 substantiate the comments
following Theorem 1.1. Note that $\varrho=-\alpha$ for the sum $\sum_{n\leq
x}\psi(\sigma(n))$ at the end of section 4, so a direct application of [14,
Theorem 1.1] (or the methods used to prove it) would be unable to detect the
negative sign of $\varrho$ and would yield a bound on this sum which would
have the same order of magnitude as the main term (by Lemma 5.3). A similar
phenomenon takes place in the proof of Proposition 5.4 for the sums of
$\chi(\sigma(n))$ for the characters $\chi$ having conductors in the set
$\mathcal{S}$. On the other hand, we cannot apply this paper’s Theorem 1.1 for
all the nontrivial characters $\chi$ mod $q$, for if we did, then the terms
with $(\log y)^{1+|\varrho|}$ in Theorem 1.1 would culminate into a large
error term that would stand in the way of achieving uniformity in $q$ up to
(fixed) large powers of $\log x$.

##  6\. Distribution of the sum-of-divisors function to general even moduli:
Proof of Theorem 1.3

We continue with $y$ and $z$ as defined in the previous section. Note that the
right hand sides of (3) and (32) are equal up to a negligible error: indeed
any $n$ having $P_{6}(n)\leq q$ also has $P_{6}(n)\leq y$, so that by (33),
(34) and (39), the contribution of all such $n$ to the right hand side of (3)
is absorbed in the error term. By Proposition 5.4, it thus suffices to show
that

(47) $\sum_{\begin{subarray}{c}n\leq x:~{}q<P_{6}(n)\leq y\\\
P(n)>z;~{}p>y\implies p^{4}\nmid n\\\ \sigma(n)\equiv
a\pmod{q}\end{subarray}}1\ll\frac{x^{1/2}}{\varphi(q)(\log
x)^{1-\widetilde{\alpha}\epsilon/2}}$

in order to complete the proof of Theorem 1.3.

We write the left hand side of (47) as $\Sigma_{1}+\Sigma_{2}$, where
$\Sigma_{1}$ denotes the count of the $n$ contributing to the sum in (47)
which are divisible by the fourth power of a prime exceeding $q$. First
consider the contribution of the $n$ counted in $\Sigma_{1}$. As before, the
coprimality of $\sigma(n)$ with $q$ guarantees that we can write
$n=2^{k}m^{2}$ for some $k\geq 0$ and some odd $m$ satisfying
$P_{6}(m^{2})\leq y$. Since $n$ is divisible by the fourth power of a prime
exceeding $q$, it follows that the squarefull part of $m$ (i.e., the largest
squarefull divisor of $m$) is divisible by a prime exceeding $q$. Hence $m$
can be written in the form $rSP$, with $r,S,P$ being pairwise coprime and
satisfying $P_{2}(r)\leq y$, $P=P(n)>z$ and with $S>q^{2}$ being squarefull.
Altogether, we find that

(48) $\begin{split}\Sigma_{1}&\leq\sum_{\begin{subarray}{c}n\leq
x:~{}P_{6}(n)\leq y\\\ P(n)>z;~{}p>y\implies p^{4}\nmid n\\\ \exists
p>q:~{}p^{4}|n\\\ \sigma(n)\equiv a\pmod{q}\end{subarray}}1\leq\sum_{k\geq
0}~{}\sum_{\begin{subarray}{c}r\leq x^{1/2}:~{}P_{2}(r)\leq y\\\ p>y\implies
p^{2}\nmid r\\\
(\sigma(r^{2}),q)=1\end{subarray}}~{}\sum_{\begin{subarray}{c}S>q^{2}\\\
S\text{ squarefull}\end{subarray}}~{}\sum_{z<P\leq
x^{1/2}\big{/}2^{k/2}rS}1\\\ &\ll\frac{x^{1/2}}{\log z}\sum_{k\geq
0}\frac{1}{2^{k/2}}~{}\sum_{\begin{subarray}{c}r\leq x^{1/2}:~{}P_{2}(r)\leq
y\\\
(\sigma(r^{2}),q)=1\end{subarray}}\frac{1}{r}~{}\sum_{\begin{subarray}{c}S>q^{2}\\\
S\text{ squarefull}\end{subarray}}\frac{1}{S}\ll\frac{x^{1/2}\log_{2}x}{q\log
x}\sum_{\begin{subarray}{c}r\leq x^{1/2}:~{}P_{2}(r)\leq y\\\
(\sigma(r^{2}),q)=1\end{subarray}}\frac{1}{r}\ll\frac{x^{1/2}}{q(\log
x)^{1-\widetilde{\alpha}\epsilon/2}},\end{split}$

where have used (38) and the standard bound $\sum_{S>q^{2}\text{ squarefull
}}1/S\ll 1/q$. Since the last expression above is absorbed in the right hand
side of (47), it remains to show that the same is true for the sum
$\Sigma_{2}$.

Now any $n$ counted in $\Sigma_{2}$ has $P_{6}(n)>q$ but is not divisible by
the fourth power of a prime exceeding $q$. Invoking the observation at the
start of the proof of Lemma 5.3, we find that any such $n$ can be written in
the form $2^{k}r^{2}(P_{1}P_{2}P_{3})^{2}$, where $k\geq 0$, $P_{2}(r)\leq y$,
and $P_{1}$, $P_{2}$, $P_{3}$ are primes satisfying $P_{1}=P(n)>z$,
$q<P_{3}<P_{2}<P_{1}$, and
$\sigma(n)=\sigma(2^{k})\sigma(r^{2})\prod_{j=1}^{3}(P_{j}^{2}+P_{j}+1)$.
Given $k$ and $r$, the congruence $\sigma(n)\equiv a\pmod{q}$ forces
$(P_{1},P_{2},P_{3})$ mod $q$ $\in\mathcal{V}_{q}(a\sigma(2^{k}r^{2})^{-1})$,
where $u^{-1}$ denotes the multiplicative inverse of a coprime residue $u$ mod
$q$, and for any coprime residue $w$ mod $q$, we have defined

$\mathcal{V}_{q}(w)\coloneqq\left\\{(v_{1},v_{2},v_{3})\in
U_{q}^{3}:~{}\prod_{j=1}^{3}(v_{j}^{2}+v_{j}+1)\equiv w\pmod{q}\right\\}.$

(Recall that $U_{q}$ denotes the group of units modulo $q$.) Given $k,r$ and
$(v_{1},v_{2},v_{3})\in\mathcal{V}_{q}(a\sigma(2^{k}r^{2})^{-1})$, we bound
the number of possible choices of $P_{1},P_{2},P_{3}$ which satisfy
$(P_{1},P_{2},P_{3})\equiv(v_{1},v_{2},v_{3})\bmod q$. Given $P_{2}$ and
$P_{3}$, the number of possible $P_{1}\in(z,x^{1/2}/2^{k/2}rP_{2}P_{3}]$
satisfying $P_{1}\equiv v_{1}\pmod{q}$ is, by the Brun-Titichmarsh inequality,

$\ll\frac{x^{1/2}/2^{k/2}rP_{2}P_{3}}{\varphi(q)\log(z/q)}\ll\frac{x^{1/2}\log_{2}x}{\varphi(q)\log
x}\cdot\frac{1}{2^{k/2}rP_{2}P_{3}}.$

We now sum this bound over all $P_{2},P_{3}\in(q,x]$ satisfying $P_{2}\equiv
v_{2}\pmod{q}$ and $P_{3}\equiv v_{3}\pmod{q}$. By Brun-Titchmarsh and partial
summation, we have

$\sum_{\begin{subarray}{c}q<p\leq x\\\ p\equiv
v\pmod{q}\end{subarray}}\frac{1}{p}\ll\frac{\log_{2}x}{\varphi(q)}.$

Applying this to the sums on $P_{2}$ and $P_{3}$, we find that given $k,r$ and
$(v_{1},v_{2},v_{3})\in\mathcal{V}_{q}(a\sigma(2^{k}r^{2})^{-1})$, the number
of possible $P_{1},P_{2},P_{3}$ satisfying
$(P_{1},P_{2},P_{3})\equiv(v_{1},v_{2},v_{3})\bmod q$ is

$\ll\frac{1}{\varphi(q)^{3}}\cdot\frac{x^{1/2}(\log_{2}x)^{3}}{2^{k/2}r\log
x}.$

Now let $V_{q}\coloneqq\max\\{\\#\mathcal{V}_{q}(w):w\in U_{q}\\}$. Summing
the above bound over all
$(v_{1},v_{2},v_{3})\in\mathcal{V}_{q}(a\sigma(2^{k}r^{2})^{-1})$, and
subsequently over all $k$ and $r$, we obtain

(49)
$\Sigma_{2}\ll\frac{V_{q}}{\varphi(q)^{3}}\cdot\frac{x^{1/2}(\log_{2}x)^{4}}{(\log
x)^{1-\widetilde{\alpha}\epsilon/4}}\exp\big{(}O\big{(}(\log_{2}(3q))^{O(1)}\big{)}\big{)}.$

To bound $V_{q}$, we consider an arbitrary coprime residue $w$ mod $q$, and
note that $\\#\mathcal{V}_{q}(w)=\prod_{\ell^{e}\parallel
q}\\#\mathcal{V}_{\ell^{e}}(w)$ by the Chinese Remainder Theorem. Moreover, by
orthogonality,

$\begin{split}\\#\mathcal{V}_{\ell^{e}}(w)&=\sum_{v_{1},v_{2},v_{3}\bmod\ell^{e}}\chi_{0,\ell}(v_{1}v_{2}v_{3})\cdot\frac{1}{\varphi(\ell^{e})}\sum_{\chi\bmod\ell^{e}}\overline{\chi}(w)\chi\left(\prod_{j=1}^{3}(v_{j}^{2}+v_{j}+1)\right)\\\
&=\frac{(\widetilde{\alpha}(\ell)\varphi(\ell^{e}))^{3}}{\varphi(\ell^{e})}\left\\{1+\frac{1}{(\widetilde{\alpha}(\ell)\varphi(\ell^{e}))^{3}}\sum_{\chi\neq\chi_{0,\ell}\bmod\ell^{e}}\overline{\chi}(w)\left(\sum_{v\bmod\ell^{e}}\chi_{0,\ell}(v)\chi(v^{2}+v+1)\right)^{3}\right\\}.\end{split}$

Given $\chi\neq\chi_{0,\ell}$ mod $\ell^{e}$, let $\ell^{e_{0}}$ denote the
conductor of $\chi$, so that $e_{0}\in\\{1,\dots,\ell^{e}\\}$. Then with
$\chi$ also denoting the primitive character mod $\ell^{e_{0}}$ inducing
$\chi$, the computations and arguments in (25), (26) and (27) reveal that if
$\ell\geq 5$, then

$\begin{split}\left|\sum_{v\bmod\ell^{e}}\chi_{0,\ell}(v)\chi(v^{2}+v+1)\right|=\ell^{e-e_{0}}\left|\sum_{v\bmod\ell^{e_{0}}}\chi(v^{2}+v+1)-\mathbbm{1}_{e_{0}=1}\right|\ll\ell^{e-e_{0}}\cdot\ell^{e_{0}/2}\ll\ell^{e-e_{0}/2}.\end{split}$

Since there are at most $\varphi(\ell^{e_{0}})$ characters mod $\ell^{e}$ with
conductor $\ell^{e_{0}}$, we obtain

$\\#\mathcal{V}_{\ell^{e}}(w)=\frac{(\widetilde{\alpha}(\ell)\varphi(\ell^{e}))^{3}}{\varphi(\ell^{e})}\left\\{1+O\left(\frac{1}{\varphi(\ell^{e})^{3}}\sum_{1\leq
e_{0}\leq
e}\varphi(\ell^{e_{0}})~{}(\ell^{e-e_{0}/2})^{3}\right)\right\\}\leq\frac{\varphi(\ell^{e})^{3}}{\varphi(\ell^{e})}\left\\{1+O\left(\frac{1}{\ell^{1/2}}\right)\right\\},$

where we have recalled that for each odd prime $\ell$ dividing $q$, we have
$\widetilde{\alpha}(\ell)\geq 1-2/(\ell-1)\geq 1/2$. Letting $e_{1}\coloneqq
v_{2}(q)$ and multiplying the above bound over all the odd primes dividing
$q$, we obtain

$\frac{\\#\mathcal{V}_{q}(w)}{\varphi(q)^{3}}\leq\frac{\\#\mathcal{V}_{2^{e_{1}}}(w)}{\varphi(2^{e_{1}})^{3}}~{}\prod_{\begin{subarray}{c}\ell^{e}\parallel
q\\\
\ell>2\end{subarray}}\frac{1}{\varphi(\ell^{e})}\left(1+O\left(\frac{1}{\ell^{1/2}}\right)\right)\leq\frac{\\#\mathcal{V}_{2^{e_{1}}}(w)}{\varphi(2^{e_{1}})^{2}}\cdot\frac{1}{\varphi(q)}\exp(O(\sqrt{\log
q}))$

uniformly in coprime residues $w$ mod $q$. Finally, recalling (from the proof
of Proposition 5.1) that the map $v\mapsto v^{2}+v+1$ is a bijection on the
multiplicative group mod $2^{e_{1}}$, we see that

(50)
$\\#\mathcal{V}_{2^{e_{1}}}(w)=\sum_{\begin{subarray}{c}a_{1},a_{2},a_{3}\bmod
2^{e_{1}}\\\ a_{1}a_{2}a_{3}\equiv
w\pmod{2^{e_{1}}}\end{subarray}}1=\sum_{\begin{subarray}{c}a_{1},a_{2}\bmod
2^{e_{1}}\\\ \gcd(a_{1}a_{2},2)=1\end{subarray}}1=\varphi(2^{e_{1}})^{2},$

leading to the bound

$\frac{\\#\mathcal{V}_{q}(w)}{\varphi(q)^{3}}\leq\frac{1}{\varphi(q)}\exp(O(\sqrt{\log
q}))$

uniformly in coprime residues $w$ mod $q$. Hence this bound also holds true
for the ratio $V_{q}/\varphi(q)^{3}$, and inserting this latter bound into
(49) we obtain

$\Sigma_{2}\ll\frac{x^{1/2}(\log_{2}x)^{4}}{\varphi(q)(\log
x)^{1-\widetilde{\alpha}\epsilon/4}}\exp(O(\sqrt{\log
q}))\ll\frac{x^{1/2}}{\varphi(q)(\log x)^{1-\widetilde{\alpha}\epsilon/2}},$

showing that $\Sigma_{2}$ is also absorbed into the right hand side of (47)
and completing the proof of Theorem 1.3. ∎

###  6.1. Optimality in the restriction $P_{6}(n)>q$.

We construct a counterexample establishing that the restriction $P_{6}(n)>q$
is optimal, in the sense that uniformity in $q\leq(\log x)^{K}$ fails if this
restriction is weakened or in other words, if the set of inputs $n$ is even
slightly enlarged to those having fewer than $6$ prime factors exceeding $q$.
To do this, we define

(51) $\widetilde{\mathcal{V}}_{q}(w)\coloneqq\left\\{(v_{1},v_{2})\in
U_{q}\times U_{q}:~{}(v_{1}^{2}+v_{1}+1)(v_{2}^{2}+v_{2}+1)\equiv
w\pmod{q}\right\\}.$

We shall first establish that

(52) $\\#\widetilde{\mathcal{V}}_{\ell^{2}}(9\cdot 16^{-1})\geq
2\ell^{2}\left(1+O\left(\frac{1}{\sqrt{\ell}}\right)\right)$

uniformly in primes $\ell\geq 5$, with $16^{-1}$ denoting the multiplicative
inverse of $16$ mod $\ell$. For each
$(v_{1},v_{2})\in\widetilde{\mathcal{V}}_{\ell^{2}}(9\cdot 16^{-1})$, we set
$a_{i}\equiv v_{i}^{2}+v_{i}+1\pmod{\ell^{2}}$, which is equivalent to
$(2v_{i}+1)^{2}\equiv 4a_{i}-3\pmod{\ell^{2}}$. As such, we may write

(53) $\\#\widetilde{\mathcal{V}}_{\ell^{2}}(9\cdot
16^{-1})=\sum_{\begin{subarray}{c}(a_{1},a_{2})\in U_{\ell^{2}}\times
U_{\ell^{2}}\\\ a_{1}a_{2}\equiv 9\cdot 16^{-1}\pmod{\ell^{2}}\\\
\text{each}~{}4a_{i}-3\text{ is a square mod
}\ell^{2}\end{subarray}}~{}~{}~{}\sum_{\begin{subarray}{c}(v_{1},v_{2})\in
U_{\ell^{2}}\times U_{\ell^{2}}\\\ \text{each}~{}(2v_{i}+1)^{2}\equiv
4a_{i}-3\pmod{\ell^{2}}\end{subarray}}1\geq S_{1}+S_{2},$

where $S_{1}$ denotes the contribution of the case $4a_{1}-3\equiv
4a_{2}-3\equiv 0\pmod{\ell^{2}}$ and $S_{2}$ denotes the contribution of the
case $\ell\nmid(4a_{1}-3)(4a_{2}-3)$.

First of all, we see that

(54) $S_{1}=\sum_{\begin{subarray}{c}(v_{1},v_{2})\in U_{\ell^{2}}\times
U_{\ell^{2}}\\\ \text{each}~{}(2v_{i}+1)^{2}\equiv
0\pmod{\ell^{2}}\end{subarray}}1=\sum_{\begin{subarray}{c}(v_{1},v_{2})\in
U_{\ell^{2}}\times U_{\ell^{2}}\\\
\text{each}~{}v_{i}\equiv-2^{-1}\pmod{\ell}\end{subarray}}1=\ell^{2}.$

We seek to put a lower bound on the sum $S_{2}$. To do this, we first note
that the condition $\ell\nmid(4a_{1}-3)(4a_{2}-3)$ in conjunction with the
condition that $4a_{1}-3$ and $4a_{2}-3$ are both squares mod $\ell^{2}$ are
together equivalent to the condition that
$\left(\frac{4a_{1}-3}{\ell}\right)=\left(\frac{4a_{2}-3}{\ell}\right)=1$;
indeed the forward direction is tautological, while the reverse implication is
a consequence of Hensel’s Lemma. In fact by the same lemma, we see that for
each choice of $a_{i}\in U_{\ell}^{2}$ satisfying
$\left(\frac{4a_{i}-3}{\ell}\right)=1$, the congruence $t^{2}\equiv
4a_{i}-3\pmod{\ell^{2}}$ has exactly two distinct solutions $t$ mod
$\ell^{2}$. If $a_{i}\not\equiv 1\pmod{\ell}$, then $4a_{i}-3\not\equiv
1\pmod{\ell}$, so that $t\not\equiv 1\pmod{\ell}$ for both of the two
aforementioned solutions, and each of them leads to a unique solution
$v_{i}\in U_{\ell^{2}}$ (given by $2v_{i}+1\equiv t\pmod{\ell^{2}}$).
Summarizing our argument, we have shown that

$S_{2}\geq\sum_{\begin{subarray}{c}(a_{1},a_{2})\in U_{\ell^{2}}\times
U_{\ell^{2}}\\\ a_{1}a_{2}\equiv 9\cdot 16^{-1}\pmod{\ell^{2}}\\\
\left(\frac{4a_{1}-3}{\ell}\right)=\left(\frac{4a_{2}-3}{\ell}\right)=1\end{subarray}}~{}~{}~{}\sum_{\begin{subarray}{c}(v_{1},v_{2})\in
U_{\ell^{2}}\times U_{\ell^{2}}\\\ \text{each}~{}(2v_{i}+1)^{2}\equiv
4a_{i}-3\pmod{\ell^{2}}\end{subarray}}1\geq
4\sum_{\begin{subarray}{c}(a_{1},a_{2})\in U_{\ell^{2}}\times U_{\ell^{2}}\\\
16a_{1}a_{2}\equiv 9\pmod{\ell^{2}}\\\ \text{each}~{}a_{i}\not\equiv
1\pmod{\ell},~{}\left(\frac{4a_{i}-3}{\ell}\right)=1\end{subarray}}1.$

Now the condition $a_{1}a_{2}\equiv 9\cdot 16^{-1}\pmod{\ell^{2}}$ shows that
if $a_{1}\equiv 1\pmod{\ell}$, then $a_{2}\equiv 9\cdot 16^{-1}\pmod{\ell}$
which can be lifted to a residue class mod $\ell^{2}$ in at most $\ell$ ways.
This shows that ignoring the condition $``\text{each}~{}a_{i}\not\equiv
1\pmod{\ell}$” in the last sum in the above display incurs an error of
$O(\ell)$. We deduce that

$S_{2}\geq 4\sum_{\begin{subarray}{c}(a_{1},a_{2})\in U_{\ell^{2}}\times
U_{\ell^{2}}\\\ 16a_{1}a_{2}\equiv 9\pmod{\ell^{2}}\\\
\left(\frac{4a_{1}-3}{\ell}\right)=\left(\frac{4a_{2}-3}{\ell}\right)=1\end{subarray}}1+O(\ell).$

Moreover, for any $a_{i}\in U_{\ell^{2}}$ satisfying
$\left(\frac{4a_{i}-3}{\ell}\right)=1$, we can write $4a_{i}-3$ in the form
$u_{i}^{2}+\ell c_{i}$ $\pmod{\ell^{2}}$ for some
$u_{i},c_{i}\in\\{0,1,\dots,\ell-1\\}$ such that $\gcd(u_{i},\ell)=1$. In
fact, given $a_{i}$, there are exactly two possible choices of $u_{i}$ and
exactly one possible choice of $c_{i}$ (this is because $u_{i}$ can only be
one of the two square roots of $4a_{i}-3$ mod $\ell$, and either of them
determines the same value of $c_{i}$ via the congruence
$c_{i}\equiv\frac{4a_{i}-3-u_{i}^{2}}{\ell}$ mod $\ell$). Hence

(55) $S_{2}\geq\sum_{\begin{subarray}{c}(u_{1},u_{2})\in U_{\ell}\times
U_{\ell}\\\ (u_{1}^{2}+3)(u_{2}^{2}+3)\equiv
9\pmod{\ell}\end{subarray}}~{}\sum_{\begin{subarray}{c}(c_{1},c_{2})\in\mathbb{Z}/\ell\mathbb{Z}\times\mathbb{Z}/\ell\mathbb{Z}\\\
c_{1}(u_{2}^{2}+3)+c_{2}(u_{1}^{2}+3)\equiv\frac{9-(u_{1}^{2}+3)(u_{2}^{2}+3)}{\ell}\pmod{\ell}\end{subarray}}1+O(\ell),$

where we have noted that since $4a_{i}\equiv u_{i}^{2}+3+\ell
c_{i}\pmod{\ell^{2}}$, the condition $(u_{1}^{2}+3+\ell
c_{1})(u_{2}^{2}+3+\ell c_{2})\equiv 16a_{1}a_{2}\equiv 9\pmod{\ell^{2}}$ can
be rewritten as $\ell(c_{1}(u_{2}^{2}+3)+c_{2}(u_{1}^{2}+3))\equiv
9-(u_{1}^{2}+3)(u_{2}^{2}+3)\pmod{\ell^{2}}$. Now given $c_{1}$, the
congruence involving $c_{1}$ and $c_{2}$ in (55) determines $c_{2}$ uniquely
mod $\ell$. Varying $c_{1}$ over the $\ell$ possibilities, we thus find that

(56) $S_{2}\geq\ell\sum_{\begin{subarray}{c}(u_{1},u_{2})\in U_{\ell}\times
U_{\ell}\\\ (u_{1}^{2}+3)(u_{2}^{2}+3)\equiv
9\pmod{\ell}\end{subarray}}1+O(\ell)=\ell\sum_{\begin{subarray}{c}(u_{1},u_{2})\in\mathbb{F}_{\ell}\times\mathbb{F}_{\ell}\\\
(u_{1}^{2}+3)(u_{2}^{2}+3)=9\text{ in
}\mathbb{F}_{\ell}\end{subarray}}1+O(\ell),$

where in the last equality above, we have noted that there is exactly one
possible tuple $(u_{1},u_{2})\in\mathbb{F}_{\ell}\times\mathbb{F}_{\ell}$
satisfying $(u_{1}^{2}+3)(u_{2}^{2}+3)=9\text{ in }\mathbb{F}_{\ell}$, in
which either $u_{1}$ or $u_{2}$ is zero (namely the tuple
$(u_{1},u_{2})=(0,0)$).

In order to estimate the last sum in (56), we proceed in a manner similar to
the proof of Theorem 1.4(b) in [16]: we first show that the polynomial
$G(X,Y)\coloneqq(X^{2}+3)(Y^{2}+3)-9$ is absolutely irreducible over
$\mathbb{F}_{\ell}[X,Y]$. 111While this claim follows from the absolute
irreducibility established in the proof of [16, Theorem 1.4(b)], we shall give
a more straightforward self-contained argument that suffices for our current
setting. Indeed, assume that $G=UV$ for some
$U,V\in\overline{\mathbb{F}}_{\ell}[X,Y]$; we wish to show that one of $U$ or
$V$ must be constant. If either $U$ or $V$ is a polynomial only in $Y$ (say
$U(X,Y)=u(Y)$), then taking $X$ to be a root
$\theta\in\overline{\mathbb{F}}_{\ell}$ of the polynomial $X^{2}+3$ on both
sides of the identity $G=UV$, we obtain $-9=G(\theta,Y)=u(Y)V(\theta,Y)$ in
the ring $\overline{\mathbb{F}}_{\ell}[Y]$, showing that $U(X,Y)=u(Y)$ must be
constant. On the other hand, if neither $U$ nor $V$ is a polynomial in $Y$
only, then by comparing the degrees in the variable $X$ on both sides of the
identity $H=UV$, we find that $U(X,Y)=u_{1}(Y)X+u_{0}(Y)$ and
$V(X,Y)=v_{1}(Y)X+v_{0}(Y)$ for some
$u_{i},v_{i}\in\overline{\mathbb{F}}_{\ell}[Y]$. Comparing the coefficients of
$X$ on both sides of the identity

$(Y^{2}+3)(X^{2}+3)-9=(u_{1}(Y)X+u_{0}(Y))(v_{1}(Y)X+v_{0}(Y)),$

we get the three identities $u_{1}(Y)v_{1}(Y)=Y^{2}+3$,
$u_{1}(Y)v_{0}(Y)+u_{0}(Y)v_{1}(Y)=0$ and $u_{0}(Y)v_{0}(Y)=3Y^{2}$. Again,
letting $\theta\in\overline{\mathbb{F}}_{\ell}$ be a root of the polynomial
$Y^{2}+3$, the first of the three identities shows that $Y-\theta$ divides
exactly one of $u_{1}$ or $v_{1}$ (as the polynomial $Y^{2}+3$ is separable
over $\mathbb{F}_{\ell}$). Assuming without loss of generality that
$(Y-\theta)\mid u_{1}(Y)$ (so that $\gcd(Y-\theta,v_{1}(Y))=1$), the second of
the aforementioned identities forces $Y-\theta$ to divide $u_{0}(Y)$, leading
to a contradiction in the third identity (since $3\theta^{2}=-9\neq 0$ in
$\overline{\mathbb{F}}_{\ell}$). This establishes that $G$ is indeed
absolutely irreducible over $\mathbb{F}_{\ell}[X,Y]$.

Consequently, the variant of the Weil bound established in [11, Corollary
2(b)] yields, from (56),

$S_{2}\geq\ell(\ell+O(\sqrt{\ell}))+O(\ell)=\ell^{2}\left(1+O\left(\frac{1}{\sqrt{\ell}}\right)\right).$

Combining this with (54) and (53) completes the proof of (52).

Now set $q\coloneqq 2\left(\prod_{5\leq\ell\leq Y}\ell\right)^{2}$, where
$Y\ll\log_{2}x$ is a parameter to be chosen appropriately later. Then
$q\leq(\log x)^{O(1)}$ and letting $w_{q}$ denote the unique coprime residue
mod $q$ satisfying $w_{q}\equiv 9\cdot 16^{-1}\pmod{\ell^{2}}$ for all primes
$\ell\in[5,Y]$, the lower bound (52) yields

(57) $\\#\widetilde{\mathcal{V}}_{q}(w_{q})=\prod_{5\leq\ell\leq
Y}\\#\widetilde{\mathcal{V}}_{\ell^{2}}(9\cdot 16^{-1})\gg
2^{\pi(Y)}q\prod_{5\leq\ell\leq
Y}\left(1+O\left(\frac{1}{\sqrt{\ell}}\right)\right)\gg
2^{\pi(Y)}q\exp(-C_{2}\sqrt{\log_{2}x}).$

for some absolute constant $C_{2}>0$. Now consider any integer $n$ of the form
$P_{1}^{2}P_{2}^{2}$, where $P_{1}$ and $P_{2}$ are primes satisfying
$x^{1/10}<P_{2}\leq x^{1/6}<P_{1}\leq x^{1/2}/P_{2}$ and $(P_{1},P_{2})$ mod
$q$ $\in\widetilde{\mathcal{V}}_{q}(w_{q})$. Then $n\leq x$,
$P_{4}(n)=P_{2}>x^{1/10}>q$ and
$\sigma(n)=(P_{1}^{2}+P_{1}+1)(P_{2}^{2}+P_{2}+1)\equiv w_{q}\pmod{q}$. By the
Siegel-Walfisz Theorem and partial summation, we obtain

$\begin{split}\sum_{\begin{subarray}{c}n\leq x:~{}P_{4}(n)>q\\\
\sigma(n)\equiv
w_{q}\pmod{q}\end{subarray}}1&\geq\sum_{(v_{1},v_{2})\in\widetilde{\mathcal{V}}_{q}(w_{q})}~{}\sum_{\begin{subarray}{c}x^{1/10}<P_{2}\leq
x^{1/6}\\\ P_{2}\equiv
v_{2}\pmod{q}\end{subarray}}~{}\sum_{\begin{subarray}{c}x^{1/6}<P_{1}\leq
x^{1/2}/P_{2}\\\ P_{1}\equiv v_{1}\pmod{q}\end{subarray}}1\\\
&\gg\sum_{(v_{1},v_{2})\in\widetilde{\mathcal{V}}_{q}(w_{q})}~{}\sum_{\begin{subarray}{c}x^{1/10}<P_{2}\leq
x^{1/6}\\\ P_{2}\equiv
v_{2}\pmod{q}\end{subarray}}\frac{x^{1/2}/P_{2}}{\varphi(q)\log
x}\gg\frac{\\#\widetilde{\mathcal{V}}_{q}(w_{q})}{\varphi(q)^{2}}\cdot\frac{x^{1/2}}{\log
x}.\end{split}$

An application of (57) now yields

$\sum_{\begin{subarray}{c}n\leq x:~{}P_{4}(n)>q\\\ \sigma(n)\equiv
w_{q}\pmod{q}\end{subarray}}1~{}\gg~{}\frac{2^{\pi(Y)}}{\varphi(q)}\cdot\frac{x^{1/2}}{\log
x}\exp(-C_{2}\sqrt{\log_{2}x})$

for some constant $C_{2}>0$. By Lemma 5.3, the quantity on the right hand side
above grows strictly faster than the expected main term
$\frac{1}{\varphi(q)}\sum_{\begin{subarray}{c}n\leq x\\\
(\sigma(n),q)=1\end{subarray}}1$ as soon as $2^{\pi(Y)}>(\log
x)^{(1+\delta)\widetilde{\alpha}}$ for some fixed $\delta>0$, which in turn is
equivalent to $\pi(Y)>(1+\delta)\widetilde{\alpha}\log_{2}x/\log 2$. But now
$\pi(Y)>Y/2\log Y$, while

(58)
$\begin{split}\widetilde{\alpha}(q)=\prod_{\begin{subarray}{c}5\leq\ell\leq
Y\\\ \ell\equiv
1\pmod{3}\end{subarray}}\left(1-\frac{2}{\ell-1}\right)=\exp\left(-2\sum_{\begin{subarray}{c}5\leq\ell\leq
Y\\\ \ell\equiv
1\pmod{3}\end{subarray}}\frac{1}{\ell}+O(1)\right)<\frac{K_{2}}{\log
Y}\end{split}$

for some absolute constant $K_{2}>0$, where we have used the prime number
theorem in arithmetic progressions to estimate the sum on $\ell$. As such, the
desired condition $\pi(Y)>(1+\delta)\widetilde{\alpha}\log_{2}x/\log 2$ holds
as soon as $Y>2K_{2}(1+\delta)\log_{2}x/\log 2$, which is compatible with the
only other condition $Y\ll\log_{2}x$ needed on the parameter $Y$. Choosing $Y$
accordingly, we have therefore established that the condition $P_{6}(n)>q$ in
Theorem 1.3 cannot be weakened to $P_{4}(n)>q$ in the range of uniformity in
$q$. Since the largest odd divisor of $n$ is a perfect square, it follows that
the restriction $P_{6}(n)>q$ in Theorem 1.3 is indeed optimal.

##  7\. Distribution of the sum-of-divisors function to squarefree even
moduli: Proof of Theorem 1.4

As in the beginning of the previous section, we can show that the right hand
sides of (4) and (32) are equal up to a negligible error: indeed, by previous
arguments, this only needs the following analogue and consequence of (39):

$\sum_{\begin{subarray}{c}n\leq x:~{}P_{4}(n)\leq y\\\ P(n)>z;~{}p>y\implies
p^{4}\nmid n\\\ \gcd(\sigma(n),q)=1\end{subarray}}1\ll\frac{x^{1/2}}{(\log
x)^{1-\widetilde{\alpha}\epsilon/2}}.$

Hence to complete the proof of the theorem, it suffices to show the following
analogue of (47) uniformly in squarefree even moduli $q\leq(\log x)^{K}$ and
in coprime residues $a$ mod $q$:

(59) $\sum_{\begin{subarray}{c}n\leq x:~{}q<P_{4}(n)\leq y\\\
P(n)>z;~{}p>y\implies p^{4}\nmid n\\\ \sigma(n)\equiv
a\pmod{q}\end{subarray}}1\ll\frac{x^{1/2}}{\varphi(q)(\log
x)^{1-\widetilde{\alpha}\epsilon/2}}.$

As before, we write the sum on the left hand side in the form
$\widetilde{\Sigma}_{1}+\widetilde{\Sigma}_{2}$, where
$\widetilde{\Sigma}_{1}$ denotes the contribution of the $n$ which are
divisible by the fourth power of a prime exceeding $q$. Then with $\Sigma_{1}$
as defined in the previous section, it follows by the intermediate bounds in
(48) that

$\widetilde{\Sigma}_{1}\leq\sum_{\begin{subarray}{c}n\leq x:~{}P_{4}(n)\leq
y\\\ P(n)>z;~{}p>y\implies p^{4}\nmid n\\\ \exists p>q:~{}p^{4}|n\\\
\sigma(n)\equiv a\pmod{q}\end{subarray}}1\leq\sum_{\begin{subarray}{c}n\leq
x:~{}P_{6}(n)\leq y\\\ P(n)>z;~{}p>y\implies p^{4}\nmid n\\\ \exists
p>q:~{}p^{4}|n\\\ \sigma(n)\equiv
a\pmod{q}\end{subarray}}1\ll\frac{x^{1/2}}{q(\log
x)^{1-\widetilde{\alpha}\epsilon/2}}$

is absorbed in the right hand side of (59).

In order to estimate the sum $\Sigma_{2}$, we note that any $n$ counted in
this sum has $P_{4}(n)>q$ but is not divisible by the fourth power of a prime
exceeding $q$. Consequently, as in the previous section, we may write
$n=2^{k}r^{2}(P_{1}P_{2})^{2}$ where $k\geq 0$, $P_{2}(r)\leq y$, and $P_{1}$,
$P_{2}$ are primes satisfying $P_{1}=P(n)>z$, $q<P_{2}<P_{1}$, and
$\sigma(n)=\sigma(2^{k})\sigma(r^{2})\prod_{j=1}^{2}(P_{j}^{2}+P_{j}+1)$.
Given $k$ and $r$, the congruence $\sigma(n)\equiv a\pmod{q}$ forces
$(P_{1},P_{2})$ mod $q$
$\in\widetilde{\mathcal{V}}_{q}(a\sigma(2^{k}r^{2})^{-1})$, where
$\widetilde{\mathcal{V}}_{q}(w)$ is as defined in (51) for any coprime residue
$w$ mod $q$. Hereafter, setting
$\widetilde{V}_{q}\coloneqq\max\\{\\#\widetilde{\mathcal{V}}_{q}(w):~{}w\in
U_{q}\\}$ and replicating the arguments leading to (49) gives the following
analogue of the latter bound:

(60)
$\widetilde{\Sigma}_{2}\ll\frac{\widetilde{V}_{q}}{\varphi(q)^{2}}\cdot\frac{x^{1/2}(\log_{2}x)^{3}}{(\log
x)^{1-\widetilde{\alpha}\epsilon/4}}\exp\big{(}O\big{(}(\log_{2}(3q))^{O(1)}\big{)}\big{)}.$

Now since $q$ is squarefree, we may write
$\\#\widetilde{\mathcal{V}}_{q}(w)=\prod_{\ell\mid
q}\\#\widetilde{\mathcal{V}}_{\ell}(w)$ for any coprime residue $w$ mod $q$.
Here $\\#\widetilde{\mathcal{V}}_{\ell}(w)$ is no more than the number of
$\mathbb{F}_{\ell}$-rational points of the polynomial
$H(X,Y)\coloneqq(X^{2}+X+1)(Y^{2}+Y+1)-w$. We claim that this latter number is
no more than $\varphi(\ell)(1+O(\ell^{-1/2}))$. By a computation similar to
(50), this is true for $\ell=2$ (without the multiplicative error term), so we
may consider the case $\ell\geq 5$. But in fact, an argument entirely
analogous to that given for the polynomial $(X^{2}+3)(Y^{2}+3)-9$ in
subsection 6.1, shows that the polynomial $H$ is absolutely irreducible over
$\mathbb{F}_{\ell}[X,Y]$. (Here again, it is important that $w\neq
0\in\overline{\mathbb{F}}_{\ell}$ and that since $\ell\geq 5$, the polynomial
$Y^{2}+Y+1$ is separable over $\mathbb{F}_{\ell}$.) As such, [11, Corollary
2(b)] establishes our claim.

As a consequence, we obtain
$\\#\widetilde{\mathcal{V}}_{q}(w)\leq\prod_{\ell\mid
q}\varphi(\ell)(1+O(\ell^{-1/2}))\leq\varphi(q)\exp(O(\sqrt{\log q}))$
uniformly in coprime residues $w$ mod $q$. The same bound thus continues to
hold for $\widetilde{V}_{q}$, and (60) shows that $\widetilde{\Sigma}_{2}$ is
also absorbed in the right hand side of (59), completing the proof of the
theorem.

###  7.1. Optimality in the restriction $P_{4}(n)>q$.

The restriction $P_{4}(n)>q$ is crucial and optimal in the sense that weak
equidistribution fails (in the range of uniformity in $q$ provided in the
theorem) as soon as one enlarges the set of inputs $n$ to those having fewer
prime factors exceeding $q$. Indeed, let $q\coloneqq 2\prod_{5\leq\ell\leq
Y}\ell$ for some parameter $Y\ll\log_{2}x$ to be chosen appropriately. For a
prime $P\in(q,x^{1/2}]$, the congruence $\sigma(P^{2})\equiv 3\pmod{q}$ holds
for $P$ lying in exactly $2^{\omega(q)-1}$ distinct coprime residue classes
modulo $q$ (namely those lying in the residue classes $-2$ or $1$ modulo each
of the odd prime divisors of $q$). As such, by the Siegel-Walfiz theorem,
there are $\gg\frac{2^{\omega(q)}}{\varphi(q)}\frac{x^{1/2}}{\log x}$ many
integers $n\leq x$ having $P_{2}(n)>q$ and $\sigma(n)\equiv 3\pmod{q}$, coming
only from the squares of the primes lying in the interval $(x^{1/4},x^{1/2}]$.
By (30), the coprime residue class $3$ mod $q$ will be over-represented as
soon as $2^{\omega(q)}>(\log{x})^{(1+\delta)\widetilde{\alpha}(q)}$ for a
fixed $\delta>0$. By the same computation as in (58), we have
$\widetilde{\alpha}(q)\ll 1/\log Y$, whereas $\omega(q)\geq Y/2\log Y$. The
inequality $2^{\omega(q)}>(\log{x})^{(1+\delta)\widetilde{\alpha}(q)}$ is thus
ensured as soon as we choose $Y>K_{1}\log_{2}x$ for some appropriate constant
$K_{1}>0$, a condition that is consistent with the only requirement
$Y\ll\log_{2}x$ on $Y$. This shows that the restriction $P_{2}(n)>q$ is
inadequate to get weak equidistribution to moduli varying up to a fixed
arbitrary power of $\log x$. Since $n$ is of the form $2^{k}m^{2}$ for some
odd $m$, it follows that the restriction $P_{4}(n)>q$ in Theorem 1.3 is
optimal.

######  Remark.

The above example may be compared with the one given in the discussion
following the statement of Theorem 1.3 in [16].

## Acknowledgements

This work was done in partial fulfillment of my PhD at the University of
Georgia. As such, I would like to thank my advisor, Prof. Paul Pollack, for
useful discussions and valuable comments. I would also like to thank the
Department of Mathematics at UGA for their support and hospitality.

## References

  * [1] S. Balasuriya, W. D. Banks, and I. E. Shparlinski, _Congruences and exponential sums with the sum of aliquot divisors function_ , Int. J. Number Theory 4 (2008), 903–909.
  * [2] S. Balasuriya and F. Luca, _Character sums with the aliquot divisors function_ , Unif. Distrib. Theory 2 (2007), 121–138.
  * [3] S. Balasuriya, I. E. Shparlinski, and D. Sutantyo, _Multiplicative character sums with the Euler function_ , Studia Sci. Math. Hungar. 46 (2009), 223–229.
  * [4] W. D. Banks and I. E. Shparlinski, _Congruences and exponential sums with the Euler function_ , High primes and misdemeanours: lectures in honour of the 60th birthday of Hugh Cowie Williams, Fields Inst. Commun., vol. 41, Amer. Math. Soc., Providence, RI, 2004, pp. 49–59.
  * [5] by same author, _Congruences and rational exponential sums with the Euler function_ , Rocky Mountain J. Math. 36 (2006), 1415–1426.
  * [6] B. Chang and G. Martin, _The smallest invariant factor of the multiplicative group_ , Int. J. Number Theory 16 (2020), no. 6, 1377–1405.
  * [7] T. Cochrane, C. L. Liu, and Z. Y. Zheng, _Upper bounds on character sums with rational function entries_ , Acta Math. Sin. (Engl. Ser.) 19 (2003), 327–338.
  * [8] D. Goldfeld, _On an additive prime divisor function of Alladi and Erdős_ , Analytic number theory, modular forms and $q$-hypergeometric series, Springer Proc. Math. Stat., vol. 221, Springer, Cham, 2017, pp. 297–309.
  * [9] G. Halász, _Über die Mittelwerte multiplikativer zahlentheoretischer Funktionen_ , Acta Math. Acad. Sci. Hungar. 19 (1968), 365–403.
  * [10] N. Lebowitz-Lockard, P. Pollack, and A. Singha Roy, _Distribution mod $p$ of Euler’s totient and the sum of proper divisors_, Michigan Math. J., to appear.
  * [11] D. B. Leep and C. C. Yeomans, _The number of points on a singular curve over a finite field_ , Arch. Math. (Basel) 63 (1994), 420–426.
  * [12] W. Narkiewicz, _On distribution of values of multiplicative functions in residue classes_ , Acta Arith. 12 (1967), 269–279.
  * [13] by same author, _Uniform distribution of sequences of integers in residue classes_ , Lecture Notes in Mathematics, vol. 1087, Springer-Verlag, Berlin, 1984.
  * [14] P. Pollack and A. Singha Roy, _Mean values of multiplicative functions and applications to residue-class distribution_ , submitted.
  * [15] by same author, _Joint distribution in residue classes of polynomial-like multiplicative functions_ , Acta Arith. 202 (2022), 89–104.
  * [16] by same author, _Distribution in coprime residue classes of polynomially-defined multiplicative functions_ , Math. Z. 303 (2023), no. 4, Paper No. 93, 20 pages.
  * [17] E. J. Scourfield, _Uniform estimates for certain multiplicative properties_ , Monatsh. Math. 97 (1984), 233–247.
  * [18] by same author, _A uniform coprimality result for some arithmetic functions_ , J. Number Theory 20 (1985), 315–353.
  * [19] J. Śliwa, _On distribution of values of $\sigma(n)$ in residue classes_, Colloq. Math. 27 (1973), 283–291, 332.
  * [20] G. Tenenbaum, _Introduction to analytic and probabilistic number theory_ , third ed., Graduate Studies in Mathematics, vol. 163, American Mathematical Society, Providence, RI, 2015.
  * [21] D. Wan, _Generators and irreducible polynomials over finite fields_ , Math. Comp. 66 (1997), no. 219, 1195–1212.