Message Boards Message Boards


Use Sum while the summand is a function?

Posted 2 months ago
3 Replies
1 Total Likes

Mathematica Windows 10 64

Before posting a bug, I would like if anybody can verify:

The following works o.k:

Sum[Times @@ (IntegerDigits[i, 7] + 1), {i, 0, 10^6}]

However if the Summand is a function we get some gibberish:

fu[n_] := Times @@ (IntegerDigits[n, 7] + 1);

Sum[fu[i], {i, 0, 10^6}]

Interestingly, the following works:

Sum[fu[i], {i, 1, 10^6}]
3 Replies

Sum can do this "procedurally", and the default method (Automatic) apparently does so when given the explicit summand. With the function form it only does the procedural when the number of terms is under a certain limit, by default 10^6. The two examples straddle this limit, hence the observed behavior. One can change this default as below.

SetSystemOptions["SymbolicSumThreshold" -> 1000001];

fu[n_] := Times @@ (IntegerDigits[n, 7] + 1)
Sum[fu[i], {i, 0, 10^6}]

(* Out[49]= 14938433536 *)
Posted 2 months ago

Hi Daniel (Lichtblau), it's a pleasure hearing from again. It has been a long time, you may not remember. Daniel (Huber)

Daniel (Huber), yes, I remember you. Goes back a ways...

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract