Matrix Trace Calculator
Calculate the trace of a square matrix by adding the entries along its main diagonal. The trace, denoted by tr(A), is also equal to the sum of the matrix's eigenvalues, counted with algebraic multiplicity.
A
Learn About Matrix Trace
Definition of the Matrix Trace
The trace of an $n \times n$ square matrix $\mathbf{A}$, denoted $\operatorname{tr}(\mathbf{A})$, is the sum of the elements along its main diagonal (from the top-left to the bottom-right):
The trace is defined strictly for square matrices. Off-diagonal entries have no effect on the trace.
Connection to Eigenvalues
A fundamental theorem of linear algebra establishes that the trace of any square matrix equals the sum of all its eigenvalues (counted with algebraic multiplicity):
In the characteristic polynomial $p(\lambda) = \det(\lambda \mathbf{I} - \mathbf{A}) = \lambda^n - c_1 \lambda^{n-1} + \dots + (-1)^n \det(\mathbf{A})$, the trace appears directly as the coefficient of the second-highest degree term: $c_1 = \operatorname{tr}(\mathbf{A})$.
Fundamental Algebraic Properties
- Linearity: $\operatorname{tr}(c\mathbf{A} + d\mathbf{B}) = c\operatorname{tr}(\mathbf{A}) + d\operatorname{tr}(\mathbf{B})$ for any scalars $c, d$
- Transpose Invariance: $\operatorname{tr}(\mathbf{A}^T) = \operatorname{tr}(\mathbf{A})$
- Cyclic Invariance of Products: For any two matrices $\mathbf{A}_{(m \times n)}$ and $\mathbf{B}_{(n \times m)}$:
Even though $\mathbf{A}\mathbf{B}$ ($m \times m$) and $\mathbf{B}\mathbf{A}$ ($n \times n$) generally have different dimensions and non-equal entries, their traces are identical!
- Similarity Invariance: If $\mathbf{B} = \mathbf{P}^{-1}\mathbf{A}\mathbf{P}$ is a similar matrix, then:
The trace is an intrinsic property of the underlying linear operator, completely independent of the choice of coordinate basis.
- Commutator Trace: The trace of any matrix commutator is strictly zero:
Worked Numerical Example
Find the trace of the $3 \times 3$ matrix $\mathbf{A} = \begin{bmatrix} 4 & -2 & 5 \\ 1 & -\frac{3}{2} & 0 \\ 7 & 8 & \frac{7}{2} \end{bmatrix}$:
- Identify the main diagonal elements:
- $a_{11} = 4$
- $a_{22} = -\frac{3}{2}$
- $a_{33} = \frac{7}{2}$
- Sum the diagonal values:
1. Can a rectangular matrix have a trace?
In standard linear algebra, the trace is undefined for non-square matrices ($m \ne n$) because a rectangular matrix lacks a well-defined main diagonal spanning from top-left to bottom-right, and does not represent an endomorphism (a linear map from a vector space to itself).
2. Does $\operatorname{tr}(\mathbf{A}\mathbf{B}\mathbf{C}) = \operatorname{tr}(\mathbf{A}\mathbf{C}\mathbf{B})$?
No. The trace is invariant under cyclic permutations ($\operatorname{tr}(\mathbf{A}\mathbf{B}\mathbf{C}) = \operatorname{tr}(\mathbf{C}\mathbf{A}\mathbf{B}) = \operatorname{tr}(\mathbf{B}\mathbf{C}\mathbf{A})$), but it is generally not invariant under arbitrary non-cyclic permutations. Swapping $\mathbf{B}$ and $\mathbf{C}$ changes the product and its trace.
3. What is the relation between the trace and the determinant?
Through Jacobi's formula and the matrix exponential, the trace and determinant are linked by:
This identity shows that the determinant of an exponential matrix is governed by the scalar trace of its exponent.
1. Why Quantum Operators Cannot Be Finite Matrices
In quantum mechanics, Heisenberg's uncertainty principle arises from the canonical commutation relation between position $\mathbf{X}$ and momentum $\mathbf{P}$:
Taking the trace of both sides yields:
Because the left side must be zero while the right side is non-zero for any finite dimension $n$, it is mathematically impossible to represent quantum position and momentum using finite-dimensional matrices! They require infinite-dimensional Hilbert spaces.
2. The Frobenius Inner Product on Matrices
The trace defines an inner product on the vector space of real matrices: $\langle \mathbf{A}, \mathbf{B} \rangle = \operatorname{tr}(\mathbf{A}^T \mathbf{B})$. The associated induced norm is the Frobenius norm:
This turns the set of matrices into a Euclidean Hilbert space with geometrical angles and orthogonal projections.