This articleneeds additional citations forverification. Please helpimprove this article byadding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Trace" linear algebra – news ·newspapers ·books ·scholar ·JSTOR(November 2023) (Learn how and when to remove this message) |
This article needs editing tocomply with Wikipedia'sManual of Style. In particular, it has problems withMOS:FORMULA - avoid mixing <math>...</math> and{{math}} in the same expression. Please helpimprove the content.(July 2025) (Learn how and when to remove this message) |
Inlinear algebra, thetrace of asquare matrixA, denotedtr(A),[1] is the sum of the elements on itsmain diagonal,. It is only defined for a square matrix (n ×n).
The trace of a matrix is the sum of itseigenvalues (counted with multiplicities). Also,tr(AB) = tr(BA) for any matricesA andB of the same size. Thus,similar matrices have the same trace. As a consequence, one can define the trace of alinear operator mapping a finite-dimensionalvector space into itself, since all matrices describing such an operator with respect to a basis are similar.
The trace is related to the derivative of thedeterminant (seeJacobi's formula).
Thetrace of ann ×nsquare matrixA is defined as[1][2][3]: 34 whereaii denotes the entry on thei th row andi th column ofA. The entries ofA can bereal numbers,complex numbers, or more generally elements of afieldF. The trace is not defined for non-square matrices.
LetA be a matrix, with
Then
The trace is alinear mapping. That is,[1][2]for all square matricesA andB, and allscalarsc.[3]: 34
A matrix and itstranspose have the same trace:[1][2][3]: 34
This follows immediately from the fact that transposing a square matrix does not affect elements along the main diagonal.
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, i.e. as the sum of all elements of theirHadamard product. Phrased directly, ifA andB are twom ×n matrices, then:
If one views any realm ×n matrix as a vector of lengthmn (an operation calledvectorization) then the above operation onA andB coincides with the standarddot product. According to the above expression,tr(A⊤A) is a sum of squares and hence is nonnegative, equal to zero if and only ifA is zero.[4]: 7 Furthermore, as noted in the above formula,tr(A⊤B) = tr(B⊤A). These demonstrate the positive-definiteness and symmetry required of aninner product; it is common to calltr(A⊤B) theFrobenius inner product ofA andB. This is a natural inner product on thevector space of all real matrices of fixed dimensions. Thenorm derived from this inner product is called theFrobenius norm, and it satisfies a submultiplicative property, as can be proven with theCauchy–Schwarz inequality:ifA andB are real matrices such thatAB is a square matrix. The Frobenius inner product and norm arise frequently inmatrix calculus andstatistics.
The Frobenius inner product may be extended to ahermitian inner product on thecomplex vector space of all complex matrices of a fixed size, by replacingB by itscomplex conjugate.
The symmetry of the Frobenius inner product may be phrased more directly as follows: the matrices in the trace of a product can be switched without changing the result. IfA andB arem ×n andn ×m real or complex matrices, respectively, then[1][2][3]: 34 [note 1]
This is notable both for the fact thatAB does not usually equalBA, and also since the trace of either does not usually equaltr(A)tr(B).[note 2] Thesimilarity-invariance of the trace, meaning thattr(A) = tr(P−1AP) for any square matrixA and any invertible matrixP of the same dimensions, is a fundamental consequence. This is proved bySimilarity invariance is the crucial property of the trace in order to discuss traces oflinear transformations as below.
Additionally, for real column vectors and, the trace of the outer product is equivalent to the inner product:
More generally, the trace isinvariant undercircular shifts, that is,
This is known as thecyclic property.
Arbitrary permutations are not allowed: in general,
However, if products ofthreesymmetric 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.
The trace of theKronecker product of two matrices is the product of their traces:
The following three properties:characterize the traceup to a scalar multiple in the following sense: If is alinear functional on the space of square matrices that satisfies then and are proportional.[note 3]
For matrices, imposing the normalization makes equal to the trace.
Given anyn ×n matrixA, there is
whereλ1, ..., λn are theeigenvalues ofA counted with multiplicity. This holds true even ifA is a real matrix and some (or all) of the eigenvalues are complex numbers. This may be regarded as a consequence of the existence of theJordan canonical form, together with the similarity-invariance of the trace discussed above.
When bothA andB aren ×n matrices, the trace of the (ring-theoretic)commutator ofA andB vanishes:tr([A,B]) = 0, becausetr(AB) = tr(BA) andtr is linear. One can state this as "the trace is a map ofLie algebrasgln →k from operators to scalars", as the commutator of scalars is trivial (it is anAbelian 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 combination of the commutators of pairs of matrices.[note 4] Moreover, any square matrix with zero trace isunitarily equivalent to a square matrix with diagonal consisting of all zeros.
This leads togeneralizations of dimension using trace.
When the characteristic of the base field is zero, the converse also holds: iftr(Ak) = 0 for allk, thenA is nilpotent.
When the characteristicn > 0 is positive, the identity inn dimensions is a counterexample, as, but the identity is not nilpotent.The trace of an matrix is the coefficient of in thecharacteristic polynomial, possibly changed of sign, according to the convention in the definition of the characteristic polynomial.
IfA is a linear operator represented by a square matrix withreal orcomplex entries and ifλ1, ...,λn are theeigenvalues ofA (listed according to theiralgebraic multiplicities), then
This follows from the fact thatA is alwayssimilar to itsJordan form, an uppertriangular matrix havingλ1, ...,λn on the main diagonal. In contrast, thedeterminant ofA is theproduct of its eigenvalues; that is,
Everything in the present section applies as well to any square matrix with coefficients in analgebraically closed field.
Ifa is a square matrixwith small entries andI denotes theidentity matrix, then we have approximately
Precisely this means that the trace is thederivative of thedeterminant function at the identity matrix.Jacobi's formula
is more general and describes thedifferential of the determinant at an arbitrary square matrix, in terms of the trace and theadjugate of the matrix.
From this (or from the connection between the trace and the eigenvalues), one can derive a relation between the trace function, thematrix exponential function, and the determinant:
A related characterization of the trace applies to linearvector fields. Given a matrixA, define a vector fieldF onRn byF(x) =Ax. The components of this vector field are linear functions (given by the rows ofA). ItsdivergencedivF is a constant function, whose value is equal totr(A).
By thedivergence theorem, one can interpret this in terms of flows: ifF(x) represents the velocity of a fluid at locationx andU is a region inRn, thenet flow of the fluid out ofU is given bytr(A) · vol(U), wherevol(U) is thevolume ofU.
The trace is a linear operator, hence it commutes with the derivative:
In general, given some linear mapf :V →V of finiterank (whereV is avector space), we can define the trace of this map by considering the trace of amatrix representation off, that is, choosing abasis forV and describingf 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 tosimilar matrices, allowing for the possibility of a basis-independent definition for the trace of a linear map.
Such a definition can be given using thecanonical isomorphism between the space of linear endomorphisms ofV of finiterank andV ⊗V*, whereV* is thedual space ofV. Letv be inV and letg be inV*. Then the trace of the decomposable elementv ⊗g is defined to beg(v); the trace of a general element is defined by linearity. The trace of a linear mapf :V →V of finite rank can then be defined as the trace, in the above sense, of the element ofV ⊗V* corresponding tof under the above-mentioned canonical isomorphism. Using an explicit basis forV and the corresponding dual basis forV*, one can show that this gives the same definition of the trace as given above.
The trace can be estimated unbiasedly by "Hutchinson's trick":[5]
Given any matrix, and any random with, we have.
For a proof expand the expectation directly.
Usually, the random vector is sampled from (normal distribution) or (Rademacher distribution).
More sophisticated stochastic estimators of trace have been developed.[6]
If a 2 x 2 real matrix has zero trace, its square is adiagonal matrix.
The trace of a 2 × 2complex matrix is used to classifyMöbius transformations. First, the matrix is normalized to make itsdeterminant equal to one. Then, if the square of the trace is 4, the corresponding transformation isparabolic. If the square is in the interval[0,4), it iselliptic. Finally, if the square is greater than 4, the transformation isloxodromic. Seeclassification of Möbius transformations.
The trace is used to definecharacters ofgroup representations. Two representationsA,B :G →GL(V) of a groupG are equivalent (up to change of basis onV) iftr(A(g)) = tr(B(g)) for allg ∈G.
The trace also plays a central role in the distribution ofquadratic forms.
The trace is a map of Lie algebras from the Lie algebra of linear operators on ann-dimensional space (n ×n matrices with entries in) to the Lie algebraK of scalars; asK 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 iszero, is often said to betraceless ortrace free, and these matrices form thesimple Lie algebra, which is theLie algebra of thespecial linear group of matrices with determinant 1. The special linear group consists of the matrices which do not change volume, while thespecial linear Lie algebra is the matrices which do not alter volume ofinfinitesimal sets.
In fact, there is an internaldirect 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 (thecounit map) with the unit map of "inclusion ofscalars" to obtain a map mapping onto scalars, and multiplying byn. Dividing byn makes this a projection, yielding the formula above.
In terms ofshort exact sequences, one haswhich is analogous to(where) forLie groups. However, the trace splits naturally (via times scalars) so, but the splitting of the determinant would be as thenth root times scalars, and this does not in general define a function, so the determinant does not split and thegeneral linear group does not decompose:
Thebilinear form (whereX,Y are square matrices)
is called theKilling form; it is used to classifyLie algebras.
The trace defines a bilinear form:
The form is symmetric, non-degenerate[note 5] and associative in the sense that:
For a complex simple Lie algebra (such asn), every such bilinear form is proportional to each other; in particular, to the Killing form[citation needed].
Two matricesX andY are said to betrace orthogonal if
There is a generalization to a general representation of a Lie algebra, such that is a homomorphism of Lie algebras The trace form on is defined as above. The bilinear formis symmetric and invariant due to cyclicity.
The concept of trace of a matrix is generalized to thetrace class ofcompact operators onHilbert spaces, and the analog of theFrobenius norm is called theHilbert–Schmidt norm.
If is a trace-class operator, then for anyorthonormal basis, the trace is given byand is finite and independent of the orthonormal basis.[7]
Thepartial 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, seetraced monoidal categories.
If is a generalassociative algebra over a field, then a trace on is often defined to be anyfunctional 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.
Asupertrace is the generalization of a trace to the setting ofsuperalgebras.
The operation oftensor contraction generalizes the trace to arbitrary tensors.
Gomme and Klein (2011) define a matrix trace operator that operates onblock matrices and use it to compute second-order perturbation solutions to dynamic economic models without the need fortensor notation.[8]
Given a vector spaceV, there is a natural bilinear mapV ×V∗ →F given by sending(v, φ) to the scalarφ(v). Theuniversal property of thetensor productV ⊗V∗ automatically implies that this bilinear map is induced by a linear functional onV ⊗V∗.[9]
Similarly, there is a natural bilinear mapV ×V∗ → Hom(V,V) given by sending(v, φ) to the linear mapw ↦ φ(w)v. The universal property of the tensor product, just as used previously, says that this bilinear map is induced by a linear mapV ⊗V∗ → Hom(V,V). IfV is finite-dimensional, then this linear map is alinear isomorphism.[9] This fundamental fact is a straightforward consequence of the existence of a (finite) basis ofV, and can also be phrased as saying that any linear mapV →V can be written as the sum of (finitely many) rank-one linear maps. Composing the inverse of the isomorphism with the linear functional obtained above results in a linear functional onHom(V,V). This linear functional is exactly the same as the trace.
Using the definition of trace as the sum of diagonal elements, the matrix formulatr(AB) = tr(BA) is straightforward to prove, and was given above. In the present perspective, one is considering linear mapsS andT, and viewing them as sums of rank-one maps, so that there are linear functionalsφi andψj and nonzero vectorsvi andwj such thatS(u) = Σφi(u)vi andT(u) = Σψj(u)wj for anyu inV. Then
for anyu inV. The rank-one linear mapu ↦ψj(u)φi(wj)vi has traceψj(vi)φi(wj) and so
Following the same procedure withS andT reversed, one finds exactly the same formula, proving thattr(S ∘T) equalstr(T ∘S).
The above proof can be regarded as being based upon tensor products, given that the fundamental identity ofEnd(V) withV ⊗V∗ is equivalent to the expressibility of any linear map as the sum of rank-one linear maps. As such, the proof may be written in the notation of tensor products. Then one may consider the multilinear mapV ×V∗ ×V ×V∗ →V ⊗V∗ given by sending(v,φ,w,ψ) toφ(w)v ⊗ψ. Further composition with the trace map then results inφ(w)ψ(v), and this is unchanged if one were to have started with(w,ψ,v,φ) instead. One may also consider the bilinear mapEnd(V) × End(V) → End(V) given by sending(f,g) to the compositionf ∘g, which is then induced by a linear mapEnd(V) ⊗ End(V) → End(V). It can be seen that this coincides with the linear mapV ⊗V∗ ⊗V ⊗V∗ →V ⊗V∗. The established symmetry upon composition with the trace map then establishes the equality of the two traces.[9]
For any finite dimensional vector spaceV, there is a natural linear mapF →V ⊗V'; in the language of linear maps, it assigns to a scalarc the linear mapc⋅idV. Sometimes this is calledcoevaluation map, and the traceV ⊗V' →F is calledevaluation map.[9] These structures can be axiomatized to definecategorical traces in the abstract setting ofcategory theory.