Expected squared distance between two jointly gaussian distributed random variables (dependent, with covariance) This is question basically asks for a generalization of the answer to this question:
Expected distance between two vectors that belong to two different Gaussian distributions . The difference here is that I know my variables have covariance.
If I have two $N$-dimensional random variables $X$ and $Y$ which are jointly gaussian distributed and not independent, i.e. the combined vector $Z=[X_0,...,X_N,Y_0,...,Y_N]$ is distributed according to $Z\sim \mathcal{N}(\mu_Z, \Sigma_Z)$, where
$\Sigma_Z = \begin{bmatrix}\Sigma_X & \Sigma_{XY}\\ \Sigma_{YX} & \Sigma_Y\end{bmatrix}$,
and $\Sigma_{XY}$, $\Sigma_{YX}$ are not just zero matrices.
What is the expected value of the squared euclidean distance between $X$ and $Y$?
I would highly appreciate help on this one. Also, please let me know if I can ask the question in a better way.
 A: Assuming that everything is $0$ mean.
You can reexpress the distance as
\begin{align*}
\mathbb E[\| X-Y \|^2] &= \mathbb E[(X-Y)^T(X-Y)]\\
&= \mathbb E[X^TX] + \mathbb E[Y^TY]-2 \mathbb E[X^TY]
\end{align*}
To treat terms like $\mathbb E[X^T X]$ you can use the trick $X^T X = \text{Tr}(X^TX) = \text{Tr}(XX^T)$ this together with the fact that trace is linear yelds
\begin{align*}
\mathbb E[X^TX] &= \text{Tr} (\Sigma_X )\\
\mathbb E[Y^TY] &= \text{Tr} (\Sigma_Y )\\
\mathbb E[X^TY] &= \text{Tr} (\Sigma_{YX} )
\end{align*}
So in the end you obtain
\begin{align*}
\mathbb E[\| X-Y \|^2] &= \text{Tr} (\Sigma_X ) + \text{Tr} (\Sigma_Y ) -2 \text{Tr} (\Sigma_{YX} )
\end{align*}

If $X$ now have mean $\mu_X$ and $Y$ have mean $\mu_Y$, then
\begin{align*}
&\| X-Y \|^2\\=& \| (X-\mu_X)-(Y-\mu_Y)+\mu_X-\mu_Y \|^2\\
=& \| (X-\mu_X)-(Y-\mu_Y) \|^2 + 2 \langle (X-\mu_X)-(Y-\mu_Y),\mu_X-\mu_Y\rangle +\| \mu_X-\mu_Y \|^2
\end{align*}
taking the expectation of this, the second term is $0$ since both $X-\mu_X$ and $Y-\mu_Y$ have mean $0$. So we get that
\begin{align*}
\mathbb E[\| X-Y \|^2] &= \text{Tr} (\Sigma_X ) + \text{Tr} (\Sigma_Y ) -2 \text{Tr} (\Sigma_{YX} ) + \| \mu_X-\mu_Y \|^2
\end{align*}
