README.md
14.2 kB · markdown
leaning-stack
- Leans the line stack: layer
nis translated by a driftt_n, so its lines sit atxwithn x - theta_nan integer,theta_n = n t_n mod 1being the phase of the layer. The plain stack istheta_n = 0. - Two leans and one control. The LINEAR lean is
t_n = delta, phasen delta; the QUADRATIC lean ist_n = n delta, phasen^2 delta, the leaning tower; the control is any phase schedule periodic inn. - Brightness is
B_N(x) = #{n <= N : n x - theta_n in Z}, the count of layers whose lines pass throughx. - The quadratic lean at rational drift
c/dturns the lit condition into the quadratic congruencen (a d - b c n) = 0 mod b datx = a/b, solved here prime by prime in closed form (local_classes,solution_classes,brightness_form). lcm(b, d*)is a period of that solution set and not always the least one; the least is read off the set itself and halves exactly on a2-adic condition (minimal_period,halving_rule).- The same congruence read by its Fourier transform is a quadratic Gauss sum, and the phase census of a prime drift denominator is a Legendre symbol (
phase_census,gauss_sum,quadratic_sum). - At irrational drift the quadratic lean has no coincidence at all, and the layer phases equidistribute (
irrational_lean,adversarial).
RUN
uv run python research/lab/py/leaning-stack/leaning_stack.py- From the repo root. One core, under two seconds.
- Domain is the linear lean at
N = 30and denominatorsb <= 30, the quadratic lean atN = 60over all reduceda/bwithb <= 12and seven drifts, the minimal-period law over all 16384 reduced tuples withb, d <= 20, the adversarial sweep atN = 60over all reduceda/bwithb <= 20and all 80 reduced drifts withd <= 16, the sharing criterion overm < n <= 12against every reduced drift withd <= 16, the origin over every reduced drift withd <= 60, the Gauss sums atd = 5, 7, 11, 13, and the irrational drifts toN = 10000. - Rational work is exact: points, drifts and phases are
Fraction, and the literal brightness is the definitionn x - theta_n in Zwith no congruence used. The literal solution set isn (a d - b c n) mod b d, the definition cleared of denominators, and is built without touching the closed form, so the set, period and class-count checks read an expectation the sweep does not supply. Irrational drifts are exact rationals of50digits, so the pair gaps and discrepancies are integer arithmetic; the linear lean's irrational check is the one float pass, at tolerance1e-12. - The single PNG beside this file is written; nothing else.
WHAT IT PRINTS
linear_lean: brightness atdelta + a/bagainstfloor(N/b)at every reduceda/bwithb <= 30, exactly atdelta = 2/7and at1e-12fordelta = sqrt 2 - 1andphi - 1, with the count of nonzero readings off the translated set and the closest approach at a rational point.quadratic_lean: literal brightness against the closed form atN = 60for all46reduceda/bwithb <= 12, per drift, with the closed form's residue set checked against the literal solution set, the least period of that set checked against the halving rule, and the top brightness table beside the origin's brightness.minimal_period_law: the count of reduced tuples withb, d <= 20whose least period is belowlcm(b, d*), the breaches of the halving rule, and three worked points.sharing_law: the criterionlcm(m, n)(m - n) delta in Zagainst literal intersection of the two layers' lit sets, with the two weaker conditions and a witness separating them.lit_set: the first layer lighting each point, literal against the form, the count of points first lit atlcm(b, d*)itself, and the numerator-dependence witness atdelta = 1/4.origin_law: the origin's brightness againstfloor(N/d*)over every reduced drift withd <= 60, the first thirtyd*, the identityd* = d/A000188(d)tod = 1000, and the Dirichlet series of1/d*against its zeta ratio.gauss_sums: the phase census of the quadratic lean at primed, its Legendre form, the exact Legendre twist of the Gauss sum, the numericS(c, p)against(c/p) eps_p sqrt p, and the solution count as a Fourier sum of quadratic Gauss sums.adversarial: the closed form against literal stacking on the widest domain, the count of distinct lit points of the irrational lean, and the closest two layers come over all pairs toN = 120.irrational_lean: the closest pair gap and the star discrepancy of{n^2 delta}atN = 1000, 10000against1/sqrt N.
WHAT IT FINDS
- The linear lean is the plain stack translated, exactly.
theta_n = n deltamakesn x - n delta in Zthe same condition asn (x - delta) in Z, so the lit set isF_Q + deltaand the brightness atdelta + a/bisfloor(N/b). AtN = 30,delta = 2/7:278nodes tested,0brightness mismatches,0nonzero readings off the translate; atdelta = sqrt 2 - 1andphi - 1,0mismatches at1e-12, and the closest a rational point comes to a coincidence is0.000036and0.000041, so no rational point is lit at all (linear_lean). - The quadratic lean is a congruence.
theta_n = n^2 deltawithdelta = c/dreduced puts layernthroughx = a/breduced exactly whenn (a d - b c n) = 0 mod b d, sincen a/b - n^2 c/d = n (a d - b c n)/(b d). The solution set is a union of arithmetic progressions, so brightness is floor-linear inN. - The class structure is closed. Write
beta = v_p(b),delta_p = v_p(d), andd*for the leastkwithd | k^2, that isd* = prod p^ceil(v_p(d)/2). The lit layers form a union of residue classes moduloP = lcm(b, d*): the single classn = 0at every prime withdelta_p < betaordelta_p >= 2 beta, and the two classesn = 0andn = p^(delta_p - beta) uwithu = a d' (c b')^-1 mod p^(2 beta - delta_p)at every prime withbeta <= delta_p < 2 beta. Solcm(b, d*)is a period and the union has2^wclasses modulo it,wthe number of primes in that middle band. Checked against the literal solution setn (a d - b c n) mod b d, not against itself: atN = 60over the46reduceda/bwithb <= 12and the seven drifts1/2, 1/3, 1/4, 2/5, 1/6, 3/8, 5/9,0brightness mismatches and0solution-set mismatches (quadratic_lean). lcm(b, d*)is a period and not always the least one, and the exception is2-adic. The least period islcm(b, d*)/2exactly whenv_2(b) >= 1andv_2(d) = 2 v_2(b) - 1, andlcm(b, d*)otherwise: in that case the middle-band class at2is2^(beta-1)times a unit, so the two classes are a subgroup and collapse to one. Over all16384reduced tuples withb, d <= 20the least period falls belowlcm(b, d*)at417of them with0breaches of the rule (minimal_period_law). The headline point is one of them:x = 1/2atdelta = 1/2has classes0, 1mod2, which is all ofZ, least period1;x = 1/6atdelta = 1/2has classes0, 3mod6, least period3;x = 1/4atdelta = 3/8has classes0, 2mod4, least period2. Every brightness above is unaffected, the count being over classes and not over periods.- Brightness is then
B_N(a/b) = sum over the classes s of #{n <= N : n = s mod P}, which isfloor(N/P)ats = 0andfloor((N - s)/P) + 1at0 < s <= N. On the widest domain run here, all128reduceda/bwithb <= 20against all80reduced drifts withd <= 16,10240pairs atN = 60, the closed form and literal stacking disagree0times (adversarial). - The lean moves the bright nodes off the origin at five of the seven drifts printed. At
delta = 1/2the top brightness atN = 60is60atx = 1/2, every layer lighting it, against30at the origin; atdelta = 1/3it is40at1/3and2/3against20; atdelta = 2/5it is24at the four fifths against12; atdelta = 1/6it is40at1/6and5/6against10; atdelta = 3/8it is30at1/4and3/4against15. Atdelta = 1/4and5/9the origin ties for top,30at0, 1/2, 1/4, 3/4and20at0, 1/3, 2/3(quadratic_lean). The plain stack's unique brightest point is the origin; the leaning stack's need not be. - The lit set depends on the numerator, which the plain stack's does not. A point
a/bis lit by some layern <= Nexactly when the least positive solution class is at mostN, and that class carriesathrough the unituabove. Witness atdelta = 1/4:x = 1/4has classes0, 1mod4, first lit atn = 1,B_61 = 31;x = 3/4has classes0, 3mod4, first lit atn = 3,B_61 = 30. Overb <= 12andd in 2, 4, 8, 9there are48reduced pairs whose first lit layer moves when the numerator does (lit_set). Every first-lit prediction matches the literal search,0mismatches at all seven drifts, where between33and40of the46points are first lit atlcm(b, d*)itself. - The origin's brightness is
floor(N/d*). Atx = 0the condition isd | c n^2, that isd* | n, so the origin reads the plain stack at scaled*instead of1. Over every reduced drift withd <= 60atN = 60:0mismatches. The first thirtyd*are1, 2, 3, 2, 5, 6, 7, 4, 3, 10, 11, 6, 13, 14, 15, 4, 17, 6, 19, 10, 21, 22, 23, 12, 5, 26, 9, 14, 29, 30, which is A019554, the smallest number whose square is divisible byn, multiplicative witha(p^e) = p^ceil(e/2); the identityd* = d/A000188(d)holds tod = 1000with0breaches (origin_law). - The origin density stays inside the zeta ratios. A019554 carries the Dirichlet series
sum_n 1/(a(n) n^s) = zeta(2s+1) zeta(s+1)/zeta(2s+2); summing1/(d* d^s)here gives1.826509, 1.826861, 1.826902at cuts10^4, 10^5, 10^6againstzeta(3) zeta(2)/zeta(4) = 1.826907ats = 1, and1.225197at all three cuts againstzeta(5) zeta(3)/zeta(6) = 1.225197ats = 2(origin_law). - The layer phases of a prime drift are a Legendre symbol. At
delta = c/pthe phasen^2 c/ptakes only(p+1)/2values, and the multiplicity ofj/pis1 + (j c^-1 / p)atj != 0and1atj = 0. Checked atp = 5, 7, 11, 13withca residue and a non-residue:3, 4, 6, 7distinct phases and0census breaches (gauss_sums). - The Gauss sum carries the twist exactly, after centring.
S(c, p) = sum_n e(c n^2/p) = (c/p) S(1, p)holds coefficient by coefficient on the CENTRED multiplicity vectors, multiplicity minus one, which is the Legendre identity(j c^-1/p) = (c/p) (j/p); the raw multiplicity vectors are not proportional,[1,0,0,2,0,2,2]against[1,2,2,0,2,0,0]atp = 7, c = 3, and the two sums agree only throughsum_j e(j/p) = 0.0centred breaches at all eight cases, and numericallyS(c, p)equals(c/p) eps_p sqrt pwitheps_p = 1atp = 1 mod 4andiatp = 3 mod 4, reading2.236068, -2.236068, 2.645751i, -2.645751i, 3.316625i, -3.316625i, 3.605551, -3.605551(gauss_sums). - The solution count is a sum of quadratic Gauss sums. Orthogonality gives
R = (1/m) sum_{h mod m} sum_{n mod m} e(h Q(n)/m)withQ(n) = b c n^2 - a d nandm = b d, the inner sum a quadratic Gauss sum with a linear term. Evaluated numerically it returns1, 1, 8, 24, 16at(a/b, delta) = (1/1, 1/5), (1/2, 1/3), (1/4, 1/4), (1/6, 1/6), (5/12, 3/8), matching the class count timesm/Pin every case (gauss_sums). - Layers
m != nshare a lit point exactly whenlcm(m, n)(m - n) deltais an integer. Solvingx = (j + m^2 delta)/mand substituting, the difference of two lit points is(j n - k m)/(m n) + delta (m - n), andj n - k mruns overgcd(m, n) Z, so a coincidence asksdelta (m - n)to lie in(1/lcm(m, n)) Z. Checked against literal intersection of the two layers' lit sets overm < n <= 12against every reduced drift withd <= 16,5280pairs,1474sharing,0criterion failures; the weaker conditions fail,n (m - n) deltabeing rational at every one of the3806non-sharing pairs andm n (m - n) deltabeing an integer at64of them, first at(m, n, delta) = (2, 4, 1/16)(sharing_law). - At irrational drift no two layers of the quadratic lean meet, since
lcm(m, n)(m - n) deltais then never an integer atm != n, so brightness is at most1everywhere and at everyN. Numerically the325lit points of layers1..25are325distinct points at bothdelta = sqrt 2 - 1andphi - 1, and the closest any two layers come over all pairs toN = 120is9.202e-09at(72, 77)and7.488e-09at(56, 92)(adversarial,irrational_lean). - The near-coincidences follow Weyl.
{n^2 delta}is equidistributed for irrationaldelta(Weyl 1916), and the star discrepancy reads0.019450and0.006421atN = 1000, 10000forsqrt 2 - 1and0.022253and0.009391forphi - 1, against1/sqrt N = 0.031623and0.010000, ratios0.6151, 0.6421, 0.7037, 0.9391(irrational_lean). Four points, no fit and no exponent is claimed.
FIGURES
leaning-stack.png: the leaning stack turned into a field by taking the product of thexandyline stacks,N = 30,500pixels a side,delta = 1/5on the left anddelta = sqrt 2 - 1on the right,45240bytes (panel_grey,render).- Grey is monotone in the rank of the brightness among the distinct values present, the faintest lit value at grey
190and the peak at black, so a picture shows which nodes are bright and reads no exact value. Panel peaks are144and16. - The left panel keeps a
5 x 5blank cross grid, the lines at multiples of1/5that no layer reaches, and the right panel has no blank structure at all: the rational drift keeps a periodic skeleton, the irrational one destroys it. Every count on this page is exact arithmetic checked against literal stacking; the picture illustrates it and proves nothing.
WITNESSES
farey.mdWHERE THE LINES LAND:floor(N/b)survives the linear lean verbatim on a translated Farey set, and is replaced under the quadratic lean by a floor-linear count over2^wclasses modulo the periodlcm(b, d*).stack.mdSTACKING THE STACKS: the lean is not a weight on the scales, so it leaves the Dirichlet group; the origin density1/d*is nonetheless a coefficient ofzeta(2s+1) zeta(s+1)/zeta(2s+2).stack.mdSPINNING THE STACK: the dead-spin theorem kills coincidences by rotation; the irrational quadratic lean kills them by translation, and needs no Niven.