# Solving recurrent equations with RSolve

I need to find (or guess?) the symbolic functional form of aFun[n] for a general n (where n>=1). Anyone can help?

aFun[n_] :=
Block[
{a},
a[-1, 0] = 0;
a[n + 1, 0] = 0;
a[-1, 1] = 0;
a[n + 1, 1] = 0;
With[{eqs =
Table[{a[i, 0] ==
i /n ( v +
b (alpha a[i, 0] + (1 - alpha) a[i - 1, 0])) + (1 -
i /n) (v - p +
b (alpha a[i + 1, 1] + (1 - alpha) a[i, 1])),
a[i, 1] ==
i /n ( v +
b (alpha a[i, 0] + (1 - alpha) a[i - 1, 0])) + (1 -
i /n) (v - p (1 - w) +
b (alpha a[i + 1, 1] + (1 - alpha) a[i, 1]))}, {i,
0, n}, {x, 0, 1}] // Flatten,
vars = Table[a[i, x], {i, 0, n}, {x, 0, 1}] // Flatten},
a[0, 0] /. First@Solve[eqs, vars]]
]

• Recurrence is of order 2, so you need one more initial condition. Mar 26, 2021 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... Mar 26, 2021 at 19:56
• The start condition you specify is simply the recursion, therefore you can not determine a[0] from this information. More info is needed. The start condition must be independent from the recursion. Mar 26, 2021 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[0], a[1], a[2], a[3], a[4]. Why we would need any additional info? Mar 26, 2021 at 20:22
• I believe you only have 4 equations in the original, relating the following sets of variables: a[0], a[1]; a[0], a[1], a[2]; a[1], a[2], a[3]; a[2], a[3], a[4]. The example seems to include a3 twice in the final equation. Mar 26, 2021 at 20:55

## 1 Answer

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},
a[-1] = 0; a[m + 1] = 0;
With[{eqs = Table[a[n] == n/m (v + b a[n - 1]) + (1 - n/m) (v - p + b a[n + 1]), {n, 0, m}],
vars = Table[a[n], {n, 0, m}]},
a[0] /. First @ Solve[eqs, vars]]]

• This was super helpful. Thanks alot Mar 27, 2021 at 3:01
• Curiously, a general solution for a[0] in terms of m seems to be a[0] -> ((-m + (m - 1) b) p + (m - (m - 2) b) v)/(m - 2 (m - 1) b + (m - 2) b^2) May 6 at 15:28