37
$\begingroup$

Bug introduced in 7.0 or earlier and fixed in 11.0.1


When I try to evaluate the following:

$$\sum_{k=1}^{\infty }\Bigg\lfloor\frac{5}{5^k}\Bigg\rfloor$$

using

Sum[Floor[5/5^k], {k, 1, ∞}]

Mathematica provides an answer of $0$ when it clearly should be $1$. Using any finite limit for the summation, however, provides the correct answer. Why does this happen?

$\endgroup$
17
  • 5
    $\begingroup$ What is the code you are using to get your result? $\endgroup$
    – Leucippus
    Commented Dec 24, 2015 at 3:27
  • 2
    $\begingroup$ Interesting: stackoverflow.com/questions/8690884/… $\endgroup$
    – smörkex
    Commented Dec 24, 2015 at 6:12
  • 1
    $\begingroup$ Fascinating. Sum[Floor[5/5^k], {k, 0, \[Infinity]}] gives the expected 6, while Sum[Floor[5/5^k], {k, a, Infinity}] gives 0 for all larger a I've tested. $\endgroup$ Commented Dec 24, 2015 at 12:51
  • 1
    $\begingroup$ The reason why a finite limit gives a good result is that in that case Mathematica computes the result directly: calculate each term, sum them up. Using a symbolic limit also results in 0. I don't have any insight into why it misses the k == 1 case when doing it symbolically. Tagging as bug. $\endgroup$
    – Szabolcs
    Commented Dec 24, 2015 at 13:16
  • 1
    $\begingroup$ @Szabolcs, i.e. such finit limit Sum[Floor[5/5^k], {k, 1, 10^20}] gives 0. But Sum[Floor[5/5^k], {k, 0.99999999, Infinity}] gives 1. Definitely bug $\endgroup$
    – garej
    Commented Dec 24, 2015 at 13:34

2 Answers 2

7
$\begingroup$

This bug has been fixed in the just released Mathematica 11.0.1.

Sum[Floor[5/5^k], {k, 1, Infinity}]

(* 1 *)
$\endgroup$
6
$\begingroup$

This is certainly a bug, but one the user is warned about. The help section on "Possible Issues" provides a couple of examples where Sum gives "an unexpected result" (read: a wrong one). It's always related to using some discrete function that cannot be evaluated symbolically, like PrimeQ or Plus@*IntegerDigits, and ends up oversimplified at the attempt. I strongly believe your case is no different because [5/5^k] is zero in all points inside [1,+∞), so perhaps Mathematica simplifies the summand to zero when trying to perform its symbolic methods. The remedy advised by the official help is to "prevent symbolic evaluation" by specifying a Method (none of the official list works, which should be a hint) or by making the sum finite.

$\endgroup$
1
  • 7
    $\begingroup$ Good guess, and in fact it was my initial guess when I first saw this. But it turns out to be an actual bug insofar as there is explicit code to handle this type of problem, and it is going awry somewhere. $\endgroup$ Commented Mar 3, 2016 at 23:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.