Does light charge the quons? › Files cited on the page › check_trials25-27_fable/

a2_charge_tools.py

In the investigation at sim/m8_engine/check_trials25-27_fable/a2_charge_tools.py · last changed in commit 46c285d, 25 November 2026 · 1,024 bytes · the folder as a zip


"""Damped Prony (linear prediction with complex roots), shared by my A2/A4/A6 scripts. Thirty-fifth reviewer."""
import numpy as np


def prony_damped(x, dt, nfreq):
    """Returns (w, gamma, amplitude) per mode, largest amplitude first; w = |angle(root)|/dt, gamma = -ln|root|/dt."""
    x = np.asarray(x, float)
    order = 2 * nfreq
    rows = len(x) - order
    A = np.array([x[i:i + order] for i in range(rows)])
    coef, *_ = np.linalg.lstsq(A, x[order:order + rows], rcond=None)
    roots = np.roots(np.concatenate([[1.0], -coef[::-1]]))
    n = np.arange(len(x))
    V = np.array([r ** n for r in roots]).T
    amp, *_ = np.linalg.lstsq(V, x.astype(complex), rcond=None)
    out = []
    for r, a in zip(roots, amp):
        w = abs(np.angle(r)) / dt
        if w < 1e-9:
            continue
        out.append((w, -np.log(abs(r)) / dt, abs(a)))
    out.sort(key=lambda z: -z[2])
    kept = []
    for z in out:
        if not any(abs(z[0] - k[0]) < 1e-9 for k in kept):
            kept.append(z)
    return kept