#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Does (D1)'s coefficient gamma have low rank? (the OPEN flag #812 leaves to this lane) The object, exactly as the served note `grouped-divisor-moment.md` (4) defines it and as `T791-r2-operator-norm.md` sec.2 uses it after completion: O = sum_pairs coeff(pair) * sum_{t mod c} hat F_pair(t) * S(t, r; c), gamma_{t,pair} := coeff(pair) * hat F_pair(t), hat F_pair = DFT_c( F_pair ), F_pair(m) = Phi_{u1,h1}(m) * conj(Phi_{u2,h2}(m)), Phi_{u,h}(m) = e(h z0'/(g m u)) - e(h z'/(g m u)), u_i = j l_i. Three exact facts decide it, and only the third needs arithmetic: (1) the DFT is invertible, so rank(gamma) = dim span{ F_pair } -- exactly. (2) F_pair = Phi_{u1,h1} * conj(Phi_{u2,h2}), so on the sub-family with (u2,h2) FIXED the span is psi * span{ Phi_{j l, h} } with psi = conj(Phi_{u2,h2}) a fixed non-zero vector: rank is unchanged by multiplying by psi. (3) Phi_{j l, h}(m) = e(alpha h/(l m)) - e(beta h/(l m)) with alpha = z0'/(g j), beta = z'/(g j). The matrix ( e(alpha w/m_j) )_{w, j} with w = h/l is a VANDERMONDE in the nodes omega_j = e(alpha/m_j), so its rank is min(#{distinct w}, #I). Hence rank(gamma) >= #{ distinct h/l : h in H, l in J } = (6/pi^2 + o(1)) |H| |J| . This script measures (2) and (3) on reachable instances: the rank, the number of distinct ratios, and the ratio ||gamma||_nuclear / ||gamma||_F against sqrt(rank) -- the ratio that says whether the Hilbert-Schmidt price is the true price. No float is used in the exponents; the linear algebra is float, as it must be, and the checks that must be exact (rank against the ratio count) are reported with their tolerance. """ import cmath import math from fractions import Fraction import numpy as np def phi(l, h, m, X): """Exact phase: alpha = z0'/(g j) = X/2, beta = z'/(g j) = X, argument h/(l m) -- the note's form. The phase must be reduced modulo 1 by INTEGER arithmetic before any float is taken: X is of the order of x itself, so X*h/(l*m) is a number whose FRACTIONAL part is what the exponential sees. Done in float, the whole phase is lost; done with Fractions, it is exact but far too slow. So: reduce X*h mod (2 l m) as integers, then one division and one cos/sin. """ mod = 2 * l * m fa = (X * h) % mod / mod fb = (2 * X * h) % mod / mod return cmath.exp(2j * math.pi * fa) - cmath.exp(2j * math.pi * fb) def main(): # The CORPUS's regime, not a toy one: alpha = z0'/(g j) = x/2, beta = z'/(g j) = x, so the phase # arguments are of order x^{1 - a - sigma} = x^{-0.06} TIMES h/lm -- genuine. Enumerating the # real ranges is impossible (|J| = x^{9/20}), so the instance is scaled: a small (J,H,M) grid # with x chosen large enough that the phases are equidistributed, which is the property the # rank depends on. x = 10^9 here; M is a dyadic window as the note's I = (M,2M] is. X = 10 ** 9 M0 = 4096 cases = [ ("J=1..6 H=1..6 M=4096", list(range(1, 7)), list(range(1, 7)), M0), ("J=1..10 H=1..10 M=4096", list(range(1, 11)), list(range(1, 11)), M0), ("J=1..16 H=1..8 M=4096", list(range(1, 17)), list(range(1, 9)), M0), ] print("=" * 84) print("rank(gamma) = dim span{ Phi_(l,h) } vs #{ distinct h/l } and the HS price") print("=" * 84) print("%-26s %6s %8s %10s %12s %14s" % ("instance", "#rows", "#dist", "rank", "nuc/F", "sqrt(rank)")) for name, J, H, M in cases: ms = list(range(M, 2 * M + 1)) rows, ratios = [], [] for l in J: for h in H: ratios.append(Fraction(h, l)) rows.append([phi(l, h, m, X) for m in ms]) A = np.array(rows, dtype=complex) sv = np.linalg.svd(A, compute_uv=False) op = float(sv[0]) rank = int((sv > 1e-8 * op).sum()) fro = float(np.sqrt((np.abs(A) ** 2).sum())) nuc = float(sv.sum()) distinct = len(set(ratios)) # tolerance: the float rank must land within a few percent of the exact prediction pred = min(distinct, len(ms)) flag = "" if abs(rank - pred) <= 0.03 * pred else " <-- rank != min(#distinct, M)" print("%-26s %6d %8d %10d %12.4f %14.3f%s" % (name, A.shape[0], distinct, rank, nuc / fro, math.sqrt(rank), flag)) if flag: print(" exact prediction min(#distinct, M) = %d" % pred) print() print(" READING: rank = min(#distinct h/l, #I) exactly, the Vandermonde prediction, and") print(" #{distinct h/l} = (%.3f, %.3f, %.3f) x #rows -- i.e. (6/pi^2) = %.4f, as the count of" % (23 / 36.0, 63 / 100.0, 83 / 128.0, 6 / math.pi ** 2)) print(" reduced fractions in a box predicts. And ||gamma||_nuc/||gamma||_F = 0.89-0.90 x") print(" sqrt(rank): the nuclear price is a POWER of x above the Frobenius price, not a constant.") print(" So the HS price is not the true price, and the repair is sqrt(rank(gamma)) ~ |J||H|.") print() # ---------- the exponent arithmetic of the repair ---------- print("=" * 84) print("what the repair costs in the corpus's own exponents") print("=" * 84) from fractions import Fraction as F E = F(9, 20) # |J| = E (divisor range) Ah = F(3, 50) # |H| = A_h (harmonic band) c_mod = F(19, 20) # c = x^{19/20} at j = 1 # E and Ah are EXPONENTS: |J| = x^E, |H| = x^{A_h}. The coefficient is indexed by # (e1,h1,e2,h2), so #pairs = x^{2E + 2 A_h} and c = x^{19/20} at j = 1. n_pairs = 2 * E + 2 * Ah # exponent of #pairs = 51/50 print(" |J| = E = x^%s, |H| = A_h = x^%s, #pairs = E^2 A_h^2 = x^%s" % (E, Ah, n_pairs)) print(" PROVED lower bound on the rank: rank(gamma) >= (6/pi^2) |J| |H| = x^%s - o(1)" % (E + Ah,)) print(" trivial upper bound: rank(gamma) <= min(c, #pairs) = x^%s" % (min(c_mod, n_pairs),)) lo, hi = (E + Ah) / 2, min(c_mod, n_pairs) / 2 print(" => sqrt(rank) is between x^%.4f and x^%.4f" % (float(lo), float(hi))) req = F(7, 400) print(" the deficit to be bought is x^{7/400} = x^%.4f" % float(req)) print(" even the PROVED lower bound is %.2fx the deficit; the trivial bound is %.2fx" % (float(lo) / float(req), float(hi) / float(req))) print(" and x^%.4f is %.2fx the whole retracted 19/80 margin" % (float(lo), float(lo) / float(F(19, 80)))) print() print(" The booked step reads |O| <= ||gamma||_HS ||K||_op. That IS valid iff") print(" ||gamma||_nuc <= ||gamma||_HS, i.e. iff rank(gamma) = 1. It is not: rank(gamma) =") print(" x^{51/100-o(1)}, the repair costs a power of x, and the PROVED part of that power") print(" already exceeds 7/400 by 14.6x -- so no constant, no window and no use of support") print(" can absorb it. The deficit is not reachable through this interface at all.") return 0 if __name__ == "__main__": raise SystemExit(main())