Symmetrization of a Function
You could make a list from 1 to n
, where n
is the length of the input, and create a permutation with that list. Then, replace each number with the corresponding input.
e.g.
g[x__] := Total[
f @@@ (Permutations[Range[Length[List[x]]]] /. a_Integer :> List[x][[a]])
]
In[181]:= g[x, x, y]
Out[181]= 2 f[x, x, y] + 2 f[x, y, x] + 2 f[y, x, x]
A more general solution:
Clear[symm, pm]
symm[group_][f_][args___] :=
With[{s = Function @@ {pm /@ GroupElements[group]}},
Plus @@ f @@@ s[args]
]
pm[p_] :=
With[{pl = PermutationList[p]},
Append[Slot /@ pl, SlotSequence[1 + Length[pl]]]
]
Then symm[group][f]
represents the symmetrized version of f
based on some permutation group.
symm[SymmetricGroup[3]][f][x, y, z]
(* f[x, y, z] + f[x, z, y] + f[y, x, z] + f[y, z, x] + f[z, x, y] + f[z, y, x] *)
Another way to solve the problem you encountered is not to use Permutations
, but use Permute
instead:
Permute[{x, x, z}, #] & /@ GroupElements[SymmetricGroup[3]]
(* {{x, x, z}, {x, z, x}, {x, x, z}, {z, x, x}, {x, z, x}, {z, x, x}} *)
This won't care if there are repeated elements. It's not necessary to use GroupElements
, you could just as well use Permutations@Range[3]
. I simply tried to keep it general.