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.

A078039 Expansion of (1 - x)/(1 + x - 2*x^2 + x^3).

Original entry on oeis.org

1, -2, 4, -9, 19, -41, 88, -189, 406, -872, 1873, -4023, 8641, -18560, 39865, -85626, 183916, -395033, 848491, -1822473, 3914488, -8407925, 18059374, -38789712, 83316385, -178955183, 384377665, -825604416, 1773314929, -3808901426, 8181135700, -17572253481, 37743426307, -81069068969
Offset: 0

Views

Author

N. J. A. Sloane, Nov 17 2002

Keywords

Comments

The repeated substitution 0 -> {0,1,2}, 1 -> {0,1,2,3}, 2 -> {0,1}, 3 -> {0,1,2}, starting on list {0} and flattening at each step { {sequence1}, {sequence2}, ...} to {sequence1, sequence2, ...} generates a list after n steps with length = a(n). - Wouter Meeussen, Mar 06 2004
Sequence is identical to its second differences negated, minus the first 3 terms. - Paul Curtz, Feb 10 2008

Crossrefs

Cf. A002478.

Programs

  • Magma
    [n le 3 select (-2)^(n-1) else -Self(n-1) +2*Self(n-2) -Self(n-3): n in [1..41]]; // G. C. Greubel, Jan 24 2023
    
  • Mathematica
    LinearRecurrence[{-1,2,-1}, {1,-2,4}, 41] (* G. C. Greubel, Jan 24 2023 *)
  • PARI
    Vec( (1-x)/(1+x-2*x^2+x^3)+O(x^99)) \\ Charles R Greathouse IV, Sep 23 2012
    
  • PARI
    my(p= Mod('x,'x^3+'x^2-2*'x+1)); a(n) = vecsum(Vec(lift(p^(n+4)))); \\ Kevin Ryde, Jan 28 2023
    
  • SageMath
    @CachedFunction
    def a(n): # a = A078039
        if(n<3): return (1,-2,4)[n]
        else: return -a(n-1) + 2*a(n-2) - a(n-3)
    [a(n) for n in range(41)] # G. C. Greubel, Jan 24 2023

Formula

a(n) = -a(n-1) + 2*a(n-2) - a(n-3). - Paul Curtz, Feb 10 2008
a(n) = (-1)^n * (A002478(n) + A002478(n+1)). - Ralf Stephan, Aug 19 2013