### A Gaussian integral identity

This integral pops up all the time in Bayesian data analysis:

$\int{N(\mathbf{a}|\mathbf{Xb},\mathbf{\Sigma}_2)N(\mathbf{b}|\mathbf{c},\mathbf{\Sigma}_1) d\mathbf{b}}$

I got tired of rederiving the solution, so I am posting it here for easy reference:

$= \left((2\pi)^{d}|\mathbf{\Sigma}_1||\mathbf{\Sigma}_2||\mathbf{H}|\right)^{-1/2}\exp(-\frac{1}{2} E)$

Where d is the dimensionality of $\mathbf{a}$, $|\cdot|$ is the matrix determinant and:

$E = \mathbf{a'\Sigma_2^{-1}a} + \mathbf{c'\Sigma_1^{-1}c} - \mathbf{x'Hx}$

$\mathbf{x} = \mathbf{H}^{-1}(\mathbf{X'\Sigma_2^{-1}a + \Sigma_1^{-1}c})$

$\mathbf{H} = \mathbf{X'\Sigma_2^{-1}X+\Sigma_1^{-1}}$