Sum problem

• To: mathgroup at smc.vnet.net
• Subject: [mg65285] Sum problem
• Date: Fri, 24 Mar 2006 00:59:42 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Hi ,

I have a problem that drives me crazy. In order to sum a (long) list of
elements (random numbers), say tab

tab = Table[Random[], {10^7}];

we use

In[3]:=
Plus@@tab

Out[3]=
4.999014220610286`*^6

....but to check Sum we get

In[6]:=
Sum[tab[[i]],{i,1,Length[tab]}]

Part specification K\$30 is neither an
integer nor a list of integers.

There is no problem for

Sum[tab[[i]], {i, 1, 10^6}]

...and for

Sum[tab[[i]], {i, 1, 5*10^6}]

So Sum is ok. for number of elements of tab less than certain number that is
< Length[tab]

I also tested recursion methods (doSum[k_]:=doSum[k]=doSum[k-1] ...... Etc)
and got the same : fine but not for many elements (of course I set
\$RecursiveLimit and \$IterationLimit as Infinity)

I understand that to sum a list of elements we use Plus, Total  etc but
nevertheless I want understand what I explained above.

Best,

Arek

```

• Prev by Date: Re: How to sample a 2-dim. r.v. with known density function?
• Next by Date: Re: Re: A question concerning Show and PlotLegend
• Previous by thread: Re: Plot equations and inequalities together
• Next by thread: Re: Sum problem