
Thermodynamic Linear Algebra
Estimating the inverse of a matrix using thermodynamic principles with interactive visualizations.
About this notebook
This notebook estimates the inverse of a symmetric positive-definite matrix with thermodynamic linear algebra, a method from Aifer et al. (2023). It simulates the overdamped Langevin equation in the quadratic potential that the matrix defines, using NumPy for the numerics. At thermal equilibrium, the time-averaged covariance of the trajectory, scaled by the inverse temperature, converges to the matrix inverse.
The controls are a matrix widget for the 2 by 2 matrix A and four sliders: the number of steps, the time step, the inverse temperature beta, and the damping constant gamma. Change any control, and marimo re-runs the simulation and redraws the plot. If the matrix is not positive definite, the notebook stops and shows a warning in red. The matplotlib figure shows the contours of the potential, the full trajectory, the current position, and a comparison of the exact inverse with the Langevin estimate.
The integrator is an Euler-Maruyama loop over the Langevin equation. The estimator discards the first 5000 steps as a burn-in transient and averages the outer products of the remaining states. The exact inverse for the comparison comes from numpy.linalg.inv.











