We will explore the matrix trace, its properties, and its significance in understanding the behavior of matrices. Although, matrices are powerful mathematical tools that allow us to organize and manipulate data efficiently. They find applications in various fields, ranging from physics and engineering to computer science and data analysis. One important concept associated with matrices is the trace.

We assume that the reader is familiar with matrix operations and vector spaces.

**What is a matrix trace?**

Throughout the following the field $\mathbb{K}$ is the real numbers set $\mathbb{R}$ or the complex numbers set $\mathbb{C}$. We also denote by $\mathscr{M}_n(\mathbb{K})$ the space of all square matrices of order $n$ with coefficients in $\mathbb{K}$. If $A$ is matrix in $\mathscr{M}_n(\mathbb{K})$ with coefficients $\{a_{ij}: 1\le i,j\le n\},$ then we denote $A=(a_{ij})_{1\le i,j\le n}$, or sometimes just $A=(a_{ij})$ if there is no notational ambiguity.

### Definition of the trace of a matrix

A trace of the matrix $A=(a_{ji})\in\mathscr{M}_n(\mathbb{K})$ is the followin scalar number \begin{align*}{\rm Tr}(A)=\sum_{i=1}^n a_{ii}.\end{align*}

**Examples:** 1- The trace of the identity matrix $I_n$ of order $n$ is ${\rm Tr}(I_n)=1+\cdots+1=n$.

2- Let the matrix $$ A=\begin{pmatrix} 1&4&0\\ 2&5&1\\ 0&1&2\end{pmatrix}.$$ Then ${\rm Tr}(A)=1+5+2=8$.

## Properties of the Matrix Trace

The trace possesses several interesting properties that make it a useful measure of matrices. Firstly, it is invariant under cyclic permutations, meaning that the trace of a matrix remains the same even if the order of the terms in the sum is changed. Secondly, the trace is linear, meaning that $${\rm Tr}(\alpha A) = \alpha {\rm Tr}(A), \quad {\rm Tr}(A + B) = {\rm Tr}(A) + {\rm Tr}(B)$$ for any scalar $\alpha$ and matrices $A$ and $B$. Moreover, the following is one of the fundamental properties of trace matrices.

### Theorem on the trace of product of two matrices

Let $A\in\mathscr{M}_{n,p}(\mathbb{K})$ and $B\in\mathscr{M}_{p,n}(\mathbb{K})$ be two matrices. Prove that \begin{align*} {\rm Tr}(AB)={\rm Tr}(BA). \end{align*}

Let $a_{ij},$ $b_{ij}$, $c_{ij}$ and $d_{ij}$ be the entries of the matrices $A,B,AB$ and $BA$ respectively. Observe that $AB$ is a square matrix of order $n$ and $BA$ is a matrix of order $p$. We have \begin{align*} c_{ij}=\sum_{k=1}^p a_{ik}b_{kj},\quad d_{ij}=\sum_{k=1}^n b_{ik}a_{kj}. \end{align*} Then by definition of the trace, we have \begin{align*} {\rm Tr}(AB)=\sum_{i=1}^n c_{ii}= \sum_{i=1}^n \left(\sum_{k=1}^p a_{ik}b_{ki}\right). \end{align*} On the other hand, \begin{align*} {\rm Tr}(BA)&=\sum_{i=1}^n d_{ii}= \sum_{i=1}^p \left(\sum_{k=1}^n b_{ik}a_{ki}\right)\cr&= \sum_{i=1}^n \left(\sum_{k=1}^p a_{ik}b_{ki}\right)\cr & ={\rm Tr}(AB). \end{align*}

Using this theorem we can easily prove that when two matrices $A$ and $B$ are similar, then they have the same trace. In fact, by similarity of $A$ and $B,$ there exists an invertible matrix $P$ such that $A=P^{-1}BP$. Thus \begin{align*} {\rm Tr}(A)={\rm Tr}(P^{-1}(BP))={\rm Tr}((BP)P^{-1})={\rm Tr}(B).\end{align*}

**Worksheet**

### Exercise on matrices commutator

Does exist matrices $A,B\in\mathscr{M}_n(\mathbb{C})$ such that $AB-BA=I_n$?

Assume that $AB-BA=I_n$. As the trace operation is a linear map “linear forme” and ${\rm Tr}(I_n)=n,$ then \begin{align*} {\rm Tr}(AB)-{\rm Tr}(BA)=n. \end{align*} According to the Theorem above, we have ${\rm Tr}(AB)={\rm Tr}(BA)$, so that $n=0$. Absurd!!!

### Using trace to prove that two matrices commute

Assume that matrices $A,B\in\mathscr{M}_n(\mathbb{C})$ satisfy \begin{align*} (AB-BA)^2=AB-BA. \end{align*} Show that $AB=BA$.

We put $N=AB-BA,$ so that $N^2=N$. This means that $N$ is the matrix associated with a projector $p$. Then ${\rm Tr}(p)={\rm Tr(N)}=0$. But it is known that ${\rm Tr}(p)={\rm Rank}$ “rank of $p$ which is the dimension of the range ${\rm Im}(p)$”. Hence ${\rm Rank}(p)=0$. This implies that $\ker(p)=\mathbb{C}$ “we recall that for a projector we have the direct sum $\mathbb{C}^n=\ker(p)+\mathcal{R}(p)$”. This means that $N=0_n$ “is the null matrix”. Finally, $AB=B

### Sove a matrix equation

Let $A,B\in\mathscr{M}_n(\mathbb{R})$. Solve, in $\mathscr{M}_n(\mathbb{R}),$ the following matrices equation \begin{align*} X={\rm Tr}(X)A+B. \end{align*}

To solve the equation it suffices to determine ${\rm Tr}(X)$. By taking trace of $X$ and ${\rm Tr}(X)A+B,$ we obtain \begin{align*} {\rm Tr}(X)={\rm Tr}(X){\rm Tr}(A)+{\rm Tr}(B). \end{align*} This implies that \begin{align*}\tag{H} (1-{\rm Tr}(A)){\rm Tr}(X)={\rm Tr}(B) \end{align*} We distinct two cases: If ${\rm Tr}(A)\neq 1$, then we have \begin{align*} {\rm Tr}(X)=\frac{{\rm Tr}(B)}{1-{\rm Tr}(A)}. \end{align*} This implies that the solution of the matrix equation is \begin{align*} X=\frac{{\rm Tr}(B)}{1-{\rm Tr}(A)}\; A+B. \end{align*} Assume that ${\rm Tr}(A)=1$. If ${\rm Tr}(B)\neq 0$, then the equation is not compatible and there are no solutions to the matrix equation. Now if ${\rm Tr}(B)= 0,$ then the condition (H) is verified for any condition on $X$. In particular if $\lambda={\rm Tr}(X)$, then $X=\lambda A+B$ is a solution.

## Relationship of the trace with Eigenvalues

An intriguing connection exists between the trace and the eigenvalues of a matrix. The trace is equal to the sum of the eigenvalues of a matrix. This relationship offers a quick way to compute the trace when the eigenvalues are known. Conversely, the trace can provide valuable information about the eigenvalues, such as their sum or average value.

## Applications of the Matrix Trace

The matrix trace finds diverse applications in various areas of mathematics and beyond. In linear algebra, it is used to define the concept of similarity between matrices, where two matrices have the same trace if they are similar. Trace also appears in the calculation of determinants, where the determinant of a matrix can be expressed in terms of its trace and eigenvalues. In physics, the trace is often used to study the behavior of quantum systems, where it corresponds to the expectation value of certain operators.

## Conclusion on matrix trace

The matrix trace is a valuable tool in linear algebra that provides insights into the behavior and properties of matrices. It serves as a compact measure that encapsulates information about a matrix, such as its diagonal elements and eigenvalues. The trace finds applications in a wide range of fields, including mathematics, physics, and engineering. By understanding the matrix trace and its properties, we can enhance our ability to analyze and manipulate matrices effectively, leading