What Is the Matrix Trace?
The trace of a square matrix is the sum of the elements on its main diagonal — the entries running from the top-left corner to the bottom-right corner. It is written \(\operatorname{tr}(A)\). The trace is only defined for square matrices (same number of rows and columns), and it is one of the most useful single-number summaries of a matrix in linear algebra.
How to Use This Calculator
Pick the size of your matrix (2×2, 3×3 or 4×4), then enter the diagonal entries \(\text{A}_{11}\), \(\text{A}_{22}\), … only. Because the trace depends solely on the diagonal, off-diagonal numbers are irrelevant and you do not need to type them. The calculator instantly returns the sum.
The Formula Explained
For an n×n matrix A, the trace is:
$$\operatorname{tr}(A) = \text{A}_{11} + \text{A}_{22} + \dots + \text{A}_{nn} = \sum_i \text{A}_{ii}$$
You simply walk down the diagonal and add up each entry. The result is a single scalar.
Worked Example
Consider the 3×3 matrix with diagonal entries 4, −2 and 7 (the off-diagonal values can be anything). Then $$\operatorname{tr}(A) = 4 + (-2) + 7 = \mathbf{9}.$$ That's it — the trace is 9 regardless of every other entry in the matrix.
FAQ
Does the trace work for non-square matrices? No. The trace is only defined for square matrices because a diagonal entry \(\text{A}_{ii}\) requires equal row and column counts.
Why is the trace useful? It equals the sum of the matrix's eigenvalues, is invariant under similarity transformations, and appears throughout statistics, physics and machine learning.
Is \(\operatorname{tr}(A + B) = \operatorname{tr}(A) + \operatorname{tr}(B)\)? Yes — the trace is linear, so the trace of a sum equals the sum of the traces, and \(\operatorname{tr}(cA) = c \cdot \operatorname{tr}(A)\) for any scalar c.