  The spherical $p$-spin is a fundamental model for glassy physics, thanks to
its analytic solution achievable via the replica method. Unfortunately the
replica method has some drawbacks: it is very hard to apply to diluted models
and the assumptions beyond it are not immediately clear. Both drawbacks can be
overcome by the use of the cavity method, which, however, needs to be applied
with care to spherical models. Here we show how to write the cavity equations
for spherical $p$-spin models on complete graphs, both in the Replica Symmetric
(RS) ansatz (corresponding to Belief Propagation) and in the 1-step Replica
Symmetry Breaking (1RSB) ansatz (corresponding to Survey Propagation). The
cavity equations can be solved by a Gaussian (RS) and multivariate Gaussian
(1RSB) ansatz for the distribution of the cavity fields. We compute the free
energy in both ansatzes and check that the results are identical to the replica
computation, predicting a phase transition to a 1RSB phase at low temperatures.
The advantages of solving the model with the cavity method are many. The
physical meaning of any ansatz for the cavity marginals is very clear. The
cavity method works directly with the distribution of local quantities, which
allows to generalize the method to dilute graphs. What we are presenting here
is the first step towards the solution of the diluted version of the spherical
$p$-spin model, which is a fundamental model in the theory of random lasers and
interesting $per~se$ as an easier-to-simulate version of the classical
fully-connected $p$-spin model.
