3
$\begingroup$

I have two tensors $\eta_{\mu\nu}$ and $M_{\mu\nu\rho}$ which are defined as following

η = DiagonalMatrix[{-1,1,1,1}]
M = Array[Subscript[mSymb, ##] &, {4, 4,4}]

I want to consider the tensor product and then contract the indexes in pairs. I want to get the following object

$$ \overline{M}_{\sigma\,\,\,\,\,\alpha}^{\,\,\,\,\mu} = \sum_\nu \eta^{\mu\nu} M_{\sigma \nu\alpha} $$

I tried with the following function

TensorContract[TensorProduct[η,M],{2,4}]

But this function instead returns the following object

$$ \tilde{M}^{\mu}_{\,\,\sigma\alpha} = \sum_\nu \eta^{\mu\nu} M_{\sigma \nu\alpha} $$

You see that the RHS is the same in both cases but the order of the indexes is important when calling the element M[[σ, μ, α]]. For example, If M was a square matrix, $\tilde{M}$ would be the transpose of the object that I call $\overline{M}$.

How can I tell Mathematica to keep track of the order??

Thanks.

$\endgroup$

2 Answers 2

6
$\begingroup$

Mathematica is keeping track of the order, you just gave it a different order than you intended. TensorProduct[eta,m] will put the the two slots of eta first, then the three slots m. If you want to think of the \[Sigma] index as coming first, you need to move it there. Then the two \[Nu] indices will be slots 3 and 4, and you have

TensorContract[
   TensorTranspose[
       TensorProduct[eta, M],
       Cycles[{{1, 3}}]
   ], 
   {3, 4}
]

Altenatively, you could fix up your first attempt after the fact, again using TensorTranspose:

TensorTranspose[TensorContract[TensorProduct[eta, M], {2, 4}], Cycles[{{1, 2}}]]
$\endgroup$
3
$\begingroup$

Perhaps you can create a function to do this:

raise[m_, slot_, η_] := TensorContract[
    TensorTranspose[
        TensorProduct[η,m],
        RotateRight[Range[slot+1],2]
    ],
    {{slot+1,slot+2}}
]

For your example:

η = DiagonalMatrix[{-1,1,1,1}];
M = Array[Subscript[mySymb,##]&,{4,4,4}];

raise[M, 2, eta] //MatrixForm //TeXForm

$\left( \begin{array}{cccc} \left( \begin{array}{c} -\operatorname{mySymb}_{1,1,1} \\ -\operatorname{mySymb}_{1,1,2} \\ -\operatorname{mySymb}_{1,1,3} \\ -\operatorname{mySymb}_{1,1,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{1,2,1} \\ \operatorname{mySymb}_{1,2,2} \\ \operatorname{mySymb}_{1,2,3} \\ \operatorname{mySymb}_{1,2,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{1,3,1} \\ \operatorname{mySymb}_{1,3,2} \\ \operatorname{mySymb}_{1,3,3} \\ \operatorname{mySymb}_{1,3,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{1,4,1} \\ \operatorname{mySymb}_{1,4,2} \\ \operatorname{mySymb}_{1,4,3} \\ \operatorname{mySymb}_{1,4,4} \\ \end{array} \right) \\ \left( \begin{array}{c} -\operatorname{mySymb}_{2,1,1} \\ -\operatorname{mySymb}_{2,1,2} \\ -\operatorname{mySymb}_{2,1,3} \\ -\operatorname{mySymb}_{2,1,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{2,2,1} \\ \operatorname{mySymb}_{2,2,2} \\ \operatorname{mySymb}_{2,2,3} \\ \operatorname{mySymb}_{2,2,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{2,3,1} \\ \operatorname{mySymb}_{2,3,2} \\ \operatorname{mySymb}_{2,3,3} \\ \operatorname{mySymb}_{2,3,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{2,4,1} \\ \operatorname{mySymb}_{2,4,2} \\ \operatorname{mySymb}_{2,4,3} \\ \operatorname{mySymb}_{2,4,4} \\ \end{array} \right) \\ \left( \begin{array}{c} -\operatorname{mySymb}_{3,1,1} \\ -\operatorname{mySymb}_{3,1,2} \\ -\operatorname{mySymb}_{3,1,3} \\ -\operatorname{mySymb}_{3,1,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{3,2,1} \\ \operatorname{mySymb}_{3,2,2} \\ \operatorname{mySymb}_{3,2,3} \\ \operatorname{mySymb}_{3,2,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{3,3,1} \\ \operatorname{mySymb}_{3,3,2} \\ \operatorname{mySymb}_{3,3,3} \\ \operatorname{mySymb}_{3,3,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{3,4,1} \\ \operatorname{mySymb}_{3,4,2} \\ \operatorname{mySymb}_{3,4,3} \\ \operatorname{mySymb}_{3,4,4} \\ \end{array} \right) \\ \left( \begin{array}{c} -\operatorname{mySymb}_{4,1,1} \\ -\operatorname{mySymb}_{4,1,2} \\ -\operatorname{mySymb}_{4,1,3} \\ -\operatorname{mySymb}_{4,1,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{4,2,1} \\ \operatorname{mySymb}_{4,2,2} \\ \operatorname{mySymb}_{4,2,3} \\ \operatorname{mySymb}_{4,2,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{4,3,1} \\ \operatorname{mySymb}_{4,3,2} \\ \operatorname{mySymb}_{4,3,3} \\ \operatorname{mySymb}_{4,3,4} \\ \end{array} \right) & \left( \begin{array}{c} \operatorname{mySymb}_{4,4,1} \\ \operatorname{mySymb}_{4,4,2} \\ \operatorname{mySymb}_{4,4,3} \\ \operatorname{mySymb}_{4,4,4} \\ \end{array} \right) \\ \end{array} \right)$

$\endgroup$

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.