login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A309873 Period-doubling turn sequence, +1 when the 2-adic valuation of n is even or -1 when odd. 1

%I #40 Jan 03 2023 09:21:57

%S 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,

%T -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,

%U 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

%N Period-doubling turn sequence, +1 when the 2-adic valuation of n is even or -1 when odd.

%C a(n)=+1 when the number of low 0 bits of n is even, and a(n)=-1 when odd. This is the "period doubling" sequence A096268 but using +1,-1. See A096268 and its complement A035263 for more. The number of low 0 bits of n is A007814. a(n) is completely multiplicative since A007814(n*m) = A007814(n) + A007814(m).

%C a(n) is among some completely multiplicative +1,-1 sequences considered by Davis and Knuth for forming curves by unfolding. a(n) is their d(n) at equation 6.4. The curve can be drawn by successively going forward a unit step and turning by a(n)*angle. Their "bending" angle T is equivalent to turns by 180-T degrees. They draw bending angle 90 degrees which is merely 4 unit squares repeatedly traversed; and bending 60 degrees "Fido" and 120 degrees which are bigger and more interesting. Partial sums A068639 are the directions (net total turn) of the segments.

%D Chandler Davis and Donald E. Knuth, Number Representations and Dragon Curves -- I and II, Journal of Recreational Mathematics, volume 3, number 2, April 1970, pages 66-81, and number 3, July 1970, pages 133-149. Reprinted in Donald E. Knuth, Selected Papers on Fun and Games, 2010, pages 571-614.

%H Kevin Ryde, <a href="/A309873/b309873.txt">Table of n, a(n) for n = 1..4096</a>

%H Kevin Ryde, <a href="/A309873/a309873.pdf">Sample Images</a> (and <a href="/A309873/a309873.tex">LaTeX source</a>)

%H Kevin Ryde, <a href="/A309873/a309873.l.txt">Xfractint L-System Specification</a>

%F a(n) = (-1)^A007814(n) = -(-1)^A065882(n) = 1 - 2*A096268(n-1) = 2*A035263(n) - 1 = A035263(n) - A096268(n-1).

%F a(n) = A068639(n) - A068639(n-1).

%F a(A003159) = 1, a(A036554) = -1.

%F For prime p, a(p) = -1 if p=2 (even), a(p) = 1 if p odd [Davis and Knuth, which together with completely multiplicative defines a(n)].

%F Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 1/3. - _Amiram Eldar_, Sep 18 2022

%F Dirichlet g.f.: zeta(s)*(2^s-1)/(2^s+1). - _Amiram Eldar_, Jan 03 2023

%t Array[(-1)^IntegerExponent[#, 2] &, 100] (* _Amiram Eldar_, Aug 22 2019 *)

%o (PARI) a(n) = (-1)^valuation(n,2);

%o (UCB Logo) ; a(n), and draw "Fido" of Davis and Knuth

%o to a :n

%o output 2*(remainder (bitxor :n :n-1) 3) - 1

%o end

%o setheading 90 ; start East

%o repeat 4095 [ forward 7 ; pixels

%o left (a repcount) * 120 ] ; or try 60 or 90

%o (Python)

%o def A309873(n): return -1 if (~n & n-1).bit_length()&1 else 1 # _Chai Wah Wu_, Dec 26 2022

%Y Cf. A096268, A035263, A003159, A036554, A007814.

%Y Partial sums A068639.

%K mult,sign,easy

%O 1

%A _Kevin Ryde_, Aug 21 2019

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 24 19:24 EDT 2024. Contains 371962 sequences. (Running on oeis4.)