# Closed Form E[exp(x'Ax)]

Is there a (general) closed form available for the following expression?

$$\mathbb{E}\left[e^{x^{T}Ax}\right]$$ Where: $$x=\left\{ x_{1},x_{2},...,x_{N}\right\} \sim\mathcal{N}\left(0,\varSigma_{N}\right)$$ With the following symmetric matrices: $$\varSigma_{N}=\left(\begin{array}{cccc} \sigma_{11} & \sigma_{21} & \ldots & \sigma_{N1}\\ \sigma_{21} & \sigma_{22} & \ldots & \sigma_{N2}\\ \vdots & \vdots & \ddots & \vdots\\ \sigma_{N1} & \sigma_{N2} & \ldots & \sigma_{NN} \end{array}\right)$$ $$A=\left(\begin{array}{cccc} a_{11} & a_{21} & \ldots & a_{N1}\\ a_{21} & a_{22} & \ldots & a_{N2}\\ \vdots & \vdots & \ddots & \vdots\\ a_{N1} & a_{N2} & \ldots & a_{NN} \end{array}\right)$$

• Are the matrices diagonal? – Fabian Jul 5 '16 at 7:47
• Unfortunately not ( – Breugem Jul 5 '16 at 7:54
• Ok, so they are symmetric. – Fabian Jul 5 '16 at 7:55
• yes that's correct! – Breugem Jul 5 '16 at 8:01

This can be solved using the general solution of the Gaussian integral $$\int\!d^nx\,\exp\Bigl(-\frac12 x^T A x\Bigr) = \sqrt{\frac{(2\pi)^n}{\det A}}.$$
In your case, you we have that $$\mathbb{E}\left[e^{x^{T}Ax}\right] = \sqrt{\frac{1}{(2\pi)^n \det \Sigma}} \int\!d^nx \exp\Bigl(-\frac{1}{2} x^T \Sigma^{-1} x\Bigr) e^{x^T A x}=\sqrt{\frac{1}{(2\pi)^n \det \Sigma}} \int\!d^nx \exp\Bigl(-\frac{1}{2} x^T (\Sigma^{-1} -2 A) x\Bigr) .$$
The expectation value is convergent, if $\Sigma^{-1} -2 A$ is a positive definite matrix. In this case, we obtain the result $$\mathbb{E}\left[e^{x^{T}Ax}\right] = \sqrt{\frac{1}{\det \Sigma\,\det(\Sigma^{-1}- 2 A)}} = \frac{1}{\sqrt{\det( I- 2 \Sigma A)}}\,.$$
• Thanks a lot! May I ask if there is a way to compute $$\mathbb{E}\left[e^{x^{T}Ax+b^{T}x+c}\right]$$ as efficiently? Note that c is a constant and:$$b=\left\{ b_{1},..,b_{N}\right\}$$ – Breugem Jul 5 '16 at 9:05
• @Breugem: the trick is called "completing the square". One obtains the result: $$\mathbb{E}\left[ e^{x^T A x + b^T x + c} \right] = \det{}^{-1/2}(I-2 A \Sigma^{-1}) \exp(c-1/4 b^T A^{-1} b).$$ Of course $A^{-1}$ should exist. – Fabian Jul 5 '16 at 9:38
• @Breugem: you are right, I somehow took $\Sigma$ to be the inverse of the variance. I will correct the post. Sorry for the confusion. – Fabian Jul 5 '16 at 16:36