4
$\begingroup$

Let define the full symmetrization of a tensor $e_1 \otimes ... \otimes e_N$ by

$$ Sym : e_1 \otimes ... \otimes e_N \rightarrow \frac{1}{N!} \sum_{\pi \in S_N} e_{\pi^{-1} (1)} \otimes ... \otimes e_{\pi^{-1} (N)} $$

where $S_N$ is the symmetric group (set of permutations of N elements). Define the symmetric product of two tensors $e_1 \otimes ... \otimes e_N$, $f_1 \otimes ... \otimes f_n$ by

$$SymProd : (e_1 \otimes ... \otimes e_N,f_1 \otimes ... \otimes f_n) \rightarrow Sym(e_1 \otimes ... \otimes e_N \otimes e_{N+1} \otimes ... \otimes e_{N+n}) $$ where the f's were labeled as e's just to express that $\pi$ acts like a switch operation.

For example, $$Sym( e_1 \otimes e_2) = e_1 \otimes e_2 + e_2 \otimes e_1$$ and $$SymProd(e_1 \otimes e_2, f_1 \otimes f_2 \otimes f_3) \\= Sym(e_1 \otimes e_2 \otimes f_1 \otimes f_2 \otimes f_3) \\= \frac{1}{5!} \sum_{\pi \in S_5} e_{\pi^{-1} (1)} \otimes e_{\pi^{-1} (2)} \otimes e_{\pi^{-1} (3)} \otimes e_{\pi^{-1} (4)} \otimes e_{\pi^{-1} (5)}.$$

Does this function exist on mathematica ? If not, how would you implement it ?

$\endgroup$
1
  • $\begingroup$ You may want to look at this. $\endgroup$
    – user293787
    Sep 19, 2022 at 20:04

2 Answers 2

4
$\begingroup$

I think you can construct SymProd with a combination of TensorProduct and Symmetrize. For example, take numeric arrays:

d = 3
a1 = RandomInteger[10, {d}]
a2 = RandomInteger[10, {d, d}]
a3 = RandomInteger[10, {d, d, d}]

Then you can take their tensor product and symmetrize:

Symmetrize[TensorProduct[a1, a2, a3]]

The result is given as a SymmetrizedArray object, that avoids storing repeated elements. To get a normal array use Normal:

% // Normal

Then you can check that the result is indeed symmetric with TensorSymmetry:

% // TensorSymmetry
(* Symmetric[{1, 2, 3, 4, 5, 6}] *)

If you want to use symbolic arrays instead of arrays of components then use the assumptions framework with something like this:

$Assumptions = Element[v, Vectors[d]] && Element[m, Matrices[{d, d}]]

and then compute things like

Symmetrize[TensorProduct[v, m]]
$\endgroup$
5
  • $\begingroup$ Thanks for your answer ! This is what I looked for, but there is one problem : it seems that it don't work if tensors don't have the same degree. For example, consider a1 = RandomInteger[1, {d - 1}] a2 = RandomInteger[1, {d}] and we have the error Symmetrize::symmcomp: Symmetry specification Symmetric[{1,2}] is incompatible with expression {2,3}. $\endgroup$
    – Baloo
    Sep 21, 2022 at 12:31
  • $\begingroup$ One cannot symmetrize over levels (i.e. indices) of different dimension. Imagine you have a matrix M of dimensions {2, 3}. What is the symmetric part of this matrix? The computation is (M + Transpose[M]) / 2, and therefore M and Transpose[M] must have the same dimensions. $\endgroup$
    – jose
    Sep 22, 2022 at 13:26
  • $\begingroup$ For low dimension example, let $$T_1=e_0 \otimes e_0 \otimes e_0 + e_1 \otimes e_1 \otimes e_1$$ and $$T_2 = e_0 \otimes e_1 + e_1 \otimes e_0$$ We have $$T_1 \otimes T_2 \\ = e_0 \otimes e_0 \otimes e_0 \otimes e_0 \otimes e_1 \\ + e_1 \otimes e_1 \otimes e_1 \otimes e_0 \otimes e_1 \\ + e_0 \otimes e_0 \otimes e_0 \otimes e_1 \otimes e_0 \\ + e_1 \otimes e_1 \otimes e_1 \otimes e_1 \otimes e_0$$ I don't see why one could not symmetrize $T1 \otimes T2$ which is is exactly my goal with mathematica $\endgroup$
    – Baloo
    Sep 22, 2022 at 13:49
  • 1
    $\begingroup$ I think we are talking about two different things here: rank/degree/order (three names of the same thing) and dimension. Something like RandomInteger[10, {d}] is a vector (rank/degree/order 1) of dimension d. RandomInteger[10, {d1, d2}] is a matrix (rank/degree/order 2) of dimensions d1 and d2. You can symmetrize objects of any rank/degree/order, but all dimensions must coincide. Your object T1 has rank/degree/order 3 and T2 has 2. You don't specify the dimensions of e0 or e1, but they must be the same. $\endgroup$
    – jose
    Sep 23, 2022 at 14:23
  • $\begingroup$ Ok thanks a lot for this explanation :) $\endgroup$
    – Baloo
    Sep 26, 2022 at 8:14
0
$\begingroup$

Perhaps

sym[array_]:=With[{n=ArrayDepth[array]},
  1/n!*Total[Map[Transpose[array,#]&,Permutations[Range[n]]]]];

For example

sym[Array[a,{2,2}]]//Expand

gives

{{a[1,1],1/2 a[1,2]+1/2 a[2,1]},{1/2 a[1,2]+1/2 a[2,1],a[2,2]}}

and

sym[Array[a,{2,2,2}]]//Expand

gives

{{{a[1,1,1],1/3 a[1,1,2]+1/3 a[1,2,1]+1/3 a[2,1,1]},
 {1/3 a[1,1,2]+1/3 a[1,2,1]+1/3 a[2,1,1],1/3 a[1,2,2]+1/3 a[2,1,2]+1/3 a[2,2,1]}},
 {{1/3 a[1,1,2]+1/3 a[1,2,1]+1/3 a[2,1,1],1/3 a[1,2,2]+1/3 a[2,1,2]+1/3 a[2,2,1]},
 {1/3 a[1,2,2]+1/3 a[2,1,2]+1/3 a[2,2,1],a[2,2,2]}}}
$\endgroup$
1
  • $\begingroup$ Thanks for your answer. I don't understand the output format. Since $Sym$ outputs a sum of separable tensors, I would rather expect something like $a[1,1]+ a[1,2]+a[2,1]+a[2,2]$ For example, $Sym( e_1 \otimes e_2) = e_1 \otimes e_2 + e_2 \otimes e_1$ $\endgroup$
    – Baloo
    Sep 20, 2022 at 13:43

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.