The deep-learning literature on state space models begins in medias res: it writes down \(\dot x = Ax + Bu\), \(y = Cx\), and proceeds at once to the question of computing with it quickly. That equation is not new. It is the central object of a mature subject with sixty-five years of theorems attached, and almost every structural fact the modern papers rely on is one of those theorems — usually with a name. These notes develop that subject, from the definition of state up to the point where Part 00 of the companion notes begins.
Fig. 0 — A system of order \(n\) is switched on and its impulse response streams in. From those numbers alone we build the Hankel matrix and take its singular values. They collapse to zero after exactly \(n\) of them — and not before you have seen about \(2n\) samples, which is the smallest amount of data from which the order can possibly be read. Add measurement noise and the collapse becomes a cliff of finite height: the order is still visible, but only down to the noise floor. Everything in §3 is contained in this picture.
That is the thesis of this document, stated before any of the machinery. The size of the state is not a hyperparameter of the model; it is a property of the operator the model is trying to be, it is computable from data, and there is a classical theory telling you what it costs to use fewer coordinates than the truth requires. The modern literature re-derives large parts of that theory under new names, and reads much more clearly once you have the old ones.
Parts 0–4 are classical linear systems theory and are the backbone. If you read only part of this page, read those. Part 5 (discretisation) and Part 7 (the Kalman filter, set up by Part 6) are where the classical theory maps onto a modern architecture almost line for line, and they are the parts most likely to change how you read Mamba. Parts 8–9 are the approximation theory and the algorithmic toolbox, 10–11 the history and the dictionary, 12 the exercises — each with its answer folded away behind a click — and 13 the references.
Prerequisites are honest ones: linear algebra through eigenvalues and the SVD, multivariable calculus, a first course in probability. No control theory is assumed. Every figure computes its own numbers in your browser from the formulas in the text — including the ones that are supposed to fail.
Everything in this subject follows from one definition, and the definition is not about matrices at all. Consider any system that consumes an input sequence \(u_0,u_1,u_2,\dots\) and emits outputs causally, so that \(y_k\) may depend on \(u_0,\dots,u_k\) and on nothing later. Ask when two different histories become interchangeable.
Declare two histories equivalent if, for every continuation \(v_1,v_2,\dots\), the two futures produce identical outputs. This is an equivalence relation, and the set of its classes is the state space of the system; the class of the history observed so far is the state. A history's class is exactly the information about the past that the future can still detect. Everything else has already been forgotten — by the system, not by us.
Sufficiency. The future output depends on the past only through the state. This is the deterministic form of the Markov property, and it is what makes a fixed-size memory conceivable at all.
Recursiveness. The state can be maintained online. If \(s\) is the class of \(u_{0:k-1}\) and we observe \(u_k\), the class of \(u_{0:k}\) is determined by \(s\) and \(u_k\) alone — otherwise two histories in \(s\) would be distinguished by a continuation beginning with \(u_k\), contradicting equivalence. So there is a well-defined \(s_k=F(s_{k-1},u_k)\) and a readout \(y_k=G(s_k,u_k)\).
This construction is Nerode's in automata theory (1958) — where the classes of a regular language are the states of its minimal automaton — and Kalman's in the linear setting, where the classes form a vector space whose dimension has a name, the McMillan degree. The pair (sufficiency, recursiveness) is precisely what a sequence model wants, which is why this subject is relevant to sequence modelling in the first place. An architecture that keeps a fixed-size vector and updates it token by token is placing a bet: that a state space of that size is large enough for the task.
The figure below is the definition, executed. Two entirely different input histories are constructed to leave the system in the same state; from that moment they are fed the same continuation, and their outputs coincide to machine precision. Then perturb the second history so the states no longer agree, and watch the futures separate.
Fig. 0.1 — Left of the divider the two inputs have nothing in common; right of it the outputs agree to \(10^{-15}\). Nudge \(\varepsilon\) off zero and the agreement degrades smoothly and immediately: the state is not merely sufficient, it is the only thing that is. Raising \(N\) makes the pair of histories harder to construct but changes nothing about the conclusion.
Specialise now to a linear, time-invariant system. The classes form a vector space, and the system can be written in the standard way — continuous time, one input and one output:
with \(A\in\mathbb{R}^{N\times N}\), \(B\in\mathbb{R}^{N\times1}\), \(C\in\mathbb{R}^{1\times N}\). Discrete time is the same statement with \(x_k=\bar Ax_{k-1}+\bar Bu_k\). This is the base object of the companion notes, and Parts 1–4 here take it apart.
Exercise 0.3 of the companion notes asks how many of the \(N^2+2N\) parameters of \((A,B,C)\) are identifiable from the input–output map. The answer is \(2N\), and the reason is the construction above: the map determines the state space only up to a choice of basis. We prove it in §3.4. Everything S4 does when it picks a convenient \(A\) is licensed by that theorem and by nothing else.
Before the systems theory, the linear algebra — because two properties of the matrix exponential settle questions the companion notes raise much later. The exponential is a similarity invariant, which is what makes canonical forms free; and the price of a similarity is the conditioning of the basis, which is what killed the naive diagonalisation of HiPPO.
For \(A\in\mathbb{C}^{N\times N}\) define \(e^{At}:=\sum_{k\ge0}(At)^k/k!\), convergent for every \(A\) and \(t\) since the series is dominated by \(e^{\|A\||t|}\). Three properties, each provable straight from the series:
Property 3 is small and load-bearing. It says the exponential does not see the basis, which is the whole content of Exercise 0.1 in the companion notes: \((A,B,C)\) and \((V^{-1}AV,V^{-1}B,CV)\) have the same impulse response \(Ce^{At}B\), hence define the same operator on inputs.
If \(A\) has \(N\) independent eigenvectors then \(A=V\Lambda V^{-1}\) and \(e^{At}=Ve^{\Lambda t}V^{-1}\), reducing a matrix function to \(N\) scalar ones. That is why "diagonalise it" is the reflex. Three refinements matter.
Not every matrix is diagonalisable, but the exceptional set — a repeated eigenvalue that is defective — is a proper algebraic subvariety, hence of measure zero. So "almost every matrix is diagonalisable over \(\mathbb{C}\)" is genuinely-almost rather than secretly-always, and it is doing real work in the diagonal turn of S4D and DSS.
Every matrix is unitarily triangularisable (Schur): \(A=QTQ^*\) with \(Q\) unitary and therefore perfectly conditioned. File this as the safe fallback that numerical linear algebra actually uses.
Normality is the dividing line. Call \(A\) normal if \(AA^*=A^*A\). The spectral theorem: \(A\) is normal exactly when it is diagonalisable by a unitary \(V\). Symmetric, skew-symmetric and orthogonal matrices are normal; a triangular matrix with all its mass on one side is typically as far from normal as a matrix gets. HiPPO-LegS is of the latter kind — and that is not incidental to its usefulness.
Let \(A=V\Lambda V^{-1}\) be diagonalisable and \(\kappa(V)=\|V\|\,\|V^{-1}\|\). Every eigenvalue \(\mu\) of \(A+E\) satisfies \(\min_j|\mu-\lambda_j|\le\kappa(V)\|E\|\).
The proof is three lines and worth doing: if \(\mu\notin\operatorname{spec}(A)\) then \((\Lambda-\mu I)^{-1}V^{-1}EV\) has an eigenvalue \(1\), so its norm is at least one; bound the product of norms. Read the theorem as a budget. Floating point guarantees \(\|E\|\approx\varepsilon\|A\|\) with \(\varepsilon\approx2^{-53}\), so eigenvalues are trustworthy to about \(\kappa(V)\varepsilon\|A\|\). For a normal matrix \(\kappa(V)=1\) and you lose nothing. For HiPPO-LegS, S4 Lemma 3.2 computes \(V\) in closed form and finds entries of size \(2^{4N/3}\); at \(N=64\) that is \(2^{85}\), and the budget was exhausted hundreds of orders of magnitude ago. The theorem "\(A\) is diagonalisable" is true and unusable in the same breath, and both halves need saying.
Having met the previous paragraph one is tempted to conclude that non-normal matrices are simply bad. They are inconvenient, but the inconvenience buys something. If \(A\) is normal with spectrum in the open left half-plane then \(\|e^{At}\|\) decays monotonically. If \(A\) is non-normal, \(\|e^{At}\|\) can grow, sometimes by orders of magnitude, before it decays. This transient growth is invisible in the spectrum; it is described by the pseudospectrum instead.
Fig. 1.4 — At \(\gamma=0\) the matrix is normal, the two curves coincide, and the perturbation bound is tight and tiny. Raise \(\gamma\) and the true norm climbs to a peak that the spectrum gives no hint of, while \(\kappa(V)\) — and with it the eigenvalue error budget — grows in step. Bringing \(\lambda_2\) toward \(\lambda_1\) makes both effects far worse, because the two eigenvectors are becoming parallel. Transient growth and ill-conditioned eigenvectors are the same phenomenon seen twice.
The point for us: a system whose state must retain a long history cannot be a set of independently decaying scalars, because independent scalars forget at their own fixed rates and interact not at all. The transfer of information between state coordinates — the thing that lets coordinate \(n\) still hold a trace of an event coordinate \(0\) absorbed long ago — is exactly what off-diagonal, non-normal structure buys. HiPPO-LegS has spectrum \(\{-1,\dots,-N\}\), which looks like fast forgetting, and yet its gradient norms decay like \(\Theta(1/t)\) rather than exponentially. The resolution is non-normality: the memory lives in the coupling, not in the eigenvalues.
HiPPO's matrix is worth its non-normality; its non-normality is what makes it uncomputable; so the field kept the spectrum (S4D, DSS, Mamba: diagonal \(A\)) and threw the coupling away. That trade is the most interesting open question in the companion notes' Parts 04–05, and it is a linear-algebra question, not a machine-learning one.
Multiply \(\dot x=Ax+Bu\) by the integrating factor \(e^{-At}\) and the left side becomes an exact derivative, \(\frac{d}{dt}\big(e^{-At}x\big)=e^{-At}Bu\). Integrating from \(0\) to \(t\):
With \(x(0)=0\) and \(D=0\) the output is \(y=h*u\) with impulse response \(h(t)=Ce^{At}B\). The name is literal: feed \(u=\delta\) and \(h\) comes back. That is the first description, the system as a convolution; the differential equation itself is the second, the system as a recurrence. The identity between them is not a modelling choice, it is the solution formula — and the entire computational drama of the companion notes follows from the fact that the two have different costs on different hardware.
Take Laplace transforms. With \(x(0)=0\), \(\dot x=Ax+Bu\) becomes \(s\hat x=A\hat x+B\hat u\), so \(\hat y = H(s)\hat u\) with
By Cramer's rule \((sI-A)^{-1}=\operatorname{adj}(sI-A)/\det(sI-A)\), so \(H\) is a rational function whose denominator divides the characteristic polynomial of \(A\) and whose numerator has strictly smaller degree when \(D=0\). Its poles are eigenvalues of \(A\) — possibly not all of them, a subtlety that becomes the entire point in Part 03.
A strictly proper rational function of degree \(N\) is determined by \(2N\) coefficients: \(N\) in the numerator, \(N\) in the monic denominator. The triple \((A,B,C)\) carries \(N^2+2N\). The discrepancy is the subject of §3.4.
Fig. 2.2 — Three views of one system, redrawn together. Pushing \(\sigma\) toward zero makes the response long-lived and the resonant peak sharp — long memory and narrow bandwidth are the same statement. Setting \(\omega=0\) leaves a pure decay: a low-pass filter with no record of when anything happened, which is precisely the regime Mamba-2 restricts itself to and Mamba-3 escapes. Dragging the zero across the imaginary axis leaves \(|H|\) nearly unchanged while inverting the early transient — a reminder that magnitude alone does not determine the system.
The system is internally stable when \(e^{At}\to0\), which holds exactly when every eigenvalue of \(A\) has negative real part (\(A\) Hurwitz). It is BIBO stable when \(h\in L^1\), which holds when the poles of \(H\) lie in the open left half-plane. The two notions differ exactly when a pole is cancelled — an unstable mode invisible from the input–output map, which Part 03 will name.
\(A\) is Hurwitz iff for every positive definite \(Q\) the equation \(A^\top P+PA+Q=0\) has a unique positive definite solution, namely \(P=\int_0^\infty e^{A^\top t}Qe^{At}\,dt\).
The integral formula is the existence proof: differentiate under the integral. Two special cases of this equation — the Gramians of §3.2 — carry most of the structural information about a linear system, and the same equation reappears in Part 06 as the covariance recursion of a noisy system. In discrete time replace the left half-plane by the unit disc and the equation by \(\bar A^\top P\bar A-P+Q=0\); Part 05 is the study of maps carrying the first geometry to the second.
This is the mathematical core of the page. Realisation theory answers three questions at once — what determines the state, how large it must be, and how much freedom is left over — and the answers are Hankel rank, McMillan degree and \(\mathrm{GL}(N)\). All three reappear, renamed, in the modern literature.
Work in discrete time, \(x_k=Ax_{k-1}+Bu_k\), \(y_k=Cx_k\). Unrolling from \(x_{-1}=0\) gives \(y_k=\sum_{i\le k}CA^{k-i}Bu_i\). The numbers \(h_j:=CA^jB\) are the Markov parameters, and they determine the system's action completely. Arrange them so that the row index counts steps into the future and the column index steps into the past:
Constant along antidiagonals — the defining shape of a Hankel matrix, and not decoration. This matrix is the operator mapping past inputs to future outputs, with the present at the corner. Its rank measures how much of the past the future can still see, which by Part 00 is the size of the state.
The sequence \((h_j)\) is generated by a finite-dimensional linear system if and only if \(\operatorname{rank}\mathcal{H}<\infty\). In that case the minimal state dimension equals \(\operatorname{rank}\mathcal{H}\), and equals the degree of \(H(z)=\sum_j h_jz^{-j-1}\) in lowest terms.
One direction is immediate, and it is the same computation that returns in §3.5 as semiseparability. Define the extended observability and reachability matrices
Then \(\mathcal{H}_{ij}=CA^{i+j}B=(CA^i)(A^jB)\), that is \(\mathcal{H}=\mathcal{O}\mathcal{R}\): a product of an \(\infty\times N\) and an \(N\times\infty\) matrix, so \(\operatorname{rank}\mathcal{H}\le N\) always.
The factorisation has a degenerate case: either factor may itself be rank-deficient. By Cayley–Hamilton the column space of \(\mathcal{R}\) is already spanned by its first \(N\) blocks, so we may test with the finite matrices \(\mathcal{R}_N=(B\ AB\ \cdots\ A^{N-1}B)\) and \(\mathcal{O}_N\). The system is reachable if \(\operatorname{rank}\mathcal{R}_N=N\) — every state can be reached from the origin by some input — and observable if \(\operatorname{rank}\mathcal{O}_N=N\) — every nonzero initial state eventually shows up at the output.
The continuous-time versions are integral rather than algebraic:
which for Hurwitz \(A\) solve \(AW_c+W_cA^\top+BB^\top=0\) and \(A^\top W_o+W_oA+C^\top C=0\) — the Lyapunov equation of §2.3, twice. Reachability is \(W_c\succ0\), observability \(W_o\succ0\). These are not merely tests: Part 04 shows they measure how much each direction of the state matters.
Every linear system is similar to one whose state splits into four blocks: reachable-and-observable, reachable-only, observable-only, and neither. The transfer function depends only on the first.
So a realisation is minimal iff it is both reachable and observable, and a non-minimal one carries coordinates that are either unreachable from the input or invisible at the output — dead weight that still costs memory and FLOPs at inference. There is a lesson here for architectures whose state size is chosen by sweep rather than by measurement.
The converse direction of the theorem is an algorithm, and it is short enough to state in full. Take a large finite block \(\mathcal{H}_0\) of (3) and the same block shifted by one, \(\mathcal{H}_1\). Compute a rank-\(r\) SVD \(\mathcal{H}_0=U\Sigma V^\top\) and split the singular values evenly between the factors, \(\mathcal{O}=U\Sigma^{1/2}\), \(\mathcal{R}=\Sigma^{1/2}V^\top\). Then read off
The middle identity is the shift-invariance \(\mathcal{O}A=\mathcal{O}^{\uparrow}\) solved in the least-squares sense. That is the entire method — fifteen lines of NumPy, and the figure below runs it on data you control.
Fig. 3.3 — With clean data and \(r=n\) the reconstruction error is \(10^{-14}\): the algorithm is exact, and it never saw the matrices, only the output. Set \(r<n\) and the error settles at roughly \(\sigma_{r+1}\), which is Part 04's theorem arriving early. Set \(r>n\) and nothing breaks but nothing improves — the extra coordinates are unreachable or unobservable, and the Kalman decomposition says the map cannot see them. Add noise and watch the singular-value cliff turn into a shelf whose height is the noise level: below it, order is no longer decidable.
import numpy as np
def ho_kalman(h, r, R=20):
"""Recover (A,B,C) of order r from Markov parameters h[0..2R]."""
H0 = np.array([[h[i + j] for j in range(R)] for i in range(R)])
H1 = np.array([[h[i + j + 1] for j in range(R)] for i in range(R)])
U, s, Vt = np.linalg.svd(H0) # the only nontrivial step
U, s, Vt = U[:, :r], s[:r], Vt[:r]
O = U * np.sqrt(s) # split Sigma evenly …
Rc = np.sqrt(s)[:, None] * Vt # … between the two factors
A = np.linalg.pinv(O) @ H1 @ np.linalg.pinv(Rc)
return A, Rc[:, 0], O[0] # A, B, C
# The state sequence is estimated before the matrices are: no iteration,
# no local minima, no initialisation. Subspace identification (N4SID)
# is this procedure generalised to arbitrary inputs.
If \((A_1,B_1,C_1)\) and \((A_2,B_2,C_2)\) are minimal realisations of the same input–output map, there is a unique invertible \(V\) with \(A_2=V^{-1}A_1V\), \(B_2=V^{-1}B_1\), \(C_2=C_1V\).
The proof is the same factorisation once more: both satisfy \(\mathcal{O}_i\mathcal{R}_i=\mathcal{H}\) with full rank \(N\); set \(V=\mathcal{R}_1\mathcal{R}_2^{+}\) and verify. Now count. The triple has \(N^2+2N\) parameters, the transfer function \(2N\); the discrepancy is \(N^2=\dim\mathrm{GL}(N)\), and the theorem says the discrepancy is the orbit of the conjugation action. A gauge group, in the physicist's sense: a redundancy of description that no measurement can resolve.
Fig. 3.4 — The two matrices share no entry, no sparsity pattern and no symmetry, and produce the same impulse response to \(10^{-14}\) — until \(\kappa(V)\) passes about \(10^{8}\), where the agreement degrades one digit per decade and finally collapses. Both facts matter: the exact theory says every \(V\) is free, and floating point says only the well-conditioned ones are. That gap is the whole of S4 §4.1, reproduced here in six dimensions instead of sixty-four.
Because the redundancy is exactly \(\mathrm{GL}(N)\), one may impose any \(N^2\)-dimensional normalisation on \(A\) without losing a single degree of freedom the input–output map could have distinguished. Companion form, modal (diagonal) form, balanced form: all free. The diagonal turn of S4D and DSS is therefore not an approximation of the dense parameterisation — generically it is a choice of gauge.
What is lost is not expressivity but interpretation: a specific \(\Lambda\) no longer corresponds to a specific measure and basis, so the HiPPO initialisation must be transplanted rather than derived. That is the honest statement of the trade, and the answer to Exercise 5.1 of the companion notes.
We can now retire the last genuinely mysterious definition in the Mamba-2 paper. The input–output map of a discrete linear system is a lower-triangular matrix \(M\) with \(M_{ji}=C_jA_j\cdots A_{i+1}B_i\), and \(M\) is called \(N\)-semiseparable when every submatrix contained in the lower triangle has rank at most \(N\). Here is the proof, in the time-varying case, in one line. Fix rows \(j\in\{j_0..j_1\}\) and columns \(i\in\{i_0..i_1\}\) with \(i_1\le j_0\); then
a product of a \((\cdot\times N)\), an \((N\times N)\) and an \((N\times\cdot)\) factor. Rank at most \(N\). \(\square\)
That is all semiseparability is: the statement \(\mathcal{H}=\mathcal{O}\mathcal{R}\) of §3.1, applied not once at the origin but at every cut point along the sequence. Two payoffs follow at once, and they are the two halves of Mamba-2. Algorithmically, an off-diagonal block need never be materialised — it is stored and applied as its two thin factors, and the "running state" the chunked algorithm carries between chunks is literally the middle term above. Conceptually, linear attention with a decay mask has the same rank structure by construction, which is why the duality theorem exists at all; Mamba-2's Theorem 5.2 — efficient autoregressive masked attention forces a semiseparable mask — is the converse of the paragraph you have just read.
LSSL's \((p,q)\)-quasiseparability (Eidelman–Gohberg) bounds submatrices lying strictly off the diagonal; Mamba-2's \(N\)-semiseparability bounds submatrices lying on or below it. The difference is whether the diagonal is included, which shifts the rank counts by one and nothing else. Both are instances of what numerical linear algebra calls rank-structured matrices.
Realisation theory says the minimal \(N\) is \(\operatorname{rank}\mathcal{H}\). In practice that rank is either huge or infinite, and the real question is how well a state of size \(r<N\) can do. This has a complete answer, and it is the classical theory that the "state size versus recall" experiments in the modern literature are re-measuring empirically.
Both Gramians transform under \(x\mapsto V^{-1}x\), but in opposite directions: \(W_c\mapsto V^{-1}W_cV^{-\top}\) and \(W_o\mapsto V^\top W_oV\). So the product \(W_cW_o\) transforms by similarity, and its eigenvalues are invariants of the system — they do not depend on the gauge choice of §3.4. Define the Hankel singular values
They are the singular values of the Hankel operator, which is the cleaner way to see the invariance: \(\mathcal{H}=\mathcal{O}\mathcal{R}\) with \(W_o=\mathcal{O}^*\mathcal{O}\) and \(W_c=\mathcal{R}\mathcal{R}^*\), so \(\mathcal{H}^*\mathcal{H}\) and \(W_cW_o\) are similar. Moore (1981) showed one can always choose a basis in which \(W_c=W_o=\operatorname{diag}(\sigma_i)\) — the balanced realisation, in which every coordinate is equally easy to excite and to observe, and \(\sigma_i\) says how much it contributes.
Truncating the balanced realisation to its leading \(r\) coordinates preserves stability and satisfies \(\;\|H-H_r\|_{\mathcal{H}^\infty}\le 2\sum_{i>r}\sigma_i\). Moreover no degree-\(r\) system can do better than \(\sigma_{r+1}\).
Read as guidance for architecture: the useful state size is set by the decay of the Hankel singular values of the operator you want to represent. Geometric decay means a small state is provably enough and doubling \(N\) buys exponentially little. Slow decay means no small state suffices — and the deficit is a theorem, not a training problem. The figure makes the two regimes sit side by side.
Fig. 4.1 — The single pole has exactly one nonzero \(\sigma\): a state of size 1 is not an approximation, it is the truth. Four resonant modes give four plateaus and then a cliff. HiPPO decays steadily — a smooth trade, which is why \(N\) is a genuine knob there. The delay line — a system that reproduces its input verbatim \(n\) steps later, i.e. exact recall — has \(\sigma_1=\cdots=\sigma_n=1\): a perfectly flat spectrum, no direction is more important than any other, and truncation buys nothing at any \(r<n\). That flat spectrum is the theorem behind every recall benchmark a fixed-state model loses.
Companion notes, Part 07.4: state size \(N=16\to64\to256\) improves MQAR recall monotonically, and Mamba-2 spends its restriction-bought speed on state. That monotone curve is a Hankel singular value spectrum being sampled. It is also why hybrid attention/SSM stacks persist: attention is the mechanism that gives up on a finite \(N\) altogether.
Three classical answers, worth naming because the modern framings map onto them. Realisation from exact data is §3.3; with noisy data it becomes the Eigensystem Realisation Algorithm (Juang–Pappa 1985), still standard in structural dynamics. Subspace identification (Van Overschee–De Moor's N4SID, 1994) generalises it to arbitrary inputs by projecting future outputs onto the row space of past data — the state sequence is estimated before the matrices are, geometrically, with no iteration and no local minima. Prediction error methods instead maximise the likelihood, which for a linear-Gaussian model is computed by the Kalman filter of Part 07; this is the framing closest to deep learning.
The "test-time regression" lens that Mamba-3 §5.4 argues against is a fourth position: read the state update as an online least-squares fit refreshed per token. It is a good lens for the delta-rule branch, whose update is a rank-one Householder correction, and a poor one for the discretisation-derived branch, which has no notion of step size in that language. Knowing the classical taxonomy makes clear that these are four different answers to "where do the matrices come from", not four descriptions of one answer.
The companion notes derive \(\bar A\) for four schemes and observe that gating falls out of one of them. This part supplies the theory those computations sit in, because the choices are not arbitrary and the classical names carry results.
For a linear system every one-step method reduces to a stability function \(R\) with \(\bar A=R(\Delta A)\), and the order of the method is the order to which \(R(z)\) matches \(e^z\) at the origin. The four schemes are four choices of \(R\):
| scheme | R(z) | order | stability |
|---|---|---|---|
| forward Euler | 1 + z | 1 | conditional: \(|1+z|<1\) |
| backward Euler | (1 − z)⁻¹ | 1 | A-stable and L-stable |
| bilinear / Tustin | (1 + z/2)/(1 − z/2) | 2 | A-stable, not L-stable |
| zero-order hold | ez | exact | exact |
Call a method A-stable if \(|R(z)|<1\) whenever \(\operatorname{Re}z<0\): it contracts exactly when the true system does, at every step size. The bilinear case deserves its own name — \(z\mapsto(1+z/2)/(1-z/2)\) is a Cayley transform, a Möbius map carrying the open left half-plane bijectively onto the open unit disc and the imaginary axis onto the unit circle. That is the sharpest possible statement of stability preservation: not "stable maps to stable" but "the two stability regions are conformally the same region". Exercise 1.2 of the companion notes is this fact in coordinates.
First. A stable \(s\)-step linear multistep method has order at most \(s+1\) (\(s\) odd) or \(s+2\) (\(s\) even). Second. An A-stable linear multistep method has order at most \(2\) — and among those, the trapezoidal rule has the smallest error constant.
So the bilinear transform is not one option among many: in the multistep world it is the optimal A-stable choice, which is a real reason S4 uses it rather than a matter of taste. One caveat has teeth, though. A-stable is not L-stable: write \(R(\infty)=\lim_{|z|\to\infty}R(z)\). For the bilinear map \(|R(\infty)|=1\), so a very stiff mode — a very negative \(\lambda\), or a large step — is not damped but flipped in sign each step, oscillating at Nyquist instead of dying. Backward Euler and ZOH both have \(R(\infty)=0\). This is one honest technical reason the field moved from bilinear (S4) to ZOH (S4D, S5, Mamba) once \(\Delta\) became learned and free to grow.
Fig. 5.1 — Forward Euler's region is a disc of radius 1 about \(-1\): stable poles fall outside it as soon as \(\Delta|\lambda|>2\), and the readout turns red. The other three cover the entire left half-plane, which is A-stability drawn rather than asserted. Watch the L-stability readout as you push \(\operatorname{Re}\lambda\) far left: bilinear's \(|R|\) creeps back toward 1 — the stiff mode survives, ringing, instead of dying — while backward Euler and ZOH send it to zero. The right panel shows the resulting step response so the failure is visible in time as well as in the plane.
ZOH is not a quadrature rule at all; it is an exact solution under an assumption about the input. If \(u\) is constant on the interval, variation of constants integrates exactly:
Introduce the \(\varphi\)-functions of the exponential-integrator literature, \(\varphi_1(z)=(e^z-1)/z\) and \(\varphi_2(z)=(e^z-1-z)/z^2\). Then the ZOH input matrix is exactly \(\bar B=\Delta\,\varphi_1(\Delta A)B\) — an identity worth internalising, because it places Mamba's shipped update inside a family with a literature.
Mamba-1 and Mamba-2 use \(\bar B_t=\Delta_tB_t\), which is \(\Delta\varphi_1(\Delta A)B\) with \(\varphi_1\) replaced by its value at the origin — exponential Euler, first order in \(\Delta\), exact only as \(\Delta\to0\). Mamba-3's exponential-trapezoidal scheme replaces the one-point rule by a weighted two-point rule on the same integral, which in the classical taxonomy is an ETD2-type method. Hochbruck and Ostermann's Acta Numerica survey is the reference — and it will tell you that the genuinely second-order weights involve \(\varphi_2\), not the free convex weight \(\lambda_t\) that Mamba-3 learns. Which is exactly the companion notes' observation that the released model does not satisfy the hypothesis of its own accuracy theorem.
The identity of LSSL Lemma 3.1 — that \(\sigma(z)\) is a step size — is backward Euler on the leaky integrator \(\dot x=-x+u\) with \(\Delta=e^z\). Nothing about it is specific to machine learning: the implicit-Euler update of a first-order lag is a convex combination of old state and new input with weight \(\Delta/(1+\Delta)\), and reparameterising the step logarithmically turns that weight into a logistic function. What is specific to machine learning is the choice among quadratures, since each scheme gives a different curve with the same saturating shape. Part 07 will add a third member to the family, derived from a completely different principle, and it will land on top of the other two.
Fig. 5.3 — Left: the approximation \(\bar B=\Delta B\) is within a per cent for \(\Delta\lesssim 0.02\), off by 58% at \(\Delta=1\) and by 216% at \(\Delta=3\). Note which regime that is: large \(\Delta\) is the open gate, the token the model decided to absorb, so the error is largest exactly where the model is paying attention. Right: three gate curves derived from three unrelated principles — implicit Euler, exact hold, and optimal filtering (Part 07) — plotted against a log signal-to-noise axis. They very nearly coincide. Saturating convex-combination gates are not a design; they are what the mathematics keeps producing.
Take the linear system driven by noise: \(x_k=Ax_{k-1}+Bu_k+w_k\) and \(y_k=Cx_k+v_k\), with \(w_k\sim\mathcal{N}(0,Q)\), \(v_k\sim\mathcal{N}(0,R)\) independent across time. Everything is jointly Gaussian, so everything is determined by means and covariances, and both propagate in closed form: \(\operatorname{Cov}(x_k)=A\operatorname{Cov}(x_{k-1})A^\top+Q\) — the discrete Lyapunov equation of §2.3, once again, now in dynamic form.
If \(A\) is stable the covariance converges to the unique stationary covariance \(P_\infty\) solving \(P=APA^\top+Q\), and the state becomes a stationary Gaussian process whose second-order statistics are fixed by \((A,Q)\) alone. In continuous time the analogue is the linear SDE \(dx = Ax\,dt + G\,dW\) — an Ornstein–Uhlenbeck process when \(A\) is a stable scalar — with stationary covariance solving \(AP+PA^\top+GG^\top=0\). That is the same Lyapunov equation as the reachability Gramian of §3.2, and the coincidence is not one: the Gramian is the stationary covariance of the system driven by white noise, which is why a direction that is hard to reach is also a direction the noise rarely visits.
Wiener's 1949 theory had already solved optimal filtering by spectral factorisation, and it has three defects Kalman's formulation removes: it assumes stationarity, it needs the whole observation record, and it returns a transfer function rather than a recursion. Kalman's move — and the reason the 1960 paper is one of the most cited in engineering — was to put a state in the middle. Once the signal is generated by a finite-dimensional Markov model, the optimal estimate can be maintained recursively in fixed memory. The philosophical content is exactly Part 00: the state is a sufficient statistic, so an estimator that tracks a distribution over it need never revisit the past.
If \(\binom{a}{b}\sim\mathcal{N}\big(\binom{\mu_a}{\mu_b}, \left(\begin{smallmatrix}\Sigma_{aa}&\Sigma_{ab}\\ \Sigma_{ba}&\Sigma_{bb}\end{smallmatrix}\right)\big)\) with \(\Sigma_{bb}\succ0\), then \(a\,|\,b\sim\mathcal{N}\big(\mu_a+\Sigma_{ab}\Sigma_{bb}^{-1}(b-\mu_b),\; \Sigma_{aa}-\Sigma_{ab}\Sigma_{bb}^{-1}\Sigma_{ba}\big)\).
Proof, in the form worth remembering: set \(\tilde a=a-\Sigma_{ab}\Sigma_{bb}^{-1}b\) and check \(\operatorname{Cov}(\tilde a,b)=0\). For jointly Gaussian variables uncorrelated implies independent, so conditioning on \(b\) leaves \(\tilde a\) alone; solve for \(a\). The Schur complement in the covariance is the residual variance after that projection — and every appearance of the Woodbury identity in this field is a cousin of this computation.
Prediction is the model applied to the current belief; the update is the lemma:
\(\nu_k\) is the innovation — the part of the observation that was not predictable — and \(K_k\) the Kalman gain. In implementations one prefers the Joseph form \(P=(I-KC)P(I-KC)^\top+KRK^\top\), manifestly symmetric positive semidefinite; the naive form loses definiteness after enough steps, and the Apollo guidance computer ran a square-root filter for precisely this reason.
There is a second derivation in one paragraph, and it is the one to keep. Work in the Hilbert space of finite-variance random variables with \(\langle X,Y\rangle=\mathbb{E}[XY]\). The conditional expectation is the orthogonal projection of \(x_k\) onto the span of the observations; the innovations are, by construction, an orthogonal basis of that span (Gram–Schmidt in time order). Projection onto an orthogonal basis is a sum of one-dimensional projections, which is why the filter is recursive: one more observation adds one more basis vector and hence one more correction term \(K_k\nu_k\). No Gaussian assumption is needed for this version — it gives the best linear estimator regardless of distribution.
Take \(N=1\), \(A=C=1\), process noise \(q\), observation noise \(r\). Then \(K_k=P_{k|k-1}/(P_{k|k-1}+r)\in(0,1)\) and
An exponential moving average with a time-varying weight — a leaky integrator with a gate. Compare §5.3, where the convex weight was \(\Delta/(1+\Delta)\); here it is \(P/(P+r)\). The steady-state gain solves a quadratic, \(K_\infty=\big(\sqrt{(q/r)^2+4q/r}-q/r\big)/2\), increasing in \(q/r\): the more the world moves relative to how noisy your sensor is, the more you weight the new observation. That is a derived forget gate, with an interpretation for its value — and it is the third curve in Fig. 5.3.
Here is the observation I would most like you to take from this page, because it locates Mamba precisely against sixty years of prior art. The Kalman filter's coefficients change with time, so the filter is a linear time-varying recurrence, exactly like Mamba's. But look at (5): the gain involves \(A,C,Q,R\) and nothing else. It does not involve \(y\). In the linear-Gaussian setting the entire gain schedule can be computed offline, before a single observation arrives. The filter adapts to how long it has been running and to the noise model — never to the values it observes.
Fig. 7.4 — Move the seed, or press the button to swap in a signal with a different amplitude, frequency and noise draw. The estimate changes completely; the two gain curves stay bit-for-bit identical, and the readout prints their maximum difference as exactly zero. Raising \(q/r\) lifts the whole schedule — the filter trusts the data more — but still without consulting it.
LTI (S4): fixed coefficients — convolutional, FFT-trainable.
LTV with a precomputable schedule (the Kalman filter; also any positional
schedule, such as vanilla RoPE): coefficients vary with \(t\) but not with the data. Still no
per-token decisions — and still fully parallelisable, since the schedule is known in advance.
Selective (Mamba): coefficients are functions of the observed token. This is
what breaks the fixed filter, and it is a genuinely different regime.
Where does data dependence enter classically? Exactly where the model stops being linear-Gaussian. The extended Kalman filter evaluates its Jacobians at the current estimate, so its gain depends on the data; the particle filter is data-dependent throughout. Selectivity is not an invention of 2023 — it is the classical signature of a nonlinear filtering problem, imported into a linear recurrence by letting a network compute the coefficients.
The same lens explains a result in the companion notes that otherwise looks like a curiosity: standard RoPE scores 1.56% on parity while a data-dependent rotation scores 100%. A fixed frequency schedule is a precomputable LTV recurrence; it can encode position and nothing else. That is not a fact about rotations — it is a fact about which of the three regimes above you are in.
Kalman answers "what should the state be" by positing a generative model and computing the optimal estimate. HiPPO answers the same question with no generative model at all, by positing an approximation criterion. This part builds the approximation theory, because otherwise HiPPO's matrix is a magic array of square roots.
Let \(\mu\) be a measure with all moments finite and give polynomials the inner product \(\langle f,g\rangle_\mu=\int fg\,d\mu\). Gram–Schmidt on \(1,Y,Y^2,\dots\) produces orthonormal \(p_n\) with \(\deg p_n=n\).
\(Y\,p_n(Y)=a_np_{n+1}(Y)+b_np_n(Y)+a_{n-1}p_{n-1}(Y)\) for real \(a_n>0\). Conversely, any sequence satisfying such a recurrence is orthonormal for some positive measure.
The forward direction is one line of orthogonality: \(Yp_n\) has degree \(n+1\) so it expands in \(p_0..p_{n+1}\), and \(\langle Yp_n,p_k\rangle=\langle p_n,Yp_k\rangle=0\) whenever \(k<n-1\). Three terms survive, so multiplication is tridiagonal in this basis — a Jacobi matrix, the ancestor of every "structured \(A\)" in the literature.
The fact that does the work is about differentiation, and it is one line of calculus: if \(p\) has degree \(n\) then \(p'\) has degree at most \(n-1\). So in an expansion of \(\partial_tp_n\), only \(p_0,\dots,p_{n-1}\) can appear. Now take HiPPO's construction — \(x_n(t)=\int u(Y)p_n(t,Y)\omega(t,Y)dY\), the coefficients of the \(L^2(\mu^{(t)})\)-projection of the history. Differentiating under the integral produces a boundary term (which supplies \(Bu(t)\)), a term in \(\partial_tp_n\) that closes into \(x_0..x_{n-1}\) by the degree fact, and a term in \(\partial_t\omega\) that closes when the measure's time dependence can be re-expressed through the measure. The result is \(\dot x=A(t)x+B(t)u\) with triangular \(A\), and the triangularity is forced by calculus rather than chosen.
A translated window (LegT) carries a horizon hyperparameter \(\theta\); a scaled window (LegS, \(\omega^{(t)}=\tfrac1t\mathbf{1}_{[0,t]}\)) grows with the history and is equivariant to time dilation — replay the input at half speed and the state trajectory is the same, replayed at half speed. That equivariance is why LegS has no timescale hyperparameter, and it is a theorem (HiPPO Prop. 3), not a heuristic.
Projection onto the first \(N\) orthogonal polynomials is the best degree-\((N-1)\) approximation in \(L^2(\mu)\), so classical approximation theory applies directly: Jackson-type bounds give algebraic rates for functions of finite smoothness (\(O(N^{-1/2})\) in HiPPO's weighted setting for Lipschitz inputs, \(O(N^{-k})\)-type for \(k\) derivatives), while Bernstein-type bounds give \(O(\rho^{-N})\) — geometric — for functions analytic in a Bernstein ellipse. The figure measures all three regimes on inputs you choose.
Fig. 8.3 — The analytic signal reaches \(10^{-14}\) by \(N\approx30\): geometric convergence, machine precision, done. The kink gives roughly \(N^{-1.5}\) and the step roughly \(N^{-0.5}\) — the latter being exactly the worst-case rate HiPPO Prop. 6 advertises. This is the resolution of Exercise 2.3 of the companion notes: the bound is a worst case over a rough function class, and real inputs are smoother than Lipschitz, so a fixed-size state does far better than the theorem promises. Note also that the coefficient stem plot is the state vector: that, and nothing else, is what the system remembers.
| Kalman filter | HiPPO | |
|---|---|---|
| what is assumed | a generative model \(A,C,Q,R\) | a measure \(\mu^{(t)}\) and a degree bound |
| what is optimised | mean-squared error of the estimate | \(L^2(\mu^{(t)})\) error of the reconstruction |
| what the state is | the posterior mean and covariance | the projection coefficients |
| what is derived | the gain schedule \(K_k\) | the matrices \(A,B\) in closed form |
| what is learned | nothing (or \(Q,R\), by likelihood) | nothing — later, only how hard to lean on it, via \(\Delta_t\) |
| failure mode | model mismatch | inputs outside the smoothness class |
Both are answers to "what should the state be", derived rather than searched. That both are derivable, and that the derivations look nothing alike, is the strongest available evidence that the question is well posed.
The last body of prerequisite material is algorithmic. A causal LTI system in discrete time is multiplication by a lower-triangular Toeplitz matrix \(T_{ki}=h_{k-i}\). Toeplitz matrices are not diagonalised by the DFT, but circulant ones are: \(C=F^{-1}\operatorname{diag}(Fc)F\). Embedding an \(L\times L\) Toeplitz matrix in a \(2L\times2L\) circulant is therefore the standard trick, and it turns a convolution into two forward FFTs, a pointwise product and one inverse FFT. That is the entire computational advantage of the convolutional view — and it is available only when there is a single fixed kernel to transform, which is the precise sense in which selectivity destroys it.
The kernel is a Krylov sequence \(h_i=CA^iB\), whose generating function is \(\sum_i CA^iBz^i = C(I-Az)^{-1}B\). Truncating at \(L\) terms and using \((I-Az)\sum_{i<L}(Az)^i=I-(Az)^L\) gives the exact truncated form; evaluating at the \(L\)-th roots of unity is the DFT of the kernel. The structural gain is that powers of a matrix have become one inverse — and inverses respect low-rank corrections (Woodbury) while powers do not. S4's algorithm is that observation plus bookkeeping.
Three structured families appear in that bookkeeping: Vandermonde \(V_{ij}=z_i^j\), what the kernel becomes when \(A\) is diagonal; Cauchy \(M_{ij}=1/(\omega_i-\lambda_j)\), what the resolvent becomes when \(A\) is diagonal; and Toeplitz/Hankel, the convolution operator itself. All three have low displacement rank — there are simple operators \(L,R\) for which \(M-LMR\) has small rank — and that is the unifying theory (Kailath, Gohberg, Olshevsky) which lets fast algorithms transfer between the families. When the companion notes say S4's algorithm is trustworthy where LSSL's was not, this forty-year literature is the reason.
Fig. 9.1 — Each matrix is full rank, and each has a displacement of rank at most two. That single number is what every fast algorithm in this area consumes: it is why an \(n\times n\) Cauchy matrix–vector product costs \(O(n\log^2 n)\) rather than \(O(n^2)\), and why S4's kernel evaluation can be converted between Cauchy and Vandermonde form without losing the structure. S4's algorithm is a walk through this zoo, and it is stable because the zoo is well studied.
Two more items complete the toolbox. An affine recurrence \(h_t=a_th_{t-1}+b_t\) is the prefix scan of the monoid \((a_2,b_2)\circ(a_1,b_1)=(a_2a_1,a_2b_1+b_2)\), whose associativity is a one-line check; Blelloch's up-sweep/down-sweep computes all prefixes in \(O(\log L)\) depth (Martin and Cundy brought this to linear RNNs in 2018, and it is the algorithmic hinge of the whole field — the reward for giving up per-step nonlinearity is parallelism over the sequence). And arithmetic intensity: FLOPs performed per byte moved. The roofline model puts a ridge at peak/bandwidth — about \(989/3.35\approx295\) ops per byte for an H100 in bf16 — and an algorithm far below it is memory-bound, so it can be made to do several times more arithmetic at almost no cost in wall-clock time. That sentence is the whole argument for Mamba-3's MIMO lift.
The mathematics above was developed by control theorists between roughly 1949 and 1985; the deep-learning line reuses it under different pressures. It is worth seeing both halves as one story, because the pattern is more informative than either half.
| era | the binding constraint | the response |
|---|---|---|
| 1940s–50s | no recursion: the optimal filter needs the whole record | Wiener and Kolmogorov solve the stationary problem by spectral factorisation |
| 1960–63 | online estimation, non-stationary, finite memory | Kalman puts a state in the middle; reachability, observability, minimality |
| 1966–85 | which state, and how much of it | Ho–Kalman from the Hankel matrix; Moore's balancing; Glover's error bounds |
| 1980s–90s | trainability: gradients across many steps | the vanishing-gradient diagnosis; LSTM's additive path; unitary RNNs |
| 2018–20 | parallelism: a sequential loop wastes the machine | drop the per-step nonlinearity, scan the affine recurrence; linear attention arrives from the other side |
| 2020–21 | what should \(A\) be? | HiPPO derives it from a projection; LSSL names the layer — and fails on conditioning |
| 2022– | throughput, then expressivity, then memory bandwidth | S4, the diagonal turn, selectivity, SSD, Mamba-3 — the companion notes |
Two episodes deserve a sentence each, because they are the ones the modern papers inherit directly. The vanishing gradient (Bengio, Simard and Frasconi 1994) is the observation that the gradient across \(T\) steps is a product of \(T\) Jacobians, so contraction — which stability requires — implies exponential gradient decay; every fix since, from LSTM's additive path to unitary RNNs' \(|\lambda|=1\), is a statement about the spectrum of the transition, and Part 01 is the language for them. And LSSL's failure is a conditioning failure, exactly the phenomenon §1.3 measures: a theorem correct in exact arithmetic, unusable in float64, which is the most instructive event in the whole sequence.
In each era the binding constraint was different — recursion, then minimality, then reduction, then trainability, then parallelism, then memory bandwidth. The mathematics did not change. What changed is which property of the same object was expensive. If you want to predict the next move in this field, the productive question is not "what is a better architecture" but "what is currently the expensive property", and that is a question about hardware and workload as much as about mathematics.
| classical name | modern name / use | here |
|---|---|---|
| impulse response, Markov parameters | the convolution kernel \(\mathcal{K}_L\) | §2.1, §3.1 |
| transfer function, McMillan degree | the \(2N\) identifiable parameters | §2.2, §3.4 |
| similarity / gauge freedom \(\mathrm{GL}(N)\) | licence for diagonal \(A\) (S4D, DSS) | §3.4 |
| Hankel factorisation \(\mathcal{H}=\mathcal{OR}\) | \(N\)-semiseparability, SSD chunking | §3.5 |
| Hankel singular values, balanced truncation | choosing \(N\); the limits of recall | §4.1 |
| Bauer–Fike, \(\kappa(V)\) | why HiPPO cannot be diagonalised in float64 | §1.3 |
| non-normality, transient growth | why coupling, not spectrum, holds memory | §1.4 |
| Cayley transform, Padé, A-stability | the bilinear discretisation of S4 | §5.1 |
| \(\varphi\)-functions, exponential integrators | ZOH; Mamba's \(\Delta B\); Mamba-3's trapezoid | §5.2 |
| backward Euler on a leaky integrator | the sigmoid gate (LSSL Lemma 3.1) | §5.3 |
| Kalman gain schedule | an LTV but non-selective recurrence | §7.4 |
| EKF: the gain depends on the estimate | selectivity, input-dependent \(\Delta_t\) | §7.4 |
| orthogonal polynomials, Favard | HiPPO's basis; the triangular \(A\) | §8.1–8.2 |
| Jackson / Bernstein rates | HiPPO Prop. 6, and why it is pessimistic | §8.3 |
| circulant diagonalisation, FFT | the convolutional training path | §9 |
| displacement rank: Vandermonde, Cauchy | S4's kernel evaluation | §9 |
| parallel prefix (Blelloch) | the selective scan | §9 |
| roofline, arithmetic intensity | Mamba-3's MIMO argument | §9 |
Read Part 00 of From the linear ODE to Mamba-3. It should now contain no step you cannot justify: the closed-form solution is §2.1 here, the two algorithms are §2.1 and §9, and the similarity invariance that its Exercise 0.1 asks you to verify is §1.1, property 3.
The single most useful thing to carry forward is the factorisation \(\mathcal{H}=\mathcal{O}\mathcal{R}\). It is the reason a state exists, the reason its size is what it is, the reason semiseparability holds, and the reason chunking works. Four apparently distinct results, one identity.
★ marks the four to do if you do only four. [hand] is pen and paper, [calc] a pocket calculator, [code] under twenty lines of NumPy. Every answer is checkable against a computation you can run or a statement proved above; several are checkable against the figures on this page.
Let \(h_j=CA^jB\) for \(A=\operatorname{diag}(\tfrac12,\tfrac13)\), \(B=(1,1)^\top\), \(C=(1,1)\). Build the \(5\times5\) Hankel matrix and compute its rank. Now set \(C=(1,0)\) and recompute. Explain the drop using §3.2, and say which of reachability and observability failed.
With \(C=(1,1)\) the rank is 2. With \(C=(1,0)\) it is 1. Nothing about reachability changed — \(\mathcal{R}_2=(B\;AB)\) still has rank 2, since both modes are excited. What failed is observability: \(\mathcal{O}_2=\binom{C}{CA}=\binom{1\;\;0}{1/2\;\;0}\) has rank 1, because the second coordinate never reaches the output. By the Kalman decomposition the transfer function sees only the reachable-and-observable part, so \(h_j=(1/2)^j\) — a first-order sequence, and \(\operatorname{rank}\mathcal{H}=1\).
The moral: a state coordinate can be perfectly alive inside the model and completely invisible from outside it. Two of the four Kalman blocks cost memory and FLOPs at inference and contribute nothing.
Show directly that \(W_c=\int_0^\infty e^{At}BB^\top e^{A^\top t}dt\) solves \(AW_c+W_cA^\top+BB^\top=0\). Where did you use stability?
Differentiate the integrand: \(\frac{d}{dt}\big(e^{At}BB^\top e^{A^\top t}\big) = A\,e^{At}BB^\top e^{A^\top t} + e^{At}BB^\top e^{A^\top t}A^\top\). Integrate both sides from \(0\) to \(\infty\). The right side gives \(AW_c+W_cA^\top\); the left telescopes to \(\big[e^{At}BB^\top e^{A^\top t}\big]_0^\infty = 0 - BB^\top\).
Stability enters exactly twice, and in the same place: it makes the integral converge at all, and it kills the boundary term at \(t=\infty\). For an unstable \(A\) neither holds and \(W_c\) does not exist — which is why the Lyapunov equation is a stability certificate and not merely an identity.
Take \(A=\left(\begin{smallmatrix}-1&\gamma\\ 0&-2\end{smallmatrix}\right)\), stable for every \(\gamma\). Plot \(\|e^{At}\|_2\) for \(t\in[0,5]\) and find its maximum at \(\gamma=25\). Compare with \(e^{-t}\). Then compute \(\kappa(V)\) and relate the two numbers. (Fig. 1.4 does this; do it yourself first.)
At \(\gamma=25\) the norm rises to about \(6.3\) near \(t\approx0.7\) before decaying — the state grows by more than a factor of six while every eigenvalue says "decay". The eigenvector matrix is \(V=\left(\begin{smallmatrix}1&\gamma\\0&-1\end{smallmatrix}\right)\) up to scaling, with \(\kappa(V)\) growing linearly in \(\gamma\), and the peak of \(\|e^{At}\|\) tracks it.
Two lessons. First, the spectrum does not determine the transient: a stable system can behave like an unstable one over the horizon you actually care about. Second, transient growth and ill-conditioned eigenvectors are the same phenomenon — the eigenvectors are nearly parallel, so a state can have small coordinates in a basis that is itself nearly degenerate. Bring \(\lambda_2\to\lambda_1\) and both blow up together.
Implement Ho–Kalman from the listing in §3.3. Verify on a random stable system of order 3 that you recover the Markov parameters to machine precision, and that taking \(r=2\) gives an error controlled by \(\sigma_3\).
You should see \(\sim10^{-14}\) at \(r=3\) and an error of order \(\sigma_3\) at \(r=2\) — not \(\sigma_3\) exactly, since plain SVD truncation of the Hankel matrix is not the same as balanced truncation, but the same order of magnitude. The bound \(2\sum_{i>r}\sigma_i\) of §4.1 is the guaranteed version.
Two things to notice while it runs. The algorithm never sees \(A,B,C\) — only the output — so it is an identification method, not a factorisation of something you already had. And the recovered \(A\) will not resemble the true \(A\) at all: it is a different point in the same \(\mathrm{GL}(N)\) orbit (§3.4), and that is not an error.
Compute the Hankel singular values of the system with \(h_j=\alpha^j\). How many are nonzero, and why? Now take the delay line — \(h_j=1\) for \(j=n-1\) and \(0\) otherwise, i.e. exact recall at lag \(n\). What do its Hankel singular values look like, and what does balanced truncation therefore promise about representing exact recall in a small state?
Exactly one. \(h_j=\alpha^j\) is generated by the scalar system \(A=\alpha,B=C=1\), so the Hankel matrix is the outer product \((\alpha^i)(\alpha^j)\) — rank one — and \(\sigma_1=1/(1-\alpha^2)\), which is what Fig. 4.1's "one pole" panel prints.
The delay line is the opposite extreme: \(W_c=W_o=I\) in the shift basis, so \(\sigma_1=\cdots=\sigma_n=1\). The spectrum is perfectly flat. Balanced truncation therefore promises nothing: every direction matters equally, discarding any one costs the full \(\sigma=1\), and by Glover's lower bound no degree-\(r\) system with \(r<n\) does better.
This is the cleanest available statement of why a fixed-size linear state cannot do exact recall over long ranges. It is not an optimisation failure or a missing inductive bias; the operator has no small approximation, and the theorem says so. It is also why hybrid stacks keep an attention layer around.
Verify that \(z\mapsto(1+z/2)/(1-z/2)\) maps \(\{\operatorname{Re}z<0\}\) bijectively onto \(\{|w|<1\}\), and compute the image of the imaginary axis. Then compute \(R(\infty)\) for backward Euler, bilinear and ZOH, and explain what a nonzero \(|R(\infty)|\) does to a very stiff mode over many steps.
\(|1+z/2|^2-|1-z/2|^2 = 2\operatorname{Re}z\), so \(|R(z)|<1\) exactly when \(\operatorname{Re}z<0\) — the map is the Cayley transform, a Möbius bijection of the open left half-plane onto the open disc, carrying the imaginary axis onto the unit circle (\(|R(iy)|=1\) identically) and \(0\mapsto1\).
\(R(\infty)\): backward Euler \(0\), ZOH \(0\), bilinear \(-1\). The last is A-stable but not L-stable, and \(|R(\infty)|=1\) means a very stiff mode is not damped at all — it is multiplied by roughly \(-1\) each step, so it survives indefinitely while alternating in sign, which is a Nyquist-frequency oscillation that no amount of further integration removes.
This is a real reason to prefer ZOH once \(\Delta\) is learned rather than fixed: a learned \(\Delta_t\) will happily wander into the stiff regime, and under bilinear the model's "forgotten" modes ring instead of dying. S4 used bilinear with a fixed \(\Delta\); S4D, S5 and Mamba use ZOH.
Show that the ZOH input matrix equals \(\Delta\varphi_1(\Delta A)B\) with \(\varphi_1(z)=(e^z-1)/z\), and expand to first order to recover Mamba's \(\bar B=\Delta B\). At \(A=-1\), tabulate the relative error for \(\Delta=0.01,0.1,1,3\). In which of Mamba's two regimes is the approximation worst, and does that matter?
\(\int_0^\Delta e^{sA}ds = A^{-1}(e^{\Delta A}-I) = \Delta\cdot\frac{e^{\Delta A}-I}{\Delta A}
= \Delta\varphi_1(\Delta A)\). Since \(\varphi_1(0)=1\), the first-order truncation is
\(\Delta\). Errors at \(A=-1\): 0.5%, 5.1%, 58%,
216%.
Worst by far at large \(\Delta\) — which is the open gate, the token the model has decided is worth absorbing. So the approximation is least accurate exactly where the model is paying attention, and it systematically over-weights strongly-gated tokens (\(\Delta\) instead of \(1-e^{-\Delta}\), which saturates at 1).
Does it matter? Arguably not much, because \(B_t\) is learned and can absorb a smooth monotone reweighting of \(\Delta_t\). That is the honest answer, and it is also why Mamba-3's more accurate quadrature buys only 15.81 → 15.72 perplexity. The discretisation frame's real contribution was a new degree of freedom, not accuracy.
Derive the scalar steady-state Kalman gain for \(A=C=1\): solve \(P=P-P^2/(P+r)+q\) for \(P_\infty\), hence \(K_\infty\). Plot \(K_\infty\) against \(q/r\) over four decades. Then find the \(z\) at which the sigmoid gate matches \(K_\infty\), and interpret \(z\).
The fixed point satisfies \(P^2/(P+r)=q\), i.e. \(P^2-qP-qr=0\), so \(P_\infty=\tfrac12\big(q+\sqrt{q^2+4qr}\big)\) and \(K_\infty=P_\infty/(P_\infty+r)=\tfrac12\big(\sqrt{\rho^2+4\rho}-\rho\big)\) with \(\rho=q/r\). It is increasing in \(\rho\), tends to \(0\) as \(\rho\to0\) and to \(1\) as \(\rho\to\infty\).
Setting \(\sigma(z)=K_\infty(\rho)\) makes \(z\) a monotone function of \(\log\rho\): the gate pre-activation is a log signal-to-noise ratio. That is the interpretation the sigmoid gate of an LSTM does not come with, and the Kalman derivation supplies for free — the network's learned \(z\) is estimating how much the world moves relative to how noisy the evidence is. Fig. 5.3 overlays the two curves.
Write the Kalman filter for a constant-velocity model (\(A=\left(\begin{smallmatrix}1&\Delta\\0&1\end{smallmatrix}\right)\), \(C=(1,0)\)) and run it on simulated data. Then answer from the code, not from memory: does any quantity in the gain computation depend on the simulated observations? Now make the measurement noise variance a function of the measurement itself, rerun, and identify exactly which line becomes data-dependent.
No. \(P_{k|k-1}=AP_{k-1|k-1}A^\top+Q\), \(S_k=CP_{k|k-1}C^\top+R\), \(K_k=P_{k|k-1}C^\top S_k^{-1}\), \(P_{k|k}=(I-K_kC)P_{k|k-1}\): the recursion is closed in \(P\) and touches \(y\) nowhere. Only \(\hat x\) sees the data, through \(K_k\nu_k\). Run two wildly different realisations and the gain sequences agree bit for bit — Fig. 6.5 prints the difference as exactly \(0\).
Making \(R\) depend on \(y_k\) changes exactly one line, \(S_k=CP_{k|k-1}C^\top+R(y_k)\), and from that moment the whole schedule is data-dependent and can no longer be precomputed. That one line is the entire distance between a scheduled LTV recurrence (S4 with a positional schedule; vanilla RoPE) and a selective one (Mamba). It is also, structurally, what the extended Kalman filter does when it evaluates its Jacobians at the current estimate.
The useful reframing: selectivity is the signature of a nonlinear filtering problem, imported into a linear recurrence by letting a network compute the coefficients.
Prove the localised rank bound of §3.5 for the time-invariant case, then check it numerically: build \(M_{ki}=CA^{k-i}B\) for a random system with \(N=4\), take a \(20\times20\) block strictly below the diagonal and report its numerical rank; then take a block straddling the diagonal and report that. Explain the difference.
Strictly below: rank 4. Straddling: full rank (20). The proof is the factorisation \(M_{ki}=(CA^{k-k_0})A^{k_0-i_0}(A^{i_0-i}B)\), valid only when every row index exceeds every column index — which is exactly the condition that the block lies below the diagonal. A straddling block contains entries on both sides of the diagonal, where the factorisation does not apply, and the diagonal band carries \(h_0\) on every entry, so nothing collapses.
This is the whole reason chunking works: diagonal blocks must be computed densely (but they are small), while off-diagonal blocks are applied through their thin factors — and the factor in the middle is what the algorithm calls the running state.
Using the three-term recurrence, show that the matrix of multiplication by \(Y\) in an orthonormal polynomial basis is symmetric tridiagonal, while the matrix of differentiation is strictly lower triangular. Which of the two is HiPPO's \(A\) built from, and why does that answer why \(A\) is triangular rather than tridiagonal?
Multiplication: \(\langle Yp_n,p_k\rangle=\langle p_n,Yp_k\rangle\) is symmetric, and vanishes unless \(|n-k|\le1\) by the degree argument — a Jacobi matrix. Differentiation: \(\deg p_n' \le n-1\), so \(\langle p_n',p_k\rangle=0\) for \(k\ge n\) — strictly lower triangular, and not banded, because \(p_n'\) generally has nonzero components on every lower index.
HiPPO's dynamics come from differentiating the projection with respect to time, and the time derivative acts on the basis through \(\partial_tp_n\), which is the differentiation operator (composed with the measure's rescaling). Hence triangular, densely so. If the dynamics had come from multiplication you would get a tridiagonal \(A\) — which is what happens in classical Jacobi-matrix models, and it is a different and much sparser structure.
Project \(u(t)=e^{-t}\sin 6t\) onto the first \(N\) Legendre polynomials for \(N=4,\dots,48\) and plot the \(L^2\) error on log axes; fit an exponent. Repeat with a step function. Which theorem of §8.3 applies to each, and what does the comparison say about HiPPO Prop. 6?
The analytic signal converges geometrically and hits machine precision near \(N\approx30\) (Bernstein). The step converges like \(N^{-1/2}\) in \(L^2\) (Jackson, at the roughest end of the scale, with Gibbs oscillations near the jump). A Lipschitz kink sits between the two at roughly \(N^{-1.5}\).
HiPPO Prop. 6's \(O(N^{-1/2})\) is therefore a worst-case statement over a rough class, and it is the rate you observe only for genuinely discontinuous inputs. Real signals — and the intermediate activations of a trained network, which are smoothed by everything upstream — are far smoother, so a fixed-size state does far better than the theorem promises. This is the resolution of Exercise 2.3 of the companion notes: the measured exponent is supposed to be steeper than the bound.
Show the scan monoid \((a_2,b_2)\circ(a_1,b_1)=(a_2a_1,\,a_2b_1+b_2)\) is associative but not commutative, and construct a two-element example in which composing on the wrong side gives the correct transitions and the wrong increments.
Associativity: both bracketings give \((a_3a_2a_1,\;a_3a_2b_1+a_3b_2+b_3)\). Non-commutativity: \((2,1)\circ(3,0)=(6,3)\) while \((3,0)\circ(2,1)=(6,1)\).
Note what the counterexample does: the first component agrees in both orders, because it is just a product of scalars. Only the increment differs. So a down-sweep that applies the incoming prefix on the wrong side produces a scan whose transitions are right and whose values are wrong — a bug that passes any test checking decay rates or shapes and fails only on exact values. This is the standard way the sum-scan's ordering silently corrupts an affine scan.
Compute the arithmetic intensity of a dense \(N\times N\) matrix–vector product and of an \(N\times N\) matrix–matrix product in bf16, as functions of \(N\). Place both against a ridge of 295 ops/byte, and state in one sentence why every efficiency argument in this field eventually becomes an argument about turning matvecs into matmuls.
Matvec: \(2N^2\) FLOPs against \(2(N^2+2N)\) bytes, so the intensity tends to \(1\) op/byte — independent of \(N\). Matmul: \(2N^3\) FLOPs against \(6N^2\) bytes, so intensity \(\approx N/3\), which crosses the ridge at \(N\approx885\) and at \(N=128\) already reaches \(\sim43\).
One sentence: a matvec is memory-bound at every size, so its arithmetic units idle no matter how large you make the state, while a matmul's intensity grows with the tile — which is why Mamba-2 reshapes the scan into batched matmuls and why Mamba-3's MIMO lift adds FLOPs that cost almost no time. Note the parallel with §4: enlarging \(N\) buys memory but not intensity, and those are separate axes that the roofline keeps separate.
| # | work | where |
|---|---|---|
| 1 | Nerode — Linear automaton transformations | Proc. AMS 9 (1958) 541–544 |
| 2 | Kalman — A new approach to linear filtering and prediction problems | J. Basic Eng. 82 (1960) 35–45 |
| 3 | Kalman, Bucy — New results in linear filtering and prediction theory | J. Basic Eng. 83 (1961) 95–108 |
| 4 | Kalman — Mathematical description of linear dynamical systems | SIAM J. Control 1 (1963) 152–192 |
| 5 | Ho, Kalman — Effective construction of linear state-variable models from input/output functions | Regelungstechnik 14 (1966) 545–548 |
| 6 | Kronecker — Zur Theorie der Elimination einer Variabeln (finite Hankel rank ⇔ rationality) | Monatsber. Berlin (1881) |
| 7 | Wiener — Extrapolation, Interpolation, and Smoothing of Stationary Time Series | MIT Press, 1949 |
| 8 | Rauch, Tung, Striebel — Maximum likelihood estimates of linear dynamic systems | AIAA J. 3 (1965) 1445–1450 |
| 9 | Anderson, Moore — Optimal Filtering | Prentice-Hall, 1979 |
| 10 | Durbin, Koopman — Time Series Analysis by State Space Methods | OUP, 2nd ed. 2012 |
| 11 | Julier, Uhlmann — A new extension of the Kalman filter to nonlinear systems (UKF) | Proc. SPIE 3068 (1997) |
| 12 | Gordon, Salmond, Smith — Novel approach to nonlinear/non-Gaussian Bayesian state estimation | IEE Proc. F 140 (1993) 107–113 |
| 13 | Rabiner — A tutorial on hidden Markov models | Proc. IEEE 77 (1989) 257–286 |
| 14 | Moore — Principal component analysis in linear systems (balancing) | IEEE TAC 26 (1981) 17–32 |
| 15 | Glover — All optimal Hankel-norm approximations and their \(L^\infty\) error bounds | Int. J. Control 39 (1984) 1115–1193 |
| 16 | Antoulas — Approximation of Large-Scale Dynamical Systems (best single reference for Parts 03–04) | SIAM, 2005 |
| 17 | Kailath — Linear Systems | Prentice-Hall, 1980 |
| 18 | Juang, Pappa — An eigensystem realization algorithm (ERA) | J. Guid. Control Dyn. 8 (1985) 620–627 |
| 19 | Van Overschee, De Moor — N4SID | Automatica 30 (1994) 75–93 |
| 20 | Ljung — System Identification: Theory for the User | Prentice-Hall, 2nd ed. 1999 |
| 21 | Bauer, Fike — Norms and exclusion theorems | Numer. Math. 2 (1960) 137–141 |
| 22 | Trefethen, Embree — Spectra and Pseudospectra | Princeton, 2005 |
| 23 | Moler, Van Loan — Nineteen dubious ways to compute the exponential of a matrix | SIAM Review 45 (2003) 3–49 |
| 24 | Dahlquist — A special stability problem for linear multistep methods | BIT 3 (1963) 27–43 |
| 25 | Hairer, Wanner — Solving ODEs II: Stiff and Differential-Algebraic Problems | Springer, 2nd ed. 1996 |
| 26 | Hochbruck, Ostermann — Exponential integrators (the \(\varphi\)-function family) | Acta Numerica 19 (2010) 209–286 |
| 27 | Tustin — A method of analysing the behaviour of linear systems in terms of time series | J. IEE 94 (1947) |
| 28 | Szegő — Orthogonal Polynomials | AMS, 1939 |
| 29 | Trefethen — Approximation Theory and Approximation Practice | SIAM, 2013 |
| 30 | Cooley, Tukey — An algorithm for the machine calculation of complex Fourier series | Math. Comp. 19 (1965) 297–301 |
| 31 | Eidelman, Gohberg — On a new class of structured matrices | Integr. Equ. Oper. Theory 34 (1999) |
| 32 | Vandebril, Van Barel, Mastronardi — Matrix Computations and Semiseparable Matrices | JHU Press, 2008 |
| 33 | Pan — Fast approximate computations with Cauchy matrices and polynomials | 1506.02285 |
| 34 | Blelloch — Prefix sums and their applications | CMU-CS-90-190, 1990 |
| 35 | Williams, Waterman, Patterson — Roofline | CACM 52 (2009) 65–76 |
| 36 | Bengio, Simard, Frasconi — Learning long-term dependencies with gradient descent is difficult | IEEE TNN 5 (1994) 157–166 |
| 37 | Hochreiter, Schmidhuber — Long short-term memory | Neural Comput. 9 (1997) 1735–1780 |
| 38 | Arjovsky, Shah, Bengio — Unitary evolution recurrent neural networks | 1511.06464 |
| 39 | Voelker, Kajić, Eliasmith — Legendre Memory Units | NeurIPS 2019 |
| 40 | Martin, Cundy — Parallelizing linear recurrent neural nets over sequence length | 1709.04057 |
| 41 | Katharopoulos et al. — Transformers are RNNs (linear attention) | 2006.16236 |
| 42 | Gu et al. — HiPPO | 2008.07669 |
| 43 | Gu et al. — LSSL | 2110.13985 |
| 44 | Gu, Goel, Ré — S4 | 2111.00396 |
| 45 | Gu, Dao — Mamba | 2312.00752 |
| 46 | Dao, Gu — Mamba-2 / SSD | 2405.21060 |
| 47 | Lahoti et al. — Mamba-3 | 2603.15569 |
Companion to From the linear ODE to Mamba-3 and its exercise and office-hours sheets. Every figure on this page computes its own numbers in your browser from the formulas in the text. Written and verified August 2026 · corrections welcome — l@muehrke.de