0

For real valued matrices, is the trace of the outer product of a matrix always equal to the trace of the inner product of a matrix?

In other words, given matrices $A$ and $B$, is $\operatorname{trace}(A^TB) = \operatorname{trace}(AB^T)$?

This question was asked in a comment here and I couldn’t find further resources.

Technically this is related somewhat to the trace of the outer product of two vectors being equal to the dot product, in quantum computing. What I’d like to know is if some variation holds for matrices of an arbitrary size, not just $1 \times m$ or $n \times 1$.

Rócherz
  • 4,241
Edison Hua
  • 21
  • 3
  • 1
    Welcome to [math.se] SE. Take a [tour]. You'll find that simple "Here's the statement of my question, solve it for me" posts will be poorly received. What is better is for you to add context (with an [edit]): What you understand about the problem, what you've tried so far, etc.; something both to show you are part of the learning experience and to help us guide you to the appropriate help. You can consult this link for further guidance. – cpiegore Apr 14 '23 at 05:48
  • Hi! What a great comment! I can certainly say I've tried some brute force searches on numpy, as well as google searches for related questions, and I've added some context to the question, as well as the fact that my original post contains a link to an existing comment on another Stack Overflow post that has gone unanswered for 7 years. Following your guidance, I added some additional context, but let me know if this follows the "Focus on questions about an actual problem you have faced." mantra and "Pare question to its basics". – Edison Hua Apr 14 '23 at 05:55

1 Answers1

4

The answer is yes. Let $A$ and $B$ be $n\times m$ matrices; then $$ \text {Tr}\,(A^TB)=\sum_{i=1}^{m}\sum_{j=1}^{n}(A^T)_{ij}B_{ji} =\sum_{j=1}^{n}\sum_{i=1}^{m}A_{ji}(B^{T})_{ij}=\text {Tr}\,(AB^T). $$

Gonçalo
  • 15,869