2
$\begingroup$

Consider this rank 6 tensor: $g_{ab}g_{cd}g_{ef}$.

Now I'd like to have a code to sum over all possible $6!$ permutations of the six indices with some coefficient $f[i]$, where $1 \leq i \leq 720$... the output should be something like:

f[1]g[[a,b]]g[[c,d]]g[[e,f]] + f[2]g[[a,f]]g[[c,d]]g[[e,b]] +..other 718 terms..

Any help would be greatly appreciated.. Thank you!

$\endgroup$
0
$\begingroup$

In:

Clear[a, b, c, d, e, f, h, xss, g, p]
xss = Permutations[{a, b, c, d, e, f}, {6}] // Map[Partition[#, 2] &]
p[n_, ps_] := h[n] Times @@ Map[Part[g, Sequence @@ #] &, ps]
ys = MapThread[p, {Range@Length@xss, xss}] // Quiet
ys // Total

Out: enter image description here

$\endgroup$
3
$\begingroup$

You can use MapIndexed for this task:

func[{a_, b_, c_, d_, e_, f_}, {n_}] := ff[n] g[a, b] g[c, d] g[e, f]
Total@MapIndexed[func, Permutations[{a, b, c, d, e, f}]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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