Trace (linear algebra)

In linear algebra, the trace of a square matrix , denoted , is defined to be the sum of elements on the main diagonal (from the upper left to the lower right) of .
The trace of a matrix is the sum of its (complex) eigenvalues (counted with multiplicities), and it is invariant with respect to a change of basis. This characterization can be used to define the trace of a linear operator in general. The trace is only defined for a square matrix ().
The trace is related to the derivative of the determinant (see Jacobi's formula).
Definition.
The trace of an square matrix is defined as
where denotes the entry on the th row and th column of .
Example.
Let be a matrix, with
Then
Properties.
Basic properties.
The trace is a linear mapping. That is,
for all square matrices and , and all scalars .
A matrix and its transpose have the same trace:
This follows immediately from the fact that transposing a square matrix does not affect elements along the main diagonal.
Trace of a product.
The trace of a square matrix which is the product of two matrices can be rewritten as the sum of entry-wise products of their elements. More precisely, if and are two "m" × "n" matrices, then:
This means that the trace of a product of equal-sized matrices functions in a similar way to a dot product of vectors (imagine and as long vectors with columns stacked on each other). For this reason, generalizations of vector operations to matrices (e.g. in matrix calculus and statistics) often involve a trace of matrix products.
For real matrices and , the trace of a product can also be written in the following forms:
The matrices in a trace of a product can be switched without changing the result: If is an matrix and is an matrix, then
Additionally, for real column matrices formula_7 and formula_8, the trace of the outer product is equivalent to the inner product:
Cyclic property.
More generally, the trace is "invariant under cyclic permutations", that is,
This is known as the "cyclic property".
Arbitrary permutations are not allowed: in general,
However, if products of "three" symmetric matrices are considered, any permutation is allowed, since:
where the first equality is because the traces of a matrix and its transpose are equal. Note that this is not true in general for more than three factors.
Trace of a matrix product.
Unlike the determinant, the trace of the product is not the product of traces, that is there exist matrices and such that
For example, if
then the product is
and the traces are
formula_14
Trace of a Kronecker product.
The trace of the Kronecker product of two matrices is the product of their traces:
Full characterization of the trace.
The following three properties:
characterize the trace completely in the sense that follows. Let be a linear functional on the space of square matrices satisfying . Then and are proportional.
Similarity invariance.
The trace is similarity-invariant, which means that for any square matrix and any invertible matrix of the same dimensions, the matrices and have the same trace. This is because
Trace of product of symmetric and skew-symmetric matrix.
If is symmetric and is skew-symmetric, then
Relation to eigenvalues.
Trace of the identity matrix.
The trace of the identity matrix is the dimension of the space, namely .
This leads to generalizations of dimension using trace.
Trace of an idempotent matrix.
The trace of an idempotent matrix (a matrix for which ) is equal to the rank of .
Trace of a nilpotent matrix.
The trace of a nilpotent matrix is zero.
When the characteristic of the base field is zero, the converse also holds: if for all , then is nilpotent.
When the characteristic is positive, the identity in dimensions is a counterexample, as formula_20, but the identity is not nilpotent.
Trace equals sum of eigenvalues.
More generally, if
is the characteristic polynomial of a matrix , then
that is, the trace of a square matrix equals the sum of the eigenvalues counted with multiplicities.
Trace of commutator.
When both and are matrices, the trace of the (ring-theoretic) commutator of and vanishes: , because and is linear. One can state this as "the trace is a map of Lie algebras from operators to scalars", as the commutator of scalars is trivial (it is an Abelian Lie algebra). In particular, using similarity invariance, it follows that the identity matrix is never similar to the commutator of any pair of matrices.
Conversely, any square matrix with zero trace is a linear combinations of the commutators of pairs of matrices. Moreover, any square matrix with zero trace is unitarily equivalent to a square matrix with diagonal consisting of all zeros.
Trace of Hermitian matrix.
The trace of a Hermitian matrix is real, because the elements on the diagonal are real.
Trace of permutation matrix.
The trace of a permutation matrix is the number of fixed points, because the diagonal term is 1 if the th point is fixed and 0 otherwise.
Trace of projection matrix.
The trace of a projection matrix is the dimension of the target space.
The matrix is idempotent, and more generally, the trace of any idempotent matrix equals its own rank.
Exponential trace.
Expressions like , where is a square matrix, occur so often in some fields (e.g. multivariate statistical theory), that a shorthand notation has become common:
 is sometimes referred to as the exponential trace function; it is used in the Golden–Thompson inequality.
Trace of a linear operator.
In general, given some linear map (where is a finite-dimensional vector space), we can define the trace of this map by considering the trace of a matrix representation of , that is, choosing a basis for and describing as a matrix relative to this basis, and taking the trace of this square matrix. The result will not depend on the basis chosen, since different bases will give rise to similar matrices, allowing for the possibility of a basis-independent definition for the trace of a linear map.
Such a definition can be given using the canonical isomorphism between the space of linear maps on and , where is the dual space of . Let be in and let be in . Then the trace of the indecomposable element is defined to be ; the trace of a general element is defined by linearity. Using an explicit basis for and the corresponding dual basis for , one can show that this gives the same definition of the trace as given above.
Eigenvalue relationships.
If is a linear operator represented by a square matrix with real or complex entries and if are the eigenvalues of (listed according to their algebraic multiplicities), then
This follows from the fact that is always similar to its Jordan form, an upper triangular matrix having on the main diagonal. In contrast, the determinant of is the "product" of its eigenvalues; that is,
More generally,
Derivatives.
The trace corresponds to the derivative of the determinant: it is the Lie algebra analog of the (Lie group) map of the determinant. This is made precise in Jacobi's formula for the derivative of the determinant.
As a particular case, "at the identity", the derivative of the determinant actually amounts to the trace: . From this (or from the connection between the trace and the eigenvalues), one can derive a connection between the trace function, the exponential map between a Lie algebra and its Lie group (or concretely, the matrix exponential function), and the determinant:
For example, consider the one-parameter family of linear transformations given by rotation through angle ,
These transformations all have determinant 1, so they preserve area. The derivative of this family at , the identity rotation, is the antisymmetric matrix
which clearly has trace zero, indicating that this matrix represents an infinitesimal transformation which preserves area.
A related characterization of the trace applies to linear vector fields. Given a matrix , define a vector field on by . The components of this vector field are linear functions (given by the rows of ). Its divergence is a constant function, whose value is equal to .
By the divergence theorem, one can interpret this in terms of flows: if represents the velocity of a fluid at location and is a region in , the net flow of the fluid out of is given by , where is the volume of .
The trace is a linear operator, hence it commutes with the derivative:
Applications.
The trace of a 2 × 2 complex matrix is used to classify Möbius transformations. First, the matrix is normalized to make its determinant equal to one. Then, if the square of the trace is 4, the corresponding transformation is "parabolic". If the square is in the interval , it is "elliptic". Finally, if the square is greater than 4, the transformation is "loxodromic". See classification of Möbius transformations.
The trace is used to define characters of group representations. Two representations of a group are equivalent (up to change of basis on ) if for all .
The trace also plays a central role in the distribution of quadratic forms.
Lie algebra.
The trace is a map of Lie algebras formula_30 from the Lie algebra formula_31 of linear operators on an -dimensional space ( matrices with entries in formula_32) to the Lie algebra of scalars; as is Abelian (the Lie bracket vanishes), the fact that this is a map of Lie algebras is exactly the statement that the trace of a bracket vanishes:
The kernel of this map, a matrix whose trace is zero, is often said to be ' or ', and these matrices form the simple Lie algebra formula_34, which is the Lie algebra of the special linear group of matrices with determinant 1. The special linear group consists of the matrices which do not change volume, while the special linear Lie algebra is the matrices which do not alter volume of "infinitesimal" sets.
In fact, there is an internal direct sum decomposition formula_35 of operators/matrices into traceless operators/matrices and scalars operators/matrices. The projection map onto scalar operators can be expressed in terms of the trace, concretely as:
Formally, one can compose the trace (the counit map) with the unit map formula_37 of "inclusion of scalars" to obtain a map formula_38 mapping onto scalars, and multiplying by . Dividing by makes this a projection, yielding the formula above.
In terms of short exact sequences, one has
which is analogous to
(where formula_41) for Lie groups. However, the trace splits naturally (via formula_42 times scalars) so formula_35, but the splitting of the determinant would be as the th root times scalars, and this does not in general define a function, so the determinant does not split and the general linear group does not decompose:
Bilinear forms.
The bilinear form (where , are square matrices)
is called the Killing form, which is used for the classification of Lie algebras.
The trace defines a bilinear form:
The form is symmetric, non-degenerate and associative in the sense that:
For a complex simple Lie algebra (such as ), every such bilinear form is proportional to each other; in particular, to the Killing form.
Two matrices and are said to be "trace orthogonal" if
Inner product.
For an matrix with complex (or real) entries and H being the conjugate transpose, we have
with equality if and only if .
The assignment
yields an inner product on the space of all complex (or real) matrices.
The norm derived from the above inner product is called the Frobenius norm, which satisfies submultiplicative property as matrix norm. Indeed, it is simply the Euclidean norm if the matrix is considered as a vector of length .
It follows that if and are real positive semi-definite matrices of the same size then
Generalizations.
The concept of trace of a matrix is generalized to the trace class of compact operators on Hilbert spaces, and the analog of the Frobenius norm is called the Hilbert–Schmidt norm.
If is trace-class, then for any orthonormal basis formula_52, the trace is given by
and is finite and independent of the orthonormal basis. 
The partial trace is another generalization of the trace that is operator-valued. The trace of a linear operator which lives on a product space is equal to the partial traces over and :
For more properties and a generalization of the partial trace, see traced monoidal categories.
If is a general associative algebra over a field , then a trace on is often defined to be any map which vanishes on commutators: for all . Such a trace is not uniquely defined; it can always at least be modified by multiplication by a nonzero scalar.
A supertrace is the generalization of a trace to the setting of superalgebras.
The operation of tensor contraction generalizes the trace to arbitrary tensors.
Coordinate-free definition.
The trace can also be approached in a coordinate-free manner, i.e., without referring to a choice of basis, as follows: the space of linear operators on a finite-dimensional vector space (defined over the field ) is isomorphic to the space via the linear map
There is also a canonical bilinear function that consists of applying an element of to an element of to get an element of :
This induces a linear function on the tensor product (by its universal property) , which, as it turns out, when that tensor product is viewed as the space of operators, is equal to the trace.
In particular, given a rank one operator (equivalently, a simple tensor formula_57), the square is formula_58 because on its one-dimensional image, is just scalar multiplication. In terms of the tensor expression, formula_59 and it is the trace (and only non-zero eigenvalue) of ; this gives a coordinate-free interpretation of the diagonal entry. Every operator on an -dimensional space can be expressed as a sum of rank one operators; this gives a coordinate-free version of the sum of diagonal entries.
This also clarifies why and why , as composition of operators (multiplication of matrices) and trace can be interpreted as "the same" pairing. Viewing
one may interpret the composition map
as
coming from the pairing on the middle terms. Taking the trace of the product then comes from pairing on the outer terms, while taking the product in the opposite order and then taking the trace just switches which pairing is applied first. On the other hand, taking the trace of and the trace of corresponds to applying the pairing on the left terms and on the right terms (rather than on inner and outer), and is thus different.
In coordinates, this corresponds to indexes: multiplication is given by
so
which is the same, while
which is different.
For finite-dimensional , with basis and dual basis , then is the -entry of the matrix of the operator with respect to that basis. Any operator is therefore a sum of the form
With defined as above,
The latter, however, is just the Kronecker delta, being 1 if and 0 otherwise. This shows that is simply the sum of the coefficients along the diagonal. This method, however, makes coordinate invariance an immediate consequence of the definition.
Dual.
Further, one may dualize this map, obtaining a map
This map is precisely the inclusion of scalars, sending to the identity matrix: "trace is dual to scalars". In the language of bialgebras, scalars are the "unit", while trace is the "counit".
One can then compose these,
which yields multiplication by , as the trace of the identity is the dimension of the vector space.
Generalizations.
Using the notion of dualizable objects and categorical traces, this approach to traces can be fruitfully axiomatized and applied to other mathematical areas.