# Implementing anti-symmetric function on two index and for more in systematic way

In mathematica, I want to impose symmetric and anti-symmetric properties of $$S$$ and $$A$$ in general way.

Usually I was working with explicit information

i.e., for anti-symmetric $$A$$ with two index, I define

ATwo[i_,i_]:=0;
ATwo[2,1]=-ATwo[1,2];
ATwo[3,1]=-ATwo[1,3];
ATwo[3,2]=-ATwo[2,3];


and so on and for symmetric with two index I do the similar things

For the higher rank (the range of $$i$$) It is quite cumbersome to do this explicilty. Is there any other ways to imposing these properties easily?

My first trial was using If, for example

ATwo[i_, i_] = 0;
ATwo[i_, j_] := If[j >= i, ATwo[i, j], -ATwo[j, i]];


but this results give something wrong when I implement ATwo[3,4] and ATwo[4,3]. For example they produce

Hold[ATwo[3, 4]]
Hold[-ATwo[4, 3]]


(Maybe it is due to recursive definition?)

Is there any good idea to implement symmetirc or antisymmetric on many index, for example $$A[i,j,k,l]$$ with i,j symmetric and kl anti-symmetric without explicit plugging as in the first my trial?

• I would use Signature, Sort and OrderedQ. Feb 13, 2023 at 13:27

## 2 Answers

You must restrict your patterns, otherwise you get a recursion:

With the definitions:

ATwo[i_, i_] = 0;
ATwo[i_, j_] /; j < i = -ATwo[j, i];

A[i_, j_, k_, l_] /; j < i = A[j, i, k, l] ;
A[i_, j_, k_, k_] = 0;
A[i_, j_, k_, l_] /; k < l = - A[i, j, l, k];


we can make an example for ATwo:

n = 3;
Table[ATwo[i, j], {i, n}, {j, n}] // TableForm


And an example for A:

n = 2;
Table[A[i, j, k, l], {i, n}, {j, n}, {k, n}, {l, n}] // TableForm


Another possibility, which can be easily extended to more symmetric and antisymmetric indices, is :

ATwo[i_, j_, k_, l_] := Signature[{k, l}]*(Apply[ATwo])[Join[Sort[{i, j}],
Sort[{k, l}]]] /;  !OrderedQ[{i, j}] ||  !OrderedQ[{k, l}];
ATwo[i_, j_, k_, k_] = 0;