  Stochastic dynamics of classical degrees of freedom, defined on vertices of
locally tree-like graphs, can be studied in the framework of the dynamic cavity
method which is exact for tree graphs. Such models correspond for example to
spin-glass systems, Boolean networks, neural networks, and other technical,
biological, and social networks. The central objects in the cavity method are
edge messages -- conditional probabilities of two vertex variable trajectories.
In this paper, we discuss a rather pedagogical derivation for the dynamic
cavity method, give a detailed account of the novel matrix product edge message
(MPEM) algorithm for the solution of the dynamic cavity equation as introduced
in Phys. Rev. E 97, 010104(R) (2018), and present optimizations and extensions.
Matrix product approximations of the edge messages are constructed recursively
in an iteration over time. Computation costs and precision can be tuned by
controlling the matrix dimensions of the MPEM in truncations. Without
truncations, the dynamics is exact. Data for Glauber-Ising dynamics shows a
linear growth of computation costs in time. In contrast to Monte Carlo
simulations, the approach has a much better error scaling. Hence, it gives for
example access to low probability events and decaying observables like temporal
correlations. We discuss optimized truncation schemes and an extension that
allows to capture models which have a continuum time limit.
