The trace is one of the simplest numbers you can compute from a square matrix, yet it packs in a surprising amount of structure — from a quick sanity check on hand calculations to a shortcut for the sum of a matrix's eigenvalues. This guide covers how to compute it, what it means, and where it shows up in linear algebra.

How the trace is computed

The trace of an n×n matrix A, written tr(A), is defined as the sum of the entries on its main diagonal: tr(A) = A₁₁ + A₂₂ + ... + Aₙₙ. Every other entry in the matrix — everything off the diagonal — is completely ignored. That makes the trace one of the cheapest matrix quantities to compute: no multiplication, no recursion, just an addition of n numbers.

Because the trace only depends on square matrices, a non-square matrix (say, a 3×4 matrix) simply has no trace defined. This calculator always builds a square n×n grid for exactly that reason.

Why the trace equals the sum of the eigenvalues

One of the trace's most useful properties is that tr(A) always equals the sum of A's eigenvalues, counted with algebraic multiplicity — even when those eigenvalues are irrational, complex, or repeated. This follows from the characteristic polynomial of A: the coefficient on the second-highest-degree term is (up to sign) the trace, and by Vieta's formulas that coefficient also equals the sum of the polynomial's roots, which are exactly the eigenvalues.

This gives you a fast partial check on an eigenvalue computation — if you compute eigenvalues by hand or with software and they don't sum to the trace you calculated directly from the diagonal, something went wrong.

Useful properties and edge cases

The trace is additive: tr(A + B) = tr(A) + tr(B) for any two same-size square matrices. It's also cyclic under multiplication: tr(ABC) = tr(BCA) = tr(CAB), even though matrix multiplication itself is not commutative (AB ≠ BA in general). This cyclic property is why the trace shows up constantly in physics and statistics — it lets you rearrange chains of matrix products without changing the result.

A special case worth remembering: the trace of any n×n identity matrix is simply n, since every diagonal entry is 1. And because the trace ignores every off-diagonal entry, two very different-looking matrices can share the exact same trace — it's an invariant, not a fingerprint.