Petty's Notebook
ArticlesPapersnfieldAbout
Get notified when new posts are published. No spam, just math.
Alexander S. Petty  |  ©2009-2026
← Back
Boundaries

The Secondary Term of the Cubic Law

July 1, 202612 min read
Companion paper: The Secondary Term in Digit-Collision Energy →
A thin stepped band runs beneath the curve of the cube. Its small steps are rounding, and they add up to a shortfall whose leading coefficient carries through to the finite digit table.
A thin stepped band runs beneath the curve of the cube. Its small steps are rounding, and they add up to a shortfall whose leading coefficient carries through to the finite digit table.

Around 1800, Adrien-Marie Legendre studied the tables of primes available to him and proposed a formula for how many primes lie below a number xxx. It was x/(log⁡x−1.08366)x/(\log x-1.08366)x/(logx−1.08366). The odd constant fit his tables beautifully, and it was wrong. Half a century later Pafnuty Chebyshev proved that if any constant belongs in that place, it must be exactly one. Legendre had fitted his constant to the tables, and the primes beyond them didn’t agree.

The first part of that formula, x/log⁡xx/\log xx/logx, was right, and it sets the scale. The trouble lived in the correction. That is usually where it lives. A leading term tells you how big something is. The next term tells you how it is built, and it is also where a finite table is most persuasive and least trustworthy.

The digit collisions of a prime base now have a leading term. Their energy grows like the cube of the base, with coefficient exactly one, and the one is proved. This paper goes after the next term. It carries a π\piπ, which a count of carries has no obvious reason to know about. And before its coefficient can be trusted, it has to survive a hazard Legendre never faced. The digit table does not see a smooth curve. It sees one read at a finite set of evenly spaced points, and readings like that can invent patterns of their own.

Your browser does not support embedded video.
How much of the smooth calculation survives on a finite grid? A video presentation, 5 min 55 sec.

Sixteen thirds

The energy is quick to build. In base three, the two-digit words whose digits agree are 00, 11 and 22, sitting at positions zero, four and eight on a wheel of nine. Multiply the wheel by a number sharing no factor with nine, push every mark forward by that same number, and count the marks that pass zero. Compare the count with the share the size of the step would predict. Square the difference for each of the six allowed multipliers, and add.

Matching-digit words 00, 11 and 22 become positions zero, four and eight. After multiplication by two, a nine-position wheel shows marks at zero, eight and seven. Two gold paths cross zero after a further step of two. Six square areas then show the complete energy calculation. Matching-digit words 00, 11 and 22 become positions zero, four and eight. After multiplication by two, a nine-position wheel shows marks at zero, eight and seven. Two gold paths cross zero after a further step of two. Six square areas then show the complete energy calculation.
The wheel after multiplication. Gold paths cross zero and the teal path does not. Below, the six excesses are squared, teal and violet keeping their signs, and forty-eight little ninths make sixteen thirds.

The six squares come to sixteen thirds. For a prime base ppp the same recipe runs over every position modulo p2p^2p2, and the total is written EpE_pEp​.

All six counts, with the exact definition

For an odd prime base ppp, the matching-digit positions are d(p+1)d(p+1)d(p+1) modulo p2p^2p2, for 0≤d<p0\le d<p0≤d<p. At multiplier aaa, let Cp(a)C_p(a)Cp​(a) count the marks that cross the join after the further step of aaa. The proportional allowance is a/pa/pa/p. Thus

Fp(a)=Cp(a)−a/p,Ep=∑a=0p2−1Fp(a)2.\begin{aligned} F_p(a)&=C_p(a)-a/p,\\ E_p&=\sum_{a=0}^{p^2-1}F_p(a)^2. \end{aligned}Fp​(a)Ep​​=Cp​(a)−a/p,=a=0∑p2−1​Fp​(a)2.​

This is the paper’s class-centering, simplified. It assumes no random-digit model. At multiples of ppp the centered response is zero, so including those positions does not change the energy.

Multiplier Carries Allowance Excess
1 1 1/3 2/3
2 2 2/3 4/3
4 2 4/3 2/3
5 1 5/3 -2/3
7 1 7/3 -4/3
8 2 8/3 -2/3

The squared numerators are 4,16,4,4,16,44,16,4,4,16,44,16,4,4,16,4, all over nine. Their sum is 48/9=16/348/9=16/348/9=16/3.

Missing by a billion

The law proved in Digit Collisions and the Cubic Law says that EpE_pEp​ divided by p3p^3p3 tends to one. Measure the gap two ways, as a share of the cube and as a plain number, and the two measurements disagree about which way things are going.

Three same-length bars compare measured energy against the cube at bases 101, 1009 and 10007. Their gold missing fractions shrink from 6.817 percent to 0.166 percent. A second ruler shows the absolute shortfall growing from 70,237 to 1,664,208,167. Three same-length bars compare measured energy against the cube at bases 101, 1009 and 10007. Their gold missing fractions shrink from 6.817 percent to 0.166 percent. A second ruler shows the absolute shortfall growing from 70,237 to 1,664,208,167.
Each upper bar is the cube of its own base, and the gold sliver missing from it shrinks. On the lower ruler every tick is ten times the last, and the same shortfalls grow.

At base 101 the energy falls short of the cube by 70,237, almost seven percent. At base 10,007 it falls short by 1,664,208,167, about one sixth of one percent. Across the three bars the gold sliver all but vanishes, while the dots on the lower ruler march right. The percentage shrinks while the amount grows, and the second term is the law that reconciles the two. The cube is right. The question now is how much it misses, and at what rate.

A third of a copy

The shortfall is made of something very plain, fractions of things that cannot be split.

Squaring a sum sets its pieces against each other in pairs, and after the first reduction in the proof those pairs live in a table with a simple rule. Take two whole numbers and divide their greatest common divisor by their least common multiple. That is the weight of their cell. The pair (2, 3) has greatest common divisor one and least common multiple six, so it weighs one sixth. So does (4, 6), and so does (6, 9). Scaling both numbers by the same factor changes nothing.

Now give the table a width of ten. Three copies of (2, 3) fit. The fourth, at (8, 12), does not. A smooth calculation divides ten by three and allows three and a third copies. The table can hold only three. The missing third of a copy, at one sixth apiece, is one eighteenth.

Nested squares of widths ten and twelve show when the fourth copy of the reduced pair two, three first fits. Three same-scale bars show whole-copy counts at widths ten, eleven and twelve, with discarded fractions one third, two thirds and zero. Nested squares of widths ten and twelve show when the fourth copy of the reduced pair two, three first fits. Three same-scale bars show whole-copy counts at widths ten, eleven and twelve, with discarded fractions one third, two thirds and zero.
The fourth copy would sit at eight, twelve. Widening the table to eleven still leaves three copies, and at twelve the fourth enters. Solid bars are whole copies of one sixth each, and hatching is the smooth quotient’s extra third.

Every reduced pair has its own count of copies and its own lost fraction. A pair whose larger number divides the width loses nothing. The rest round down, and pairs too large to fit even once lose a little more. Add up every one of those slivers and you have the second term.

Two logarithms and a pi

The slivers get lighter as the pairs get larger. Their weights fall off like one, one half, one third and so on, and a sum like that does not grow in proportion to its length. It grows like a logarithm. The pair table runs that slow sum twice, once along the smaller coordinate and once along the larger, so the loss collects two logarithms. On average each lost fraction is half a copy. That sounds obvious, but the fractions come from dividing one number by many others, and it takes a theorem of Saffari and Vaughan to justify it.

Then the π\piπ. Pick two whole numbers at random. The chance that they share no common factor is 6/π26/\pi^26/π2, about sixty-one percent, as Dirichlet already knew in 1849. Only reduced pairs lose slivers, because every other cell is a scaled copy of one, so the entire loss is filtered through that same proportion. The π\piπ comes in through a side door marked no common factor, and it brings no circle with it.

Look more closely at the pairs
Four pairs of complete integer squares at widths twelve, forty-eight, 192 and 512 compare the gcd-to-lcm weight with the coprime mask. Weighted squares reveal bright diagonal and rational rays; gold masks reveal the interlaced holes made by common prime factors. Four pairs of complete integer squares at widths twelve, forty-eight, 192 and 512 compare the gcd-to-lcm weight with the coprime mask. Weighted squares reveal bright diagonal and rational rays; gold masks reveal the interlaced holes made by common prime factors.
Left, every cell colored by gcd over lcm, with bright rays of scaled copies. Right, only the coprime pairs, in gold. The largest squares hold 262,144 cells each, so open the image to see them.

The left squares show every weight in the continuous pair table. Each bright ray follows scaled copies of one reduced ratio. The right squares retain only the pairs with no common factor. Compare the two views at the same size, then follow how their patterns develop as the square grows. Every one of the 262,144 cells is present in each largest panel.

Two orientations for each pair, half a copy lost on average, another half from adding up the logarithms, and the coprime share.

2×12×12×6π2=3π22\times\frac12\times\frac12\times\frac6{\pi^2}=\frac3{\pi^2}2×21​×21​×π26​=π23​

That is the second coefficient of a classical sum, the sum of greatest common divisors over least common multiples across an NNN by NNN square.

∑r,s≤Ngcd⁡(r,s)lcm⁡(r,s)=3N−3π2(log⁡N)2+O((log⁡N)5/3)\sum_{r,s\le N}\frac{\gcd(r,s)}{\operatorname{lcm}(r,s)}=3N-\frac3{\pi^2}(\log N)^2+O\left((\log N)^{5/3}\right)r,s≤N∑​lcm(r,s)gcd(r,s)​=3N−π23​(logN)2+O((logN)5/3)

Hilberdink, Luca and Tóth proved the leading term 3N3N3N and bounded the rest by a constant times (log⁡N)2(\log N)^2(logN)2. The constant inside that bound is −3/π2-3/\pi^2−3/π2. The collision energy divides this table by three, so its own coefficient is −1/π2-1/\pi^2−1/π2.

The pair count behind the coefficient

The continuous weight is gcd⁡(r,s)/lcm⁡(r,s)\gcd(r,s)/\operatorname{lcm}(r,s)gcd(r,s)/lcm(r,s). Let A(N)A(N)A(N) be its sum over the square 1≤r,s≤N1\le r,s\le N1≤r,s≤N. At width four,

Row / column 1 2 3 4
1 1 1/2 1/3 1/4
2 1/2 1 1/6 1/2
3 1/3 1/6 1 1/12
4 1/4 1/2 1/12 1

The sum is 23/323/323/3. Put Hk∗=∑a<k, (a,k)=11/aH_k^*=\sum_{a<k,\,(a,k)=1}1/aHk∗​=∑a<k,(a,k)=1​1/a. Counting each reduced pair and its whole copies gives

A(N)=N+2∑k=2N⌊N/k⌋kHk∗.A(N)=N+2\sum_{k=2}^{N}\frac{\lfloor N/k\rfloor}{k}H_k^*.A(N)=N+2k=2∑N​k⌊N/k⌋​Hk∗​.

Replacing the floor by the quotient exposes the rounding loss. The exact deficit 3N−A(N)3N-A(N)3N−A(N) consists of twice

∑k≤N{Nk}Hk∗k\sum_{k\le N}\left\{\frac Nk\right\}\frac{H_k^*}{k}k≤N∑​{kN​}kHk∗​​

and a positive missing-pair tail of size O(log⁡N)O(\log N)O(logN).

Möbius inversion contributes 6/π26/\pi^26/π2. The weighted fractional-part theorem of Saffari and Vaughan contributes a mean one half, and harmonic summation contributes another half. Two orientations give

2×12×12×6π2=3π2.2\times\frac12\times\frac12\times\frac6{\pi^2} =\frac3{\pi^2}.2×21​×21​×π26​=π23​.

The continuous energy divides this table by three, leaving 1/π21/\pi^21/π2. Precisely,

A(N)=3N−3π2(log⁡N)2+O((log⁡N)5/3).\begin{aligned} A(N)={}&3N-\frac3{\pi^2}(\log N)^2\\ &+O\bigl((\log N)^{5/3}\bigr). \end{aligned}A(N)=​3N−π23​(logN)2+O((logN)5/3).​

Hilberdink, Luca and Tóth prove the classical leading estimate with an O((log⁡N)2)O((\log N)^2)O((logN)2) remainder. The result here identifies its leading correction. The fractional-part averaging is weighted, not ordinary uniform distribution.

Twenty-five readings of one curve

So far the correction belongs to a smooth average. The digit table is not smooth. It reads certain positions and nothing in between.

The connection between the two is exact. Each remainder pattern rises and resets, a sawtooth. Add the sawteeth for a base, double the result and square it. The collision energy of base five is precisely this curve read at twenty-five evenly spaced points and added up. One multiplication, by one minus the base, lines the carry table up with the readings, and no approximation enters anywhere.

The exact squared base-five response is shown twice. Above, teal fills its continuous area. Below, twenty-five equal-width gold rectangles use the height read at their left endpoints. The zero sample leaves an empty rectangle beside the first tall peak. The averages are 2.556 and 1.920. The exact squared base-five response is shown twice. Above, teal fills its continuous area. Below, twenty-five equal-width gold rectangles use the height read at their left endpoints. The zero sample leaves an empty rectangle beside the first tall peak. The averages are 2.556 and 1.920.
The same base-five curve twice. Above, its continuous average. Below, twenty-five readings as gold rectangles, some over the curve and some under, with a zero reading beside the tall peak at the left.

The smooth curve averages 23/923/923/9. The twenty-five readings average 48/2548/2548/25. They differ by exactly 143/225143/225143/225, and that difference is the sampling defect.

Anyone who has watched a wagon wheel turn backward in an old film has seen what sampling can do. The camera catches the spokes at fixed instants, and a wheel rolling forward is recorded rolling back. The digit table catches its curve at fixed instants too, and the curve changes with the base. It grows more teeth and sharper peaks at the same pace the readings crowd together. Nothing obvious stops the grid from inventing a correction of its own at exactly the size of the one just found, and changing the coefficient.

Winning by a log log

The proof has to show that the grid’s error is smaller than (log⁡p)2(\log p)^2(logp)2. The first attempt only ties.

The defect has two exact descriptions. One follows the jumps of the curve and where they fall relative to the grid. The other, after Rademacher’s reciprocity, is a collection of Dedekind sums at smaller moduli. Bounding those sums by their sizes and ignoring their signs gives an error of order (log⁡p)2(\log p)^2(logp)2. That is exactly the size of the correction, and a tie proves nothing.

To do better the signs have to stay in. Each Dedekind sum opens, through a Fourier expansion, into a series of sawtooth values read at modular inverses. Lemke Oliver and Soundararajan meet the same series in their study of biases between consecutive primes. Korolev’s estimate for incomplete sums of inverses controls it. Composite moduli pay a price in divisors, and that price stays bounded on average. The saving is one factor of log⁡log⁡p\log\log ploglogp.

∣Sp∣≪(log⁡2p)2log⁡log⁡3p|\mathcal S_p|\ll\frac{(\log 2p)^2}{\log\log 3p}∣Sp​∣≪loglog3p(log2p)2​

At base 10,007, log⁡log⁡p\log\log ploglogp is about 2.2. It is a thin margin, and it grows about as slowly as anything in analysis. But it grows without bound, and that is all the argument needs. The grid cannot reach the coefficient.

The exact bridge and the sampling theorem

Let saw⁡(x)={x}−1/2\operatorname{saw}(x)=\{x\}-1/2saw(x)={x}−1/2 away from integers and zero at integers. Put

Bp(x)=2∑r=1p−1saw⁡(rx).B_p(x)=2\sum_{r=1}^{p-1}\operatorname{saw}(rx).Bp​(x)=2r=1∑p−1​saw(rx).

Multiplication by 1−p1-p1−p permutes the residues modulo p2p^2p2 and gives

Fp([(1−p)j]p2)=Bp(j/p2).F_p([(1-p)j]_{p^2})=B_p(j/p^2).Fp​([(1−p)j]p2​)=Bp​(j/p2).

Consequently the two averages are

∫01Bp(x)2 dx=A(p−1)3,1p2∑j=0p2−1Bp(j/p2)2=Epp2.\begin{aligned} \int_0^1B_p(x)^2\,dx&=\frac{A(p-1)}3,\\ \frac1{p^2}\sum_{j=0}^{p^2-1}B_p(j/p^2)^2&=\frac{E_p}{p^2}. \end{aligned}∫01​Bp​(x)2dxp21​j=0∑p2−1​Bp​(j/p2)2​=3A(p−1)​,=p2Ep​​.​

Their difference is Sp\mathcal S_pSp​. At five, the averages are 23/923/923/9 and 48/2548/2548/25, with exact difference 143/225143/225143/225.

The uniform estimate is

∣Sp∣≪(log⁡(2p))2log⁡log⁡(3p).|\mathcal S_p|\ll \frac{(\log(2p))^2}{\log\log(3p)}.∣Sp​∣≪loglog(3p)(log(2p))2​.

One exact description keeps the jump sizes and their positions relative to the grid. Another uses Rademacher reciprocity and smaller Dedekind sums. Additive Fourier expansion opens the surviving term into centered inverse-residue series. Nonunit arguments descend to their actual moduli before Korolev’s incomplete-sum estimate is applied. Completion handles the remaining lengths, and bounded average divisor costs preserve the saving when the moduli are added.

The growing denominator in the bound makes the defect smaller than (log⁡p)2(\log p)^2(logp)2. The stronger logarithmic bound, boundedness and the conjectured limit Sp→1\mathcal S_p\to1Sp​→1 remain open in this manuscript. None is needed to transfer the secondary coefficient.

So the shortfall has its law.

p3−Ep∼p2(log⁡p)2π2p^3-E_p\sim\frac{p^2(\log p)^2}{\pi^2}p3−Ep​∼π2p2(logp)2​

The ratio of the two sides tends to one. It describes large bases, and any one table can still sit well away from it. At base 10,007 the right-hand side is 860,845,875, a little more than half the actual shortfall. The remainder the theorem allows is smaller in the limit, but it is not yet small.

Finite values and the remainder in the theorem
Base Exact energy Exact gap First correction
31 24,784 5,007 1,148
101 960,064 70,237 22,015
1,009 1,016,385,360 10,858,369 4,934,945
10,007 1,000,437,262,176 1,664,208,167 860,845,875

The energies are exact finite counts. The correction column uses natural logarithms and is rounded for display. The calculation covers every odd prime through 1,009, followed by the declared checkpoints 1,201, 2,003, 3,001, 4,001, 5,003, 7,001 and 10,007. These finite checks do not prove the limiting ratio.

The full statement is

Ep=p3−p2π2(log⁡p)2+O(p2(log⁡(2p))2log⁡log⁡(3p)).\begin{aligned} E_p={}&p^3-\frac{p^2}{\pi^2}(\log p)^2\\ &+O\left(\frac{p^2(\log(2p))^2}{\log\log(3p)}\right). \end{aligned}Ep​=​p3−π2p2​(logp)2+O(loglog(3p)p2(log(2p))2​).​

The error estimate is asymptotic. It does not specify a usable numerical error constant at one small base.

Four worked diagrams

The copy count, common-factor filter and sampled curve can also be inspected in these annotated calculations.

Three copies of two, three fit into the width-ten table. The diagram compares that integer count with the extra third admitted by the smooth quotient.
Three copies of two, three fit into the width-ten table. The diagram compares that integer count with the extra third admitted by the smooth quotient.
The complete width-forty coprime mask and the four factors producing the continuous square-table coefficient. The finite proportion differs from its limit.
The complete width-forty coprime mask and the four factors producing the continuous square-table coefficient. The finite proportion differs from its limit.
The exact base-five squared response, its actual jump values, twenty-five grid samples and the two averages. Their gap is 143 over 225.
The exact base-five squared response, its actual jump values, twenty-five grid samples and the two averages. Their gap is 143 over 225.
A wider-window comparison at bases five, eleven and thirty-one. Each panel uses the same normalized height scale as its curve and grid both change.
A wider-window comparison at bases five, eleven and thirty-one. Each panel uses the same normalized height scale as its curve and grid both change.

The full proofs are in The Secondary Term in Digit-Collision Energy.

One reading at zero

The theorem lets the sampling defect grow, slowly. The tables do not let it move much at all. These values come from exact integer floor counts in nfield.

  base     defect     endpoint
    31    0.951176    0.936524
   101    1.026972    0.980296
   199    1.058311    0.989975
   401    1.011478    0.995019
  1201    0.992167    0.998335
  4001    0.999951    0.999500
 10007    1.008630    0.999800

The endpoint column is a single term that the exact formula sets apart, and it has a plain meaning. At zero the squared curve stands at its full height (p−1)2(p-1)^2(p−1)2 on both sides, and the grid takes its reading exactly there and records zero. It is the dashed box at the left edge of the base-five picture, a zero reading beside a peak of sixteen. That one missed reading costs (p−1)2/p2(p-1)^2/p^2(p−1)2/p2, which tends to one.

If the defect tends to one as well, then the reading at zero is the grid’s entire lasting cost, and everything else it does cancels. The tables sit within a few percent of that, first above and then below. The proof says only that the defect is smaller than (log⁡p)2/log⁡log⁡p(\log p)^2/\log\log p(logp)2/loglogp. There is a great deal of room between one and (log⁡p)2/log⁡log⁡p(\log p)^2/\log\log p(logp)2/loglogp, and the tables keep landing near one.

The difference is now proved to tend to one. The common reset accounts for that unit, while the combined interior discrepancy vanishes. The calculation is developed in The Common Reset in the Cubic Law.

Companion paper: The Secondary Term in Digit-Collision Energy →
Share

Discussion

Sign in to join the discussion.

← All articlesRead the paper →
← Previous: Digit Collisions and the Cubic Law
Next: Magnitude Decorrelation in the Collision Spectrum →