### Permutations, Signature, and Trace

In "Antisymmetrizing Functions," TMJ, 2 (1), 1992 p. 45, Permutations and Signature were used in the construction of totally antisymmetric functions, that is, functions that change sign under the interchange of any pair of arguments. Jorma Virtamo (jorma.virtamo@vtt.fi) suggested the following improved code.

The Signature of a permutation is , where is the number of transpositions of pairs of elements that must be composed to build up the permutation. By including in the definition of Antisymmetrize initially, cyclic and anticyclic permutations are distinguishable.

In "Calculus with Anticommuting Variables," TMJ, 8 (1), 2001 pp. 38-40, ordered determinants are computed using dynamic programming and Laplace expansion. For an interesting discussion of determinants of matrices with noncommutative entries, see [1]. Here is an alternative functional implementation, which is an extension of the code for Antisymmetrize.

For example, the ordered determinant of a general matrix

is

The code uses the observation that (ordered) terms in the determinant, say , appear as diagonal elements in a permutation of the rows of the transposed matrix.

Tr[list, f] finds a generalized trace, combining terms with f instead of Plus.

As an aside, Robert Knapp (rknapp@wolfram.com) writes: Here are two user-defined functions for computing the trace of a matrix.

Note that Tr is much, much faster.

The timings here are small, but if you have an application that requires repeatedly computing a trace, it makes a difference.

Second, Tr generalizes to multiple dimensions.

One can also use Tr to project out the list of diagonal elements.

Here is a cute way to use it to speed up something very common.

The thing to note here is that Tr[list of numbers] does the same thing as Apply[Plus, list of numbers], but is much faster for packed arrays.