Mathwords logoMathwords

Trace of a Matrix — Definition, Formula & Examples

The trace of a matrix is the sum of the entries on its main diagonal. It is only defined for square matrices (same number of rows and columns).

For an n×nn \times n matrix A=[aij]A = [a_{ij}], the trace is defined as tr(A)=i=1naii\operatorname{tr}(A) = \sum_{i=1}^{n} a_{ii}, the sum of all diagonal elements a11,a22,,anna_{11}, a_{22}, \ldots, a_{nn}.

Key Formula

tr(A)=i=1naii=a11+a22++ann\operatorname{tr}(A) = \sum_{i=1}^{n} a_{ii} = a_{11} + a_{22} + \cdots + a_{nn}
Where:
  • AA = An $n \times n$ square matrix
  • aiia_{ii} = The diagonal entry in row $i$, column $i$
  • nn = The number of rows (and columns) of $A$

How It Works

To find the trace, identify the main diagonal of the square matrix — these are the entries where the row index equals the column index. Then add those entries together. The trace has several useful properties: tr(A+B)=tr(A)+tr(B)\operatorname{tr}(A + B) = \operatorname{tr}(A) + \operatorname{tr}(B), tr(cA)=ctr(A)\operatorname{tr}(cA) = c \cdot \operatorname{tr}(A) for any scalar cc, and tr(AB)=tr(BA)\operatorname{tr}(AB) = \operatorname{tr}(BA) even when ABBAAB \neq BA. The trace also equals the sum of the eigenvalues of the matrix, counted with multiplicity.

Worked Example

Problem: Find the trace of the matrix A=[413025768]A = \begin{bmatrix} 4 & 1 & 3 \\ 0 & -2 & 5 \\ 7 & 6 & 8 \end{bmatrix}.
Identify diagonal entries: The main diagonal entries are at positions (1,1), (2,2), and (3,3).
a11=4,a22=2,a33=8a_{11} = 4, \quad a_{22} = -2, \quad a_{33} = 8
Sum the diagonal entries: Add these three values together.
tr(A)=4+(2)+8=10\operatorname{tr}(A) = 4 + (-2) + 8 = 10
Answer: tr(A)=10\operatorname{tr}(A) = 10

Why It Matters

The trace appears throughout linear algebra and its applications. In differential equations, the trace of a 2×22 \times 2 system matrix determines whether solutions spiral inward or outward. In physics and data science, the trace of a covariance matrix gives the total variance across all variables.

Common Mistakes

Mistake: Trying to compute the trace of a non-square matrix.
Correction: The trace is only defined for square matrices. A 3×43 \times 4 matrix, for instance, does not have a well-defined main diagonal that spans all rows and columns, so its trace does not exist.