Closed form for the partial sums of the Thue-Morse sequence

closed-formcombinatorics-on-wordssequences-and-series

Let $t_n$ denote the $n^{\rm th}$ element of the Thue-Morse sequence, i.e., $t_n$ begins
$$
0,1,1,0,1,0,0,1,\ldots
$$

Now let $s_n$ denote the sequence defined by the partial sums of the $t_n$, so $s_n$ therefore begins
$$
0, 1, 2, 2, 3, 3, 3, 4, \ldots
$$

(entry A115384 in the OEIS). Unfortunately the OEIS page does not list any closed forms for the $n^{\rm th}$ element of this sequence. Can such a closed form be found? Note that by ''closed form'' I mean a function that does not involve any partial sum.

Best Answer

I get heuristically , for the sequence beginning with $n=0$ and $$T(n)=\text{Hammingweight}(n) \\ \qquad \qquad =\text{bitcount}(n) \pmod 2 \tag 1$$ for $s(n)=\sum_{k=0}^n T(n)$

$$ s(n)=\sum_{k=0}^n T(n) = \frac n2 + \begin{cases} T(n) &\text{if } n \equiv 0,2 \pmod 4 \\ \frac 12 &\text{if } n \equiv 1,3 \pmod 4 \\ \end{cases} \tag 2$$ (modulo typing-error)....

Using $(-1)^n$ one can even make a oneliner from Eq (2).


   ----------------------------------------------
        n      T(n)     s(n)      n/2    + T(n)
   ----------------------------------------------
        0        0        0        0    
        4        1        3        2    
        8        1        5        4    
       12        0        6        6    
       16        1        9        8    
       20        0       10       10    
       24        0       12       12    
       28        1       15       14    
   ----------------------------------------------
        n      T(n)     s(n)      n/2      +1/2
   ----------------------------------------------
        1        1        1      1/2        1/2                    
        5        0        3      5/2        1/2                    
        9        0        5      9/2        1/2                    
       13        1        7     13/2        1/2                    
       17        0        9     17/2        1/2                    
       21        1       11     21/2        1/2                    
       25        1       13     25/2        1/2                    
       29        0       15     29/2        1/2                    
   ----------------------------------------------
        n      T(n)     s(n)      n/2     +T(n)
   ----------------------------------------------
        2        1        2        1    
        6        0        3        3    
       10        0        5        5    
       14        1        8        7    
       18        0        9        9    
       22        1       12       11    
       26        1       14       13    
       30        0       15       15    
   ----------------------------------------------
        n      T(n)     s(n)      n/2      +1/2
   ----------------------------------------------
        3        0        2      3/2        1/2                    
        7        1        4      7/2        1/2                    
       11        1        6     11/2        1/2                    
       15        0        8     15/2        1/2                   
       19        1       10     19/2        1/2                    
       23        0       12     23/2        1/2                    
       27        0       14     27/2        1/2                    
       31        1       16     31/2        1/2                    
Related Question