# Automatically generated summation region

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:

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


works;

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


or

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


doesn't work.

• You could use something like Sum[1,Evaluate[Sequence@@{{i,1,2},{j,1,2}}]] Commented Jul 21, 2013 at 21:50

As always there are several possibilities. For example

Sum[1,Evaluate[Sequence@@{{i,1,2},{j,1,2}}]]


or

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


both work.

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

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


you need to write

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

(* ==> 4 *)


Sum[1,A]

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

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