# Covariance of Two Quadratic Forms

We're looking for the $$\operatorname{Cov}\left[x^T A x, ~x^T B x\right]$$ where $$x$$ is random variable and mean-centered, but not independent and $$A$$ and $$B$$ are symmetric matrices. The fundamental term to compute is $$E\left[x^T A x x^T B x\right]$$, a quartic form. For the normal case, you can find this in the matrix cookbook. Has anyone figured this out in general?

• Not a whole lot of simplification is available for the general case you pose. But if you intend that the $x_i$ be iid, for instance, or exchangeable, or uncorrelated, then extensive simplification is possible. Could you clarify for us what assumptions you are making about the first four moments of $x$ (beyond "mean-centered," which implies all means are zero)? BTW, I'm curious about what you mean by "heterogeneous," because this expectation looks like a homogeneous quartic form in the components of $A$ and $B$ to me. – whuber Dec 15 '18 at 20:01
• Maybe you don't need this anymore. I think you may find this video useful: youtube.com/watch?v=Z0jBgMDkfUg. – jwyao Apr 16 '20 at 23:12

In the special case when $$A$$ and $$B$$ commute, they are simultaneously diagonalisable. If the spectrum of $$A$$ is made of the $$\lambda_i$$'s and the spectrum of $$B$$ of the $$\xi_i$$'s, then $$\text{Cov}[x^T A x, ~x^T B x]=\sum_i \lambda_i\xi \text{var}(X_i^2)$$ if $$X_i$$ is the $$i$$-th coordinate of $$X$$ in the orthonormal basis.
• You must be assuming both $A$ and $B$ are symmetric (which is reasonable, but ought to be made explicit). – whuber Dec 13 '18 at 15:48