Verifying the Gaussian Transformation of $exp\left\{\frac{1}{2}\sum_{i,j} S_i J_{ij} S_j\right\}$ from "Advanced Mean Field Methods" The book Advanced Mean Field Methods mentions the following equation as a result of a "simple gaussian transformation".
$$
exp\left\{\frac{1}{2}\cdot\textbf{s}^T \cdot \textbf{J} \cdot\textbf{s}\right\} = \frac{1}{(2\pi)^{N/2}\sqrt{det(J)}} \int_{-\infty}^\infty \prod_i dx_i \exp\left\{-\frac{1}{2}\sum_{ij}x_i(\textbf{J}^{-1})_{ij}x_j + \sum_ix_iS_i\right\}
$$
It is assumed that $\textbf{J}$ is positive definite. I would like to derive this for myself as I try to with all the expression I come across. Looking at the right-hand side, it is very similar to a multivariate normal distribution with $\mu = \textbf{s}$ and $\Sigma=\textbf{J}$
$$\frac{1}{(2\pi)^{N/2}\sqrt{det(J)}} \exp\left\{-\frac{1}{2}(\textbf{x}-\textbf{s})^T\textbf{J}^{-1}(\textbf{x}-\textbf{s})\right\}$$
$$
= \frac{1}{(2\pi)^{N/2}\sqrt{det(J)}} \exp\left\{-\frac{1}{2}\left(\textbf{x}^T\textbf{J}^{-1}\textbf{x} + \textbf{s}^T\textbf{J}^{-1}\textbf{s}\right) +\textbf{x}^T\textbf{J}^{-1}\textbf{s}\right\}.
$$
We are missing some terms and gaining some extra terms. Here, I don't know how to proceed, or if I am on the right track. I would like to take the expectation of some $g(\textbf{x}) =e^{f(\textbf{x} ; \textbf{s})}$ with respect to the multivariate normal above to cancel the extra terms and add the missing ones. However, my attempts at solving for such an $g$ does not lead to an easily interpretable one nor give reason to think we would have equality. I feel I am not taking the right approach.
I would greatly appreciate ideas and insights. Thank you.
 A: Let's consider the argument of the exponential on the R.H.S.:
$$
-\frac{1}{2} \bf{x}^T \bf{J}^{-1} \bf{x} + \bf{x}^T\cdot \bf{s}
$$
the trick is to add and subtract here a suitable quantity to complete the square. The correct choice (suggested by the solution you have) is clearly
$$
\frac{1}{2}\bf{s}^T \bf{J} \bf{s}.
$$
After this your exponent reads:
$$
\left(-\frac{1}{2} \bf{x}^T \bf{J}^{-1} \bf{x} + \bf{x}^T\cdot \bf{s} - \frac{1}{2}\bf{s}^T \bf{J} \bf{s} \right) + \frac{1}{2}\bf{s}^T \bf{J} \bf{s}
$$
Now the term in brackets can be written as a quadratic form $-\frac{1}{2} \bf{y}^T \bf{J}^{-1} \bf{y}$ if you define
$$
\bf{y} = \bf{x} - \bf{J}\bf{s}
$$
and with the assumption that $\bf{J}$ is a symmetric matrix, so that $\bf{J}^T=\bf{J}$.
In conclusion, your integral can be performed with a linear change of variable $\bf{x} \to \bf{y}$ (notice that this is simply a shift of your variable, so the extrema remain infinite and the Jacobian of the transformation is the identity):
$$
\frac{\exp{\left[\frac{1}{2}\bf{s}^T \bf{J} \bf{s} \right]}}{(2\pi)^{N/2}\sqrt{\det{\bf{J}}}} \int D\bf{y} \exp{\left[-\frac{1}{2} \bf{y}^T \bf{J}^{-1} \bf{y}\right]} = \exp{\left[\frac{1}{2}\bf{s}^T \bf{J} \bf{s} \right]}.
$$
where I have used the standard Gaussian integral result in the last equality.
Notice that this formula is a very useful trick to study mean field theory in classical and quantum field theories of interacting systems, and is often called Hubbard-Stratonovich transformation.
