Connect via MCP →

Enter Calculation

Enter the diagonal entries (top-left to bottom-right). Off-diagonal entries do not affect the trace.

Formula

Advertisement

Results

Trace of Matrix A
6
tr(A) = sum of diagonal entries
Matrix size 3 × 3

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.

3 by 3 matrix grid with the main diagonal cells highlighted from top-left to bottom-right
The trace sums the highlighted main-diagonal entries of a square matrix.

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.

Advertisement
Diagonal entries of a 4 by 4 matrix being added together to a single sum
\(\operatorname{tr}(A)\) adds every entry where the row index equals the column index.

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.

Last updated: