login
a(n) = a(n - 1) - 2*a(n - 2) + a(n - 3) - 2*a(n - 4) + a(n - 5).
4

%I #22 Sep 08 2022 08:45:28

%S 1,1,1,1,1,-1,-3,-1,3,5,3,-5,-13,-7,13,27,15,-25,-61,-37,57,135,81,

%T -119,-297,-191,257,661,431,-549,-1455,-991,1169,3225,2257,-2497,

%U -7115,-5145,5299,15725,11715,-11261,-34709,-26623,23829,76603,60479,-50361,-168997,-137173,106105,372655,310905,-222951

%N a(n) = a(n - 1) - 2*a(n - 2) + a(n - 3) - 2*a(n - 4) + a(n - 5).

%C This recursion is inspired by Ulam's early experiments in derivative recursions.

%H G. C. Greubel, <a href="/A122582/b122582.txt">Table of n, a(n) for n = 1..1000</a>

%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (1,-2,1,-2,1).

%F G.f.: x*(1+2*x^2+x^3+3*x^4)/(1-x+2*x^2-x^3+2*x^4-x^5). - _R. J. Mathar_, May 12 2013

%t a[n_]:= a[n]= If[n<6, 1, a[n-1] -2*a[n-2] +a[n-3] -2*a[n-4] +a[n-5]];

%t Table[a[n], {n, 60}]

%t Transpose[NestList[Flatten[{Rest[#],ListCorrelate[{1,-2,1,-2,1},#]}]&, {1,1,1,1,1},60]][[1]] (* _Harvey P. Dale_, Mar 21 2011 *)

%o (Magma) [n le 5 select 1 else Self(n-1) -2*Self(n-2) +Self(n-3) -2*Self(n-4) +Self(n-5): n in [1..50]]; // _G. C. Greubel_, Nov 28 2021

%o (Sage)

%o @CachedFunction # a=A122582

%o def a(n): return 1 if (n<6) else a(n-1) -2*a(n-2) +a(n-3) -2*a(n-4) +a(n-5)

%o [a(n) for n in (1..50)] # _G. C. Greubel_, Nov 28 2021

%Y Cf. A122581, A122583, A122584.

%K sign

%O 1,7

%A _Roger L. Bagula_, Sep 19 2006

%E Edited by _N. J. A. Sloane_, Oct 01 2006, Jan 01 2007