# proof on trace trick

I wanted to find the maximum likelihood estimator for $\mathbf{\Sigma}$ in the multivariate gaussian.

I was anticipating the solution would be a bit involved and messy, if not 'brute-forced', but I was surprised to find an elegant and clever shortcut known as the trace trick.

For a vector $\mathbf{x}$ and a matrix $\mathbf{A}$, $\mathbf{x}^T\mathbf{Ax} = tr (\mathbf{x}^T\mathbf{Ax}) = tr (\mathbf{xx}^T\mathbf{A}) = tr (\mathbf{Axx}^T)$.

I am not sure how this can be true. Any insight/rough sketch of proof would be great.

The first equality is just using the fact that $x^TAx$ is a real number, so when seen as a $1\times 1$ matrix, it's equal to its trace!
The other equalities use the fact that $tr(AB)=tr(BA)$.
• To clarify for the asker: this means that $$\operatorname{trace}([x^TA][x]) = \operatorname{trace}([x][x^TA])$$ – Omnomnomnom Apr 27 '16 at 15:05