nDot.io physics
07-ilang-weight / 05-inertia-of-mark
05inertia of markverified

Determines, for a moving body with its own mark and three couplings, whether its inertia is its cost over the square of one speed for all levels, and whether weight over inertia is level-independent.

Code of version 1

check_full_grip.py7 KB · raw
"""Check of 05-inertia-of-mark (v1): full grip, N_f = 1, exact sector contract (6.1).

Compares the curvature of the exact dressed level at P = 0 with (5.2) and (5.6),
and the ratios of items 2 and 3 ((5.7), (5.10)) with the same exact data.
Output: output/check_full_grip.txt
"""
from pathlib import Path
import numpy as np

OUT = Path(__file__).parent / "output"
OUT.mkdir(exist_ok=True)
lines = []


def log(s=""):
    lines.append(s)


t_f, g_s = 1.0, 1.0
m, Nclk, lam0 = 1.0, 2, 2.5 * np.pi              # M_k = m + 2 pi k/(N lam0): 1.0, 1.4
Ms = [m + 2 * np.pi * k / (Nclk * lam0) for k in range(Nclk)]
sx = np.array([[0, 1], [1, 0]], complex)
sz = np.diag([1.0, -1.0]).astype(complex)


def ring(L):
    Tp = np.roll(np.eye(L), 1, axis=0)            # T_+ |r> = |r+1>
    c1 = -t_f * (Tp + Tp.T)
    P0 = np.zeros((L, L)); P0[0, 0] = 1.0
    return Tp, Tp.T, c1, P0


def ground(L, g):
    _, _, c1, P0 = ring(L)
    w, V = np.linalg.eigh(c1 + g * P0)
    phi = V[:, 0] * np.sign(V[0, 0] if abs(V[0, 0]) > 1e-12 else V[1, 0])
    return w[0], phi


def sector(L, g, tau):
    """C(P) = C0 + e^{-iP} Cp + e^{iP} Cp^dag, full grip, N_f = 1, (5.1)."""
    _, Tm, c1, P0 = ring(L)
    C0 = np.kron(np.eye(2), c1) + g * np.kron(sz, P0)
    Cp = 0.5 * tau * np.kron(-1j * sx, Tm)
    return C0, Cp


def exact_curv(L, g, tau, sig):
    C0, Cp = sector(L, g, tau)
    C = C0 + Cp + Cp.conj().T
    d1 = -1j * Cp + 1j * Cp.conj().T             # dC/dP at P = 0
    d2 = -(Cp + Cp.conj().T)                       # d2C/dP2 at P = 0
    w, V = np.linalg.eigh(C)
    _, phi = ground(L, sig * g)
    ref = np.kron(np.eye(2)[:, 0 if sig > 0 else 1], phi)
    i = np.argmax(abs(V.conj().T @ ref))
    psi = V[:, i]
    a = V.conj().T @ (d1 @ psi)
    mask = np.arange(len(w)) != i
    E2 = np.real(psi.conj() @ d2 @ psi) + 2 * np.sum(abs(a[mask]) ** 2 / (w[i] - w[mask]))
    w0 = np.linalg.eigvalsh(C0)
    e0s = ground(L, sig * g)[0]
    j = np.argmin(abs(w0 - e0s))
    dist = np.min(abs(np.delete(w0, j) - e0s))     # isolation distance d_sigma
    return E2, dist


def J_tau2(L, g, sig):
    """(5.2): J = <phi_s| T_- (E0_s - h_{-s})^{-1} T_- |phi_s>, E'' = 2 tau^2 J."""
    Tp, Tm, c1, P0 = ring(L)
    e0, phi = ground(L, sig * g)
    return (Tp @ phi) @ np.linalg.solve(e0 * np.eye(L) - (c1 - sig * g * P0), Tm @ phi)


def sums(L):
    q = 2 * np.pi * np.arange(1, L) / L
    eps = 2 * t_f * (1 - np.cos(q))
    s1 = np.sum(1 / eps) / L
    s2 = np.sum(1 / eps ** 2) / L
    S2 = np.sum((1 + np.cos(q)) / eps ** 2) / L
    Lam = 2 * np.eye(L) - ring(L)[0] - ring(L)[1]
    ell = np.linalg.pinv(Lam)
    return s1, s2, S2, ell[:, 0], (ell @ ell)[:, 0]


# ---- 0. sector contract (6.1)/(5.1) against the full contract, L = 6
L, g, tau = 6, 0.3, 0.2
Tp, Tm, c1, P0 = ring(L)
A = 0.5 * tau * (np.kron(np.kron(Tp, -1j * sx), np.eye(L)))
A = A + A.conj().T
Cf = A + np.kron(np.eye(2 * L), c1)
for x in range(L):
    Px = np.zeros((L, L)); Px[x, x] = 1
    Cf = Cf + g * np.kron(np.kron(np.diag(np.eye(L)[x]), sz), Px)
full = np.sort(np.linalg.eigvalsh(Cf))
sec = []
for jP in range(L):
    C0, Cp = sector(L, g, tau)
    P = 2 * np.pi * jP / L
    sec += list(np.linalg.eigvalsh(C0 + np.exp(-1j * P) * Cp + np.exp(1j * P) * Cp.conj().T))
log("0. Sector contract vs full contract (L=6, gamma*M=0.3, tau=0.2): max |eig diff| = %.2e"
    % np.max(abs(full - np.sort(sec))))
log()

# ---- 1-3. curvature, inertia vs cost, weight over inertia
r, rp = 2, 3                                      # r = x_s - x, r' = x_s - x'
for L in (8, 13):
    n = 1.0 / L
    s1, s2, S2, ell, ell2 = sums(L)
    ell0 = ell[0]
    K = 2 * n * S2 + s1 ** 2 - s2 / L
    br = lambda f: f[r] - f[rp]
    F = -2 * g_s * br(ell) / t_f
    F2 = g_s / (n * t_f ** 2) * br(ell ** 2 - 2 * ell2 / L)
    Xi = -br(ell ** 2 + 2 * ell0 * ell - 2 * ell2 / L) / (2 * t_f * br(ell))
    eps1 = 2 * t_f * (1 - np.cos(2 * np.pi / L))
    log("L = %d, N_f = 1, n = 1/L, t_f = 1, eps_1 = %.4f, ell_0 = %.5f, K_L = %.4f, Xi = %.4f"
        % (L, eps1, ell0, K, Xi))
    for gam in (0.01, 0.02, 0.3):
        log("  gamma = %.3f   (N_f*kappa_k = gamma*M_k*L/t_f = %s)"
            % (gam, ", ".join("%.3f" % (gam * M * L / t_f) for M in Ms)))
        log("    k sig   d_sig     tau/d   |E''/(2tau^2 J)-1|  E''/(5.6)-1   "
            "tau^2 mu-Cost  pred(5.7)  -C_even   E''dW/(tau^2F)-1  pred g_sig*Xi")
        res = {}
        for k, M in enumerate(Ms):
            g = gam * M
            e00 = ground(L, 0.0)[0]
            cost = {s: ground(L, s * g)[0] - e00 for s in (1, -1)}
            ceven = 0.5 * (cost[1] + cost[-1])
            for sig in (1, -1):
                tau = 1e-5
                E2, d = exact_curv(L, g, tau, sig)
                E2b, _ = exact_curv(L, g, 0.2 * d, sig)
                J = J_tau2(L, g, sig)
                pred6 = tau ** 2 / (n * sig * g) * (1 - g ** 2 * K)
                D = tau ** 2 / E2 - cost[sig]
                phi = ground(L, sig * g)[1]
                dW = g_s * (phi[r] ** 2 - phi[rp] ** 2)
                rat3 = E2 * dW / (tau ** 2 * F) - 1
                res[(k, sig)] = (D, E2 * dW / tau ** 2, cost[sig], tau ** 2 / E2, dW)
                log("    %d %+d  %.3e  %.1e   %.1e (tau=d/5: %.1e)  %+.2e   %+.4e %+.4e %+.4e   %+.4e  %+.4e"
                    % (k, sig, d, tau / d, abs(E2 / (2 * tau ** 2 * J) - 1),
                       abs(E2b / (2 * (0.2 * d) ** 2 * J) - 1), E2 / pred6 - 1,
                       D, n * ell0 * g ** 2 / t_f, -ceven, rat3, sig * g * Xi))
        # level-difference and branch-difference forms (item 2), weight over inertia spread (item 3)
        lv = res[(1, 1)][0] - res[(0, 1)][0]
        lvp = n * ell0 * gam ** 2 * (Ms[1] ** 2 - Ms[0] ** 2) / t_f
        brd = [(res[(k, 1)][3] - res[(k, -1)][3]) - (res[(k, 1)][2] - res[(k, -1)][2]) for k in range(Nclk)]
        spread = [res[key][1] for key in res]
        cw = [abs(res[(k, s)][4] - (F * res[(k, s)][2] + F2 * res[(k, s)][2] ** 2)) for k in range(Nclk) for s in (1, -1)]
        log("    item 2: level difference of tau^2 mu - Cost (k=1 minus k=0, sig=+): %+.4e, pred %+.4e"
            % (lv, lvp))
        log("    item 2: branch differences tau^2(mu_+ - mu_-) - (Cost_+ - Cost_-), k=0,1: %+.2e, %+.2e"
            "  (vs Cost_+ - Cost_- = %.3e, %.3e)"
            % (brd[0], brd[1], res[(0, 1)][2] - res[(0, -1)][2], res[(1, 1)][2] - res[(1, -1)][2]))
        log("    item 3: E''dW/tau^2 over (k,sig): min %+.5e max %+.5e, leading F = %+.5e;"
            " max |dW - (F C + F2 C^2)| = %.1e" % (min(spread), max(spread), F, max(cw)))
        odd = [0.5 * (res[(k, 1)][1] - res[(k, -1)][1]) / F for k in range(Nclk)]
        evn = [0.5 * (res[(k, 1)][1] + res[(k, -1)][1]) / F - 1 for k in range(Nclk)]
        log("    item 3: odd part of E''dW/(tau^2 F) over sig, k=0,1: %+.5e %+.5e; pred gamma*M_k*Xi:"
            " %+.5e %+.5e; even part minus 1: %+.2e %+.2e"
            % (odd[0], odd[1], gam * Ms[0] * Xi, gam * Ms[1] * Xi, evn[0], evn[1]))
    log()

(OUT / "check_full_grip.txt").write_text("\n".join(lines) + "\n", encoding="utf-8")
print("\n".join(lines))
output/check_full_grip.txt8 KB · raw
0. Sector contract vs full contract (L=6, gamma*M=0.3, tau=0.2): max |eig diff| = 3.66e-15

L = 8, N_f = 1, n = 1/L, t_f = 1, eps_1 = 0.5858, ell_0 = 0.65625, K_L = 0.6562, Xi = -0.1667
  gamma = 0.010   (N_f*kappa_k = gamma*M_k*L/t_f = 0.080, 0.112)
    k sig   d_sig     tau/d   |E''/(2tau^2 J)-1|  E''/(5.6)-1   tau^2 mu-Cost  pred(5.7)  -C_even   E''dW/(tau^2F)-1  pred g_sig*Xi
    0 +1  2.500e-03  4.0e-03   6.2e-13 (tau=d/5: 4.5e-11)  -9.29e-08   +8.2444e-06 +8.2031e-06 +8.2033e-06   -1.7575e-03  -1.6667e-03
    0 -1  2.500e-03  4.0e-03   6.8e-14 (tau=d/5: 4.6e-11)  +9.46e-08   +8.1623e-06 +8.2031e-06 +8.2033e-06   +1.5753e-03  +1.6667e-03
    1 +1  3.500e-03  2.9e-03   3.6e-13 (tau=d/5: 1.8e-10)  -2.54e-07   +1.6192e-05 +1.6078e-05 +1.6079e-05   -2.5111e-03  -2.3333e-03
    1 -1  3.500e-03  2.9e-03   6.2e-13 (tau=d/5: 1.7e-10)  +2.61e-07   +1.5966e-05 +1.6078e-05 +1.6079e-05   +2.1540e-03  +2.3333e-03
    item 2: level difference of tau^2 mu - Cost (k=1 minus k=0, sig=+): +7.9472e-06, pred +7.8750e-06
    item 2: branch differences tau^2(mu_+ - mu_-) - (Cost_+ - Cost_-), k=0,1: +8.20e-08, +2.25e-07  (vs Cost_+ - Cost_- = 2.500e-03, 3.500e-03)
    item 3: E''dW/tau^2 over (k,sig): min -3.75808e-01 max -3.74058e-01, leading F = -3.75000e-01; max |dW - (F C + F2 C^2)| = 8.0e-09
    item 3: odd part of E''dW/(tau^2 F) over sig, k=0,1: -1.66638e-03 -2.33255e-03; pred gamma*M_k*Xi: -1.66667e-03 -2.33333e-03; even part minus 1: -9.11e-05 -1.79e-04
  gamma = 0.020   (N_f*kappa_k = gamma*M_k*L/t_f = 0.160, 0.224)
    k sig   d_sig     tau/d   |E''/(2tau^2 J)-1|  E''/(5.6)-1   tau^2 mu-Cost  pred(5.7)  -C_even   E''dW/(tau^2F)-1  pred g_sig*Xi
    0 +1  5.001e-03  2.0e-03   6.8e-14 (tau=d/5: 7.4e-10)  -7.36e-07   +3.3145e-05 +3.2812e-05 +3.2815e-05   -3.6953e-03  -3.3333e-03
    0 -1  5.001e-03  2.0e-03   4.3e-13 (tau=d/5: 7.2e-10)  +7.64e-07   +3.2488e-05 +3.2812e-05 +3.2815e-05   +2.9668e-03  +3.3333e-03
    1 +1  7.002e-03  1.4e-03   3.5e-13 (tau=d/5: 2.9e-09)  -2.01e-06   +6.5229e-05 +6.4312e-05 +6.4320e-05   -5.3744e-03  -4.6667e-03
    1 -1  7.002e-03  1.4e-03   4.5e-13 (tau=d/5: 2.8e-09)  +2.11e-06   +6.3426e-05 +6.4312e-05 +6.4320e-05   +3.9464e-03  +4.6667e-03
    item 2: level difference of tau^2 mu - Cost (k=1 minus k=0, sig=+): +3.2084e-05, pred +3.1500e-05
    item 2: branch differences tau^2(mu_+ - mu_-) - (Cost_+ - Cost_-), k=0,1: +6.57e-07, +1.80e-06  (vs Cost_+ - Cost_- = 5.001e-03, 7.002e-03)
    item 3: E''dW/tau^2 over (k,sig): min -3.76480e-01 max -3.72985e-01, leading F = -3.75000e-01; max |dW - (F C + F2 C^2)| = 6.6e-08
    item 3: odd part of E''dW/(tau^2 F) over sig, k=0,1: -3.33105e-03 -4.66041e-03; pred gamma*M_k*Xi: -3.33333e-03 -4.66667e-03; even part minus 1: -3.64e-04 -7.14e-04
  gamma = 0.300   (N_f*kappa_k = gamma*M_k*L/t_f = 2.400, 3.360)
    k sig   d_sig     tau/d   |E''/(2tau^2 J)-1|  E''/(5.6)-1   tau^2 mu-Cost  pred(5.7)  -C_even   E''dW/(tau^2F)-1  pred g_sig*Xi
    0 +1  7.721e-02  1.3e-04   2.0e-11 (tau=d/5: 4.7e-05)  -2.06e-03   +8.8141e-03 +7.3828e-03 +7.4816e-03   -1.2343e-01  -5.0000e-02
    0 -1  7.721e-02  1.3e-04   1.4e-11 (tau=d/5: 3.4e-05)  +3.58e-03   +6.3737e-03 +7.3828e-03 +7.4816e-03   -3.7490e-02  +5.0000e-02
    1 +1  1.110e-01  9.0e-05   4.3e-11 (tau=d/5: 2.1e-04)  -5.47e-03   +1.9021e-02 +1.4470e-02 +1.4838e-02   -2.0696e-01  -7.0000e-02
    1 -1  1.110e-01  9.0e-05   2.6e-11 (tau=d/5: 1.3e-04)  +1.17e-02   +1.1668e-02 +1.4470e-02 +1.4838e-02   -1.0217e-01  +7.0000e-02
    item 2: level difference of tau^2 mu - Cost (k=1 minus k=0, sig=+): +1.0207e-02, pred +7.0875e-03
    item 2: branch differences tau^2(mu_+ - mu_-) - (Cost_+ - Cost_-), k=0,1: +2.44e-03, +7.35e-03  (vs Cost_+ - Cost_- = 7.721e-02, 1.110e-01)
    item 3: E''dW/tau^2 over (k,sig): min -3.60941e-01 max -2.97389e-01, leading F = -3.75000e-01; max |dW - (F C + F2 C^2)| = 6.5e-04
    item 3: odd part of E''dW/(tau^2 F) over sig, k=0,1: -4.29681e-02 -5.23942e-02; pred gamma*M_k*Xi: -5.00000e-02 -7.00000e-02; even part minus 1: -8.05e-02 -1.55e-01

L = 13, N_f = 1, n = 1/L, t_f = 1, eps_1 = 0.2291, ell_0 = 1.07692, K_L = 1.8225, Xi = -0.8077
  gamma = 0.010   (N_f*kappa_k = gamma*M_k*L/t_f = 0.130, 0.182)
    k sig   d_sig     tau/d   |E''/(2tau^2 J)-1|  E''/(5.6)-1   tau^2 mu-Cost  pred(5.7)  -C_even   E''dW/(tau^2F)-1  pred g_sig*Xi
    0 +1  1.539e-03  6.5e-03   2.4e-14 (tau=d/5: 1.4e-10)  -5.04e-07   +8.3549e-06 +8.2840e-06 +8.2844e-06   -8.2471e-03  -8.0769e-03
    0 -1  1.539e-03  6.5e-03   1.9e-13 (tau=d/5: 1.3e-10)  +5.18e-07   +8.2147e-06 +8.2840e-06 +8.2844e-06   +7.9033e-03  +8.0769e-03
    1 +1  2.154e-03  4.6e-03   2.4e-14 (tau=d/5: 5.2e-10)  -1.38e-06   +1.6432e-05 +1.6237e-05 +1.6238e-05   -1.1640e-02  -1.1308e-02
    1 -1  2.154e-03  4.6e-03   6.0e-13 (tau=d/5: 5.1e-10)  +1.43e-06   +1.6047e-05 +1.6237e-05 +1.6238e-05   +1.0966e-02  +1.1308e-02
    item 2: level difference of tau^2 mu - Cost (k=1 minus k=0, sig=+): +8.0773e-06, pred +7.9527e-06
    item 2: branch differences tau^2(mu_+ - mu_-) - (Cost_+ - Cost_-), k=0,1: +1.40e-07, +3.85e-07  (vs Cost_+ - Cost_- = 1.539e-03, 2.154e-03)
    item 3: E''dW/tau^2 over (k,sig): min -6.22133e-01 max -6.08222e-01, leading F = -6.15385e-01; max |dW - (F C + F2 C^2)| = 3.1e-08
    item 3: odd part of E''dW/(tau^2 F) over sig, k=0,1: -8.07519e-03 -1.13029e-02; pred gamma*M_k*Xi: -8.07692e-03 -1.13077e-02; even part minus 1: -1.72e-04 -3.37e-04
  gamma = 0.020   (N_f*kappa_k = gamma*M_k*L/t_f = 0.260, 0.364)
    k sig   d_sig     tau/d   |E''/(2tau^2 J)-1|  E''/(5.6)-1   tau^2 mu-Cost  pred(5.7)  -C_even   E''dW/(tau^2F)-1  pred g_sig*Xi
    0 +1  3.078e-03  3.2e-03   1.4e-12 (tau=d/5: 2.2e-09)  -3.98e-06   +3.3710e-05 +3.3136e-05 +3.3143e-05   -1.6828e-02  -1.6154e-02
    0 -1  3.078e-03  3.2e-03   1.4e-12 (tau=d/5: 2.1e-09)  +4.20e-06   +3.2587e-05 +3.3136e-05 +3.3143e-05   +1.5452e-02  +1.6154e-02
    1 +1  4.311e-03  2.3e-03   1.3e-12 (tau=d/5: 8.5e-09)  -1.08e-05   +6.6538e-05 +6.4947e-05 +6.4971e-05   -2.3925e-02  -2.2615e-02
    1 -1  4.311e-03  2.3e-03   1.4e-12 (tau=d/5: 8.1e-09)  +1.17e-05   +6.3454e-05 +6.4947e-05 +6.4971e-05   +2.1229e-02  +2.2615e-02
    item 2: level difference of tau^2 mu - Cost (k=1 minus k=0, sig=+): +3.2828e-05, pred +3.1811e-05
    item 2: branch differences tau^2(mu_+ - mu_-) - (Cost_+ - Cost_-), k=0,1: +1.12e-06, +3.08e-06  (vs Cost_+ - Cost_- = 3.078e-03, 4.311e-03)
    item 3: E''dW/tau^2 over (k,sig): min -6.28449e-01 max -6.00661e-01, leading F = -6.15385e-01; max |dW - (F C + F2 C^2)| = 2.5e-07
    item 3: odd part of E''dW/(tau^2 F) over sig, k=0,1: -1.61400e-02 -2.25773e-02; pred gamma*M_k*Xi: -1.61538e-02 -2.26154e-02; even part minus 1: -6.88e-04 -1.35e-03
  gamma = 0.300   (N_f*kappa_k = gamma*M_k*L/t_f = 3.900, 5.460)
    k sig   d_sig     tau/d   |E''/(2tau^2 J)-1|  E''/(5.6)-1   tau^2 mu-Cost  pred(5.7)  -C_even   E''dW/(tau^2F)-1  pred g_sig*Xi
    0 +1  4.994e-02  2.0e-04   1.9e-10 (tau=d/5: 1.9e-04)  -1.13e-02   +1.0712e-02 +7.4556e-03 +7.7631e-03   -3.5532e-01  -2.4231e-01
    0 -1  4.994e-02  2.0e-04   9.6e-11 (tau=d/5: 9.4e-05)  +2.48e-02   +5.7983e-03 +7.4556e-03 +7.7631e-03   +4.5096e-02  +2.4231e-01
    1 +1  7.497e-02  1.3e-04   4.8e-10 (tau=d/5: 1.1e-03)  -3.34e-02   +2.7503e-02 +1.4613e-02 +1.5723e-02   -5.3528e-01  -3.3923e-01
    1 -1  7.497e-02  1.3e-04   1.6e-10 (tau=d/5: 3.5e-04)  +9.67e-02   +9.7896e-03 +1.4613e-02 +1.5723e-02   -6.1963e-02  +3.3923e-01
    item 2: level difference of tau^2 mu - Cost (k=1 minus k=0, sig=+): +1.6791e-02, pred +7.1574e-03
    item 2: branch differences tau^2(mu_+ - mu_-) - (Cost_+ - Cost_-), k=0,1: +4.91e-03, +1.77e-02  (vs Cost_+ - Cost_- = 4.994e-02, 7.497e-02)
    item 3: E''dW/tau^2 over (k,sig): min -6.43136e-01 max -2.85982e-01, leading F = -6.15385e-01; max |dW - (F C + F2 C^2)| = 1.6e-03
    item 3: odd part of E''dW/(tau^2 F) over sig, k=0,1: -2.00207e-01 -2.36658e-01; pred gamma*M_k*Xi: -2.42308e-01 -3.39231e-01; even part minus 1: -1.55e-01 -2.99e-01

Interested in this research?

Join the readers' list and get an e-mail when a new stage or a correction is published. No password, and you can unsubscribe at any time.