3
$\begingroup$

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}
]
$\endgroup$
8
  • $\begingroup$ This is not a question. $\endgroup$
    – user23127
    Commented Jul 28, 2014 at 17:14
  • $\begingroup$ 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. $\endgroup$
    – acl
    Commented Jul 28, 2014 at 18:02
  • $\begingroup$ Of course; a, b, c are defined $\endgroup$
    – user18822
    Commented Jul 28, 2014 at 18:09
  • $\begingroup$ Output needs to be a vector and $\mu$ and $\nu$ are not known. That is the problem. $\endgroup$
    – user18822
    Commented Jul 28, 2014 at 18:16
  • $\begingroup$ @Dave84 since you have explicit values for the $a,b,c$ you can use TensorProduct $\endgroup$
    – acl
    Commented Jul 28, 2014 at 18:21

3 Answers 3

6
$\begingroup$

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}]
$\endgroup$
7
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ Thank you, both answers are great. $\endgroup$
    – user18822
    Commented Jul 28, 2014 at 19:53
4
$\begingroup$

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.

$\endgroup$
2
  • 1
    $\begingroup$ Instead of LeviCivitaTensor[...][[mu,nu,alpha,beta]] you can use Signature[{mu,nu,alpha,beta}]. $\endgroup$
    – Szabolcs
    Commented Sep 8, 2014 at 17:31
  • $\begingroup$ 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. :) $\endgroup$
    – Michael E2
    Commented Sep 8, 2014 at 18:14