Trace (linear algebra)

From Wikipedia, the free encyclopedia
Jump to: navigation, search
For other uses, see Trace (disambiguation).

In linear algebra, the trace of an n-by-n square matrix A is defined to be the sum of the elements on the main diagonal (the diagonal from the upper left to the lower right) of A, i.e.,

\operatorname{tr}(A) = a_{11} + a_{22} + \dots + a_{nn}=\sum_{i=1}^{n} a_{ii}

where ann denotes the entry on the n-th row and n-th 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).

Geometrically, the trace can be interpreted as the infinitesimal change in volume (as the derivative of the determinant), which is made precise in Jacobi's formula.

The term trace is a calque from the German Spur (cognate with the English spoor), which, as a function in mathematics, is often abbreviated to "tr".

Example[edit]

Let A be a matrix, with


 A=
\begin{bmatrix}
  a & b & c \\
  d & e & f \\
  g & h & i
 \end{bmatrix}
 .

Then tr(A) = a + e + i.

Properties[edit]

Basic properties[edit]

The trace is a linear mapping. That is,

\operatorname{tr}(A + B) = \operatorname{tr}(A) + \operatorname{tr}(B),
\operatorname{tr}(cA) = c \operatorname{tr}(A).

for all square matrices A and B, and all scalars c.

A matrix and its transpose have the same trace:

 \operatorname{tr}(A) = \operatorname{tr}(A^{\mathrm T}).

This follows immediately from the fact that transposing a square matrix does not affect elements along the main diagonal.

Trace of a product[edit]

The trace of a product can be rewritten as the sum of entry-wise products of elements:

\operatorname{tr}(X^{\mathrm T}Y) = \operatorname{tr}(XY^{\mathrm T}) = \operatorname{tr}(Y^{\mathrm T}X) = \operatorname{tr}(YX^{\mathrm T}) = \sum_{i,j}X_{ij}Y_{ij}.

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:

\operatorname{tr}(X^{\mathrm T}Y) = \sum_{ij}(X \circ Y)_{ij}
(using the Hadamard product, i.e. entry-wise product).
\operatorname{tr}(X^{\mathrm T}Y) = \operatorname{vec}(Y)^{\mathrm T} \operatorname{vec}(X) = \operatorname{vec}(X)^{\mathrm T}\operatorname{vec}(Y)
(using the vectorization operator).

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

\operatorname{tr}(AB) = \operatorname{tr}(BA).[1]

Equivalently, the trace is invariant under cyclic permutations, i.e.,

\operatorname{tr}(ABCD) = \operatorname{tr}(BCDA) = \operatorname{tr}(CDAB) = \operatorname{tr}(DABC).

This is known as the cyclic property.

Note that arbitrary permutations are not allowed: in general,

\operatorname{tr}(ABC) \neq \operatorname{tr}(ACB).

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.

Unlike the determinant, the trace of the product is not the product of traces. What is true is that the trace of the tensor product of two matrices is the product of their traces:

\operatorname{tr}(X \otimes Y) = \operatorname{tr}(X)\operatorname{tr}(Y).

Other properties[edit]

The following three properties:

\operatorname{tr}(A + B) = \operatorname{tr}(A) + \operatorname{tr}(B),
\operatorname{tr}(cA) = c\cdot \operatorname{tr}(A),
\operatorname{tr}(AB) = \operatorname{tr}(BA),

characterize the trace completely in the sense as follows. Let f be a linear functional on the space of square matrices satisfying f(x y) = f(y x). Then f and tr are proportional.[2]

The trace is similarity-invariant, which means that A and P−1AP have the same trace. This is because

\operatorname{tr}(P^{-1}AP) = \operatorname{tr}(P^{-1}(AP)) = \operatorname{tr}((AP) P^{-1}) = \operatorname{tr}(A (PP^{-1}))= \operatorname{tr}(A).

If A is symmetric and B is antisymmetric, then

\operatorname{tr}(AB) = 0.

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

\operatorname{tr}(A) = d_1 \lambda_1 + \cdots + d_k 
\lambda_k.

When both A and B are n-by-n, the trace of the (ring-theoretic) commutator of A and B vanishes: tr([AB]) = 0; one can state this as "the trace is a map of Lie algebras gl_n \to k 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.[3] 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 \operatorname{tr}(x^k) = 0 for all k, then x is nilpotent.

The trace of a Hermitian matrix is real, because the elements on the diagonal are real.

P_X = X\left(X^{\mathrm T} X\right)^{-1}X^{\mathrm T},
then
\operatorname{tr}\left(P_X \right)=\operatorname{rank}\left(X\right).

Exponential trace[edit]

Expressions like exp(tr(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:

\operatorname{etr}(A) := \exp(\operatorname{tr}(A)).

This is sometimes referred to as the exponential trace function; it is used in the Golden–Thompson inequality.

Trace of a linear operator[edit]

Given some linear map f : VV (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 VV*, where V* is the dual space of V. Let v be in V and let f be in V*. Then the trace of the decomposable element vf 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.

Eigenvalue relationships[edit]

If A is a square n-by-n matrix with real or complex entries and if λ1,...,λn are the eigenvalues of A (listed according to their algebraic multiplicities), then

\operatorname{tr}(A) = \sum_i \lambda_i.

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 A is the product of its eigenvalues; i.e.,

\operatorname{det}(A) = \prod_i \lambda_i.

More generally,

\operatorname{tr}(A^k) = \sum_i \lambda_i^k.

Derivatives[edit]

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: \operatorname{tr}=\operatorname{det}'_I. 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:

\det(\exp(A)) = \exp(\operatorname{tr}(A)).


For example, consider the one-parameter family of linear transformations given by rotation through angle θ,

R_{\theta} = \left(\begin{array}{cc}\cos \theta & -\sin \theta\\\sin \theta&\cos \theta\end{array}\right).

These transformations all have determinant 1, so they preserve area. The derivative of this family at θ = 0 is the antisymmetric matrix

A = \left(\begin{array}{cc}0 & -1\\1&0\end{array}\right)

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:

\operatorname{d} \operatorname{tr} (X) = \operatorname{tr}(\operatorname{d\!} X).

Applications[edit]

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 is used to define characters of group representations. Two representations A, B : G \to \mathit{GL}(V) of a group G are equivalent (up to change of basis on V) if \operatorname{tr} A(g) = \operatorname{tr} B(g) for all gG.

The trace also plays a central role in the distribution of quadratic forms.

Lie algebra[edit]

The trace is a map of Lie algebras \operatorname{tr}\colon \mathit{gl}_n \to k 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: \operatorname{tr}([A, B]) = 0.

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 \mathit{gl}_n = \mathit{sl}_n \oplus k 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:

A \mapsto \textstyle{\frac{1}{n}}\operatorname{tr}(A) \cdot I.

Formally, one can compose the trace (the counit map) with the unit map k \to \mathit{gl}_n of "inclusion of scalars" to obtain a map \mathit{gl}_n \to \mathit{gl}_n 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

0 \to \mathit{sl}_n \to \mathit{gl}_n \overset{\operatorname{tr}}{\to} k \to 0

which is analogous to

1 \to \mathit{SL}_n \to \mathit{GL}_n \overset{\operatorname{det}}{\to} K^* \to 1

for Lie groups. However, the trace splits naturally (via \textstyle{\frac{1}{n}} times scalars) so \mathit{gl}_n = sl_n \oplus k, 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: \mathit{GL}_n \neq SL_n \times K^*.

Bilinear forms[edit]

The bilinear form

B(x, y) = \operatorname{tr}(\operatorname{ad}(x)\operatorname{ad}(y))\text{ where }\operatorname{ad}(x)y = [x, y] = xy - yx

is called the Killing form, which is used for the classification of Lie algebras.

The trace defines a bilinear form:

(x, y) \mapsto \operatorname{tr}(xy)

(x, y square matrices).

The form is symmetric, non-degenerate[4] and associative in the sense that:

\operatorname{tr}(x[y, z]) = \operatorname{tr}([x, y]z).

For a complex simple Lie algebra (e.g., \mathfrak{sl}_n), 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

\operatorname{tr}(xy) = 0.

Inner product[edit]

For an m-by-n matrix A with complex (or real) entries and * being the conjugate transpose, we have

 \operatorname{tr}(A^* A) \ge 0

with equality if and only if A = 0. The assignment

\langle A, B\rangle = \operatorname{tr}(B^* A)

yields an inner product on the space of all complex (or real) m-by-n matrices.

The norm induced by the above inner product is called the Frobenius norm. Indeed it is simply the Euclidean norm if the matrix is considered as a vector of length m n.

It follows that if A and B are positive semi-definite matrices of the same size then

 0 \leq \operatorname{tr}(A B)^2 \leq \operatorname{tr}(A^2) \operatorname{tr}(B^2) \leq \operatorname{tr}(A)^2 \operatorname{tr}(B)^2.[5]

Generalization[edit]

The concept of trace of a matrix is generalised to the trace class of compact operators on Hilbert spaces, and the analog of the Frobenius norm is called the Hilbert–Schmidt norm.

The partial trace is another generalization of the trace that is operator-valued. The trace of a linear operator Z which lives on a product space A \otimes B is equal to the partial traces over A and B: \operatorname{tr}(Z)=\operatorname{tr}_A(\operatorname{tr}_B(Z))=\operatorname{tr}_B(\operatorname{tr}_A(Z)).

If A is a general associative algebra over a field k, then a trace on A is often defined to be any map tr: Ak 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.

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[edit]

We can identify the space of linear operators on a vector space V with the space V \otimes V^*, where v \otimes h = (w \mapsto h(w)v). We also have a canonical bilinear function t \colon V \times V^* \to F that consists of applying an element w* of V* to an element v of V to get an element of F, in symbols t(v, w^*) := w^*(v) \in F. This induces a linear function on the tensor product (by its universal property) t\colon V \otimes V^* \to F, 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 \operatorname{tr}(AB)=\operatorname{tr}(BA) and why \operatorname{tr}(AB)\neq\operatorname{tr}(A)\operatorname{tr}(B), as composition of operators (multiplication of matrices) and trace can be interpreted as the same pairing. Viewing \operatorname{End}(V) \cong V \otimes V^*, one may interpret the composition map \operatorname{End}(V) \times \operatorname{End}(V) \to \operatorname{End}(V) as

(V \otimes V^*) \times (V \otimes V^*) \to (V \otimes V^*)

coming from the pairing V^* \times V \to F 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 \textstyle{(AB)_{ik} = \sum_j a_{ij}b_{jk}}, so \textstyle{\operatorname{tr}(AB) = \sum_{ij} a_{ij}b_{ji}} and \textstyle{\operatorname{tr}(BA) = \sum_{ij} b_{ij}a_{ji}} which is the same, while \textstyle{\operatorname{tr}(A)\cdot \operatorname{tr}(B) = \sum_i a_{ii} \cdot \sum_j b_{jj}}, which is different.

For V finite-dimensional, with basis \{ e_i \} and dual basis \{ e^i \}, then e_i \otimes e^j is the ij'-entry of the matrix of the operator with respect to that basis. Any operator A is therefore a sum of the form A = a_{ij} e_i \otimes e^j. With t defined as above, t(A) = a_{ij} t(e_i \otimes e^j). The latter, however, is just the Kronecker delta, being 1 if i = j and 0 otherwise. This shows that t(A) is simply the sum of the coefficients along the diagonal. This method, however, makes coordinate invariance an immediate consequence of the definition.

Dual[edit]

Further, one may dualize this map, obtaining a map F^* = F \to V \otimes V^* \cong \operatorname{End}(V). 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, F \overset{I}{\to} \operatorname{End}(V) \overset{\operatorname{tr}}{\to} F, which yields multiplication by n, as the trace of the identity is the dimension of the vector space.

See also[edit]

Notes[edit]

  1. ^ This is immediate from the definition of the matrix product:
    \operatorname{tr}(AB) = \sum_{i=1}^m \left(AB\right)_{ii} = \sum_{i=1}^m \sum_{j=1}^n A_{ij} B_{ji} = \sum_{j=1}^n \sum_{i=1}^m B_{ji} A_{ij} = \sum_{j=1}^n \left(BA\right)_{jj} = \operatorname{tr}(BA).
  2. ^ Proof:
    f(e_{ij}) = 0 if and only if i \neq j and f(e_{jj}) = f(e_{11}) (with the standard basis e_{ij}),
    and thus
    f(A) = \sum_{i, j} [A]_{ij} f(e_{ij}) = \sum_i [A]_{ii} f(e_{11}) = f(e_{11}) \operatorname{tr}(A).
    More abstractly, this corresponds to the decomposition \mathit{gl}_n = \mathit{sl}_n \oplus k, as tr(AB) = tr(BA) (equivalently, \operatorname{tr}([A, B]) = 0) defines the trace on sln, which has complement the scalar matrices, and leaves one degree of freedom: any such map is determined by its value on scalars, which is one scalar parameter and hence all are multiple of the trace, a non-zero such map.
  3. ^ Proof: \mathfrak{sl}_n 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.
  4. ^ This follows from the fact that \operatorname{tr}(A^*A) = 0 if and only if A = 0
  5. ^ Can be proven with the Cauchy–Schwarz inequality.

External links[edit]