research/lab/py/parity-fill
0 directories and 2 files in research/lab/py/parity-fill.
parity-fill
- Computes the inked fraction of the unit square under the parity blend of the odd carpet stack: the XOR of the layers
C_n(u, v) = chi_n(u) chi_n(v),n = 1, 3, ..., N, withchi_n(u) = 1ifffloor(n u)is odd. - The parity blend is the sum of the layers folded to its parity,
mrlynum::spin::Blend::Parity, which on0/1layers is exactly their XOR. - Layer
n = 1is blank on[0, 1)^2, so the XOR is carried by the scales3, 5, ..., Nalone and the expansion runs over subsets of those. - The exact route is the subset expansion. With
s_n = 1 - 2 C_nin{+1, -1},prod_n s_n = (-1)^(sum_n C_n) = 1 - 2 XOR, sofill = (1 - E[prod_n s_n])/2; expandingprod_n (1 - 2 C_n) = sum_S (-2)^|S| prod_(n in S) C_nand splittingprod_(n in S) C_n(u, v) = [prod_(n in S) chi_n(u)][prod_(n in S) chi_n(v)]factorises each mean, soE[prod_(n in S) C_n] = m_S^2withm_Sthe measure of the set ofuin[0, 1)where everyfloor(n u),n in S, is odd. Hencefill(N) = (1 - sum_S (-2)^|S| m_S^2)/2. m_Sis exact and rational: everychi_n,n in S, is constant on each cell of the grid of side1/lcm(S), som_Sis a cell count overlcm(S). All2^Lmasses,Lthe number of layers, come from one pass over the grid oflcm(3, 5, ..., 21) = 14549535, which records the scale set of each cell and then sums over supersets (mass_table).- The independent comparison gives layer
nthe meanp_n = ((n-1)/(2n))^2and pretends the layers are independent Bernoulli, which would make the XOR fill(1 - prod_n (1 - 2 p_n))/2(fill_independent).
RUN
uv run python research/lab/py/parity-fill/parity_fill.py- From the repo root. One core, about three seconds, numpy and
fractionsonly. - Domain is the exact fill at
N = 3, 5, ..., 21, the literal 2D cross-check atN <= 9, a4096 x 4096raster check at everyN, the spun readings atN = 55on rastersR = 256, 512, 1024, 2048, and the whole-degree increment sweep0..90atR = 512.
WHAT IT PRINTS
section_exactprintsfill(N)as an exact fraction and a decimal for eachN, beside the4096 x 4096raster mean and the gap, and beside the literal 2D XOR count atN <= 9.fill_exactsums the2^Lsubset terms in integers over the common denominatorlcm^2, so no rounding enters;fill_literalXORs the actual layer products on thelcm x lcmcell grid and counts inked cells, sharing no line with the expansion.section_independentprints the exact fill, the independent-Bernoulli fill, their difference, the two deviations from1/2and their ratio, then the successive ratios of each deviation.section_spunprints the disc fill atN = 55for eight schedules, the resolution table for three of them, and fill against layer count with the exact and square-raster columns beside the disc readings.section_sweepprints the disc fill of the fixed-increment stack at every whole increment from0to90, its extremes, the eyes, and two symmetry checks.
WHAT IT FINDS
- The expansion is exact and the literal count confirms it:
fill(N)reads1/9,53/225,3524/11025,36284/99225,19619/51975,117419647/289864575,109067744/289864575,17006699344/45107387325,6812188030619/19244451701475and1114185811873/2749207385925atN = 3, 5, ..., 21, matching the literal 2D XOR count at all fourN <= 9with zero mismatches and the4096 x 4096raster mean at everyNwithin2.42e-04(fill_exact,fill_literal,raster_row). - The fill is not monotone in
N: it climbs to0.405084502atN = 13, falls to0.376271381atN = 15, falls again to0.353981924atN = 19, and returns to0.405275287atN = 21(section_exact). - Most subsets contribute nothing:
587of the1024subsets of{3, 5, ..., 21}havem_S = 0, the smallest being{3, 5, 7}, sincefloor(3u),floor(5u)andfloor(7u)are never all odd at the sameu(mass_table). - That zero is the whole mechanism. At two coprime scales the layers are independent and the exact and independent fills agree to the digit,
1/9atN = 3and53/225atN = 5; the triple{3, 5, 7}has joint mass0against the independent2/35, so the two fills part company atN = 7and the exact fill is below the independent one at everyNfrom7to21, by-1.31e-02up to-1.40e-01(section_independent). - The independent approximation decays as advertised and the exact quantity does not. The independent deviation
1/2 - fillhas successive ratios0.680000, 0.632653, ..., 0.546485falling toward1/2, while the exact deviation's ratios run0.680000, 0.682044, 0.744755, 0.912184, 0.774630, 1.303566, 0.993894, 1.187399, 0.648719and rise above1twice; the ratio of the two deviations grows from1.000000to29.337331overL = 2toL = 11(section_independent). - On the square the raster fill of the unspun stack still climbs toward
1/2:0.320427, 0.375175, 0.424397, 0.444069atL = 4, 8, 14, 28atR = 1024, the first two against the exact0.319637188and0.376271381, the raster reading high by7.9e-04and low by1.1e-03(section_spun). - Spinning pushes the fill to
1/2. On the disc atN = 55andR = 1024the fill reads0.472574unspun,0.490510at one degree per layer index,0.505291prime degrees,0.503331golden, and0.500821, 0.491967, 0.500658, 0.502868at the eyes90/j,j = 2, 3, 4, 5; the unspun stack is the outlier at2.74e-02from1/2and no spun schedule exceeds9.49e-03(section_spun). - The raster reading is good to about
3e-03: the same schedule overR = 256, 512, 1024, 2048reads0.478511, 0.475647, 0.472574, 0.473205unspun,0.485506, 0.492253, 0.490510, 0.489691at one degree, and0.492967, 0.494657, 0.491967, 0.492404at the eye90/3. The unspun offset survives that band by a factor of nine; the individual spun readings mostly do not (section_spun). - The eyes do not stand out. Over the whole-degree sweep at
R = 512the89nonzero increments span0.490165to0.511161, the eyes at18,30and45reading0.500185,0.494657and0.500282, inside that band and not at either end; the extremes are0and90at0.475647on one side and23and67at0.511161on the other (section_sweep). - Two symmetries close the sweep. Every layer is invariant under the quarter turn about the centre, since
chi_n(1 - u) = chi_n(u)at oddnandC_nis symmetric in its two coordinates, so increment90reproduces the unspun stack exactly and incrementsdand90 - dare mirror images: the sweep readsfill(90) = fill(0) = 0.475647and matches45of the46mirror pairs to the bit, the one exception differing by9.71e-06infloat32(section_sweep).
WITNESSES
stack.mdTHE SPUN PICTURE: the same field this study folds by parity is the one that study averages, scalesn = 1, 3, ..., 55,28layers, disc-masked raster; the mean-blend paper coverage0.7682there and the parity fill here are two blends of one stack.stack.mdSELECTING THE SCALES: the moire correlation law's coprime independence is what makes the exact and independent fills agree atN = 3andN = 5, and the joint massm_{3,5,7} = 0is what makes them disagree atN = 7.mrlynum::spin::Blend::Parity: the blend this study measures, the sum of the copies folded to its parity.
- parity_fill.py8.7 kB
- README.md7.3 kB