Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

I'm trying to write the expression $$\sum_{\alpha,\beta = 1}^{4}\epsilon_{\mu \nu\alpha\beta}a^{\nu} b^{\alpha} c^{\beta}$$ in Mathematica, where $\epsilon$ is the Levi-Civita symbol and $a$, $b$, $c$ are 4-dimensional vectors.

I tried this but the problem is with Levi-Civita as $\mu$ and $\nu$ are not specified in advance

a = {a1, a2, a3, a4}; 
b = {b1, b2, b3, b4}; 
c = {c1, c2, c3, c4};

Sum[
  LeviCivitaTensor[4][[mu, nu, alpha, beta]] a[[nu]] b[[alpha]] c[[beta]],
  {alpha, 1, 4}, {beta, 1, 4}
]
share|improve this question

marked as duplicate by acl, Artes, RunnyKine, Michael E2, Pickett Jul 31 at 21:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
This is not a question. –  user23127 Jul 28 at 17:14
    
It looks like LeviCivitaTensor, not LeviCivita. Also the code you give has syntax errors, and even if it didn't it doesn't work because a and so on aren't defined and when you try to retrieve their elements, you get an error. Not to put too fine a point on it, but you need to look at the docs. –  acl Jul 28 at 18:02
    
Of course; a, b, c are defined –  Dave Jul 28 at 18:09
    
Output needs to be a vector and $\mu$ and $\nu$ are not known. That is the problem. –  Dave Jul 28 at 18:16
    
@Dave84 since you have explicit values for the $a,b,c$ you can use TensorProduct –  acl Jul 28 at 18:21

3 Answers 3

up vote 2 down vote accepted

You need to construct a "table" that acts like a vector

a = {a1, a2, a3, a4}; b = {b1, b2, b3, b4}; c = {c1, c2, c3, c4};
Table[
   Sum[LeviCivitaTensor[4][[mu, nu, alpha, beta]] 
        a[[nu]] b[[alpha]] c[[beta]], {alpha, 1, 4}, {beta, 1, 4}, {nu, 1, 4}], 
  {mu, 1, 4}]
share|improve this answer

Assuming $\mu$ and $\nu$ also run from 1 to 4 (which they have to, otherwise your expression doesn't make sense), you can simply take a cue from this Q&A and write

TensorContract[
  TensorProduct[LeviCivitaTensor[4], a, b, c],
  {{2, 5}, {3, 6}, {4, 7}}
] // Normal
{
 -a4 b3 c2 + a3 b4 c2 + a4 b2 c3 - a2 b4 c3 - a3 b2 c4 + a2 b3 c4, 
  a4 b3 c1 - a3 b4 c1 - a4 b1 c3 + a1 b4 c3 + a3 b1 c4 - a1 b3 c4, 
 -a4 b2 c1 + a2 b4 c1 + a4 b1 c2 - a1 b4 c2 - a2 b1 c4 + a1 b2 c4,  
  a3 b2 c1 - a2 b3 c1 - a3 b1 c2 + a1 b3 c2 + a2 b1 c3 - a1 b2 c3
}

This is actually the same output as in @QuantomDot's answer.

share|improve this answer
    
Thank you, both answers are great. –  Dave Jul 28 at 19:53

In the question, there is no summation over $\nu$, as there is in other answers. In case $\nu$ is not specified, as the OP explicitly states, and meant to be an index, here is a way to calculate the desired tensor without using Table and Sum.

SymbolicTensors`ArrayContract[
  TensorContract[
    a \[TensorProduct] b \[TensorProduct] c \[TensorProduct] LeviCivitaTensor[4],
    {{2, 6}, {3, 7}}],
 {{1, 3}}, List]

One can compare its output with the output of Table -- they're the same:

Table[
 Sum[Signature[{mu, nu, alpha, beta}] a[[nu]] b[[alpha]] c[[beta]], {alpha, 4}, {beta, 4}],
 {mu, 4}, {nu, 4}]
(*
  {{ 0,  -a2 b4 c3 + a2 b3 c4,  a3 b4 c2 - a3 b2 c4, -a4 b3 c2 + a4 b2 c3},
   { a1 b4 c3 - a1 b3 c4,  0,  -a3 b4 c1 + a3 b1 c4,  a4 b3 c1 - a4 b1 c3},
   {-a1 b4 c2 + a1 b2 c4,  a2 b4 c1 - a2 b1 c4,  0,  -a4 b2 c1 + a4 b1 c2},
   { a1 b3 c2 - a1 b2 c3, -a2 b3 c1 + a2 b1 c3,  a3 b2 c1 - a3 b1 c2,  0 }}
*)

Note: LeviCivitaTensor[4][[mu, nu, alpha, beta]] is the same as Signature[{mu, nu, alpha, beta}] (thanks to Szabolcs for pointing it out).

Admittedly, it seems odd not to sum over $\nu$, but I thought I may as well answer the question as it is (currently) stated.

share|improve this answer
1  
Instead of LeviCivitaTensor[...][[mu,nu,alpha,beta]] you can use Signature[{mu,nu,alpha,beta}]. –  Szabolcs Sep 8 at 17:31
    
Of course. Thanks. I don't remember but I think I just adapted the OP's or QuantumDot's code. Since QuantumDot's is the accepted answer, your comment might help more visitors there. But I'll use it to improve my answer anyway. :) –  Michael E2 Sep 8 at 18:14

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