4
$\begingroup$

I would like to create symbolic tensor. For example a 2nd order symmetric tensor that would look like this in matrix representation:

$$ \left( \begin{array}{ccc} a & d & f \\ d & b & e \\ f & e & c \\ \end{array} \right) $$

Is this possible for higher order tensors (order 4, for example)? I don't feel like typing out all 81 components. And more importantly, will further calculations with these tensors simplify due to symmetry (if applicable)?

My goal is to find zero elements of the following tensor: : $$ (c_{n_1 m_1}+c_{n_2m_2}+...+c_{n{_\mu m_{\mu}}})D_{m_1 m_2 ... m_{\mu}} $$

($D_{m_1 m_2 ... m_{\mu}}$ symmetric in all its indices, $c_{ij}$ is antisymmetric and zero everywhere except $c_{12}=\theta$ and $c_{21}=-\theta$, working in 3 dimensions)

$\endgroup$
1
  • 1
    $\begingroup$ What do you want to do with the tensor? Do you want the elements explicitly listed, or do you want to tell Mathematica that x represents a symmetric tensor, without any direct reference to its elements? What kind of symmetry do you need for the 4-index tensor? $\endgroup$
    – Szabolcs
    Sep 29, 2016 at 14:00

2 Answers 2

4
$\begingroup$

If you are only interested in fully symmetric arrays, then I think using SetAttributes[c, Orderless] and then Array[c, dims] is the simplest solution, as proposed by @march.

But let me give another solution that generalizes to other symmetries:

This is a 3x3 symmetric matrix:

In[1]:= Normal@ SymmetrizedArray[{i_, j_} -> c[i, j], {3, 3}, Symmetric[{1, 2}]]
Out[1]= {{c[1, 1], c[1, 2], c[1, 3]}, {c[1, 2], c[2, 2], c[2, 3]}, {c[1, 3], c[2, 3], c[3, 3]}}

In[2]:= SymmetricMatrixQ[%]
Out[2]= True

This is a 3x3 antisymmetric matrix:

In[3]:= Normal@ SymmetrizedArray[{i_, j_} -> c[i, j], {3, 3}, Antisymmetric[{1, 2}]]
Out[3]= {{0, c[1, 2], c[1, 3]}, {-c[1, 2], 0, c[2, 3]}, {-c[1, 3], -c[2, 3], 0}}

In[4]:= AntisymmetricMatrixQ[%]
Out[4]= True

This is a depth 3 antisymmetric array:

In[5]:= Normal@ SymmetrizedArray[{i_, j_, k_} -> c[i, j, k], {3, 3, 3}, Antisymmetric[All]]
Out[5]= {{{0, 0, 0}, {0, 0, c[1, 2, 3]}, {0, -c[1, 2, 3], 0}}, {{0, 0, -c[1, 2, 3]}, {0, 0, 0}, {c[1, 2, 3], 0, 0}}, {{0, c[1, 2, 3], 0}, {-c[1, 2, 3], 0, 0}, {0, 0, 0}}}

In[6]:= TensorSymmetry[%]
Out[6]= Antisymmetric[{1, 2, 3}]

In dimension 3 it has only one independent component, namely c[1, 2, 3].

It is possible to specify any slot symmetry and SymmetrizedArray will take care of finding the appropriate independent components, zeros, signs, etc. for you.

$\endgroup$
3
$\begingroup$

Perhaps use Array to construct the symbolic nested list that represents the tensor and then set all elements with the same set of indices to the same list. For example, if you have a 3 by 3 by 3, given by

ClearAll[d]
t = Array[d, {3, 3, 3}]; t // MatrixForm

enter image description here

Then, we re-order the indices:

t = t /. x_d :> Sort[x]; t // MatrixForm

enter image description here

Note, for instance, that

Equal @@ Extract[t, Permutations[{1, 2, 3}]]
(* True *)

Or, do it all at once:

t = Array[d @@ Sort[{##}] &, {3, 3, 3}];

Alternatively,

ClearAll[d]
SetAttributes[d, Orderless];
t = Array[d, {3, 3, 3}];
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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