5D Library › Five-Node Cyclic Network Dynamics, Solar-Longitude Ephemeris and Multi-Scale Oscillator Perturbations · 中文

Chapter 4. Two-Scale Forcing: Resonant Gain, Peaks and Troughs, and the Jacobian’s Condition Number

Putting the ring in a rhythmic world

The rings of the last two chapters were autonomous. This chapter forces one, on two time scales: a square wave switching every ten years (period twenty years) and a once-a-year sine. The questions: which forcing moves the ring more? When do the energy peaks and troughs fall in a past and a future window? And what role does the condition number of the ring’s Jacobian play?

To give time a unit, this chapter scales the rates by 10 per year: the linearised ring sits 0.1 on the stable side of its Hopf threshold (μ=μc+0.1\mu = \mu_c + 0.1; stable, damped), mode 1 has a natural frequency of 1.314 radians a year (a period of about 4.78 years) and decays at 0.200 a year. The forcing enters at node 0 and leaves at node 2, so it stays on the simplex.

Resonant gain and energy extremes

Calculation

The circulant ring’s exact frequency response. For a sine of frequency ω\omega, the steady response is found mode by mode: ŷk=b̂k/(iω−λk)\hat y_k = \hat b_k / (i\omega – \lambda_k). The gain |𝒚|/|u||\mathbf{y}|/|u| peaks when ω\omega is near |Im⁡λ1||\operatorname{Im}\lambda_1|, with a height set by the decay rate.

Calculation

# Chapter 4. p08: Two-scale forcing of the damped ring: gain, peaks, troughs.
# Linearised ring on the stable side of Hopf: mu = mu_c + 0.1 with c1 = 1,
# c2 = 0.5, rates scaled by 10 per year, so mode 1 has frequency
# |Im lambda_1| * 10 / 5 = 1.314 rad/yr (period 4.78 yr) and decays at
# 0.2 per year. Forcing enters node 0 and leaves node 2 (zero-sum, so it
# stays on the simplex):
#   slow  a square wave switching every 10 years (period 20 yr), size 1
#   fast  a 1-year sine, size 1
# A. Steady-state gain |y|/|u| of a pure sine, from the exact circulant
#    resolvent y_k = b_k / (i w - lambda_k), at the frequencies that
#    matter. B. The energy E = |y|^2 under both forcings together,
#    simulated from year 0 to 160 (RK4, step 0.002 yr); its largest peaks
#    and deepest troughs in a past window (60-100) and a future window
#    (120-160), against each forcing alone.
import cmath
import math

W = cmath.exp(2j * math.pi / 5)
C1, C2, SCALE = 1.0, 0.5, 10.0
MU = (C1 * math.cos(math.radians(72)) + C2 * math.cos(math.radians(36))
      + 0.1)
B = [1.0, 0.0, -1.0, 0.0, 0.0]

def lam(k):
    return (C1 * W ** -k - C2 * W ** (-2 * k) - MU) * SCALE / 5

def gain(w):
    bk = [sum(B[j] * W ** (-j * k) for j in range(5)) / 5 for k in range(5)]
    yk = [bk[k] / (1j * w - lam(k)) if k else 0 for k in range(5)]
    y = [sum(yk[k] * W ** (j * k) for k in range(5)) for j in range(5)]
    return math.sqrt(sum(abs(v) ** 2 for v in y) / sum(v * v for v in B))

def forcing(t, slow, fast):
    s = (1.0 if int(t // 10) % 2 == 0 else -1.0) if slow else 0.0
    f = math.sin(2 * math.pi * t) if fast else 0.0
    return s + f

def simulate(slow, fast, t1=160.0, h=0.002):
    def f(y, t):
        u = forcing(t, slow, fast)
        return [SCALE / 5 * (C1 * y[(i - 1) % 5] - C2 * y[(i - 2) % 5]
                             - MU * y[i]) + B[i] * u for i in range(5)]
    y, t, out = [0.0] * 5, 0.0, []
    while t < t1:
        k1 = f(y, t)
        k2 = f([a + h / 2 * b for a, b in zip(y, k1)], t + h / 2)
        k3 = f([a + h / 2 * b for a, b in zip(y, k2)], t + h / 2)
        k4 = f([a + h * b for a, b in zip(y, k3)], t + h)
        y = [a + h / 6 * (b + 2 * c + 2 * d + e)
             for a, b, c, d, e in zip(y, k1, k2, k3, k4)]
        t += h
        out.append((t, sum(v * v for v in y)))
    return out

def extremes(series, lo, hi, n=3):
    pts = [(t, e) for t, e in series if lo <= t <= hi]
    pk = [(t, e) for (_, a), (t, e), (_, c) in zip(pts, pts[1:], pts[2:])
          if e > a and e >= c]
    tr = [(t, e) for (_, a), (t, e), (_, c) in zip(pts, pts[1:], pts[2:])
          if e < a and e <= c]
    return (sorted(pk, key=lambda r: -r[1])[:n],
            sorted(tr, key=lambda r: r[1])[:n])

if __name__ == "__main__":
    print("A. gain |y|/|u| for a sine of angular frequency w (rad/yr)")
    print("   mode-1 frequency {:.3f}, decay {:.3f} per yr".format(
        abs(lam(1).imag), -lam(1).real))
    for name, w in (("20-yr fundamental", 2 * math.pi / 20),
                    ("3rd harmonic", 3 * 2 * math.pi / 20),
                    ("5th harmonic", 5 * 2 * math.pi / 20),
                    ("mode-1 resonance", abs(lam(1).imag)),
                    ("1-yr sine", 2 * math.pi)):
        print("   {:<18} w = {:6.3f}   gain {:7.4f}".format(
            name, w, gain(w)))
    both = simulate(True, True)
    slow = simulate(True, False)
    fast = simulate(False, True)
    print("\nB. energy E = |y|^2")
    for label, lo, hi in (("past window", 60, 100),
                          ("future window", 120, 160)):
        pk, tr = extremes(both, lo, hi)
        print("   {} {}-{} yr".format(label, lo, hi))
        print("     peaks  : " + ", ".join(
            "{:.2f} yr ({:.3f})".format(t, e) for t, e in pk))
        print("     troughs: " + ", ".join(
            "{:.2f} yr ({:.4f})".format(t, e) for t, e in tr))
    m = lambda s: max(e for t, e in s if 120 <= t <= 160)
    print("   largest E 120-160: both {:.3f}, slow only {:.3f},"
          " fast only {:.5f}".format(m(both), m(slow), m(fast)))
    print("\nReading: the yearly sine barely moves the ring - it is far")
    print("above the ring's own frequency. The decadal square wave matters")
    print("through its 5th harmonic, close to resonance. Peaks and troughs")
    print("repeat every 20 years, so with known parameters the future")
    print("window is the past window shifted: the extremes are computable,")
    print("not discovered. Chapter 5 asks how well the parameters are")
    print("known.")
# A. gain |y|/|u| for a sine of angular frequency w (rad/yr)
#    mode-1 frequency 1.314, decay 0.200 per yr
#    20-yr fundamental  w =  0.314   gain  0.7059
#    3rd harmonic       w =  0.942   gain  1.4547
#    5th harmonic       w =  1.571   gain  1.8654
#    mode-1 resonance   w =  1.314   gain  3.0188
#    1-yr sine          w =  6.283   gain  0.1648
#
# B. energy E = |y|^2
#    past window 60-100 yr
#      peaks  : 72.04 yr (4.130), 92.04 yr (4.130), 82.44 yr (3.788)
#      troughs: 85.02 yr (0.0963), 65.02 yr (0.0964), 74.73 yr (0.1114)
#    future window 120-160 yr
#      peaks  : 132.04 yr (4.130), 152.04 yr (4.130), 122.44 yr (3.788)
#      troughs: 125.02 yr (0.0963), 145.02 yr (0.0963), 154.73 yr (0.1115)
#    largest E 120-160: both 4.130, slow only 3.739, fast only 0.04963
#
# Reading: the yearly sine barely moves the ring - it is far
# above the ring's own frequency. The decadal square wave matters
# through its 5th harmonic, close to resonance. Peaks and troughs
# repeat every 20 years, so with known parameters the future
# window is the past window shifted: the extremes are computable,
# not discovered. Chapter 5 asks how well the parameters are
# known.

Part A gives the gain at each frequency. The once-a-year sine lies far above the ring’s natural frequency and has a gain of only 0.1648: the yearly rhythm barely moves the ring. The twenty-year square wave’s fundamental has a gain of 0.7059, but a square wave also contains odd harmonics: the third has a gain of 1.4547, and the fifth (1.571 radians a year) lies closest to resonance, with a gain of 1.8654. Resonance itself gives 3.0188. So what actually drives the ring is the fifth harmonic of the decadal forcing — not the yearly sine, and not the square wave’s fundamental.

Part B simulates 160 years with both forcings and finds the extremes of the energy E=|𝒚|2E = |\mathbf{y}|^2. In the past window (60 to 100 years) the two largest peaks fall at 72.04 and 92.04 years, height 4.130; in the future window (120 to 160 years) at 132.04 and 152.04 years, again 4.130. The troughs likewise: 85.02 years matches 145.02. Peaks and troughs repeat exactly every twenty years: the future window is the past window shifted by a whole number of twenty-year periods. With both forcings the largest energy in the future window is 4.130; with the square wave alone 3.739; with the sine alone only 0.04963.

So for a damped system with known parameters under periodic forcing, future energy extremes are not “discovered” but computed; their relation to past extremes is fixed entirely by the period of the forcing. The only uncertainty is in the parameters themselves — the subject of Chapter 5.

The energy E = |\mathbf{y}|^2 under both forcings; peaks and troughs repeat exactly every twenty years.

The condition number: what the spectrum does not say

Looking only at eigenvalues, one would think a stable system simply decays after a disturbance. That is true for normal matrices (those that commute with their transpose); for non-normal ones it is not: a disturbance can first grow and then decay, and the stationary variance is no longer fixed by the eigenvalues alone (Trefethen and Embree 2005).

Calculation

The Lyapunov equation. Under white-noise forcing BB, the stationary covariance PP of a stable linear system 𝒚̇=J𝒚+Bξ\dot{\mathbf{y}} = J\mathbf{y} + B\xi satisfies JP+PJ⊤+BB⊤=0.J P + P J^{\top} + B B^{\top} = 0 . This book solves it exactly as a linear system in Kronecker form (Bartels and Stewart 1972). If JJ’s eigenvectors are orthogonal, tr⁡P\operatorname{tr}P equals the sum of independent modal contributions ∑k|ck|2/(−2Re⁡λk)\sum_k |c_k|^2/(-2\operatorname{Re}\lambda_k); the condition number κ(V)\kappa(V) of the eigenvector matrix measures how far that fails.

Calculation

# Chapter 4. p09: Lyapunov equation, condition number and transient growth.
# Linearised replicator ring at its interior equilibrium x*, on the
# 4-dimensional simplex tangent (orthonormal Helmert basis Q), rates x10
# per year as in p08, mu = mu_c + 0.1. J_ij = x*_i (A_ij - ((A + A^T) x*)_j).
# Cases: the symmetric ring (a circulant, so J is a normal matrix) and
# rings whose ten edge weights are scaled by fixed factors (1 + d).
# Reported: the spectral abscissa (largest Re lambda), the condition
# number kappa(V) of the eigenvector matrix, Henrici's departure from
# normality, the largest transient gain max_t |exp(J t)|, and the
# stationary variance tr P under white-noise forcing B = (1, 0, -1, 0,
# 0), where J P + P J^T + B B^T = 0 is solved exactly (Kronecker form),
# against the sum over modes of |c_k|^2 / (-2 Re lambda_k), c = V^-1 B,
# which is exact only when the (unit) eigenvectors are orthogonal.
import cmath
import math

C1, C2, SCALE = 1.0, 0.5, 10.0
MU = (C1 * math.cos(math.radians(72)) + C2 * math.cos(math.radians(36))
      + 0.1)
CASES = (("symmetric ring", [0.0] * 5, [0.0] * 5),
         ("weights +-20 %", [0.2, -0.2, 0.1, -0.1, 0.0],
          [-0.2, 0.2, 0.0, 0.1, -0.1]),
         ("weights +-40 %", [0.4, -0.4, 0.2, -0.2, 0.0],
          [-0.4, 0.4, 0.0, 0.2, -0.2]))

def solve(m, v):
    n = len(v)
    a = [list(r) + [x] for r, x in zip(m, v)]
    for c in range(n):
        p = max(range(c, n), key=lambda r: abs(a[r][c]))
        a[c], a[p] = a[p], a[c]
        for r in range(n):
            if r != c:
                f = a[r][c] / a[c][c]
                a[r] = [x - f * y for x, y in zip(a[r], a[c])]
    return [a[i][n] / a[i][i] for i in range(n)]

def mul(a, b):
    return [[sum(a[i][k] * b[k][j] for k in range(len(b)))
             for j in range(len(b[0]))] for i in range(len(a))]

def tr(a):
    return [list(r) for r in zip(*a)]

def norm2(m, it=60):
    v = [1.0] * len(m[0])
    mtm = mul(tr(m), m)
    for _ in range(it):
        w = [sum(r[j] * v[j] for j in range(len(v))) for r in mtm]
        s = math.sqrt(sum(x * x for x in w))
        v = [x / s for x in w]
    w = [sum(r[j] * v[j] for j in range(len(v))) for r in mtm]
    return math.sqrt(sum(x * y for x, y in zip(w, v)))

def setup(d1, d2):
    a = [[0.0] * 5 for _ in range(5)]
    for i in range(5):
        a[i][(i - 1) % 5] += C1 * (1 + d1[i])
        a[i][(i - 2) % 5] -= C2 * (1 + d2[i])
        a[i][i] -= MU
    m = [row + [-1.0] for row in a] + [[1.0] * 5 + [0.0]]
    xs = solve(m, [0.0] * 5 + [1.0])[:5]
    s = [sum((a[i][j] + a[j][i]) * xs[i] for i in range(5))
         for j in range(5)]
    j5 = [[SCALE * xs[i] * (a[i][j] - s[j]) for j in range(5)]
          for i in range(5)]
    q = []
    for k in range(1, 5):
        col = [1.0] * k + [-float(k)] + [0.0] * (4 - k)
        n = math.sqrt(sum(x * x for x in col))
        q.append([x / n for x in col])
    q = tr(q)
    return xs, mul(mul(tr(q), j5), q), q

def eig4(j):
    # characteristic polynomial (Faddeev-LeVerrier), roots (Durand-Kerner)
    n = 4
    c, mk = [1.0], [[float(i == k) for k in range(n)] for i in range(n)]
    for k in range(1, n + 1):
        am = mul(j, mk)
        ck = -sum(am[i][i] for i in range(n)) / k
        c.append(ck)
        mk = [[am[i][l] + (ck if i == l else 0.0) for l in range(n)]
              for i in range(n)]
    p = lambda z: sum(ci * z ** (n - i) for i, ci in enumerate(c))
    r = [(0.4 + 0.9j) ** i for i in range(n)]
    for _ in range(500):
        r = [ri - p(ri) / math.prod(ri - rj for rj in r if rj is not ri)
             for ri in r]
    return r

def kappa(j, lams):
    vs = []
    for lv in lams:
        m = [[j[r][c] - (lv if r == c else 0) for c in range(4)]
             for r in range(4)]
        sub = [row[1:] for row in m[1:]]
        rest = solve(sub, [-row[0] for row in m[1:]])
        v = [1.0] + rest
        nv = math.sqrt(sum(abs(x) ** 2 for x in v))
        vs.append([x / nv for x in v])
    g = [[sum(vs[a][k].conjugate() * vs[b][k] for k in range(4))
          for b in range(4)] for a in range(4)]
    ev = [abs(e) for e in eig4([[g[a][b].real for b in range(4)]
                                for a in range(4)])] if all(
        abs(g[a][b].imag) < 1e-12 for a in range(4) for b in range(4)) \
        else None
    if ev is None:   # Hermitian Gram matrix: power iteration both ways
        def pw(mat, inv=False):
            v = [1.0 + 0.1j * k for k in range(4)]
            for _ in range(200):
                w = solve(mat, v) if inv else [sum(mat[a][b] * v[b]
                                                   for b in range(4))
                                               for a in range(4)]
                s = math.sqrt(sum(abs(x) ** 2 for x in w))
                v = [x / s for x in w]
            w = [sum(mat[a][b] * v[b] for b in range(4)) for a in range(4)]
            return abs(sum(x.conjugate() * y for x, y in zip(v, w)))
        return math.sqrt(pw(g) / pw(g, True)), vs
    return math.sqrt(max(ev) / min(ev)), vs

def lyap_var(j, b):
    n = 4
    k = [[0.0] * (n * n) for _ in range(n * n)]
    for i in range(n):
        for l in range(n):
            for p in range(n):
                k[i * n + l][p * n + l] += j[i][p]
                k[i * n + l][i * n + p] += j[l][p]
    rhs = [-b[i] * b[l] for i in range(n) for l in range(n)]
    pv = solve(k, rhs)
    return sum(pv[i * n + i] for i in range(n))

def growth(j, t1=12.0, h=0.01):
    m = [[float(i == k) for k in range(4)] for i in range(4)]
    best, when, t = 1.0, 0.0, 0.0
    while t < t1:
        def f(x):
            return mul(j, x)
        k1 = f(m)
        k2 = f([[a + h / 2 * b for a, b in zip(r, s)]
                for r, s in zip(m, k1)])
        k3 = f([[a + h / 2 * b for a, b in zip(r, s)]
                for r, s in zip(m, k2)])
        k4 = f([[a + h * b for a, b in zip(r, s)] for r, s in zip(m, k3)])
        m = [[a + h / 6 * (b + 2 * c + 2 * d + e)
              for a, b, c, d, e in zip(*rows)]
             for rows in zip(m, k1, k2, k3, k4)]
        t += h
        if round(t / h) % 10 == 0:
            g = norm2(m)
            if g > best:
                best, when = g, t
    return best, when

if __name__ == "__main__":
    print("   case             min x*  max x*  abscissa  kappa(V)  Henrici")
    rows = []
    for name, d1, d2 in CASES:
        xs, j, q = setup(d1, d2)
        lams = eig4(j)
        fro = sum(v * v for r in j for v in r)
        hen = math.sqrt(max(fro - sum(abs(v) ** 2 for v in lams), 0.0))
        kap, vs = kappa(j, lams)
        print("   {:<16} {:6.4f}  {:6.4f}  {:+8.4f}  {:8.3f}  {:7.3f}"
              .format(name, min(xs), max(xs), max(v.real for v in lams),
                      kap, hen))
        b5 = [1.0, 0.0, -1.0, 0.0, 0.0]
        b = [sum(q[i][k] * b5[i] for i in range(5)) for k in range(4)]
        rows.append((name, j, lams, b, vs))
    print("\n   case             max |exp(Jt)|  at t (yr)  var tr P"
          "  modal sum")
    for name, j, lams, b, vs in rows:
        g, when = growth(j)
        var = lyap_var(j, b)
        cs = solve([[vs[k][i] for k in range(4)] for i in range(4)],
                   [complex(x) for x in b])
        nvar = sum(abs(c) ** 2 / (-2 * lv.real) for c, lv in zip(cs, lams))
        print("   {:<16} {:10.3f}     {:7.2f}   {:8.4f}  {:9.4f}".format(
            name, g, when, var, nvar))
    print("\nReading: the symmetric ring is a circulant, so its Jacobian is")
    print("normal: kappa(V) = 1, no transient growth, and the modal sum is")
    print("exact. Uneven edge weights make it non-normal: with +-40 %")
    print("weights a perturbation grows by a quarter before decaying, and")
    print("the modal sum misses the exact variance by a few per cent. At")
    print("these weights the effect is mild; the condition number, not")
    print("the spectrum, is what reports it.")
#    case             min x*  max x*  abscissa  kappa(V)  Henrici
#    symmetric ring   0.2000  0.2000   -0.2000     1.000    0.000
#    weights +-20 %   0.1653  0.2555   -0.2112     1.426    1.570
#    weights +-40 %   0.1290  0.3288   -0.2265     1.982    3.117
#
#    case             max |exp(Jt)|  at t (yr)  var tr P  modal sum
#    symmetric ring        1.000        0.00     3.6958     3.6958
#    weights +-20 %        1.047        0.60     2.4361     2.3831
#    weights +-40 %        1.245        0.90     1.7510     1.6849
#
# Reading: the symmetric ring is a circulant, so its Jacobian is
# normal: kappa(V) = 1, no transient growth, and the modal sum is
# exact. Uneven edge weights make it non-normal: with +-40 %
# weights a perturbation grows by a quarter before decaying, and
# the modal sum misses the exact variance by a few per cent. At
# these weights the effect is mild; the condition number, not
# the spectrum, is what reports it.

The symmetric ring is a circulant, and every circulant is normal: κ(V)=1.000\kappa(V) = 1.000, Henrici’s departure from normality is 0, |eJt||e^{Jt}| never exceeds 1, and the exact solution of the Lyapunov equation, 3.6958, equals the modal sum, 3.6958. This row also checks the program: the two methods must agree in the normal case.

Let each of the ten edge weights depart by ±20 % and the equilibrium is no longer uniform (smallest share 0.1653, largest 0.2555), and κ(V)\kappa(V) rises to 1.426; at ±40 % it is 1.982, a disturbance grows by up to 1.245 (about a quarter) before decaying, and the modal sum, 1.6849, misses the exact variance, 1.7510, by about 4 %.

This is the third correction to the outline: a perfectly symmetric five-node ring cannot amplify transiently, because its Jacobian is normal; condition numbers and transient growth appear only when the weights are uneven. Over the weights tried here the effect is mild. The condition number matters because it reports what the spectrum cannot see, not because it is large here.

Note

The units are chosen. The rate scale of 10 per year, the “decadal square wave” and the “yearly sine” are mathematical settings chosen to give the problem a concrete sense of time; they correspond to no real decadal or yearly system. The chapter’s conclusions — which harmonic lies nearest resonance, that the symmetric ring is normal — hold in any unit of time; the particular year numbers mean something only in this setting.

Hypothesis · not established

The author’s hypothesis (not yet tested): for five-node rings with randomly perturbed edge weights, the largest transient amplification grows monotonically with κ(V)\kappa(V). (That the amplification cannot exceed κ(V)\kappa(V) itself is a known bound, since |eJt|≤κ(V)eαt|e^{Jt}| \le \kappa(V)\,e^{\alpha t} with spectral abscissa α<0\alpha < 0; it is not a hypothesis.) What would show it wrong: among many random weightings, no monotone relation between amplification and κ(V)\kappa(V) — for instance, a sizeable share of rings with larger κ(V)\kappa(V) amplifying less.

Summary

Under periodic forcing, the component that matters is the one nearest the ring’s natural frequency: in this chapter’s example the fifth harmonic of the decadal square wave, not the yearly sine. With known parameters, the energy extremes of a future window are those of a past window shifted by whole forcing periods. The symmetric ring is normal and cannot amplify transiently; condition numbers and transient growth appear only with uneven edge weights, and remain mild at ±40 %.

References

Bartels, R. H., and G. W. Stewart. 1972. “Solution of the Matrix Equation AX + XB = C.” Communications of the ACM 15 (9): 820–26.
Trefethen, Lloyd N., and Mark Embree. 2005. Spectra and Pseudospectra: The Behavior of Nonnormal Matrices and Operators. Princeton University Press.

Fan, Y. (2026). Five-Node Cyclic Network Dynamics, Solar-Longitude Ephemeris and Multi-Scale Oscillator Perturbations: Rock-Paper-Scissors-Lizard-Spock Lotka-Volterra Graphs, Equation-of-Time Keplerian Mechanics and Jacobian Sensitivity Bounds [五节点循环网络动力学、黄经历表与多尺度振子扰动] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090168 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).