Skip to content

Dynamical Systems & Chaos

A pure mathematics use case: there is no downloaded dataset. The “real data” is two of the canonical objects of dynamical systems theory, the logistic map and the Lorenz system. This use case also doubles as a real regression check for two engine bugs fixed the same session it was built.

The logistic map: classification via Bool, filtered in SQL

Section titled “The logistic map: classification via Bool, filtered in SQL”

x(n+1) = r * x(n) * (1 - x(n)), swept across 300 values of r, classified chaotic or stable by the sign of its Lyapunov exponent, cross-checked against the real period-doubling cascade and the Feigenbaum point (r ≈ 3.5700):

DATASET logistic_runs COLUMNS (r: Double, lyapunov_exponent: Double, is_chaotic: Bool)
SELECT COUNT(*) AS n FROM logistic_runs WHERE is_chaotic = 1
SELECT COUNT(*) AS n FROM logistic_runs WHERE is_chaotic

Both forms agree. This is the exact Bool-predicate pattern that silently matched zero rows before this session’s fix.

The Lorenz attractor: sensitive dependence via DISTANCE

Section titled “The Lorenz attractor: sensitive dependence via DISTANCE”

Two trajectories separated by only 1e-4 at t=0, tracked with linaldb’s own DISTANCE: at rho=28 (the classic chaotic parameter) the separation grows; at rho=10 (a stable regime) it shrinks to zero: the defining signature of chaos, computed by the engine and cross-checked against numpy.

Attractor shape via EIGENVALUES: on the right matrix

Section titled “Attractor shape via EIGENVALUES: on the right matrix”

EIGENVALUES/EIGEN only accept symmetric matrices: the raw Lorenz Jacobian isn’t one (its eigenvalues are genuinely complex at the chaotic fixed points, confirmed against numpy). The honest answer: use the attractor’s covariance matrix instead, a real, standard technique, genuinely symmetric:

MATRIX cov = [[62.664, 62.730, 0.206], [62.730, 81.016, 1.827], [0.206, 1.827, 73.244]]
LET cov_eigvals = EIGENVALUES cov

Matches numpy.linalg.eigvalsh to within f32 precision. TRACE (works on any square matrix) still gives one honest real number off the raw, non-symmetric Jacobian; the notebook demonstrates EIGENVALUES correctly refusing it rather than returning something wrong.