# Solving recurrent equations with RSolve

I am trying to find a by solving the following system of equations where n can get 1,2,3,...,m-1

RSolve[{a[m]==(v+b a[m-1],
a[n] ==  n/m (v + b a[n - 1]) + (1 - n/m) (v - p + b a[n + 1]),
a == v - p + b a}, a[n], n]


But it doesn't produce any results, any idea how to make this work?

This is an example with m= 4:


Solve[{a0 == v - p + b a1 &&
a1 == 1/4 (v + b a0) + (1 - 1/4) (v - p + b a2) &&
a2 == 2/4 (v + b a1) + (1 - 2/4) (v - p + b a3) &&
a3 == 3/4 (v + b a2) + (1 - 3/4) (v - p + b a4) &&
a4 == 4/4 (v + b a3) }, {a0, a1, a2, a3,a4}]

$$$$

• Recurrence is of order 2, so you need one more initial condition. – Vaclav Kotesovec Mar 26 at 19:41
• I don't think that's the issue; adding one doesn't produce a result, and mathematica usually includes undetermined constants if the solution is underdetermined anyway, so that shouldn't be an issue. It might simply be not solvable by mathematica... – thorimur Mar 26 at 19:56
• The start condition you specify is simply the recursion, therefore you can not determine a from this information. More info is needed. The start condition must be independent from the recursion. – Daniel Huber Mar 26 at 20:01
• Thanks for the comments. I do not have any other conditions to add. Say m = 4, we will have 5 equations in this series with five unknowns: a, a, a, a, a. Why we would need any additional info? – Monire Jalili Mar 26 at 20:22
• I believe you only have 4 equations in the original, relating the following sets of variables: a, a; a, a, a; a, a, a; a, a, a. The example seems to include a3 twice in the final equation. – thorimur Mar 26 at 20:55

I'm not totally sure RSolve is the best way to approach this; I'm also not sure the below is the best way to approach it either! But I was able to get it to work:
a0[m_] := Block[{a},