cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A106400 Thue-Morse sequence: let A_k denote the first 2^k terms; then A_0 = 1 and for k >= 0, A_{k+1} = A_k B_k, where B_k is obtained from A_k by interchanging 1's and -1's.

Original entry on oeis.org

1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, 1
Offset: 0

Views

Author

Michael Somos, May 02 2005

Keywords

Comments

See A010060, the main entry for the Thue-Morse sequence, for additional information. - N. J. A. Sloane, Aug 13 2014
a(A000069(n)) = -1; a(A001969(n)) = +1. - Reinhard Zumkeller, Apr 29 2012
Partial sums of every third terms give A005599. - Reinhard Zumkeller, May 26 2013
Fixed point of the morphism 1 --> 1,-1 and -1 --> -1,1. - Robert G. Wilson v, Apr 07 2014
Fibbinary numbers (A003714) gives the numbers n for which a(n) = A132971(n). - Antti Karttunen, May 30 2017

Examples

			G.f. = 1 - x - x^2 + x^3 - x^4 + x^5 + x^6 - x^7 - x^8 + x^9 + x^10 + ...
The first 2^2 = 4 terms are 1, -1, -1, 1. Exchanging 1 and -1 gives -1, 1, 1, -1, which are a(4) through a(7). - _Michael B. Porter_, Jul 29 2016
		

Crossrefs

Convolution inverse of A018819.
Partial sums of A292118.

Programs

  • Haskell
    import Data.List (transpose)
    a106400 n = a106400_list !! n
    a106400_list =  1 : concat
       (transpose [map negate a106400_list, tail a106400_list])
    -- Reinhard Zumkeller, Apr 29 2012
    
  • Magma
    [1-2*(&+Intseq(n,2) mod(2)): n in [0..100]]; // Vincenzo Librandi, Sep 01 2015
    
  • Maple
    A106400 := proc(n)
            1-2*A010060(n) ;
    end proc: # R. J. Mathar, Jul 22 2012
    subs("0"=1,"1"=-1, StringTools:-Explode(StringTools:-ThueMorse(1000))); # Robert Israel, Sep 01 2015
    # third Maple program:
    a:= n-> (-1)^add(i, i=Bits[Split](n)):
    seq(a(n), n=0..120);  # Alois P. Heinz, Apr 13 2020
  • Mathematica
    tm[0] = 0; tm[n_?EvenQ] := tm[n/2]; tm[n_] := 1 - tm[(n-1)/2]; Table[(-1)^tm[n], {n, 0, 101}] (* Jean-François Alcover, Oct 24 2013 *)
    Nest[ Flatten[# /. {1 -> {1, -1}, -1 -> {-1, 1}}] &, {1}, 7] (* Robert G. Wilson v, Apr 07 2014 *)
    Table[Coefficient[Product[1 - x^(2^k), {k, 0, Log2[n + 1]}], x, n], {n, 0, 20}] (* Vladimir Reshetnikov, Nov 11 2016 *)
    (-1)^ThueMorse[Range[0,100]] (* Paolo Xausa, Dec 18 2023 *)
  • PARI
    {a(n) = if( n<1, n>=0, a(n\2) * (-1)^(n%2))};
    
  • PARI
    {a(n) = my(A, m); if( n<1, n==0, m=1; A = 1 + O(x); while( m<=n, m*=2; A = subst(A, x, x^2) * (1-x)); polcoeff(A, n))};
    
  • PARI
    a(n) = { 1 - 2 * (hammingweight(n) % 2) };  \\ Gheorghe Coserea, Aug 30 2015
    
  • PARI
    apply( {A106400(n)=(-1)^hammingweight(n)}, [0..99]) \\ M. F. Hasler, Feb 07 2020
    
  • Python
    def aupto(nn):
        A = [1]
        while len(A) < nn+1: A += [-i for i in A]
        return A[:nn+1]
    print(aupto(101)) # Michael S. Branicky, Jun 26 2022
    
  • Python
    def A106400(n): return -1 if n.bit_count()&1 else 1 # Chai Wah Wu, Mar 01 2023

Formula

a(n) = (-1)^A010060(n).
a(n) = (-1)^wt(n), where wt(n) is the binary weight of n, A000120(n).
G.f. A(x) satisfies 0 = f(A(x), A(x^2), A(x^4)) where f(u, v, w) = v^3 - 2*u*v*w + u^2*w.
G.f. A(x) satisfies 0 = f(A(x), A(x^2), A(x^3), A(x^6)) where f(u1, u2, u3, u6) = u6*u1^3 - 3*u6*u2*u1^2 + 3*u6*u2^2*u1 - u3*u2^3.
Euler transform of sequence b(n) where b(2^k) = -1 and zero otherwise.
G.f.: Product_{k>=0} (1 - x^(2^k)) = A(x) = (1-x) * A(x^2).
a(n) = B_n(-A038712(1)*0!, ..., -A038712(n)*(n-1)!)/n!, where B_n(x_1, ..., x_n) is the n-th complete Bell polynomial. See the Wikipedia link for complete Bell polynomials , and A036040 for the coefficients of these partition polynomials. - Gevorg Hmayakyan, Jul 10 2016 (edited by - Wolfdieter Lang, Aug 31 2016)
a(n) = A008836(A005940(1+n)). [Analogous to Liouville's lambda] - Antti Karttunen, May 30 2017
a(n) = (-1)^A309303(n), see the closed form (5) in the MathWorld link. - Vladimir Reshetnikov, Jul 23 2019