Symbolic visualization of tr(A) = sum of the main-diagonal entries.
Dimension of A (square)?Trace is defined only for square matrices. The trace of an n×n matrix A is the sum of its main-diagonal entries: tr(A) = a₁,₁ + a₂,₂ + … + aₙ,ₙ. Off-diagonal entries are ignored entirely.
A4×4
A4×4
a1,1
a1,2
a1,3
a1,4
a2,1
a2,2
a2,3
a2,4
a3,1
a3,2
a3,3
a3,4
a4,1
a4,2
a4,3
a4,4
Step 1 / 7
Step explanations
1Trace of a square matrix (4×4)
What is the trace of A? Trace is a single number assigned to every square matrix — we'll build it step by step.
Set the size of A and watch the trace build one diagonal entry at a time.
• Use the Dimension steppers to set the size of A from 2×2 up to 10×10 — both dimensions move together because A must be square • Hover the ? icon for a reminder that trace requires a square matrix • The scene player starts by posing the question with no highlights, then reveals the main diagonal, then sweeps the diagonal entry by entry • Use the speed selector and step log to control the pace and review prior steps
Each scene focuses on the diagonal of A with three visual states.
• Pending entries (not yet counted) appear with a dashed green outline • The current entry being added is highlighted in solid blue with a slight scale-up • Counted entries turn solid green • Off-diagonal cells stay neutral throughout — the trace ignores them completely • The running formula tr(A)=a1,1+a2,2+⋯ updates above with the same color coding
The dimension stepper controls the size of the square matrix A.
• Smaller sizes (2×2, 3×3) make each scene easy to follow and show how short the trace sum is • Larger sizes (up to 10×10) demonstrate how the same rule scales — exactly n terms regardless of how many off-diagonal entries exist • Cell size shrinks automatically as n grows so the matrix stays readable • Both row and column steppers are linked since trace only applies to square matrices
The animation follows a deliberate three-stage order.
• Pose — the matrix appears with no highlights; the question "what is the trace?" is asked first • Reveal — the entire main diagonal is highlighted in blue, separating the entries that contribute from those that do not • Sweep — one scene per diagonal entry, adding ak,k to the running sum • Outro — every diagonal entry is green and the complete formula is shown along with the Σ notation
This order separates "what is the trace looking at?" from "what does the trace compute?" — two questions that are easy to conflate.
The trace of an n×n matrix A is the sum of its main-diagonal entries:
tr(A)=a1,1+a2,2+⋯+an,n=i=1∑nai,i
Trace is defined only for square matrices. Off-diagonal entries play no role at all — the trace ignores them completely. The result is a single scalar that summarizes one piece of information about A, complementary to the determinant.
The trace has a short list of clean algebraic properties.
• Linearity: tr(A+B)=tr(A)+tr(B) and tr(kA)=k⋅tr(A) • Transpose invariance: tr(AT)=tr(A) — the diagonal stays put under transposition • Cyclic property: tr(AB)=tr(BA), and more generally tr(ABC)=tr(BCA)=tr(CAB) • Similarity invariance: tr(P−1AP)=tr(A) — trace doesn't change under change of basis • Sum of eigenvalues: for any square A, tr(A)=∑iλi where λi are the eigenvalues counted with multiplicity
The cyclic property is the workhorse — it's behind nearly every nontrivial trace identity.
The trace appears throughout mathematics and applications because it captures the sum of eigenvalues in an arithmetic form that's easy to compute.
• Linear algebra: tr(A)=∑λi — read off the eigenvalue sum without diagonalizing • Differential geometry and physics: the trace of a stress or strain tensor measures volume change; the trace of a Hamiltonian relates to partition functions • Machine learning: trace appears in covariance summaries, Frobenius norms (∥A∥F2=tr(ATA)), and many regularization terms • Inner product: the Frobenius inner product is ⟨A,B⟩F=tr(ATB) • Statistics: trace of a projection matrix counts the degrees of freedom of the projection
Anywhere a "total" or "sum of intrinsic quantities" of a square matrix is needed, the trace is the right tool.
The other six entries (7, −1, 0, 4, 3, 1) are ignored entirely. Notice that for the same A, the determinant uses every entry while the trace uses only three — they capture different aspects of the matrix.
Set the visualizer to 3×3 and step through to see this picking-out process animated.
• Trying to compute the trace of a non-square matrix — the trace is undefined for rectangular A because there is no full main diagonal • Confusing trace with determinant — both are scalar summaries of a square matrix, but trace sums diagonal entries while determinant computes a signed product across all permutations • Forgetting the cyclic property is cyclic, not commutative — tr(AB)=tr(BA) holds, but tr(ABC)=tr(ACB) in general • Assuming trace equals the determinant of the diagonal — the trace is a sum, not a product • Mixing up "diagonal" with "anti-diagonal" — trace uses entries where i=j, not where i+j=n+1