Let $X_{1},...,X_{N}$ be $N$ matrices. I want to compute an antisymmetrized product of $X_{i}$'s in mathematica:

$X_{[a_{1}...a_{N}]} \equiv \tfrac{1}{N!}\sum_{\sigma}(-1)^{P}X_{\sigma(a_{1})}X_{\sigma(a_{2})}...X_{\sigma(a_{N})},$

where the sum is taken over permutations and the sign factor $(-1)^P$ is $+1$ for even permutations and $-1$ for odd ones.

Eventually, I want to calculate the above equation componentwise by substituting e.g. Dirac $\gamma$-matrices into $X_{i}$'s. How can I make a code for that? Thanks for your help.


1 Answer 1


If we assume that the symbol x is reserved for the matrices you're planning to use, and the individual matrices are named x[i], then you can do this:

xProduct[indices__] := 
 Signature[{indices}] Dot @@ x /@ {indices}

xPerm[a_List] := Total[xProduct @@@ Permutations[a]]

xPerm[{3, 4, 5}]

==> x[3].x[4].x[5] - x[3].x[5].x[4] - x[4].x[3].x[5] + 
 x[4].x[5].x[3] + x[5].x[3].x[4] - x[5].x[4].x[3]

Here, {indices} is a particular permutation of the provided indices, and the terms in the sum get the correct sign from Signature. However, this assumes that the indices that you provide as arguments to the function xPerm are in canonical order. If you're not assuming that, the function xPerm should be multiplied by Signature[a].


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.