Vectors and matrices

tr⁡(A)\operatorname{tr}(A) Trace

The sum of the diagonal entries of a square matrix.

In ML papers

tr⁡(A)=∑iAii\operatorname{tr}(A) = \sum_i A_{ii}. It equals the sum of the eigenvalues, and tr⁡(A⊤B)=∑ijAijBij\operatorname{tr}(A^\top B) = \sum_{ij} A_{ij}B_{ij} is a handy way to write the sum of an elementwise product, which is how many matrix-calculus derivations are done. ∥A∥F2=tr⁡(A⊤A)\|A\|_F^2 = \operatorname{tr}(A^\top A).

How to type it

LaTeXShows
\operatorname{tr}(A)tr⁡(A)\operatorname{tr}(A)
\mathrm{Tr}(A)Tr(A)\mathrm{Tr}(A)

A worked example

tr⁡(2113)=2+3=5\operatorname{tr} \begin{pmatrix} 2 & 1 \\ 1 & 3 \end{pmatrix} = 2 + 3 = 5

Related

det⁡(A)\det(A)Determinant∥A∥F\|A\|_FFrobenius normdiag⁡(v)\operatorname{diag}(\mathbf{v})Diag

Decode this example →