// Exact conversion prices for the twin tile's local factor, at z = 13..41. // // OBJECT. T = T_z = {r mod P : r != 0 and r != -2 (mod q) for every prime q <= z}, // P = prod_{q <= z} q, and the probability measure mu = (1/P) sum_{r in T} delta_r. // Its Fourier transform factorises: mu^(v) = prod_{q <= z} g_q(v_q), with // g_q(0) = (q-2)/q // |g_q(v)| = 2|cos(pi v / q)| / q (v != 0 mod q) // (the two-class local factor: the surviving classes are all classes but {0,-2}). // // TWO CONVERSION PRICES. For a vector indexed by the frequency set Z/PZ, // one-point price P1 = ||G||_1 / ||G||_2 with G = (mu^(v))_v // two-point price P2 = ||G2||_1 / ||G2||_2 with G2 = (|mu^(v)|^2)_v // The record's C^{pi(z)} loss is P1: each prime multiplies it by rho_q. // // EXACT VS SERIES. ||G||_2, ||G2||_1 and ||G2||_2 are exact rationals: // ||g_q||_2^2 = (q-2)/q ; ||g_q||_4^4 = ((q-2)^4 + 6q - 16)/q^4 ; // sum_v |g_q(v)|^2 = (q-2)/q. (All three fail at q = 2, handled separately.) // Only ||g_q||_1 needs a transcendental: sum_{v=1}^{q-1} |cos(pi v/q)| = csc(pi/2q) - 1 // for odd q (at q = 3, 5 this is 1 and sqrt 5), and csc is taken by its Taylor series // at x = pi/(2q) <= pi/26 (five terms, ~1e-22). q = 2 is the one-class factor // g_2 = (1/2, 1/2), entered explicitly. // All arithmetic is BigInt fixed point at scale 1e-40; no floating point enters any // printed ratio, so stdout is platform independent. 'use strict'; const SCALE = 10n ** 40n; const PI = 31415926535897932384626433832795028841972n; // 3.1415926535897932384626433832795028841972 const SCALE_DIGITS = 40; const mul = (a, b) => (a * b) / SCALE; const div = (a, b) => (a * SCALE) / b; const rat = (n, d) => (BigInt(n) * SCALE) / BigInt(d); function sqrtF(x) { if (x <= 0n) return 0n; let y = x > SCALE ? x : SCALE; for (let i = 0; i < 300; i++) { const next = (y + (x * SCALE) / y) / 2n; if (next === y) break; y = next; } return y; } // sin(x) = x - x^3/6 + x^5/120 - x^7/5040 + x^9/362880 function sinF(x) { const x2 = mul(x, x); const terms = [[1n, 1n], [-1n, 6n], [1n, 120n], [-1n, 5040n], [1n, 362880n]]; let out = 0n, xp = x; for (const [n, d] of terms) { out += mul(rat(n, d), xp); xp = mul(xp, x2); } return out; } // csc(x) = 1/sin(x) function cscF(x) { return div(SCALE, sinF(x)); } function fmt(x, dp = 12) { const neg = x < 0n; const a = neg ? -x : x; const ip = a / SCALE; const fp = (a % SCALE).toString().padStart(SCALE_DIGITS, '0').slice(0, dp); return (neg ? '-' : '') + ip.toString() + '.' + fp; } const toNum = (x, dp = 12) => Number(fmt(x, dp)); const PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]; const LEVELS = [13, 17, 19, 23, 29, 31, 37, 41]; const per = {}; for (const p of PRIMES) { if (p === 2) { // one class survives mod 2: g_2 = (1/2, 1/2). sum|g|^2 = 1/2, sum|g|^4 = 1/8. const l1 = SCALE; // 1/2 + 1/2 const l2 = sqrtF(rat(1, 2)); const l2sq = l2; per[p] = { l1, l2, rho1: div(l1, l2), rho2: div(rat(1, 2), l2sq) }; continue; } // x = pi/(2p) in fixed point: pi/2 divided by p, with p read as a fixed-point number. const x = div(mul(PI, rat(1, 2)), BigInt(p) * SCALE); const l1 = rat(p - 4, p) + mul(rat(2, p), cscF(x)); const l2 = sqrtF(rat(p - 2, p)); const rho1 = div(l1, l2); const t1 = rat(p - 2, p); const num4 = BigInt(p - 2) ** 4n + BigInt(6 * p - 16); const l2sq = sqrtF((num4 * SCALE) / BigInt(p) ** 4n); const rho2 = div(t1, l2sq); per[p] = { l1, l2, rho1, rho2, l2sq, t1 }; } console.log('tile conversion prices -- twin two-class tile, BigInt fixed point, scale 1e-40'); console.log(''); console.log('z pi(z) rho_z(1-point) P1=prod rho_q lgP1/pi(z) P2=prod rho2_q lgP2/pi(z)'); let P1 = SCALE, P2 = SCALE, k = 0; for (const z of LEVELS) { const ps = PRIMES.filter((p) => p <= z); while (k < ps.length) { P1 = mul(P1, per[ps[k]].rho1); P2 = mul(P2, per[ps[k]].rho2); k++; } const n1 = Math.log10(toNum(P1)) / ps.length; const n2 = Math.log10(toNum(P2)) / ps.length; console.log( String(z).padEnd(4) + String(ps.length).padEnd(7) + fmt(per[ps[ps.length - 1]].rho1, 10).padEnd(16) + fmt(P1, 10).padEnd(20) + n1.toFixed(6).padEnd(12) + fmt(P2, 10).padEnd(21) + n2.toFixed(6) ); } console.log(''); console.log('per-prime ratios:'); for (const p of PRIMES) { console.log(' q=' + String(p).padStart(2) + ' rho1(1-point)=' + fmt(per[p].rho1, 10) + ' rho2(2-point)=' + fmt(per[p].rho2, 10)); } console.log(''); console.log('closed forms: ||g_q||_1 = (q-4)/q + (2/q)*csc(pi/2q) [series, 5 terms]; q=2 entered as (1, 1/2);'); console.log(' ||g_q||_2 = sqrt((q-2)/q) [exact]; ||g_q||_4^4 = ((q-2)^4+6q-16)/q^4 [exact].'); console.log('asymptotics: rho1 -> 1 + 4/pi = 2.27323954, so P1 ~ (1+4/pi)^pi(z);'); console.log(' rho2 -> 1 + 2/q, so P2 ~ C (log z)^2 (no C^pi(z) factor).');