The trace trick:

If \( A^T \Sigma^{-1} A \) is a 1×1 matrix,

$$ A^T \Sigma^{-1} A = \text{trace}( A^T \Sigma^{-1} A ) = \text{trace}(\Sigma^{-1} A A^T )$$

http://andreweckford.blogspot.com/2009/09/trace-tricks.html

http://nonconditional.com/2012/06/the-trace-trick-for-gaussian-log-likelihood/

http://www.cs.cmu.edu/~epxing/Class/10701-08s/recitation/gaussian.pdf