#!/usr/bin/env python3 # -*- coding: utf-8 -*- """The pair moment, and whether it fits inside the 19/80 margin. All exponents are exact fractions of log_x. Conventions, taken from the corpus's own definitions (structured-dispersion-estimate.md lines 66-90 and grouped-divisor-moment.md): a = 14/25 (M = x^a) b = 1/2 (N = x^b) sigma = 1/20 (q ~ Q = x^sigma) E = b - sigma = 9/20 A_h = a + b - 1 = 3/50 (harmonic band) c = sigma + 2E - mu = 19/20 - mu (mu = log_x j) |beta(e)| <= 1 on J, |J| = E |c_h| <= C/A_h on H, |H| = A_h #pairs = E^2 * A_h^2 (ordered pairs of (e,h), q fixed) """ from fractions import Fraction as F a, b, sigma = F(14, 25), F(1, 2), F(1, 20) E = b - sigma Ah = a + b - 1 M = a # M = x^a (summed index) mu = F(0) # j = 1, the class the reopening condition names c = sigma + 2 * E - mu # c = q E^2 / j cm = c + M # c*M, the Parseval norm squared per pair print("== exponents ==") for name, v in [("E", E), ("A_h", Ah), ("c", c), ("M", M), ("c*M", cm)]: print(" %-6s = %-8s = %.6f" % (name, v, float(v))) # ---- the two pair bookkeepings ------------------------------------------------- l2_coeff = E + (-Ah) # ||coeff||_2^2 = E^2 * (C^2/A_h)^2 -> exponent 2E - 2A_h... see below l2_coeff = 2 * E - 2 * Ah # log_x of sum_pairs |coeff|^2 l1_coeff = 2 * E # log_x of sum_pairs |coeff| (|c_h| <= C/A_h and |H| = A_h) n_pairs = 2 * E + 2 * Ah print("\n== the pair moment ==") print(" sum_pairs |coeff|^2 <= C^4 x^{%s} = x^{%.6f}" % (l2_coeff, float(l2_coeff))) print(" ||coeff||_2 = x^{%s} = x^{%.6f}" % (l2_coeff / 2, float(l2_coeff / 2))) print(" sum_pairs |coeff| <= C^2 x^{%s} = x^{%.6f}" % (l1_coeff, float(l1_coeff))) print(" #pairs = x^{%s} = x^{%.6f}" % (n_pairs, float(n_pairs))) print(" l1/l2 ratio = x^{%s} = x^{%.6f} (sqrt(#pairs) = x^{%s}, equal: %s)" % (l1_coeff - l2_coeff / 2, float(l1_coeff - l2_coeff / 2), n_pairs / 2, l1_coeff - l2_coeff / 2 == n_pairs / 2)) req = F(7, 400) margin = F(19, 80) gain = l1_coeff - l2_coeff / 2 print("\n== does it eat the margin? ==") print(" requirement 7/400 = %.6f" % float(req)) print(" 19/80 = %.6f" % float(margin)) print(" pair-side gain l1 -> l2 = %.6f = %s of the requirement, %s of 19/80" % (float(gain), float(gain / req), float(gain / margin))) print(" -> the pair moment is SLACK, not cost: it cannot eat either.") # ---- the two accountings of the whole object ----------------------------------- # corpus: |O| <= sum_pairs|coeff| * sup_t|S| * sum_t|what(t)| with |S| <= sqrt(c), l1(what) = c corpus_t = c / 2 + c # sqrt(c) * c (log 2c is x^{o(1)}) corpus = l1_coeff + corpus_t # operator: |O| <= ||gamma||_HS * ||K||_op, ||gamma||_HS^2 = mult * c*M * sum|coeff|^2 mult = E + Ah # log_x of the pairs-per-shift multiplicity = E*A_h row_norm = c # max row 2-norm = sqrt(sum_t|S|^2) = sqrt(c phi(c)) ~ c triv = (Ah + E + c + c) / 2 # log_x sqrt(K M r) with K = A_h E, M = c, r = c paper_saving = F(7, 400) # the corollary's saving over its own trivial bound (note A) paper_op = triv - paper_saving print("\n== the two accountings of the object ==") print(" corpus sum_pairs|coeff| * sqrt(c) * c = x^{%.6f}" % float(corpus)) # operator with the row norm (no corollary needed): ||gamma||_HS * max row norm op_rownorm_dup = l1_coeff + cm / 2 + row_norm print(" operator, l1 over pairs + row norm = x^{%.6f} (loss %.4f)" % (float(op_rownorm_dup), float(op_rownorm_dup - corpus))) op_rownorm_l2 = l2_coeff / 2 + cm / 2 + row_norm print(" operator, l2 over pairs + row norm = x^{%.6f} (gain %.4f)" % (float(op_rownorm_l2), float(corpus - op_rownorm_l2))) # operator with the paper's operator-norm bound, coefficients merged per shift op_paper = F(1, 2) * mult + cm / 2 + l2_coeff / 2 + paper_op print(" operator, l2 over pairs + paper ||K||_op, merged per shift = x^{%.6f} (%+.4f vs corpus)" % (float(op_paper), float(corpus - op_paper))) print(" (merge cost sqrt(#pairs per shift) = x^{%.4f}; paper op saving over trivial = x^{-%.4f})" % (float(mult / 2), float(paper_saving))) print("\n K = A_h*E = %s (log_x = %.4f); trivial ||K||_op bound sqrt(KMc) = x^{%.4f};" " row norm c = x^{%.4f}" % (Ah + E, float(Ah + E), float(triv), float(c))) need = corpus - (cm / 2 + l2_coeff / 2 + F(1, 2) * mult) print(" => the operator route needs ||K||_op <= x^{%.6f}" % float(need)) print(" (the paper's corollary gives x^{%.6f}; the trivial sqrt(KM)max|S| gives x^{%.6f};" " the row norm is x^{%.6f})" % (float(paper_op), float(triv), float(row_norm))) print(" saving demanded of the operator norm: x^{%.6f} vs the printed corollary's x^{-%.6f}" % (float(triv - need), float(paper_saving))) print(" and the merge cost of the operator index set: x^{%.6f}" % float(mult / 2))