I would like to evaluate

$$s = 1 - \frac{1}{2} - \frac{1}{3} + \frac{1}{4} - \frac{1}{5} + \frac{1}{6}+\frac{1}{7}-\frac{1}{8} - ... + \frac{(-1)^{\textrm{binary digit sum}(n-1)}}{n} + ... $$

where the signs follow the Thue-Morse sequence. When I try to evaluate

Sum[ (-1)^Total[ IntegerDigits[ n - 1, 2]]/n, {n, 1, ∞}]

using Mathematica 7 I get


This is incorrect. $$\log( 2) = \sum_{n=1}^\infty \frac{(-1)^{n-1}}{n} \approx 0.693147$$ but $$s \approx 0.39876108810841881241$$ I checked this using C# and finite sums within Mathematica. This value is not in the inverse symbolic calculator, but since that is incomplete I still have some hope for an analytic summation.

The difference between these series can be expressed as a sum of positive terms $$\frac{2}{3\times 4} + \frac{2}{5\times 6} + \frac{2}{9\times 10} + \frac{2}{15\times 16}+\ldots+\frac{2}{n \times (n+1)}+ \ldots$$ where the sum is over all odd $n$ with even binary digit sum, so it is definitely the case that $s \lt \log( 2).$

I also tried

Sum[ (-1)^Total[ IntegerDigits[ n - 1, 2]]/n, { n, 1, ∞, 2}]

which equals $\frac{3}{2}s \approx 0.59814163216262821861$, but which instead evaluates to

Sum::div: Sum does not converge

Sum[ (-1)^(1 + n)/n, { n, 1, ∞, 2}]

So, is this a known bug?
What sorts of related sums are affected?
Is there a way to get the right answer from Mathematica?

  • $\begingroup$ Is the partial sum Sum[(-1)^Total[IntegerDigits[n - 1, 2]]/n, {n, 1, m}] also incorrect ? $\endgroup$ Apr 1, 2014 at 13:10
  • $\begingroup$ @b.gatessucks: The partial sums seem to be correct. They agree numerically with computations in C#. $\endgroup$ Apr 1, 2014 at 13:12
  • 8
    $\begingroup$ The result obtained arises from the fact that IntegerDigits[n - 1, 2] returns unevaluated, and Total thereof then gives n+1. Not wrong, but also not what is wanted. To forestall this one might rewrite the summand as a "black box" function that only evaluates on explicit integer input, e.g. f[n_Integer] := (-1)^Total[IntegerDigits[n - 1, 2]]/n. Using this the sum returns unevaluated (no surprise there). $\endgroup$ Apr 1, 2014 at 14:24
  • 1
    $\begingroup$ @DouglasZare I did not mean numerical calculations were not welcome. I guessed you would underline the problem in a bit clearer setting. Anyway I upvoted your question and I think it deserves more upvotes. $\endgroup$
    – Artes
    Apr 1, 2014 at 16:27
  • 1
    $\begingroup$ Just to throw another non-working idea onto the pile, GeneratingFunction won't work because the recurrence for the Thue Morse sequence (and thus also the summand here) is not simple enough for GeneratingFunction and DifferenceRoot to handle. Otherwise we could construct a whole power series / generating function and then evaluate at $x=1$. $\endgroup$ Aug 9, 2014 at 6:31


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.