Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Sum problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65285] Sum problem
  • From: Majka Arkadiusz <Arkadiusz.Majka at telekomunikacja.pl>
  • 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