0
$\begingroup$

I have two problems with the List bracket {}.

First, I want to get a specific component of LeviCivitaTensor, so I should use

Normal[ LeviCivitaTensor[n] ] [[ i1, i2, i3, ..., in ]]

For other purpose, however, I need to use

Normal[ LeviCitaTensor[n] ] [[ Table[ i[j], {j, 1, n}] ]]

However, the Table gives an additional List bracket "{}", and my method won't work.

Second, I want to calculate

Sum[f, {i[1], 1, n}, {i[2], 1, n}, ..., {i[m], 1, n}]

However, m in my function is an input, so I use Sum[f, Table[{i[j], 1, n}, {j, 1, m}]]. But the Table once again gives rise to an additional List bracket which make my code unworkable.

Can some one help me out? I would appreciate it.

$\endgroup$
  • 1
    $\begingroup$ Have a look at Flatten. $\endgroup$ – Sjoerd C. de Vries Jun 6 '15 at 17:33
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$ – bbgodfrey Jun 6 '15 at 17:38
  • $\begingroup$ Still can't get rid of the {} $\endgroup$ – xjtan Jun 7 '15 at 3:11
  • $\begingroup$ If I understand what you are trying to do, try adding Sequence@@ in front of your Table expression. $\endgroup$ – MarcoB Jun 7 '15 at 18:49
  • $\begingroup$ it works. thanks. but need to evaluate first. $\endgroup$ – xjtan Jun 10 '15 at 4:40
0
$\begingroup$

First, you should know that you don't need Normal to index the LeviCivitaTensor:

LeviCivitaTensor[3][[1, 2, 3]]
(* 1 *)

Now to your first problem. This can be solved with Apply (shorthand form @@):

i[1] = 1; (* example i data *)
i[2] = 2;
i[3] = 3;

LeviCivitaTensor[3][[##]] & @@ Table[i[j], {j, 1, 3}]
(* 1 *)

The second problem can be solved similarly. Alternatively, Sequence is an option:

ClearAll[i]

n = 2;
m = 3;

Sum[f, Sequence @@ Table[{i[j], 1, n}, {j, 1, m}] // Evaluate]

Sum[f, ##] & @@ Table[{i[j], 1, n}, {j, 1, m}]

(* 8 f *)
(* 8 f *)
| improve this answer | |
$\endgroup$
  • $\begingroup$ Oh man you are great, thanks a lot. $\endgroup$ – xjtan Jun 10 '15 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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