Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Is the partial sum Sum[(-1)^Total[IntegerDigits[n - 1, 2]]/n, {n, 1, m}] also incorrect ? – b.gatessucks Apr 1 '14 at 13:10
@b.gatessucks: The partial sums seem to be correct. They agree numerically with computations in C#. – Douglas Zare Apr 1 '14 at 13:12
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). – Daniel Lichtblau Apr 1 '14 at 14:24
@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. – Artes Apr 1 '14 at 16:27
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$. – Kellen Myers Aug 9 '14 at 6:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.