# Create a tensor with a well defined symmetry

I want to create a symmetric rank four tensor with this kind of symmetry: {1,2} and {3,4}. How can I implement this using "Array"?

v = Array[Subscript[a, ##] &, {5,5,5,5}]

You can use this construction, which is an efficient representation (avoiding repeating symmetry-related entries):

sa = SymmetrizedArray[{i_, j_, k_, l_} :> Subscript[a, i, j, k, l], {5, 5, 5, 5}, {Symmetric[{1, 2}], Symmetric[{3, 4}]}]


If you want the ordinary array just do

Normal[sa]


In this way you can also implement antisymmetries. For example you could have the symmetry

{Symmetric[{1, 2}], Antisymmetric[{3, 4}]}

• Thank you so much! Do you know a way to make it also traceless? For example, I want Sum[sa[[i,l,i,k]],{i,1,5}]=0 Mar 28, 2022 at 15:35
• SymmetrizedArray only handles symmetries under permutations, not trace conditions. There are many different trace conditions that can be imposed. I think you'll have to impose all conditions you want manually and solve the corresponding system of equations, in the direction that @Adam's answer suggests.
– jose
Mar 28, 2022 at 16:48

Does this work?

#/.Solve[{
TensorTranspose[#,{2,1,3,4}]==#,
TensorTranspose[#,{1,2,4,3}]==#
}][[1]]& @ Array[Subscript[a,##]&,{5,5,5,5}]


Use TensorSymmetry@% to verify