Petty’s Notebook

Digit-Collision Energy and the Common Reset

About this paperZenodo
Cite this paper

A. S. Petty, Digit-Collision Energy and the Common Reset, DOI: 10.5281/zenodo.24602180.

Abstract

For an odd prime pp, the first p−1p-1 dilates of the sawtooth 2{x}−12\{x\}-1 all jump at zero. With midpoint values at the jumps, the continuous mean square of their sum is the Franel–Landau GCD sum J(p−1)J(p-1). A permutation of the p2p^2 division points identifies the sampled field values with the excesses of carries at equal-digit positions in base pp. The sum of their squares is the digit-collision energy EpE_p. We prove J(p−1)−Ep/p2=1+Oε(p−1/4+ε).J(p-1)-E_p/p^2=1+O_\varepsilon(p^{-1/4+\varepsilon}). Restoring the one-sided value of the square at zero adds exactly (p−1)2/p2(p-1)^2/p^2 to the grid mean. The remaining error tends to zero even as both mean squares grow like pp. For the interior jumps we bound a signed double sum of Dedekind sums by Oε(p7/4+ε)O_\varepsilon(p^{7/4+\varepsilon}). Keeping the second term of the GCD sum then gives Ep=p3−π−2p2(log⁡p)2+O(p2(log⁡p)5/3).E_p=p^3-\pi^{-2}p^2(\log p)^2+O\bigl(p^2(\log p)^{5/3}\bigr). The unit correction also gives the discrepancy of a weighted second moment of L(1,χ)L(1,\chi) over the primitive odd characters modulo p2p^2, relative to the same GCD sum.

November 27, 2026
2020 Mathematics Subject Classification: Primary 11A63, 11K38; Secondary 11A25, 11F20, 11L05
Key words and phrases: digit-collision energy, quadrature error, GCD sums, Dedekind sums, weighted character moments, Kloosterman sums

The common reset and the carry table

Every one of the first p−1p-1 sawtooth waves jumps at zero. Their sum has midpoint value zero there, and its square approaches (p−1)2(p-1)^2 from either side. In the integral the value at that point costs nothing. On the grid of p2p^2 points its weight is 1/p21/p^2. The common jump alone therefore accounts for nearly one unit of mean square. Meanwhile, every reduced fraction with denominator below pp is a jump of at least one wave. Can correcting a single squared sample recover the integral to an error tending to zero when the number of waves grows with the grid?

For an odd prime pp their signed contribution reduces, up to an explicit curvature term, to a double sum of classical Dedekind sums. Writing p2‾\overline{p^2} for the inverse modulo kk and taking s(h,1)=0s(h,1)=0, the estimate we need is ∑k,j=1p−1s(jp2‾,k)≪εp7/4+ε.\sum_{k,j=1}^{p-1}s(j\overline{p^2},k) \ll_\varepsilon p^{7/4+\varepsilon}. Theorem 28 proves it. After division by the number of samples, this bound leaves the common jump as the entire limiting defect.

The same grid arises from a carry count. A digit collision occurs where the two digits of a word agree. In base five these words are 00,11,22,33,4400,11,22,33,44. They occupy one fifth of the table, yet a walk can put more or fewer than one fifth of its carries there. Opposite increments give opposite excesses (Proposition 5), so the signed excesses sum to zero. Squaring each excess before summing retains the size of every surplus and shortfall. We call this total the digit-collision energy.

For an odd prime pp, only primitive odd characters modulo p2p^2 contribute to the carry field. Proposition 7 expresses the digit-collision energy as an explicit multiple of their weighted second moment of L(1,χ)L(1,\chi). Zhang [21] studied the corresponding moment over all nonprincipal characters, with weight ∣∑h=1Nχ(h)∣2|\sum_{h=1}^N\chi(h)|^2. Shparlinski [16] extended the range to include q=p2q=p^2, N=p−1N=p-1. Zhang’s earlier identity for a single Dedekind sum [20] gives another derivation of the moment formula. By bounding the signed contribution of all the interior jumps together, we prove that restoring the squared sample at zero brings the grid mean within Oε(p−1/4+ε)O_\varepsilon(p^{-1/4+\varepsilon}) of the continuous mean square (Theorem 2).

For an integer base b≥2b\ge2, the equal-digit positions are Gb={(b+1)d:0≤d<b}.G_b=\{(b+1)d:0\le d<b\}. For 0≤a<b20\le a<b^2, define Cb(a)=∑n∈Gb(⌊(n+1)ab2⌋−⌊nab2⌋),Fb(a)=Cb(a)−ab,Eb=∑a=0b2−1Fb(a)2.\begin{aligned} C_b(a)&=\sum_{n\in G_b} \left(\left\lfloor\frac{(n+1)a}{b^2}\right\rfloor -\left\lfloor\frac{na}{b^2}\right\rfloor\right), \\ F_b(a)&=C_b(a)-\frac ab,\qquad E_b=\sum_{a=0}^{b^2-1}F_b(a)^2. \end{aligned} Each difference of floors is zero or one. Arrival at an integer counts as a crossing. This convention fixes the value at every boundary. Over all b2b^2 steps the floor differences telescope to aa. The marked words account for a proportion 1/b1/b of the steps, giving the allowance a/ba/b even when the walk revisits a position.

The corresponding field on the circle is built from the centered sawtooth ψ(x)={{x}−12,x∉Z,0,x∈Z,BN(x)=2∑j=1Nψ(jx),\psi(x)=\begin{cases} \{x\}-\tfrac12,&x\notin\mathbb{Z},\\ 0,&x\in\mathbb{Z}, \end{cases} \qquad B_N(x)=2\sum_{j=1}^N\psi(jx), where {x}=x−⌊x⌋\{x\}=x-\lfloor x\rfloor. The jjth wave has period 1/j1/j. We call each jump a reset. The origin is the common reset of all NN waves. For positive integers N,qN,q, put J(N)=∫01BN(x)2 dx,S(N,q)=J(N)−1q∑a=0q−1BN(a/q)2.J(N)=\int_0^1 B_N(x)^2\,dx,\qquad \mathcal S(N,q)=J(N)-\frac1q\sum_{a=0}^{q-1}B_N(a/q)^2. We call S(N,q)\mathcal S(N,q) the sampling defect, taking the integral minus the grid mean. The permutation in Proposition 5 identifies each signed carry excess with a sample of Bb−1B_{b-1}. Thus Eb/b2E_b/b^2 is the mean square of this field on the b2b^2 grid points, and J(b−1)J(b-1) is its mean square over the whole period. Subtracting the grid mean from the period mean gives S(b−1,b2)\mathcal S(b-1,b^2). In base five the squared excesses sum to E5=48E_5=48. Their mean over the 2525 increments is 48/2548/25, while the same four sawtooths have mean square J(4)=23/9J(4)=23/9 over a full period. The difference between the two means is S(4,25)=143/225\mathcal S(4,25)=143/225.

Theorem 1 (Cubic law and its secondary term). As pp tends to infinity through odd primes, Ep=p3−1π2p2(log⁡p)2+O(p2(log⁡p)5/3).E_p=p^3-\frac1{\pi^2}p^2(\log p)^2 +O\bigl(p^2(\log p)^{5/3}\bigr).

The continuous energy is the classical GCD quadratic form J(N)=13∑r,s≤N(r,s)2rs.J(N)=\frac13\sum_{r,s\le N}\frac{(r,s)^2}{rs}. Its leading estimate J(N)=N+O((log⁡N)2)J(N)=N+O((\log N)^2) follows from Hilberdink, Luca and Tóth [9]. Section 3 retains the fractional-floor contribution and obtains J(N)=N−1π2(log⁡N)2+O((log⁡N)5/3).J(N)=N-\frac1{\pi^2}(\log N)^2+O((\log N)^{5/3}). To transfer that coefficient to the finite table, the sampling error must be smaller than (log⁡p)2(\log p)^2. The following estimate resolves the discrepancy on the finer, absolute scale.

Theorem 2 (Unit sampling defect). Let Sp=S(p−1,p2)\mathcal S_p=\mathcal S(p-1,p^2). For every ε>0\varepsilon>0, as pp tends to infinity through odd primes, Sp=J(p−1)−Epp2=1+Oε(p−1/4+ε).\mathcal S_p=J(p-1)-\frac{E_p}{p^2} =1+O_\varepsilon(p^{-1/4+\varepsilon}). Equivalently, Ep=p2[J(p−1)−1]+Oε(p7/4+ε).E_p=p^2[J(p-1)-1]+O_\varepsilon(p^{7/4+\varepsilon}). The implied constants depend only on ε\varepsilon.

On the prime-square grid each individual wave misses only 1/p2−2/(3p4)1/p^2-2/(3p^4) of its continuous mean square. Even after adding p−1p-1 such deficits one obtains a quantity tending to zero. The secondary coefficient in Theorem 1 and the limiting unit in Theorem 2 both come from products of distinct waves (Proposition 29 and Corollary 30).

As the prime increases, the grid is refined and the field gains new waves. The first comparison is available on every integer grid (Proposition 12). The Dedekind representation in Proposition 14 requires the grid size to be coprime to the indices. The all-prime bound takes the cutoff p−1p-1 and the grid p2p^2 together. In particular every inverse frequency below pp is a unit modulo p2p^2.

The notation (r,s)(r,s) denotes the greatest common divisor, μ\mu the Möbius function and τ(n)\tau(n) the number of positive divisors of nn. We write ζ(s)=∑n≥1n−s\zeta(s)=\sum_{n\ge1}n^{-s} for real s>1s>1 and Hn=∑j=1nj−1\mathsf H_n=\sum_{j=1}^n j^{-1}, with H0=0\mathsf H_0=0. All logarithms are natural. The symbols OO and ≪\ll have their usual uniform meaning. Subscripts indicate allowed dependence of the implied constant.

Sawtooth sums for the carry table

The nine two-digit words in base three occupy a circle in numerical order. The steps of a walk are numbered from 00 to 88. Steps 0,4,80,4,8 are marked because their words are 00,11,2200,11,22. With increment one the only carry comes on step 88, when the walk returns to zero. The three marked steps have one carry against a proportional share of 1/31/3, an excess of 2/32/3. With increment eight, step nn starts at 8n mod 98n\bmod 9. The same marked steps now start at 0,5,10,5,1. Two of them carry, against a share of 8/38/3. The two excesses have opposite signs, but each contributes 4/94/9 when squared.

Table 1 displays all nine readings in base three. The three carry rows correspond to the selected words. Their sum is C3C_3, and the last row subtracts the allowance. Thus E3=16/3E_3=16/3.

The complete base-three carry table.
aa 00 11 22 33 44 55 66 77 88
0000 0 0 0 0 0 0 0 0 0
1111 0 0 1 0 1 0 1 0 1
2222 0 1 1 1 1 1 1 1 1
C3(a)C_3(a) 0 1 2 1 2 1 2 1 2
F3(a)F_3(a) 00 23\frac23 43\frac43 00 23\frac23 −23-\frac23 00 −43-\frac43 −23-\frac23

A pair of base-bb digits specifies an interval of width 1/b21/b^2. Counting remainders in the equal-digit intervals of long division gives the floor differences in the carry table. Once those counts are known, a change of address makes every centered count a value of the same sawtooth sum. Write qb=b2q_b=b^2 and let [z]q[z]_q denote the least nonnegative residue modulo qq.

Equal successive digits

In the base-bb expansion of r/ℓr/\ell, with ℓ>b\ell>b prime and 1≤r<ℓ1\le r<\ell, the first digit is δ(r)=⌊br/ℓ⌋\delta(r)=\lfloor br/\ell\rfloor. Long division gives [br]ℓ[br]_\ell as the next remainder, so two successive digits agree precisely when δ(r)=δ([br]ℓ)\delta(r)=\delta([br]_\ell). Replacing bb in the remainder update by any unit gg gives a related question. For which multipliers must the two digits differ at every remainder?

Proposition 3 (Collision-free multipliers). Exactly b−1b-1 multipliers give δ(r)≠δ([gr]ℓ)\delta(r)\ne\delta([gr]_\ell) for every rr. They are g=1−b/c mod ℓg=1-b/c\bmod\ell for 1≤c<b1\le c<b.

Proof. Write x=[br]ℓx=[br]_\ell. Euclidean division gives x≡−ℓδ(r)(modb)x\equiv-\ell\delta(r)\pmod b. Since (ℓ,b)=1(\ell,b)=1 and the digit lies between 00 and b−1b-1, the residue of xx modulo bb determines the digit. As rr runs through the nonzero remainders, so does xx. A collision therefore occurs exactly when y=[gx]ℓy=[gx]_\ell and xx have the same residue modulo bb.

Let Dℓ(g)D_\ell(g) count these collisions. For g≠1g\ne1, write c=[b(1−g)−1]ℓc=[b(1-g)^{-1}]_\ell. The displacement y−xy-x is a nonzero multiple kbkb and x≡−kc(modℓ)x\equiv-kc\pmod\ell. For j=∣k∣j=|k| put z=[jc]ℓz=[jc]_\ell. Since jb<ℓjb<\ell and c≠0c\ne0, we have z≠0z\ne0. The two possible pairs (x,y)(x,y) are (ℓ−z,ℓ−z+jb)and(z,z−jb).(\ell-z,\ell-z+jb)\quad\hbox{and}\quad(z,z-jb). Both lie in {1,…,ℓ−1}2\{1,\ldots,\ell-1\}^2 precisely when z>jbz>jb. The displacement recovers kk. Summing the two contributions at each jj gives Dℓ(g)=2 #{1≤j≤⌊(ℓ−1)/b⌋:[jc]ℓ>jb}.D_\ell(g)=2\,\#\{1\le j\le\lfloor(\ell-1)/b\rfloor: [jc]_\ell>jb\}. If c<bc<b, then jc<jb<ℓjc<jb<\ell throughout this range, and the count is zero. If c>bc>b, the displacement j=1j=1 already gives two collisions. The value c=bc=b would give g=0g=0. For g=1g=1, every remainder gives a collision. The b−1b-1 values 1≤c<b1\le c<b give distinct multipliers g=1−b/cg=1-b/c. ◻

The number of collision-free multipliers is independent of ℓ\ell. Long division uses the particular multiplier bb. For this multiplier the excess count is the field FbF_b of (2), even for a composite denominator coprime to bb.

Proposition 4 (Successive equal digits). Write M=kb2+aM=kb^2+a with (M,b)=1(M,b)=1 and M>b2M>b^2. Among r=1,…,M−1r=1,\ldots,M-1, the number whose first two base-bb digits in r/Mr/M coincide is bk+Cb(a)−1=M/b−1+Fb(a).bk+C_b(a)-1=M/b-1+F_b(a).

Proof. The integer ⌊b2r/M⌋\lfloor b^2r/M\rfloor has the first two digits of r/Mr/M as its base-bb digits, including a leading zero when needed. Both digits are dd precisely on [n/b2,(n+1)/b2)[n/b^2,(n+1)/b^2) for n=(b+1)dn=(b+1)d. With r=0r=0 included, the number in that interval is ⌈(n+1)M/b2⌉−⌈nM/b2⌉\lceil(n+1)M/b^2\rceil-\lceil nM/b^2\rceil. All interior endpoints are nonintegral in units of 1/M1/M. The ceiling count exceeds the floor difference by one at n=0n=0 and falls short by one at n=b2−1n=b^2-1. Both intervals are marked. Their corrections cancel. Substituting M=kb2+aM=kb^2+a leaves kk from each of the bb intervals and Cb(a)C_b(a) from the remaining floor differences. Removing the remainder zero gives the stated count. ◻

Straightening the carry table

Multiplying an increment by 1+b1+b permutes all b2b^2 addresses. Its inverse is 1−b1-b modulo b2b^2, since their product is 1−b21-b^2. At the new address the floor differences in the marked count reduce to a sum of sawtooth values. This identifies the field value even for an increment that revisits positions during its walk.

Proposition 5 (Straightening identity for the carry table). For every integer b≥2b\ge2, Fb([(1−b)A]b2)=Bb−1(A/b2),Eb=∑A=0b2−1Bb−1(A/b2)2.F_b([(1-b)A]_{b^2})=B_{b-1}(A/b^2),\qquad E_b=\sum_{A=0}^{b^2-1}B_{b-1}(A/b^2)^2.

Proof. Each floor is its argument minus its fractional part. The linear terms cancel the centering a/ba/b. Since (1−b)(b+1)d≡d(modb2)(1-b)(b+1)d\equiv d\pmod{b^2}, substitution of a=[(1−b)A]b2a=[(1-b)A]_{b^2} gives two fractional-part sums with indices 0,…,b−10,\ldots,b-1 and 1−b,…,01-b,\ldots,0. Their difference is ∑j=1b−1({jA/b2}−{−jA/b2})=2∑j=1b−1ψ(jA/b2).\sum_{j=1}^{b-1}\bigl(\{jA/b^2\}-\{-jA/b^2\}\bigr) =2\sum_{j=1}^{b-1}\psi(jA/b^2). The equality includes integer arguments. The multiplier 1−b1-b is a unit modulo b2b^2, with inverse 1+b1+b, proving the energy identity. ◻

The continuous comparison comes from the pairwise integral of two sawtooth waves. Franel stated the identity and Landau proved it [1].

Proposition 6 (Franel–Landau sawtooth identity). For every positive integer NN, J(N)=13∑j,k≤N(j,k)2jk.J(N)=\frac13\sum_{j,k\le N}\frac{(j,k)^2}{jk}.

Proof. The nonzero Fourier coefficients of ψ\psi are −1/(2πin)-1/(2\pi i n). The common frequencies of ψ(jx)\psi(jx) and ψ(kx)\psi(kx) are the multiples of their least common multiple. Parseval gives ∫01ψ(jx)ψ(kx) dx=(j,k)212jk.\int_0^1\psi(jx)\psi(kx)\,dx=\frac{(j,k)^2}{12jk}. In the expansion of BN2B_N^2, each ordered pair contributes four times this integral. Their sum gives the formula. ◻

Thus every pair of clocks contributes through its gcd overlap. Primality enters later, when the sampling grid must be coprime to every interior reset denominator.

Primitive odd characters

At an odd prime pp the field vanishes on every multiple of pp in the address table. For A=ptA=pt with p∤tp\nmid t, the waves run once through the nonzero residues modulo pp, whose sawtooth values cancel in pairs. At A=0A=0 each wave vanishes separately. We can therefore expand the entire energy in characters of the unit group. Oddness removes the even characters. A complete sum over the nonzero residues modulo pp removes the induced odd characters as well.

Put Q=p2Q=p^2, U=(Z/QZ)×U=(\mathbb{Z}/Q\mathbb{Z})^\times, ϕ=∣U∣=p(p−1)\phi=|U|=p(p-1) and c=1−pc=1-p. Extend each character modulo QQ by zero on the nonunits, and set Sχ=∑h=1p−1χ(h),B1,χˉ=Q−1 ⁣∑1≤u<Quχˉ(u),F^(χ)=ϕ−1∑a∈UFp(a)χˉ(a).S_\chi=\sum_{h=1}^{p-1}\chi(h),\qquad B_{1,\bar\chi}=Q^{-1}\!\sum_{1\le u<Q}u\bar\chi(u),\qquad \widehat F(\chi)=\phi^{-1}\sum_{a\in U}F_p(a)\bar\chi(a). A primitive character here means one that does not factor through reduction modulo pp. A star below restricts the sum to primitive characters satisfying χ(−1)=−1\chi(-1)=-1.

Proposition 7 (Prime-square character energy). Only primitive odd characters can contribute, and on them F^(χ)=2χˉ(c)ϕB1,χˉSχ.\widehat F(\chi)=\frac{2\bar\chi(c)}{\phi}B_{1,\bar\chi}S_\chi . Consequently Ep=4ϕ∑χ mod Q∗∣B1,χˉSχ∣2,∑χ mod Q∗∣L(1,χ)Sχ∣2=π2(p−1)4p Ep.E_p=\frac4{\phi}\sum_{\chi\bmod Q}^{*}|B_{1,\bar\chi}S_\chi|^2,\qquad \sum_{\chi\bmod Q}^{*}|L(1,\chi)S_\chi|^2 =\frac{\pi^2(p-1)}{4p}\,E_p .

Proof. Under the substitution a=cAa=cA, the field in the transform is the sawtooth sum of Proposition 5. Oddness of Bp−1B_{p-1} removes every even character. For an odd character, substituting u=hAu=hA into each inner sum gives χ(h)∑u∈Uψ(u/Q)χˉ(u)=χ(h)B1,χˉ\chi(h)\sum_{u\in U}\psi(u/Q)\bar\chi(u)=\chi(h)B_{1,\bar\chi}. An odd character induced from modulo pp has Sχ=0S_\chi=0. Character orthogonality on UU gives the first energy formula.

For the last formula put τ=∑u∈Uχˉ(u)e2πiu/Q\tau=\sum_{u\in U}\bar\chi(u)e^{2\pi i u/Q}. Replacing uu by nunu in the exponent multiplies this sum by χ(n)\chi(n) for a unit nn. For p∣np\mid n the exponential is constant on each fibre modulo pp, where primitivity makes the character sum zero. Finite Parseval on Z/QZ\mathbb{Z}/Q\mathbb{Z} now gives ∣τ∣2=Q|\tau|^2=Q. At every u/Qu/Q in the sum the sine series ψ(u/Q)=−π−1∑n≥1sin⁡(2πnu/Q)/n\psi(u/Q)=-\pi^{-1}\sum_{n\ge1}\sin(2\pi n u/Q)/n converges. Oddness turns the finite sum of the sines against χˉ\bar\chi into τχ(n)/i\tau\chi(n)/i. Hence B1,χˉ=−τL(1,χ)/(πi)B_{1,\bar\chi}=-\tau L(1,\chi)/(\pi i), where L(1,χ)=∑n≥1χ(n)/nL(1,\chi)=\sum_{n\ge1}\chi(n)/n. Substitution gives the stated factor. ◻

Zhang’s earlier identity for a single Dedekind sum [20] gives a second derivation of the moment from the ordered pairs s(srˉ,Q)s(s\bar r,Q) in (45). For each divisor dd of QQ, summing χ(srˉ)\chi(s\bar r) over 1≤r,s<p1\le r,s<p gives ∣Sχ∣2|S_\chi|^2 for characters modulo dd. Odd characters modulo pp and their lifts have Sχ=0S_\chi=0. The surviving term at d=Qd=Q has coefficient 4Q/(π2ϕ)4Q/(\pi^2\phi) for EpE_p. The field calculation above also retains the phase χˉ(c)\bar\chi(c) of each coefficient.

For the full nonprincipal moment, Shparlinski’s error bound contains φ(Q)2ω(Q)(log⁡Q)2\varphi(Q)2^{\omega(Q)}(\log Q)^2, where ω(Q)\omega(Q) counts the distinct prime divisors. Put cp=π2(p−1)/(4p)c_p=\pi^2(p-1)/(4p). Relative to cpQJ(p−1)c_p QJ(p-1), the primitive odd moment has correction −cpQ+Oε(p7/4+ε)-c_pQ+O_\varepsilon(p^{7/4+\varepsilon}) by Theorem 2. The error in the full-family estimate allows a term of this size. Here the even characters have zero field coefficient. Walum [18] gives an exact unweighted mean square. For mean squares of odd LL-values and their relation to Dedekind sums, see Louboutin and Munsch [12].

The integer threshold used in counting base-pp blocks gives the same energy after a class correction. For a=pk+s∈Ua=pk+s\in U, 1≤s<p1\le s<p, put V(a)=Cp(a)−1−kV(a)=C_p(a)-1-k and T(a)=2V(a)+1T(a)=2V(a)+1. Then Ep=14∑a∈UT(a)2−(p−1)(p−2)12,∑a∈UV(a)2=14∑a∈UT(a)2+ϕ4.E_p=\frac14\sum_{a\in U}T(a)^2-\frac{(p-1)(p-2)}{12}, \qquad \sum_{a\in U}V(a)^2=\frac14\sum_{a\in U}T(a)^2+\frac{\phi}{4}. Indeed T(a)/2=Fp(a)+s/p−1/2T(a)/2=F_p(a)+s/p-1/2. Each residue class modulo pp has zero sum of FpF_p: its indicator on UU is a linear combination of characters induced from modulo pp, all of which have zero coefficient. The cross term thus vanishes, and p∑s=1p−1(s/p−1/2)2=(p−1)(p−2)/12p\sum_{s=1}^{p-1}(s/p-1/2)^2=(p-1)(p-2)/12. Also ∑a∈UT(a)=0\sum_{a\in U}T(a)=0, giving the second identity.

The second term of the GCD sum

With ten waves, the reduced pair (2,3)(2,3) occurs three times, as (2,3)(2,3), (4,6)(4,6) and (6,9)(6,9). All three pairs contribute the same integral. More generally, a reduced pair with larger index kk occurs ⌊N/k⌋\lfloor N/k\rfloor times. Replacing this count by N/kN/k overcounts the pair by the fractional part of N/kN/k.

Hilberdink, Luca and Tóth [9] give J(N)=N+O((log⁡N)2)J(N)=N+O((\log N)^2). To determine the coefficient on that logarithmic scale, we keep the fractional part of every count and sum it with the weight of its reduced pair. The estimate for these fractional parts comes from Saffari and Vaughan, who adapt a theorem of Walfisz in their proof [15].

Put Hk∗=∑1≤a<k(a,k)=11a(k≥2),H1∗=0.H_k^*=\sum_{\substack{1\le a<k\\(a,k)=1}}\frac1a\quad(k\ge2), \qquad H_1^*=0.

Lemma 8 (The deficit in the continuous mean square). For every positive integer NN, N−J(N)=23N∑k>NHk∗k2+23∑k≤N{Nk}Hk∗k.N-J(N)=\frac23 N\sum_{k>N}\frac{H_k^*}{k^2} +\frac23\sum_{k\le N}\left\{\frac Nk\right\}\frac{H_k^*}{k}. The first term is O(log⁡(2N))O(\log(2N)).

Proof. After multiplying (8) by three, the diagonal contributes NN. For an off-diagonal pair, divide by its gcd and call the larger reduced coordinate kk, the smaller aa. The two orders and the ⌊N/k⌋\lfloor N/k\rfloor scales give 3J(N)=N+2∑k=2N⌊N/k⌋kHk∗.3J(N)=N+2\sum_{k=2}^N\frac{\lfloor N/k\rfloor}{k}H_k^*. Möbius inversion and the classical Euler sum ∑k≥1Hk/k2=2ζ(3)\sum_{k\ge1}\mathsf H_k/k^2=2\zeta(3) [6] give ∑k=2∞Hk∗k2=1ζ(3)∑k=2∞Hk−1k2=1.\sum_{k=2}^\infty\frac{H_k^*}{k^2} =\frac1{\zeta(3)}\sum_{k=2}^\infty\frac{\mathsf H_{k-1}}{k^2}=1. All these sums converge absolutely. Insert ⌊N/k⌋=N/k−{N/k}\lfloor N/k\rfloor=N/k-\{N/k\} and complete the sum to obtain (9). The tail estimate follows from Hk∗≤Hk−1≪log⁡(2k)H_k^*\le \mathsf H_{k-1}\ll\log(2k). ◻

Saffari and Vaughan’s Theorem 6 [15] gives the logarithmically weighted distribution for 2≤Y≤X2\le Y\le X. Its error has an absolute implied constant, uniform in 0≤α≤10\le\alpha\le1. The GCD sum uses its first moment (12). In our notation the distribution estimate is 1log⁡Y∑n≤Y1n1[0,α) ⁣({Xn})=α+O((log⁡X)2/3log⁡Y).\frac1{\log Y}\sum_{n\le Y}\frac1n \mathbf 1_{[0,\alpha)}\!\left(\left\{\frac Xn\right\}\right) =\alpha+O\left(\frac{(\log X)^{2/3}}{\log Y}\right).

Lemma 9 (Weighted fractional parts). For real X≥3X\ge3, W(X):=∑n≤XHn−1n{Xn}=14(log⁡X)2+O((log⁡X)5/3).W(X):=\sum_{n\le X}\frac{\mathsf H_{n-1}}n\left\{\frac Xn\right\} =\frac14(\log X)^2+O\bigl((\log X)^{5/3}\bigr).

Proof. Integrate (10) in α\alpha. Since ∫011[0,α)(u) dα=1−u,\int_0^1\mathbf 1_{[0,\alpha)}(u)\,d\alpha=1-u, one first obtains H⌊Y⌋−AX(Y)=12log⁡Y+O((log⁡X)2/3).\mathsf H_{\lfloor Y\rfloor}-A_X(Y) =\frac12\log Y+O\bigl((\log X)^{2/3}\bigr). Since H⌊Y⌋=log⁡Y+O(1)\mathsf H_{\lfloor Y\rfloor}=\log Y+O(1), rearrangement gives, uniformly for 2≤Y≤X2\le Y\le X, AX(Y):=∑n≤Y1n{Xn}=12log⁡Y+O((log⁡X)2/3).A_X(Y):=\sum_{n\le Y}\frac1n\left\{\frac Xn\right\} =\frac12\log Y+O\bigl((\log X)^{2/3}\bigr). Partial summation gives ∑n≤Xlog⁡nn{Xn}=14(log⁡X)2+O((log⁡X)5/3).\sum_{n\le X}\frac{\log n}{n}\left\{\frac Xn\right\} =\frac14(\log X)^2+O\bigl((\log X)^{5/3}\bigr). Finally, Hn−1=log⁡n+γ+O(1/n)\mathsf H_{n-1}=\log n+\gamma+O(1/n). The constant term contributes O(log⁡X)O(\log X) by (12), and the final error is O(1)O(1). ◻

Theorem 10 (Secondary term of the GCD sum). As N→∞N\to\infty, J(N)=N−1π2(log⁡N)2+O((log⁡N)5/3).J(N)=N-\frac1{\pi^2}(\log N)^2+O((\log N)^{5/3}).

Proof. Write R(N)R(N) for the fractional-part sum in (9). Möbius inversion gives Hk∗=∑d∣kμ(d)dHk/d−1,R(N)=∑d≤Nμ(d)d2W(N/d).H_k^*=\sum_{d\mid k}\frac{\mu(d)}d \mathsf H_{k/d-1},\qquad R(N)=\sum_{d\le N}\frac{\mu(d)}{d^2}W(N/d). For d≤N/3d\le N/3, Lemma 9 bounds each error. Their absolute values are summed with the weights in the last display. For 1≤X<31\le X<3, the defining sum W(X)W(X) is O(1)O(1), so d>N/3d>N/3 contributes O(1/N)O(1/N). Therefore R(N)=14∑d≤Nμ(d)d2(log⁡Nd)2+O((log⁡N)5/3)=14ζ(2)(log⁡N)2+O((log⁡N)5/3).\begin{aligned} R(N)&=\frac14\sum_{d\le N}\frac{\mu(d)}{d^2} \left(\log\frac Nd\right)^2 +O((\log N)^{5/3})\\ &=\frac1{4\zeta(2)}(\log N)^2+O((\log N)^{5/3}). \end{aligned} Extending the main sum from N/3N/3 to NN costs O(1/N)O(1/N). The last equality uses absolute convergence of ∑d−2(1+∣log⁡d∣2)\sum d^{-2}(1+|\log d|^2); the linear and constant logarithmic moments are absorbed by the stated error. Equation (9) now gives N−J(N)=2314ζ(2)(log⁡N)2+O((log⁡N)5/3).N-J(N)=\frac23\frac1{4\zeta(2)}(\log N)^2+O((\log N)^{5/3}). The coefficient follows from ζ(2)=π2/6\zeta(2)=\pi^2/6. ◻

Corollary 11 (Square and triangular GCD/LCM sums). Writing [r,s][r,s] for the least common multiple, we have ∑r,s≤N(r,s)[r,s]=3N−3π2(log⁡N)2+O((log⁡N)5/3),∑1≤r≤s≤N(r,s)[r,s]=2N−32π2(log⁡N)2+O((log⁡N)5/3).\begin{aligned} \sum_{r,s\le N}\frac{(r,s)}{[r,s]} &=3N-\frac3{\pi^2}(\log N)^2+O((\log N)^{5/3}),\\ \sum_{1\le r\le s\le N}\frac{(r,s)}{[r,s]} &=2N-\frac3{2\pi^2}(\log N)^2+O((\log N)^{5/3}). \end{aligned}

Proof. The square sum is 3J(N)3J(N) by Proposition 6, since (r,s)[r,s]=rs(r,s)[r,s]=rs. Symmetry makes the triangular sum one half of the square sum plus one half of its diagonal NN. Apply Theorem 10. ◻

The square-box formula identifies the coefficient in the O((log⁡N)2)O((\log N)^2) error of the earlier leading estimate. To carry it back to the digits we must compare the integral of the squared waves with their mean on the original grid.

Sampling at rational resets

Of the four waves in base five, only the third jumps at 1/31/3. The other three have values −1/3,1/3,−1/3-1/3,1/3,-1/3, so the midpoint field at the jump is −1/3-1/3. The grid of twenty-five points misses 1/31/3, yet the position of this jump between two samples affects the error. At zero the grid hits the jump, and all four waves reset together.

Independent coefficients in the two factors of the square distinguish the wave that jumps in the first factor from the value of the second factor at the same point. The following form of Huxley’s weighted Farey identity [10] also counts the jumps that fall on the grid.

For real coefficient vectors u,vu,v of length NN, put Bu(x)=2∑h≤Nuhψ(hx)B_u(x)=2\sum_{h\le N}u_h\psi(hx) and let Sq(u,v)\mathcal S_q(u,v) be ∫01BuBv−q−1∑a=0q−1Bu(a/q)Bv(a/q)\int_0^1B_u B_v-q^{-1}\sum_{a=0}^{q-1} B_u(a/q)B_v(a/q). Write Ud={1≤a<d:(a,d)=1}\mathcal U_d=\{1\le a<d:(a,d)=1\} for d>1d>1 and set md(u)=∑d∣h, h≤Nuh,α(u)=∑h≤Nhuh,γq(u)=∑h≤N(h,q)2h uh.m_d(u)=\sum_{d\mid h,\,h\le N}u_h,\qquad \alpha(u)=\sum_{h\le N}h u_h,\qquad \gamma_q(u)=\sum_{h\le N}\frac{(h,q)^2}{h}\,u_h . The waves with d∣hd\mid h reset at each reduced fraction a/da/d.

Proposition 12 (Bilinear sampling identity). For all N,q≥1N,q\ge1 the signed discrepancy is Sq(u,v)=1q∑d∣qd≤Nφ(d)md(u)md(v)+2q∑d=2N∑a∈Ud(md(u)Bv(a/d)+md(v)Bu(a/d))ψ(qa/d)−α(u)γq(v)+α(v)γq(u)3q2.\begin{aligned} \mathcal S_q(u,v) &=\frac1q\sum_{\substack{d\mid q\\d\le N}}\varphi(d)m_d(u)m_d(v) \notag\\ &\quad+\frac2q\sum_{d=2}^N\sum_{a\in\mathcal U_d} \bigl(m_d(u)B_v(a/d)+m_d(v)B_u(a/d)\bigr)\psi(qa/d) \notag\\ &\quad-\frac{\alpha(u)\gamma_q(v)+\alpha(v)\gamma_q(u)}{3q^2}. \end{aligned} Here φ(1)=1\varphi(1)=1 counts the origin.

Proof. At x=a/dx=a/d, write Tu=Bu(x)T_u=B_u(x) and mu=md(u)m_u=m_d(u), with the analogous notation for vv. The left and right values of BuB_u are Tu+muT_u+m_u and Tu−muT_u-m_u, and its slope between resets is 2α(u)2\alpha(u). For f=BuBvf=B_u B_v the right value minus the left value and the corresponding jump of its ordinary derivative are [f]x=−2(muTv+mvTu),[f′]x=−4(α(u)mv+α(v)mu).[f]_x=-2(m_uT_v+m_vT_u),\qquad [f']_x=-4\bigl(\alpha(u)m_v+\alpha(v)m_u\bigr). The mean of the one-sided products is TuTv+mumvT_uT_v+m_um_v. An actual grid value uses TuTvT_uT_v. This contributes mumv/qm_um_v/q to the discrepancy precisely when d∣qd\mid q.

For n≠0n\ne0, twice differentiating ff distributionally gives f^(n)=∑xe−2πinx([f]x2πin+[f′]x(2πin)2).\widehat f(n)=\sum_x e^{-2\pi i n x} \left(\frac{[f]_x}{2\pi in}+\frac{[f']_x}{(2\pi in)^2}\right). The remaining ordinary second derivative is constant on the circle away from the finitely many resets, so has zero nnth coefficient. In the grid average of the Fourier series, taken in symmetric Abel limits, only the frequencies divisible by qq remain. The two series of coefficients 1/n1/n and 1/n21/n^2 give ψ\psi and B2(y)={y}2−{y}+1/6B_2(y)=\{y\}^2-\{y\}+1/6. Subtracting the point corrections just calculated gives 1q∑a=0q−1f(a/q)−∫01f=−1q∑d∣qd≤Nφ(d)md(u)md(v)+1q∑x[f]xψ(qx)−12q2∑x[f′]xB2(qx).\begin{aligned} \frac1q\sum_{a=0}^{q-1}f(a/q)-\int_0^1 f &=-\frac1q\sum_{\substack{d\mid q\\d\le N}}\varphi(d)m_d(u)m_d(v) +\frac1q\sum_x[f]_x\psi(qx) \notag\\ &\quad-\frac1{2q^2}\sum_x[f']_xB_2(qx). \end{aligned} All jump sums are finite. For each wave hh the residues qa/hqa/h run through a grid of size h/(h,q)h/(h,q) with multiplicity (h,q)(h,q). Summing the quadratic B2B_2 over this grid gives ∑a=0h−1B2(qa/h)=(h,q)2/(6h)\sum_{a=0}^{h-1}B_2(qa/h)=(h,q)^2/(6h). With these two jump contributions, the negative of (17) gives the stated discrepancy. ◻

For the original equal weights put Md=⌊N/d⌋M_d=\lfloor N/d\rfloor, rd=N mod dr_d=N\bmod d, and define Td,r(a)=2∑j=1rψ(ja/d),A(N,q)=∑d=2NMd∑a∈UdTd,rd(a)ψ(qa/d).T_{d,r}(a)=2\sum_{j=1}^r\psi(ja/d),\qquad \mathcal A(N,q)=\sum_{d=2}^N M_d\sum_{a\in\mathcal U_d}T_{d,r_d}(a)\psi(qa/d). Complete residue periods have zero midpoint sum, so BN(a/d)=Td,rd(a)B_N(a/d)=T_{d,r_d}(a). At a/da/d precisely MdM_d waves jump. The factor Td,rd(a)T_{d,r_d}(a) is what the other waves contribute at that point, and ψ(qa/d)\psi(qa/d) records where the reset lies between grid points.

Corollary 13 (Sampling on a coprime grid). If (q,j)=1(q,j)=1 for 1≤j≤N1\le j\le N, then S(N,q)=N2q+4A(N,q)q−N(N+1)HN3q2.\mathcal S(N,q)=\frac{N^2}q+\frac{4\mathcal A(N,q)}q -\frac{N(N+1)\mathsf H_N}{3q^2}.

Proof. With uh=vh=1u_h=v_h=1 in (15), only the origin belongs to both the grid and the reset set. Here m1=Nm_1=N, α=N(N+1)/2\alpha=N(N+1)/2 and γq=HN\gamma_q=\mathsf H_N. ◻

For an odd prime pp, the carry table has N=p−1N=p-1 and q=p2q=p^2. With Ap=A(p−1,p2)\mathcal A_p=\mathcal A(p-1,p^2) its discrepancy is Sp=N2p2+4App2−NHN3p3.\mathcal S_p=\frac{N^2}{p^2}+\frac{4\mathcal A_p}{p^2} -\frac{N\mathsf H_N}{3p^3}. The reset term tends to one and the curvature term is O(p−2log⁡(2p))O(p^{-2}\log(2p)). To obtain the sampling theorem, it remains to bound the signed sum Ap\mathcal A_p over the interior resets. Figure 1 shows the point correction at base five.

The common reset at N=4N=4, q=25q=25. The curve shows the one-sided squared profile near zero; the filled marks are grid readings. The origin records zero although both limits are 1616. Replacing that one squared sample by 1616 increases the finite average by 16/2516/25. The discrepancy from interior resets is accounted for separately.

For the interior estimate, use the classical Dedekind sum [2] s(h,k)=∑a=1k−1ψ(a/k)ψ(ha/k),s(h,1)=0.s(h,k)=\sum_{a=1}^{k-1}\psi(a/k)\psi(ha/k),\qquad s(h,1)=0. It is periodic and odd in hh. A bar denotes the multiplicative inverse modulo the denominator in use.

Proposition 14 (Dedekind representation). If (q,j)=1(q,j)=1 for every 1≤j≤N1\le j\le N, A(N,q)=2∑k,j≤Ns(jq‾,k).\mathcal A(N,q)=2\sum_{k,j\le N}s(j\overline q,k). All numerator indices occur, including nonunits.

Proof. Complete periods of ψ(ja/d)\psi(ja/d) sum to zero, so the prefix j≤rdj\le r_d in the definition of A(N,q)\mathcal A(N,q) has the same sum as j≤Nj\le N. The multiplicity MdM_d counts the multiples of dd through NN. Collecting the reduced fractions on each larger grid gives A(N,q)=2∑k=1N∑j=1N∑a=1k−1ψ(qa/k)ψ(ja/k).\mathcal A(N,q)=2\sum_{k=1}^N\sum_{j=1}^N\sum_{a=1}^{k-1} \psi(qa/k)\psi(ja/k). Changing variable to qa mod kqa\bmod k turns the inner sum into s(jq‾,k)s(j\overline q,k). ◻

The ratio 3/23/2 on the square grid

The pair (2,3)(2,3) gives a signed term in the defect that we can follow at every prime p>3p>3. The square p2p^2 is one modulo both denominators, so the contribution of this pair can be calculated for all its common multiples at once. The two orders contribute the sum Cq(u,v)=s(vqˉ,u)+s(uqˉ,v),(u,v)=1,u<v.C_q(u,v)=s(v\bar q,u)+s(u\bar q,v),\qquad (u,v)=1,\quad u<v . Grouping (20) by the common factor of its indices gives Ap=2∑u<v<p(u,v)=1⌊p−1v⌋Cp2(u,v).\mathcal A_p=2\sum_{\substack{u<v<p\\(u,v)=1}} \left\lfloor\frac{p-1}{v}\right\rfloor C_{p^2}(u,v). Indeed s(da,dk)=s(a,k)s(da,dk)=s(a,k), by summing the first sawtooth over the dd lifts of each residue modulo kk. The second sawtooth is constant on those lifts. Diagonal terms vanish. For every prime p>3p>3 the square p2p^2 is one modulo six. Thus Cp2(2,3)=−1/18C_{p^2}(2,3)=-1/18, and all the common multiples of the fifth contribute −⌊(p−1)/3⌋/9-\lfloor(p-1)/3\rfloor/9.

At p=5p=5 the fifth lies on the line u+v=pu+v=p. On the entire line, p2≡v2 mod up^2\equiv v^2\bmod u and p2≡u2 mod vp^2\equiv u^2\bmod v. The substitution of a unit times the summation index gives s(a,k)=s(aˉ,k)s(a,k)=s(\bar a,k). Classical reciprocity [2] now gives Cp2(u,v)=s(v,u)+s(u,v)=−14+u2+v2+112uv.C_{p^2}(u,v)=s(v,u)+s(u,v)=-\frac14+\frac{u^2+v^2+1}{12uv}. Every pair on this line is primitive and has multiplier one. Summing over both orders gives (p2+1)Hp−1/(6p)−5(p−1)/12(p^2+1)\mathsf H_{p-1}/(6p)-5(p-1)/12, using 1/(u(p−u))=(1/u+1/(p−u))/p1/(u(p-u))=(1/u+1/(p-u))/p. More generally the same reciprocity calculation holds whenever uv∣p2−u2−v2uv\mid p^2-u^2-v^2. On this family ∣Cp2(u,v)∣≤v/(2u)|C_{p^2}(u,v)|\le v/(2u). For a fixed uu, each vv divides the nonzero integer p2−u2p^2-u^2. Including the original multiplicities bounds the sum of absolute contributions by (p−1)∑u<pτ(p2−u2)/u≪εp1+ε(p-1)\sum_{u<p}\tau(p^2-u^2)/u\ll_\varepsilon p^{1+\varepsilon}.

The digit-alignment count in [13] gives a simple comparison for the same ratio. Among ℓm\ell m cells, ℓ≥3\ell\ge3, mark those numbered 00 or 11 modulo ℓ\ell. Removing the marked point zero and distributing equal weight over the remaining ℓm−1\ell m-1 points changes the marked proportion by 2ℓ−2m−1ℓm−1=ℓ−2ℓ(ℓm−1).\frac2\ell-\frac{2m-1}{\ell m-1} =\frac{\ell-2}{\ell(\ell m-1)}. For prime ℓ∣b−1\ell\mid b-1 and m∣bLm\mid b^L, shifting k/(ℓm)k/(\ell m) by LL base-bb digits leaves (bL/m)k/ℓ(b^L/m)k/\ell. The factor bL/mb^L/m is a unit modulo ℓ\ell. Classes 00 and 11 thus give the terminating tail and the tail of the reference numerator 11, respectively. At m=tu,tvm=tu,tv the ratio of these deficits is (ℓtv−1)/(ℓtu−1)(\ell tv-1)/(\ell tu-1) whenever both denominators have the required support. In base twelve, ℓ=11\ell=11, u=2u=2, v=3v=3 gives the limit 3/23/2.

Multiples on either side of the square

At p=47p=47 the interval of length 4747 just below 47247^2 contains two multiples of 3131. The interval just above it contains one. For 3333 the counts reverse (Figure 2). The side containing the extra multiple determines the sign of the surviving term from this pair of residue classes.

Multiples in the two equal intervals adjacent to 47247^2. Each dot is a multiple of the denominator at the left.

For q=p2q=p^2 and N=p−1N=p-1, the interval II consists of 2N/3<k<3N/42N/3<k<3N/4. At each such kk, the terms with j≡±q mod kj\equiv\pm q\bmod k in (20) have source readings ±s(1,k)\pm s(1,k). The first full cycle of jj contains one of each, with sum zero. The last r=N−kr=N-k terms form a prefix of length less than k/2k/2. Put z=q mod kz=q\bmod k. Let i+(k)i_+(k) be one if z≤rz\le r and zero otherwise, and let i−(k)i_-(k) be one if k−z≤rk-z\le r and zero otherwise. The surviving weights, with the factor two from (20), are w(k)i+(k)w(k)i_+(k) and −w(k)i−(k)-w(k)i_-(k), where summing the squares in s(1,k)s(1,k) gives w(k)=(k−3+2/k)/6w(k)=(k-3+2/k)/6.

Proposition 15. For either sign, as pp tends to infinity through primes, ∑k∈Iw(k)i±(k)=7p21728+Oε(p339/208+ε).\sum_{k\in I}w(k)i_\pm(k)=\frac{7p^2}{1728} +O_\varepsilon(p^{339/208+\varepsilon}).

Proof. Since p=k+r+1p=k+r+1, the count in (q−p,q](q-p,q] is 1+i+(k)1+i_+(k). The count in (q,q+p−1](q,q+p-1] is 1+i−(k)1+i_-(k). A central kk is coprime to pp and lies strictly between (p+1)/2(p+1)/2 and p−1p-1 for large pp. It cannot divide q+p=p(p+1)q+p=p(p+1), so the upper interval extends to q+pq+p with the same count. In particular i+(k)−i−(k)=2⌊qk⌋−⌊q−pk⌋−⌊q+pk⌋.i_+(k)-i_-(k)=2\left\lfloor\frac qk\right\rfloor -\left\lfloor\frac{q-p}{k}\right\rfloor -\left\lfloor\frac{q+p}{k}\right\rfloor . Writing ρ(x)={x}−1/2\rho(x)=\{x\}-1/2, the two individual counts after subtracting one are respectively pk−1+ρ((q−p)/k)−ρ(q/k),pk−1+ρ(q/k)−ρ((q+p)/k).\frac pk-1+\rho((q-p)/k)-\rho(q/k),\qquad \frac pk-1+\rho(q/k)-\rho((q+p)/k). Their common weighted mean is 16∫2p/33p/4(p−t) dt+O(p)=7p2/1728+O(p).\frac16\int_{2p/3}^{3p/4}(p-t)\,dt+O(p)=7p^2/1728+O(p). For each of the three numerators XX, Lemma 3.4 of [11] gives ∑k∈Jρ(X/k)=Oε(p131/208+ε)\sum_{k\in J}\rho(X/k)=O_\varepsilon(p^{131/208+\varepsilon}) on every subinterval JJ of II. Its hypotheses hold with ξ=1\xi=1 and lower dyadic endpoint p/2p/2, since k2≤Xk^2\le X. Partial summation against ww costs O(p)O(p). ◻

The remaining coprime readings make both signs larger still. After the complete cycle on each central row has canceled, put UI=∑k∈I, 1≤j≤N−k(j,k)=1(2s(jqˉ,k))+,VI=∑k∈I, 1≤j≤N−k(j,k)=1(−2s(jqˉ,k))+,U_I=\sum_{\substack{k\in I,\ 1\le j\le N-k\\(j,k)=1}} \bigl(2s(j\bar q,k)\bigr)_+,\qquad V_I=\sum_{\substack{k\in I,\ 1\le j\le N-k\\(j,k)=1}} \bigl(-2s(j\bar q,k)\bigr)_+ , where x+=max⁡(x,0)x_+=\max(x,0). These are the two sign masses of the same part of the original table, in the row order of (20).

Proposition 16. Both UIU_I and VIV_I have order p2(log⁡p)2p^2(\log p)^2.

Proof. Let B=⌊p1/24⌋B=\lfloor p^{1/24}\rfloor. For coprime b,d≤Bb,d\le B, use the central denominators coprime to m=bdm=bd. The two residues ±bqdˉ mod k\pm bq\bar d\bmod k are distinct across all these reduced fractions on each such row, since 2B2<k2B^2<k. Rademacher’s three-term reciprocity law [14, 8] gives s(bdˉ,k)+s(dkˉ,b)+s(kbˉ,d)=k2+b2+d212bdk−14.s(b\bar d,k)+s(d\bar k,b)+s(k\bar b,d) =\frac{k^2+b^2+d^2}{12bdk}-\frac14 . Thus 2s(bdˉ,k)=k/(6bd)+O(b+d+1)≫p/m2s(b\bar d,k)=k/(6bd)+O(b+d+1)\gg p/m uniformly for large pp, using ∣s(a,t)∣≤t/4|s(a,t)|\le t/4. Write z=bqdˉ mod kz=bq\bar d\bmod k. If z/k∈[1/8,1/4]z/k\in[1/8,1/4], this positive reading lies in the prefix. If z/k∈[3/4,7/8]z/k\in[3/4,7/8], its negative lies there. These inclusions use k/3<N−k<k/2k/3<N-k<k/2.

Each window occurs ≫p/m\gg p/m times on each reduced class k mod mk\bmod m, uniformly in b,db,d. To see this, inverse reciprocity gives z/k≡bq/(dk)−bqkˉ/d mod 1z/k\equiv bq/(dk)-bq\bar k/d\bmod1, with the second term constant on the class (zero for d=1d=1). On each window the triangular tent of height one, zero off the window, has area 1/161/16. A real trigonometric polynomial approximates the tent uniformly within 1/1281/128. Subtracting 1/1281/128 gives a minorant of the indicator with mean at least 3/643/64. Both polynomials are fixed before b,d,pb,d,p are chosen. For each of their finitely many nonzero frequencies aa, the phase abq/(dk)abq/(dk) has second derivative of size ≍a(b/d)m2/p\asymp_a (b/d)m^2/p in the progression index. The second derivative estimate [7] bounds the exponential sum on the class by Oa(pb/d+pd/b/m)=Oa(pB)O_a(\sqrt{p b/d}+\sqrt{p d/b}/m)=O_a(\sqrt{pB}). The constant term contributes ≫p/m\gg p/m. Dividing the error by p/mp/m gives O(mB/p)=O(p−19/48)O(m\sqrt{B/p})=O(p^{-19/48}) since m≤B2m\le B^2.

Each sign therefore has mass ≫p2∑(b,d)=1, b,d≤Bφ(bd)/(bd)2\gg p^2\sum_{(b,d)=1,\ b,d\le B}\varphi(bd)/(bd)^2. This sum is asymptotic to (log⁡B)2∏ℓ prime(1−3/ℓ2+2/ℓ3)(\log B)^2\prod_{\ell\ {\rm prime}}(1-3/\ell^2+2/\ell^3). Indeed, give each of b,d≤Bb,d\le B the independent weight 1/(jHB)1/(j\mathsf H_B) at jj. At a prime ℓ\ell, the factor is zero if both are divisible, 1−1/ℓ1-1/\ell if exactly one is divisible, and one otherwise. For any finite set of primes the harmonic weights become uniform on residue classes, giving the indicated product of means. The omitted primes ℓ>L\ell>L change the mean by at most 3∑ℓ>L1/ℓ23\sum_{\ell>L}1/\ell^2, since the probability of divisibility by ℓ\ell is at most 1/ℓ1/\ell. The product is positive. Finally the absolute first moment ∑a∈Uk∣s(a,k)∣≪klog⁡2(2k)\sum_{a\in\mathcal U_k}|s(a,k)|\ll k\log^2(2k) [4] bounds both masses from above on summing over II. ◻

After division by p2p^2, each sign on these rows still grows. The sampling identity adds the two signs together with every remaining row and numerator. It is that complete signed sum which the following sections estimate.

Dedekind sums by additive order

On the six-point grid a frequency of 2/62/6 turns per step completes a turn in three steps. The same frequency occurs at moduli 3,6,93,6,9 and every further multiple of three. In general the denominator of the reduced frequency is its additive order, which we call its conductor. We group the terms in the Dedekind sums by this order.

The numerator at each multiple runs from 11 to the same endpoint NN. At conductor tt the kernel is odd, so every complete period cancels. Only the last N mod tN\bmod t terms remain, however many multiples of tt occur in the original sum. The multiples still determine the weight of that last interval. Throughout, a bar denotes a modular inverse at the indicated modulus, μ\mu is the Möbius function and τ\tau counts positive divisors.

Write e(x)=exp⁡(2πix)\mathrm e(x)=\exp(2\pi ix) and define cot⁡∗(πx)=cot⁡(πx)\cot^*(\pi x)=\cot(\pi x) for x∉Zx\notin\mathbb{Z}, with value zero for x∈Zx\in\mathbb{Z}. The conductor kernel will be denoted by Ct\mathscr C_t, to distinguish it from the carry count CpC_p.

Lemma 17 (Exact-order kernel). For every integer t≥2t\ge2 and every integer hh, Ct(h):=∑d∣tμ(t/d)d s(h,d)=14∑u∈Utcot⁡(πu/t)cot⁡∗(πhu/t),\mathscr C_t(h):=\sum_{d\mid t}\mu(t/d)d\,s(h,d) =\frac14\sum_{u\in\mathcal U_t} \cot(\pi u/t)\cot^*(\pi hu/t), where C1=0\mathscr C_1=0. Consequently, t s(h,t)=∑d∣tCd(h).t\,s(h,t)=\sum_{d\mid t}\mathscr C_d(h). The kernel is odd in hh and has zero sum over a complete period.

Proof. The finite Fourier transform of the integer-zero sawtooth is 1t∑a=0t−1ψ(a/t)e(−ja/t)={i2tcot⁡(πj/t),j≢0(modt),0,j≡0(modt).\frac1t\sum_{a=0}^{t-1}\psi(a/t)\mathrm e(-ja/t) =\begin{cases} \dfrac{i}{2t}\cot(\pi j/t),&j\not\equiv0\pmod t,\\ 0,&j\equiv0\pmod t. \end{cases} It follows by differentiating the finite geometric sum, or directly by summing azaa z^a at a nontrivial tt-th root of unity. Fourier inversion in one factor of s(h,t)s(h,t) gives t s(h,t)=14∑j=1t−1cot⁡(πj/t)cot⁡∗(πhj/t).t\,s(h,t)=\frac14\sum_{j=1}^{t-1} \cot(\pi j/t)\cot^*(\pi hj/t). This computation permits nonunit hh. Group the terms according to d=t/(j,t)d=t/(j,t), writing j/t=u/dj/t=u/d with u∈Udu\in\mathcal U_d. The resulting sum is (23) with the cotangent kernel in (22). Divisor Möbius inversion gives its first expression. Oddness follows from the sawtooth definition. For each unit uu, multiplication by uu permutes the residues, whose odd cotangent sum is zero. This proves the complete-period assertion. ◻

Assume throughout this section that gcd⁡(q,k)=1\gcd(q,k)=1 for 1≤k≤N1\le k\le N. Put mt=⌊N/t⌋m_t=\lfloor N/t\rfloor and rt=N mod tr_t=N\bmod t.

Proposition 18 (Harmonic weight of a conductor). The entire interior source is A(N,q)=2∑t=2NHmtt∑a=1rtCt(aq‾).\mathcal A(N,q)=2\sum_{t=2}^N\frac{\mathsf H_{m_t}}t \sum_{a=1}^{r_t}\mathscr C_t(a\overline q).

Proof. After substitution of (23) into (20), each original modulus has the form k=tℓk=t\ell and contributes the factor 1/(tℓ)1/(t\ell). The numerator sum is through the same NN for every lift. Complete periods of Ct(aq‾)\mathscr C_t(a\overline q) cancel, leaving the prefix rtr_t. Summing 1/ℓ1/\ell over ℓ≤N/t\ell\le N/t gives Hmt\mathsf H_{m_t}. Every sum is finite and every original modulus is retained. ◻

For a residue aa modulo tt, represented in 0,…,t−10,\ldots,t-1, define Δr(a;t)=1a≤r−1t−a≤r(0<a<t),Δr(0;t)=0.\Delta_r(a;t)=\mathbf 1_{a\le r}-\mathbf 1_{t-a\le r}\quad(0<a<t), \qquad \Delta_r(0;t)=0. This signed pair of endpoint indicators is odd. It records the prefix and its reflection together, including equality at either endpoint.

Proposition 19 (Fourier expansion of the signed cutoff). For 1≤u,v,j<t/21\le u,v,j<t/2, (u,t)=1(u,t)=1, put fN,q(t;u,v,j)=4t2cot⁡(πu/t)cot⁡(πv/t)sin⁡(πjN/t)sin⁡(πj(N+1)/t)sin⁡(πj/t)⋅sin⁡(2πjqvu‾/t).\begin{aligned} f_{N,q}(t;u,v,j)={}&\frac4{t^2}\cot(\pi u/t)\cot(\pi v/t) \frac{\sin(\pi jN/t)\sin(\pi j(N+1)/t)}{\sin(\pi j/t)}\notag\\ &\hspace{15mm}\cdot\sin(2\pi jqv\overline u/t). \end{aligned} Then A(N,q)=∑t=2NHmt∑1≤u,v,j<t/2(u,t)=1fN,q(t;u,v,j).\mathcal A(N,q)=\sum_{t=2}^N\mathsf H_{m_t} \sum_{\substack{1\le u,v,j<t/2\\(u,t)=1}}f_{N,q}(t;u,v,j). Completing the endpoint frequency gives A(N,q)=∑t=2NHmtt∑1≤u,v<t/2(u,t)=1cot⁡(πu/t)cot⁡(πv/t)Δrt(qvu‾;t).\mathcal A(N,q)=\sum_{t=2}^N\frac{\mathsf H_{m_t}}t \sum_{\substack{1\le u,v<t/2\\(u,t)=1}} \cot(\pi u/t)\cot(\pi v/t)\Delta_{r_t}(qv\overline u;t). Only uu is restricted to units. All nonunit vv and jj are included.

Proof. Oddness replaces twice the prefix in (24) by a full period weighted by Δrt\Delta_{r_t}. Insert the cotangent expression (22) and change variable to v=aq‾u(modt)v=a\overline q u\pmod t. This gives the double sum over all nonzero u,vu,v, with factor Hmt/(4t)\mathsf H_{m_t}/(4t). Each of the four sign choices has the same product. Restricting to 0<u,v<t/20<u,v<t/2 therefore gives (28). The zero and half-period cotangent terms vanish.

The normalized finite Fourier coefficients of the endpoint indicator are Δ^r(j)=−2itsin⁡(πjr/t)sin⁡(πj(r+1)/t)sin⁡(πj/t)(j≢0(modt)),\widehat\Delta_r(j)=-\frac{2i}{t} \frac{\sin(\pi jr/t)\sin(\pi j(r+1)/t)}{\sin(\pi j/t)} \quad(j\not\equiv0\pmod t), and its mean is zero. Pairing jj with −j-j in Fourier inversion introduces 4/t4/t times the corresponding sine factor. The half-period coefficient, when present, is zero. Finally rt=N−mttr_t=N-m_t t, so the two signs (−1)jmt(-1)^{jm_t} cancel in the product of sines. This proves (26), with the literal endpoints NN and N+1N+1. ◻

In the triple sum, vv enters the last sine linearly, uu enters through its inverse modulo tt, and jj comes from the cutoff at the end of the numerator interval. We shall truncate vv and jj. The sum over uu will run over its full range.

Small conductors

For the original carry table let pp be an odd prime, N=p−1N=p-1 and q=p2q=p^2. Write Ap=A(N,q)\mathcal A_p=\mathcal A(N,q), fp(t;u,v,j)=fN,q(t;u,v,j)f_p(t;u,v,j)=f_{N,q}(t;u,v,j) and ℓ=log⁡(2p)\ell=\log(2p). After the complete periods cancel, one prefix remains at each conductor. Through t=⌊p3/4⌋t=\lfloor p^{3/4}\rfloor, summing the absolute bounds for these prefixes costs O(p3/2ℓ3)O(p^{3/2}\ell^3). At the larger conductors we shall need the signs.

The elementary inequality ∣cot⁡(πx)∣≤[2min⁡(x,1−x)]−1|\cot(\pi x)|\le[2\min(x,1-x)]^{-1} for 0<x<10<x<1 gives ∑a=1t−1∣cot⁡(πa/t)∣≤tHt.\sum_{a=1}^{t-1}|\cot(\pi a/t)|\le t\mathsf H_t. Since each u∈Utu\in\mathcal U_t permutes the residues, (22) implies ∑h=0t−1∣Ct(h)∣≤t2Ht2/4.\sum_{h=0}^{t-1}|\mathscr C_t(h)| \le t^2\mathsf H_t^2/4. Oddness makes the total positive and negative masses equal. Any prefix, including one permuted by q‾\overline q, is therefore bounded by half the total absolute mass. Put K=⌊p3/4⌋K=\lfloor p^{3/4}\rfloor. Multiplying by 2Hmt/t2\mathsf H_{m_t}/t and summing t/4t/4 through KK gives ∑t≤K∣2Hmtt∑a≤rtCt(aq‾)∣≤HNK(K+1)HK28≪p3/2log⁡3(2p).\sum_{t\le K}\left|\frac{2\mathsf H_{m_t}}t \sum_{a\le r_t}\mathscr C_t(a\overline q)\right| \le\frac{\mathsf H_N K(K+1)\mathsf H_K^2}{8} \ll p^{3/2}\log^3(2p). This includes every frequency at those conductors.

Bounds for the Fourier tails

In the sum over vv, a phase increment close to an integer number of turns can give a large geometric sum. How often can this happen as the conductor varies? Fixing the residue of the increment restricts the conductor to divisors of one integer. The same argument applies to jj once we expand the two sine factors that record the endpoint. This lets us bound both tails while keeping every inverse frequency uu.

The linear phase

For fixed uu and jj, the phase in the sum over vv advances by qju‾/tqj\overline u/t turns per step. Write zz for the centered residue of qju‾qj\overline u modulo tt. When ∣z∣/t|z|/t is small, consecutive terms turn slowly and the geometric bound weakens. For fixed u,j,zu,j,z, however, every eligible tt divides qj−uzqj-uz. The choice q=p2q=p^2 makes this integer positive, so its divisor count bounds the number of such moduli.

Write τ∗(p)=max⁡1≤n≤2p3τ(n)\tau_*(p)=\max_{1\le n\le 2p^3}\tau(n), so that τ∗(p)≪εpε\tau_*(p)\ll_\varepsilon p^\varepsilon for every ε>0\varepsilon>0.

Lemma 20 (Nonzero determinant count). Let 2≤t<p2\le t<p and 1≤b<p/21\le b<p/2. For every 0<u<t/20<u<t/2, (u,t)=1(u,t)=1, let zz be the centered residue of qbu‾(modt)qb\overline u\pmod t. Then z≠0z\ne0 if b<t/2b<t/2, and t∣qb−uz,0<qb−uz<2p3.t\mid qb-uz,\qquad 0<qb-uz<2p^3. For fixed b,u,zb,u,z there are at most τ∗(p)\tau_*(p) possible t<pt<p. Also, for 1≤M≤p1\le M\le p, ∑0<∣z∣≤p/2min⁡(M,p/∣z∣)≪plog⁡(2p).\sum_{0<|z|\le p/2}\min(M,p/|z|)\ll p\log(2p).

Proof. The congruence follows from uu‾≡1(modt)u\overline u\equiv1\pmod t. Since qq and uu are units, zero would imply t∣bt\mid b, impossible for 0<b<t/20<b<t/2. Also ∣uz∣<p2/4|uz|<p^2/4 while qb≥p2qb\ge p^2, proving the strict lower bound. The upper bound follows from b<p/2b<p/2. The last estimate follows by splitting at ∣z∣=p/M|z|=p/M, or by the harmonic sum. No zero determinant is charged as a divisor. ◻

Proposition 21 (Linear-frequency tail). For 1≤V≤p1\le V\le p, the part of (26) with v>Vv>V has magnitude Oε(p2+ε/V)O_\varepsilon(p^{2+\varepsilon}/V). The same bound holds if uu or jj is restricted to any initial interval, and if the moduli are restricted to any subset.

Proof. Split v>Vv>V into dyadic intervals of scale W≥VW\ge V. For fixed t,u,jt,u,j, the coefficient outside cot⁡(πv/t)sin⁡(2πjqvu‾/t)\cot(\pi v/t)\sin(2\pi jqv\overline u/t) has magnitude O(1/(uj))O(1/(uj)). On the retained interval the cotangent is positive decreasing, with sup norm plus variation O(t/W)O(t/W). The geometric-sum estimate and summation by parts therefore give ∣∑v∼Wfp(t;u,v,j)∣≪pujWmin⁡(W,p/∣z∣),z=[qju‾]tcent.\left|\sum_{v\sim W}f_p(t;u,v,j)\right| \ll\frac{p}{ujW}\min(W,p/|z|),\qquad z=[qj\overline u]_t^{\rm cent}. The cutoff v<t/2v<t/2 can shorten the last interval. In summing over t,u,jt,u,j we bound Hmt\mathsf H_{m_t} by HN\mathsf H_N. All terms of the bound are positive, so the sums over tt and zz may be interchanged. By Lemma 20 with b=jb=j, each fixed (u,j,z)(u,j,z) occurs for at most τ∗(p)\tau_*(p) moduli. Thus the block cost is at most CpHNτ∗(p)W∑u,j<p/21uj∑0<∣z∣≤p/2min⁡(W,p/∣z∣)≪p2τ∗(p)log⁡4(2p)W.\frac{Cp\mathsf H_N\tau_*(p)}W \sum_{u,j<p/2}\frac1{uj} \sum_{0<|z|\le p/2}\min(W,p/|z|) \ll\frac{p^2\tau_*(p)\log^4(2p)}W. The dyadic sum of 1/W1/W is O(1/V)O(1/V), proving the proposition. ◻

The three endpoint phases

The two endpoint factors contain N=p−1N=p-1 and N+1=pN+1=p. Expanding their product leaves the original linear phase in jj and two shifted phases. The shifts are ±(p−1/2)\pm(p-1/2) in the phase numerator. Doubling that numerator gives an odd integer in the shifted cases, so the geometric sum never encounters a zero residue there.

Proposition 22 (Endpoint-frequency tail). For 1≤J≤p1\le J\le p, the part of (26) with j>Jj>J has magnitude Oε(p2+ε/J)O_\varepsilon(p^{2+\varepsilon}/J). The same estimate holds after initial-interval restrictions on u,vu,v and arbitrary modulus selection.

Proof. The product-to-sum identity gives the amplitudes a0(t)=2t2cot⁡(πu/t)cot⁡(πv/t)cot⁡(πj/t),a±(t)=−1t2cot⁡(πu/t)cot⁡(πv/t)csc⁡(πj/t).\begin{aligned} a_0(t)&=\frac2{t^2}\cot(\pi u/t)\cot(\pi v/t)\cot(\pi j/t),\\ a_\pm(t)&=-\frac1{t^2}\cot(\pi u/t)\cot(\pi v/t)\csc(\pi j/t). \end{aligned} On a dyadic jj interval of scale WW, the positive cotangent and cosecant factors decrease. Their sup norms plus variations in jj are O(t/(uvW))O(t/(uvW)). The phases are 2πjωη/t2\pi j\omega_\eta/t, with ωη=qvu‾+η(p−1/2),η=0,1,−1.\omega_\eta=qv\overline u+\eta(p-1/2),\qquad \eta=0,1,-1. Let yy be the centered residue of 2ωη2\omega_\eta modulo 2t2t. It is nonzero. For η=0\eta=0 this follows from 0<v<t/20<v<t/2, and for η=±1\eta=\pm1 it is odd. The geometric bound for a block is ≪puvWmin⁡(W,p/∣y∣)\ll\frac{p}{uvW}\min(W,p/|y|) up to an absolute constant. For fixed u,v,y,ηu,v,y,\eta, every contributing modulus satisfies 2t∣Dη:=2qv+ηu(2p−1)−uy.2t\mid D_\eta:=2qv+\eta u(2p-1)-uy. Moreover 0<Dη<2p30<D_\eta<2p^3. Here u<p/2u<p/2, ∣y∣≤t<p|y|\le t<p, so Dη>2p2−p2−p2/2>0D_\eta>2p^2-p^2-p^2/2>0. The upper bound follows from v<p/2v<p/2. Each such modulus is a divisor of this fixed nonzero integer. Sum over 0<∣y∣≤p0<|y|\le p, use the harmonic bound corresponding to (31), and sum 1/u1/u and 1/v1/v. The resulting block cost is O(p2τ∗(p)log⁡4(2p)/W)O(p^2\tau_*(p)\log^4(2p)/W). Summing the dyadic blocks proves the claim. All three phases were included. ◻

Completion of the reciprocal sums

Even at fixed frequencies the conductor tt varies. The inverse of uu modulo tt changes with it, which makes cancellation across consecutive tt hard to see. Reciprocity gives a periodic factor depending only on t mod ut\bmod u and a smooth phase proportional to 1/t1/t. Expanding the periodic factor in its finite Fourier series leaves uu linear twists of that same smooth phase.

Twists with derivative near an integer

When the derivative of a phase is close to an integer, successive terms of its exponential sum can point in nearly the same direction. The twist indexed by hh shifts the derivative by h/uh/u. Since these shifts are equally spaced, the range of the derivative bounds the number of twists that need the second-derivative estimate. For the others the distance to the nearest integer gives a first-derivative bound.

For a compact interval D⊂RD\subset\mathbb R, put dh=dist⁡(h/u,D+Z),0≤h<u.d_h=\operatorname{dist}(h/u,D+\mathbb Z),\qquad 0\le h<u. Here the distance is the usual distance on the circle, or equivalently the infimum of ordinary distances to all integer translates.

Lemma 23 (Grid distances). If u≥1u\ge1 is an integer and DD has length δ<1/4\delta<1/4, then #{h:dh≤1/u}≤uδ+4,∑dh>1/u1dh≤4uHu.\#\{h:d_h\le1/u\}\le u\delta+4,\qquad \sum_{d_h>1/u}\frac1{d_h}\le4u\mathsf H_u.

Proof. Enlarge the arc DD by 1/u1/u at either end. If this covers the circle, the first bound is immediate. Otherwise an arc of length δ+2/u\delta+2/u contains at most uδ+3u\delta+3 grid points, with one additional point allowed to cover every endpoint convention.

Outside the enlarged arc, group distances into [k/u,(k+1)/u)[k/u,(k+1)/u), k≥1k\ge1. Each group lies in at most two arcs of length 1/u1/u, one at each end of DD. Allowing both boundary points gives at most four grid points per group. Distances on the circle are at most 1/21/2, so summing 4u/k4u/k through k=uk=u proves the bound. ◻

We use two classical derivative estimates. If a real phase has monotone derivative a distance at least d>0d>0 from the integers, its exponential sum is O(d−1)O(d^{-1}). If λ≤f′′≤Aλ\lambda\le f''\le A\lambda on an interval containing LL consecutive integers, the sum is OA(Lλ+λ−1/2)O_A(L\sqrt\lambda+\lambda^{-1/2}). See Graham and Kolesnik [7]. The estimates include arbitrary subintervals. A negative second derivative is handled by complex conjugation.

Lemma 24 (Sum of linear twists). Let I=[a,b]∩Z\mathcal I=[a,b]\cap\mathbb Z contain L≥1L\ge1 consecutive integers, taking a,ba,b to be its first and last integers. Suppose ff is twice continuously differentiable and 0<λ≤f′′(x)≤Aλ0<\lambda\le f''(x)\le A\lambda on [a,b][a,b], where A≥1A\ge1. Then, for every integer u≥1u\ge1, ∑h=0u−1∣∑t∈Ie(f(t)+ht/u)∣≪AuLλ+λ−1/2+ulog⁡(2u).\sum_{h=0}^{u-1}\left|\sum_{t\in\mathcal I} \mathrm e(f(t)+ht/u)\right| \ll_A uL\sqrt\lambda+\lambda^{-1/2}+u\log(2u). The same conclusion holds for negative second derivative with the corresponding absolute bounds.

Proof. The case L=1L=1 follows from the last term. Otherwise let δ=f′(b)−f′(a)\delta=f'(b)-f'(a), so λ(b−a)≤δ≤Aλ(b−a)≤AλL.\lambda(b-a)\le\delta\le A\lambda(b-a)\le A\lambda L. If δ≥1/4\delta\ge1/4, apply the second-derivative bound to all uu twists. Its contribution uλ−1/2u\lambda^{-1/2} is at most 4AuLλ4A uL\sqrt\lambda, giving (34).

For δ<1/4\delta<1/4 the negative derivative ranges over D=[−f′(b),−f′(a)]D=[-f'(b),-f'(a)]. For the modes with dh≤1/ud_h\le1/u the second-derivative bound suffices. Their LλL\sqrt\lambda contributions total at most uLλuL\sqrt\lambda. By Lemma 23, their other contributions total at most (uδ+4)λ−1/2≤AuLλ+4λ−1/2.(u\delta+4)\lambda^{-1/2} \le A uL\sqrt\lambda+4\lambda^{-1/2}. For every remaining mode the derivative stays between two consecutive integers, at distance at least dhd_h. The first-derivative estimate and (33) give O(ulog⁡(2u))O(u\log(2u)) for their sum. This proves the claim. Conjugation and reindexing hh prove the negative case. All estimates are uniform on subintervals. ◻

The complete Kloosterman sum enters through the bound of Weil [19] in the general-modulus form of Estermann [5].

Proposition 25 (Completed reciprocal phase). Let u≥2u\ge2, n∈Zn\in\mathbb Z, and assume the hypotheses of Lemma 24. Then, for every ε>0\varepsilon>0, ∣∑t∈I(t,u)=1e(−nt‾/u+f(t))∣≪A,εuε(n,u)(Luλ+1uλ+ulog⁡(2u)).\begin{aligned} \left|\sum_{\substack{t\in\mathcal I\\(t,u)=1}} \mathrm e(-n\overline t/u+f(t))\right| \ll_{A,\varepsilon}u^\varepsilon\sqrt{(n,u)}\left( L\sqrt{u\lambda}+\frac1{\sqrt{u\lambda}} +\sqrt u\log(2u)\right). \end{aligned} For u=1u=1 interpret the periodic factor as one. The same bound holds.

Proof. The function a(t)=1(t,u)=1e(−nt‾/u)a(t)=\mathbf 1_{(t,u)=1}\mathrm e(-n\overline t/u) is periodic modulo uu. Its normalized Fourier coefficients are a^(h)=1uS(−h,−n;u),S(c,d;u)=∑x mod u∗e((cx+dx‾)/u).\widehat a(h)=\frac1u S(-h,-n;u),\qquad S(c,d;u)=\sum_{x\bmod u}^{*}\mathrm e((cx+d\overline x)/u). The classical complete Kloosterman estimate gives, for every ε>0\varepsilon>0, ∣a^(h)∣≪εu−1/2+ε(h,n,u)≤u−1/2+ε(n,u).|\widehat a(h)|\ll_\varepsilon u^{-1/2+\varepsilon} \sqrt{(h,n,u)} \le u^{-1/2+\varepsilon}\sqrt{(n,u)}. For positive numerator indices this is the bound stated by Bettin and Chandee [3]. Periodicity covers every nonzero residue. If one index is zero, the sum is a Ramanujan sum with magnitude at most the gcd of the other index and uu, which satisfies the same bound. If both are zero, S(0,0;u)=φ(u)≤uS(0,0;u)=\varphi(u)\le u. Thus the estimate also includes zero modes and composite moduli. Fourier inversion is exact on the whole conductor interval, even across many periods. Lemma 24 bounds the sum over the linear twists. The uniform coefficient bound supplies the remaining factor. For u=1u=1 the sole Fourier coefficient is one, and the derivative estimates also apply directly. ◻

Conductors with the same quotient

As tt varies, the weight H⌊N/t⌋\mathsf H_{\lfloor N/t\rfloor} is constant until the quotient changes. On an interval with quotient mm, the second derivative of the reciprocal phase has size m3jv/(pu)m^3jv/(pu), with absolute comparison constants. It lets us sum the linear-twist bounds over all inverse frequencies on that interval.

Put K=⌊p3/4⌋K=\lfloor p^{3/4}\rfloor and Im=(N/(m+1),N/m]I_m=(N/(m+1),N/m]. For fixed u,v,ju,v,j, let Fp,m(u,v,j;K)F_{p,m}(u,v,j;\mathcal K) denote the sum of fp(t;u,v,j)f_p(t;u,v,j) over the integers t∈Im∩K,t>K,t>2max⁡(u,v,j),(t,u)=1,t\in I_m\cap\mathcal K,\quad t>K,\quad t>2\max(u,v,j),\quad(t,u)=1, where K\mathcal K is any interval. Empty ranges contribute zero.

Lemma 26 (Band estimate from slope separation). For u,v,j<p/2u,v,j<p/2 and every admissible mm, ∣Fp,m(u,v,j;K)∣≪εpε(jv,u)(p3/2m3/2ujv+p3/2m5/2u(jv)3/2+pmu jv).\begin{aligned} |F_{p,m}(u,v,j;\mathcal K)| \ll_\varepsilon p^\varepsilon\sqrt{(jv,u)}\left( \frac{p^{3/2}}{m^{3/2}u\sqrt{jv}} +\frac{p^{3/2}}{m^{5/2}u(jv)^{3/2}} +\frac{p}{m\sqrt u\,jv}\right). \end{aligned} The estimate is uniform in the interval and in all half-range cuts.

Proof. The exact product-to-sum expansion has amplitudes a0(t)=2t2cot⁡(πu/t)cot⁡(πv/t)cot⁡(πj/t),a±(t)=−1t2cot⁡(πu/t)cot⁡(πv/t)csc⁡(πj/t).\begin{aligned} a_0(t)&=\frac2{t^2}\cot(\pi u/t)\cot(\pi v/t)\cot(\pi j/t),\\ a_\pm(t)&=-\frac1{t^2}\cot(\pi u/t)\cot(\pi v/t)\csc(\pi j/t). \end{aligned} and sine phases 2π(nu‾+ηj(p−1/2))/t2\pi(n\overline u+\eta j(p-1/2))/t, where n=p2jvn=p^2jv and η=0,1,−1\eta=0,1,-1. Inverse reciprocity gives the exact identity e((nu‾+ηj(p−1/2))/t)=e(−nt‾/u+bη/t),bη=n/u+ηj(p−1/2).\mathrm e((n\overline u+\eta j(p-1/2))/t) =\mathrm e(-n\overline t/u+b_\eta/t),\qquad b_\eta=n/u+\eta j(p-1/2). For u=1u=1 the first factor on the right is one. Since u<p/2u<p/2 and v≥1v\ge1, all three coefficients obey n/(2u)<bη<3n/(2u)n/(2u)<b_\eta<3n/(2u).

Set X=N/(m+1)X=N/(m+1). The interval ImI_m lies in [X,2X][X,2X] and X≍p/mX\asymp p/m. For f(t)=bη/tf(t)=b_\eta/t, the scale λ=bη/(4X3)\lambda=b_\eta/(4X^3) gives λ≤f′′≤8λ\lambda\le f''\le8\lambda and uλ≍m3jvp.u\lambda\asymp\frac{m^3jv}{p}. The number of consecutive integers in any permitted conductor interval is at most N/(m(m+1))+1≪p/m2N/(m(m+1))+1\ll p/m^2. Indeed t>Kt>K implies m<p1/4m<p^{1/4}, so the extra endpoint is absorbed. All constants are absolute for sufficiently large pp. The finitely many smaller primes are harmless.

Proposition 25, including its uniform subinterval form, therefore bounds the phase sum by ≪εpε(jv,u)(pjvm+pm3/2jv+u).\ll_\varepsilon p^\varepsilon\sqrt{(jv,u)}\left( \frac{\sqrt p\sqrt{jv}}{\sqrt m} +\frac{\sqrt p}{m^{3/2}\sqrt{jv}}+\sqrt u\right). Here (p,u)=1(p,u)=1 gives (n,u)=(jv,u)(n,u)=(jv,u), and divisor and logarithmic factors are absorbed into pεp^\varepsilon.

Each absolute amplitude is increasing on the permitted range. This follows from the increasing factors cot⁡(πb/t)/t\cot(\pi b/t)/t, tt, and csc⁡(πj/t)\csc(\pi j/t). Its supremum plus variation on any retained interval is O(p/(muvj))O(p/(muvj)). Partial summation with (40), followed by summing the three original phases, proves (37). ◻

Proposition 27 (Sum over all inverse frequencies). For 1≤V,J≤p1\le V,J\le p, the part of the exact source with t>Kt>K, v≤Vv\le V, j≤Jj\le J, and every permitted inverse frequency uu has magnitude ≪εp3/2+ε(VJ+1).\ll_\varepsilon p^{3/2+\varepsilon}\bigl(\sqrt{VJ}+1\bigr). The same bound holds with an additional interval restriction on uu and on the conductors within each quotient band.

Proof. For a≥1a\ge1 and Y≥1Y\ge1, divisor expansion gives ∑u≤Y(a,u)u≤H⌊Y⌋∑d∣ad−1/2,∑u≤Y(a,u)u≤2Y∑d∣ad−1/2.\begin{aligned} \sum_{u\le Y}\frac{\sqrt{(a,u)}}u &\le \mathsf H_{\lfloor Y\rfloor}\sum_{d\mid a}d^{-1/2},\notag\\ \sum_{u\le Y}\frac{\sqrt{(a,u)}}{\sqrt u} &\le2\sqrt Y\sum_{d\mid a}d^{-1/2}. \end{aligned} Indeed (a,u)≤∑d∣a, d∣ud\sqrt{(a,u)}\le\sum_{d\mid a,\,d\mid u}\sqrt d. With u=dku=dk the two estimates follow from the harmonic sum and ∑k≤yk−1/2≤2y\sum_{k\le y}k^{-1/2}\le2\sqrt y. The divisor factor is at most τ(a)\tau(a), hence pεp^\varepsilon for a=jv<p2/4a=jv<p^2/4.

In the sum of (37) over u<p/2u<p/2 and then over v,jv,j, each band retains its original harmonic weight Hm\mathsf H_m. The first term costs p3/2+εVJ∑m≥1Hmm3/2,p^{3/2+\varepsilon}\sqrt{VJ}\sum_{m\ge1}\frac{\mathsf H_m}{m^{3/2}}, using ∑j≤Jj−1/2≤2J\sum_{j\le J}j^{-1/2}\le2\sqrt J and the analogous bound for vv. The second term costs Oε(p3/2+ε)O_\varepsilon(p^{3/2+\varepsilon}) because ∑j−3/2\sum j^{-3/2} and ∑Hm/m5/2\sum \mathsf H_m/m^{5/2} converge. The third costs Oε(p3/2+εlog⁡2(2p)∑m<p1/4Hmm).O_\varepsilon\left(p^{3/2+\varepsilon}\log^2(2p) \sum_{m<p^{1/4}}\frac{\mathsf H_m}{m}\right). Since the last sum is O(log⁡2(2p))O(\log^2(2p)), reducing preliminary epsilons absorbs these logarithms. Convergence of the two other harmonic-lift sums follows from Hm≤1+log⁡m\mathsf H_m\le1+\log m. Initial frequency restrictions, nonunit products, partial intervals and the full u=1u=1 contribution have all been included. Positive majorants also permit the stated additional interval restrictions. ◻

The quarter-power bound for the sampling defect

Raising the cutoff in either frequency shortens its tail and enlarges the sum left to estimate. For a common cutoff V=J=TV=J=T the bounds vary in opposite directions. Up to factors pεp^\varepsilon, each tail is bounded by p2/Tp^2/T and the remaining sum by p3/2Tp^{3/2}T. They meet at T=p1/4T=p^{1/4}. The factor p−2p^{-2} in the grid mean then gives the quarter-power error.

Table 2 records the disjoint ranges. Here K=⌊p3/4⌋K=\lfloor p^{3/4}\rfloor and 1≤V,J≤p1\le V,J\le p. Every permitted inverse frequency uu is retained in every row. A common factor pεp^\varepsilon absorbs divisor factors and fixed powers of logarithms.

Ranges and bounds for the interior source.
Range Bound, apart from pεp^\varepsilon Estimate
t≤Kt\le K p3/2p^{3/2} (30)
t>K, v>Vt>K,\ v>V p2/Vp^2/V Proposition 21
t>K, v≤V, j>Jt>K,\ v\le V,\ j>J p2/Jp^2/J Proposition 22
t>K, v≤V, j≤Jt>K,\ v\le V,\ j\le J p3/2(VJ+1)p^{3/2}(\sqrt{VJ}+1) Proposition 27

Theorem 28 (Bound for the signed sum over interior resets). Uniformly for 1≤V,J≤p1\le V,J\le p and every ε>0\varepsilon>0, ∣Ap∣≪εpε(p3/2(VJ+1)+p2V+p2J).|\mathcal A_p|\ll_\varepsilon p^\varepsilon\left( p^{3/2}(\sqrt{VJ}+1)+\frac{p^2}V+\frac{p^2}J\right). Consequently, Ap=Oε(p7/4+ε).\mathcal A_p=O_\varepsilon(p^{7/4+\varepsilon}).

Proof. Retain all frequencies at t≤K=⌊p3/4⌋t\le K=\lfloor p^{3/4}\rfloor and use (30). At larger tt, partition the remaining triples into v>Vv>V; then v≤V,j>Jv\le V,j>J; and v≤V,j≤Jv\le V,j\le J. Every inverse frequency uu remains in each part. Propositions 21 and 22 apply with exactly these interval restrictions. Proposition 27 bounds the last part. There are no overlaps or omitted ranges. Choosing preliminary epsilons smaller absorbs divisor factors and fixed powers of logarithms, proving (43).

At V=J=⌈p1/4⌉V=J=\lceil p^{1/4}\rceil, the box and both tails have order p7/4+εp^{7/4+\varepsilon}, and the small-conductor cost is smaller. The ceilings change only absolute constants. The finitely many smaller primes are absorbed into the constant. This proves (44). ◻

Proof of Theorem 2. Equation (19) gives Sp−1=4App2−2p+1p2−NHN3p3.\mathcal S_p-1=\frac{4\mathcal A_p}{p^2}-\frac2p+\frac1{p^2} -\frac{N\mathsf H_N}{3p^3}. The first term satisfies the bound of Theorem 28. The three explicit corrections together contribute O(p−1)+O(p−2log⁡(2p))O(p^{-1})+O(p^{-2}\log(2p)), smaller than the asserted error. Multiplication by p2p^2 gives (6). ◻

Thus restoring the squared value at zero leaves an error tending to zero in absolute size. The comparison is with the integral of the same p−1p-1 waves for each pp. Their integral itself grows with pp.

The cubic law and its second term

In the carry table the continuous energy is multiplied by the number of entries p2p^2. This gives a leading term of order p3p^3 and a correction of order p2(log⁡p)2p^2(\log p)^2. On the same scale, replacing the integral by the grid mean costs only order p2p^2. Thus the finite count inherits the coefficient of the squared logarithm.

Proof of Theorem 1. Theorem 10 and Theorem 2 give Ep=p2[J(p−1)−1]+Oε(p7/4+ε)=p3−2p2−p2π2(log⁡(p−1))2+O(p2(log⁡p)5/3)+Oε(p7/4+ε).\begin{aligned} E_p &=p^2[J(p-1)-1]+O_\varepsilon(p^{7/4+\varepsilon})\\ &=p^3-2p^2-\frac{p^2}{\pi^2}(\log(p-1))^2 +O\bigl(p^2(\log p)^{5/3}\bigr) +O_\varepsilon(p^{7/4+\varepsilon}). \end{aligned} For 0<ε<1/40<\varepsilon<1/4 the last error is smaller than p2p^2, and (log⁡(p−1))2=(log⁡p)2+O((log⁡p)/p).(\log(p-1))^2=(\log p)^2+O((\log p)/p). Absorbing the displayed order-p2p^2 term and this logarithmic change into O(p2(log⁡p)5/3)O(p^2(\log p)^{5/3}) proves (4). ◻

The term −2p2-2p^2 in this calculation has two sources. One −p2-p^2 comes from taking N=p−1N=p-1, the other from correcting for the finite grid. The available bound for the remainder of J(N)J(N) is too large to identify a third coefficient in EpE_p. The unit correction is relative to the exact integral.

Individual squares and mixed products

For any one of the p−1p-1 waves, multiplication by its index permutes the p2p^2 sampling addresses. All the individual squares consequently have the same grid mean. The mixed products retain the arithmetic of the two indices, and it is here that both the squared-logarithm term and the limiting unit discrepancy enter.

Proposition 29 (The leading 1:21:2 split). For an odd prime pp, put q=p2q=p^2 and N=p−1N=p-1. Then Ep=4∑r,s=1Ns(sr‾,q),E_p=4\sum_{r,s=1}^N s(s\overline r,q), where the inverse is modulo qq. Its diagonal part is Δp=4Ns(1,q)=(p−1)(p2−1)(p2−2)3p2.\Delta_p=4N s(1,q) =\frac{(p-1)(p^2-1)(p^2-2)}{3p^2}. Consequently, Δp=13p3+O(p2),Ep−Δp=23p3−1π2p2(log⁡p)2+O(p2(log⁡p)5/3).\begin{aligned} \Delta_p&=\frac13p^3+O(p^2),\\ E_p-\Delta_p &=\frac23p^3-\frac1{\pi^2}p^2(\log p)^2 +O\bigl(p^2(\log p)^{5/3}\bigr). \end{aligned}

Proof. Each ordered pair in the square of Proposition 5 has indices 1≤r,s<p1\le r,s<p. The change of variable y=rA(modq)y=rA\pmod q is a permutation, so ∑A=0q−1ψ(rA/q)ψ(sA/q)=∑y=1q−1ψ(y/q)ψ(sr‾y/q)=s(sr‾,q).\sum_{A=0}^{q-1}\psi(rA/q)\psi(sA/q) =\sum_{y=1}^{q-1}\psi(y/q)\psi(s\overline r y/q) =s(s\overline r,q). This proves (45). On the diagonal, r=sr=s. The elementary sums of integers and their squares give s(1,q)=∑y=1q−1(yq−12)2=(q−1)(q−2)12q,s(1,q)=\sum_{y=1}^{q-1}\left(\frac yq-\frac12\right)^2 =\frac{(q-1)(q-2)}{12q}, which proves (46) and (47). Subtract this from Theorem 1 to obtain (48). ◻

Thus the individual squares and mixed products carry one third and two thirds of the leading energy. The ratio is asymptotic. At base three, for instance, Δ3=112/27\Delta_3=112/27 and E3−Δ3=32/27E_3-\Delta_3=32/27.

One can also group (45) by the address ratio. Let w(v)w(v) count ordered pairs 1≤r,s<p1\le r,s<p with s≡vr mod qs\equiv vr\bmod q. Then Ep=4∑v∈Uw(v)s(v,q)E_p=4\sum_{v\in U}w(v)s(v,q). For every nonzero residue dd modulo pp, ∑v≡d mod pw(v)=p−1\sum_{v\equiv d\bmod p}w(v)=p-1: each rr has one ss in the window with s≡dr mod ps\equiv dr\bmod p, and hence one vv. Consequently ∑v∈Uw(v)s(v mod p,p)=0\sum_{v\in U}w(v)s(v\bmod p,p)=0 by oddness of the Dedekind sum. This explains why the complete energy has no contribution from the lower modulus.

Corollary 30 (The unit in the mixed products). Let Dp×D_p^\times be the continuous mean minus the sampled mean of the sum of all ordered products of two distinct waves. With q=p2q=p^2 and N=p−1N=p-1, Dp×=Sp−N(1q−23q2)=1+Oε(p−1/4+ε).D_p^\times=\mathcal S_p-N\left(\frac1q-\frac{2}{3q^2}\right) =1+O_\varepsilon(p^{-1/4+\varepsilon}). Restoring each distinct pair’s one-sided product at zero subtracts N(N−1)/qN(N-1)/q from this discrepancy.

Proof. Each individual wave has continuous mean square 1/31/3 and sampled mean square (q−1)(q−2)/(3q2)(q-1)(q-2)/(3q^2) by (46). Subtract their differences from the full defect and apply Theorem 2. At zero each ordered product changes from its assigned value zero to one on either side. There are N(N−1)N(N-1) such products. ◻

The squared sample at zero

At zero the field has opposite one-sided limits, but their squares agree. The table assigns zero to that entry. Replacing it by the common one-sided square keeps all the other p2−1p^2-1 readings and gives

Epcorrp2=Epp2+(p−1)2p2.\frac{E_p^{\mathrm{corr}}}{p^2} =\frac{E_p}{p^2}+\frac{(p-1)^2}{p^2}. For the resulting energy, Theorem 2 gives J(p−1)−Epcorrp2=Oε(p−1/4+ε).J(p-1)-\frac{E_p^{\mathrm{corr}}}{p^2} =O_\varepsilon(p^{-1/4+\varepsilon}). For a fixed 0<ε<1/40<\varepsilon<1/4, this error tends to zero while J(p−1)J(p-1) itself grows. The comparison is therefore finer than agreement of leading terms.

At p=3p=3, J(2)=1J(2)=1 and the sampled energy is 16/2716/27. The defect is 11/2711/27 and the correction is 4/94/9, leaving −1/27-1/27. At this finite base the contribution from the common reset exceeds the discrepancy for the entire table.

Section 10 asks how fast the error decays once this one entry has been restored. We first give another exact expression for that error.

The discrepancy by reduced ratios

For a coprime pair (k,a)(k,a) with k<ak<a, all multiples (dk,da)(dk,da) with da≤p−1da\le p-1 have the same sampled mean product because multiplication by dd permutes the grid. Grouping by this ratio gives another way to measure the signed sum over interior resets.

Throughout this subsection N=p−1N=p-1, q=p2q=p^2 and wa=⌊N/a⌋w_a=\lfloor N/a\rfloor. In the sums below 1≤k<a≤N1\le k<a\le N and (a,k)=1(a,k)=1. Put Xp=∑a,kwa(a/k+k/a),Rp=−8∑a,kwa s(qaˉ,k).X_p=\sum_{a,k}w_a(a/k+k/a),\qquad R_p=-8\sum_{a,k}w_a\,s(q\bar a,k). As before s(h,1)=0s(h,1)=0, so the term with k=1k=1 in RpR_p is zero. The inverse in s(qaˉ,k)s(q\bar a,k) is modulo kk.

Rademacher’s three-term reciprocity law [14] separates the two smaller denominators from the square denominator in this sum.

Proposition 31 (The signed remainder by ratios). The exact corrections are N+Xp=N(N+1)HN/2N+X_p=N(N+1)\mathsf H_N/2 and Rp=−4ApR_p=-4\mathcal A_p. Consequently, Sp=N2q−2(N+Xp)3q2−Rpq,Xp≪p2log⁡(2p),Rp≪εp7/4+ε.\mathcal S_p=\frac{N^2}{q}-\frac{2(N+X_p)}{3q^2}-\frac{R_p}{q}, \qquad X_p\ll p^2\log(2p),\qquad R_p\ll_\varepsilon p^{7/4+\varepsilon}.

Proof. Each unordered pair i<ji<j contributes i/j+j/ii/j+j/i to XpX_p. Adding the diagonal gives N+Xp=∑i,j≤Ni/j=(∑i≤Ni)HNN+X_p=\sum_{i,j\le N}i/j=(\sum_{i\le N}i)\mathsf H_N.

In (20) the diagonal vanishes and s(dh,dm)=s(h,m)s(dh,dm)=s(h,m), as in the calculation for (2,3)(2,3). Grouping the two orders gives Ap=2∑a,kwa{s(kqˉ,a)+s(aqˉ,k)}.\mathcal A_p=2\sum_{a,k}w_a\{s(k\bar q,a)+s(a\bar q,k)\}. For fixed aa the first sum vanishes because kk runs through all units modulo aa and s(−h,a)=−s(h,a)s(-h,a)=-s(h,a). In the second sum the change of variable by a unit gives s(aqˉ,k)=s(qaˉ,k)s(a\bar q,k)=s(q\bar a,k) for k>1k>1. At k=1k=1 the last equality holds by convention. The definition of RpR_p gives the factor −4-4. Substitution in (19) proves the formula for Sp\mathcal S_p, and Section 8 gives the bound on RpR_p.

The two orders of a reduced pair in (45) agree by inversion symmetry. They contribute 8was(akˉ,q)8w_a s(a\bar k,q). Three-term reciprocity [8] gives s(akˉ,q)=q12ka+a/k+k/a12q−14−s(kqˉ,a)−s(qaˉ,k).s(a\bar k,q)=\frac{q}{12ka}+\frac{a/k+k/a}{12q} -\frac14-s(k\bar q,a)-s(q\bar a,k). The first term gives qq times the continuous off-diagonal by (8). The constant contributes −N(N−1)-N(N-1), since ∑a,kwa=N(N−1)/2\sum_{a,k}w_a=N(N-1)/2. The same odd row cancels and the last term gives RpR_p, recovering the ratio remainder directly on the grid. ◻

A small residue of qq at a denominator gives a recognizable local contribution. We can bound the entire contribution of such denominators before estimating their signs against one another. For 2≤k<p2\le k<p, let ckc_k be the representative of q mod kq\bmod k in (−k/2,k/2](-k/2,k/2] and put Lk(Y)=∑1≤a≤Y(a,k)=1s(qaˉ,k).L_k(Y)=\sum_{\substack{1\le a\le Y\\(a,k)=1}}s(q\bar a,k). A complete period vanishes. Expanding waw_a as a count of multiples expresses the kkth row of −Rp/8-R_p/8 as ∑h≤N/(k+1)Lk(⌊N/h⌋)\sum_{h\le N/(k+1)}L_k(\lfloor N/h\rfloor), since Lk(k)=0L_k(k)=0.

Proposition 32 (Denominators close to the prime square). For integers 1≤D≤p/21\le D\le p/2, 8q∑2≤k<p0<∣ck∣≤D∑h≤N/(k+1)∣Lk(⌊N/h⌋)∣≪(Dp+p−1/3)(log⁡(2p))3.\frac8q\sum_{\substack{2\le k<p\\0<|c_k|\le D}} \sum_{h\le N/(k+1)}|L_k(\lfloor N/h\rfloor)| \ll \left(\frac Dp+p^{-1/3}\right)(\log(2p))^3 . In particular this absolute mass tends to zero for D=⌊p/(log⁡p)4⌋D=\lfloor p/(\log p)^4\rfloor. At D=⌊p/(log⁡p)2⌋D=\lfloor p/(\log p)^2\rfloor it is O(log⁡p)O(\log p), and every remaining row has only O((log⁡p)2)O((\log p)^2) positive floor levels.

Proof. Put Kk=∑n=1k−1∣cot⁡(πn/k)∣K_k=\sum_{n=1}^{k-1}|\cot(\pi n/k)|. Splitting the sum at k/2k/2 gives Kk≪klog⁡(2k)K_k\ll k\log(2k). For fixed nn, put g=(n,k)g=(n,k). As uu runs through Uk\mathcal U_k, the residues nunu have multiplicity at most gg on the reduced grid of denominator k/gk/g. Their absolute cotangent sum is at most gKk/g≪klog⁡(2k)gK_{k/g}\ll k\log(2k). The finite cotangent formula of Lemma 17 now gives ∑u∈Uk∣s(u,k)∣≤14k∑n=1k−1∣cot⁡(πn/k)∣∑u∈Uk∣cot⁡(πnu/k)∣≪k(log⁡(2k))2.\sum_{u\in\mathcal U_k}|s(u,k)| \le \frac{1}{4k}\sum_{n=1}^{k-1}|\cot(\pi n/k)| \sum_{u\in\mathcal U_k}|\cot(\pi n u/k)| \ll k(\log(2k))^2 . Each prefix Lk(Y)L_k(Y) costs at most this first moment after complete periods are removed. The sum of absolute prefixes in one row is therefore O(p(log⁡(2p))2)O(p(\log(2p))^2).

Each selected kk divides p2−ckp^2-c_k. Apply the classical divisor estimate [17] ∑n≤xτ(n)=xlog⁡x+(2γ−1)x+O(x1/3log⁡(2x))\sum_{n\le x}\tau(n)=x\log x+(2\gamma-1)x+O(x^{1/3}\log(2x)) at the endpoints of the two intervals next to p2p^2. The number of rows is at most ∑1≤∣c∣≤Dτ(p2−c)≪Dlog⁡(2p)+p2/3log⁡(2p).\sum_{1\le |c|\le D}\tau(p^2-c) \ll D\log(2p)+p^{2/3}\log(2p). The product of this count and the bound for one row gives the stated estimate after division by q/8q/8. Outside the selected rows one has k≥2∣ck∣>2Dk\ge2|c_k|>2D, giving the floor-level assertion. ◻

The ratio table also records exactly when a new reduced pair enters. For 2≤x≤N2\le x\le N let Dq(i,j)=∑y mod qψ(iy/q)ψ(jy/q)D_q(i,j)=\sum_{y\bmod q}\psi(iy/q)\psi(jy/q), and write A(x)=∑i=1x−1Dq(i,x−i),C(x)=∑1≤i<x(i,x)=1Dq(i,x−i),A(1)=C(1)=0.A(x)=\sum_{i=1}^{x-1}D_q(i,x-i),\qquad C(x)=\sum_{\substack{1\le i<x\\(i,x)=1}}D_q(i,x-i), \qquad A(1)=C(1)=0 . Dividing i,x−ii,x-i by their gcd leaves DqD_q unchanged, since that gcd permutes the qq grid addresses. Grouping by the gcd and applying Möbius inversion gives A(x)=∑d∣xC(d),C(x)=∑d∣xμ(d)A(x/d).A(x)=\sum_{d\mid x}C(d),\qquad C(x)=\sum_{d\mid x}\mu(d)A(x/d). For x≥3x\ge3 each primitive pair occurs in two orders. To see its contribution to the ratio error put Hx∗=∑1≤i<x, (i,x)=1i−1H_x^*=\sum_{1\le i<x,\,(i,x)=1}i^{-1}. Then ∑1≤k<x(k,x)=1s(qxˉ,k)=qHx∗12x+xHx∗−φ(x)12q−φ(x)8−C(x)2.\sum_{\substack{1\le k<x\\(k,x)=1}}s(q\bar x,k) =\frac{qH_x^*}{12x}+\frac{xH_x^*-\varphi(x)}{12q} -\frac{\varphi(x)}8-\frac{C(x)}2 . Indeed, pair ii with j=x−ij=x-i. Modulo ii one has x≡jx\equiv j, and modulo jj one has x≡ix\equiv i. Three-term reciprocity for i,j,qi,j,q leaves −Dq(i,j)-D_q(i,j) for each unordered pair. The rational terms sum as written because 1/(ij)=(1/i+1/j)/x1/(ij)=(1/i+1/j)/x and i/j+j/i=x(1/i+1/j)−2i/j+j/i=x(1/i+1/j)-2. Multiplying this identity by wxw_x and summing over x≥3x\ge3 recovers the rows of −Rp/8-R_p/8. The row x=2x=2 is zero.

The square-root conjecture for the sampling defect

In base five the centered carries have total squared energy 4848. The continuous energy is 23/923/9, so the integral exceeds the grid mean 48/2548/25 by 143/225143/225. Restoring the square at the common reset adds 16/25=144/22516/25=144/225 to the mean. The corrected discrepancy is −1/225-1/225. For growing primes the corrected discrepancy tends to zero. How quickly do the positive and negative contributions from the other resets cancel?

Conjecture 33 (Square-root sampling rate). For every ε>0\varepsilon>0, Sp=1+Oε(p−1/2+ε)\mathcal S_p=1+O_\varepsilon(p^{-1/2+\varepsilon}) as p→∞p\to\infty through odd primes.

By (19), this is equivalent to ∣Ap∣≪εp3/2+ε.|\mathcal A_p|\ll_\varepsilon p^{3/2+\varepsilon}. In the original carry table this would give Ep=p2[J(p−1)−1]+Oε(p3/2+ε)E_p=p^2[J(p-1)-1]+O_\varepsilon(p^{3/2+\varepsilon}). For a known continuous mean square, the error allowed in the carry energy would fall by a factor of p1/4p^{1/4}. The three principal allowances in (43) satisfy C0=p3/2VJ,Cv=p2/V,Cj=p2/J,C02CvCj=p7.C_0=p^{3/2}\sqrt{VJ},\qquad C_v=p^2/V,\qquad C_j=p^2/J, \qquad C_0^2C_vC_j=p^7. Their maximum is at least p7/4p^{7/4}, attained at V=J=p1/4V=J=p^{1/4}. Improving the exponent therefore requires a sharper estimate for at least one range, or cancellation between ranges. Changing the two cutoffs alone can give no saving beyond the quarter power.

The two residue classes beside p2p^2 in Section (*) give one reason to test the square-root scale. On the central band their signed contribution at denominator kk is ck=w(k)(i+(k)−i−(k))c_k=w(k)(i_+(k)-i_-(k)). At most one of the two indicators is nonzero. Each nonzero ∣ck∣|c_k| has order pp, and Proposition 15 gives total mass of order p2p^2 for each sign. Hence ∑kck2≍p3\sum_k c_k^2\asymp p^3 on this band. Under independent, equally likely sign reversals the root mean square of their sum would be (∑kck2)1/2≍p3/2(\sum_k c_k^2)^{1/2}\asymp p^{3/2}. In the actual table the residue of p2p^2 fixes each sign. Including all the coprime classes in the same prefixes brings the mass of each sign to order p2(log⁡p)2p^2(\log p)^2.

At a finite prime we can read both the cubic correction and the remaining signed discrepancy in the same table. The first numerical column is (p3−Ep)/p2(p^3-E_p)/p^2. The last subtracts one from the defect before multiplying by p\sqrt p, the scale of the conjecture.

pp p−Ep/p2p-E_p/p^2 (log⁡p)2/π2(\log p)^2/\pi^2 p (Sp−1)\sqrt p\,(\mathcal S_p-1)
13 4.1006 0.6666 −0.6378-0.6378
31 5.2102 1.1948 −0.2718-0.2718
101 6.8853 2.1581 −0.2711\phantom{-}0.2711
499 9.6432 3.9106 −0.0798\phantom{-}0.0798
1009 10.6655 4.8473 −1.1899\phantom{-}1.1899

The entries use the GCD sum and (19), with each Dedekind sum evaluated by reciprocity. Among the 29 primes from 101 through 251, the defect exceeds one at 23 and falls below one at six. At p=1009p=1009 the scaled difference is still about 1.191.19. These finite readings are consistent with the proposed scale. The outstanding question is whether the positions of all the interior resets enforce that much cancellation at every prime.

Earlier versions.

The collision-free multipliers for prime denominators appear in The Collision Invariant (March 29, 2026). The cubic law, its 1:21:2 split and the character moment appear together in Digit Collisions and Carry-Boundary Spectra (June 4, 2026), later titled The Cubic Law for Digit-Collision Energy. The change of address and the squared-logarithm term for the integral and the table are in The Secondary Term in Digit-Collision Energy (June 2026, revised in August). Zenodo dates its first edition July 1, 2026. The Unit Sampling Defect in Digit-Collision Energy (October 10, 2026) proves convergence of the defect to one. The quarter-power bound appears in the revision of November 2, 2026.

Funding

This research received no external funding.

Disclosure statement

The author reports no competing interests.

References

[1]C. Aistleitner, I. Berkes, and K. Seip, GCD sums from Poisson integrals and systems of dilated functions, J. Eur. Math. Soc. 17 (2015), no. 6, 1517–1546, https://doi.org/10.4171/JEMS/537.

[2]M. Beck, Dedekind cotangent sums, Acta Arith. 109 (2003), no. 2, 109–130, https://doi.org/10.4064/aa109-2-1.

[3]S. Bettin and V. Chandee, Trilinear forms with Kloosterman fractions, Adv. Math. 328 (2018), 1234–1262, https://doi.org/10.1016/j.aim.2018.01.026.

[4]J. B. Conrey, E. Fransen, R. Klein, and C. Scott, Mean values of Dedekind sums, J. Number Theory 56 (1996), 214–226, https://doi.org/10.1006/jnth.1996.0014.

[5]T. Estermann, On Kloosterman's sum, Mathematika 8 (1961), 83–86, https://doi.org/10.1112/S0025579300002187.

[6]P. Flajolet and B. Salvy, Euler sums and contour integral representations, Experiment. Math. 7 (1998), no. 1, 15–35.

[7]S. W. Graham and G. Kolesnik, Van der Corput's Method of Exponential Sums, London Mathematical Society Lecture Note Series, vol. 126, Cambridge University Press, 1991, https://doi.org/10.1017/CBO9780511661976.

[8]R. R. Hall, J. C. Wilson, and D. Zagier, Reciprocity formulae for general Dedekind–Rademacher sums, Acta Arith. 73 (1995), 389–396.

[9]T. Hilberdink, F. Luca, and L. Tóth, On certain sums concerning the gcd's and lcm's of kk positive integers, Int. J. Number Theory 16 (2020), no. 1, 77–90, https://doi.org/10.1142/S1793042120500049.

[10]M. N. Huxley, Identities involving Farey fractions, Proc. Steklov Inst. Math. 276 (2012), no. 1, 125–139, https://doi.org/10.1134/S0081543812010105.

[11]E. Krätzel, W. G. Nowak, and L. Tóth, On certain arithmetic functions involving the greatest common divisor, Cent. Eur. J. Math. 10 (2012), no. 2, 761–774, https://doi.org/10.2478/s11533-011-0144-6.

[12]S. R. Louboutin and M. Munsch, Mean square values of LL-functions over subgroups for nonprimitive characters, Dedekind sums and bounds on relative class numbers, Canad. J. Math. 75 (2023), no. 5, 1711–1743, https://doi.org/10.4153/S0008414X2300010X.

[13]A. S. Petty, The alignment deficit lattice and musical tuning, Journal of Mathematics and Music (2026), 1–7, https://doi.org/10.1080/17459737.2026.2741838.

[14]H. Rademacher, Generalization of the reciprocity formula for Dedekind sums, Duke Math. J. 21 (1954), no. 3, 391–397, https://doi.org/10.1215/S0012-7094-54-02140-7.

[15]B. Saffari and R. C. Vaughan, On the fractional parts of x/nx/n and related sequences. II, Ann. Inst. Fourier (Grenoble) 27 (1977), no. 2, 1–30, https://doi.org/10.5802/aif.649.

[16]I. E. Shparlinski, On some weighted average values of LL-functions, Bull. Aust. Math. Soc. 79 (2009), no. 2, 183–186, https://doi.org/10.1017/S0004972708001020.

[17]E. C. Titchmarsh, The Theory of the Riemann Zeta-Function, second ed., revised by D. R. Heath-Brown, Clarendon Press, Oxford, 1986.

[18]H. Walum, An exact formula for an average of LL-series, Illinois J. Math. 26 (1982), no. 1, 1–3, https://doi.org/10.1215/ijm/1256046895.

[19]A. Weil, On some exponential sums, Proc. Nat. Acad. Sci. U.S.A. 34 (1948), no. 5, 204–207, https://doi.org/10.1073/pnas.34.5.204.

[20]W. Zhang, On the mean values of Dedekind sums, J. Théor. Nombres Bordeaux 8 (1996), no. 2, 429–442, https://doi.org/10.5802/jtnb.179.

[21]W. Zhang, On the mean value of LL-functions with the weight of character sums, J. Number Theory 128 (2008), 2459–2466, https://doi.org/10.1016/j.jnt.2007.11.008.