I know what I'm doing can be done with Total
:
a = Range@3;
Total@a
And if I simply choose Sum
, nothing wrong will happen:
a = Range@3;
Sum[a[[i]], {i, 3}]
N@Sum
is still OK:
a = Range@3;
N@Sum[a[[i]], {i, 3}]
But when it's changed to NSum
, a warning message comes out though I still get the correct result:
a = Range@3;
NSum[a[[i]], {i, 3}]
Part::pspec: Part specification i is neither an integer nor a list of integers.
I found if I add a Hold
, I can avoid the warning:
a = Range@3;
NSum[Hold@a[[i]], {i, 3}]
But I still want to know the exact reason.