%I #66 Oct 22 2023 16:55:32
%S 1,1,-1,-3,1,5,-1,-7,1,9,-1,-11,1,13,-1,-15,1,17,-1,-19,1,21,-1,-23,1,
%T 25,-1,-27,1,29,-1,-31,1,33,-1,-35,1,37,-1,-39,1,41,-1,-43,1,45,-1,
%U -47,1,49,-1,-51,1,53,-1,-55,1,57,-1,-59,1,61,-1,-63,1,65,-1,-67,1,69,-1,-71,1,73,-1,-75,1,77,-1,-79,1,81,-1,-83,1,85
%N Expansion of e.g.f: (1+x)*cos(x).
%C If signs are ignored, continued fraction for tan(1) (cf. A093178).
%H Harry J. Smith, <a href="/A009001/b009001.txt">Table of n, a(n) for n = 0..20000</a>
%H <a href="/index/Rec#order_04">Index entries for linear recurrences with constant coefficients</a>, signature (0,-2,0,-1).
%F a(n) = (-1)^(n/2) if n is even, n*(-1)^((n-1)/2) if n is odd.
%F a(n) = -a(n-2) if n is even, 2*a(n-1) - a(n-2) if n is odd. - _Michael Somos_, Jan 26 2014
%F From _Henry Bottomley_, Oct 19 2001: (Start)
%F a(n) = (n^n mod (n+1))*(-1)^floor(n/2) for n > 0.
%F a(n) = (-1)^n*(a(n-2) - a(n-1)) - a(n-3) for n > 2. (End)
%F G.f.: (1+x+x^2-x^3)/(1+x^2)^2.
%F E.g.f.: (1+x)*cos(x) = U(0) where U(k) = 1 + x - x^2/((2*k+1)*(2*k+2)) * U(k+1). - _Sergei N. Gladkovskii_, Oct 17 2012 [Edited by _Michael Somos_, Jan 26 2014]
%F From _James C. McMahon_, Oct 12 2023: (Start)
%F a(0) = 1; for n > 1,
%F a(n) = a(n-1) * n if n mod 4 = 1,
%F a(n-1) - n if n mod 4 = 2,
%F a(n-1) * n if n mod 4 = 3,
%F a(n-1) + n if n mod 4 = 4. (End)
%e tan(1) = 1.557407724654902230... = 1 + 1/(1 + 1/(1 + 1/(3 + 1/(1 + ...)))). - _Harry J. Smith_, Jun 15 2009
%e G.f. = 1 + x - x^2 - 3*x^3 + x^4 + 5*x^5 - x^6 - 7*x^7 + x^8 + 9*x^9 - x^10 + ...
%p seq(coeff(series(factorial(n)*(1+x)*cos(x), x,n+1),x,n),n=0..90); # _Muniru A Asiru_, Jul 21 2018
%t With[{nn=90},CoefficientList[Series[(1+x)Cos[x],{x,0,nn}],x]Range[0,nn]!] (* _Harvey P. Dale_, Jul 15 2012 *)
%t LinearRecurrence[{0, -2, 0, -1}, {1, 1, -1, -3}, 100] (* _Jean-François Alcover_, Feb 21 2020 *)
%t FoldList[If[Mod[#2, 4]==1, #1*#2, If[Mod[#2, 4]==2, #1-#2,If[Mod[#2,4] ==3,#1*#2,#1+#2]]]&, 1, Range[1, 85]] (* _James C. McMahon_, Oct 12 2023 *)
%o (PARI) {a(n) = (-1)^(n\2) * if( n%2, n, 1)} /* _Michael Somos_, Oct 16 2006 */
%o (PARI) { allocatemem(932245000); default(realprecision, 79000); x=contfrac(tan(1)); for (n=0, 20000, write("b009001.txt", n, " ", (-1)^(n\2)*x[n+1])); } \\ _Harry J. Smith_, Jun 15 2009
%o (Magma) m:=50; R<x>:=PowerSeriesRing(Rationals(), m); b:=Coefficients(R!((1+x)*Cos(x))); [Factorial(n-1)*b[n]: n in [1..m]]; // _G. C. Greubel_, Jul 21 2018
%Y Cf. A009531, A049471 (decimal expansion of tan(1)).
%K sign,easy,nice
%O 0,4
%A _R. H. Hardin_, _N. J. A. Sloane_, _Simon Plouffe_, _David W. Wilson_
%E Formula corrected by _Olivier Gérard_, Mar 15 1997
%E Definition clarified by _Harvey P. Dale_, Jul 15 2012