Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10083 > unrolled thread

Re: unexpected behaviour of Sum

Started byAndrzej Kozlowski <akozlowski@gmail.com>
First post2012-05-15 08:55 +0000
Last post2012-05-15 08:55 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: unexpected behaviour of Sum Andrzej Kozlowski <akozlowski@gmail.com> - 2012-05-15 08:55 +0000

#10083 — Re: unexpected behaviour of Sum

FromAndrzej Kozlowski <akozlowski@gmail.com>
Date2012-05-15 08:55 +0000
SubjectRe: unexpected behaviour of Sum
Message-ID<jot5mf$aof$1@smc.vnet.net>
Your guess about "something symbolic" was correct:

SetSystemOptions["SymbolicSumThreshold" -> 10^7];

sod[n_] := Plus @@ IntegerDigits[n]

Sum[sod[k], {k, 1 + 10^6}]

27000003

Andrzej Kozlowski

On 14 May 2012, at 07:34, perplexed wrote:

> I do not want to say that this is a bug, however I did
> not find, in the Sum documentation, an explanation of this
> behaviour (v8.0.4)
> 
> I defined an innocent function like
> sod[n_]:=Plus@@IntegerDigits[n]
> that compute the sum of the digits of a number.
> (I tried with other functions, so the culprit is not IntegerDigits)
> 
> Then I compute two sums:
> Sum[sod[k],{k,10^6}] which gives 27000001 (ok)
> then 
> Sum[sod[k],{k,1+10^6}] which gives 500001500001 (nonsense).
> then 
> Sum[sod[k],{k,2,1+10^6}] which gives 27000002 (ok)
> 
> so, it seems to me that Sum has a problem when the iterator
> works in a range greater than 10^6.
> 
> Indeed, I made an experiment:
> I set L={}; and defined
> sod[n_]:=(AppendTo[L,n];Plus@@IntegerDigits[n])
> Then Sum[sod[k],{k,1+10^6}] still gives 500001500001 
> and at the end L is equal to {k}, so it seems that
> Sum tried to do something symbolic (??).
> 
> Is this a bug or a feature whose documentation I was not
> able to find? Say, is there an option to fix things ?
> 
> Btw, using ParallelSum instead of Sum works fine (and faster).
> thanks
> 

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web