{
  "id": "matrix-trace",
  "title": "Matrix Trace",
  "lang": "en",
  "source_lang": "en",
  "summary": "The matrix trace is the sum of a square matrix’s diagonal entries, equal to the sum of its eigenvalues and invariant under changes of basis.",
  "category": "mathematics",
  "subcategory": "algebra",
  "type": "concept",
  "aliases": [
    "Trace of a matrix",
    "Trace"
  ],
  "generated_at": "2026-10-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/matrix-trace/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/matrix-trace/",
      "json": "https://aiwiki.page/zh/matrix-trace.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The matrix trace is a scalar obtained by adding the main diagonal entries of a square matrix. Usually written \\(\\operatorname{tr}(A)\\) or \\(\\operatorname{Tr}(A)\\), 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)"
    },
    {
      "heading": "Definition and elementary properties",
      "text": "For an \\(n\\times n\\) matrix \\(A=(a_{ij})\\),\n\n\\[\\operatorname{tr}(A)=\\sum_{i=1}^{n}a_{ii}.\\]\n\nFor example,\n\n\\[A=\\begin{pmatrix}2&7\\\\-1&3\\end{pmatrix} \\quad\\Longrightarrow\\quad \\operatorname{tr}(A)=2+3=5.\\]\n\nOnly 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)\n\nTrace is linear: for matrices \\(A,B\\) of the same size and scalars \\(\\alpha,\\beta\\),\n\n\\[\\operatorname{tr}(\\alpha A+\\beta B) =\\alpha\\operatorname{tr}(A)+\\beta\\operatorname{tr}(B).\\]\n\nThus trace is a scalar-valued linear map on the vector space of square matrices. The identity matrix \\(I_n\\) has trace \\(n\\), and the zero matrix has trace zero. Transposition leaves trace unchanged:\n\n\\[\\operatorname{tr}(A^{\\mathsf T})=\\operatorname{tr}(A).\\]\n\nThese identities follow immediately by summing diagonal entries. (learning.quantum.ibm.com)"
    },
    {
      "heading": "Cyclicity and basis independence",
      "text": "A particularly useful identity is\n\n\\[\\operatorname{tr}(AB)=\\operatorname{tr}(BA).\\]\n\nIt holds even when \\(A\\) is \\(m\\times n\\) and \\(B\\) is \\(n\\times m\\), so the two products need not have the same size. Expanding the diagonal sums gives a direct proof:\n\n\\[\\operatorname{tr}(AB) =\\sum_{i=1}^{m}\\sum_{j=1}^{n}a_{ij}b_{ji} =\\operatorname{tr}(BA).\\]\n\nMore generally, compatible factors may be rotated cyclically:\n\n\\[\\operatorname{tr}(ABC) =\\operatorname{tr}(BCA) =\\operatorname{tr}(CAB).\\]\n\nThis does not permit arbitrary rearrangement; in general, \\(\\operatorname{tr}(ABC)\\ne\\operatorname{tr}(ACB)\\). (ericdarve.github.io)\n\nFor any invertible matrix \\(S\\), cyclicity yields\n\n\\[\\operatorname{tr}(S^{-1}AS) =\\operatorname{tr}(ASS^{-1}) =\\operatorname{tr}(A).\\]\n\nThe matrices \\(A\\) and \\(S^{-1}AS\\) 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)"
    },
    {
      "heading": "Eigenvalues and the characteristic polynomial",
      "text": "If \\(\\lambda_1,\\ldots,\\lambda_n\\) are the eigenvalues of a complex square matrix, repeated according to algebraic multiplicity, then\n\n\\[\\operatorname{tr}(A)=\\lambda_1+\\cdots+\\lambda_n.\\]\n\nFor 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)\n\nThe identity remains valid without assuming diagonalizability. With the convention\n\n\\[p_A(t)=\\det(tI-A),\\]\n\nthe characteristic polynomial begins\n\n\\[p_A(t)=t^n-\\operatorname{tr}(A)t^{n-1}+\\cdots.\\]\n\nFactoring it into linear factors over the complex numbers identifies the coefficient of \\(t^{n-1}\\) as minus the sum of its roots. For a \\(2\\times2\\) matrix, this gives the complete formula\n\n\\[p_A(t)=t^2-\\operatorname{tr}(A)t+\\det(A).\\]\n\nThus trace and determinant together determine the two eigenvalues, including their multiplicities. (math.mit.edu)"
    },
    {
      "heading": "Inner products and differentiation",
      "text": "For real matrices \\(A,B\\) of the same dimensions,\n\n\\[\\langle A,B\\rangle_F =\\operatorname{tr}(A^{\\mathsf T}B) =\\sum_{i,j}a_{ij}b_{ij}.\\]\n\nThis is the Frobenius inner product, with associated squared norm\n\n\\[\\|A\\|_F^2=\\operatorname{tr}(A^{\\mathsf T}A).\\]\n\nFor complex matrices, the transpose is replaced by the conjugate transpose \\(A^*\\), giving \\(\\operatorname{tr}(A^*B)\\). Trace therefore converts entrywise sums into compact matrix expressions. (math.uwaterloo.ca)\n\nIn mathematical optimization, this notation also simplifies differentiation. Under the entrywise convention for the gradient of a real matrix variable \\(X\\),\n\n\\[\\nabla_X\\operatorname{tr}(C^{\\mathsf T}X)=C, \\qquad \\nabla_X\\operatorname{tr}(X^{\\mathsf T}X)=2X.\\]\n\nThe second identity underlies differentiation of squared matrix-error terms and quadratic penalties. (math.uwaterloo.ca)"
    },
    {
      "heading": "Statistical and quantum applications",
      "text": "For a real random vector with covariance matrix \\(\\Sigma\\), the trace is the sum of its component variances. If the mean is \\(\\mu\\) and second moments are finite, then\n\n\\[\\mathbb E\\!\\left[\\|X-\\mu\\|^2\\right] =\\operatorname{tr}(\\Sigma).\\]\n\nMore generally, for a fixed real symmetric matrix \\(A\\),\n\n\\[\\mathbb E[X^{\\mathsf T}AX] =\\operatorname{tr}(A\\Sigma)+\\mu^{\\mathsf T}A\\mu.\\]\n\nThese formulas connect trace with expected values of quadratic quantities without requiring a normal distribution. (math.uwaterloo.ca)\n\nIn finite-dimensional quantum mechanics, a density matrix \\(\\rho\\) is positive semidefinite and normalized by \\(\\operatorname{tr}(\\rho)=1\\). For an observable represented by \\(O\\), its expectation is \\(\\operatorname{tr}(\\rho O)\\). 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)"
    },
    {
      "heading": "Computation and estimation",
      "text": "If diagonal entries are directly accessible, evaluating trace requires only their sum: \\(n-1\\) additions for an \\(n\\times n\\) matrix. Computing eigenvalues solely to obtain trace is therefore unnecessary. This operation count follows directly from the definition. (online.stat.psu.edu)\n\nFor a large matrix accessible mainly through matrix–vector products, stochastic estimation offers an alternative. If a real random vector \\(z\\) satisfies \\(\\mathbb E[zz^{\\mathsf T}]=I\\), then\n\n\\[\\mathbb E[z^{\\mathsf T}Az]=\\operatorname{tr}(A).\\]\n\nAveraging 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)"
    }
  ],
  "links": [
    "matrix",
    "linear-algebra",
    "real-number",
    "complex-number",
    "field-mathematics",
    "linear-map",
    "vector-space",
    "identity-matrix",
    "matrix-transpose",
    "linear-transformation",
    "basis-linear-algebra",
    "eigenvalues-and-eigenvectors",
    "determinant",
    "matrix-diagonalization",
    "characteristic-polynomial",
    "inner-product",
    "mathematical-optimization",
    "gradient",
    "covariance-matrix",
    "variance",
    "expected-value",
    "quantum-mechanics",
    "density-matrix"
  ],
  "sources": [
    {
      "title": "learning.quantum.ibm.com/course/general-formulation-of-quantum-information/dens…",
      "url": "https://learning.quantum.ibm.com/course/general-formulation-of-quantum-information/density-matrices"
    },
    {
      "title": "online.stat.psu.edu/statprogram/reviews/matrix-algebra/properties",
      "url": "https://online.stat.psu.edu/statprogram/reviews/matrix-algebra/properties"
    },
    {
      "title": "ericdarve.github.io/NLA/content/trace.html",
      "url": "https://ericdarve.github.io/NLA/content/trace.html"
    },
    {
      "title": "math.mit.edu/~gs/dela/dela_6-1.pdf",
      "url": "https://math.mit.edu/~gs/dela/dela_6-1.pdf"
    },
    {
      "title": "math.uwaterloo.ca/~hwolkowi/matrixcookbook.pdf",
      "url": "https://www.math.uwaterloo.ca/~hwolkowi/matrixcookbook.pdf"
    },
    {
      "title": "arxiv.org/abs/2312.14499",
      "url": "https://arxiv.org/abs/2312.14499"
    }
  ],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}