cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A140165 a(n) = -a(n-1) + 3*a(n-2), starting a(1)=1, a(2)=2.

Original entry on oeis.org

1, 2, 1, 5, -2, 17, -23, 74, -143, 365, -794, 1889, -4271, 9938, -22751, 52565, -120818, 278513, -640967, 1476506, -3399407, 7828925, -18027146, 41513921, -95595359, 220137122, -506923199, 1167334565
Offset: 1

Views

Author

Gary W. Adamson, May 10 2008

Keywords

Comments

Row sums of triangle A140166.
Equals eigensequence of triangle A112555. - Gary W. Adamson, Jan 30 2009

Examples

			a(6) = 17 = (-1)*a(5) + 3*a(4) = (-1)*(-2) + 3*5.
a(4) = 5 = term (1,1) of X^5, where X^5 = [5,7; 7,26].
		

Crossrefs

Programs

  • GAP
    a:=[1,2];; for n in [3..30] do a[n]:=-a[n-1]+3*a[n-2]; od; a; # G. C. Greubel, Dec 26 2019
  • Magma
    R:=PowerSeriesRing(Integers(), 30); Coefficients(R!( x*(1+3*x)/(1+x-3*x^2) )); // G. C. Greubel, Dec 26 2019
    
  • Magma
    a:=[1,2]; [n le 2 select a[n] else -Self(n-1) + 3*Self(n-2): n in [1..30]]; // Marius A. Burtea, Jan 02 2020
    
  • Maple
    seq(coeff(series(x*(1+3*x)/(1+x-3*x^2), x, n+1), x, n), n = 1..30); # G. C. Greubel, Dec 26 2019
  • Mathematica
    Table[Round[(-Sqrt[3])^n*(LucasL[n, 1/Sqrt[3]] - 5*Fibonacci[n, 1/Sqrt[3]]/Sqrt[3])/2], {n,0,30}] (* G. C. Greubel, Dec 26 2019 *)
    LinearRecurrence[{-1,3},{1,2},40] (* Harvey P. Dale, Jun 11 2024 *)
  • PARI
    my(x='x+O('x^30)); Vec(x*(1+3*x)/(1+x-3*x^2)) \\ G. C. Greubel, Dec 26 2019
    
  • Sage
    def A140165_list(prec):
        P. = PowerSeriesRing(ZZ, prec)
        return P( x*(1+3*x)/(1+x-3*x^2) ).list()
    a=A140165_list(30); a[1:] # G. C. Greubel, Dec 26 2019
    

Formula

a(n) = term (1,1) of X^n, where X = the 2 X 2 matrix [1,-1; -1,-2].
G.f.: x*(1+3*x)/(1+x-3*x^2). - Philippe Deléham, Dec 18 2011
a(n) = -(3*A140167(n-1) + A140167(n)). - R. J. Mathar, Apr 22 2013
a(n) = (-sqrt(3))^n*( Lucas(n, 1/sqrt(3)) - 5*Fibonacci(n, 1/sqrt(3))/sqrt(3) )/2. - G. C. Greubel, Dec 26 2019
E.g.f.: (1/13)*exp(-x/2)*(13*cosh(sqrt(13)*x/2) + 5*sqrt(13)*sinh(sqrt(13)*x/2)) - 1. - Stefano Spezia, Jan 02 2020