<s>[INST] Cross covariance and trace identity This may be a simple answer but I can't find any proof. I know that the following identities are true
$$ E\left \{  \left ( \mathbf{x} - E\left ( \mathbf{x} \right )  \right )^T\mathbf{Q}\left ( \mathbf{x} - E\left ( \mathbf{x}  \right ) \right ) \right \}=tr\left ( \mathbf{Q}cov\left ( \mathbf{x} \right ) \right )$$
$$ E\left \{ \left ( \mathbf{A}\left ( \mathbf{x} - E\left ( \mathbf{x} \right ) \right ) \right )^T\mathbf{Q}\left ( \mathbf{A}\left ( \mathbf{x} - E\left ( \mathbf{x} \right ) \right ) \right ) \right \}=tr\left ( \mathbf{Q}\mathbf{A}cov\left ( \mathbf{x} \right )\mathbf{A}^T \right )=tr\left ( \mathbf{A}^T\mathbf{Q}\mathbf{A}cov\left ( \mathbf{x} \right ) \right ) $$
where $\mathbf{Q}$ is a diagonal matrix, $\mathbf{x}$ is a random column vector, $\mathbf{A}$ is a matrix of appropriate dimensions and $cov$ is the covariance. For the case of two random vectors, are these identities true?
$$ E\left \{  \left ( \mathbf{x} - E\left ( \mathbf{x} \right )  \right )^T\mathbf{Q}\left ( \mathbf{y} - E\left ( \mathbf{y}  \right ) \right ) \right \}=tr\left ( \mathbf{Q}cov\left ( \mathbf{x,y} \right ) \right )$$
$$ E\left \{ \left ( \mathbf{A}\left ( \mathbf{x} - E\left ( \mathbf{x} \right ) \right ) \right )^T\mathbf{Q}\left ( \mathbf{B}\left ( \mathbf{y} - E\left ( \mathbf{y} \right ) \right ) \right ) \right \}=tr\left ( \mathbf{Q}\mathbf{A}cov\left ( \mathbf{x,y} \right )\mathbf{B}^T \right )=tr\left ( \mathbf{A}^T\mathbf{Q}\mathbf{B}cov\left ( \mathbf{x,y} \right ) \right ) $$
Thanks
 [/INST] The answer to both is yes.
For the first one, let $\mathbf{c}=\mathbf{x}-E\left ( \mathbf{x} \right)$, $\mathbf{d}=\mathbf{y}-E\left ( \mathbf{y} \right)$ and $Q=\text{diag}(q_1,\ldots,q_n)$, then you can easily check
$$ E\left[ \mathbf{c}^TQ\mathbf{d}\right]=E\left[\sum_i q_i\mathbf{c}_i \mathbf{d}_i\right]=\sum_i q_iE\left[\mathbf{c}_i \mathbf{d}_i\right].$$
Since $\left(cov(\mathbf{x},\mathbf{y})\right)_{ij}=\left(E\left[\mathbf{c}\mathbf{d}^T\right]\right)_{ij}=E\left[\mathbf{c}_i\mathbf{d}_j\right]$, the $i$-th diagonal element of $Qcov\left ( \mathbf{x},\mathbf{y} \right )$ is $q_iE\left[\mathbf{c}_i\mathbf{d}_i\right]$ and thus the first equality follows.
For the second equality, an important fact to keep in mind is that $E\left[A\mathbf{x}\right]=AE\left[\mathbf{x}\right]$. So $A\mathbf{c}=A\left( \mathbf{x} - E\left ( \mathbf{x} \right )\right )=\left ( A\mathbf{x} - E\left ( A\mathbf{x} \right )\right )$ and we can apply the first equation to obtain
$$  E\left [  \left( A\left ( \mathbf{x} - E\left ( \mathbf{x} \right )  \right )\right )^T\mathbf{Q}\left( B\left ( \mathbf{y} - E\left ( \mathbf{y} \right )  \right )\right ) \right ]=tr\left ( \mathbf{Q}cov\left ( \mathbf{Ax},\mathbf{By} \right ) \right ). $$
To complete the proof, note that
$$ cov(A\mathbf{x},B\mathbf{y})= E\left[ A\mathbf{c}\left(B\mathbf{d}\right)^T\right]=E\left[ A\mathbf{c}\mathbf{d}^TB^T\right]=A E\left[ \mathbf{c}\mathbf{d}^T\right]B^T=A cov(\mathbf{x},\mathbf{y})B^T  $$
</s>