README.md
4.4 kB · markdown
sumset-density
- Computes the sumset
S = A + Bof the base-3 designA = {0, 1}and the base-4 designB = {0, 1}, the object of Erdos problem 125, exactly as a bit array up to3^K, and reads its densityD(x) = card(S meet [1, x])/x. - The bit array holds one bit per integer in
[0, 3^K]; the members ofAare set directly, and each power4^j <= 3^Kis folded in by one shift-or pass,S |= S << 4^j, sofloor(K log_4 3) + 1passes over the array build the whole sumset,14atK = 17and18atK = 22. The other order,Bdirect and the powers of3shifted, is the control. - The scan reads
card(S meet [1, x])atx = 3^k,4^m,floor(3^k/2),floor(4^m/3)and at the centresd = (3^k - 1)/2 + (4^m - 1)/3, and the maximum and minimum ofD(x)over each window[3^k, 3^(k+1)), each window[2^j, 2^(j+1))and over all of[1, 3^K], each with its location. Maxima and minima are compared exactly by cross multiplication; a density prints truncated to six places; an exponentlog(card)/log(x)prints truncated. - The energy verb computes the additive energy
E(k, m) = card{(a, b, a', b') in A_k^2 x B_m^2 : a + b = a' + b'}exactly, assum over t of 2^(z_3(t) + z_4(t))withtranging over the3^mintegers with base-4 digits in{-1, 0, 1},z_4(t)the number of zero digits there andz_3(t)the number of zero digits in the balanced ternary expansion oftonkdigits, or nothing whenabs(t) > (3^k - 1)/2; a test checks it against the histogram of the representation function at three pairs. It prints, per pair(k, m)with4^mwithin a factor3of3^k, the fillcard(S meet [0, d])/(d + 1), the energy, the flat energy4^(k+m)/(d + 1), their ratioQrounded up, and the Cauchy-Schwarz bound1/Qtruncated down.
VERBS
density KbuildsSto3^Kand prints the readings above. Runtime0.09s atK = 17,1.3s atK = 20,13s atK = 22on a4GB bit array;K = 23wants12GB.energy KbuildsSto3^Kand prints the energy table for every pair withd <= 3^K. Runtime0.3s atK = 17,39s atK = 22.controlcompares the shift-or array against a double loop overA x Bat3^13, the two shift orders against each other at3^17, the first58non-members against the terms of A367090, and tests the reflectionx -> d - xonS meet [0, d]at every centre below3^17. Runtime0.08s.
RUN
CARGO_BUILD_JOBS=4 cargo run --release -p sumset-density -- density 17
CARGO_BUILD_JOBS=4 cargo run --release -p sumset-density -- density 22
CARGO_BUILD_JOBS=4 cargo run --release -p sumset-density -- energy 22
CARGO_BUILD_JOBS=4 cargo run --release -p sumset-density -- control
CARGO_BUILD_JOBS=4 cargo test --release -p sumset-density,8tests, under0.1s after the build.
READS
card(S meet [1, 3^22]) = 26666749554,D(3^22) = 0.849772.D(3^k)atk = 4..22:0.975308, 0.835390, 0.858710, 0.887517, 0.908855, 0.864959, 0.778472, 0.837186, 0.858264, 0.874244, 0.814704, 0.763392, 0.831183, 0.858962, 0.881342, 0.792352, 0.767893, 0.831191, 0.849772.D(4^m)atm = 3..17:0.968750, 0.843750, 0.860351, 0.897460, 0.859313, 0.791305, 0.837238, 0.868845, 0.806823, 0.783585, 0.838184, 0.875988, 0.785523, 0.793552, 0.845272.- Maximum of
Dover[3^k, 3^(k+1))atk = 5..21:0.913419, 0.903768, 0.912038, 0.931596, 0.913781, 0.875566, 0.875469, 0.881621, 0.908274, 0.885045, 0.865671, 0.882855, 0.886340, 0.910650, 0.874408, 0.865858, 0.872186; minimum:0.835390, 0.852729, 0.887517, 0.858945, 0.778468, 0.778472, 0.822506, 0.858264, 0.806430, 0.763391, 0.763392, 0.815887, 0.858962, 0.785230, 0.767893, 0.767875, 0.818358. - Minimum of
Dover[1, 3^22]:0.763391atx = 3^15 - 1; the maximum is1atx <= 61. - The reflection
x -> d - xfixesS meet [0, d]at every clean centre and at no mixed centre withd >= 449. Q(k, m)over the27pairs with6 <= k <= 22lies in[1.467705, 2.060586], the maximum at(16, 12); the Cauchy-Schwarz bound1/Qis at least0.485298on every one of them, against fills between0.834213and0.928391. Fitted as3^(eta k)on two endpoints,Qgrows ateta = 0.015852fromk = 6tok = 22and ateta = 0.001987fromk = 11tok = 22, both rounded up.
WITNESSES
cobham.mdsection "Object S: the base-3 design plus the base-4 design", every number there.