# unknown variable in a recursion relation

I have a code as follows

fv = RecurrenceTable[{a[i] ==
1/Sqrt[w] a[i - 1] + (2 i - 1 - (2 i + 1)) a[i - 2],
a[2] == 1/6 (1/(2*w) + 3 - (2 i + 1)), a[1] == 1/(2 Sqrt[w])},
a, {i, 3, 5}];


In fact I want to calculate answers of a recursion relation. but when I try to print fv I have the below answer which means that i is unknown,

{-(1/Sqrt[w])+(2-2 i+1/(2 w))/(6 Sqrt[w]),1/3 (-2+2 i-1/(2 w))+(-(1/Sqrt[w])+(2-2 i+1/(2 w))/(6 Sqrt[w]))/Sqrt[w]}


I don't know how should I debug it, any idea?

This

sol=RSolve[{a[i]==1/Sqrt[w]a[i-1]+(2i-1-(2i+1))a[i-2],
a[2]==1/6(1/(2*w)+3-(2i+1)),a[1]==1/(2 Sqrt[w])}, a[i],i];
a[i]/.sol[[1]]/.i->4//Simplify


instantly returns

(24 + w^(-2) - 26/w)/12


and likewise provides a solution if you replace that 4 with 3 or with 5, etc.

You could adapt this to use Table to provide your list of solutions.

Check these results very carefully to make certain that they are correct.

I am just guessing, but I expect the reason you have an i remaining in your results from RecurrenceTable is that you have an i in your base case a[2]. Usually the base cases for recurrence relations do not include that recurrence index. It appears that RSolve applies some extra calculations to be able to resolve the result in spite of your extra recurrence index. But again, this is just guessing.

• Thanks a lot. your code works however I have to specify i each time manually. Also your guess was true, the problem returned to definition of a[2]. Commented Oct 13, 2019 at 8:55