0
$\begingroup$

I want to evaluate a system of simple recursive equations using ReccurenceTable but for a reason that escapes me, I am not able to get it to work. Here is the input.

Clear[c0, s0, m, w, \[Eta],y, c, s, t, simul2]
c0 = 25;
s0 = 20;
m = .75;
w = .3;
\[Eta] = .2;
simul2 = RecurrenceTable[{y[t] == (c[t - 1] + \[Eta]*(c[t - 1] - c[t - 2]))*(1 + w) + s0 - s[t - 1], s[t] == s0 + (c[t - 1] + \[Eta]*(c[t - 1] - c[t - 2]))*(1 + w) - c[t], c[t] == c0 + m*y[t], y[0] == 105, y[1] == 105, c[0] == 103.75, c[1] == 103.75, s[0] == 50, s[1] == 50}, {y, s, c}, {t,2,20}]

The only output I get following this is simply the input itself. I don't understand why I don't get a list out of this input, as I have already done it with similar equations and had no problem at all. I tweaked the parameters for over an hour for it to work and had absolutely no luck.

$\endgroup$
1
$\begingroup$
Clear[c0, s0, m, w, η, y, c, s, t, simul2]
c0 = 25;
s0 = 20;
m = 3/4;
w = 3/10;
η = 1/5;

Using RSolve

soln = RSolve[{y[t] == (c[t - 1] + η*(c[t - 1] - c[t - 2]))*(1 + w) + 
       s0 - s[t - 1], 
     s[t] == s0 + (c[t - 1] + η*(c[t - 1] - c[t - 2]))*(1 + w) - c[t], 
     c[t] == c0 + m*y[t], y[0] == 105, y[1] == 105, c[0] == 415/4, 
     c[1] == 415/4, s[0] == 50, s[1] == 50},
    {y[t], s[t], c[t]}, t] // Simplify[#, t >= 0] &;

EDIT: Using ComplexExpand to obtain an explicitly real form

solnN = soln[[1]] // N // ComplexExpand // Simplify // Chop

(*  {c[t] -> 100. + 1.41231 0.187461^t + 2.33769 1.01991^t Cos[0.556027 t] + 
   2.71244 1.01991^t Sin[0.556027 t], 
 s[t] -> 50. - 0.108611 0.187461^t - 1.14139 1.01991^t Cos[0.556027 t] + 
   1.87454 1.01991^
    t Sin[0.556027 t] + (1.71832 + 0.00970207 0.187461^t - 
      0.478024 1.01991^t Cos[0.556027 t] + 
      0.235722 1.01991^t Sin[0.556027 t]) UnitStep[-1. t], 
 y[t] -> 100. + 1.88307 0.187461^t + 3.11693 1.01991^t Cos[0.556027 t] + 
   3.61659 1.01991^t Sin[0.556027 t]}  *)

Given the complexity of the solution it is likely that RecurrenceTable is timing out before arriving at a solution.

Table[{t, y[t], s[t], c[t]} /. solnN, {t, 0, 20}] // 
  Prepend[#, {"t", "y[t]", "s[t]", "c[t]"}] & // Grid[#, Frame -> All] &

enter image description here

$\endgroup$
  • $\begingroup$ I made a mistake in the question, I wrote y[1] == 105, y[2] == 105 instead of y[0]==105, y[1]==105. With this correction, the output for what you wrote is: {y[2] == 104.875, s[2] == 154.875 - c[2], c[2] == 25 + 0.75 y[2]}. However, even with this correction, the ReccurenceTable still doesn't work. $\endgroup$ – EBassal Sep 22 '17 at 20:05
  • $\begingroup$ So from what I understand, RecurrenceTable is to be used only when the system of difference equations is relatively simple? $\endgroup$ – EBassal Sep 22 '17 at 21:46

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.