1
$\begingroup$

I have some decent problems with performing a double summation. The Sum is as follows

Sum[
 f[M[2, 1],M[2, 2]]
 , {M[2, 1], -Border, Border}
 , {M[2, 2], -Border, Border}
]

over some function f, and this summation gives me the right result. However I want to generalize this thing in the following way

Sum[
 Sum[
  f[M[2, 1],M[2, 2]]
  , {M[2, i], -Border, Border}]
 , {i, 1, 2}
]

which doesn't give me the right result and I cannot understand why. Can anybody tell me what is going wrong here and more importantly, how to make this generalized sum work?!

greets mike

$\endgroup$
0
$\begingroup$

I think what you need is

Sum[f[M[2, 1], M[2, 2]], 
  Evaluate[Sequence @@ Table[{M[2, i], -Border, Border}, {i, 1, 2}]]]
$\endgroup$
  • $\begingroup$ Thank you very much! This worked out for me! $\endgroup$ – mkmk Jul 24 at 12:10
  • $\begingroup$ You're welcome. The usual way of giving thanks on StackExchange is to up-vote an answer and to check the tick mark to accept an answer. $\endgroup$ – Roman Jul 25 at 5:46
0
$\begingroup$

Perhaps

Fold[Sum[#, {m[2, #2], -b, b}] &,  f[m[2, 1], m[2, 2]], {2, 1}]

TexForm @ %

$\sum _{m(2,1)=-b}^b \left(\sum _{m(2,2)=-b}^b f(m(2,1),m(2,2))\right)$

$\endgroup$

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.