Matrix Trace Calculator

Enter a 2×2 or 3×3 matrix to find its trace — the sum of the main diagonal entries, tr(A) = a11 + a22 + ... + ann.

Quick Facts

Trace formula
tr(A) = a11 + a22 + ... + ann
Sum only the entries running from the top-left to the bottom-right corner.
Square matrices only
Rows = columns
Trace is undefined for a non-square matrix — there is no single main diagonal.
Sum of eigenvalues
tr(A) = λ1 + λ2 + ... + λn
A quick way to sanity-check an eigenvalue computation.

Your Results

Calculated
Trace, tr(A)
-
Sum of the main diagonal entries
Matrix Order
-
Number of rows = number of columns
Average Diagonal Entry
-
tr(A) ÷ n
Sum of All Entries
-
For reference — not part of the trace

Ready

Choose a matrix size, enter the entries, then press Calculate.

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.

Frequently Asked Questions

What is the trace of a matrix?
The trace of a square n×n matrix A, written tr(A), is the sum of its main diagonal entries: tr(A) = a11 + a22 + ... + ann. For example, the matrix [[4,1,2],[0,3,5],[1,2,6]] has a trace of 4 + 3 + 6 = 13.
Can the trace be found for a non-square matrix?
No. Trace is only defined for square matrices, where the number of rows equals the number of columns, because it requires a well-defined main diagonal running from the top-left entry to the bottom-right entry.
How is the trace related to eigenvalues?
The trace of a matrix equals the sum of its eigenvalues, counted with algebraic multiplicity, even when the eigenvalues themselves are irrational or complex. This makes trace a fast way to sanity-check an eigenvalue calculation.
Is the trace the same no matter how the matrix is written?
The trace is invariant under similarity transformations, so tr(A) = tr(P⁻¹AP) for any invertible matrix P, and tr(AB) = tr(BA) whenever both products are defined. This basis-independence is why trace appears throughout linear algebra.