What does Koopman Modes for Audience Turning Points conclude, in numbers, about “Jacobi Rotations: Symmetric Eigendecomposition and the Singular Value Decomposition with the Standard Library Alone”?
Answer: A Jacobi rotation turns one off-diagonal element into zero, off-diagonal energy can only flow onto the diagonal, and cyclic sweeps converge quadratically in their later stage: in program p31 six sweeps take an 8 by 8 Gram matrix from 9.217e-01 to 1.022e-16, with orthogonality error 2.7e-15. Singular values must not be obtained by the shortcut of multiplying by the transpose and taking roots: in program p32 the one-billionth singular value comes out negative on that road, with a relative error of 8.6e+00, while one-sided Jacobi errs by 2.6e-08, right at the limit set by rounding in the input. Program p33 confirms the theorem of Eckart and Young: the truncation error equals the root of the sum of the discarded squared singular values. With these standard-library factorisations in hand, the next chapter builds dynamic mode decomposition proper, computing eigenvalues and modes, and shows how noise disguises a swing that never decays as a signal that is fading away.
Scope of the numbers: Marked boxes separate published evidence, runnable Python calculations (19 programs), classical sources and the author's hypotheses.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: -01, -15, -16, 1.022, 2.7, 9.217
| sweep | off-diagonal norm / norm of G |
|---|---|
| 0 | 9.217e-01 |
| 1 | 4.695e-02 |
| 2 | 1.819e-03 |
| 3 | 5.628e-05 |
| 4 | 4.051e-07 |
| 5 | 3.454e-12 |
| 6 | 1.022e-16 |
| eigenvalues / trace: | |
| 0.9094 0.0699 0.0139 0.0020 | |
| 1.3e-03 1.3e-03 1.1e-03 1.0e-03 | |
| max |V^T V - I| = 2.7e-15 | max |V W V^T - G| / max|G| = 4.0e-15 |
Show the full program
# Chapter 3. p31: cyclic Jacobi rotations on a symmetric Gram matrix.
# Model: the 8 x 8 Gram matrix G = H H^T of the de-meaned p11 curve
# embedded with 8 delay rows (illustrative data, fixed seed). Each sweep
# visits all 28 off-diagonal pairs once; we print the off-diagonal norm
# after every sweep (quadratic convergence), the eigenvalues, and two
# checks: orthogonality of V and the reconstruction G = V diag(w) V^T.
import math
import random
def slow(t):
# 慢分量:进场与离场两个指数之差(示意参数,单位:人)
return 800.0 + 5000.0 * (math.exp(-t / 60.0) - math.exp(-t / 20.0))
def cycle(t):
# 每 12 分钟一轮上新或福袋带来的起伏(示意)
return 150.0 * math.cos(2.0 * math.pi * t / 12.0)
def session(sd=40.0, n=120, shift=0):
rng = random.Random(20261113 + shift)
return [slow(t) + cycle(t) + rng.gauss(0.0, sd) for t in range(n)]
def jacobi_eig(a, max_sweeps=50, log=None):
# 循环 Jacobi 旋转:对称矩阵 A = V diag(w) V^T,每次把一个非对角元转成 0
n = len(a)
a = [row[:] for row in a]
v = [[1.0 if i == j else 0.0 for j in range(n)] for i in range(n)]
for sweep in range(max_sweeps):
off = math.sqrt(math.fsum(a[i][j] ** 2 for i in range(n)
for j in range(n) if i != j))
if log is not None:
log.append(off)
if off <= 1e-15 * math.sqrt(math.fsum(a[i][i] ** 2
for i in range(n))):
break
for p in range(n - 1):
for q in range(p + 1, n):
if a[p][q] == 0.0:
continue
th = (a[q][q] - a[p][p]) / (2.0 * a[p][q])
t = math.copysign(1.0, th) / (
abs(th) + math.sqrt(th * th + 1.0))
c = 1.0 / math.sqrt(t * t + 1.0)
s = t * c
for k in range(n):
akp, akq = a[k][p], a[k][q]
a[k][p] = c * akp - s * akq
a[k][q] = s * akp + c * akq
for k in range(n):
apk, aqk = a[p][k], a[q][k]
a[p][k] = c * apk - s * aqk
a[q][k] = s * apk + c * aqk
for k in range(n):
vkp, vkq = v[k][p], v[k][q]
v[k][p] = c * vkp - s * vkq
v[k][q] = s * vkp + c * vkq
w = [a[i][i] for i in range(n)]
order = sorted(range(n), key=lambda i: (-w[i], i))
return [w[i] for i in order], [[v[k][i] for i in order]
for k in range(n)]
def hankel(x, rows):
# 延迟嵌入:第 i 行是从第 i 分钟起的一段序列
k = len(x) - rows + 1
return [[x[i + j] for j in range(k)] for i in range(rows)]
def dot(a, b):
return math.fsum(x * y for x, y in zip(a, b))
def matmul(a, b):
bt = list(zip(*b))
return [[dot(r, c) for c in bt] for r in a]
def transpose(a):
return [list(r) for r in zip(*a)]
x = session()
mean = math.fsum(x) / len(x)
h = hankel([q - mean for q in x], 8)
g = matmul(h, transpose(h))
log = []
w, v = jacobi_eig(g, log=log)
scale = math.sqrt(math.fsum(q * q for row in g for q in row))
print("sweep off-diagonal norm / norm of G")
for k, off in enumerate(log):
print("%5d %.3e" % (k, off / scale))
print("eigenvalues / trace:")
tr = math.fsum(w)
print(" " + " ".join("%.4f" % (q / tr) for q in w[:4]))
print(" " + " ".join("%.1e" % (q / tr) for q in w[4:]))
vtv = matmul(transpose(v), v)
orth = max(abs(vtv[i][j] - (1.0 if i == j else 0.0))
for i in range(8) for j in range(8))
rec = matmul(matmul(v, [[w[i] if i == j else 0.0 for j in range(8)]
for i in range(8)]), transpose(v))
err = max(abs(rec[i][j] - g[i][j]) for i in range(8) for j in range(8))
print("max |V^T V - I| = %.1e max |V W V^T - G| / max|G| = %.1e"
% (orth, err / max(abs(q) for row in g for q in row)))Single source and citation
Fan, Y. (2026). Koopman Operators and Dynamic Mode Decomposition: Linearising Nonlinear Cash-Flow Swings and Forecasting Turning Points in Livestream Audience Curves (Version 1.0.0), Chapter 3: Jacobi Rotations: Symmetric Eigendecomposition and the Singular Value Decomposition with the Standard Library Alone. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-238 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026238,
author = {Fan, Yafu},
title = {Koopman Operators and Dynamic Mode Decomposition: Linearising Nonlinear Cash-Flow Swings and Forecasting Turning Points in Livestream Audience Curves},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · Two or Three Modes: the Low-Rank Structure of a Livestream Audience Curve and the Built-In Lag of Moving Averages
- Chapter 2 · The Koopman Operator: Lifting Nonlinear Dynamics into Linear Ones, and the Limits of the Lift
- Chapter 4 · Dynamic Mode Decomposition: Eigenvalues, Amplitudes and the False Decay Caused by Noise
- Chapter 5 · Lead Time at the Turning Point: a Mode-Based Warning Every Five Minutes against Moving Averages
- Chapter 6 · Cash Flow: Linearising Daily, Weekly and Monthly Swings with Modes, and Choosing the Observable
- Chapter 7 · East and West in the Sources: "Knowing the Incipient" in the Book of Changes and Fourier's Analysis of Heat
- Chapter 8 · Closing the Empirical Loop: a Mode Fit Every Five Minutes, a Cooling Warning and a Pre-Registered Test