A deduction in cavity method (statistical physics) I am reading the book: Statistical Mechanics of Neural Networks by Huang, Haiping.
I cannot figure out how to get the following step in (2.14), page 10, chapter 2, spin Glass Models and Cavity Method.
$$
Z^{new} = Z^{old} \sum_{\{\sigma_i|i\in\partial a\}} \left[\exp\left(\beta J_a \prod_{i\in \partial a} \sigma_i\right) \prod_{i \in \partial a} \left(\frac{1+ \sigma_i m_{i->a}}{2}\right)\right]
\\= Z^{old} \cosh(\beta J_a) \left[1 + \tanh(\beta J_a) \prod_{i \in \partial a} m_{i->a}\right]
$$
I don't know how many items in total in this summation and how to get the second part from the first part.
I knew the relation between $e^x$ and $\cosh(x)$ or $\tanh(x)$:
$$\cosh (x) = \frac{e^{x} + e^{-x}}{2}$$
Any help would be appreciated.
 A: One way to get this is to group configurations of the neighbors according to their product.
Let's call the neighbors $\sigma_1, \sigma_2, \ldots, \sigma_k$ and the messages $m_1, m_2, \ldots, m_k$.
$$\begin{aligned}
 \sum_{\sigma_1, \sigma_2, \ldots, \sigma_k} e^{\beta J_a \prod_{i=1}^k\sigma_i} \prod_{i=1}^k \frac{1+\sigma_i m_i}{2} &= \sum_{\sigma=\pm1} e^{\beta J_a \sigma} \sum_{\substack{\sigma_1, \sigma_2, \ldots, \sigma_k\\\prod_{i=1}^k\sigma_i=\sigma}} \prod_{i=1}^k \frac{1+\sigma_i m_i}{2}
\end{aligned}$$
The inner sum is
$$\begin{aligned}
\sum_{\substack{\sigma_1, \sigma_2, \ldots, \sigma_k\\\prod_{i=1}^k\sigma_i=\sigma}} \prod_{i=1}^k \frac{1+\sigma_i m_i}{2}
&=\sum_{\sigma_1, \sigma_2, \ldots, \sigma_{k-1}} \prod_{i=1}^{k-1} \frac{1+\sigma_i m_i}{2} \frac{1+\sigma\left(\prod_{i=1}^{k-1}\sigma_i\right) m_k}{2}\\
&=\sum_{\sigma_1, \sigma_2, \ldots, \sigma_{k-1}} \left[\left(\prod_{i=1}^{k-1} \frac{1+\sigma_i m_i}{2}\right)+\frac{\sigma m_k}{2}\left(\prod_{i=1}^{k-1}\frac{1+\sigma_i m_i}{2}\sigma_i \right)\right]\\
&=\frac12 \prod_{i=1}^{k-1}\underbrace{\sum_{\sigma_i}\frac{1+\sigma_i m_i}{2}}_{1} + \frac12\sigma m_k \prod_{i=1}^{k-1} \underbrace{\sum_{\sigma_i}\frac{\sigma_i + m_i}{2}}_{m_i}\\
&= \frac{1 + \sigma\prod_{i=1}^k m_i}{2}
\end{aligned}$$
Bringing everything together
$$\begin{aligned}
\sum_{\sigma = \pm 1} e^{\beta J_a \sigma}\frac{1 +\sigma \prod_{i=1}^k m_i} {2} = \cosh(\beta J_a) + \sinh\left(\beta J_a\right)\prod_{i=1}^k m_i = \cosh(\beta J_a) \left[1 + \tanh\left(\beta J_a\right)\prod_{i=1}^k m_i\right]
\end{aligned}$$
