A052545 Expansion of (1-x)^2/(1-3*x+x^3).
1, 1, 4, 11, 32, 92, 265, 763, 2197, 6326, 18215, 52448, 151018, 434839, 1252069, 3605189, 10380728, 29890115, 86065156, 247814740, 713554105, 2054597159, 5915976737, 17034376106, 49048531159, 141229616740, 406654474114
Offset: 0
Links
- G. C. Greubel, Table of n, a(n) for n = 0..1000
- INRIA Algorithms Project, Encyclopedia of Combinatorial Structures 481
- Index entries for linear recurrences with constant coefficients, signature (3,0,-1).
Programs
-
GAP
a:=[1,1,4];; for n in [4..40] do a[n]:=3*a[n-1]-a[n-3]; od; a; # G. C. Greubel, May 08 2019
-
Magma
R
:=PowerSeriesRing(Integers(), 40); Coefficients(R!( (1-x)^2/(1-3*x+x^3) )); // G. C. Greubel, May 08 2019 -
Maple
spec := [S,{S=Sequence(Prod(Z,Union(Z,Sequence(Z)),Sequence(Z)))},unlabeled]: seq(combstruct[count](spec,size=n), n=0..20);
-
Mathematica
LinearRecurrence[{3,0,-1}, {1,1,4}, 40] (* G. C. Greubel, May 08 2019 *)
-
PARI
my(x='x+O('x^40)); Vec((1-x)^2/(1-3*x+x^3)) \\ G. C. Greubel, May 08 2019
-
Python
TOP = 33 a = [1]*TOP a[2]=4 for n in range(3,TOP): print(a[n-3], end=',') a[n] = 3*a[n-1] - a[n-3] # Alex Ratushnyak, Aug 10 2012
-
Sage
((1-x)^2/(1-3*x+x^3)).series(x, 40).coefficients(x, sparse=False) # G. C. Greubel, May 08 2019
Formula
G.f.: (1-x)^2/(1-3*x+x^3).
a(n) = 3*a(n-1) - a(n-3), with a(0)=a(1)=1, a(2)=4.
a(n) = Sum_{alpha = RootOf(1-3*x+x^3)} (-1/9 * (-1+2*alpha^2-2*alpha) * alpha^(-1-n)).
Comments