Transform an expression into a form involving the trace of a product of two matrices

linear algebra

In page 594 of Bishop's PRML, the following equation is implied:

$$
-\frac{1}{2}\sum(\mathbf{x}_n-\mathbf{\bar{x}})^T\mathbf{C}^{-1}(\mathbf{x}_n-\mathbf{\bar{x}}) = -\frac{N}{2}\mathrm{Tr}(\mathbf{C}^{-1}\mathbf{S})
$$

where

$$
\mathbf{S} = \frac{1}{N}\sum(\mathbf{x}_n-\mathbf{\bar{x}})(\mathbf{x}_n-\mathbf{\bar{x}})^T
$$

,$\mathbf{C}$ is a symmetric matrix and $\mathbf{\bar{x}} = \frac{\sum_{n=1}^N\mathbf{x}_n}{N}$.

I want to derive this equation myself. But I'm not sure how to do it. Could someone show why the equation holds?

Best Answer

Guide:

Notice that $(x_n - \bar{x})^TC^{-1}(x_n - \bar{x})$ is a scalar,

hence $$(x_n - \bar{x})^TC^{-1}(x_n - \bar{x})= \operatorname{Tr}\left[(x_n - \bar{x})^TC^{-1}(x_n - \bar{x})\right]=\operatorname{Tr}\left[C^{-1}(x_n - \bar{x})(x_n - \bar{x})^T\right]$$

since $\operatorname{Tr}(AB)=\operatorname{Tr}(BA)$. Hopefully you can take it from here.