0
$\begingroup$

I try to solve the equation system as

p[n_] := Piecewise[{{a, Mod[n, 2] == 0}, {b, Mod[n, 2] == 1}}]

q[n_] := Piecewise[{{c,Mod[n,2]==0},{d,Mod[n,2]==1}}]

RSolve[
{x[n + 1] == (p[n] + y[n])/(p[n] + y[n - 2]), 
y[n + 1] == (q[n] + x[n])/(q[n] + x[n - 2]), x[-2] == A, x[-1] == B,
x[0] == H, y[-2] == J, y[-1] == M, y[0] == L}, {x[n], y[n]}, n
]

but I didn't achieve this. When I execute the process, RSolve can't solve the system. How can I deal with this? Thank you.

$\endgroup$
  • 1
    $\begingroup$ Not that it helps with your problem but I'd like to point out that you have used a few reserved keywords as variables in your code (E and D). In order to prevent conflicts you better refrain from using variables with an initial uppercase character. $\endgroup$ – Sjoerd C. de Vries Feb 4 '16 at 19:56
  • $\begingroup$ You're right. I have edited the expressions. Thank you... $\endgroup$ – drxy Feb 4 '16 at 20:01
  • $\begingroup$ What, precisely, are you seeking? This system of difference equations may not have a closed-form analytical solution, just as many differential equations do not. Nonetheless, they can be solved numerically. $\endgroup$ – bbgodfrey Feb 4 '16 at 22:29
3
$\begingroup$

Just to illustrate @bbgodfrey 's comment. If I have coded recursion correctly (noting NestList and many other refinements I have not done):

p[n_?EvenQ] := a
p[n_] := b
q[n_?EvenQ] := c
q[n_] := d
r[n_, {x__}, {y__}, {pq__}] := 
 Nest[{#[[2]], #[[3]], (p[#[[7]]] + #[[6]])/(p[#[[7]]] + #[[4]]),
     #[[5]], #[[6]],
     (q[#[[7]]] + #[[3]])/(q[#[[7]]] + #[[1]]),
     #[[7]] + 1} /. Thread[{a, b, c, d} -> {pq}] &,
  {x, y, 0}, n]
rc[n_, {x__}, {y__}, {pq__}] := r[n, {x}, {y}, {pq}][[{3, 6}]]

You can play:

Manipulate[
 ListPlot[Transpose@(rc[#, {x1, x2, x3}, {y1, y2, y3}, {m, s, u, 
        v}] & /@ Range[n]), Joined -> True, PlotRange -> All, 
  PlotLegends -> {"\!\(\*SubscriptBox[\(x\), \(n\)]\)", 
    "\!\(\*SubscriptBox[\(y\), \(n\)]\)"}],
 {n, {10, 20, 30}}, {x1, 1, 10}, {x2, 1, 10}, {x3, 1, 10}, {y1, 1, 
  10}, {y2, 1, 10}, {y3, 1, 10}, {m, 1, 10}, {s, 1, 10}, {u, 1, 
  10}, {v, 1, 10}]

enter image description here

Apologies for errors or misunderstanding.

$\endgroup$
  • $\begingroup$ Inspring from your code I have solved my problem. Thank you very much. $\endgroup$ – drxy Feb 9 '16 at 13:37
  • 1
    $\begingroup$ @drxy I am glad it was some help to you in achieving your goal :) $\endgroup$ – ubpdqn Feb 10 '16 at 4:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.