The matrix trace is a scalar obtained by adding the main diagonal entries of a square matrix. Usually written or , it is a fundamental operation in linear algebra. Although defined using matrix entries, the trace is unchanged by a change of basis and equals the sum of the matrix’s eigenvalues, counted with algebraic multiplicity. It therefore describes an intrinsic property of the represented linear operator rather than merely its coordinate representation. (learning.quantum.ibm.com)
Definition and elementary properties
For an matrix ,
For example,
Only the diagonal entries contribute directly. The definition applies to matrices over the real numbers, the complex numbers, or more generally a field. (online.stat.psu.edu)
Trace is linear: for matrices of the same size and scalars ,
Thus trace is a scalar-valued linear map on the vector space of square matrices. The identity matrix has trace , and the zero matrix has trace zero. Transposition leaves trace unchanged:
These identities follow immediately by summing diagonal entries. (learning.quantum.ibm.com)
Cyclicity and basis independence
A particularly useful identity is
It holds even when is and is , so the two products need not have the same size. Expanding the diagonal sums gives a direct proof:
More generally, compatible factors may be rotated cyclically:
This does not permit arbitrary rearrangement; in general, . (ericdarve.github.io)
For any invertible matrix , cyclicity yields
The matrices and represent the same linear transformation in different choices of basis. Consequently, the trace of an operator on a finite-dimensional space can be defined using any matrix representation. Basis independence is what makes trace useful in coordinate-free formulations. (ericdarve.github.io)
Eigenvalues and the characteristic polynomial
If are the eigenvalues of a complex square matrix, repeated according to algebraic multiplicity, then
For a real matrix, nonreal eigenvalues must also be included. Unlike the determinant, which is their product, trace measures their sum. Neither quantity by itself determines all eigenvalues in dimensions greater than two. (math.mit.edu)
The identity remains valid without assuming diagonalizability. With the convention
the characteristic polynomial begins
Factoring it into linear factors over the complex numbers identifies the coefficient of as minus the sum of its roots. For a matrix, this gives the complete formula
Thus trace and determinant together determine the two eigenvalues, including their multiplicities. (math.mit.edu)
Inner products and differentiation
For real matrices of the same dimensions,
This is the Frobenius inner product, with associated squared norm
For complex matrices, the transpose is replaced by the conjugate transpose , giving . Trace therefore converts entrywise sums into compact matrix expressions. (math.uwaterloo.ca)
In mathematical optimization, this notation also simplifies differentiation. Under the entrywise convention for the gradient of a real matrix variable ,
The second identity underlies differentiation of squared matrix-error terms and quadratic penalties. (math.uwaterloo.ca)
Statistical and quantum applications
For a real random vector with covariance matrix , the trace is the sum of its component variances. If the mean is and second moments are finite, then
More generally, for a fixed real symmetric matrix ,
These formulas connect trace with expected values of quadratic quantities without requiring a normal distribution. (math.uwaterloo.ca)
In finite-dimensional quantum mechanics, a density matrix is positive semidefinite and normalized by . For an observable represented by , its expectation is . The related partial trace removes one subsystem from a composite-system description, producing the density matrix of the remaining subsystem rather than a scalar. (learning.quantum.ibm.com)
Computation and estimation
If diagonal entries are directly accessible, evaluating trace requires only their sum: additions for an matrix. Computing eigenvalues solely to obtain trace is therefore unnecessary. This operation count follows directly from the definition. (online.stat.psu.edu)
For a large matrix accessible mainly through matrix–vector products, stochastic estimation offers an alternative. If a real random vector satisfies , then
Averaging independent evaluations produces an unbiased trace estimate. Hutchinson-type methods use such quadratic forms to avoid explicitly constructing matrices, including large derivative matrices arising in scientific computing. (arxiv.org)