Trace (linear algebra)
where aii denotes the entry on the ith row and ith column of A. The trace of a matrix is the sum of the (complex) eigenvalues, 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. Note that the trace is only defined for a square matrix (i.e., n × n).
- 1 Example
- 2 Properties
- 3 Exponential trace
- 4 Trace of a linear operator
- 5 Applications
- 6 Lie algebra
- 7 Inner product
- 8 Generalization
- 9 Coordinate-free definition
- 10 See also
- 11 Notes
- 12 External links
Let A be a matrix, with
The trace is a linear mapping. That is,
for all square matrices A and B, and all scalars c.
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 product can be rewritten as the sum of entry-wise products of elements:
This means that the trace of a product of matrices functions similarly to a dot product of vectors. For this reason, generalizations of vector operations to matrices (e.g. in matrix calculus and statistics) often involve a trace of matrix products.
The trace of a product can also be written in the following forms:
The matrices in a trace of a product can be switched: If A is an m×n matrix and B is an n×m matrix, then
Equivalently, the trace is invariant under cyclic permutations, i.e.,
This is known as the cyclic property.
Note that arbitrary permutations are not allowed: in general,
However, if products of three symmetric matrices are considered, any permutation is allowed. (Proof: tr(ABC) = tr(AT BT CT) = tr(AT(CB)T) = tr((CB)TAT) = tr((ACB)T) = tr(ACB), where the last equality is because the traces of a matrix and its transpose are equal.) For more than three factors this is not true.
The following three properties:
The trace is similarity-invariant, which means that A and P−1AP have the same trace. This is because
The trace of the identity matrix is the dimension of the space; this leads to generalizations of dimension using trace. The trace of an idempotent matrix A (for which A2 = A) is the rank of A. The trace of a nilpotent matrix is zero.
More generally, if f(x) = (x − λ1)d1···(x − λk)dk is the characteristic polynomial of a matrix A, then
When both A and B are n-by-n, the trace of the (ring-theoretic) commutator of A and B vanishes: tr([A, B]) = 0; 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.
The trace of any power 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.
The trace of a Hermitian matrix is real, because the elements on the diagonal are real.
The trace of a projection matrix is the dimension of the target space. If
Expressions like tr(exp(A)), where A is a square matrix, occur so often in some fields (e.g. multivariate statistical theory), that a shorthand notation has become common:
This is sometimes referred to as the exponential trace function; it is used in the Golden–Thompson inequality.
Trace of a linear operator
Given some linear map f : V → V (V is a finite-dimensional vector space) generally, we can define the trace of this map by considering the trace of matrix representation of f, that is, choosing a basis for V and describing f 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 End(V) of linear maps on V and V ⊗ V*, where V* is the dual space of V. Let v be in V and let f be in V*. Then the trace of the indecomposable element v ⊗ f is defined to be f(v); the trace of a general element is defined by linearity. Using an explicit basis for V and the corresponding dual basis for V*, one can show that this gives the same definition of the trace as given above.
This follows from the fact that A is always similar to its Jordan form, an upper triangular matrix having λ1,...,λn on the main diagonal. In contrast, the determinant of is the product of its eigenvalues; i.e.,
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 θ = 0, 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 A, define a vector field F on ℝn by F(x) = A x. The components of this vector field are linear functions (given by the rows of A). Its divergence div F is a constant function, whose value is equal to tr(A). By the divergence theorem, one can interpret this in terms of flows: if F(x) represents the velocity of a fluid at location x and U is a region in ℝn, the net flow of the fluid out of U is given by tr(A) · vol(U), where vol(U) is the volume of U.
The trace is a linear operator, hence it commutes with the derivative:
The trace of a 2-by-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 [0,4), it is elliptic. Finally, if the square is greater than 4, the transformation is loxodromic. See classification of Möbius transformations.
The trace also plays a central role in the distribution of quadratic forms.
The trace is a map of Lie algebras from the Lie algebra gln of operators on a n-dimensional space (n × n matrices) to the Lie algebra k of scalars; as k 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 traceless or tracefree, and these matrices form the simple Lie algebra sln, 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 algebra is the matrices which infinitesimally do not change volume.
In fact, there is an internal direct sum decomposition 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 of "inclusion of scalars" to obtain a map mapping onto scalars, and multiplying by n. Dividing by n makes this a projection, yielding the formula above.
In terms of short exact sequences, one has
which is analogous to
for Lie groups. However, the trace splits naturally (via times scalars) so , but the splitting of the determinant would be as the nth 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:
The bilinear form
is called the Killing form, which is used for the classification of Lie algebras.
The trace defines a bilinear form:
(x, y square matrices).
The form is symmetric, non-degenerate and associative in the sense that:
For a complex simple Lie algebra (e.g., ), every such bilinear form is proportional to each other; in particular, to the Killing form.
Two matrices x and y are said to be trace orthogonal if
For an m-by-n matrix A with complex (or real) entries and * being the conjugate transpose, we have
with equality if and only if A = 0. The assignment
yields an inner product on the space of all complex (or real) m-by-n matrices.
It follows that if A and B are positive semi-definite matrices of the same size then
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 the article on traced monoidal categories.
If A is a general associative algebra over a field k, then a trace on A is often defined to be any map tr: A → k which vanishes on commutators: tr([a, b]) = 0 for all a, b in A. Such a trace is not uniquely defined; it can always at least be modified by multiplication by a nonzero scalar.
The operation of tensor contraction generalizes the trace to arbitrary tensors.
We can identify the space of linear operators on a vector space V with the space , where . We also have a canonical bilinear function that consists of applying an element w* of V* to an element v of V to get an element of F, in symbols . 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.
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 A and the trace of B 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 and which is the same, while , which is different.
For finite-dimensional, with basis and dual basis , then is the ij'-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 i = j 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.
Further, one may dualize this map, obtaining a map . This map is precisely the inclusion of scalars, sending 1 ∈ F 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 n, as the trace of the identity is the dimension of the vector space.
- Trace of a tensor with respect to a metric tensor
- Characteristic function
- Field trace
- Golden–Thompson inequality
- Specht's theorem
- Trace class
- Trace inequalities
- von Neumann's trace inequality
- This is immediate from the definition of the matrix product:
- if and only if and (with the standard basis ),
- Proof: is a semisimple Lie algebra and thus every element in it is a linear combination of commutators of some pairs of elements, otherwise the derived algebra would be a proper ideal.
- This follows from the fact that if and only if
- Can be proven with the Cauchy–Schwarz inequality.