Binary Recurrence Sequences

JavaScript (ES6), 51 44 bytes

(x,y,z,a,b)=>g=n=>n<y?z[n]:a*g(n-x)+b*g(n-y)

Note that the function is partially curried, e.g. f(1,2,[1,1],1,1)(8) returns 34. It would cost 2 bytes to make the intermediate functions independent of each other (currently only the last generated function works correctly).

Edit: Saved 7 bytes thanks to @Mego pointing out that I'd overlooked that the the passed-in array always contains the first y elements of the result.


Python 2, 62 bytes

x,y,l,a,b=input();f=lambda n:l[n]if n<y else a*f(n-x)+b*f(n-y)

A direct recursive solution. All inputs are taken from STDIN except for n as a function argument, a split that's is allowed by default (though contentiously).

There doesn't seem to be a way to save bytes with and/or in place of if/else because l[n] could be falsey as 0.


Jelly, 11 bytes

⁴Cịæ.⁵ṭµ¡⁶ị

Try it online!  1  |  2  |  3  |  4  |  5 

How it works

⁴Cịæ.⁵ṭµ¡⁶ị  Main link. Arguments: a; [x, y]; [α, β]; n (1-based)

       µ     Combine the links to the left into a chain.
        ¡    Execute that chain n times, updating a after each execution.
⁴              Yield [x, y].
 C             Complement; yield [1 - x, 1 - y].
  ị            Retrieve the elements of a at those indices.
               Indexing is 1-based and modular in Jelly, so this retrieves
               [a[-x], a[-y]] (Python syntax).
     ⁵         Yield [α, β].
   æ.          Take the dot product of [a[-x], a[-y]] and [α, β].
         ⁶   Yield n.
          ị  Retrieve the element of a at index n.