I would like to compute the following integral $$ I_n = \frac{1}{\sqrt{det(2\pi A)}} \int_{\mathbb{R}^n} ||x||^2_2 \exp\left(-\frac{1}{2} x^TAx\right) \mathrm{d} x $$ where $A$ is symmetric and positive definite.

Any suggestions or hints? Thanks in advance!

  • $\begingroup$ Hint: by a change of variables, try to express it in terms of the variance of the standard Gaussian. $\endgroup$ – Federico Nov 6 '18 at 19:30

The strategy for dealing with this sort of integral is to start with the integral $$\int \exp\left(-\frac12 x^TAx+c^Tx\right)\,dx$$ for some fixed vector $c$.

If we then make the change of variables $x\mapsto x+A^{-1}c$, that integral becomes $$\int\exp\left(-\frac12 x^TAx+\frac12c^TA^{-1}c\right)\,dx=\sqrt{\det(2\pi A)}\exp\left(\frac12c^TA^{-1}c\right).$$

Now comes the trick: we differentiate the integral with respect to $c_i$ and $c_j$ (the $i$th and $j$th components of the $c$ vector), and then set $c=0$: $$\frac{\partial^2}{\partial c_i\partial c_j}\int \exp\left(-\frac12 x^TAx+c^Tx\right)\,dx=\sqrt{\det(2\pi A)}\frac{\partial^2}{\partial c_i\partial c_j}\exp\left(\frac12c^TA^{-1}c\right)$$ $$\int x_ix_j\exp\left(-\frac12 x^TAx\right)\,dx=\sqrt{\det(2\pi A)}(A^{-1})_{ij}$$ where $(A^{-1})_{ij}$ is the $i,j$ entry of the matrix $A^{-1}$.

Now you can just sum over the pairs $x_ix_j$ that you want; in your case you have $\|x\|_2^2=\sum_{i=1}^nx_ix_i$, so you get $\sum_{i=1}^n (A^{-1})_{ii}=\boxed{\operatorname{Tr}A^{-1}}$.

  • $\begingroup$ why can you interchange derivative and integral here? $\endgroup$ – Syd Amerikaner Jul 1 '20 at 0:10
  • $\begingroup$ @SydAmerikaner I believe it follows from dominated convergence theorem, but I'm not too sure of the details. See this Wikipedia section, or for a proof check e.g. Theorem 2.27 of Folland's Real Analysis: Modern Techniques and Their Applications. $\endgroup$ – Carmeister Jul 1 '20 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.