Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10075
| From | perplexed <yudumbo@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | unexpected behaviour of Sum |
| Date | 2012-05-14 05:34 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <joq5h8$r20$1@smc.vnet.net> (permalink) |
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
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
unexpected behaviour of Sum perplexed <yudumbo@gmail.com> - 2012-05-14 05:34 +0000
Re: unexpected behaviour of Sum A Retey <awnl@gmx-topmail.de> - 2012-05-15 08:53 +0000
Re: unexpected behaviour of Sum perplexed <yudumbo@gmail.com> - 2012-05-18 09:23 +0000
Re: unexpected behaviour of Sum Murray Eisenberg <murray@math.umass.edu> - 2012-05-19 09:53 +0000
Re: unexpected behaviour of Sum Murray Eisenberg <murray@math.umass.edu> - 2012-05-16 08:25 +0000
csiph-web