38
$\begingroup$

there is a similar thread here Coordinate-free proof of $\operatorname{Tr}(AB)=\operatorname{Tr}(BA)$?, but I'm only looking for a simple linear algebra proof.

$\endgroup$
0

4 Answers 4

48
$\begingroup$

Observe that if $A$ and $B$ are $n\times n$ matrices, $A=(a_{ij})$, and $B=(b_{ij})$, then $$(AB)_{ii} = \sum_{k=1}^n a_{ik}b_{ki},$$ so $$ \operatorname{Tr}(AB) = \sum_{j=1}^n\sum_{k=1}^n a_{jk}b_{kj}. $$ Conclude calculating the term $(BA)_{ii}$ and comparing both traces.

$\endgroup$
1
  • 6
    $\begingroup$ Perhaps another useful observation is that if we transpose the matrix A, we get basically the standard inner product. See, for example, this answer. $\endgroup$ Commented Jan 11, 2015 at 11:58
14
$\begingroup$

For any couple $(A,B)$ of $n\times n$ matrices with complex entries, the following identity holds: $$ \operatorname{Tr}(AB) = \operatorname{Tr}(BA).$$

Proof. Assuming $A$ is an invertible matrix, $AB$ and $BA$ share the same characteristic polynomial, since they are conjugated matrices due to $BA = A^{-1}(AB)A$. In particular they have the same trace. Equivalently, they share the same eigenvalues (counted according to their algebraic multiplicity) hence they share the sum of such eigenvalues. On the other hand, if $A$ is a singular matrix then $A_\varepsilon\stackrel{\text{def}}{=} A+\varepsilon I$ is an invertible matrix for any $\varepsilon\neq 0$ small enough. It follows that $\operatorname{Tr}(A_\varepsilon B) = \operatorname{Tr}(B A_\varepsilon)$, and since $\operatorname{Tr}$ is a continuous operator, by considering the limits of both sides as $\varepsilon\to 0$ we get $\operatorname{Tr}(AB)=\operatorname{Tr}(BA)$ just as well.

$\endgroup$
4
  • 3
    $\begingroup$ What if $A$ is a $m\times n$ matrix and $B$ is a $n\times m$ matrix then is the statement $Tr(AB)=Tr(BA)$ true $\endgroup$
    – Maverick
    Commented Jul 15, 2020 at 18:47
  • $\begingroup$ How is $A+\epsilon I$ invertible for $\epsilon$ small enough? I know that the invertible matrix is a dense set in the set of the matrices, but this statement is stronger that that. $\endgroup$ Commented Aug 30, 2021 at 13:56
  • 1
    $\begingroup$ @R.W.Prado: since the identity matrix commutes with any matrix, the spectrum of $A+\varepsilon I$ is the spectrum of $A$ translated by $\epsilon$, and a matrix is invertible iff $0$ does not belong to its spectrum. $\endgroup$ Commented Aug 30, 2021 at 14:03
  • $\begingroup$ Nice argument! I first thought using Schur's decomposition. $\endgroup$ Commented Aug 30, 2021 at 14:18
13
$\begingroup$

If $A$ is an $m\times n$ matrix and $B$ an $n\times m$ matrix we have

\begin{eqnarray} \operatorname{tr}(AB) &=&\sum_{i=1}^m(AB)_{ii}\cr &=&\sum_{i=1}^m\sum_{k=1}^n A_{ik}B_{ki}\cr &=&\sum_{k=1}^n\sum_{i=1}^mB_{ki}A_{ik}\cr &=&\sum_{k=1}^n(BA)_{kk}\cr &=&\operatorname{tr}(BA). \end{eqnarray}

$\endgroup$
3
  • 1
    $\begingroup$ most general proof $\endgroup$
    – athos
    Commented Nov 14, 2022 at 20:43
  • $\begingroup$ Very Noice!! : ) $\endgroup$
    – Nimu Basak
    Commented Nov 30, 2023 at 5:46
  • $\begingroup$ Very, very elegant :) $\endgroup$
    – FafaDog
    Commented Dec 5, 2023 at 23:54
12
$\begingroup$

The efficient @hjhjhj57: answer

$$\text{Tr}(AB) = \text{Tr}(BA)= \sum a_{ij} b_{ji}$$

Now we can start to understand why if we do a circular permutation of the factors the expression

$$\text{Tr}( A_1 A_2 \ldots A_m)$$

does not change, and what is the expression.

Assume now $A$,$B$ square. Then certainly $\det(AB) = \det(BA)$, using the multiplicative property of the $\det$.

In fact, the matrices $AB$ and $BA$ have the same characteristic polynomial, so in particular the same trace, and the same determinant.

$\endgroup$
9
  • 1
    $\begingroup$ amazing... they have the same characteristic polynomial? how to show that ? $\endgroup$
    – athos
    Commented Jan 11, 2015 at 8:17
  • 5
    $\begingroup$ @athos: $\det(A) \det( t - BA) =\det(t A - ABA) = \det(t- AB) \det A$. This holds for all same size square matrices $A$,$B$. Look at it as an identity in the entries of $A$,$B$ and also $t$. An equality of two polynomials. Now divide by the non-zero polynomial $\det A$... $\endgroup$
    – orangeskid
    Commented Jan 11, 2015 at 8:22
  • $\begingroup$ Trace of a matrix is sum of its eigenvalues. Note that $AB$ and $BA$ have the same nonzero eigenvalues. $\endgroup$ Commented Jan 11, 2015 at 8:41
  • $\begingroup$ @JankoBracic: They do have the same eigenvalues, including zeroes, for linear operators on a finite dimensional vector space. However, you probably consider the case of $A$,$B$ elements in an algebra and looking at spectra then your statement is the right one in this general case. $\endgroup$
    – orangeskid
    Commented Jan 11, 2015 at 8:58
  • 1
    $\begingroup$ Once the case for two matrices has been proved, the cyclic property can easily be proved by induction. $\endgroup$
    – hjhjhj57
    Commented Jan 11, 2015 at 19:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .