# Problem with using RSolve to solve recurrence equations

Whenever I run the my code, the output of Mathematica is only a copy of the input again.

RSolve[{x[1 + k] == (-(Cos[(k π)/2]/k!) + z[k])/(1 + k),
y[1 + k] == (1/k! + z[k])/(1 + k),
z[1 + k] == (x[k] - y[k])/(1 + k),
x[0] == x0, y[0] == y0, z[0] == z0}, {x[k], y[k], z[k]}, k]


I cannot find what I am doing wrong with my simple code.

• Your "simple code" is not so simple. Mathematica does not know how to solve it. – m_goldberg Nov 27 '16 at 17:29
• Do you perhaps know the solution? – Mirko Aveta Nov 27 '16 at 17:29
• @MirkoAveta, No,I do not have the solution. – Sima Nov 27 '16 at 17:41
• Please. Can you clarify if you mean 1/k! Or (1/k)! ? Also try substitution to grin the argument K alone (Against using 1+k in arguments – Jose Enrique Calderon Nov 27 '16 at 17:56
• @JoseECalderon ,Thank you. I have done it, the output is same as before – Sima Nov 27 '16 at 18:08

You can use the first two equations to get an algebraic equation for z[k]:

(* x[k+1] - y[k+1] then compare to third equation *)
zksol = Simplify[(-(Cos[(k π)/2]/k!) + z[k])/(1 + k) - (1/k! +
z[k])/(1 + k) /. k -> (k - 2), Assumptions -> {k ∈ Integers}]
(* -((2 Sin[(k π)/4]^2)/((-1 + k) (-2 + k)!)) *)


Then you can solve a smaller system

{xksol[k_], yksol[k_]} = {x[k], y[k]} /.
First@RSolve[{x[1 + k] == (-(Cos[(k π)/2]/k!) + zksol)/(1 + k),
y[1 + k] == (1/k! + zksol)/(1 + k)}, {x[k], y[k]}, k]
(* {(2 Cos[1/2 (-1 + k) π] (-3 + k)! -
k Cos[1/2 (-1 + k) π] (-3 + k)! - (-1 + k)! +
Cos[1/2 (-1 + k) π] (-1 + k)!)/((-2 k +
k^2) (-3 + k)! (-1 + k)!), (-2 (-3 + k)! +
k (-3 + k)! - (-1 + k)! +
Cos[1/2 (-1 + k) π] (-1 + k)!)/((-2 k +
k^2) (-3 + k)! (-1 + k)!)} *)


Check:

Simplify[{x[1 + k] == (-(Cos[(k π)/2]/k!) + z[k])/(1 + k),
y[1 + k] == (1/k! + z[k])/(1 + k)} /.
{x[p_] -> xksol[p], y[p_] -> yksol[p], z[k] -> zksol}]
(* {True, True} *)


Notice there is no freedom left for initial conditions.