%I #56 Oct 17 2024 20:03:54
%S 1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,
%T 1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,
%U -2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1,1,-2,1
%N Period 3: repeat [1, -2, 1].
%C Second differences of A131534. Binomial transform of 1, -3, 6, -9, 9, 0, ..., A057083 signed.
%C Nonsimple continued fraction expansion of sqrt(2)-1 = 0.414213562... - _R. J. Mathar_, Mar 08 2012
%H <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (-1,-1).
%F a(n) = b(2*n + 1) where b(n) is multiplicative with b(2^n) = 0^n, b(3^n) = 3 * 0^n - 2, b(p^n) = 1 if p > 3. - _Michael Somos_, Jan 02 2011
%F G.f.: (1-x)/(x^2+x+1). - _R. J. Mathar_, Nov 14 2007
%F a(n) = 2*cos((2n+1)*Pi/3). - _Jaume Oliver Lafont_, Nov 23 2008
%F a(n) = A117188(2*n). - _R. J. Mathar_, Jun 13 2011
%F a(n) + a(n-1) + a(n-2) = 0 for n>1, a(n) = a(n-3) for n>2. - _Wesley Ivan Hurt_, Jul 01 2016
%F a(n) = (1/4^n) * Sum_{k = 0..n} binomial(2*n+1,2*k)*(-3)^k. - _Peter Bala_, Feb 06 2019
%F E.g.f.: 2*exp(-x/2)*cos(sqrt(3)*x/2 + Pi/3). - _Fabian Pereyra_, Oct 17 2024
%p seq(op([1, -2, 1]), n=0..50); # _Wesley Ivan Hurt_, Jul 01 2016
%t f[n_] := If[ Mod[n, 3] == 1, -2, 1]; Array[f, 105, 0]
%t CoefficientList[Series[(1 - x)/(1 + x + x^2), {x, 0, 104}], x]
%t PadRight[{}, 120, {1,-2,1}] (* _Harvey P. Dale_, Jan 25 2014 *)
%o (PARI) a(n)=[1,-2,1][1+n%3] \\ _Jaume Oliver Lafont_, Mar 24 2009
%o (PARI) a(n)=1-3*(n%3==1) \\ _Jaume Oliver Lafont_, Mar 24 2009
%o (Magma) &cat [[1, -2, 1]^^30]; // _Wesley Ivan Hurt_, Jul 01 2016
%Y Cf. A057083, A061347, A131534.
%K sign,easy,less
%O 0,2
%A _Paul Curtz_, Sep 14 2007
%E Corrected and extended by _Michael Somos_, Jan 02 2011