← back to home

Deriving the DMFT cavity equation using the matrix block inverse formula

In many high-dimensional linear problems, I want to calculate how one variable (or coordinate) responds to constraints on the remaining. A classic example is the disordered linear dynamical system, where we have a large system of sites, arranged into a vector hh, which undergo random but coupled dynamics. The goal is to find an equation to describe the dynamics of a single site, marginalizing out the effects of the other sites. This is a rich system; Blake gives a nice introduction in his 2026 review paper with Cengiz Pehlevan, and Mark wrote up a detailed walkthrough of it on his blog.

The color of site ii represents its activity hi(t)h_i(t), the size of its halo is its external drive ji(t)j_i(t), and the edges are the couplings AA. We want a self-contained equation for the dynamics of a single site (e.g., circled).

Two other problems with similar structure:

  1. High-dimensional linear regression. We have a random function "vector" y(x)y(x) whose expected covariance is known. We want to find an equation that predicts the distribution of a single element y(x0)y(x_0) conditioned on observations {y(xi)}i\{y(x_i)\}_i at several other training points.
  2. Gaussian free field. We have a free field ϕ(x)\phi(x) with kinetic operator L=−∇2+m2L = -\nabla^2 + m^2. We place a point source at the endpoint x0x_0 of a semi-infinite 1D lattice. What's ϕ(x0)\phi(x_0)?

What all of these problems have in common is that they're linear problems that can be solved by the matrix block inversion formula. I thought that this formula was pretty opaque, and I wanted to better understand where it comes from. The point of this blog post is to give a few different derivations of it, and then show how to use it to solve the disordered linear dynamical system. I'll leave the other two problems as exercises :—)

Why is this about block inversion?

At the core of all these problems is the linear relation j=Mhj = Mh, where the symmetric matrix MM is known, but jj and hh are both only partially-known to us, with some unknown components we need to solve for. For example, the linear dynamical system is governed by h˙=−Ah+j\dot h = -Ah + j, which can be written as j=(A+ddt)hj = \left(A + \frac{d}{dt}\right)h. We want to isolate the behavior of a single site (wlog, index 0), which we can depict as separated from the remaining "bath" variables:

[j0jb]=[A00+ddtAb0⊤Ab0Abb+ddtI][h0hb]=:[s    c⊤    c    B    ][h0hb].\begin{align*} \left[\begin{array}{c} j_0 \\[0.4em] \hdashline \rule[-2em]{0pt}{4.5em} j_b \end{array}\right] &= \left[\begin{array}{c:c} A_{00} + \frac{d}{dt} & \qquad A_{b0}^\top \qquad \\[0.4em] \hdashline \rule[-2em]{0pt}{4.5em} A_{b0} & \qquad A_{bb} + \frac{d}{dt} I \qquad \end{array}\right] \left[\begin{array}{c} h_0 \\[0.4em] \hdashline \rule[-2em]{0pt}{4.5em} h_b \end{array}\right] \\[4.5em] &=: \left[\begin{array}{c:c} s & \qquad\;\; c^\top \qquad\;\; \\[0.4em] \hdashline \rule[-2em]{0pt}{4.5em} c & \qquad\;\; B \qquad\;\; \end{array}\right] \left[\begin{array}{c} h_0 \\[0.4em] \hdashline \rule[-2em]{0pt}{4.5em} h_b \end{array}\right] . \end{align*}

This site-bath structure makes the problem interesting — in some sense it precludes naive spectral approaches, since the site basis is privileged. In the second line I've renamed the blocks for simplicity of notation: ss (for "site") is a scalar, cc (for "coupling") is a vector, and BB (for "bath") is a matrix.

To solve for h0(t)h_0(t) without explicit reference to hb(t)h_b(t), we clearly need to invert M:=A+ddtM:=A + \frac{d}{dt} in terms of the blocks ss, cc, and BB. The formula is pretty complicated:

[h0hb]=[1s−c⊤B−1c−c⊤B−1s−c⊤B−1c−B−1cs−c⊤B−1cB−1+B−1c c⊤B−1s−c⊤B−1c][j0jb].\left[\begin{array}{c} \rule[-1.3em]{0pt}{2.9em} h_0 \\[0.4em] \hdashline \rule[-2em]{0pt}{4.5em} h_b \end{array}\right] = \left[\begin{array}{c:c} \rule[-1.3em]{0pt}{2.9em} \dfrac{1}{s - c^\top B^{-1} c} & \quad -\dfrac{c^\top B^{-1}}{s - c^\top B^{-1} c} \quad \\[0.4em] \hdashline \rule[-2em]{0pt}{4.5em} -\dfrac{B^{-1} c}{s - c^\top B^{-1} c} & \quad B^{-1} + \dfrac{B^{-1} c\, c^\top B^{-1}}{s - c^\top B^{-1} c} \quad \end{array}\right] \left[\begin{array}{c} \rule[-1.3em]{0pt}{2.9em} j_0 \\[0.4em] \hdashline \rule[-2em]{0pt}{4.5em} j_b \end{array}\right] .

I think it's important to understand what's going on in this formula. I want to give a few different derivations, all of which give some physical intuition for this formula, and for the linear dynamical system. If you don't care about that, you can skip to the next section.

Using Gaussian elimination

This is the most straightforward method, but imo the least illuminating. We just write the two block rows of j=Mhj = Mh:

j0=s h0+c⊤hbjb=c h0+B hb.\begin{aligned} j_0 &= s\, h_0 + c^\top h_b \\ j_b &= c\, h_0 + B\, h_b . \end{aligned}

Solve for the bath site variables using the bath row equation: hb=B−1(jb−c h0)h_b = B^{-1}\left(j_b - c\, h_0\right). Substitute this into the site row and collect h0h_0:

(s−c⊤B−1c)h0=j0−c⊤B−1jb.\left(s - c^\top B^{-1} c\right) h_0 = j_0 - c^\top B^{-1} j_b .

The quantity (s−c⊤B−1c)\left(s - c^\top B^{-1} c\right) is called the Schur complement. Dividing it from both sides gives the top row of the block inverse, and plugging h0h_0 back into our equation for hbh_b gives the bottom row.

As we'll soon see, the Schur complement shows up a lot in these problems. Sadly, this derivation didn't give me much intuition for what it means, or why it has that functional form. Also, the Schur complement is dimensionful; we know from physics that oftentimes the key structural insight comes from trying to extract dimension-free quantities. The next method (using the Sherman-Morrison formula) does this directly.

Using the Sherman-Morrison formula

Notice that the site-bath coupling is the annoying part of the inverse. If we could just nix it, c=0c=0, then we'd have

[s00B]−1=[1/s00B−1]\begin{bmatrix} s & 0 \\ 0 & B \end{bmatrix}^{-1} = \begin{bmatrix} 1/s & 0 \\ 0 & B^{-1} \end{bmatrix}

since that's how block-diagonal matrices work. This is intuitive — the site and the bath don't talk, so their inverses are independent. Can we just sneak the coupling back in somehow? A useful starting observation is that the uncoupled interaction matrix is a low-rank perturbation of the full interaction matrix:

M=[s00B]+e p⊤+p e⊤M = \begin{bmatrix} s & 0 \\ 0 & B \end{bmatrix} + e\,p^\top + p\, e^\top

where p⊤=[ 0    c⊤ ]p^\top = \left[\,0 \;\; c^\top\,\right] contains the couplings, and e=[1,0,…,0]⊤e = \left[1, 0, \dots, 0\right]^\top is the first canonical basis vector. The problem has now transformed: we want to invert a low-rank perturbation of a matrix whose inverse we already know. This is where the Sherman-Morrison formula comes in. First we factor out the uncoupled part:

M−1=(I+e q⊤+p~ e⊤)−1[s00B]−1M^{-1} = \left( I + e\,q^\top + \tilde p\, e^\top\right)^{-1} \begin{bmatrix} s & 0 \\ 0 & B \end{bmatrix}^{-1}

where p~⊤:=[ 0    (B−1c)⊤ ]\tilde p^\top := \left[\,0 \;\; \left(B^{-1}c\right)^\top\,\right] contains the coupling as seen through the uncoupled inverse, and q:=p/sq := p/s. I'll leave it as an exercise to go through the same steps as in my previous blog post; as a hint, it's useful to observe that e⊤e=1e^\top e=1 and e⊤q=e⊤p~=0e^\top q = e^\top \tilde p = 0. It's also useful to define g:=q⊤p~=1sc⊤B−1cg:=q^\top \tilde p=\frac{1}{s}c^\top B^{-1} c. If you do the calculation, you find that

M−1=(I−11−g(e q⊤+p~ e⊤−p~ q⊤−g e e⊤))[s00B]−1=(I−11−g[−gc⊤/sB−1c−B−1c c⊤/s])[s00B]−1=[1s(1−g)−c⊤B−1s(1−g)−B−1cs(1−g)B−1+B−1c c⊤B−1s(1−g)].\begin{aligned} M^{-1} &= \left( I - \frac{1}{1-g} \left( e\,q^\top + \tilde p\, e^\top - \tilde p\,q^\top - g\, e\, e^\top \right) \right) \begin{bmatrix} s & 0 \\ 0 & B \end{bmatrix}^{-1} \\[1.5em] &= \left( I - \frac{1}{1-g} \begin{bmatrix} -g & c^\top / s \\ B^{-1}c & -B^{-1}c\,c^\top / s \end{bmatrix} \right) \begin{bmatrix} s & 0 \\ 0 & B \end{bmatrix}^{-1} \\[1.5em] &= \begin{bmatrix} \dfrac{1}{s\left(1-g\right)} & \qquad -\dfrac{c^\top B^{-1}}{s\left(1-g\right)} \\[2em] -\dfrac{B^{-1}c}{s\left(1-g\right)} & \qquad B^{-1} + \dfrac{B^{-1}c\,c^\top B^{-1}}{s\left(1-g\right)} \end{bmatrix} . \end{aligned}

Notice that our quantity g=q⊤p~g=q^\top \tilde p has two nice properties: a) it shows up everywhere, and b) it's dimensionless! I think this is a strong signal that it's worth trying to interpret its meaning. We can get some intuition by relying on the visual derivation in my previous blog post. First, our quantity p~\tilde p is exactly analogous to the p~\tilde p from the blog post. It represents the coupling that remains after we factor out the uncoupled inverse. Then, since p~e⊤\tilde p e^\top skews the bath variables according to the first site's activity, and eq⊤e q^\top skews the site variable according to the bath's activity, the quantity g=q⊤p~g=q^\top \tilde p is akin to a gain, or echo: it measures the strength of the round-trip effect of the site on itself through the bath.

This interpretation of gg becomes a lot more explicit when we solve the inverse problem using an iterative method. That's what we'll do next.

Using Gauss-Seidel iteration (alternating minimization)

In non-convex optimization, alternating minimization is a powerful method. (An example from neuroscience is sparse coding w/ dictionary learning.) The idea is that even though the full problem is jointly non-convex, the sub-problems where we optimize only one variable while keeping the others fixed are often individually convex. So, we just alternate between minimizing each variable separately. Applying that idea to blockwise inversion is called Gauss-Seidel iteration: we solve the site row for h0h_0 holding the bath fixed, then solve the bath row for hbh_b holding the site fixed, and repeat.

h0(k+1)=1s(j0−c⊤hb(k))hb(k+1)=B−1(jb−c h0(k+1)).\begin{aligned} h_0^{(k+1)} &= \frac{1}{s}\left(j_0 - c^\top h_b^{(k)}\right) \\[1em] h_b^{(k+1)} &= B^{-1}\left(j_b - c\, h_0^{(k+1)}\right) . \end{aligned}

The uncoupled bath satisfies hb(0)=B−1jbh_b^{(0)} = B^{-1} j_b. How does the site react? It responds to both its drive j0j_0 and the bath: h0(1)=1s(j0−c⊤B−1jb)h_0^{(1)} = \frac{1}{s}\left(j_0 - c^\top B^{-1} j_b\right). Then the bath reacts to this, hb(1)=B−1jb−B−1c h0(1)h_b^{(1)} = B^{-1} j_b - B^{-1} c\, h_0^{(1)}, and that reaction comes back to the site as h0(2)=(1+g)h0(1)h_0^{(2)} = \left(1 + g\right) h_0^{(1)}, where g=1sc⊤B−1cg=\frac{1}{s}c^\top B^{-1} c is the same dimensionless gain from the previous section. Each round trip through the bath multiplies the latest correction by gg, so

h0(k)=(1+g+g2+⋯+gk−1)h0(1)  ⟶  h0(1)1−g=j0−c⊤B−1jbs(1−g),h_0^{(k)} = \left(1 + g + g^2 + \dots + g^{k-1}\right) h_0^{(1)} \;\longrightarrow\; \frac{h_0^{(1)}}{1-g} = \frac{j_0 - c^\top B^{-1} j_b}{s\left(1-g\right)} ,

which is the top row of the block inverse again. Therefore 1/(1−g)=1+g+g2+g3+…1/\left(1-g\right)= 1 + g + g^2 + g^3 + \dots is the cumulative effect of all the echoes, cycling through the site and the bath and back to the site again, multiple times.Technically the iteration only converges when ∣g∣<1\lvert g \rvert < 1, but our solution is correct as long as g≠1g \neq 1. In the case ∣g∣>1\lvert g \rvert > 1, iteration is simply not the right approach.

Returning to the linear dynamical system

Our problem is j(t)=(A+ddt)h(t)j(t) = \left(A + \frac{d}{dt}\right)h(t), where h(t)h(t) contains the site activities, j(t)j(t) contains the per-site external drive, and AA is the time-independent interaction matrix. The trouble here is the d/dtd/dt, which is a bit hard to handle. Things will get a lot easier if we Fourier transform, since this takes d/dtd/dt to iωi\omega, i.e., just a scalar times the identity matrix:

[ȷ~0ȷ~b]=[A00+iωAb0⊤Ab0Abb+iωI][h~0h~b]=:[sc⊤cB][h~0h~b].\begin{align*} \begin{bmatrix} \tilde\jmath_0 \\ \tilde\jmath_b \end{bmatrix} &= \begin{bmatrix} A_{00} + i\omega & A_{b0}^\top \\ A_{b0} & A_{bb} + i\omega I \end{bmatrix} \begin{bmatrix} \tilde h_0 \\ \tilde h_b \end{bmatrix} \\[1.5em] &=: \begin{bmatrix} s & c^\top \\ c & B \end{bmatrix} \begin{bmatrix} \tilde h_0 \\ \tilde h_b \end{bmatrix} . \end{align*}

Here I'm using tildes to denote Fourier-space variables, i.e., functions of ω\omega. We want to solve for the site activity h0(t)h_0(t) in terms of j(t)j(t). To do this we can just invert (using the block inversion formula) and read off the top row:

h~0=1A00+iω−r~(ȷ~0−Ab0⊤(Abb+iωI)−1 ȷ~b)\tilde h_0 = \frac{1}{A_{00} + i\omega - \tilde r} \left( \tilde\jmath_0 - A_{b0}^\top \left(A_{bb}+i\omega I\right)^{-1}\, \tilde\jmath_b \right)

where I've introduced r~:=Ab0⊤(Abb+iωI)−1Ab0=c⊤B−1c\tilde r := A_{b0}^\top \left(A_{bb}+i\omega I\right)^{-1} A_{b0}=c^\top B^{-1} c. Our equation for h~0\tilde h_0 is, in some sense, complete: it does not directly depend on the other site trajectories. But, the annoying thing about our equation is that it still depends on the drive's bath variables, as well as all the bath couplings. If the system has permutation symmetry — there are no privileged sites — then we should expect to be able to simplify this further, to somehow "average out" the aggregate effect of the bath. This requires studying the remaining bath terms.

The first remaining bath term is r~\tilde r. A few notes:

  1. Since r~=sg\tilde r= sg, where g=1sc⊤B−1cg=\frac{1}{s}c^\top B^{-1} c is the same dimensionless gain from the previous section, you can think of it as a dimensionful gain factor.
  2. If AA is a symmetric random matrix with i.i.d. entries (zero mean and variance 1/N1/N for NN sites), then cc is independent of B−1B^{-1}, and in the large-bath limit the random quadratic form r~=c⊤B−1c\tilde r = c^\top B^{-1} c concentrates to its expectation: r~=c⊤B−1c→Ec[c⊤B−1c]=tr[B−1],\tilde r = c^\top B^{-1} c \to \mathbb{E}_c\mleft[c^\top B^{-1} c\mright] = \mathrm{tr}\mleft[B^{-1}\mright], where tr\mathrm{tr} is the normalized trace (i.e., trace divided by matrix dimension). This "deterministic equivalent" is therefore a consequence of self-averaging in the large bath limit.
  3. If the system is large enough that A00≪tr[B−1]A_{00} \ll \mathrm{tr}\mleft[B^{-1}\mright], then we can discard that particular coupling. Then the site 0 inverse matrix element converges to a deterministic quantity: 1A00+iω−r~→1iω−r~.\frac{1}{A_{00}+i\omega-\tilde r} \to \frac{1}{i\omega-\tilde r}. If the system also has permutation symmetry, then the full system acts the same as the bath by itself, and all the diagonal elements are equal to the normalized trace (which, recall, is just r~\tilde r): 1iω−r~=tr[(A+iωI)−1]=tr[B−1]=r~.\frac{1}{i\omega-\tilde r} = \mathrm{tr}\mleft[(A+i\omega I)^{-1}\mright] = \mathrm{tr}\mleft[B^{-1}\mright] = \tilde r. This leave-one-out approximation gives a self-consistent equation for r~\tilde r, which we can just solve! This is what I meant earlier by "averaging out the aggregate effect of the bath." Under the (pretty reasonable) assumptions we made, we don't actually need to know any of the bath details to solve how the bath actually interacts with the site (through r~\tilde r).
  4. Finally, a note on nomenclature: in this particular problem, r~\tilde r is often called the memory kernel (it'll become clear why later).

The second remaining bath term is u~:=−Ab0⊤(Abb+iωI)−1 ȷ~b=c⊤B−1ȷ~b\tilde u := -A_{b0}^\top \left(A_{bb}+i\omega I\right)^{-1}\, \tilde\jmath_b=c^\top B^{-1} \tilde\jmath_b. A few more notes:

  1. Consider the bath activities if we nixed the coupling, c=0c=0, or equivalently just removed site zero entirely. I'll use hb∖0h_{b\setminus 0} to denote these counterfactual bath activities. In this scenario, we'd have B−1ȷ~b=h~b∖0B^{-1} \tilde\jmath_b = \tilde h_{b\setminus 0}. Then u~=−c⊤h~b∖0\tilde u = -c^\top \tilde h_{b\setminus 0}.
  2. If we assume again that AA has i.i.d. entries, then cc is independent of hb∖0h_{b\setminus 0}, and in the large-bath limit u~\tilde u converges to a Gaussian process (by central limit theorem). The autocovariance of the GP is just the autocovariance of h~b∖0\tilde h_{b\setminus 0}.
  3. If we assume self-consistency again (i.e., that the permutation symmetry + large bath implies that the full system acts the same as the bath by itself) then the autocovariance of h~b∖0\tilde h_{b\setminus 0} is equal to the autocovariance of h~\tilde h which is equal to the autocovariance of h~0\tilde h_0.
  4. Finally, a note on nomenclature: in this particular problem, u~\tilde u is often called the noise term since it's a Gaussian process that does not directly respond to either h0h_0 or j0j_0.

We've now killed all the bath variables (yay!). After rearranging, here's what's left:

iω h~0=ȷ~0+u~+r~ h~0.i\omega\, \tilde h_0 = \tilde\jmath_0 + \tilde u + \tilde r\, \tilde h_0 .

Now we finally Fourier transform back, using the convolution theorem for the product r~ h~0\tilde r \,\tilde h_0:

ddth0(t)=j0(t)+u(t)+∫−∞tdt′ r(t−t′) h0(t′).\frac{d}{dt} h_0(t) = j_0(t) + u(t) + \int_{-\infty}^{t} dt'\, r(t-t')\, h_0(t') .

This is quite amazing: we have an ODE for a single site's dynamics that explicitly depends only on the site's own history (through the memory kernel rr) and its own external drive j0j_0. The dependence on the bath is implicit; it lives in the autocovariance of the Gaussian process uu, and in the functional form of rr. We already obtained a self-consistent equation for rr earlier; I'll leave it to you to do the same for uu. (You can find details in Mark's blogpost and Blake's paper.)

(Left.) A system of interacting sites. Each site's color is its activity hi(t)h_i(t), and the size of its halo is its external drive ji(t)j_i(t). The cavity site is circled, and one of its neighbors has a dashed circle. (Top Right.) The cavity site's true trajectory (solid) is well predicted by the single-site equation we derived (dashed). The faint envelope shows the memory kernel rr. (Bottom right.) The neighbor site's true trajectory (solid) stays close to the counterfactual sans-cavity-site field (dashed).

To recap, the main cavity idea here is exact: it follows from the block-inverse formula, which is straight up correct. Then, to simplify even more, we make the following extra approximations:

  • concentration: with large bath, things self-average and many random variables converge to deterministic limits
  • cavity (leave-one-out) approximation: when we remove the site, nothing much changes in the bath (at least, as far as its correlations are concerned). This gives self-consistency: noise autocovariance and memory kernel are shared across all sites. This allows us to solve for them with no dependence on the bath's details.

Two exercises

  1. Kernel regression. We have a random function y(x)y(x) with zero mean and known covariance K(x,x′)K(x, x'), so its values at a test point and at a set of training points are jointly Gaussian:

    [ytestytrain]∼N(0,  [K(xtest,xtest)K(xtest,xtrain)K(xtrain,xtest)K(xtrain,xtrain)]).\left[\begin{array}{c} y_\mathrm{test} \\[0.4em] \hdashline \rule[-2em]{0pt}{4.5em} y_\mathrm{train} \end{array}\right] \sim \mathcal{N}\left(0,\; \left[\begin{array}{c:c} K(x_\mathrm{test}, x_\mathrm{test}) & \qquad K(x_\mathrm{test}, x_\mathrm{train}) \qquad \\[0.4em] \hdashline \rule[-2em]{0pt}{4.5em} K(x_\mathrm{train}, x_\mathrm{test}) & \qquad K(x_\mathrm{train}, x_\mathrm{train}) \qquad \end{array}\right] \right) .

    We observe the training labels ytrainy_\mathrm{train}. Conditioned on these, what's the mean and variance of ytesty_\mathrm{test}? Hint: use the probability density function for high-dim Gaussians and isolate the part of the log density that depends on ytesty_\mathrm{test} (the rest can be absorbed into the normalizing constant). You should find that the mean is the kernel regression estimator and the variance is the Schur complement s(1−g)s(1-g).

  2. Gaussian free field. We have j=Lϕj = L\phi, where LL is the discretized −∇2+m2-\nabla^2 + m^2 on a semi-infinite 1D lattice with endpoint x0x_0: L(x,x)=2+m2L(x, x) = 2 + m^2, L(x,x±1)=−1L(x, x \pm 1) = -1, and zero otherwise. The source is j(x0)=1j(x_0)=1 and zero otherwise. Solve for ϕ(x0)\phi(x_0). Hint: solving for r=sgr=sg will involve a self-consistency argument (note that the bath itself is self-similar to the site+bath system). Another hint: make sure the system is well-behaved in the large-mass limit.

    In the end, you should get

    r=12+m2−r  ⟹  r=(2+m2)−(2+m2)2−42ϕ(x0)=12+m2−r=r.\begin{align*} r &= \frac{1}{2 + m^2 - r} \quad\implies\quad r = \frac{\left(2 + m^2\right) - \sqrt{\left(2+m^2\right)^2 - 4}}{2} \\ \phi(x_0) &= \frac{1}{2 + m^2 - r} = r. \end{align*}

    As an extra challenge, try to find the field ϕ\phi everywhere.

    As another extra challenge, try the full infinite chain, with x0x_0 somewhere in the middle. You should get ϕ(x0)=1/(2+m2)2−4\phi(x_0) = 1/\sqrt{\left(2+m^2\right)^2 - 4}.