I want to sort the arguments of a function f while multiplying with the signature of the permutation, i.e. f is totally antisymmetric function. My idea was something like
f[2, 4, 3, 1] /. {f[x1_, x2_, x3_, x4_] -> Signature[{x1, x2, x3, x4}]*f[Sort[{x1, x2, x3, x4}][[1]], Sort[{x1, x2, x3, x4}][[2]], Sort[{x1, x2, x3, x4}][[3]], Sort[{x1, x2, x3, x4}][[4]]]}
where I would have expected the output to be
- f[1, 2, 3 ,4]
but instead I just get
f[2, 4, 3, 1]
Any ideas on how to achieve this?
f[{2, 4, 3}] /. f[l_List] :> (Signature[l] f[Sort[l]])
, which gives-f[{2, 3, 4}]
$\endgroup${2,4,3,1}
is 1, not -1, so that part's not the issue. UseRuleDelayed
instead ofRule
, i.e., replace->
with:>
. Then your code works. Butf[4, 2, 3, 1] /. f[xs__] :> Signature[{xs}] f @@ Sort[{xs}]
is shorter. $\endgroup$