%I #53 Jan 22 2023 03:52:27
%S 2,1,7,10,31,61,154,337,799,1810,4207,9637,22258,51169,117943,271450,
%T 625279,1439629,3315466,7634353,17580751,40483810,93226063,214677493,
%U 494355682,1138388161,2621455207,6036619690,13900985311,32010844381,73713800314,169746333457
%N Variant on Lucas numbers: a(n) = a(n-1) + 3*a(n-2) with a(0)=2 and a(1)=1.
%C The sequence 4,1,7,.. = 2*0^n+A075118(n) is given by trace(A^n) where A=[1,1,1,1;1,0,0,0;1,0,0,0;1,0,0,0]. - _Paul Barry_, Oct 01 2004
%C For n>2, a(n) is the numerator of the value of the continued fraction 1+3/(1+3/(1+...+3/7)) where there are n-2 1's. - _Alexander Mark_, Aug 16 2020
%D Thomas Koshy, "Fibonacci and Lucas Numbers with Applications", Wiley, 2001, p. 471.
%H Vincenzo Librandi, <a href="/A075118/b075118.txt">Table of n, a(n) for n = 0..1000</a>
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Lucas_sequence">Lucas sequence</a>
%H <a href="/index/Rec#order_02">Index entries for linear recurrences with constant coefficients</a>, signature (1,3).
%F a(n) = ((1+sqrt(13))/2)^n + ((1-sqrt(13))/2)^n.
%F a(n) = 2*A006130(n) - A006130(n-1) = A075117(3, n).
%F G.f.: (2-x)/(1-x-3*x^2). - _Philippe Deléham_, Nov 15 2008
%F a(n) = [x^n] ( (1 + x + sqrt(1 + 2*x + 13*x^2))/2 )^n for n >= 1. - _Peter Bala_, Jun 23 2015
%F a(n) = 3^(n/2) * Lucas(n, 1/sqrt(3)). - _G. C. Greubel_, Jan 15 2020
%e a(4) = a(3)+3*a(2) = 10+3*7 = 31.
%p a:= n-> (Matrix([[1,2]]). Matrix([[1,1], [3,0]])^n)[1,2]:
%p seq(a(n), n=0..35); # _Alois P. Heinz_, Aug 15 2008
%t a[0]=2; a[1]=1; a[n_]:= a[n]= a[n-1] +3a[n-2]; Table[a[n], {n, 0, 30}]
%t CoefficientList[Series[(2-x)/(1-x-3x^2), {x,0,40}], x] (* _Vincenzo Librandi_, Jul 20 2013 *)
%t LinearRecurrence[{1,3},{2,1},40] (* _Harvey P. Dale_, Jun 18 2017 *)
%t Table[Round[Sqrt[3]^n*LucasL[n, 1/Sqrt[3]]], {n,0,40}] (* _G. C. Greubel_, Jan 15 2020 *)
%o (Sage) [lucas_number2(n,1,-3) for n in range(0, 30)] # _Zerinvary Lajos_, Apr 30 2009
%o (Magma) I:=[2,1]; [n le 2 select I[n] else Self(n-1)+3*Self(n-2): n in [1..40]]; // _Vincenzo Librandi_, Jul 20 2013
%o (Magma) R<x>:=PowerSeriesRing(Integers(), 33); Coefficients(R!((2-x)/(1-x-3*x^2))); // _Marius A. Burtea_, Jan 15 2020
%o (PARI) my(x='x+O('x^30)); Vec((2-x)/(1-x-3*x^2)) \\ _G. C. Greubel_, Dec 21 2017
%o (PARI) polsym(x^2-x-3, 44) \\ _Joerg Arndt_, Jan 22 2023
%o (GAP) a:=[2,1];; for n in [3..40] do a[n]:=a[n-1]+3*a[n-2]; od; a; # _G. C. Greubel_, Jan 15 2020
%Y Cf. A000032, A006130, A014551, A072265, A075117, A274977.
%K nonn,easy
%O 0,1
%A _Henry Bottomley_, Sep 02 2002