How Matrix Trace Works
The trace of a square matrix is one of the simplest but most useful quantities in linear algebra. For an n×n matrix A, the trace, written tr(A), is defined as the sum of the entries on the main diagonal — the entries where the row index equals the column index: tr(A) = a11 + a22 + a33 + ... + ann. Trace is only defined for square matrices, since a non-square matrix has no single diagonal running from corner to corner.
How the trace is calculated
Enter the matrix size (2×2 or 3×3) and fill in the entries. The calculator reads off only the diagonal entries — a11 and a22 for a 2×2 matrix, or a11, a22, and a33 for a 3×3 matrix — and adds them together. For example, for A = [[4,1,2],[0,3,5],[1,2,6]], the diagonal entries are 4, 3, and 6, so tr(A) = 4 + 3 + 6 = 13. Every off-diagonal entry (like a12 or a31) is part of the matrix but plays no role in the trace itself.
Common mistakes
- Summing the wrong entries: the trace only uses a11, a22, ..., ann — do not add row sums, column sums, or off-diagonal entries.
- Confusing trace with determinant: the determinant measures how a matrix scales volume and involves every entry in a more complex formula; the trace is just the diagonal sum.
- Applying trace to a non-square matrix: a 2×3 or 3×2 matrix has no main diagonal in the usual sense, so trace is undefined for it.
Properties and applications
- Linearity: tr(A + B) = tr(A) + tr(B) and tr(cA) = c·tr(A) for a scalar c.
- Cyclic property: tr(AB) = tr(BA) for any matrices where both products are defined, even though AB ≠ BA in general.
- Sum of eigenvalues: tr(A) equals the sum of A's eigenvalues, and det(A) equals their product — two quick checks used when verifying eigenvalue calculations by hand.
- Basis independence: trace is invariant under similarity transformations, tr(A) = tr(P⁻¹AP), which is why it appears in physics and statistics as a coordinate-free scalar summary of a matrix or operator.