# Calculate $\int_{\mathbb R^3} \exp(-x^tAx + b^tx) \,\lambda_3(dx)$

I want to calculate $\int_{\mathbb R^3} \exp(-x^tAx + b^tx) \,\lambda_3(dx)$ for $$A= \begin{pmatrix} 2 & -1 & 0 \\ -1 & 2 & 1 \\ 0 & 1 & 1\end{pmatrix}, \quad b= \begin{pmatrix} 1 \\ 2 \\ 3\end{pmatrix}$$ I would like to ask if my solution is correct and if there is a faster/better way.

Solution:
We see that $A$ is a positive definite symmetric covariance matrix.

Call $B := 2A$ and write $$-x^tAx + b^t x = -\frac{1}{2}(x^tBx - 2b^tx) = -\frac{1}{2}\left((x-B^{-1}b)^t B(x-B^{-1}b) -b^tB^{-1}b\right)$$ so we get $$\int_{\mathbb R^3} \exp(-x^tAx + b^tx) \,\lambda_3(dx) = \exp(b^tA^{-1}b) \int_{\mathbb R^3} \exp\left(-\frac{1}{2}\left((x-B^{-1}b)^t B(x-B^{-1}b)\right)\right) \,\lambda_3(dx)$$ Now the integral is the integral over the $3$-dimensional centered normal distribution and evaluates to $$\int_{\mathbb R^3} \exp\left(-\frac{1}{2}\left((x-B^{-1}b)^t B(x-B^{-1}b)\right)\right) \,\lambda_3(dx) = (2\pi)^{3/2}\det B = (8\pi)^{3/2} \det A$$ So it now only remains to compute $\det A$ and $A^{-1}$: $$\det A = 1, \quad A^{-1} = \begin{pmatrix} 1 & 1 & -1 \\ 1 & 2 & -2 \\ -1 & -2 & 3\end{pmatrix}$$ hence $$\int_{\mathbb R^3} \exp(-x^tAx + b^tx) \,\lambda_3(dx) = \exp(b^t A b) (8\pi)^{3/2} = e^{10} (8\pi)^{3/2}.$$

According to my calculations the integral has the value $e^{5/2}\pi^{3/2}$. I give two different answers. It is a matter of taste which one is the faster/better one.
Answer 1. This is essentially your solution. I omit the matrix $B$. Since \begin{equation*} -\left(x-\dfrac{1}{2}A^{-1}b\right)^{t}A\underbrace{\left(x-\dfrac{1}{2}A^{-1}b\right)}_{=y} + \dfrac{1}{4}x^tA^{-1}x = -y^{t}Ay +\dfrac{1}{4}x^tA^{-1}x . \end{equation*} I get \begin{equation*} I = \int_{\mathbb{R}^3}\exp(-x^{t}Ax+b^{t}x )\,\mathrm{d}x_{1}\mathrm{d}x_{2}\mathrm{d}x_{3} = \exp(\dfrac{1}{4}x^tA^{-1}x)\int_{\mathbb{R}^3}\exp(-y^{t}Ay)\,\mathrm{d}y_{1}\mathrm{d}y_{2}\mathrm{d}y_{3} \end{equation*} The next substitution is $y = Qz$ where $Q$ is an orthogonal matrix with columns that are orthonormal eigenvectors to $A$. Then $\det Q = 1$ and \begin{equation*} y^{t}Ay =\lambda_{1}z_{1}^{2}+\lambda_{1}z_{2}^{2}+\lambda_{1}z_{3}^{2} \end{equation*} where $\lambda_{k}, k=1,2,3$, are positive eigenvalues to $A$. Now we return to the integral \begin{gather*} I = \exp(\frac{1}{4}10)\int_{\mathbb{R}^3}\exp(-\lambda_{1}z_{1}^{2}-\lambda_{2}z_{2}^{2}-\lambda_{3}z_{3}^{2})\,\mathrm{d}z_{1}\mathrm{d}z_{2}\mathrm{d}z_{3} =\\[2ex] e^{5/2}\dfrac{\pi^{3/2}}{\sqrt{\lambda_{1}\lambda_{2}\lambda_{3}}} = e^{5/2}\dfrac{\pi^{3/2}}{\sqrt{\det(A)}} = e^{3/2}\pi^{3/2} \end{gather*} where I have used that $\lambda_{1}\lambda_{2}\lambda_{3}=\det(A) = 1.$
Answer 2. In this solution completing the square is essential. Put $x^t = \left(x_1\, x_2\, x_3\right)$. Then \begin{equation*} -x^{t}Ax+b^{t}x = -2x_1^2+2x_1x_2-2x_2^2-2x_2x_3-x_3^2+x_1+2x_2+3x_3 = -2u_1^2-\dfrac{3}{2}u_2^2-\frac{1}{3}u_3^2 +\dfrac{5}{2} \end{equation*} where \begin{equation*} \left\{\begin{array}{lclclclcl} u_1&=&x_1&-&\dfrac{1}{2}x_2&&&-&\dfrac{1}{4}\\[2ex] u_2&=&&&x_2&+&\dfrac{2}{3}x_3&-&\dfrac{5}{6}\\[2ex] u_3&=&&&&&x_3&-&2 \end{array}\right. \end{equation*} With notation from answer 1 I get \begin{equation*} I =e^{5/2}\int_{\mathbb{R}^3}\exp\left(-2u_1^2-\dfrac{3}{2}u_2^2-\frac{1}{3}u_3^2\right)\,\mathrm{d}u_{1}\mathrm{d}u_{2}\mathrm{d}u_{3} = e^{5/2}\dfrac{\sqrt{\pi}}{\sqrt{2}}\dfrac{\sqrt{\pi}}{\sqrt{3/2}}\dfrac{\sqrt{\pi}}{\sqrt{1/3}} = e^{3/2}\pi^{3/2} . \end{equation*}