# Trace (mathematics)

In mathematics, a trace is a property of a matrix and of a linear operator on a vector space. The trace plays an important role in the representation theory of groups (the collection of traces is the character of the representation) and in statistical thermodynamics (the trace of a thermodynamic observable times the density operator is the thermodynamic average of the observable).

## Definition and properties of matrix traces

Let A be an n × n matrix; its trace is defined by $\mathrm{Tr}(\mathbf{A})\; \stackrel{\mathrm{def}}{=} \; \sum_{i=1}^n A_{ii}$

where Aii is the ith diagonal element of A.

Example $\mathbf{A} = \begin{pmatrix} 2.1 & 1.3 & 0.0 \\ 5.0 & -0.1 & 8.3 \\ 7.0 & -4.7 & 3.0 \\ \end{pmatrix} \Longrightarrow \mathrm{Tr}(\mathbf{A}) = 2.1-0.1+3.0 = 5.0$

Theorem
Let A and B be n×n matrices, then Tr(A B) = Tr (B A).
Proof $\mathrm{Tr}(\mathbf{AB}) = \sum_{i=1}^n (\mathbf{AB})_{ii} = \sum_{i=1}^n\sum_{j=1}^n \; A_{ij}B_{ji} = \sum_{j=1}^n\sum_{i=1}^n \; B_{ji} A_{ij} = \sum_{j=1}^n (\mathbf{BA})_{jj} = \mathrm{Tr}(\mathbf{BA})$

Theorem
The trace of a matrix is invariant under a similarity transformation Tr(B−1A B) = Tr(A).
Proof $\mathrm{Tr}\big(\mathbf{B}^{-1}(\mathbf{AB})\big) = \mathrm{Tr}\big((\mathbf{AB})\mathbf{B}^{-1}\big) = \mathrm{Tr}(\mathbf{A E}) = \mathrm{Tr}(\mathbf{A}),$

where we used B B−1 = E (the identity matrix).

Other properties of traces are (all matrices are n × n matrices): \begin{align} \mathrm{Tr}( \mathbf{A} + \mathbf{B} ) &= \mathrm{Tr}( \mathbf{A}) + \mathrm{Tr}(\mathbf{B} ) \\ \mathrm{Tr}( \mathbf{E}) &= n \qquad\hbox{(trace of identity matrix)}\\ \mathrm{Tr}( \mathbf{O}) &= 0 \qquad\hbox{(trace of zero matrix)} \\ \mathrm{Tr}( \mathbf{ABC}) &= \mathrm{Tr}( \mathbf{CAB})=\mathrm{Tr}( \mathbf{BCA}) \\ \mathrm{Tr}(c\mathbf{A}) & = c \mathrm{Tr}(\mathbf{A}) \quad c\in\mathbb{C} \\ \mathrm{Tr}(\mathbf{A}^\mathrm{T}) & = \mathrm{Tr}(\mathbf{A}) \\ \end{align}

Theorem
Let S be a symmetric matrix, ST = S, and A be an antisymmetric matrix, AT = −A. Then $\mathrm{Tr}(\mathbf{S}\mathbf{A}) = \mathrm{Tr}(\mathbf{A}\mathbf{S}) =0 .$

Proof $\mathrm{Tr}(\mathbf{SA}) = \mathrm{Tr}\big((\mathbf{SA})^\mathrm{T}\big) = \mathrm{Tr}(\mathbf{A}^\mathrm{T}\mathbf{S}^\mathrm{T}) = -\mathrm{Tr}(\mathbf{AS}) = -\mathrm{Tr}(\mathbf{SA})$

A number equal to minus itself can only be zero.

### Relation to eigenvalues

We will show that the trace of an n×n matrix is equal to the sum of its n eigenvalues (the n roots of its secular equation).

The secular determinant of an n × n matrix A is the determinant of A −λ E, where λ is a number (an element of a field F). If we put the secular determinant equal to zero we obtain the secular equation of A (also known as the characteristic equation), $\Delta(\lambda) \equiv \begin{vmatrix} A_{11}-\lambda & A_{12} & \cdots & \cdots & A_{1n} \\ A_{21} & A_{22}-\lambda & \cdots & \cdots & A_{2n} \\ \cdots & \cdots & \ddots \\ A_{n1} & A_{n2} & &\cdots & A_{nn}-\lambda \\ \end{vmatrix} = 0$

The secular determinant is a polynomial in λ: $\Delta(\lambda) = (-\lambda)^n + P_1(-\lambda)^{n-1} + P_2(-\lambda)^{n-2}+ \cdots +P_{n-1}(-\lambda) + P_n = 0.$

The coefficient P1 of (−λ)n−1 is equal to the trace of A (and incidentally Pn is the determinant of A). If the field F is algebraically closed (such as the field of complex numbers) then the fundamental theorem of algebra states that the secular equation has exactly n roots (zeros) λi, i =1, ..., n, the eigenvalues of A and the following factorization holds $\Delta(\lambda) = (\lambda_1-\lambda)(\lambda_2-\lambda)\cdots(\lambda_n-\lambda).$

Expansion shows that the coefficient P1 of (−λ)n−1 is equal to $\sum_{i=1}^n \lambda_i = P_1 =\mathrm{Tr}(\mathbf{A}).$

Note: It is not necessary that A has n linearly independent eigenvectors, although any A has n eigenvalues in an algebraically closed field.

## Definition for a linear operator on a finite-dimensional vector space

Let Vn be an n-dimensional vector space (also known as linear space). Let $\hat{A}$ be a linear operator (also known as linear map) on this space, $\hat{A}:\quad V_n \rightarrow V_n$.

Let $\{v_1, v_2, \ldots, v_n\}$

be a basis for Vn, then the matrix of $\hat{A}$ with respect to this basis is given by $\hat{A} v_i = \sum_{j=1}^n\; v_j A_{ji} \quad \hbox{for}\quad i=1,\ldots, n, \quad\hbox{and}\quad \mathbf{A} \equiv (A_{ij}).$

Definition: The trace of the linear operator $\hat{A}$ is the trace of the matrix of the operator in any basis. This definition is possible since the trace is independent of the choice of basis.

We prove that a trace of an operator does not depend on choice of basis. Consider two bases connected by the non-singular matrix B (a basis transformation matrix), $w_i = \sum_{j=1}^n\; v_j B_{ji}, \quad i=1,\ldots, n.$

Above we introduced the matrix A of $\hat{A}$ in the basis vi. Write A' for its matrix in the basis wi $\hat{A} w_i = \sum_{j=1}^n\; w_j A'_{ji} \quad\hbox{with}\quad \mathbf{A}' = (A'_{ij}).$

It is not difficult to prove that $\mathbf{A}' = \mathbf{B}^{-1}\; \mathbf{A}\; \mathbf{B}\quad\Longrightarrow\quad \mathrm{Tr}(\mathbf{A}' ) = \mathrm{Tr}(\mathbf{A} ),$

from which follows that the trace of $\hat{A}$ in both bases is equal.

Theorem

Let a linear operator $\hat{A}$ on Vn have n linearly independent eigenvectors, $\hat{A}\; v_i = \alpha_i v_i\quad\hbox{with}\quad \alpha_i \in \mathbb{C}\quad\hbox{and}\quad i=1,\ldots,n.$

Then its trace is the sum of the eigenvalues $\mathrm{Tr}(\hat{A}) = \sum_{i=1}^n \alpha_i.$

Proof

The matrix of $\hat{A}$ in basis of its eigenvectors is $\hat{A}\; v_i = \sum_{j=1}^n \;v_j (\alpha_j \delta_{ji}) \quad\Longrightarrow\quad \mathbf{A}= \begin{pmatrix} \alpha_1 & 0 & \cdots & 0 \\ 0 &\alpha_2 & \cdots \\ \cdots & & \ddots \\ 0 & & &\alpha_n \\ \end{pmatrix},$

where δji is the Kronecker delta.

Note. To avoid misunderstanding: not all linear operators on Vn possess n linearly independent eigenvectors.

### Finite-dimensional inner product space

When the n-dimensional linear space Vn is equipped with a positive definite inner product, an expression for the matrix of a linear operator and its trace can be given. These expressions can be generalized to inner product spaces of infinite dimension and are of great importance in quantum mechanics.

Let $\{v_1, v_2, \ldots, v_n\} \quad\hbox{with}\quad \langle v_i | v_j\rangle =\delta_{ij}, \quad i,j=1,\ldots, n,$

be an orthonormal basis for Vn. The symbol δij stands for the Kronecker delta. The matrix of $\hat{A}$ with respect to this basis is given by $\hat{A} v_i = \sum_{j=1}^n\; v_j A_{ji} .$

Project with vk: $\langle v_k|\hat{A}| v_i\rangle = \sum_{j=1}^n\; \langle v_k |v_j \rangle \; A_{ji} = \sum_{j=1}^n\; \delta_{kj} \; A_{ji} = A_{ki}.$

Hence $A_{ij} = \langle v_i|\hat{A}| v_j\rangle \quad\Longrightarrow\quad \mathrm{Tr}(\hat{A}) = \sum_{i=1}^n \langle v_i|\hat{A}| v_i\rangle.$

## Infinite-dimensional space

The trace of a linear operator on an infinite-dimensional linear space is not always defined. For instance, we saw above that the trace of the identity operator on a finite-dimensional space is equal to the dimension of the space, so that a simple extension of the definition leads to a trace of the identity operator that is infinite, i.e., the trace is undefined. In fact, the property of having a finite trace is a severe restriction on a linear operator.

We consider an infinite-dimensional space with an inner product (a Hilbert space). Let be a linear operator on this space with the property $(\hat{T}^\dagger\hat{T})\; v_i = \alpha_i^2 \; v_i,\quad i=1,2,\ldots,\infty \quad \hbox{and} \quad \alpha_i^2\in \mathbb{R},$

where {vi} is an orthonormal basis of the space. Note that the operator is self-adjoint and positive definite, i.e., $\langle (\hat{T}^\dagger \hat{T}) w | w \rangle = \langle w | (\hat{T}^\dagger \hat{T}) w \rangle = \langle \hat{T} w | \hat{T} w \rangle \ge 0 \quad\hbox{for any}\quad w.$

From this follows that the eigenvalues of are positive—so that they may be written as squares—and its eigenvectors vi are orthonormal.

If the following sum of square roots of eigenvalues converges, $\sum_{i=1}^\infty \alpha_i < \infty,$

then the trace of can be defined by $\mathrm{Tr}(\hat{T}) \equiv \sum_{i=1}^\infty \langle v_i |\hat{T}| v_i \rangle,$

i.e., it can be proved that this summation converges as well. Operators that have a well-defined trace are called "trace class operators" or sometimes "nuclear operators".

As in the finite-dimensional case the trace is independent of the choice of (orthonormal) basis, $\mathrm{Tr}(\hat{T}) = \sum_{i=1}^\infty \langle w_i |\hat{T}| w_i \rangle < \infty,$

for any orthonormal basis {wi}.

An important example of a trace class operator is the exponential of the self-adjoint operator Ĥ, $e^{-\beta\hat{H}},\quad \beta \in \mathbb{R},\quad 0< \beta < \infty.$

The operator Ĥ, being self-adjoint, has only real eigenvalues εi. When Ĥ is bounded from below (its lowest eigenvalue is finite) then the sum $\mathrm{Tr}e^{-\beta \hat{H}} = \sum_{i=1}^\infty e^{-\beta \epsilon_i} < \infty$

converges. This trace is the canonical partition function of statistical physics.

## Reference

• F. R. Gantmacher, Matrizentheorie, Translated from the Russian by H. Boseck, D. Soyka, and K. Stengert, Springer Verlag, Berlin (1986). ISBN 3540165827
• N. I Achieser and I. M. Glasmann, Theorie der linearen Operatoren im Hilbert Raum, Translated from the Russian by H. Baumgärtel, Verlag Harri Deutsch, Thun (1977). ISBN 3871443263