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

Phase-Filtered Ramanujan Sums and the Spectral Gate

April 17, 202214 min read
Companion paper: Phase-Filtered Ramanujan Sums and the Spectral Gate →
Opposing blue paths leave one gold direction clear. The spectral gate selects a precise contribution from signed phase terms whose separate magnitudes conceal the cancellation.
Opposing blue paths leave one gold direction clear. The spectral gate selects a precise contribution from signed phase terms whose separate magnitudes conceal the cancellation.

In 1918 Ramanujan published a paper on a family of sums that now carry his name. At a prime they are about as simple as a sum can be. Each one adds up p−1p-1p−1 arrows of length one, and depending on its argument either the arrows all point the same way and the total is p−1p-1p−1, or they fan out evenly around a circle with one missing and the total is −1-1−1. Ramanujan used them to write familiar arithmetic functions as infinite series, and they have been a working tool of analytic number theory ever since. They also turn up, exactly, in long division. Ask how many remainders keep their first digit when every remainder is multiplied by the same number, and the answer is a sum over the frequency table of The Autocorrelation Formula in which Ramanujan’s two values do the selecting.

The question I brought to it was whether the last digit of a prime decides those counts. Thirteen and fifty-three both end in three, and in decimal that fixes where their larger digit bins sit, at the digits three and six, however big the prime gets. It does not fix which multiplications keep a digit. Doubling moves every remainder of thirteen out of its digit bin, while at fifty-three four remainders keep their digit, and none of the four lives in one of the larger bins.

Here is where the bins come from. Write the twelve fractions from 1/131/131/13 through 12/1312/1312/13 and look at the first decimal digit of each. There are ten digits for twelve fractions, so most digits appear once, while three appears twice, from 4/134/134/13 and 5/135/135/13, and six appears twice, from 8/138/138/13 and 9/139/139/13. Over 53 there are fifty-two fractions, and every digit appears five times except three and six, which appear six times. The extra places stay in the same columns.

Decimal bin populations at thirteen and fifty-three. Teal bars show one place per bin at thirteen and five at fifty-three. Gold adds one place at digits three and six in both tables. Decimal bin populations at thirteen and fifty-three. Teal bars show one place per bin at thirteen and five at fifty-three. Gold adds one place at digits three and six in both tables.
How many fractions start with each digit, at thirteen and at fifty-three. The teal base grows from one to five per digit, but the gold extra place lands on digits 3 and 6 both times.

Both primes end in three, and that ending is what lands the extra places in the same two columns.

The extra places

A digit bin collects remainders that emit the same first digit. At thirteen, the digit-three bin is {4,5}\{4,5\}{4,5} and the digit-six bin is {8,9}\{8,9\}{8,9}.

For a prime ppp not dividing the base b≥2b\ge2b≥2, write

p=bq+r,1≤r<b.p=bq+r,\qquad 1\le r<b.p=bq+r,1≤r<b.

Every bin has qqq or q+1q+1q+1 members. Exactly r−1r-1r−1 bins get the extra member. We lose one of the rrr extra places because remainder zero is excluded. Digit zero is not excluded. At fifty-three, five fractions begin with it.

The remainder rrr decides which bins are larger, and in decimal, primes other than two and five give four possibilities.

Last digit of the prime Larger bins
1 None
3 Two
7 Six
9 Eight

The quotient grows with the prime, but the pattern of extra places does not.

Doubling, and then six

Return to thirteen. Double each nonzero remainder, reduce modulo thirteen, and compare its digit before and after the move.

The bin {4,5}\{4,5\}{4,5} goes to {8,10}\{8,10\}{8,10}, and neither result stays in the digit-three bin. The bin {8,9}\{8,9\}{8,9} goes to {3,5}\{3,5\}{3,5}, and neither stays in the digit-six bin. The other eight bins are singletons, where a remainder could keep its digit only by returning to itself, and doubling fixes no nonzero remainder modulo thirteen. There are no matches anywhere.

Now multiply by six. Five goes to four, since 6⋅5=306\cdot5=306⋅5=30 leaves remainder four, and both emit three. Eight goes to nine, and both emit six.

Remainders four, five, eight and nine modulo thirteen under multiplication by two and by six. Doubling changes every digit. Multiplication by six keeps five to four in digit three and eight to nine in digit six. The surviving pairs are gold. Remainders four, five, eight and nine modulo thirteen under multiplication by two and by six. Doubling changes every digit. Multiplication by six keeps five to four in digit three and eight to nine in digit six. The surviving pairs are gold.
The four remainders in thirteen’s two-member bins, doubled and then multiplied by six. Doubling sends every one of them to a different digit, while six keeps two, 5 going to 4 and 8 going to 9, shown in gold.

Call the number of matches C(a)C(a)C(a), where aaa is the multiplier, so we have counted C(2)=0C(2)=0C(2)=0 and C(6)=2C(6)=2C(6)=2.

These counts use every nonzero remainder, and a multiplier need not be a power of the base. When it is, the count adds the corresponding shifted matches across all remainder cycles, and only in the full-period case does one repeating block supply the whole count.

Twelve, or minus one

The Autocorrelation Formula puts digit equality in a square table KKK, with a one wherever two remainders write the same digit and an empty row and column at zero. Its Fourier transform G(k,k′)G(k,k')G(k,k′) carries the same information in frequency coordinates, and a line through GGG recovers C(a)C(a)C(a). Ramanujan’s sum supplies another way to select that line, with two weights and a balance.

For a prime ppp, the sum cp(t)c_p(t)cp​(t) adds the unit arrows for all nonzero residues. When t=0t=0t=0 modulo ppp, all p−1p-1p−1 arrows point together. Otherwise they form every pppth root of unity except the arrow at one, and since the complete set sums to zero, leaving out that arrow gives minus one.

At thirteen,

c13(t)={12,t=0(mod13),−1,t≠0(mod13).c_{13}(t)=\begin{cases}12,&t=0\pmod{13},\\-1,&t\ne0\pmod{13}.\end{cases}c13​(t)={12,−1,​t=0(mod13),t=0(mod13).​

This is the classical sum from Ramanujan’s 1918 paper, and here its argument is the combined frequency k+ak′k+ak'k+ak′. The collision identity is

C(a)=1p2∑k,k′G(k,k′)cp(k+ak′).C(a)=\frac1{p^2}\sum_{k,k'}G(k,k')c_p(k+ak').C(a)=p21​k,k′∑​G(k,k′)cp​(k+ak′).

Both frequency labels run from zero to p−1p-1p−1. The line k+ak′=0k+ak'=0k+ak′=0 receives weight p−1p-1p−1 and every other cell receives minus one, so the off-line cells have not been erased.

The transform and the collision identity

Let BdB_dBd​ be the bin for digit ddd, and let fdf_dfd​ be its indicator, with fd(0)=0f_d(0)=0fd​(0)=0. Its Fourier coefficient is the sum of the bin’s rotating arrows,

f^d(k)=∑x∈Bde−2πikx/p.\widehat f_d(k)=\sum_{x\in B_d}e^{-2\pi i kx/p}.f​d​(k)=x∈Bd​∑​e−2πikx/p.

The equality table and its transform are

K(x,y)=∑d=0b−1fd(x)fd(y),K(x,y)=\sum_{d=0}^{b-1}f_d(x)f_d(y),K(x,y)=d=0∑b−1​fd​(x)fd​(y), G(k,k′)=∑d=0b−1f^d(k)f^d(k′).G(k,k')=\sum_{d=0}^{b-1}\widehat f_d(k)\widehat f_d(k').G(k,k′)=d=0∑b−1​f​d​(k)f​d​(k′).

There is no conjugate in the second product. Fourier inversion gives

K(x,y)=1p2∑k,k′G(k,k′)e2πi(kx+k′y)/p.K(x,y)=\frac1{p^2}\sum_{k,k'}G(k,k')e^{2\pi i(kx+k'y)/p}.K(x,y)=p21​k,k′∑​G(k,k′)e2πi(kx+k′y)/p.

Set y=axy=axy=ax and sum over nonzero xxx. Each exponential becomes part of

∑x=1p−1e2πi(k+ak′)x/p=cp(k+ak′).\sum_{x=1}^{p-1}e^{2\pi i(k+ak')x/p}=c_p(k+ak').x=1∑p−1​e2πi(k+ak′)x/p=cp​(k+ak′).

The left side counts remainders that keep their digit and the right side is the Ramanujan-weighted collision identity, which holds for every nonzero multiplier without a primitive-root assumption.

The full table GGG sums to zero, because Fourier inversion gives ∑k,k′G(k,k′)=p2K(0,0)=0\sum_{k,k'}G(k,k')=p^2K(0,0)=0∑k,k′​G(k,k′)=p2K(0,0)=0. If the selected line sums to SSS, the rest of the table sums to −S-S−S. Apply the two weights,

(p−1)S−(−S)=pS.(p-1)S-(-S)=pS.(p−1)S−(−S)=pS.

Divide by p2p^2p2 and the answer is S/pS/pS/p, so the double sum has become a single line.

A thirteen-by-thirteen table of Ramanujan weights for multiplier six. Gold cells on k plus six k prime equals zero carry twelve. Every other cell carries minus one. The spectral sum on the line is 26 and off the line minus 26. Their weighted total 338 divided by 169 gives two matches. A thirteen-by-thirteen table of Ramanujan weights for multiplier six. Gold cells on k plus six k prime equals zero carry twelve. Every other cell carries minus one. The spectral sum on the line is 26 and off the line minus 26. Their weighted total 338 divided by 169 gives two matches.
Ramanujan’s weights at thirteen for multiplier six, twelve on the selected line and minus one everywhere else. The line sums to 26 and the rest of the table to −26, and 12 × 26 − (−26) = 338 = 169 × 2 gives the two matches.

At thirteen with multiplier six, the line sums to 26 and the remaining cells sum to −26-26−26. Their weighted total is 12⋅26−(−26)=33812\cdot26-(-26)=33812⋅26−(−26)=338, and dividing by 132=16913^2=169132=169 gives two, with no rounding anywhere. The two are 5→45\to45→4 and 8→98\to98→9.

Twenty-six survives

The selected line adds contributions from all the digit bins, each with a magnitude and a phase, and adding them can lose much of the magnitude to cancellation.

To measure that loss, take the magnitude of each bin contribution before adding across bins or frequencies. Call the unsigned total M(a)M(a)M(a). With k′=−a−1kk'=-a^{-1}kk′=−a−1k along the selected line,

M(a)=∑d,k∣f^d(k)∣ ∣f^d(−a−1k)∣.M(a)=\sum_{d,k}|\widehat f_d(k)|\,|\widehat f_d(-a^{-1}k)|.M(a)=d,k∑​∣f​d​(k)∣∣f​d​(−a−1k)∣.

The sum after cancellation is S(a)=pC(a)S(a)=pC(a)S(a)=pC(a). Define the phase-gate coefficient by

Γ(a)=∣S(a)∣M(a)=pC(a)M(a).\Gamma(a)=\frac{|S(a)|}{M(a)}=\frac{pC(a)}{M(a)}.Γ(a)=M(a)∣S(a)∣​=M(a)pC(a)​.

The order of operations matters. Taking ∣G(k,k′)∣|G(k,k')|∣G(k,k′)∣ after its bins have already been added would miss cancellation between bins and give a different denominator.

At thirteen, multiplier six selects k′=2kk'=2kk′=2k, whose unsigned total is 144.5895015…144.5895015\ldots144.5895015… while the signed sum is exactly 26.

Thirteen frequencies at denominator thirteen, multiplier six. Teal bars show unsigned bin contributions before adding across bins. Gold dots and stems show the signed entries after adding bins on the selected line. Unsigned mass totals 144.5895015, while the signed sum is exactly 26, giving gate approximately 0.1798194. Thirteen frequencies at denominator thirteen, multiplier six. Teal bars show unsigned bin contributions before adding across bins. Gold dots and stems show the signed entries after adding bins on the selected line. Unsigned mass totals 144.5895015, while the signed sum is exactly 26, giving gate approximately 0.1798194.
The selected line at thirteen, frequency by frequency. The teal bars are the contributions before any cancellation and add to about 144.6, while the gold stems keep their signs, dip below zero in the middle and add to exactly 26.

Thus Γ(6)=0.1798194…\Gamma(6)=0.1798194\ldotsΓ(6)=0.1798194…, so about eighteen percent of the unsigned mass survives. That is not the fraction of remainders that match, which is 2/122/122/12.

Work out the unsigned total at thirteen

Each singleton bin supplies a Fourier coefficient of magnitude one at every frequency, so eight such bins and thirteen frequencies contribute 8⋅13=1048\cdot13=1048⋅13=104 to M(6)M(6)M(6).

Each two-member bin contains neighbors. Their unit arrows differ in angle by 2πk/132\pi k/132πk/13, so the sum has magnitude 2∣cos⁡(πk/13)∣2|\cos(\pi k/13)|2∣cos(πk/13)∣. Along k′=2kk'=2kk′=2k, the product of the two magnitudes is 4∣cos⁡(πk/13)cos⁡(2πk/13)∣4|\cos(\pi k/13)\cos(2\pi k/13)|4∣cos(πk/13)cos(2πk/13)∣. Both two-member bins contribute the same amount.

Put

tk=∣cos⁡πk13cos⁡2πk13∣.t_k=\left|\cos\frac{\pi k}{13}\cos\frac{2\pi k}{13}\right|.tk​=​cos13πk​cos132πk​​. M(6)=104+8∑k=012tk.M(6)=104+8\sum_{k=0}^{12}t_k.M(6)=104+8k=0∑12​tk​.

The terms satisfy t13−k=tkt_{13-k}=t_kt13−k​=tk​, so these seven values give the entire sum. The displayed decimals are rounded.

kkk tkt_ktk​
0 1.000000000
1 0.859726283
2 0.502996353
3 0.090223001
4 0.201438535
5 0.265425569
6 0.117034103

Count t0t_0t0​ once and each of the other six twice. Their sum is 5.073687689…5.073687689\ldots5.073687689…, giving

M(6)=144.589501512…,M(6)=144.589501512\ldots,M(6)=144.589501512…, Γ(6)=26144.589501512….\Gamma(6)=\frac{26}{144.589501512\ldots}.Γ(6)=144.589501512…26​.

Only the decimal evaluation is approximate, since the finite cosine sum specifies the denominator exactly.

Zero means no returns

The gate lies between two bounds,

C(a)p−1≤Γ(a)≤1.\frac{C(a)}{p-1}\le\Gamma(a)\le1.p−1C(a)​≤Γ(a)≤1.

Its denominator is always positive, because the zero-frequency terms alone contribute the sum of the squared bin sizes, so the gate vanishes exactly when C(a)C(a)C(a) does. At the identity multiplier nothing moves and the gate is one. At thirteen doubling makes it zero, and multiplication by six puts it just above the lower bound 1/61/61/6.

Phase-gate values for every nonzero multiplier at thirteen and fifty-three. Gold points show the gate and teal points the normalized collision lower bound. Hollow gold points at zero represent exact zero counts. The identity multiplier has gate one in both panels. Phase-gate values for every nonzero multiplier at thirteen and fifty-three. Gold points show the gate and teal points the normalized collision lower bound. Hollow gold points at zero represent exact zero counts. The identity multiplier has gate one in both panels.
The gate for every multiplier at thirteen and at fifty-three, gold for the gate and teal for its lower bound. Thirteen is zero almost everywhere, with small gates at 6 and 11, while fifty-three has only nine zeros and a scatter of small positive gates everywhere else.

A zero has a literal meaning in the bins, since it says every bin moves completely away from itself. If even one remainder stays inside its bin, the gate is positive.

The proof of the bounds

The triangle inequality gives ∣S(a)∣≤M(a)|S(a)|\le M(a)∣S(a)∣≤M(a), which is the upper bound.

For the lower bound, multiplication by −a−1-a^{-1}−a−1 permutes the frequency labels. Cauchy-Schwarz and Parseval give, bin by bin,

∑k∣f^d(k)∣ ∣f^d(−a−1k)∣≤p∣Bd∣.\sum_k|\widehat f_d(k)|\,|\widehat f_d(-a^{-1}k)|\le p|B_d|.k∑​∣f​d​(k)∣∣f​d​(−a−1k)∣≤p∣Bd​∣.

Adding over bins yields M(a)≤p(p−1)M(a)\le p(p-1)M(a)≤p(p−1). Since S(a)=pC(a)S(a)=pC(a)S(a)=pC(a), division gives Γ(a)≥C(a)/(p−1)\Gamma(a)\ge C(a)/(p-1)Γ(a)≥C(a)/(p−1).

When a=1a=1a=1, opposite-frequency coefficients are conjugates, every product is a nonnegative squared magnitude, and no cancellation occurs, so Γ(1)=1\Gamma(1)=1Γ(1)=1.

A positive collision count is an integer at least one, so a positive gate is at least 1/(p−1)1/(p-1)1/(p−1) at a fixed prime. That bound shrinks as ppp grows and supplies no uniform positive gap over all primes.

Phase-Filtered Ramanujan Sums and the Spectral Gate gives the complete proofs and the Euclidean bin formula.

Four returns at fifty-three

Doubling leaves no return at thirteen, so try the same multiplier at fifty-three. The digit-zero bin now contains {1,2,3,4,5}\{1,2,3,4,5\}{1,2,3,4,5}, and doubling keeps 1→21\to21→2 and 2→42\to42→4 inside it. The digit-nine bin contains {48,49,50,51,52}\{48,49,50,51,52\}{48,49,50,51,52}, and doubling modulo fifty-three keeps 51→4951\to4951→49 and 52→5152\to5152→51 inside that bin.

The two endpoint digit bins at fifty-three under doubling. Bin zero contains one through five and keeps one to two and two to four. Bin nine contains 48 through 52 and keeps 51 to 49 and 52 to 51. The four returns are gold. The two endpoint digit bins at fifty-three under doubling. Bin zero contains one through five and keeps one to two and two to four. Bin nine contains 48 through 52 and keeps 51 to 49 and 52 to 51. The four returns are gold.
The four remainders at fifty-three that keep their first digit when doubled, two in the digit-0 bin and two in the digit-9 bin. Both are ordinary five-member bins, not the larger ones at 3 and 6.

Those are all four matches. The same Ramanujan calculation gives a line sum of 53⋅4=21253\cdot4=21253⋅4=212 and recovers C(2)=4C(2)=4C(2)=4, so the gate is positive.

Six primes with the same two extra places

Every prime below ends in three and has its extra places at digits three and six. The pictures show actual returns, one cell per remainder and multiplier.

Six integer collision tables for decimal primes thirteen, 43, 53, 103, 223 and 503. Columns are nonzero remainders and rows are nonzero multipliers. Colored cells mark equal first digits before and after multiplication. Ten colors identify the retained digit. Uncolored cells mark no match. Six integer collision tables for decimal primes thirteen, 43, 53, 103, 223 and 503. Columns are nonzero remainders and rows are nonzero multipliers. Colored cells mark equal first digits before and after multiplication. Ten colors identify the retained digit. Uncolored cells mark no match.
Six primes ending in three, with a colored cell wherever multiplying the remainder x by a keeps its first digit, colored by that digit. The extra bins sit at 3 and 6 for all six, yet doubling keeps 0 remainders at 13, 4 at 43 and 53, 10 at 103, 22 at 223 and 50 at 503.

Read a row to see which remainders keep their digit under one multiplication. Its number of colored cells is C(a)C(a)C(a), an empty row means a zero gate, and the bottom row is the identity, so it is completely filled.

These are integer comparisons in the remainder table, not frequency plots, and color names the retained digit with one key shared by all six panels. The largest table has 5022=252,004502^2=252{,}0045022=252,004 cells, all kept in the full-size plate, and each row count is also checked against its Fourier slice and phase-gate bounds.

The bins, the moves, and the selector

These wider plates put the two bin populations alongside their multiplication tests and the Ramanujan weights. The selector’s gold cells carry twelve, not the spectral values being weighted.

Bin populations at thirteen and fifty-three. The two gold additions stay at digits three and six while the common part of each bin grows.
Bin populations at thirteen and fifty-three. The two gold additions stay at digits three and six while the common part of each bin grows.
The two nonsingleton bins at thirteen under multiplication by two and six. The intersections isolate the two returns under six.
The two nonsingleton bins at thirteen under multiplication by two and six. The intersections isolate the two returns under six.
The Ramanujan selector at thirteen for multiplier six, with its line and off-line spectral totals shown alongside. Weighting both parts gives exactly two matches.
The Ramanujan selector at thirteen for multiplier six, with its line and off-line spectral totals shown alongside. Weighting both parts gives exactly two matches.

The extra places are still at three and six, and none of the four returns uses either of those bins. They happen at zero and nine, where the smaller table had no room for them.

Companion paper: Phase-Filtered Ramanujan Sums and the Spectral Gate →
Share

Discussion

Sign in to join the discussion.

← All articlesRead the paper →
← Previous: The Autocorrelation Formula
Next: Bin Derangements and the Gate Width Theorem →