%I #45 Feb 13 2023 09:02:01
%S 1,3,9,28,89,286,924,2993,9707,31501,102256,331981,1077870,3499720,
%T 11363361,36896355,119801329,388991876,1263047761,4101088878,
%U 13316149700,43237262993,140390505643,455845099957,1480119728920
%N Number of (s(0), s(1), ..., s(2n)) such that 0 < s(i) < 7 and |s(i) - s(i-1)| = 1 for i = 1,2,...,2*n, s(0) = 1, s(2n) = 3.
%C In general a(n) = (2/m)*Sum_{r=1..m-1} sin(r*j*Pi/m)*sin(r*k*Pi/m)*(2*cos(r*Pi/m))^(2n)) counts (s(0), s(1), ..., s(2n)) such that 0 < s(i) < m and |s(i) - s(i-1)| = 1 for i = 1,2,...,2n, s(0) = j, s(2n) = k.
%C With interpolated zeros (0,0,1,0,3,0,9,...), counts walks of length n between the first and third nodes of P_6. - _Paul Barry_, Jan 26 2005
%C Counts all paths of length (2*n+1), n >= 0, starting at the initial node and ending on the nodes 1, 2, 3, 4 and 5 on the path graph P_6, see the Maple program. - _Johannes W. Meijer_, May 29 2010
%C With offset 0 = the INVERT transform of A055588. - _Gary W. Adamson_, Apr 01 2011
%H Michael De Vlieger, <a href="/A094790/b094790.txt">Table of n, a(n) for n = 1..1956</a>
%H Nachum Dershowitz, <a href="https://arxiv.org/abs/2006.06516">Between Broadway and the Hudson: A Bijection of Corridor Paths</a>, arXiv:2006.06516 [math.CO], 2020.
%H László Németh and László Szalay, <a href="https://cs.uwaterloo.ca/journals/JIS/VOL24/Nemeth/nemeth8.html">Sequences Involving Square Zig-Zag Shapes</a>, J. Int. Seq., Vol. 24 (2021), Article 21.5.2.
%H <a href="/index/Rec#order_03">Index entries for linear recurrences with constant coefficients</a>, signature (5,-6,1).
%F a(n) = (2/7)*Sum_{k=1..6} sin(Pi*k/7)*sin(3*Pi*k/7)*(2*cos(Pi*k/7))^(2n).
%F a(n) = 5*a(n-1) - 6*a(n-2) + a(n-3).
%F G.f.: x*(1-2*x)/(1 - 5*x + 6*x^2 - x^3).
%F a(n) = rightmost term in M^n * [1,0,0] where M = the 3 X 3 matrix [2,1,1; 1,2,0; 1,0,1]. E.g., M^3 * [1,0,0] = [19,14,9]; right term = 9 = a(3). - _Gary W. Adamson_, Apr 04 2006
%p with(GraphTheory):G:=PathGraph(6): A:= AdjacencyMatrix(G): nmax:=24; n2:=2*nmax+1: for n from 0 to n2 do B(n):=A^n; a(n):=add(B(n)[k,1],k=1..5); od: seq(a(2*n+1),n=0..nmax); # _Johannes W. Meijer_, May 29 2010
%t f[n_]:= FullSimplify[ TrigToExp[(2/7)Sum[ Sin[Pi*k/7]Sin[3Pi*k/7](2Cos[Pi*k/7] )^(2n), {k,6}]]];
%t Table[f[n], {n, 25}] (* _Robert G. Wilson v_, Jun 18 2004 *)
%t LinearRecurrence[{5,-6,1},{1,3,9},30] (* _Harvey P. Dale_, Nov 19 2019 *)
%o (PARI) Vec(x*(1-2*x)/(1-5*x+6*x^2-x^3)+O(x^99)) \\ _Charles R Greathouse IV_, Jun 14 2015
%o (Magma) [n le 3 select 3^(n-1) else 5*Self(n-1) -6*Self(n-2) +Self(n-3): n in [1..31]]; // _G. C. Greubel_, Feb 12 2023
%o (SageMath)
%o @CachedFunction
%o def a(n): # a = A094790
%o if (n<4): return 3^(n-1)
%o else: return 5*a(n-1) - 6*a(n-2) + a(n-3)
%o [a(n) for n in range(1,41)] # _G. C. Greubel_, Feb 12 2023
%Y Cf. A005021, A028495, A052975, A055588, A078038, A080937, A094789.
%K nonn,easy
%O 1,2
%A _Herbert Kociemba_, Jun 11 2004