Linear Algebra
Intermediate

Trace of a Matrix

Sum of the diagonal entries of a square matrix.

Formula

tr(A)=∑iaii\text{tr}(A) = \sum_i a_{ii}

Variables

a_{ii}Diagonal entries

Example

The trace of [[1,2],[3,4]] is 1 + 4 = 5.

How it works

The trace of a square matrix is found by adding the entries on its main diagonal, from the top-left to the bottom-right. It appears naturally because diagonal entries often represent how each coordinate axis is scaled, and the trace captures the total of those self-effects. In many areas of linear algebra, it is also equal to the sum of the matrix’s eigenvalues, which is why it carries important structural information about the matrix.

When to use it

Use the trace when you need a quick summary of a square matrix, especially in eigenvalue problems, similarity transformations, and matrix invariants. It also shows up in applied settings such as differential equations, statistics, and physics when describing total scaling, divergence, or the sum of variances in covariance matrices.

Worked example, step by step

Let A = [[2, -1, 5], [0, 3, 4], [7, 8, -2]] Step 1: Identify the main diagonal entries: 2, 3, and -2 Step 2: Add them: 2 + 3 + (-2) = 3 Step 3: Therefore, tr(A) = 3

Common mistakes to avoid

  • Adding all entries in the matrix instead of only the diagonal entries
  • Using a non-square matrix, even though trace is defined only for square matrices
  • Mixing up the main diagonal with the other diagonal running from top-right to bottom-left

Did You Know?

The trace — the sum of the diagonal — equals the sum of all the eigenvalues.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026