                                             AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER
                                                                     CONJECTURE

                                                           DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG
arXiv:2404.14628v2 [math.NT] 20 Sep 2024




                                                   A BSTRACT. We prove a quantitative version of the Duffin–Schaeffer conjecture       P∞with an almost
                                                   sharp error term. Precisely, let ψ : N → [0, 1/2] be a function such that the series q=1 ϕ(q)ψ(q)/q
                                                   diverges. In addition, given α ∈ R and Q ⩾ 1, let N (α; Q) be the number          P of coprime pairs
                                                   (a, q) ∈ Z × N with q ⩽ Q and |α − a/q| < ψ(q)/q. Lastly, let Ψ(Q) = q⩽Q 2ϕ(q)ψ(q)/q,
                                                   which is the expected value of N (α; Q) when α is uniformly chosen from [0, 1]. We prove that
                                                   N (α; Q) = Ψ(Q) + Oα,ε (Ψ(Q)1/2+ε ) for almost all α (in the Lebesgue sense) and for every fixed
                                                   ε > 0. This improves upon results of Koukoulopoulos–Maynard and of Aistleitner–Borda–Hauke.




                                                                                         1. I NTRODUCTION
                                                                    Khintchine [21] states that if ψ : N → [0, 1/2] is a function such that qψ(q)
                                              A classical result of P
                                           is non-increasing and q ψ(q) = ∞, then for almost all α ∈ R (that is, for α in a set of full
                                           Lebesgue measure) there are infinitely many pairs (a, q) ∈ Z × N such that
                                                                                                 a   ψ(q)
                                           (1.1)                                           α−      <      .
                                                                                                 q    q
                                                           P
                                           Conversely, if q ψ(q) < ∞ then the Borel–Cantelli lemma implies that for almost all α ∈ R there
                                           are only finitely many pairs (a, q) ∈ Z×N satisfying (1.1). Hence, Khintchine’s theorem is optimal
                                           up to the hypothesis that qψ(q) is non-increasing. In fact, in modern treatments of Khintchine’s
                                           theorem (e.g., see [18]) this condition is relaxed to simply require that ψ is non-increasing.
                                              Erdős [12] and Schmidt [29] proved a quantitative version of Khintchine’s theorem: if ψ is
                                           non-increasing and we let                            X
                                                                                   Ψ1 (Q) := 2      ψ(q),
                                                                                                        q⩽Q
                                           then we have that [18, Theorem 4.1]
                                                       n                              o                                     
                                                                   2                                       1/2           2+ε
                                           (1.2)     # (a, q) ∈ Z : q ⩽ Q, (1.1) holds = Ψ1 (Q) + Oε Ψ1 (Q) (log Ψ1 (Q))
                                           for almost all α ∈ R, and for all Q sufficiently large in terms of α and ψ. As a matter of fact, if we
                                           impose some even stronger conditions on ψ, we know from work of Fuchs [15] that the quantity
                                           on the left-hand side of (1.2) satisfies a Central Limit Theorem. In particular, the error term on the
                                           right-hand side of (1.2) is nearly sharp.
                                              Duffin and Schaeffer [10] undertook a study to understand to what extent Khintchine’s theorem
                                           holds without the hypothesis that ψ is non-increasing. They realized P that the fact that the fractions
                                           a/q are not reduced can lead to degenerate situations, with the series ∞ q=1 ψ(q) diverging but with

                                              Date: September 23, 2024.
                                              2010 Mathematics Subject Classification. Primary: 11J83. Secondary: 05C40.
                                              Key words and phrases. Diophantine approximation, Metric Number Theory, Duffin–Schaeffer conjecture, graph
                                           theory, density increment, compression arguments.
                                                                                                    1
2                 DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

                                                                       α. This led them to formulate
the inequality (1.1) having only finitely many solutions for almost allP
the following conjecture: if ψ : N → R⩾0 is a function such that ∞       q=1 ψ(q)ϕ(q)/q = ∞ (with
ϕ denoting the Euler totient function), then for almost all α ∈ R the inequality (1.1) is satisfied
                                ∈ Z × N of coprime integers. Conversely, the first Borel–Cantelli
by infinitely many pairs (a, q) P
lemma readily implies that if ∞    q=1 ψ(q)ϕ(q)/q < ∞, then for almost all α ∈ R there are only
finitely many coprime pairs (a, q) ∈ Z × N satisfying (1.1). This would therefore give a full 0-1
law with a simple criterion to determine whether the measure of approximable α is full or null.
   The Duffin–Schaeffer conjecture was resolved in full by the first two named authors [24] after
important partial results by many authors [1, 2, 4, 6, 7, 8, 9, 11, 13, 14, 16, 20, 27, 30]. See also
[23] for an exposition on the history of the conjecture.
   The work of [24] left open the quantitative question of the number of approximations, corre-
sponding to (1.2). Given a function ψ : N → [0, 1/2], let
                                                 X ϕ(q)ψ(q)
(1.3)                                 Ψ(Q) := 2                 .
                                                 q⩽Q
                                                          q
Aistleitner, Borda and Hauke [3] proved that if limQ→∞ Ψ(Q) = ∞, then for almost all α and all
C > 0, we have
          n                                                     o                 Ψ(Q) 
(1.4) # (a, q) ∈ Z × N : q ⩽ Q, (1.1) holds, gcd(a, q) = 1 = Ψ(Q) + OC                             ,
                                                                                   (log Ψ(Q))C
whenever Q was sufficiently large in terms of α and ψ. Therefore the expected asymptotic holds
for almost all α ∈ R, in keeping with (1.2). The main goal of our paper is to establish a refinement
of (1.4), which obtains a near-sharp error term similar to the one in (1.2).
                                                             P
Theorem 1. Let ψ : N → [0, 1/2]. Assume that Ψ(Q) = 2 q⩽Q ψ(q)ϕ(q)/q → ∞ as Q → ∞.
   Then there exists a set B of Lebesgue measure 0 such that, for all α ∈ R \ B and ε > 0,
                                                                                              
                                          a    ψ(q)                                         1
                                                                                              +ε
    # (a, q) ∈ Z × N : q ⩽ Q, α −            <      , gcd(a, q) = 1 = Ψ(Q) + Oε Ψ(Q)        2
                                          q      q
for all Q sufficiently large in terms of α and ψ.
   LeVeque [26] showed that when ψ satisfies certain more stringent conditions, the quantity on the
left-hand side of (1.4) satisfies a Central Limit Theorem analogous to Fuchs’ result [15] for (1.2).
In particular, the error term in Theorem 1 cannot be O(Ψ(Q)1/2 ), and so Theorem 1 is sharp up
to a factor of Ψ(Q)o(1) . We have made no attempt to quantify more precisely this Ψ(Q)o(1) factor;
                                                                                         −c
as written the argument here would likely give a quantification Ψ(Q)1/2+O((log log Ψ(Q)) ) for some
c > 0, but with a bit more care (particularly in Proposition 8.3) this could surely be improved.
Remark. LeVeque originally claimed a result analogous to Fuchs’ theorem [25]. He corrected his
claim in [26], noticing that his proof is instead suited for the left-hand side of (1.4).
   In Section 16, we give a different and simple proof of the optimality of the 1/2 in the exponent
1/2 + ε in Theorem 1.
Notation. We shall use the letter λ to denote the Lebesgue measure on R.
  Sets will be typically denoted by capital calligraphic letters such as A, V and E. A triple G =
(V, W, E) denotes a bipartite graph with vertex sets V and W and edge set E ⊆ V × W.
  Given a set or an event E, we let 1E denote its indicator function.
  The letter p will always denote a prime number. We also write pk kn to mean that pk divides n,
but pk+1 does not divide n.
         AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                   3

                                         2. P ROOF OUTLINE
  Throughout the rest of this paper, we fix a function ψ : N → [0, 1/2] such that Ψ(Q) → ∞
(where Ψ is as defined in (1.3)) as Q → ∞. In addition, we set
                         n                               a     ψ(q)                o
          N(α; Q) = # (a, q) ∈ Z × N : q ⩽ Q, α −           <       , gcd(a, q) = 1 .
                                                         q      q
With this notation, the conclusion of Theorem 1 is that
                                                        1
                                                              
                                                           +ε
                                N(α; Q) = Ψ(Q) + Oε Ψ(Q) 2



for every fixed ε > 0, for almost all α ∈ R and for all Q sufficiently large in terms of α. As
a matter of fact, the function α → N(α; Q) is 1-periodic, so that it suffices to prove the above
estimate for almost all α ∈ [0, 1].
   Now, let
                                                                                 
                                       a    ψ(q)
              Aq := α ∈ [0, 1] : α −      <        for some a ∈ Z coprime with q
                                       q      q
                                G  a ψ(q) a ψ(q) 
                  = [0, 1] ∩             −      , +          ,
                              0⩽a⩽q
                                      q     q    q       q
                            gcd(a,q)=1

where ⊔ denotes a disjoint union. The fact that the above union is disjoint follows readily from our
assumption that ψ(q) ∈ [0, 1/2]. For the same reason, we restricted the union to a ∈ [0, q], because
otherwise the interval ( a−ψ(q)
                           q
                                , a+ψ(q)
                                    q
                                         ) does not intersect [0, 1]. We thus have
                                            X
(2.1)                        N(α; Q) =          1Aq (α) for all α ∈ [0, 1],
                                          q⩽Q

as well as
                                                    2ϕ(q)ψ(q)
                                         λ(Aq ) =             .
                                                        q
As a consequence,
                             Z 1                    X
(2.2)                              N(α; Q) dα =           λ(Aq ) = Ψ(Q).
                               0                    q⩽Q

   We shall deduce Theorem 1 from the following bound on the variance of the random variable
[0, 1] ∋ α → N(α; Q).
Theorem 2. Assume the above notation. Then, for every fixed ε > 0, we have
                  Z 1
                                        2                             
                       N(α; Q) − Ψ(Q) dα ⩽ Ψ(Q) + Oε Ψ(Q)1+ε ;
                       0

the implied constant depends at most on ε.

                    in Theorem 2 holds for all Ψ(Q) ⩾ 0. When Ψ(Q) ⩾ 1, the expression
Remark. The inequality
Ψ(Q) + Oε Ψ(Q)1+ε is dominated by Ψ(Q)1+ε ; when Ψ(Q) < 1, it is dominated by Ψ(Q).
4                   DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

   As with all previous works, the key to Theorem 2 is to show that λ(Aq ∩ Ar ) / λ(Aq )λ(Ar )
for ‘most’ pairs q, r, which can be thought of as a quantitative ‘quasi-independence on average’ of
the events Aq . Typically, one first attacks this via a counting argument, which shows
                                                X         c X
                                                        w                  f (d)
                                                           C
                        λ(Aq ∩ Ar )          gcd(c,n)=1        d| gcd(ℓ,c)
                                      ⩽          Z ∞   X                       ,
                       λ(Aq )λ(Ar )        ϕ(n)              t                f (d) 
                                                         w      dt
                                            n         0     C                   d
                                                                               d|ℓ

for some integers n, ℓ which divide qr, length of summation C = max(rψ(q), qψ(r))/ gcd(q, r),
continuous compactly supported weight function w and multiplicative function f . Thus, to show
the right hand side is close to 1 we wish to show that the numerator, a weighted sum of a multiplica-
tive function, is close to its expected size. The function f and weight w only cause minor technical
inconveniences, but more substantial complications are caused by the restriction gcd(c, n) = 1.
Thus morally the key issue is to get a good upper bound for the number of c ⩽ C which are co-
prime to n. We want an upper bound which is as close to the expected ϕ(n)C/n as possible, but
with good uniformity in the size of n and C. The work of Pollington and Vaughan [27] uses a
standard upper bound sieve, which essentially gives
                                     X           ϕ(n) Y          1
(2.3)                                       1 ≪       C       1+     .
                                     c⩽C
                                                   n              p
                                                               p|n
                                       gcd(c,n)=1             p⩾C

The loss factor of the product over p ⩾ C is typically close to 1, and the arguments of [24] use
this to show λ(Aq ∩ Ar ) ≪ λ(Aq )λ(Ar ) for ‘most’ q, r, which is sufficient to resolve the Duffin-
Schaeffer conjecture1, but not to give better quantitative estimates.
   In [3], a fundamental-lemma style sieve was used, giving for any choice of the parameter u
                           X          ϕ(n)                     Y        1
                                                        −u
(2.4)                            1⩽         C(1 + O(u ))              1+    .
                           c⩽C
                                        n                                p
                                                                       p|n
                           gcd(c,n)=1                                p⩾C 1/u

This improves upon the Pollington-Vaughan bound because it no longer loses a constant factor if u
is moderately large and the final product is close to 1. By choosing u appropriately and using this
bound in the arguments of [24], they were able to show λ(Aq ∩ Ar ) ⩽ (1 + o(1))λ(Aq )λ(Ar ) for
most q, r, which then gave the result (1.4). Unfortunately the quantification of the o(1) is severely
limited by the limitations on the possible choices of the parameter u to ensure that the O(u−u )
error term is small but the product over primes p > C 1/u is still typically close to 1, and it appears
that there is no version of this argument which could yield a power-saving bound in (1.4).
   In our work, we instead use a Legendre sieve to get an upper bound when q and r have suitably
generic prime factorisations. Let n∗ denote the t-smooth part of n. Then we have
                          X             X              ϕ(n∗ )                 
                                                                      #{p|n∗ }
                                  1⩽            1=C ∗ +O 2                      .
                          c⩽C           c⩽C
                                                         n
                          gcd(c,n)=1        gcd(c,n∗ )=1

    1
    An average form of λ(Aq ∩ Ar ) ≪ λ(Aq )λ(Ar ) together with a simple application of the Cauchy-Schwarz in-
equality would give λ(lim supq Aq ) > 0. By Gallagher’s 0-1 law [16], one can immediately obtain λ(lim supq Aq ) =
1, which confirms the Duffin-Schaeffer conjecture.
         AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                    5

When t is chosen appropriately, this gives a good estimate provided q and r have somewhat typical
factorisations. In particular, this gives a good quantitative estimate for suitably ‘generic’ q, r. We
then separately handle ‘non-generic’ pairs q, r using (2.3) and adapting the methods of [24] to
exploit the unusual factorisations. The crucial point is that for those ‘non-generic’ pairs, we have
an extra decay (roughly speaking, either exponential decay or polynomial decay) in the summation.
Thus, the cruder Pollington–Vaughan inequality (cf. Lemma 5.2) for λ(Aq ∩ Ar ) is sufficient for
our purpose.
   An adoption of the above strategy would enable one to get a result similar to Theorem 1, but
with the exponent 1/2 in the error term replaced by some number in (1/2, 1) close to 1. To get the
full quantitative strength of Theorem 1 we need to modify some of the technical definitions in [24]
(most notably, the definition of ‘quality’ of a GCD graph) and verify that the arguments of [24]
still hold with these quantitatively stronger definitions.
Remark. Hauke–Saez–Walker [19] have recently refined the argument of [3] to obtain an estimate
Ψ(Q) + O(Ψ(Q) exp(−(log Ψ(Q))1/2+o(1) )) for the left hand side of (1.4), which appears to be
close to the strongest possible quantification obtainable from using only the overlap estimate (2.4).
Their strategy (building on the earlier work of Green–Walker [17]) also contains some additional
ideas similar to the modification of the definition of quality mentioned above.

                                  3. S TRUCTURE OF THE PAPER
   The first part of the paper consists of Sections 4-7 whose goal is to reduce the proof of Theo-
rem 1 to three bilinear estimates (Propositions 7.1-7.3). Specifically, in Section 4, we show how
Theorem 2 implies Theorem 1. In Section 5 we establish a technical estimate about the measure
of the intersection of two events Aq and Ar ; this is key for our improvement over the Aistleitner–
Borda–Hauke estimate (1.4). In Section 6, we present two auxiliary statistical lemmas about the
multiplicative ‘anatomy’ of a random integer; these serve as the underlying cause for the additional
decay in two of the bilinear estimates of Section 7 (Propositions 7.2 and 7.3). Lastly, in Section 7,
we state the three key bilinear estimates (Propositions 7.1-7.3) and deduce Theorem 2 from them.
   The second part of the paper consists of Sections 8-15. In this part, we prove Propositions 7.1-
7.3 using the language of GCD graphs developed in [24]. In Section 8, we present the definition of
a GCD graph and of other related notions, and we present three iterative Propositions (Propositions
8.1-8.3) and three structural lemmas (Lemmas 8.4-8.6) about GCD graphs. In Section 9, we show
how the results of Section 8 imply the three bilinear estimates of Section 7 (Propositions 7.1-7.3).
In Section 10, we prove Lemma 8.6. In Section 11, we collect some preliminary properties of
GCD graph. Section 12 is dedicated to the proof of the anatomical Lemmas 8.4 and 8.5, Section
13 to the proof of Proposition 8.1. Finally, in Sections 14 and 15, we prove Propositions 8.3 and
8.2, respectively.

                       4. P ROOF OF T HEOREM 1 ASSUMING T HEOREM 2
  This claimed deduction follows by a straightforward adaption of Lemma 1.5 in [18]. Let Q0 = 0
and, for each j ∈ N, let
                               Qj := max{Q ⩾ 0 : Ψ(Q) < j}.
We have that Ψ(Qj ) ∈ [j − 1, j) for all j ⩾ 1. Hence, if Q ∈ [Qj , Qj+1), then Ψ(Q) = j + O(1),
and we also have that
                             N(α; Qj ) ⩽ N(α; Q) ⩽ N(α; Qj+1 ).
6                  DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

This reduces Theorem 1 to proving that
                                                                         1
                                                                                 
                                                                            +ε
(4.1)                           N(α; Qj ) = Ψ(Qj ) + Oε Ψ(Qj )            2



for almost all α ∈ [0, 1] and all j sufficiently large in terms of α.
   For each r ∈ N, let Er be the set of α ∈ [0, 1] such that
                                                    1
                      N(α; Qj ) − Ψ(Qj ) > 2( 2 +ε)r            for some j ∈ [2r , 2r+1 ),
and let B = lim supr→∞ Er be the set of α ∈ [0, 1] which lie in infinitely many Er . Since we also
have that Ψ(Qj ) ≍ 2r whenever j ∈ [2r−1 , 2r ), we have (4.1) for all α ∈ [0, 1]\B and j sufficiently
large in terms of α. Thus it suffices to show that λ(B) = 0. We will prove that
(4.2)                                        λ(Er ) ≪ε 1/r 2 .
                       P
This relation implies ∞  r=1 λ(Er ) < ∞, so the first Borel–Cantelli lemma [18, Lemma 1.2] then
shows that λ(B) = 0, giving Theorem 1.
   Now, let usPfix r ∈ N and demonstrate (4.2). Each integer j ∈ [2r , 2r+1 ) can be written in binary
     as j = rt=0 bt 2t with bt ∈ {0, 1} for t < r and br = 1. For s = 0, 1, . . . , r + 1, let us define
form P
js = t⩾s bt 2t with the convention that jr+1 = 0. We then have that for any j ∈ [2r , 2r+1 )
        X                              r
                                       X       X
                                                                                    
               1Aq (α) − λ(Aq ) =                             1Aq (α) − λ(Aq )
        q⩽Qj                           s=0 Qjs+1 <q⩽Qjs

                                                     r
                                                                                                           !1/2
                                                     X               X                                2
                                     ⩽ (r + 1)1/2                            1Aq (α) − λ(Aq )
                                                        s=0   Qjs+1 <q⩽Qjs

by the Cauchy–Schwarz inequality. Evidently, we may restrict the summation to those numbers s
for which js > js+1 . For such s we have that js = js+1 + 2s as well as js+1 = 2s+1 i with i < 2r−s .
Hence, if we set
                                            X                             
                        ∆(i, s, α) :=                    1Aq (α) − λ(Aq ) ,
                                         Qi2s+1 <q⩽Q2s +i2s+1

then we conclude that
                   X                         2                  X       X
                          1Aq (α) − λ(Aq )
                                                                                                  2
                                                  ⩽ (r + 1)                          ∆(i, s, α)
                   q⩽Qj                                         0⩽s⩽r 0⩽i<2r−s

for each j ∈ [2r , 2r+1). We now note that the right-hand side above doesn’t depend on j. Hence, if
α ∈ Er , then we must have
                                 X       X                       2    2(1+2ε)r
                                                  ∆(i, s, α) >                 .
                                0⩽s⩽r 0⩽i<2r−s
                                                                       r+1

Using Markov’s inequality, we arrive at the bound
                                                                Z 1
                                   r+1 X                X                            2
(4.3)                     λ(Er ) ⩽ (1+2ε)r                            ∆(i, s, α) dα.
                                  2        0⩽s⩽r                 0
                                                    0⩽i<2r−s
             AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                        7

Fix for the moment s and i as above, and let Q′ = Qi2s+1 , Q = Q2s +i2s+1 and ψ ′ (q) = 1q>Q′ ψ(q).
We see that
              X ψ ′ (q)ϕ(q)      X ϕ(q)ψ(q)
                              =                   = Ψ(Q) − Ψ(Q′ ) = 2s + O(1),
              q⩽Q
                       q         ′
                                            q
                                              Q <q⩽Q

since Ψ(Qj ) = j + O(1) for all j ∈ Z⩾0 . To estimate the right-hand side of (4.3), we apply
Theorem 2 with the above choice of Q and ψ ′ (q) in place of ψ. As a consequence,
                             r+1 X X                            r+1        1
                  λ(Er ) ≪ε (1+2ε)r                  2s(1+ε) ≪ε εr ≪ε 2 .
                            2       0⩽s⩽r        r−s
                                                                 2        r
                                                              0⩽i<2

This proves (4.2), thus completing the deduction of Theorem 1 from Theorem 2.

                                                  5. OVERLAP ESTIMATES
  Throughout the rest of the paper, we let
                                                                  max (rψ(q), qψ(r))
(5.1)                                    D = D(q, r) =
                                                                      gcd(q, r)
for any pair of natural numbers (q, r). In addition, if t ⩾ 1 is a real number, then we let
                           X                                                           
                                   1                                      qr
(5.2)      Lt (q, r) :=                   and      ωt (q, r) := # p               :p⩽t .
                                 2
                                   p                                   gcd(q, r)2
                             p|qr/ gcd(q,r)
                                   p>t

   It does not seem possible to improve the overlap estimate in [3, Lemma 5] for arbitrary pair of
integers q and r, so we improve the overlap estimate for generic pairs of integers.
Lemma 5.1 (Overlap estimate for generic pairs of integers). Let q 6= r be two natural numbers
and let D = D(q, r). For any real number t ⩾ 1, we have
                                                               ωt (q,r)         
                                                                2         log(4D)
           λ(Aq ∩ Ar ) ⩽ 1D⩾1/2 · λ(Aq )λ(Ar )e 2Lt (q,r)
                                                           1+O                      .
                                                                          D
Proof. If D < 1/2, we know from [27, Section 3] that Aq ∩ Ar = ∅. So let us assume that
D ⩾ 1/2. Let νp (·) denote the p-adic valuation function, let
           Y                         Y                                 Y
  ℓ=              pνp (q) , m =              pmin{νp (q),νp (r)} , n =   pmax{νp (q),νp (r)} ,
          p: νp (q)=νp (r)                    p: νp (q)6=νp (r)                        p: νp (q)6=νp (r)

and let                                
                                       
                                       2δ                         if 0 ⩽ y ⩽ ∆ − δ,
                                 w(y) = ∆ + δ − y                  if ∆ − δ < y ⩽ ∆ + δ,
                                       
                                       0                          otherwise,
with                                                                       
                                 ψ(q) ψ(r)                        ψ(q) ψ(r)
                     δ = min          ,           and ∆ = max            ,      .
                                   q      r                          q      r
Finally, let s = 12|ℓ . Then, arguing as in the proof of Lemma 5 of [3], we have
                                                        X          2s c  Y            
                    s+1        ϕ(ℓ)2 Y             1                                   1
  λ(Aq ∩ Ar ) = 2 ϕ(m)                     1−                     w               1+        .
                                 ℓ             (p − 1)2     c⩾1
                                                                       ℓn            p − 2
                                                p|ℓ                                           p| gcd(ℓ,c)
                                               p>2                       gcd(c,n)=1               p>2
8                     DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

Since w is supported on [0, ∆ + δ] ⊆ [0, 2∆], we must have c ⩽ 2∆ℓn = 2D. In particular,
we may restrict the last product to primes p ⩽ 2D. In addition, we may replace the condition
gcd(c, n) = 1 by the condition gcd(c, n∗ ) = 1, where n∗ denotes the t-smooth part of n, at the cost
of replacing the exact expression for λ(Aq ∩ Ar ) by an upper bound. We detect the condition that
gcd(c, n∗ ) = 1 using Möbius inversion.
   In conclusion, the above discussion implies that
                                                   X         X  2s c  Y                     
                  s+1     ϕ(ℓ)2 Y             1                                               1
λ(Aq ∩ Ar ) ⩽ 2 ϕ(m)                   1−                 µ(a)     w                  1+
                             ℓ             (p − 1)2     ∗      c⩾1
                                                                       ℓn                  p−2
                                              p|ℓ                           a|n                        p| gcd(ℓ,c)
                                             p>2                                        a|c            2<p⩽2D

with µ denoting the Möbius function throughout this proof. If we let c = ab, then gcd(ℓ, c) =
gcd(ℓ, b) because a|n∗ , and n∗ and ℓ are co-prime. Moreover, note that
                                   Y            1
                                                     X
                                           1+         =     f (j),
                                               p−2
                                               p|k                                j|k
                                             2<p⩽2D

where f is the unique multiplicative function that is supported on square-free integers and satisfies
f (p) = 12<p⩽2D /(p − 2). Hence,
                                                        X                   X  2s aj 
                     s+1      ϕ(ℓ)2 Y               1                X
     λ(Aq ∩ Ar ) ⩽ 2 ϕ(m)                  1−                   µ(a)    f (j)     w i·        ,
                                 ℓ              (p − 1)2      ∗               i⩾1
                                                                                         ℓn
                                                     p|ℓ                          a|n          j|ℓ
                                                    p>2

where we set b = ij. Uniformly for ̺ > 0, the Euler–Maclaurin formula2 [22, Theorem 1.10]
implies
              X          Z ∞            Z ∞
(5.3)            w(̺i) =     w(̺t) dt +     ̺w ′ (̺t){t} dt = 2δ∆̺−1 + O(δ).
                    i⩾1                  0                       0

Therefore,
                                                            X
                                       ϕ(ℓ)2 Y         1         µ(a) X f (j)
               λ(Aq ∩ Ar ) ⩽ 4δ∆ℓnϕ(m)           1−
                                         ℓ          (p − 1)2   ∗
                                                                  a       j
                                                                 p|ℓ                          a|n        j|ℓ
                                                                p>2
                                                                 X               
                                              ϕ(ℓ)2 Y        1          2
                                                                             X
                                    + O δϕ(m)          1−              µ (a)   f (j) .
                                                ℓ         (p − 1)2   ∗
                                                                 p|ℓ                          a|n          j|ℓ
                                                                p>2

We have
                             X µ(a)              ϕ(n∗ )         X                       ∗
                                             =          ,              µ2 (a) = 2#{p|n } = 2ωt (q,r) ,
                                     a            n∗
                             a|n∗                               a|n∗

as well as
      X f (j)          Y                1
                                                    −1          X                  Y                1
                                                                                                           
                     ⩽   1−                                 ,           f (j) =        1+                        ≪ log(4D).
                j                     (p − 1)2                                                       p−2
         j|ℓ               p|ℓ                                   j|ℓ                p|ℓ
                          p>2                                                     2<p⩽2D

    2In [22], the Euler–Maclaurin formula is stated for continuously differentiable functions, but it can be easily gener-

alized to continuous functions that are piecewise differentiable. This requires Theorem 7.35 in [5].
         AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE             9

Since we also have that D = ∆ℓn and 4δ∆ϕ(ℓ)2 ϕ(m)ϕ(n) = λ(Aq )λ(Ar ), we conclude that
                                                          ωt (q,r)         
                                          ϕ(n∗ )/n∗        2         log(4D)
             λ(Aq ∩ Ar ) ⩽ λ(Aq )λ(Ar ) ·           · 1+O                     .
                                           ϕ(n)/n                    D
In order to complete the proof, note that
                          ϕ(n∗ )/n∗   Y     1
                                                
                                    =    1+       ⩽ e2Lt (q,r) ,
                           ϕ(n)/n           p−1
                                        p|n, p>t

where we used the inequality 1 + 1/(y − 1) ⩽ e2/y for y ⩾ 2.                                
  For non-generic pairs of integers, we use the following estimate.
Lemma 5.2 (Pollington–Vaughan [27]). If q, r and D are as in Lemma 5.1, then we have
                          λ(Aq ∩ Ar ) ≪ 1D⩾1/2 · λ(Aq )λ(Ar )eLD (q,r) .

                             6. AUXILIARY ANATOMICAL LEMMAS
Lemma 6.1 (Bounds on multiplicative functions). Let k ∈ N and write τk for the k-th divisor
function. If f is a multiplicative function such that 0 ⩽ f ⩽ τk , then
                                X                     n X f (p) − 1 o
                                    f (n) ≪k x · exp                   .
                                n⩽x                     p⩽x
                                                               p

Proof. This is [22, Theorem 14.2, p. 145].                                                  
Lemma 6.2 (Few numbers with many prime factors). Fix C ⩾ 1. For x, t, s ⩾ 1, we have the
uniform estimate
                                  X1         
                                            1
                        # n⩽x:           ⩾      ≪C xe−Ct/s .
                                      p     s
                                            p|n
                                            p>t

Proof. The quantity in question is
                                                   X
                                        ⩽ e−Ct/s         f (n)
                                                   n⩽x
             Q
with f (n) = p|n e1p>t Ct/p . In particular, f (p) = 1 + OC (1p>t t/p). Hence we may use Lemma
6.1 to complete the proof.                                                                   
Lemma 6.3 (Few numbers with many prime factors). Fix C ⩾ 1 and κ > 0. For x, t ⩾ 1, we have
the uniform estimate
                      n                                o
                     # n ⩽ x : #{p|n : p ⩽ t} ⩾ κ log t ≪C, κ x · t−C .

Proof. The quantity in question is
                                                   X
                                        ⩽ t−C−1          f (n)
                                                   n⩽x
               Q    1p⩽t C+1
with f (n) =   p|n e
                          κ . Using Lemma 6.1 completes the proof.                          
10                   DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

                                  7. R EDUCTION TO THREE PROPOSITIONS
  In this section, we reduce the proof of Theorem 2 (and hence Theorem 1) to the following three
propositions. In their statements, recall the definitions of D(q, r), Lt (q, r) and ωt (q, r) given in the
beginning of Section 5.
Proposition 7.1. Fix ε ∈ (0, 1). Let ψ : N → R⩾0 and y ⩾ 1. We then have the uniform estimate
                               X X ψ(q)ϕ(q) ψ(r)ϕ(r)
                                           ·         ≪ε y 1−ε Ψ(Q)1+ε .
                                  2
                                      q        r
                              (q,r)∈[1,Q]
                               D(q,r)⩽y

Proposition 7.2. Fix ε ∈ (0, 1) and C ⩾ 1. Let ψ : N → R⩾0 and y, t, s ⩾ 1. We then have the
uniform estimate
                        XX                  ψ(q)ϕ(q) ψ(r)ϕ(r)
                                                    ·         ≪ε, C e−Ct/s y 1−ε Ψ(Q)1+ε .
                                               q        r
                      (q,r)∈[1,Q]2
                 D(q,r)⩽y, Lt (q,r)⩾1/s

Proposition 7.3. Fix ε ∈ (0, 1), κ > 0 and C ⩾ 1. Let ψ : N → R⩾0 and y, t ⩾ 1. We then have
the uniform estimate
                        XX                    ψ(q)ϕ(q) ψ(r)ϕ(r)
                                                      ·         ≪ε, κ, C t−C y 1−ε Ψ(Q)1+ε .
                                                 q        r
                       (q,r)∈[1,Q]2
                 D(q,r)⩽y, ωt (q,r)⩾κ log t

Deduction of Theorem 2 from Propositions 7.1-7.3. Using (2.1) and (2.2), we find that
                   Z 1                           Z 1X         2
                                        2
               0⩽       N(α; Q) − Ψ(Q) dα =                1Aq dα − Ψ(Q)2
                          0                                     0   q⩽Q
                                                                XX
                                                            =           λ(Aq ∩ Ar ) − Ψ(Q)2 .
                                                                q,r⩽Q

So in order to prove Theorem 2, it suffices to establish the upper bound
                     XX                                                  
                            λ(Aq ∩ Ar ) ⩽ Ψ(Q)2 + Ψ(Q) + Oε Ψ(Q)1+ε .
                          q,r⩽Q

The terms with q = r contribute
                                                 X
                                                       λ(Aq ) = Ψ(Q).
                                                 q⩽Q

It thus remains to show that
                         XX                                  
(7.1)                        λ(Aq ∩ Ar ) ⩽ Ψ(Q)2 + Oε Ψ(Q)1+ε .
                                 q,r⩽Q
                                  q6=r

     From the first part of Lemma 5.1, we may assume that D(q, r) ⩾ 1/2. To this end, let
                                E = {(q, r) ∈ [1, Q]2 : q 6= r, D(q, r) ⩾ 1/2},
          AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                                11

so that the sum in (7.1) is over all pairs (q, r) ∈ E. Writing D = D(q, r), we split E into the
following three subsets:
                         n                          1             ε         o
                  (1)
                 E = (q, r) ∈ E : LD (q, r) ⩽ , ωD2 (q, r) ⩽ log(2D) ,
                                          2
                                                    D             4
                         n                          1o
                  (2)
                 E = (q, r) ∈ E : LD2 (q, r) >         ,
                                                    D
                         n                          1             ε         o
                  (3)
                 E = (q, r) ∈ E : LD2 (q, r) ⩽ , ωD2 (q, r) > log(2D) .
                                                    D             4
We claim the following estimates:
                         XX                                         
(7.2)                            λ(Aq ∩ Ar ) ⩽ Ψ(Q)2 + Oε Ψ(Q)1+ε ;
                               (q,r)∈E (1)
                               XX
(7.3)                                        λ(Aq ∩ Ar ) ≪ε Ψ(Q)1+ε ;
                               (q,r)∈E (2)
                               XX
(7.4)                                        λ(Aq ∩ Ar ) ≪ε Ψ(Q)1+ε .
                               (q,r)∈E (3)

These bounds suffice to complete the proof, since they readily imply
            XX                                3 XX
                                              X                                                
                      λ(Aq ∩ Ar ) =                             λ(Aq ∩ Ar ) ⩽ Ψ(Q)2 + Oε Ψ(Q)1+ε .
             q,r⩽Q                            i=1 (q,r)∈E (i)
              q6=r

This gives (7.1), and so completes the proof of Theorem 2.
  Let us now prove (7.2). Here the summation is over pairs (q, r) ∈ E (1) . We then use Lemma 5.1
with t = D 2 to find that
                                                                     
                          λ(Aq ∩ Ar ) ⩽ λ(Aq )λ(Ar ) 1 + O D −1+ε/2 .
Therefore                              XX
                                                     λ(Aq ∩ Ar ) ⩽ M + Oε (R),
                                       (q,r)∈E (1)
where                XX                                                XX
            M :=                   λ(Aq )λ(Ar ) and             R :=                 D(q, r)ε/2−1λ(Aq )λ(Ar ).
                     (q,r)∈E (1)                                       (q,r)∈E (1)
                                                                            2
For the main term M we simply notice that it is ⩽ Ψ(Q) . Thus we focus on the Oε (R) term. Let
I be the smallest non-negative integer such that 2I ⩾ Ψ(Q). We then split R according to the size
of D(q, r) as
                                              XI
                                         R=       Ri + R′
                                                             i=0
where Ri is the part of the sum with D(q, r) ∈ [2i−1 , 2i ), and R′ is the part with D(q, r) ⩾ 2I ⩾
Ψ(Q). Now, we trivially have that
                                      XX
                       R′ ⩽ Ψ(Q)ε/2−1          λ(Aq )λ(Ar ) ⩽ Ψ(Q)1+ε/2 .
                                                     (q,r)∈E (1)

For each i ∈ {0, 1, . . . , I}, Proposition 7.1 implies that
                            Ri ≪ε (2i )ε/2−1 · (2i )1−ε Ψ(Q)1+ε = 2−iε/2 Ψ(Q)1+ε .
12                 DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

We thus conclude that R ≪ε Ψ(Q)1+ε , whence (7.2) follows.
 Let us now prove (7.3). For (q, r) ∈ E (2) we use Lemma 5.2 to find that
                      XX                      XX
                             λ(Aq ∩ Ar ) ≪            λ(Aq )λ(Ar )eLD (q,r) .
                        (q,r)∈E (2)                          (q,r)∈E (2)

Note that if D ∈ [2i−1 , 2i ) and (q, r) ∈ E (2) , then L4i−1 (q, r) > 1/2i . We may thus write
                                                      ∞ [
                                                      [  ∞
                                                              (2)
                                           E (2) =          Ei,j ,
                                                             i=0 j=i
         (2)                                                                                             (2)
where Ei,i is the set of pairs (q, r) ∈ E (2) with D ∈ [2i−1 , 2i ) and L4i−1 (q, r) ⩽ 1, and Ei,j with
j > i is the set of pairs (q, r) ∈ E (2) with D ∈ [2i−1 , 2i ) and L4j−1 (q, r) ⩽ 1 < L4j−2 (q, r). In
                         (2)
particular, if (q, r) ∈ Ei,j , then
                                             X      1                       j+1
             LD (q, r) ⩽ L2i−1 (q, r) ⩽               + L4j−1 (q, r) ⩽ log          + O(1),
                                         i−1    j−1
                                                    p                       i+1
                                                  2   <p⩽4

and thus
                    XX                                 XX j + 1 XX
(7.5)                             λ(Aq ∩ Ar ) ≪                                          λ(Aq )λ(Ar ).
                                                        j⩾i⩾0
                                                                    i+1
                    (q,r)∈E (2)                                                    (2)
                                                                            (q,r)∈Ei,j

For each i ⩾ 0, Proposition 7.2 applied with y = 2i , t = max{1, 4i−1 }, s = 2i and C = 8 implies
that3                        XX                            i
                                     λ(Aq )λ(Ar ) ≪ε e−2 Ψ(Q)1+ε .
                                            (2)
                                   (q,r)∈Ei,i

In addition, if j > i ⩾ 0, then Proposition 7.2 applied with y = 2i , t = max{1, 4j−2}, s = 1 and
C = 17 implies that           XX                           j
                                     λ(Aq )λ(Ar ) ≪ε e−4 Ψ(Q)1+ε .
                                            (2)
                                   (q,r)∈Ei,j

Inserting the two above bounds into (7.5) completes the proof of (7.3).
  It remains to prove (7.4). We note that for pairs (q, r) ∈ E (3) we have
                                            X 1
                             LD (q, r) ⩽             + LD2 (q, r) ≪ 1.
                                                2
                                                  p
                                                      D<p⩽D

Therefore, using Lemma 5.2, we find that
                        XX                    XX
                                λ(Aq ∩ Ar ) ≪    λ(Aq )λ(Ar ).
                              (q,r)∈E (3)                         (q,r)∈E (3)

Note that if D ∈ [2i−1 , 2i ) and ωD2 (q, r) > 0.25ε log(2D), then ω4i (q, r) > 0.1ε log(4i ). There-
fore,
                         XX                       XXX
(7.6)                             λ(Aq ∩ Ar ) ≪               λ(Aq )λ(Ar ),
                           (q,r)∈E (3)                         i⩾0 (q,r)∈E (3)
                                                                            i


  3Since any prime is larger than 1, we have L i−1 (q, r) = L (q, r) when i < 1, so we may indeed take t =
                                              4              1
max{1, 4i−1 }.
         AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                  13

        (3)
where Ei is the set of pairs (q, r) ∈ E (3) with D ∈ [2i−1 , 2i ) and ω4i (q, r) > 0.1ε log(4i ).
Proposition 7.3 applied with y = 2i , t = 4i , κ = ε/10, and C = 2 implies that
                              XX
                                        λ(Aq )λ(Ar ) ≪ε 2−i Ψ(Q)1+ε
                                      (3)
                               (q,r)∈Ei

for all i ⩾ 0. Inserting this bound into (7.6) completes the proof of (7.4), and thus of Theorem
2.                                                                                             

                                             8. GCD GRAPHS
  In order to prove Propositions 7.1-7.3, we shall use the method of GCD graphs developed in
[24] with some important modifications. The definition of a GCD graph is almost the same as in
[24]:
Definition 1 (GCD graph). Let G be a septuple (µ, V, W, E, P, f, g) such that:
   (a) µ is a measure on N such that µ(n) < ∞ for all n ∈ N; we extend to N2 by letting
                                     X
                         µ(N ) :=          µ(n1 )µ(n2 ) for N ⊆ N2 ;
                                     (n1 ,n2 )∈N

   (b) V and W are finite sets of positive integers;
   (c) E ⊆ V × W, that is to say (V, W, E) is a bipartite graph;
   (d) P is a set of primes;
   (e) f and g are functions from P to Z⩾0 such that for all p ∈ P we have:
          (i) pf (p) |v for all v ∈ V, and pg(p) |w for all w ∈ W;
         (ii) if (v, w) ∈ E, then pmin{f (p),g(p)} k gcd(v, w);
We then call G a (bipartite) GCD graph with sets of vertices (V, W), set of edges E and multiplica-
tive data (P, f, g). We will also refer to P as the set of primes of G. If P = ∅, we say that G has
trivial set of primes and we view f = f∅ and g = g∅ as two copies of the empty function from ∅ to
Z⩾0 .
Remark. In [24], the definition of a GCD graph included one additional condition: if f (p) 6= g(p),
then we required that pf (p) kv for all v ∈ V, and pg(p) kw for all w ∈ W. Even though the GCD
graphs we will consider do satisfy this condition, we no longer need to include it in the definition
due to a small strengthening of Proposition 8.1, which allows us to specify the p-adic valuation of
all vertices in G′ and for all primes p ∈ P ′ \ P.
   To each GCD graph G, we associate a quality q(G). This will be defined differently to [24], and
                                          1
it will depend on some parameter τ ∈ (0, 100 ), which we can take to be arbitrarily small.
Definition 2. For a GCD graph G = (µ, V, W, E, P, f, g), we define:
   (a) The edge density is defined by
                                                       µ(E)
                                            δ(G) =            ,
                                                     µ(V)µ(W)
       provided that µ(V)µ(W) 6= 0. If µ(V)µ(W) = 0, we define δ(G) to be 0.
14                    DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

     (b) The quality is defined by
                                                                                          −2                −3
                        2+τ
                                         Y
                                                   |f (p)−g(p)|            1f (p)=g(p)⩾1               1
            q(G) := δ         µ(V)µ(W)         p                      1−                        1−         τ         .
                                         p∈P
                                                                                p                    p1+ 4

Definition 3 (Non-trivial GCD graph). Let G = (µ, V, W, E, P, f, g). We say that G is non-trivial
if µ(E) > 0.
Definition 4 (GCD subgraph). Let G = (µ, V, W, E, P, f, g) and G′ = (µ′ , V ′ , W ′ , E ′ , P ′ , f ′ , g ′)
be two GCD graphs. We say that G′ is a GCD subgraph of G if:
            µ′ = µ,     V ′ ⊆ V,   W ′ ⊆ W,             E ′ ⊆ E,           P ′ ⊇ P,    f ′ P = f,    g ′ P = g.
Lastly, we say that G′ is a non-trivial GCD subgraph of G if µ(E ′ ) > 0, that is to say G′ is
non-trivial as a GCD graph.
Definition 5 (maximal GCD graph). Let G = (µ, V, W, E, P, f, g) be a GCD graph. We say that
G is maximal or, more precisely, that G is (P, f, g)-maximal if for every GCD subgraph G′ of G
with the same multiplicative data (P, f, g) we have that q(G′ ) ⩽ q(G).
Remark. For any given GCD graph G = (µ, V, W, E, P, f, g), since both the sets V and W are
finite, there exists a GCD subgraph G′ of G with the same multiplicative data (P, f, g), such that
G′ is (P, f, g)-maximal. To see this, just list all subgraphs of G with the same multiplicative data,
and pick out one with the largest possible quality. We will use this fact several times in the later
sections without mentioning it again.
   We recall from [24] the special vertex sets Vpk and GCD graphs Gpk ,pℓ formed by restricted
elements by their prime-power divisibilty.
Definition 6. Let p be a prime number, and let k, ℓ ∈ Z⩾0 .
     (a) If V is a set of integers, we set
                                             Vpk = {v ∈ V : pk kv}.
         Here we have the understanding that Vp0 denotes the set of v ∈ V that are coprime to p.
     (b) Let G = (V, W, E) be a bipartite graph. If V ′ ⊆ V and W ′ ⊆ W, we define
                                      E(V ′ , W ′ ) := E ∩ (V ′ × W ′ ).
         We write for brevity
                                             Epk ,pℓ := E(Vpk , Wpℓ ).
                                                                  / P. We then define the septuple
     (c) Let G = (µ, V, W, E, P, f, g) be a GCD graph such that p ∈
                       Gpk ,pℓ = (µ, Vpk , Wpℓ , E ∩ (Vpk × Wpℓ ), P ∪ {p}, fpk , gpℓ )
         where the functions fpk , gpℓ are defined on P ∪ {p} by the relations fpk |P = f , gpℓ |P = g,
                                      fpk (p) = k           and gpℓ (p) = ℓ.
     We further fix a constant M ⩾ 2 and we introduce the auxiliary quantities C1 , . . . , C7 as follows:
                 104
            C1 =     ,         C2 = 10MC13 ,               C3 = 103 C13 ,             C4 = 1010 M 2 C22 ,
(8.1)             τ
                                                                                              10
            C5 = max{C3 , (50 log C4 )3 },               C6 = max{C4 , 104 MC2 , C2τ },                    C7 = C5C6 .
          AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                      15

Definition 7. Let G = (µ, V, W, E, P, f, g) be a GCD graph. We let R(G) be given by
                                   / P : ∃(v, w) ∈ E such that p| gcd(v, w)}.
                        R(G) := {p ∈
That is to say R(G) is the set of primes occurring in a GCD which we haven’t yet accounted for.
We split this into two further subsets:
     • The set R♯ (G) consisting of all primes p ∈ R(G) for which there exists an integer k ⩾ 0
       such that
                         µ(Vpk )         C2        µ(Wpk )          C2
                                  ⩾ 1−        and           ⩾1−        ,
                          µ(V)            p         µ(W)             p
       and
                    q(Gpa ,pb ) < M · q(G) for all (a, b) ∈ Z2⩾0 with a 6= b.
     • The set R♭ (G) := R(G) \ R♯ (G).
  In the next section, we reduce the proof of Propositions 7.1-7.3 (and hence Theorem 2) to the
existence of GCD subgraphs with nice properties as described in the following three propositions
and three lemmas.
Proposition 8.1 (Iteration when R♭ (G) 6= ∅). Let G = (µ, V, W, E, P, f, g) be a GCD graph with
edge density δ > 0 such that
                                 R(G) ⊆ {p > C6 } and R♭ (G) 6= ∅.
Then there is a GCD subgraph G′ of G with edge density δ ′ > 0 and multiplicative data (P ′ , f ′ , g ′)
such that:
   (a) G′ is (P ′ , f ′ , g ′)-maximal;
   (b) P ( P ′ ⊆ P ∪ R(G);
   (c) R(G′ ) ( R(G);
   (d) q(G′ ) ⩾ M N q(G) with N = #{p ∈ P ′ \ P : f ′ (p) 6= g ′ (p)};
          ′              ′
   (e) pf (p) kv and pg (p) kw for all p ∈ P ′ \ P, (v, w) ∈ V × W.
Proposition 8.2 (Iteration when R♭ (G) = ∅). Let G = (µ, V, W, E, P, f, g) be a GCD graph with
edge density δ > 0 such that
                             R(G) ⊆ {p > C6 },       R♭ (G) = ∅,      R♯ (G) 6= ∅.
Then there is a GCD subgraph G′ = (µ, V ′ , W ′ , E ′ , P ′ , f ′ , g ′) of G such that
                      P ( P ′ ⊆ P ∪ R(G),         R(G′ ) ( R(G),         q(G′ ) ⩾ q(G).
Proposition 8.3 (Bounded quality loss for small primes). Let G = (µ, V, W, E, P, f, g) be a GCD
graph with edge density δ > 0. Then there is a GCD subgraph G′ = (µ, V ′, W ′ , E ′, P ′ , f ′ , g ′) of G
with edge density δ ′ > 0 such that
                                        
          P ′ ⊆ P ∪ R(G) ∩ {p ⩽ C6 } , R(G′ ) ⊆ {p > C6 }, q(G′ ) ⩾ q(G)/C7 .
Lemma 8.4 (Removing the effect of R(G) from Lt (v, w)). Let G = (µ, V, W, E, P, f, g) be a
maximal GCD graph with edge density δ > 0 and let s ⩾ 1 and t ⩾ C6 s. Assume further that
                                       
              R♭ (G) = ∅ and E ⊆ (v, w) ∈ V × W : Lt (v, w) ⩾ 1/s .
16                 DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

Then there exists a GCD subgraph G′ = (µ, V, W, E ′, P, f, g) of G such that
                                                                   X               
              ′     q(G)             ′                                       1   1
          q(G ) ⩾        > 0 and E ⊆ (v, w) ∈ V × W :                          ⩾     .
                      2                                                    2
                                                                             p   2s
                                                                  p|vw/ gcd(v,w)
                                                                   p>t, p∈R(G)
                                                                          /

Lemma 8.5 (Removing the effect of R(G) from ωt (v, w)). Let G = (µ, V, W, E, P, f, g) be a
maximal GCD graph with edge density δ > 0 and let t ⩾ exp exp(C6 ) and U ⩾ 2C6 log log t.
Assume further that
                                      
                  R♭ (G) = ∅ and E ⊆ (v, w) ∈ V × W : ωt (v, w) ⩾ U .
Then there exists a GCD subgraph G′ = (µ, V, W, E ′, P, f, g) of G such that
                                                                   X             
              ′     q(G)             ′                                          U
          q(G ) ⩾        > 0 and E ⊆ (v, w) ∈ V × W :                        1⩾    .
                      2                                                    2
                                                                                2
                                                                   p|vw/ gcd(v,w)
                                                                  C6 <p⩽t, p∈R(G)
                                                                             /

Lemma 8.6 (Subgraph with high-degree vertices). Let G = (µ, V, W, E, P, f, g) be a GCD graph
with edge density δ > 0. Then there is a GCD subgraph G′ = (µ, V ′ , W ′ , E ′, P, f, g) of G with
edge density δ ′ > 0 such that:
     (a) q(G′ ) ⩾ q(G);
     (b) For all v ∈ V ′ and for all w ∈ W ′ , we have
                               1+τ ′                               1+τ ′
                 µ(ΓG′ (v)) ⩾         · δ µ(W ′ ) and µ(ΓG′ (w)) ⩾     · δ µ(V ′ ).
                               2+τ                                 2+τ
         9. P ROOF OF P ROPOSITIONS 7.1-7.3 ASSUMING THE RESULTS OF S ECTION 8
Definition 8 (Neighbourhood sets). Given a bipartite graph G = (V, W, E), we define the neigh-
bourhood sets by
                      ΓG (v) := {w ∈ W : (v, w) ∈ E} for any v ∈ V,
and
                      ΓG (w) := {v ∈ V : (v, w) ∈ E} for any w ∈ W.
Proof of Proposition 7.1. Let S = Z ∩ [1, Q], µ(q) = ϕ(q)ψ(q)/q and E = {(q, r) ∈ S 2 :
D(q, r) ⩽ y}, and consider the GCD graph G = (µ, S, S, E, ∅, f∅ , g∅ ) with trivial set of primes.
Let δ = δ(G) be its edge density. It suffices to show that
(9.1)                                      q(G) ≪τ y 2 .
Indeed, we have that
                          q(G) = δ 2+τ µ(S)2 = µ(E)2+τ µ(S)−2−2τ
and µ(S) = 21 Ψ(Q). Hence, if (9.1) holds, then
                                                 2         2+2τ
                                     µ(E) ≪τ y 2+τ Ψ(Q) 2+τ .
This proves Proposition 7.1 with ε = τ /(2 + τ ). Since τ > 0 can be taken to be arbitrarily small,
this completes the proof of Proposition 7.1.
   Let us now prove (9.1). If δ = 0, relation (9.1) holds trivially, so let us assume that δ > 0.
We use the results of Section 8 with M = 2. We first use Proposition 8.3, and we then iterate
Propositions 8.1 and 8.2. Lastly, we apply Lemma 8.6. Thus, we find that there exists a GCD
subgraph G′ = (µ, V ′, W ′ , E ′ , P ′ , f ′ , g ′) of G of density δ ′ > 0. such that:
             AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                                17

   (a) R(G′ ) = ∅;
                                              1+τ ′
   (b) For all v ∈ V ′ , we have µ(ΓG′ (v)) ⩾ 2+τ δ µ(W ′ ) ⩾ 0.5δ ′ µ(W ′ );
                                              1+τ ′
   (c) For all w ∈ W ′ , we have µ(ΓG′ (w)) ⩾ 2+τ δ µ(V ′ ) ⩾ 0.5δ ′ µ(V ′ );
   (d) q(G′ ) ≫τ q(G).
Hence, it suffices to prove that
(9.2)                                                  q(G′ ) ≪τ y 2.
To do this, we largely follow the proof of Proposition 6.3 in [24], with some important simplifica-
tions because we do not need to keep track of the ‘anatomical’ condition Lt (v, w) ⩾ 10 as we did
there. For the ease of the reader, we repeat all the details instead of referring to [24].
   Set
                                     Y ′                       Y ′
(9.3)                          a :=      pf (p) and b :=           pg (p) .
                                           p∈P ′                         p∈P ′

The definition of a GCD graph implies that
(9.4)                           a|v    for all v ∈ V ′ ,        b|w     for all w ∈ W ′ .
                                                   ′    ′
Moreover, since R(G′ ) = ∅, and pmin{f (p),g (p)} k gcd(v, w) for all (v, w) ∈ E ′, we have that
(9.5)                            gcd(v, w) = gcd(a, b)          for all (v, w) ∈ E ′.
  Now, note that
        Y ′           ′
                              Y        ′     ′          ′     ′       lcm(a, b)      ab
             p|f (p)−g (p)| =    pmax{f (p),g (p)}−min{f (p),g (p)} =           =            ,
           ′                   ′
                                                                      gcd(a, b)   gcd(a, b)2
             p∈P                   p∈P

as well as
     Y                                1                         Y                   1                     ab
                                                            ≪                                        ⩽          .
                   1
                                                              τ
                                                                           1
                                                       τ
                                                    1+                (1 −                         2
                                                                             f ′ (p)=g ′ (p)⩾1 /p)     ϕ(a)ϕ(b)
              (1 −                        2
                       ′ (p)=g ′ (p)⩾1 /p) (1 − 1/p    4) 3
        p∈P ′        f                                          p∈P ′


Consequently, from the definition of q(·), we find
                                           Y                         ′    ′
                                                                p|f (p)−g (p)|
                 ′      ′ 2+τ    ′       ′
            q(G ) = (δ ) µ(V )µ(W )
                                                 (1 − 1f ′ (p)=g′ (p)⩾1 /p)2 (1 − 1/p1+ 4 )3
                                                                                        τ

                                           p∈P ′
                                                           ab         ab
                         ≪τ (δ ′ )2+τ µ(V ′ )µ(W ′ ) ·          2
                                                                  ·
                                                       gcd(a, b) ϕ(a)ϕ(b)
                                                 ab           ab
(9.6)                    = (δ ′ )1+τ µ(E ′) ·          2
                                                         ·          .
                                              gcd(a, b) ϕ(a)ϕ(b)
It remains to bound µ(E ′ ).
   We have that
                                  E ′ ⊆ E = {(v, w) ∈ S × S : D(v, w) ⩽ y},
where we recall that D(v, w) = max{vψ(w), wψ(v)}/ gcd(v, w). Since gcd(v, w) = gcd(a, b)
for all (v, w) ∈ E ′ , we infer that
                          y · gcd(a, b)                         y · gcd(a, b)
                ψ(v) ⩽                      and        ψ(w) ⩽                    for all (v, w) ∈ E ′.
                                w                                     v
18                    DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

The vertex sets V ′ , W ′ are finite sets of positive integers. For each v ∈ V ′ , let wmax (v) be the largest
integer in W ′ such that (v, wmax(v)) ∈ E ′ . (This quantity is well-defined in virtue of property (b)
above. In addition, we emphasise to the reader that ‘largest’ refers to the size of elements as
positive integers, and does not depend on the measure µ.) Similarly, for each w ∈ W ′ , let vmax (w)
be the largest element of V ′ such that (vmax (w), w) ∈ E ′. Consequently,
                             y · gcd(a, b)                              y · gcd(a, b)
(9.7)          ψ(v) ⩽                           and    ψ(w) ⩽                             for all     v ∈ V ′, w ∈ W ′.
                               wmax (v)                                   vmax (w)
     Now, let w0 be the largest integer in W ′ and E ′′ = {(v, w) ∈ E ′ : (v, w0) ∈ E ′ }. We then have
(9.8)                                  wmax (v) = w0              for all (v, w) ∈ E ′′ .
In addition, by properties (b) and (c) of G′ , we have
                  X                                                                       ′ 2
         ′′                                                  δ ′ µ(W ′ )                  δ                      δ ′ µ(E ′ )
     µ(E ) =                 µ(v)µ(ΓG′ (v)) ⩾ µ(ΓG′ (w0 )) ·             ⩾                      µ(V ′ )µ(W ′ ) =             .
                                                                  2                       2                           4
               v∈ΓG′ (w0 )

Substituting this bound into (9.6), we find
                                                  ab       ab                       ab        ab
(9.9)          q(G′ ) ≪τ (δ ′ )τ µ(E ′′ ) ·            ·          2
                                                                    ⩽ µ(E ′′ ) ·          2
                                                                                            ·       ,
                                               ϕ(a)ϕ(b) gcd(a, b)                gcd(a, b) ϕ(a)ϕ(b)
where we used the trivial bound δ ′ ⩽ 1 in the second inequality and our assumption that τ > 0.
  In addition,
                                        X ψ(v)ϕ(v) ψ(w)ϕ(w)
                            µ(E ′′ ) =                   ·           .
                                             ′′
                                                   v           w
                                                  (v,w)∈E

Since a|v and b|w, we have ϕ(v)/v ⩽ ϕ(a)/a and ϕ(w)/w ⩽ ϕ(b)/b. Therefore
                                      ϕ(a)ϕ(b) X
                            µ(E ′′) ⩽                 ψ(v)ψ(w).
                                         ab        ′′               (v,w)∈E

Together with (9.7), (9.8) and (9.9), this implies that
                                   X             1               X        1
(9.10)            q(G′ ) ≪ y 2 ab                       ⩽ y 2 ab                .
                                         ′′
                                            vmax (w)w0             ′
                                                                     vmax (w)w0
                                             (v,w)∈E                                (v,w)∈E

Writing v = v ′ a and w = w ′ b, we find that
                       X          1            X      1                                       X
                                          ⩽                                                                 1
                          ′
                            vmax (w)w0        ′
                                                 w0 vmax (bw ′ ) ′
                             (v,w)∈E                       w ⩽w0 /b                     v ⩽vmax (bw ′ )/a
                                                             X                1           vmax (bw ′ )
                                                       ⩽                                ·
                                                                        w0 vmax (bw ′ )       a
                                                           w ′ ⩽w0 /b
                                                           1
                                                       ⩽      .
                                                           ab
Together with (9.10), this implies that
                                                           q(G′ ) ≪ y 2 .
as needed. This completes the proof of Proposition 7.1.                                                                          
            AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                                19

Proof of Proposition 7.2. Let C6 be defined as in (8.1) , where the parameter M will be determined
later. If t ⩽ C6 s, then the result follows immediately by Proposition 7.1. Let us assume now that
t ⩾ C6 s.
   Let S = Z ∩ [1, Q], µ(q) = ϕ(q)ψ(q)/q and E = {(q, r) ∈ S 2 : D(q, r) ⩽ y, Lt (q, r) ⩾ 1/s},
and consider the GCD graph G = (µ, S, S, E, ∅, f∅, g∅ ) with trivial set of primes. Let δ = δ(G) be
its edge density. As in the proof of Proposition 7.1, it suffices to show that
(9.11)                                                 q(G) ≪τ,C y 2 e−Ct/s .
We may assume that δ > 0; otherwise, (9.11) holds trivially. To proceed, we adapt the argument
leading to Propositions 6.3 and 7.1 of [24].
   We shall apply the results of Section 8 on GCD graphs with the parameter M = e4C . First, we
use Proposition 8.3 to find a GCD subgraph G(0) = (µ, V (0) , W (0) , E (0) , P (0) , f (0) , g (0) ) of G of
density δ (0) > 0 such that:
   (a) P (0) ⊆ {p ⩽ C6 };
   (b) R(G(0) ) ⊆ {p > C6 };
   (c) q(G(0) ) ≫τ,C q(G).
   Next, we claim we may find a GCD subgraph G(1) = (µ, V (1) , W (1) , E (1) , P (1) , f (1) , g (1) ) of G(0)
that has density δ (1) > 0 and that satisfies the following properties:
   (a) G(1) is maximal;
   (b) R♭ (G(1) ) = ∅;
   (c) q(G(1) ) ⩾ e4CN q(G(0) ) with N = #{p ∈ P (1) : p > C6 , f (1) (p) 6= g (1) (p)};
            (1) (p)               (1) (p)
   (d) pf             kv and pg             kw for all (v, w) ∈ V (1) × W (1) and all primes p > C6 lying in P (1) .
   Indeed, if R♭ (G(0) ) 6= ∅, we may apply Proposition 8.1 in an iterative fashion to construct G(1) .
On the other hand, if R♭ (G(0) ) = ∅, then we need to be a bit careful because G(0) is not necessarily
maximal, so property (a) above might not be automatically satisfied if we take G(1) = G(0) . In this
case, we begin by first selecting a maximal GCD subgraph of G(0) with the same multiplicative
data as G(0) , let us call it G′ . We then check whether the set R♭ (G′ ) is empty or not. If it is empty,
then we take G(1) = G′ and check easily that this choice satisfies all four properties listed above
(property (c) holds with N = 0). Otherwise, if R♭ (G′ ) 6= ∅, then we repeatedly apply Proposition
8.1 till we arrive to a GCD subgraph G(1) of G′ satisfying all four properties above.
   In all cases, we have constructed the claimed GCD graph G(1) . We then separate two cases.

Case 1: N ⩾ 0.25t/s. We then iterate Propositions 8.1 and 8.2, and we subsequently apply Lemma
8.6 to arrive at a GCD subgraph G′ = (µ, V ′ , W ′ , E ′ , P ′ , f ′ , g ′) of G(1) of density δ ′ > 0 such that:
   (a) R(G′ ) = ∅;
                                              1+τ ′
   (b) For all v ∈ V ′ , we have µ(ΓG′ (v)) ⩾ 2+τ δ µ(W ′ ) ⩾ 0.5δ ′ µ(W ′ );
                                              1+τ ′
   (c) For all w ∈ W ′ , we have µ(ΓG′ (w)) ⩾ 2+τ δ µ(V ′ ) ⩾ 0.5δ ′ µ(V ′ );
   (d) q(G′ ) ⩾ q(G(1) ).
In particular, we see that q(G′ ) ≫τ e4CN q(G) ⩾ eCt/s q(G). In addition, arguing as in the proof of
Proposition 7.1, we have that q(G′ ) ≪τ y 2. Hence, (9.11) holds in this case.
20                   DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

Case 2: N < 0.25t/s. In this case we must exploit the condition Lt (q, r) ⩾ 1/s to obtain the
necessary savings. If we blindly apply Proposition 8.2, we might lose track of this condition. So
we first perform some cosmetic surgery to our graph. Applying Lemma 8.4, we find that there
exists a GCD subgraph G(2) = (µ, V (2) , W (2) , E (2) , P (2) , f (2) , g (2) ) of G(1) with
(9.12)                                                P (2) = P (1) ,
                                                                q(G(1) )
(9.13)                                             q(G(2) ) ⩾            ,
                                                                  2
and such that
                                    X          1   1
(9.14)                                           ⩾          whenever (v, w) ∈ E (2) .
                                             2
                                               p   2s
                              p|vw/ gcd(v,w)
                              p>t, p∈R(G
                                    /     (1) )


   We claim that an inequality of the form (9.14) holds even if we remove from consideration the
                                                                                           vw
primes lying in P (1) . Indeed, if p > C6 lies in P (1) , (v, w) ∈ E (2) ⊆ E (1) and p| gcd(v,w)2 , then we

use property (d) of G(1) to find that f (1) (p) 6= g (1) (p). Hence,
                     X           1   #{p ∈ P (1) : f (1) (p) 6= g (1) (p), p > t}   N   1
                                   <                                              ⩽   <
                               2
                                 p                        t                         t   4s
                p|vw/ gcd(v,w)
                  p>t, p∈P (1)

by our assumption on N, and because t ⩾ C6 s ⩾ C6 here. As a consequence, for all (v, w) ∈ E (2)
we have
                                        X         1     1
(9.15)                                              ⩾ .
                                               2
                                                  p     4s
                                               p|vw/ gcd(v,w)
                                             p>t, p∈R(G
                                                   /    (1) )∪P (1)


 Next, we iterate Propositions 8.1 and Proposition 8.2, and we also apply Lemma 8.6 to find a
GCD subgraph G′ = (µ, V ′ , W ′ , E ′ , P ′ , f ′ , g ′) of G(2) of density δ ′ > 0 such that:
     (a) R(G′ ) = ∅;
                                                1+τ ′
     (b) For all v ∈ V ′ , we have µ(ΓG′ (v)) ⩾ 2+τ δ µ(W ′ ) ⩾ 0.5δ ′ µ(W ′ );
                                                1+τ ′
     (c) For all w ∈ W ′ , we have µ(ΓG′ (w)) ⩾ 2+τ δ µ(V ′ ) ⩾ 0.5δ ′ µ(V ′ );
     (d) q(G′ ) ⩾ q(G(2) );
     (e) (9.15) holds for all (v, w) ∈ E ′ .
Hence, Proposition 7.2 will follow in this case too if we show that
(9.16)                                            q(G′ ) ≪τ,C y 2e−Ct/s .
To do this, we largely follow the proof of Propositions 6.3 and 7.1 in [24]. We give all details for
the ease of the reader.
   As in the proof of Proposition 7.1 above, we define a and b by (9.3) and take note of relations
(9.4) and (9.5). In addition, relation (9.6) implies that
                                                                   ab        ab
(9.17)                        q(G′ ) ≪τ (δ ′ )1+τ µ(E ′) ·               2
                                                                           ·       .
                                                                gcd(a, b) ϕ(a)ϕ(b)
          AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                      21

  It remains to bound µ(E ′ ). First of all, note that

                              P ′ ⊆ R(G(2) ) ∪ P (2) ⊆ R(G(1) ) ∪ P (1) ,

where the second relation follows by (9.12). Let (v, w) ∈ E ′ and let us write v = av ′ and w =
bw ′ . Note that if p|vw but p ∤ v ′ w ′ , then p|ab, and thus p ∈ P ′ ⊆ R(G(1) ) ∪ P (1) . Since
gcd(v, w) = gcd(a, b), we must have that gcd(v ′ , w ′ ) = 1. Together with (9.15), this implies that
Lt (v ′ , w ′) ⩾ 1/(4s). We conclude that
                                                                                         
              ′                ′   ′      ′     ′   gcd(v, w) = gcd(a, b), D(v, w) ⩽ y,
           E ⊆ (v, w) = (av , bw ) ∈ V × W :                         1                      .
                                                    Lt (v ′ , w ′) ⩾ 4s

  Next, let us define wmax (v), vmax (w), w0 and E ′′ as in the proof of Proposition 7.1. We find that
                                       X               1              X        1
(9.18)             q(G′ ) ≪ y 2 ab                           ⩽ y 2 ab                .
                                               ′′
                                                  vmax (w)w0            ′
                                                                          vmax (w)w0
                                     (v,w)∈E                                  (v,w)∈E


If v = v ′ a and w = w ′ b and (v, w) ∈ E ′ , then we know that Lt (v ′ , w ′) ⩾ 1/(4s). In particular, we
see that either
                                  X 1           1        X 1            1
                                          ⩾         or            ⩾
                                   ′
                                       p       8s         ′
                                                                p      8s
                                p|v , p>t                         p|w , p>t

whenever (v, w) ∈ E ′. Consequently,
                                       X               1
                                                             ⩽ S1 + S2 ,
                                                ′
                                                  vmax (w)w0
                                      (v,w)∈E


where
                                                   XX                          1
                              S1 :=                                                     ,
                                                                         vmax (bw ′ )w0
                                          ⩽w0 /b, v′ ⩽vmax (bw ′ )/a
                                       w ′P
                                           p|v ′ , p>t 1/p⩾1/(8s)
                                                   XX                          1
                              S2 :=                                                     .
                                                                         vmax (bw ′ )w0
                                          ⩽w0 /b, v′ ⩽vmax (bw ′ )/a
                                       w ′P
                                            p|w′ , p>t 1/p⩾1/(8s)



For S1 , we note that
                                      X                1                      X
                            S1 ⩽                                                            1
                                                w0 vmax (bw ′ )      ′           ′
                                   w ′ ⩽w0 /b                     P v ⩽vmax (bw )/a
                                                                       ′
                                                                   p|v , p>t 1/p⩾1/(8s)
                                        X                  1       vmax (bw ′ )/a
                               ≪C                                    ·
                                                   w0 vmax (bw ′ )    eCt/s
                                      w ′ ⩽w0 /b
                                        1
                               ⩽
                                     abeCt/s
22                  DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

by Lemma 6.2. Similarly for S2 , we find that
                                   X                               1             X
                     S2 ⩽                                                                         1
                                                             w0 vmax (bw ′ ) ′
                                 P       w ′ ⩽w0 /b                         v ⩽vmax   (bw ′ )/a
                                     p|w′ , p>t 1/p⩾1/(8s)
                                           X                  1
                             ⩽
                                                             aw0
                                 P       w ′ ⩽w0 /b
                                     p|w′ , p>t 1/p⩾1/(8s)

                                  1
                             ≪C       ,
                              abeCt/s
by applying Lemma 6.2 once again. Substituting these bounds into (9.18) establishes (9.16), thus
completing the proof of Proposition 7.2.                                                      
Proof of Proposition 7.3. We use a very similar argument to the one employed in the previous
proof. We highlight only the important changes.
       • We may assume that t is large enough in terms of κ and C; otherwise, the result follows
         from Proposition 7.1.
       • We use the results of Section 8 with M = e4C/κ .
       • We separate Cases 1 and 2 according to whether N > 0.25κ log t or N ⩽ 0.25κ log t.
       • In Case 2, we aim to show that
(9.19)                                         q(G′ ) ≪τ,κ,C y 2t−C .
       • In Case 2, we use Lemma 8.5 with U = κ log t in place of Lemma 8.4 to find G(2) such that
                                            / R(G(1) )} ⩾ 0.5κ log t whenever (v, w) ∈ E (2) .
         #{p|vw/ gcd(v, w)2 : C6 < p ⩽ t, p ∈
       • In Case 2, we note that #{p|vw/ gcd(v, w)2 : p > C6 , p ∈ P (1) } ⩽ N ⩽ 0.25κ log t,
         where we used property (d) of the graph G(1) . Thus #{p|vw/ gcd(v, w)2 : C6 < p ⩽
              / R(G(1) ) ∪ P (1) } ⩾ 0.25κ log t.
         t, p ∈
       • To prove (9.19) and conclude the proof, we apply Lemma 6.3 in place of 6.2.
We leave the details for how to complete the proof of Proposition 7.3 to the reader.                   

                                          10. P ROOF OF L EMMA 8.6
     In this section we establish Lemma 8.6.
     Recall the definition of neighborhood sets (cf. Definition 8). We then have the following lemma.
Lemma 10.1 (Quality increment or all vertices have high degree). Let G = (µ, V, W, E, P, f, g)
be a GCD graph with edge density δ > 0. Then one of the following holds:
     (a) For all v ∈ V and for all w ∈ W, we have
                               1+τ                                      1+τ
                   µ(ΓG (v)) ⩾        · δµ(W) and µ(ΓG (w)) ⩾                  · δµ(V).
                               2+τ                                      2+τ
     (b) There is a GCD subgraph G′ = (µ, V ′ , W ′ , E ′, P, f, g) of G with quality q(G′ ) > q(G).
Proof. Assume that (a) fails. Then either its first or its second inequality fails. Assume that the first
one fails for some v ∈ V; the other case is entirely analogous. Let E ′ be the set of edges between
         AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                   23

the vertex sets V \ {v} and W. Note that
                                                                  
                         ′                                     1+τ
                     µ(E ) = µ(E) − µ(v)µ(ΓG (v)) >         1−       µ(E) > 0
                                                               2+τ
                      1+τ
because µ(ΓG (v)) < 2+τ   δµ(W), µ(v) ⩽ µ(V), and µ(E) > 0 by the assumption that δ > 0. In
particular, we have µ(W), µ(V \ {v}) > 0. We then consider G′ = (µ, V \ {v}, W, E ′, P, f, g),
which is a GCD subgraph of G. Let G′ have edge density δ ′ . We claim that δ ′ ⩾ δ and q(G′ ) ⩾
q(G).
  Indeed, we have
                                                      (1 + τ )δ
     µ(E ′) = µ(E) − µ(v)µ(ΓG (v)) > δµ(V)µ(W) −                µ(v)µ(W)
                                                        2+τ
                                                                      µ(v)       1 
                                       = δ µ(V) − µ(v) µ(W) · 1 +               ·      .
                                                                     µ(V) − µ(v) 2 + τ
Thus the edge density δ ′ of G′ satisfies
                   µ(E ′)            µ(E ′ )             µ(v)       1 
       δ′ =                  =                 >δ· 1+            ·      .
              µ(V \ {v})µ(W)   µ(V) − µ(v) µ(W)        µ(V) − µ(v) 2 + τ
Consequently,
                                                                 µ(v)     
  (δ ′ )2+τ µ(V \ {v})µ(W) > δ 2+τ µ(V) − µ(v) µ(W) 1 +                       = δ 2+τ µ(V)µ(W).
                                                                µ(V) − µ(v)
This proves the claim that q(G′ ) > q(G), thus completing the proof of the lemma.                 
Proof of Lemma 8.6. Let G′ be a (P, f, g)-maximal GCD subgraph of G, and let us apply Lemma
10.1 to G′ . By its maximality, conclusion (a) of Lemma 10.1 must hold. This completes the
proof.                                                                                    

                                  11. L EMMAS ON GCD GRAPHS
Lemma 11.1 (Quality variation for special GCD subgraphs). Let G = (µ, V, W, E, P, f, g) be a
GCD graph, p ∈ R(G) and k, ℓ ∈ Z⩾0 . In addition, if G is non-trivial and µ(Vpk ), µ(Wpℓ ) > 0,
then we have
                                                  
   q(Gpk ,pℓ )     µ(Epk ,pℓ ) 2+τ µ(V) 1+τ µ(W) 1+τ                    p|k−ℓ|
               =                                                                              .
     q(G)           µ(E)           µ(Vpk )     µ(Wpℓ )     (1 − 1k=ℓ⩾1 /p)2 (1 − 1/p1+τ /4 )3
Proof. This follows from directly the definitions.                                                
Lemma 11.2 (One subgraph must have limited quality loss). Let G = (µ, V, W, E, P, f, g) be a
GCD graph with edge density δ > 0, and let V = V1 ⊔ · · · ⊔ VI and W = W1 ⊔ · · · ⊔ WJ be
partitions of V and W. Then there is a GCD subgraph G′ = (µ, V ′ , W ′ , E ′, P, f, g) of G with edge
density δ ′ > 0 such that
                                                   q(G)                 δ
                                       q(G′ ) ⩾        2+τ
                                                           ,     δ′ ⩾     ,
                                                (IJ)                   IJ
and with V ′ ∈ {V1 , . . . , VI }, W ′ ∈ {W1 , . . . , WJ }, and E ′ = E(V ′ , W ′ ).
Proof. This is Lemma 11.2 in [24] with the obvious changes to account for the modified definition
of q(G).                                                                                       
24                  DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

Lemma 11.3 (Few edges between unbalanced sets, I). Let G = (µ, V, W, E, P, f, g) be a GCD
graph with edge density δ > 0. Let p ∈ R(G), r ∈ Z⩾1 and k ∈ Z⩾0 be such that pr > C4 and
                                          µ(Wpk )          C2
                                                    ⩾1−       .
                                           µ(W)             p
(In particular, if p ⩽ C2 , the last hypothesis is vacuous.)
   If we set Lk,r = {ℓ ∈ Z⩾0 : |ℓ − k| ⩾ r + 1}, then one of the following holds:
   (a) There is ℓ ∈ Lk,r such that q(Gpk , pℓ ) > M · q(G).
       P
   (b) ℓ∈Lk,r µ(Epk , pℓ ) ⩽ µ(E)/(4p1+τ /4 ).
                                                        P
Proof. Assume that conclusion (b) does not hold, so ℓ∈Lk,r µ(Epk ,pℓ ) > µ(E)/(4p1+τ /4) and we
wish to establish (a). Then there must exist some ℓ ∈ Lk,r such that
                                                        µ(E)
                                µ(Epk ,pℓ ) >                            > 0,
                                                300 · 2|k−ℓ|/20p1+τ /4
                      P
where we used that |j|⩾0 2−|j|/20 ⩽ 2/(1 − 2−1/20 ) ⩽ 60. In particular, Gpk ,pℓ is a non-trivial
GCD graph. Since µ(Wpk ) ⩾ (1 − C2 /p)µ(W) and ℓ 6= k, we have that µ(Wpℓ ) ⩽ C2 µ(W)/p.
Consequently,
                                                                      
           q(Gpk ,pℓ )     µ(Epk ,pℓ ) 2+τ µ(V) 1+τ µ(W) 1+τ                           p|k−ℓ|
                       =
             q(G)            µ(E)             µ(Vpk )            µ(Wpℓ )          (1 − 1/p1+τ /4 )3
                                     1            2+τ  p 1+τ
                       ⩾                                             p|k−ℓ|
                           300 · 2|k−ℓ|/20p1+τ /4          C2
                                                  |k−ℓ|
                               1              p                          2
                       ⩾     2+τ   1+τ ·      2+τ         · p−1−τ /2−τ /4 .
                         300 C2             2 20
  Note that 0 < τ ⩽ 0.01, so 1 + τ /2 + τ 2 /4 ⩽ 1.01 and (2 + τ )/20 ⩽ 1/9. Since |k − ℓ| ⩾
r + 1 ⩾ 0.99r + 1.01 and p/21/9 ⩾ p8/9 , we have
                                  |k−ℓ|
                                p                            2       88       1
                               2+τ         · p−1−0.5τ −0.25τ ⩾ p 100 r · 101 .
                              2 20                                          2 900
Therefore
                            q(Gpk ,pℓ )           1            88      1
                                        ⩾      2.01  1.01
                                                          · p 100 r · 101 > M
                              q(G)        300 C2                     2 900
                         r
by our assumption that p > C4 (recall (8.1)). This completes the proof of the lemma.                
     Clearly, the symmetric version of Lemma 11.3 also holds:
Lemma 11.4 (Few edges between unbalanced sets, II). Let G = (µ, V, W, E, P, f, g) be a GCD
graph with edge density δ > 0. Let p ∈ R(G), r ∈ Z⩾1 and ℓ ∈ Z⩾0 be such that pr > C4 and
                                       µ(Vpℓ )       C2
                                               ⩾1−      ,
                                        µ(V)         p
and set Kℓ,r = {k ∈ Z⩾0 : |ℓ − k| ⩾ r + 1}. Then one of the following holds:
     (a) There is k ∈ Kℓ,r such that q(Gpk , pℓ ) > M · q(G).
         P
     (b) k∈Kℓ,r µ(Epk , pℓ ) ⩽ µ(E)/(4p1+τ /4 ).
         AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                         25

Lemma 11.5 (Few edges between small sets). Let G = (µ, V, W, E, P, f, g) be a GCD graph with
edge density δ > 0 and let η ∈ (0, 1]. Then one of the following holds:
   (a) For all sets A ⊆ V and B ⊆ W such that µ(A) ⩽ η · µ(V) and µ(B) ⩽ η · µ(W), we have
       µ(E(A, B)) ⩽ η (2+2τ )/(2+τ ) · µ(E).
   (b) There is a GCD subgraph G′ = (µ, V ′ , W ′ , E ′, P, f, g) of G such that q(G′ ) > q(G),
       V ′ ( V and W ′ ( W.
Proof. When η = 1, case (a) holds trivially. When η < 1, the claimed result is Lemma 11.5 in [24]
with the obvious changes to account for the modified definition of q(G).                       
Lemma 11.6 (Subgraph with few edges between all small sets). Let G = (µ, V, W, E, P, f, g)
be a GCD graph with edge density δ > 0, and let η ∈ (0, 1]. Then there is a GCD subgraph
G′ = (µ, V ′ , W ′ , E ′, P, f, g) of G with edge density δ ′ > 0 such that both of the following hold:
   (a) q(G′ ) ⩾ q(G) > 0.
   (b) For all sets A ⊆ V ′ and B ⊆ W ′ such that µ(A) ⩽ η · µ(V ′ ) and µ(B) ⩽ η · µ(W ′ ), we
       have µ(E ′ ∩ (A × B)) ⩽ η (2+2τ )/(2+τ ) µ(E ′).
Proof. By iterating Lemma 11.5.                                                                          
Lemma 11.7. Let G = (µ, V, W, E, P, f, g) be a GCD graph with R♭ (G) = ∅ and edge density
δ > 0. Let p > C6 be a prime in R(G). There exists an integer k ⩾ 0 such that if we let
V ′ = V \ Vpk and W ′ = W \ Wpk , then one of the following holds:
   (a) We have
                                                      C6
                           µ E (V × W ′ ) ∪ (V ′ × W) ⩽ 10 · µ(E).
                                                        10 p
   (b) The GCD subgraph G′ = (µ, V ′ , W ′ , E ′ , P, f, g) of G with E ′ = E(V ′ , W ′ ) satisfies q(G′ ) >
       q(G).
Proof. Let p > C6 be a prime in R(G). Since R♭ (G) = ∅, we must have p ∈ R♯ (G). Therefore
there exists an integer k ⩾ 0 such that
                            µ(Vpk )      C2              µ(Wpk )     C2
(11.1)                              ⩾ 1−          and            ⩾1−    ,
                             µ(V)        p                µ(W)       p
and
(11.2)                 q(Gpa ,pb ) < M · q(G) for all (a, b) ∈ Z2⩾0 with a 6= b.
In particular, we have
                                  µ(V ′ )   C2           µ(W ′ )   C2
                                          ⩽       and            ⩽    .
                                  µ(V)      p            µ(W)      p
By the proof of Lemma 11.5 applied with η = min{1, C2/p} we see that one of the following
holds:
                                2+2τ
   (a) µ(E ′) ⩽ µ(E) · (C2 /p) 2+τ ;
   (b) q(G′ ) > q(G).
26                 DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

If (b) holds, we are done, so let us assume that (a) holds. In particular, we then find that
               XX                                      2+2τ  2+τ1

                                         ′              C2            1              1
(11.3)                  µ(Epa,pb ) = µ(E ) ⩽ µ(E) ·        τ
                                                                     · ⩽ µ(E) · 10
                                                         p            p            10 p
              a,b∈Z⩾0 \{k}

                    10/τ
since p > C6 ⩾ C2 and τ ⩽ 0.01 (recall (8.1)). Moreover, since p > C6 ⩾ C4 , we may apply
Lemmas 11.3 and 11.4 with r = 1. Relation (11.2) tells us that we must in case (b) of these two
lemmas. We must therefore have that
                  X                   µ(E)         X                   µ(E)
(11.4)                  µ(Epk ,pb ) ⩽      and           µ(Epa ,pk ) ⩽      .
                   b⩾0
                                       4p          a⩾0
                                                                        4p
                     |k−b|⩾2                                |a−k|⩾2

In addition, if we take (a, b) = (k, k + 1) in (11.2) and we use Lemma 11.1, we find that
                                                                         1+τ
                    q(Gpk ,pk+1 )     µ(Epk ,pk+1 ) 2+τ µ(V) 1+τ      µ(W)
             M>                   ⩾                                                 p.
                       q(G)             µ(E)            µ(Vpk )     µ(Wpk+1 )
Using (11.1), we find that µ(W)/µ(Wpk+1 ) ⩾ p/C2 . In addition, we have the trivial lower bound
µ(V)/µ(Vpk ) ⩾ 1. Therefore we conclude that
                                                   
                                       µ(Epk ,pk+1 ) 2+τ p2+τ
                                M>                             ,
                                          µ(E)           C21+τ
whence
                                                               1
                                                    (MC21+τ ) 2+τ          C6
(11.5)                       µ(Epk ,pk+1 ) ⩽ µ(E) ·               ⩽ µ(E) · 11
                                                         p                10 p
since C6 ⩾ C4 = 1010 M 2 C22 ⩾ 1012 from (8.1). Similarly, we find that
                                                                                 C6
(11.6)                     µ(Epk ,pk−1 ), µ(Epk+1,pk ), µ(Epk−1,pk ) ⩽ µ(E) ·          ,
                                                                                1011 p
with the convention that Ep0 ,p−1 = Ep−1,p0 = ∅. Combining (11.3), (11.4), (11.5) and (11.6)
completes the proof of the lemma.                                                         
Corollary 11.8. Let G = (µ, V, W, E, P, f, g), p and G′ be as in Lemma 11.7. Then one of the
following holds:
         n                  vw       o   C6
    (a) µ (v, w) ∈ E : p|           2
                                         ⩽ 10 · µ(E);
                          gcd(v, w)       10 p
     (b) q(G′ ) > q(G).
Proof. Let k ∈ Z⩾0 , V ′ and W ′ be as in Lemma 11.7. Assume that conclusion (b) is false. Then
conclusion (a) of Lemma 11.7 must be true. In addition, note that if p|vw/ gcd(v, w)2, then pj kv
and pℓ kw for some j 6= ℓ. In particular we cannot have pk kv and pk kw. Thus
        n                     vw     o                                      C6
                                                           ′        ′
       µ (v, w) ∈ E : p|                  ⩽  µ   E (V × W    ) ∪ (V   × W)    ⩽        · µ(E),
                           gcd(v, w)2                                           1010 p
as claimed.                                                                                    
         AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                            27

                       12. P ROOF OF THE ANATOMICAL L EMMAS 8.4 AND 8.5
Proof of Lemma 8.4. For brevity, let
                                                               X               1
                                          L′t (v, w) =                           .
                                                                             2
                                                                               p
                                                          p|vw/ gcd(v,w)
                                                           p∈R(G), p>t

Since we have assumed that G is maximal, conclusion (b) of Corollary 11.8 cannot hold, and thus
                               n                      vw       o   C6
(12.1)                     µ        (v, w) ∈ E : p|           2
                                                                   ⩽ 10 · µ(E)
                                                    gcd(v, w)       10 p

for every prime p > C6 lying in R(G). Consequently,
              X                         X 1 n                        vw      o
                              ′
                   µ(v)µ(w)Lt(v, w) =          · µ (v, w) ∈ E : p|
                                             p                     gcd(v, w)2
             (v,w)∈E                               p∈R(G)
                                                     p>t
                                                   X C6 µ(E)     C6 µ(E)   µ(E)
                                               ⩽               <         ⩽
                                                   p>t
                                                       1010 p2    1010 t   1010 s

by Corollary 11.8 and our assumption that t ⩾ C6 s ⩾ C6 (recall (8.1)). Now, let us define

                                 E ′ := {(v, w) ∈ E : L′t (v, w) ⩽ 1/(2s)}.

Evidently, we have that
                                X                                   X                              µ(E)
           µ(E \ E ′) =                       µ(v)µ(w) < 2s                  µ(v)µ(w)L′t(v, w) <        .
                                                                                                   1000
                                (v,w)∈E                            (v,w)∈E
                           L′t (v,w)>1/(2s)

                999
Thus µ(E ′ ) ⩾ 1000 µ(E). We then take G′ := (µ, V, W, E ′ , P, f, g) and note that
                                                                  2+τ
                                         q(G′ )          µ(E ′ )           1
                                                =                         ⩾ .
                                         q(G)            µ(E)              2

Hence, since E ′ ⊆ E ⊆ {(v, w) ∈ V × W : Lt (v, w) ⩾ 1/s}, for any (v, w) ∈ E ′ we have
                             X           1                           1  1  1
                                           = Lt (v, w) − L′t (v, w) ⩾ −   = .
                                       2
                                         p                           s 2s  2s
                        p|vw/ gcd(v,w)
                         p∈R(G),
                           /      p>t

This completes the proof.                                                                                   

Proof of Lemma 8.5. For brevity, let
                                                               X
                                         ωt′ (v, w) =                          1.
                                                          p|vw/ gcd(v,w)2
                                                         p∈R(G), C6 <p⩽t
28                DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

As before, using the maximality of G yields (12.1) for each prime p > C6 lying in R(G). Hence,
      X                            X         n                    vw     o
            µ(v)µ(w)ωt′ (v, w) =        1 · µ (v, w) ∈ E : p|
                                                               gcd(v, w)2
     (v,w)∈E                            p∈R(G)
                                        C6 <p⩽t
                                      X C6 µ(E)
                                    ⩽
                                     C6 <p⩽t
                                             1010 p
                                                                         1            1         C µ(E)
                                                                                                   6
                                    ⩽ log log t − log log C6 +                 2
                                                                                 +            2
                                                                      2(log t)     2(log C6 )      1010
                                C6 log log t
                                    ⩽        · µ(E),
                                   1010
where we used [28, Theorem 5] in the third line and the fact C6 > 1010 in the final line. Now, let
us define
                            n                            C6         o
                         ′                     ′
                        E := (v, w) ∈ E : ωt (v, w) ⩽ 9 log log t .
                                                         10
Evidently, we have that
                        X                         X                    ωt′ (v, w)       µ(E)
    µ(E \ E ′ ) =                 µ(v)µ(w) <           µ(v)µ(w) ·       −9
                                                                                      ⩽      .
                                                                   C6 10 log log t        10
                         (v,w)∈E                          (v,w)∈E
                ωt′ (v,w)>C6 10−9 log log t

Thus µ(E ′ ) ⩾ 9µ(E)/10. We then take G′ := (µ, V, W, E ′ , P, f, g) and note that
                                  q(G′ )  µ(E ′ ) 2+τ      1
                                        =               ⩾ .
                                  q(G)       µ(E)            2
By assumption we have E ⊆ {(v, w) ∈ V × W : ωt (v, w) ⩾ U}. Thus, since E ′ ⊆ E, for any
(v, w) ∈ E ′ we have
                X                                           C6                  U
                       1 ⩾ ωt (v, w) − ωt′ (v, w) − C6 ⩾ U − 9 log log t − C6 ⩾
                     2
                                                            10                  2
           p|vw/ gcd(v,w)
          p∈R(G),
           /       C6 <p⩽t

since we have assumed that U ⩾ 2C6 log log t ⩾ 2C62 . This completes the proof.                            

                                     13. P ROOF OF P ROPOSITION 8.1
Lemma 13.1 (Bounds on edge sets). Consider a GCD graph G = (µ, V, W, E, P, f, g) with edge
density δ > 0 and a prime p ∈ R(G). For each k, ℓ ∈ Z⩾0 , let
                                              µ(Vpk )                µ(Wpℓ )
                                   αk =                 and   βℓ =           .
                                               µ(V)                   µ(W)
Then there exist k, ℓ ∈ Z⩾0 such that αk , βℓ > 0 and
                      
                              (1+τ )/(2+τ )
        µ(Epk ,pℓ ) (αk βk )               ,                                    if k = ℓ,
                   ⩾ αk (1 − βk ) + βk (1 − αk ) + αℓ (1 − βℓ ) + βℓ (1 − αℓ )
          µ(E)                                                                , if k 6= ℓ.
                                              2|k−ℓ|/20 × C1
         AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                                    29

Proof. Let X = {(k, ℓ) ∈P  Z2⩾0 : αk , βℓ > 0}. Note that if (k, ℓ) ∈ Z2⩾0 \ X , then µ(Epk ,pℓ ) ⩽
µ(Vpk )µ(Wpℓ ) = 0. Thus (k,ℓ)∈X µ(Epk ,pℓ ) = µ(E). Hence, if we assume that the inequality in
the statement of the lemma does not hold for any pair (k, ℓ) ∈ X , we must have
                                       X µ(Epk ,pℓ )
                                1=                    < S1 + S2 ,
                                              µ(E)
                                         (k,ℓ)∈X

where
                                                  ∞
                                                  X
                                       S1 :=            (αk βk )(1+τ )/(2+τ )
                                                  k=0
and
                       X X αk (1 − βk ) + βk (1 − αk ) + αℓ (1 − βℓ ) + βℓ (1 − αℓ )
               S2 :=                                                                                   .
                        k,ℓ⩾0
                                                              2|k−ℓ|/20 × C1
                         k6=ℓ
Thus, to arrive at a contradiction, it suffices to show that
                                                  S1 + S2 ⩽ 1.
                       P
First of all, note that |j|⩾1 2−|j|/20 = 2/(21/20 − 1) ⩽ 100 and recall from (8.1) that C1 = 104 /τ ,
whence
                    X ∞                 X∞                 X∞                 X∞               
                 τ
        S2 ⩽              αk (1 − βk ) +     βk (1 − αk ) +     αℓ (1 − βℓ ) +     βℓ (1 − αℓ )
               100 k=0                   k=0                ℓ=0                ℓ=0
                   X ∞                 X∞              
                τ
            =            αk (1 − βk ) +     βℓ (1 − αℓ ) .
               50 k=0                   ℓ=0
Observing that                          X                                         X
                           1 − βk =               βℓ     and 1 − αℓ =                       αk ,
                                      ℓ⩾0, ℓ6=k                                 k⩾0, k6=ℓ
we conclude that                                                 
                                                          ∞
                                 τ XX             τ      X
                            S2 ⩽          αk βℓ =     1−     αk βk .
                                 25 k,ℓ⩾0         25     k=0
                                         k6=ℓ
  Let us now study S1 . Since αk , βℓ are non-negative reals which sum to 1, there exists some
k0 ⩾ 0 such that
                                   γ := max αk βk = αk0 βk0 .
                                                  k⩾0
We thus find that
            X ∞
                         1+τ       τ
                                        ∞
                                        X         1       τ
                                                               X
                                                                ∞     12 X
                                                                           ∞    21    τ
      S1 =      (αk βk ) 2+τ ⩽γ 2(2+τ )   (αk βk ) ⩽ γ
                                                  2    2(2+τ )    αk         βℓ = γ 2(2+τ )
             k=0                          k=0                              k=0                ℓ=0
                                                                       P               1/2
where we used the Cauchy–Schwarz inequality to bound k (αk βk )                               from above. We also find
that                                           
                                      X ∞
                              τ                     τ
                         S2 ⩽      1−      αk βk ⩽ (1 − γ).
                              25       k=0
                                                    25
As a consequence,
                                                          τ        τ
                                  S1 + S2 ⩽ γ 2(2+τ ) +               (1 − γ).
                                                                   25
30                  DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG
                         τ
                              τ
The function x 7→ x 2(2+τ ) + 25 (1 − x) is increasing for 0 ⩽ x ⩽ 1, and so maximized at x = 1.
Thus we infer that S1 + S2 ⩽ 1 as required, completing the proof of the lemma.                
Lemma 13.2 (Quality increment unless a prime power divides almost all). Consider a GCD graph
G = (µ, V, W, E, P, f, g) with edge density δ > 0 and a prime p ∈ R(G) with p > C2 . Then one
of the following holds:
     (a) There is a GCD subgraph G′ of G with multiplicative data (P ′ , f ′ , g ′) and edge density
         δ ′ > 0 such that:
              (i) G′ is (P ′ , f ′ , g ′)-maximal;
             (ii) P ′ = P ∪ {p};
           (iii) R(G′ ) ⊆ R(G) \ {p};
            (iv) q(G′ ) ⩾ M 1f ′ (p)6=g′ (p) · q(G);
                     ′                  ′
             (v) pf (p) kv and pg (p) kw for all (v, w) ∈ V × W.
     (b) There is some k ∈ Z⩾0 such that
                             µ(Vpk )     C2                µ(Wpk )     C2
                                     ⩾1−           and             ⩾1−    .
                              µ(V)       p                  µ(W)       p
Proof. Let αk and βℓ be defined as in the statement of Lemma 13.1. Consequently, there are
k, ℓ ∈ Z⩾0 such that αk , βℓ > 0 and
                               
                                        (1+τ )/(2+τ )
              µ(Epk ,pℓ ) (αk βk )                   ,                                            if k = ℓ,
(13.1)                      ⩾ αk (1 − βk ) + βk (1 − αk ) + αℓ (1 − βℓ ) + βℓ (1 − αℓ )
                  µ(E)                                                                       , if k 6= ℓ
                                                        2|k−ℓ|/20 × C1
In particular, µ(Epk ,pℓ ) > 0, so that Gpk ,pℓ is a non-trivial GCD subgraph of G.
   Let (P ′ , f ′ , g ′) be the multiplicative data of Gpk ,pℓ , and let G′ be a (P ′ , f ′ , g ′)-maximal GCD
subgraph of Gpk ,pℓ . We claim that either q(G′ ) ⩾ M 1k6=ℓ q(G), so that G′ satisfies conclusion (a) of
the lemma, or that conclusion (b) holds.
   We separate two cases, according to whether k = ℓ or not.

Case 1: k = ℓ. Lemma 11.1 and our lower bound µ(Epk ,pk )/µ(E) ⩾ (αk βk )(1+τ )/(2+τ ) imply that
                                       
    q(G′ )   q(Gpk ,pℓ )     µ(Epk ,pk ) 2+τ        1                        1
           ⩾             =                   ·              ·                                 ⩾ 1.
    q(G)       q(G)            µ(E)            (αk βk ) 1+τ   (1 − 1k⩾1 /p) (1 − 1/p1+τ /4 )3
                                                                           2

This establishes conclusion (a) in this case, since f ′ (p) = g ′ (p) = k and thus 1f ′ (p)6=g′ (p) = 0.

Case 2: k 6= ℓ. As before, we use Lemma 11.1 and our lower bound on µ(Epk ,pℓ ) to find that
                                           
                      q(G′ )     µ(Epk ,pℓ ) 2+τ                   p|k−ℓ|
                             ⩾                   (αk βℓ )−1−τ
                      q(G)         µ(E)                       (1 − 1/p1+τ /4 )3
                                                         |k−ℓ|
                                    S 2+τ              p
                             ⩾ 2+τ               ·    2+τ        ,
                               C1 (αk βℓ )1+τ        2 20
where
                   S = αk (1 − βk ) + βk (1 − αk ) + αℓ (1 − βℓ ) + βℓ (1 − αℓ ).
Note that
(13.2)                                  S ⩾ αk (1 − βk ) ⩾ αk βℓ .
         AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE               31
                                                                                   P
Indeed, this follows by our assumption that k 6= ℓ, which implies that βk + βℓ ⩽ j⩾0 βj = 1.
Combining the above, we conclude that
                                                              |k−ℓ|
                              q(G′ )     S2      1         p
(13.3)                               ⩾        ·      ·                .
                              q(G)      αk βℓ C12+τ       2+τ
                                                         2 20
If q(G′ ) ⩾ M · q(G), we are done. So let us assume that q(G′ ) < M · q(G). Since |k − ℓ| ⩾ 1, we
must then have that
                                             |k−ℓ|
                        S2            2+τ     2          2MC12.01       C2    1
                  S⩽         ⩽ M · C1 ·               ⩽            ⩽        ⩽ ,
                       αk βℓ                  p               p         10p  10
where we used our assumption that p ⩾ C2 = 10MC13 for the second-to-last inequality (recall
(8.1)). In particular, this gives
                                        C2            S2    1
(13.4)                           S⩽           and          ⩽ .
                                        10p          αk βℓ  10
  We note that
(13.5)           S ⩾ αk (1 − βk ) + βℓ (1 − αℓ ) ⩾ (αk + βℓ )(1 − max{αℓ , βk }).
Thus by the arithmetic-geometric mean inequality, and relations (13.5) and (13.4), we have
                                      (αk + βℓ )2                         S2      1
             (1 − max{αℓ , βk })2 ⩽               (1 − max{αℓ , βk })2 ⩽        ⩽ .
                                        4αk βℓ                           4αk βℓ  40
In particular, max{αℓ , βk } ⩾ 1/2.
   We consider the case when βk ⩾ 1/2; the case with αℓ ⩾ 1/2 is entirely analogous with the
roles of β and α swapped, and the roles of k and ℓ swapped. Thus, to complete the proof of the
lemma, it suffices to show that
                                                         C2
(13.6)                                     αk , βk ⩾ 1 −    .
                                                         p
The first inequality of (13.4) states that
                                                                               C2
                   αk (1 − βk ) + βk (1 − αk ) + αℓ (1 − βℓ ) + βℓ (1 − αℓ ) ⩽     .
                                                                               10p
Since βk ⩾ 1/2 and p ⩾ C2 , we infer that
                                                            2C2      1
                                 1 − αk ⩽ 2βk (1 − αk ) ⩽        ⩽ .
                                                             10p     5
In particular, αk ⩾ 1 − C2 /p and αk ⩾ 1/2, whence
                                                           2C2      C2
                                1 − βk ⩽ 2αk (1 − βk ) ⩽         ⩽     .
                                                           10p       p
This completes the proof of (13.6) and hence of the lemma.                                  
Proof of Proposition 8.1. This follows almost immediately from Lemma 13.2. Since R(G) ⊆
{p > C6 } by assumption, if p ∈ R(G) then p > C6 . We have also assumed that R♭ (G) 6= ∅.
Consequently, there is a prime p ∈ R♭ (G) with p > C6 > C2 . We then have two cases:
Case 1: there exists an integer k ⩾ 0 such that
                           µ(Vpk )       C2          µ(Wpk )     C2
                                   ⩾ 1−        and           ⩾1−    .
                            µ(V)          p           µ(W)       p
32                  DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

Since p ∈/ R♯ (G), there must exist some a pair of distinct integers a, b ⩾ 0 such that q(Gpa ,pb ) ⩾
Mq(G). We then take G′ to be a (P ∪{p}, fpa , gpb )-maximal GCD subgraph of Gpa ,pb . To complete
the proof of the proposition, note that the condition δ > 0 implies that q(G) > 0. Therefore
q(G′ ) ⩾ q(Gpa ,pb ) ⩾ Mq(G) > 0, which also means that δ ′ > 0.
Case 2: for every k ∈ Z⩾0 , we have
                                                   
                                    µ(Vpk ) µ(Wpk )       C2
(13.7)                        min          ,          <1−    .
                                     µ(V) µ(W)            p
We may then apply Lemma 13.2 with this choice of p. By (13.7), conclusion (b) cannot hold, and
so conclusion (a) must hold. This then gives the result.                                    

                                  14. P ROOF OF P ROPOSITION 8.3
     In this section we prove Proposition 8.3.
Lemma 14.1 (Small quality loss or prime power divides positive proportion). Consider a GCD
graph G = (µ, V, W, E, P, f, g) with edge density δ > 0, and let p ∈ R(G) be a prime. Then one
of the following holds:
     (a) There is a GCD subgraph G′ of G with multiplicative data (P ′ , f ′ , g ′) and edge density
         δ ′ > 0 such that
                    P ′ = P ∪ {p},      R(G′ ) ⊆ R(G) \ {p},      q(G′ ) ⩾ q(G)/C3 .
     (b) There is some k ∈ Z⩾0 such that
                                 µ(Vpk )   9             µ(Wpk )  9
                                         ⩾        and            ⩾ .
                                  µ(V)     10             µ(W)    10
Proof. Assume that conclusion (a) does not hold, so we intend to establish (b). For k, ℓ ∈ Z⩾0 ,
let µ(Vpk ) = αk µ(V) and µ(Wpℓ ) = βℓ µ(W). We begin as in the proof of Lemma 13.2, by
considering k, ℓ ∈ Z⩾0 satisfying (13.1) and the inequalities αk , βℓ > 0. We do not need to worry
about the maximality of G′ here, so we shall simply take G′ = Gpk ,pℓ . In particular, G′ is a
non-trivial GCD subgraph of G.
   We note that the proof of Lemma 13.2 up to relation (13.3) requires no assumption on the size
of p. Now, if k = ℓ, then Case 1 of the proof of Lemma 13.2 shows that conclusion (a) must hold,
contradicting our assumption. Therefore we may assume that k 6= ℓ. Now, arguing as in Case 2 of
the proof of Lemma 13.2, and setting
                      S = αk (1 − βk ) + βk (1 − αk ) + αℓ (1 − βℓ ) + βℓ (1 − αℓ ),
we infer that                                          |k−ℓ|
                    1    q(G′ )    S2        1       p            S2    1
                       ⩾        ⩾        · 2+τ ·    2+τ        ⩾      · 3.
                   C3    q(G)     αk βℓ C1         2 20          αk βℓ C1
Therefore we have that
                                          S2     C3      1
                                   S⩽          ⩽ 1 ⩽ 3.
                                         αk βℓ   C3     10
Since S ⩾ (αk + βℓ )(1 − max{αℓ , βk }), we have
                                        (αk + βℓ )2                         S2       1
               (1 − max{αℓ , βk })2 ⩽               (1 − max{αℓ , βk })2 ⩽        ⩽     ,
                                          4αk βℓ                           4αk βℓ   100
         AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                    33

so max{αℓ , βk } ⩾ 9/10. We deal with the case when βk ⩾ 9/10; the case with αℓ ⩾ 9/10 is
entirely analogous with the roles of k and ℓ and the roles of α and β swapped.
   Since βk ⩾ 9/10, we have
                                                                  2
                               1 − αk ⩽ 2βk (1 − αk ) ⩽ 2S ⩽ 3
                                                                 10
In particular, αk ⩾ 9/10 and so conclusion (b) holds, as required.                     
Lemma 14.2 (Adding small primes to P). Let G = (µ, V, W, E, P, f, g) be a GCD graph with
edge density δ > 0. Let p ∈ R(G) be a prime.
  Then there is a GCD subgraph G′ of G with set of primes P ′ and edge density δ ′ > 0 such that
                  P ′ = P ∪ {p},         R(G′ ) ⊆ R(G) \ {p},           q(G′ ) ⩾ q(G)/C5 .
Proof. We first repeatedly apply Lemma 10.1 until we arrive at a GCD subgraph
                                  G(1) = (µ, V (1) , W (1) , E (1) , P, f, g)
of G with edge density δ (1) such that
                                             q(G(1) ) ⩾ q(G),
as well as
                                    1 + τ (1)
                        µ(ΓG(1) (v)) ⩾    · δ µ(W (1) )     for all v ∈ V (1) .
                                    2+τ
(We must eventually arrive at such a subgraph since the vertex sets are strictly decreasing at each
stage but can never become empty since the edge density remains bounded away from 0.)
   We now apply Lemma 14.1 to G(1) . If conclusion (a) of Lemma 14.1 holds, then there is a
GCD subgraph G(2) of G(1) satisfying the conclusion of Lemma 14.2, so we are done by taking
G′ = G(2) . Therefore we may assume that instead conclusion (b) of Lemma 14.1 holds, so there is
some k ∈ Z⩾0 such that
                                     (1)                          (1)
                                µ(Vpk )    9        µ(Wpk )       9
(14.1)                              (1)
                                        ⩾       and       (1)
                                                              ⩾ .
                                µ(V )      10       µ(W )        10
In fact we claim that either the conclusion of Lemma 14.2 holds, or we have the stronger condition
                  (1)           9                           (1)
              µ(Vpk )                      C2          µ(Wpk )          9        C2 
(14.2)                   ⩾ max       ,1 −         and             ⩾ max       ,1 −      .
               µ(V (1) )          10       p            µ(W (1) )          10      p
Relation (14.2) follows immediately from (14.1) if p ⩽ 10C2 , so let us assume that p > 10C2 .
We then apply Lemma 13.2 to G(1) . If conclusion (a) of Lemma 13.2 holds, then there is a GCD
subgraph G(3) of G(1) satisfying the required conditions of Lemma 14.2, so we are done by taking
G′ = G(3) . Therefore we may assume that conclusion (b) of Lemma 13.2 holds, so that there is
                            (1)                                          (1)
some k ′ ⩾ 0 such that µ(Vpk′ )/µ(V (1) ) ⩾ 1 − C2 /p ⩾ 9/10 and µ(Wpk′ )/µ(W (1) ) ⩾ 1 − C2 /p ⩾
9/10. Since there cannot be two disjoint subsets of V (1) of density ⩾ 9/10, we must then have
k ′ = k, thus proving (14.2) in this case too.
    In conclusion, regardless of the size of p we have established (14.2). Next, we fix an integer r ⩽
r0 such that pr > C4 , where r0 is the smallest integer such that 2r0 > C4 , namely r0 = ⌊ log  C4
                                                                                             log 2
                                                                                                   ⌋+1
and we apply Lemma 11.3.
                                                                        (1)
    If conclusion (a) of Lemma 11.3 holds, then we take G′ = Gpk ,pℓ , whose quality satisfies
q(G′ ) ⩾ Mq(G(1) ) ⩾ Mq(G) > 0. In particular, δ ′ > 0, so the proof is complete in this case.
34                  DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

     Thus we may assume that conclusion (b) of Lemma 11.3 holds, so that
                                         X            (1)            µ(E (1) )   µ(E (1) )
                                                 µ(Epk ,pℓ ) ⩽                 <           ,
                                        ℓ∈Lk,r
                                                                     4p1+τ /4      4

where we recall the notation Lk,r = {ℓ ∈ Z⩾0 : |ℓ − k| ⩾ r + 1}. Let
                                                 [        (1)
                                    Wf(1) =            Wpℓ
                                                                  ℓ⩾0 : |ℓ−k|⩽r

and let
                                                               (1)  f(1) ) ⊆ E (1)
                                             E (2) = E (1) ∩ (Vpk × W
                             (1)    f(1) in G(1) . Since µ(V (1)
be the set of edges between Vpk and W                       pk
                                                                 ) ⩾ 9µ(V (1) )/10 and µ(ΓG(1) (v)) ⩾
1+τ                                                       (1)
2+τ
    · δ (1) µ(W (1) ) ⩾ 12 · δ (1) µ(W (1) ) for all v ∈ Vpk , we have

                        (1)            X     (1)
                                                         X                       µ(E (1) )
µ(E (2) ) ⩾ µ E (1) ∩ (Vpk × W (1) ) −     µ(Epk ,pℓ ) ⩾      µ(v)µ(ΓG(1) (v)) −
                                       ℓ∈L                (1)
                                                                                   4
                                                            k,r                   v∈V k
                                                                                        p

                                                                               1 (1)    (1)               µ(E (1) )
                                                                             ⩾   · δ µ(Vpk )µ(W (1) ) −
                                                                               2                            4
                                                                                          
                                                                                 1 9     1                 µ(E (1) )
                                                                             ⩾      · −      · µ(E (1) ) =           > 0.
                                                                                 2 10 4                       5
                 (1) f(1)                                                                           (1)
Let G(2) = (µ, Vpk , W     , E (2) , P, f, g) be the GCD subgraph of G(1) formed by restricting to Vpk
    f(1) . Since µ(E (2) ) > 0, G(2) is a non-trivial GCD subgraph. In addition, we have that
and W
                                      2+τ                  1+τ                  1+τ            2+τ
          q(G(2) )         µ(E (2) )              µ(V (1) )              µ(W (1) )                   1               1
                   =                                                                              ⩾        · 1 · 1 ⩾ 3.
          q(G(1) )         µ(E (1) )                   (1)
                                                  µ(Vpk )                  f(1) )
                                                                         µ(W                         5              5

Finally, we apply Lemma 11.2 to the partition
                                                                      G            (1)
                                                  f(1) =
                                                  W                               Wpℓ
                                                                  ℓ⩾0 : |ℓ−k|⩽r

   f(1) into ⩽ 2 · r + 1 ⩽ 10 log C4 subsets. This produces a GCD subgraph
of W
                                                             (1)       (1)   (1)
                                         G(3) = (µ, Vpk , Wpℓ , Epk ,pℓ , P, f, g)

of G(2) for some ℓ ⩾ 0 with |ℓ − k| ⩽ r such that
                                         q(G(2) )           q(G(1) )       q(G)
                   q(G(3) ) ⩾                    2+τ ⩾          3    ⩾           3 .
                                       10 log C4        10 log C4 · 53   50 log C4
                             (1)
Finally, we note that Gpk ,pℓ is a GCD subgraph of G(3) with set of primes P ∪ {p}, edge density
 (1)                                   (1)                                                  (1)
δpk ,pℓ = δ (3) , and quality q(Gpk ,pℓ ) ⩾ q(G(3) ). Taking G′ = Gpk ,pℓ then gives the result on recalling
the definition (8.1) of C5 .                                                                              
            AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                 35

Proof of Proposition 8.3. If R(G) ∩ {p ⩽ C6 } = ∅, then we can simply take G′ = G.
  If R(G) ∩ {p ⩽ C6 } = 6 ∅, then we can choose a prime p ∈ R(G) ∩ {p ⩽ C6 } and apply Lemma
14.2. We do this repeatedly to produce a sequence of GCD subgraphs
                                       G =: G1  G2  · · ·
such that
(14.3)                                 q(Gi+1 ) ⩾ q(Gi )/C5 .
for each i. In addition, we let Pi denote the set of primes associated to Gi , so that P = P1 ⊆ P2 ⊆
· · · ⊆ P ∪ R(G) ∩ {p ⩽ C6 } .
    At each stage, the set R(Gi ) ∩ {p ⩽ C6 } is strictly smaller than before. So, after at most C6
steps we arrive at a GCD subgraph G(1) = (µ, V (1) , W (1) , E (1) , P (1) , f (1) , g (1) ) of G with
                                                   
                P (1) ⊆ P ∪ R(G) ∩ {p ⩽ C6 } and R(G(1) ) ∩ {p ⩽ C6 } = ∅.
Iterating (14.3) at most C6 times, we find that q(G(1) ) ⩾ q(G)/C5C6 = q(G)/C7 . Thus, taking
G′ = G(1) gives the result.                                                                

                                 15. P ROOF OF P ROPOSITION 8.2
  In this section we prove Proposition 8.2.
Lemma 15.1 (Quality increment even when a prime power divides almost all). Consider a GCD
graph G = (µ, V, W, E, P, f, g) with edge density δ > 0 and let p ∈ R(G) be a prime with
p ⩾ C6 . Then there is a GCD subgraph G′ of G with set of primes P ′ = P ∪ {p} such that
                         R(G′ ) ⊆ R(G) \ {p}      and q(G′ ) ⩾ q(G) > 0.
Proof. First of all, we may assume without loss of generality that for all sets A ⊆ V and B ⊆ W,
we have that
                                                                         
                                µ(E)                       µ(A) µ(B)            C2
(15.1)           µ(E(A, B)) ⩽ 1+ τ whenever max                  ,           ⩽     .
                                p 3                        µ(V) µ(W)             p
Indeed, if G does not satisfy (15.1), then we apply Lemma 11.6 with η = C2 /p to replace G
by a non-trivial subgraph G(1) that does have this property (noticing that (C2 /p)(2+2τ )/(2+τ ) ⩽
1/(p1+τ /3 ) for p ⩾ C6 from the definition (8.1)). In addition, G(1) has the same multiplicative data
as G and its quality is strictly larger. Hence, we may work with G(1) instead. So, from now on, we
assume that (15.1) holds.
   We now apply Lemma 13.2. If conclusion (a) of Lemma 13.2 holds, then we are done. Thus we
may assume that conclusion (b) holds, that is to say there is some k ∈ Z⩾0 such that
                           µ(Vpk )      C2            µ(Wpk )     C2
                                   ⩾ 1−         and           ⩾1−    .
                            µ(V)        p              µ(W)       p
In particular, by (15.1) we see that
                                                         µ(E)
(15.2)                           µ E(V \ Vpk , W \ Wpk ) ⩽ 1+ τ .
                                                          p 3
  Now, set
                 epk = Vpk−1 ∪ Vpk ∪ Vpk+1
                 V                                fpk = Wpk−1 ∪ Wpk ∪ Wpk+1 ,
                                              and W
36                   DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

with the convention that Vp−1 = ∅ = Wp−1 . In view of Lemmas 11.3 and 11.4 applied with r = 1,
we may assume that
                                            X                       µ(E)
(15.3)               µ E(V \ Vepk , Wpk ) =       µ(E(Vpi , Wpk )) ⩽ 1+ τ ,
                                             i⩾0
                                                                    4p 4
                                                  |i−k|⩾2

and
                                             X                      µ(E)
(15.4)                                fpk ) =
                        µ E(Vpk , W \ W           µ(E(Vpk , Wpj )) ⩽ 1+ τ .
                                              j⩾0
                                                                    4p 4
                                                   |j−k|⩾2

Hence, if we let
                                                             epk , Wpk ),
                                                   fpk ) ∪ E(V
                                     E ∗ = E(Vpk , W
then (15.2)-(15.4) imply that
                                                                                   32
                           µ(E ∗)        1      1                          1
                                  ⩾ 1 − 1+ τ − 1+ τ ⩾            1−            τ          > 0,
                           µ(E)        2p 4   p 3                        p1+ 4
where we used our assumption that p ⩾ C6 and the inequality (1 − x)2/3 ⩽ 1 − 2x/3 for x ∈
[0, 1] that follows from Taylor’s theorem. We then consider the non-trivial GCD subgraph G∗ =
(µ, V, W, E ∗ , P, f, g) of G formed by restricting the edge set to E ∗ . Note that
                                                          4+2τ                 2
                    q(G∗ )  µ(E ∗ ) 2+τ              1      3
                                                                              1
(15.5)                      =              ⩾ 1 − 1+ τ             ⩾ 1 − 1+ τ .
                     q(G)        µ(E)                p 4                    p 4
     We set G+ = (µ, V + , W + , E + , P ∪ {p}, f + , g + ), where:
                V + = Vpk ∪ Vpk+1 ,     W + = Wpk ∪ Wpk+1 ,           E + = E ∗ ∩ (V + × W + ),
as well as
                           f + P = f,     f + (p) = k,      g + P = g,     g + (p) = k.
It is easy to check that G+ is a GCD subgraph of G∗ (and hence of G). Note that µ(V + ) ⩾
µ(Vpk ) ⩾ 1 − C2 /p > 0. Similarly, we have µ(W + ) > 0. Consequently, its quality satisfies the
relation
                          2+τ          1+τ          1+τ                    −3
       q(G+ )      µ(E + )         µ(V)           µ(W)            1k⩾1 −2       1
              =                                                1−         1 − 1+ τ      .
       q(G∗ )      µ(E ∗ )        µ(V + )        µ(W + )           p         p 4
(This relation is valid even if µ(E + ) = 0.) We separate two cases.

Case 1: k = 0.
                                                             µ(V)      µ(W)
  In this case Vpk−1 = Wpk−1 = ∅, E + = E ∗ . And note that µ(V + ) , µ(W + ) ⩾ 1. As a consequence,

                                                        −3
                                    q(G+ )           1
                                            ⩾ 1 − 1+ τ        .
                                     q(G∗ )        p 4
Together with (15.5) this implies that
                                                      −1
                                  q(G+ )           1
                                         ⩾ 1 − 1+ τ         ⩾ 1.
                                   q(G)          p 4
In particular, q(G+ ) > 0. Thus the lemma follows by taking G′ = G+ .
          AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                                           37

Case 2: k ⩾ 1.

  In this case we have
                              2+τ          1+τ          1+τ      −2          −3
            q(G+ )     µ(E + )         µ(V)          µ(W)             1           1
(15.6)             =                                               1−        1 − 1+ τ     .
            q(G∗ )     µ(E ∗ )        µ(V + )        µ(W + )          p         p 4

We also consider the GCD subgraphs Gpk ,pk−1 and Gpk−1 ,pk of G. Notice that µ(Vpk ) ⩾ 1−C2 /p >
0 for p ⩾ C6 . Hence, if µ(Wpk−1 ) > 0, then Lemma 11.1 implies that
                                                  2+τ              1+τ                   1+τ
             q(Gpk ,pk−1 )         µ(Epk ,pk−1 )             µ(V)               µ(W)                        p
(15.7)                     =                                                                                         3 .
               q(G∗ )                µ(E ∗ )                µ(Vpk )            µ(Wpk−1 )              1 − 1+1 τ4
                                                                                                            p

Similarly, if µ(Vpk−1 ) > 0, then we have
                                                  2+τ                 1+τ                1+τ
             q(Gpk−1 ,pk )         µ(Epk−1,pk )              µ(V)                  µ(W)                     p
(15.8)                     =                                                                                         3 .
               q(G∗ )                µ(E ∗ )                µ(Vpk−1 )             µ(Wpk )             1 − 1+1 τ4
                                                                                                            p

  Since µ(Vpk ) ⩾ (1 − C2 /p)µ(V), we have that µ(Vpk−1 ) ⩽ C2 µ(V)/p. Similarly, we have that
µ(Wpk−1 ) ⩽ C2 µ(W)/p. To this end, let 0 ⩽ A, B ⩽ C2 be such that

                                µ(Vpk−1 )   A                      µ(Wpk−1 )  B
(15.9)                                    =              and                 = .
                                 µ(V)       p                       µ(W)      p

We note that this implies that

                               µ(V + )     A                       µ(W + )    B
                                       ⩽1−               and               ⩽1− .
                               µ(V)        p                        µ(W)      p

We also note that µ(Epk ,pk−1 ) ⩽ µ(Vpk )µ(Wpk−1 ) ⩽ Bµ(V)µ(W)/p, so if µ(Epk ,pk−1 ) > 0 then
B > 0. Similarly if µ(Epk−1,pk ) > 0 then A > 0.
  Combining (15.6) and (15.9) with (15.5), we find
                                             2+τ
                  q(G+ )            µ(E + )                                     1
(15.10)                  ⩾                                                                  2                .
                   q(G)             µ(E ∗)                  A 1+τ           B  1+τ
                                                      1− p            1− p           1 − 1p        1 − 1+1 τ4
                                                                                                        p

Similarly, provided B > 0, (15.7), (15.9) and (15.5) give
                                                                 2+τ
                       q(Gpk ,pk−1 )              µ(Epk ,pk−1 )                p2+τ
(15.11)                              ⩾                                                     ,
                          q(G)                      µ(E ∗ )              B 1+τ 1 − 1+1 τ4
                                                                                     p

and, provided A > 0, (15.8), (15.9) and (15.5) give
                                                                 2+τ
                        q(Gpk−1 ,pk )              µ(Epk−1,pk )               p2+τ
(15.12)                               ⩾                                                  .
                           q(G)                      µ(E ∗ )             A1+τ 1 − 1+1 τ4
                                                                                     p
38                  DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

We now claim that at least one of the following inequalities holds:
                                         1+τ            1+τ       2           31
                     µ(E + )           A 2+τ          B 2+τ         1 2+τ       1
(15.13)                      > 1−                1−              1−        1 − 1+ τ      ;
                     µ(E ∗)            p               p            p         p 4
                                  1+τ             13
               µ(Epk ,pk−1 )    B 2+τ          1
(15.14)                      >          1 − 1+ τ        ;
                  µ(E ∗ )         p          p 4
                                  1+τ             13
               µ(Epk−1,pk )     A 2+τ          1
(15.15)                      >          1 − 1+ τ       .
                  µ(E ∗ )         p          p 4
If (15.13) holds then q(G+ ) ⩾ q(G) by (15.10). If (15.14) holds, then µ(Epk ,pk−1 ) > 0, so B > 0,
and so q(Gpk ,pk−1 ) ⩾ q(G) by (15.11) and (15.14). Finally, if (15.15) holds, then µ(Epk−1,pk ) > 0,
so A > 0, and so q(Gpk−1 ,pk ) ⩾ q(G) by (15.12) and (15.15). Therefore this claim would com-
plete the proof by choosing G′ ∈ {G+ , Gpk ,pk−1 , Gpk−1 ,pk } according to which of the inequalities
(15.13)-(15.15) hold.
   Since µ(E + ) + µ(Epk ,pk−1 ) + µ(Epk−1,pk ) = µ(E ∗ ), at least one of (15.13)-(15.15) holds if we can
prove that
                      1+τ          1+τ          2          1+τ       1+τ            13
                     A 2+τ          B 2+τ          1 2+τ        B 2+τ    A 2+τ          1
      S :=     1−               1−             1−           +         +            1 − 1+ τ      < 1.
                     p              p              p              p         p         p 4
     Using the inequality 1 − x ⩽ e−x three times, we find that
                          (A + B)(1 + τ ) + 2  B 2+τ   1+τ     1+τ           31
                                                                A 2+τ        1
               S ⩽ exp −                            +         +         1 − 1+ τ      .
                                    p(2 + τ )             p       p        p 4
  Since we also have that e−x ⩽ 1 − x + x2 /2 for x ⩾ 0, as well as 0 ⩽ A, B ⩽ C2 and
0 < τ < 1/100, we conclude that
                                                  1+τ     1+τ           31
                     (A + B)(1 + τ ) + 2 C22 B 2+τ       A 2+τ        1
          S ⩽ 1−                        + 2 +          +         1 − 1+ τ      .
                           p(2 + τ )      p       p        p         p 4
                                       1+τ
     Using the inequality x(1+τ
                             2+τ
                                )+1
                                    ⩾ x 2+τ for x ⩾ 0 and τ > 0 , we obtain that
                                                      31
                                         C22        1
                                   S ⩽ 1+ 2    1 − 1+ τ      .
                                         p        p 4
  Note that C22 /p2 ⩽ 1/(3p1+τ /4 ) for p ⩾ C6 (recall (8.1)). Since (1 − x)1/3 ⩽ 1 − x/3 for
x ∈ [0, 1], we must have that S ⩽ 1 − 1/(9p2+τ /2 ) < 1 for p ⩾ C6 , thus completing the proof of
the lemma.                                                                                     
Proof of Proposition 8.2. This follows almost immediately from Lemma 15.1. Our assumptions
that R(G) ⊆ {p > C6 } and R♯ (G) 6= ∅ imply that there is a prime p > C6 lying in R(G). Thus
we can apply Lemma 15.1 with this choice of p and complete the proof.                     

                     16. O PTIMALITY OF THE EXPONENT 1/2 IN T HEOREM 1
   We shall prove the following result, which is sufficient to prove our claim that the exponent 1/2
in Theorem 1 cannot be improved in full generality.
         AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                            39

Proposition 16.1. Let ψ(q) = 1q prime /q. Then
                        Z 1
                                               2
                             N(α; Q) − Ψ(Q) dα = Ψ(Q) + O(1).
                           0

Proof. Arguing as in the proof of Theorem 2 in Section 7, we have
            Z 1                            XX
                                    2
                  N(α; Q) − Ψ(Q) dα =               λ(Aq ∩ Ar ) − Ψ(Q)2
               0                               q,r⩽Q
                                                          XX
                                           = Ψ(Q) +                   λ(Aq ∩ Ar ) − Ψ(Q)2 .
                                                              q,r⩽Q
                                                               q6=r

   Let q 6= r be two primes. We shall compute λ(Aq ∩ Ar ) by adapting the proof of Lemma 5.1.
In the notation there, we have ℓ = m = 1 and n = qr. Hence,
                                                 X c
                                 λ(Aq ∩ Ar ) = 2      w       ,
                                                  c⩾1
                                                          qr
                                                    (c,qr)=1

where w is defined as in Lemma 5.1. Recall also the definition of δ and ∆ there. With our definition
of ψ, we have δ = 1/ max{q, r}2 and ∆ = 1/ min{q, r}2. By Möbius inversion and estimate (5.3),
we have
                                X c              X         X  c′ d 
               λ(Aq ∩ Ar ) = 2       w        =2        µ(d)       w
                                c⩾1
                                         qr                  c′ ⩾1
                                                                      qr
                                                       d|qr
                                (c,qr)=1

                                               = 4∆δϕ(q)ϕ(r) + O(δ)
                                                                              
                                                                       1
                                               = λ(Aq )λ(Ar ) + O               .
                                                                    max{q, r}2
Hence,
   Z 1                                       XX                                          XX            
                          2                                                       2               1
         N(α; Q) − Ψ(Q)        dα = Ψ(Q) +             λ(Aq )λ(Ar ) − Ψ(Q) + O
     0                                        q,r⩽Q                                      q,r prime
                                                                                                   q2
                                               q6=r                                      r<q⩽Q
                                             X                        XX           
                                                                                 1
                                 = Ψ(Q) −          λ(Aq )2 + O                       .
                                             q⩽Q                       q,r prime
                                                                                 q2
                                                                       r<q⩽Q

The sum of λ(Aq )2 is uniformly boundedPby the choice of ψ. In addition, by the prime number
theorem, the sum inside the big-Oh is ≪ q prime 1/(q log q) ≪ 1. We thus conclude that
                          Z 1
                                              2
                               N(α; Q) − Ψ(Q) dα = Ψ(Q) + O(1),
                           0
as claimed. This completes the proof of the proposition.                                                    

                                      ACKNOWLEDGEMENTS
  The authors would like to thank Manuel Hauke, Santiago Vazquez Saez and Aled Walker for
sharing a preliminary version of their preprint [19] with them. D.Y. would also like to thank
Christoph Aistleitner for introducing him to this problem and for some interesting discussion on
40                   DIMITRIS KOUKOULOPOULOS, JAMES MAYNARD, AND DAODAO YANG

the reference [3]. Finally, we thank the anonymous referees of the paper for their careful reading
and valuable comments.

   D.K. was supported by the Courtois Chair II in fundamental research, by the Natural Sciences
and Engineering Research Council of Canada (RGPIN-2018-05699) and by the Fonds de recherche
du Québec - Nature et technologies (2022-PR-300951).
   J.M. was supported by the European Research Council (ERC) under the European Union’s Hori-
zon 2020 research and innovation programme (grant agreement No 851318).
   D.Y. was supported by a postdoctoral fellowship funded by the Courtois Chair II in fundamental
research, the Natural Sciences and Engineering Research Council of Canada, and the Fonds de
recherche du Québec - Nature et technologies.


                                                   R EFERENCES
 [1] C. Aistleitner, A note on the Duffin-Schaeffer conjecture with slow divergence. Bull. Lond. Math. Soc. 46 (2014),
     no. 1, 164–168.
 [2]          , Decoupling theorems for the Duffin-Schaeffer problem. Progress report (2019), 24 pages,
     arXiv:1907.04590.
 [3] C. Aistleitner, B. Borda and M. Hauke, On the metric theory of approximations by reduced fractions: a quanti-
     tative Koukoulopoulos-Maynard theorem. Compos. Math. 159 (2023), no. 2, 207–231.
 [4] C. Aistleitner, T. Lachmann, M. Munsch, N. Technau, and A. Zafeiropoulos, The Duffin-Schaeffer conjecture
     with extra divergence. Adv. Math. 356 (2019), 106808.
 [5] T. M. Apostol, Mathematical analysis. Second edition. Addison-Wesley Publishing Co., Reading, Mass.-
     London-Don Mills, Ont., 1974.
 [6] V. Beresnevich, V. Bernik, M. Dodson and S. Velani, Classical metric Diophantine approximation revisited.
     Analytic number theory, 38–61, Cambridge Univ. Press, Cambridge, 2009.
 [7] V. Beresnevich, G. Harman, A. K. Haynes and S. Velani, The Duffin-Schaeffer conjecture with extra divergence
     II. Math. Z. 275 (2013), no. 1-2, 127–133.
 [8] V. Beresnevich and S. Velani, A mass transference principle and the Duffin-Schaeffer conjecture for Hausdorff
     measures. Ann. of Math. (2) 164 (2006), no. 3, 971–992.
 [9] P. A. Catlin, Two problems in metric Diophantine approximation. I. J. Number Theory 8 (1976), no. 3, 282–288.
[10] R. J. Duffin and A. C. Schaeffer, Khinchin’s problem in metric Diophantine approximation. Duke Math. J. 8
     (1941), 243–255.
[11] F. J. Dyson, A theorem on the densities of sets of integers. J. London Math. Soc. 20 (1945), 8–14.
[12] P. Erdős, Some results on diophantine approximation. Acta Arith. 5 (1959), no. 4, 359-369.
[13]          , On the distribution of the convergents of almost all real numbers. J. Number Theory 2 (1970), 425–441.
[14] P. Erdős, C. Ko, and R. Rado, Intersection theorems for systems of finite sets. Quart. J. Math. Oxford Ser. (2) 12
     (1961), 313–320.
[15] M. Fuchs, On a problem of W. J. LeVeque concerning metric Diophantine approximation. Trans. Amer. Math.
     Soc. 355 (2003), no.5, 1787–1801.
[16] P. Gallagher, Approximation by reduced fractions. J. Math. Soc. Japan 13 (1961), 342–345.
[17] B. Green and A. Walker, Extremal problems for GCDs. Combin. Probab. Comput. 30 (2021), no.6, 922–929.
[18] G. Harman, Metric number theory, London Mathematical Society Monographs. New Series 18, 1998.
[19] M. Hauke, S. Vazquez Saez and A. Walker, Proving the Duffin–Schaeffer conjecture without GCD graphs. Private
     communication.
[20] A. K. Haynes, A. D. Pollington, S. L. Velani, The Duffin-Schaeffer conjecture with extra divergence. Math. Ann.
     353 (2012), no. 2, 259–273.
[21] A. Khintchine, Einige Sätze über Kettenbrüche, mit Anwendungen auf die Theorie der Diophantischen Approxi-
     mationen. (German) Math. Ann. 92 (1924), no. 1-2, 115–125.
[22] D. Koukoulopoulos, The distribution of prime numbers. Graduate Studies in Mathematics, 203. American Math-
     ematical Society, Providence, RI, 2019.
[23]          , Rational approximations of irrational numbers. EMS Press, Berlin, 2023, 1894–1916.
           AN ALMOST SHARP QUANTITATIVE VERSION OF THE DUFFIN–SCHAEFFER CONJECTURE                               41

[24] D. Koukoulopoulos and J. Maynard, On the Duffin-Schaeffer conjecture. Ann. of Math. (2) 192 (2020), no. 1,
     251–307.
[25] W. J. LeVeque, On the frequency of small fractional parts in certain real sequences. Trans. Amer. Math. Soc. 87
     (1958), 237-260
[26] W. J. LeVeque, On the frequency of small fractional parts in certain real sequences. II Trans. Amer. Math. Soc.
     94 (1960), 130–149.
[27] A. D. Pollington and R. C. Vaughan, R. C., The k-dimensional Duffin and Schaeffer conjecture. Mathematika 37
     (1990), no. 2, 190–200.
[28] J. B. Rosser and L. Schoenfeld, Approximate formulas for some functions of prime numbers. Illinois J. Math. 6
     (1962), 64–94.
[29] W. Schmidt, A Metrical Theorem in Diophantine Approximation. Canadian J. Math. 12 (1960), 619–631.
[30] J. D. Vaaler, On the metric theory of Diophantine approximation. Pacific J. Math. 76 (1978), no. 2, 527–539.

   D ÉPARTEMENT DE MATH ÉMATIQUES ET DE STATISTIQUE , U NIVERSIT É DE M ONTR ÉAL , CP 6128 SUCC .
C ENTRE -V ILLE , M ONTR ÉAL , QC H3C 3J7, C ANADA
   Email address: dimitris.koukoulopoulos@umontreal.ca

   M ATHEMATICAL I NSTITUTE , R ADCLIFFE O BSERVATORY QUARTER , W OODSTOCK ROAD , OXFORD OX2 6GG,
E NGLAND
   Email address: james.alexander.maynard@gmail.com

   D ÉPARTEMENT DE MATH ÉMATIQUES ET DE STATISTIQUE , U NIVERSIT É DE M ONTR ÉAL , CP 6128 SUCC .
C ENTRE -V ILLE , M ONTR ÉAL , QC H3C 3J7, C ANADA
   Email address: yangdao2@126.com
