README.md

14.2 kB · markdown

leaning-stack

  • Leans the line stack: layer n is translated by a drift t_n, so its lines sit at x with n x - theta_n an integer, theta_n = n t_n mod 1 being the phase of the layer. The plain stack is theta_n = 0.
  • Two leans and one control. The LINEAR lean is t_n = delta, phase n delta; the QUADRATIC lean is t_n = n delta, phase n^2 delta, the leaning tower; the control is any phase schedule periodic in n.
  • Brightness is B_N(x) = #{n <= N : n x - theta_n in Z}, the count of layers whose lines pass through x.
  • The quadratic lean at rational drift c/d turns the lit condition into the quadratic congruence n (a d - b c n) = 0 mod b d at x = 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 a 2-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 = 30 and denominators b <= 30, the quadratic lean at N = 60 over all reduced a/b with b <= 12 and seven drifts, the minimal-period law over all 16384 reduced tuples with b, d <= 20, the adversarial sweep at N = 60 over all reduced a/b with b <= 20 and all 80 reduced drifts with d <= 16, the sharing criterion over m < n <= 12 against every reduced drift with d <= 16, the origin over every reduced drift with d <= 60, the Gauss sums at d = 5, 7, 11, 13, and the irrational drifts to N = 10000.
  • Rational work is exact: points, drifts and phases are Fraction, and the literal brightness is the definition n x - theta_n in Z with no congruence used. The literal solution set is n (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 of 50 digits, so the pair gaps and discrepancies are integer arithmetic; the linear lean's irrational check is the one float pass, at tolerance 1e-12.
  • The single PNG beside this file is written; nothing else.

WHAT IT PRINTS

  • linear_lean: brightness at delta + a/b against floor(N/b) at every reduced a/b with b <= 30, exactly at delta = 2/7 and at 1e-12 for delta = sqrt 2 - 1 and phi - 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 at N = 60 for all 46 reduced a/b with b <= 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 with b, d <= 20 whose least period is below lcm(b, d*), the breaches of the halving rule, and three worked points.
  • sharing_law: the criterion lcm(m, n)(m - n) delta in Z against 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 at lcm(b, d*) itself, and the numerator-dependence witness at delta = 1/4.
  • origin_law: the origin's brightness against floor(N/d*) over every reduced drift with d <= 60, the first thirty d*, the identity d* = d/A000188(d) to d = 1000, and the Dirichlet series of 1/d* against its zeta ratio.
  • gauss_sums: the phase census of the quadratic lean at prime d, its Legendre form, the exact Legendre twist of the Gauss sum, the numeric S(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 to N = 120.
  • irrational_lean: the closest pair gap and the star discrepancy of {n^2 delta} at N = 1000, 10000 against 1/sqrt N.

WHAT IT FINDS

  • The linear lean is the plain stack translated, exactly. theta_n = n delta makes n x - n delta in Z the same condition as n (x - delta) in Z, so the lit set is F_Q + delta and the brightness at delta + a/b is floor(N/b). At N = 30, delta = 2/7: 278 nodes tested, 0 brightness mismatches, 0 nonzero readings off the translate; at delta = sqrt 2 - 1 and phi - 1, 0 mismatches at 1e-12, and the closest a rational point comes to a coincidence is 0.000036 and 0.000041, so no rational point is lit at all (linear_lean).
  • The quadratic lean is a congruence. theta_n = n^2 delta with delta = c/d reduced puts layer n through x = a/b reduced exactly when n (a d - b c n) = 0 mod b d, since n 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 in N.
  • The class structure is closed. Write beta = v_p(b), delta_p = v_p(d), and d* for the least k with d | k^2, that is d* = prod p^ceil(v_p(d)/2). The lit layers form a union of residue classes modulo P = lcm(b, d*): the single class n = 0 at every prime with delta_p < beta or delta_p >= 2 beta, and the two classes n = 0 and n = p^(delta_p - beta) u with u = a d' (c b')^-1 mod p^(2 beta - delta_p) at every prime with beta <= delta_p < 2 beta. So lcm(b, d*) is a period and the union has 2^w classes modulo it, w the number of primes in that middle band. Checked against the literal solution set n (a d - b c n) mod b d, not against itself: at N = 60 over the 46 reduced a/b with b <= 12 and the seven drifts 1/2, 1/3, 1/4, 2/5, 1/6, 3/8, 5/9, 0 brightness mismatches and 0 solution-set mismatches (quadratic_lean).
  • lcm(b, d*) is a period and not always the least one, and the exception is 2-adic. The least period is lcm(b, d*)/2 exactly when v_2(b) >= 1 and v_2(d) = 2 v_2(b) - 1, and lcm(b, d*) otherwise: in that case the middle-band class at 2 is 2^(beta-1) times a unit, so the two classes are a subgroup and collapse to one. Over all 16384 reduced tuples with b, d <= 20 the least period falls below lcm(b, d*) at 417 of them with 0 breaches of the rule (minimal_period_law). The headline point is one of them: x = 1/2 at delta = 1/2 has classes 0, 1 mod 2, which is all of Z, least period 1; x = 1/6 at delta = 1/2 has classes 0, 3 mod 6, least period 3; x = 1/4 at delta = 3/8 has classes 0, 2 mod 4, least period 2. 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 is floor(N/P) at s = 0 and floor((N - s)/P) + 1 at 0 < s <= N. On the widest domain run here, all 128 reduced a/b with b <= 20 against all 80 reduced drifts with d <= 16, 10240 pairs at N = 60, the closed form and literal stacking disagree 0 times (adversarial).
  • The lean moves the bright nodes off the origin at five of the seven drifts printed. At delta = 1/2 the top brightness at N = 60 is 60 at x = 1/2, every layer lighting it, against 30 at the origin; at delta = 1/3 it is 40 at 1/3 and 2/3 against 20; at delta = 2/5 it is 24 at the four fifths against 12; at delta = 1/6 it is 40 at 1/6 and 5/6 against 10; at delta = 3/8 it is 30 at 1/4 and 3/4 against 15. At delta = 1/4 and 5/9 the origin ties for top, 30 at 0, 1/2, 1/4, 3/4 and 20 at 0, 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/b is lit by some layer n <= N exactly when the least positive solution class is at most N, and that class carries a through the unit u above. Witness at delta = 1/4: x = 1/4 has classes 0, 1 mod 4, first lit at n = 1, B_61 = 31; x = 3/4 has classes 0, 3 mod 4, first lit at n = 3, B_61 = 30. Over b <= 12 and d in 2, 4, 8, 9 there are 48 reduced pairs whose first lit layer moves when the numerator does (lit_set). Every first-lit prediction matches the literal search, 0 mismatches at all seven drifts, where between 33 and 40 of the 46 points are first lit at lcm(b, d*) itself.
  • The origin's brightness is floor(N/d*). At x = 0 the condition is d | c n^2, that is d* | n, so the origin reads the plain stack at scale d* instead of 1. Over every reduced drift with d <= 60 at N = 60: 0 mismatches. The first thirty d* are 1, 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 by n, multiplicative with a(p^e) = p^ceil(e/2); the identity d* = d/A000188(d) holds to d = 1000 with 0 breaches (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); summing 1/(d* d^s) here gives 1.826509, 1.826861, 1.826902 at cuts 10^4, 10^5, 10^6 against zeta(3) zeta(2)/zeta(4) = 1.826907 at s = 1, and 1.225197 at all three cuts against zeta(5) zeta(3)/zeta(6) = 1.225197 at s = 2 (origin_law).
  • The layer phases of a prime drift are a Legendre symbol. At delta = c/p the phase n^2 c/p takes only (p+1)/2 values, and the multiplicity of j/p is 1 + (j c^-1 / p) at j != 0 and 1 at j = 0. Checked at p = 5, 7, 11, 13 with c a residue and a non-residue: 3, 4, 6, 7 distinct phases and 0 census 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] at p = 7, c = 3, and the two sums agree only through sum_j e(j/p) = 0. 0 centred breaches at all eight cases, and numerically S(c, p) equals (c/p) eps_p sqrt p with eps_p = 1 at p = 1 mod 4 and i at p = 3 mod 4, reading 2.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) with Q(n) = b c n^2 - a d n and m = b d, the inner sum a quadratic Gauss sum with a linear term. Evaluated numerically it returns 1, 1, 8, 24, 16 at (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 times m/P in every case (gauss_sums).
  • Layers m != n share a lit point exactly when lcm(m, n)(m - n) delta is an integer. Solving x = (j + m^2 delta)/m and substituting, the difference of two lit points is (j n - k m)/(m n) + delta (m - n), and j n - k m runs over gcd(m, n) Z, so a coincidence asks delta (m - n) to lie in (1/lcm(m, n)) Z. Checked against literal intersection of the two layers' lit sets over m < n <= 12 against every reduced drift with d <= 16, 5280 pairs, 1474 sharing, 0 criterion failures; the weaker conditions fail, n (m - n) delta being rational at every one of the 3806 non-sharing pairs and m n (m - n) delta being an integer at 64 of 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) delta is then never an integer at m != n, so brightness is at most 1 everywhere and at every N. Numerically the 325 lit points of layers 1..25 are 325 distinct points at both delta = sqrt 2 - 1 and phi - 1, and the closest any two layers come over all pairs to N = 120 is 9.202e-09 at (72, 77) and 7.488e-09 at (56, 92) (adversarial, irrational_lean).
  • The near-coincidences follow Weyl. {n^2 delta} is equidistributed for irrational delta (Weyl 1916), and the star discrepancy reads 0.019450 and 0.006421 at N = 1000, 10000 for sqrt 2 - 1 and 0.022253 and 0.009391 for phi - 1, against 1/sqrt N = 0.031623 and 0.010000, ratios 0.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 the x and y line stacks, N = 30, 500 pixels a side, delta = 1/5 on the left and delta = sqrt 2 - 1 on the right, 45240 bytes (panel_grey, render).
  • Grey is monotone in the rank of the brightness among the distinct values present, the faintest lit value at grey 190 and the peak at black, so a picture shows which nodes are bright and reads no exact value. Panel peaks are 144 and 16.
  • The left panel keeps a 5 x 5 blank cross grid, the lines at multiples of 1/5 that 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.md WHERE 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 over 2^w classes modulo the period lcm(b, d*).
  • stack.md STACKING THE STACKS: the lean is not a weight on the scales, so it leaves the Dirichlet group; the origin density 1/d* is nonetheless a coefficient of zeta(2s+1) zeta(s+1)/zeta(2s+2).
  • stack.md SPINNING THE STACK: the dead-spin theorem kills coincidences by rotation; the irrational quadratic lean kills them by translation, and needs no Niven.