On the Trace of Matrix Products