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.

A140167 a(n) = (-1)*a(n-1) + 3*a(n-2) with a(1)=-1 and a(2)=1.

Original entry on oeis.org

-1, 1, -4, 7, -19, 40, -97, 217, -508, 1159, -2683, 6160, -14209, 32689, -75316, 173383, -399331, 919480, -2117473, 4875913, -11228332, 25856071, -59541067, 137109280, -315732481, 727060321, -1674257764, 3855438727, -8878212019, 20444528200
Offset: 1

Views

Author

Gary W. Adamson, May 10 2008

Keywords

Comments

A140165 is a companion sequence.

Examples

			a(5) = -19 = (-1)*7 + 3*(-4).
a(5) = -19 = term (1,2) of X^5 since X^5 = [ -2, -19; -19, -59].
		

Crossrefs

Programs

  • GAP
    a:=[-1,1];; for n in [3..30] do a[n]:= -a[n-1]+3*a[n-2]; od; a; # G. C. Greubel, Dec 26 2019
  • Magma
    I:=[-1,1]; [n le 2 select I[n] else (-1)*Self(n-1) + 3*Self(n-2): n in [1..30]]; // Vincenzo Librandi, Aug 31 2015
    
  • Maple
    seq(coeff(series(-x/(1+x-3*x^2), x, n+1), x, n), n = 1..30); # G. C. Greubel, Dec 26 2019
  • Mathematica
    RecurrenceTable[{a[n]== -a[n-1]+3*a[n-2], a[1]== -1, a[2]==1}, a, {n,30}] (* G. C. Greubel, Aug 30 2015 *)
    Table[Round[-(-Sqrt[3])^(n-1)*(LucasL[n-1, 1/Sqrt[3]] + Fibonacci[n-1, 1/Sqrt[3] ]/Sqrt[3])/2], {n,30}] (* G. C. Greubel, Dec 26 2019 *)
  • PARI
    first(m)=my(v=vector(m));v[1]=-1;v[2]=1;for(i=3,m,v[i]=-v[i-1] + 3*v[i-2]); v \\ Anders Hellström, Aug 30 2015
    
  • Sage
    def A140167_list(prec):
        P. = PowerSeriesRing(ZZ, prec)
        return P( -x/(1+x-3*x^2) ).list()
    a=A140167_list(30); a[1:] # G. C. Greubel, Dec 26 2019
    

Formula

a(n) = (-1)*a(n-1) + 3*a(n-2), given a(1) = -1, a(2) = 1. a(n) = term (1,2) of X^n, where X = the 2x2 matrix [1,-1; -1,-2].
From R. J. Mathar, Dec 12 2009: (Start)
a(n) = (-1)^n*A006130(n-1).
G.f.: -x/(1+x-3*x^2). (End)
G.f.: -Q(0)/2 , where Q(k) = 1 + 1/(1 - x*(4*k-1 + 3*x)/( x*(4*k+1 + 3*x) + 1/Q(k+1) )); (continued fraction). - Sergei N. Gladkovskii, Sep 08 2013
E.g.f.: (1/sqrt(13))*(exp(-(1+sqrt(13))*x/2) - exp(-(1-sqrt(13))*x/2)). G. C. Greubel, Aug 30 2015
a(n) = -(-sqrt(3))^(n-1)*(Lucas(n-1, 1/sqrt(3)) + Fibonacci(n-1, 1/sqrt(3) )/sqrt(3))/2. - G. C. Greubel, Dec 26 2019