Matrix Trace Calculator

Calculate the trace (sum of diagonal elements) of a square matrix with step-by-step solutions.

Enter Matrix

Result

Trace (tr(A))
--
Matrix Size --
Diagonal Elements --
Number of Elements --

Step-by-Step Solution

tr(A) = a11 + a22 + ... + ann

What is the Trace of a Matrix?

The trace of a square matrix A, denoted tr(A), is defined as the sum of the elements on the main diagonal (from the upper left to the lower right). The trace is only defined for square matrices (n x n). It is one of the most fundamental matrix operations in linear algebra.

Trace Formula

For an n x n matrix A with elements aij, the trace is:

Definition

Sum of all diagonal elements where row index equals column index.

tr(A) = a11 + a22 + ... + ann

Sigma Notation

Using summation notation for compact representation.

tr(A) = Σ aii for i = 1 to n

Properties of the Trace

Linearity

The trace of a sum equals the sum of traces, and scalars factor out.

tr(A + B) = tr(A) + tr(B)

Scalar Multiplication

A scalar multiple factors out of the trace.

tr(cA) = c · tr(A)

Transpose Invariance

The trace is unchanged by transposition.

tr(A) = tr(AT)

Cyclic Property

Trace is invariant under cyclic permutations of matrix products.

tr(ABC) = tr(CAB) = tr(BCA)

Eigenvalue Connection

The trace equals the sum of all eigenvalues (counted with multiplicity).

tr(A) = λ1 + λ2 + ... + λn

Identity Matrix

The trace of the n x n identity matrix equals n.

tr(In) = n

Applications of the Trace

The trace is used extensively in physics (quantum mechanics, general relativity), statistics (multivariate analysis), machine learning (regularization, matrix calculus), and computer graphics. It appears in the characteristic polynomial of a matrix and is related to the derivative of the determinant.

Trace in Machine Learning

In machine learning, the trace is used in matrix calculus for computing gradients of matrix expressions. The Frobenius norm of a matrix can be expressed as the trace: ||A||F = sqrt(tr(ATA)). This makes the trace invaluable for optimization algorithms.