What is the easiest way to perform Rotation for Higher Order Tensors in Mathematica ? For Instance 4th order tensor
$C_{ijkl} = \lambda_{im}\lambda_{jn}\lambda_{ko}\lambda_{lp} C_{mnop}$
There are multiple ways of implementing something like this, and the comments above give you good suggestions. Let me suggest another simple method, which is valid for arrays of any depth, not just 4. This contracts (the second level of) the matrix m on all levels of the array a
multiDot[m_, a_] := With[{d = ArrayDepth[a]},
Nest[Transpose[m.#, RotateRight[Range[d]]] &, a, d]
]
Take for example a random rotation r and a random array c of depth 4 with the symmetries of an elasticity tensor:
r = RotationMatrix[RandomReal[2 Pi], RandomReal[1, 3]];
c = Normal@ SymmetrizedArray[_ :> RandomReal[1], {3, 3, 3, 3}, {{{2, 1, 3, 4}, 1}, {{1, 2, 4, 3}, 1}, {{3, 4, 1, 2}, 1}}];
Then we can check the preservation of symmetry under the rotation:
rc = multiDot[r, c]
TensorSymmetry[rc] === TensorSymmetry[c]
(* True *)
You can use arrays of any depth in the second argument. Check for example:
multiDot[r, r] == r.r.Transpose[r]
(* True *)
https://mathematica.stackexchange.com/questions/217096/...
. $\endgroup$