Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a multiple Sum I need to put an automatically generated summation region. But when I generate the summation region automatically I get a list whose elements are lists. Then the summation does not work.

For example:





A = Table[{i[j],j+1},{j,2}];

doesn't work.

share|improve this question
You could use something like Sum[1,Evaluate[Sequence@@{{i,1,2},{j,1,2}}]] – sebhofer Jul 21 '13 at 21:50
up vote 4 down vote accepted

As always there are several possibilities. For example



Sum[1, ##] & @@ {{i, 1, 2}, {j, 1, 2}}

both work.

share|improve this answer

The syntax for Sum is wrong. For multiple sums, you list each summation index as a separate argument, not enclosed in a list. For example, instead of


you need to write

Sum[1, {i, 1, 2}, {j, 1, 2}]

(* ==> 4 *)

To modify your last example,


you should do this:

A = Table[{i, j}, {i, 1, 2}, {j, 1, 2}];
Sum[1, {tuple, Flatten[A, 1]}]

(* ==> 4 *)

This assumes that your goal was to have A be a list of tuples i, j.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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