# Tr

Tr[list]

finds the trace of the matrix or tensor list.

Tr[list,f]

finds a generalized trace, combining terms with f instead of Plus.

Tr[list,f,n]

goes down to level n in list.

# Details

• Tr[list] sums the diagonal elements list[[i,i,]].
• Tr works for rectangular as well as square matrices and tensors.
• Tr can be used on SparseArray objects. »

# Examples

open allclose all

## Basic Examples(1)

The trace of a matrix is the sum of the diagonal elements:

## Scope(2)

Symbolic trace:

Trace of a numerical matrix:

Trace of a sparse matrix:

## Generalizations & Extensions(6)

For a vector Tr gives the sum of the elements:

For a higherrank tensor, Tr gives the sum of elements with equal indices:

Apply a function to the diagonal elements of a matrix:

Extract the diagonal of a matrix as a list:

Only consider down to level 1; this adds the rows of the matrix:

Only consider down to level 2:

## Applications(2)

Find the determinant of a triangular matrix:

Define an inner product for the cone of positive definite matrices using :

Project the matrix onto the space spanned by the matrix :

## Properties & Relations(3)

The trace of a matrix is invariant under similarity transformations:

The invariance means that the sum of the eigenvalues must equal the trace:

The Frobenius norm is defined as :

Tr[m,List] is equivalent to Diagonal[m] for a matrix m:

Wolfram Research (1999), Tr, Wolfram Language function, https://reference.wolfram.com/language/ref/Tr.html (updated 2003).

#### Text

Wolfram Research (1999), Tr, Wolfram Language function, https://reference.wolfram.com/language/ref/Tr.html (updated 2003).

#### CMS

Wolfram Language. 1999. "Tr." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2003. https://reference.wolfram.com/language/ref/Tr.html.

#### APA

Wolfram Language. (1999). Tr. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Tr.html

#### BibTeX

@misc{reference.wolfram_2024_tr, author="Wolfram Research", title="{Tr}", year="2003", howpublished="\url{https://reference.wolfram.com/language/ref/Tr.html}", note=[Accessed: 04-August-2024 ]}

#### BibLaTeX

@online{reference.wolfram_2024_tr, organization={Wolfram Research}, title={Tr}, year={2003}, url={https://reference.wolfram.com/language/ref/Tr.html}, note=[Accessed: 04-August-2024 ]}