# How can I solve my recursion equation?

How can I solve the recursion equation given below?

I doubt there have no solution for the recursion equation because this is circulating recucrsion equation.

RSolve[
If[n >= 3,
S[n] == ((c/m + 1)*S[n - 1] - q*S[n - 2])/q,
{S[2] == (S[1]*(c + m))/(m*q) - 2*S[0],
S[1] == ((S[0] - 1)*(c/m + 1) + 2*q)/q - S[n]}],
S[n], n]

-
Something is wrong in the definition of the boundary term S[1], are you sure that there is S[n]? – mmal Aug 6 '13 at 8:33
@user69748 Am I missing something or there should be a boundary condition S[0] ? – Sektor Aug 8 '13 at 15:52

I still think that the condition S[0] should be included in your code, but nevertheless I obtained some results which might be helpful in your situation. So, two approaches:

Solve[
{Assuming[n >= 3, S[n] == ((c/m + 1)*S[n - 1] - q*S[n - 2])/q],
S[2] == (S[1]*(c + m))/(m*q) - 2*S[0],
S[1] == ((S[0] - 1)*(c/m + 1) + 2*q)/q - S[n]},
S[n], n] // FullSimplify


Output:

$\left\{\left\{S(n)\to \frac{c (S(0)-1)+m (-q (S(1)-2)+S(0)-1)}{m q}\right\}\right\}$

Reduce[
{Assuming[n >= 3, S[n] == ((c/m + 1)*S[n - 1] - q*S[n - 2])/q],
S[2] == (S[1]*(c + m))/(m*q) - 2*S[0],
S[1] == ((S[0] - 1)*(c/m + 1) + 2*q)/q - S[n]},
S[n]] // FullSimplify


Output:

m q != 0 && ((S[-2 + n] + S[n] == ((c + m) S[-1 + n])/(
m q) && ((c + m + (m q (-2 + S[1] - S[-2 + n]))/(
1 - S[0] + S[-1 + n]) ==
0 && (4 S[0] + S[2] + Sqrt[
8 (-2 + S[1]) S[1] + (2 + S[2])^2 - 8 S[1] S[-2 + n] +
4 S[-1 + n] (2 + S[2] + S[-1 + n])] == 2 + 2 S[-1 + n] ||
2 + 2 S[-1 + n] + Sqrt[
8 (-2 + S[1]) S[1] + (2 + S[2])^2 - 8 S[1] S[-2 + n] +
4 S[-1 + n] (2 + S[2] + S[-1 + n])] ==
4 S[0] + S[2])) || (c == (
m (-2 + q (2 + S[2]) - S[-2 + n] + 2 q S[-1 + n]))/(
2 + S[-2 + n]) && S[0] == 1 + S[-1 + n] &&
S[1] == 2 + S[-2 + n] && 2 + S[-2 + n] != 0))) || (S[0] ==
1 + S[-1 + n] && S[1] == 0 && 2 + S[-2 + n] == 0 &&
2 + S[2] + 2 S[-1 + n] == 0 &&
S[n] == 2 + ((c + m) S[-1 + n])/(m q)))


I know this is not a pretty nor elegant answer, but should give you a kick-start.

-