0
$\begingroup$

The following code was working fine -- now it produces errors. I originally built this in ver 13.1 and I'm now running ver 14. I think I'm getting machine precision errors after k=11 that were not previously a problem. Any recommendations are welcomed.

> ClearSystemCache[]
>         Clear["Global`*"]
>         NN = 20; a = 1.1; b = 0.05; c = 0.2; R0 = 4; U0 = 5;
>         sol = RSolve[{R[k + 1] == (a - b*(1 - c))*R[k] + (b*c)*U[k], 
>            U[k + 1] == b*(1 - c)*R[k] + (a - b*c)*U[k], R[0] == R0, 
>            U[0] == U0}, {R[k], U[k]}, k]
>         TableForm[Table[{k, R[k] /. %[[1]], U[k] /. %[[1]]}, {k, 0, NN}], 
>          TableHeadings -> {{}, {"k", "R[k]", "U[k]"}}]
>         DiscretePlot[{R[k] /. sol[[1]], U[k] /. sol[[1]]}, {k, 0, NN}, 
>          Ticks -> {Automatic, Automatic}, PlotStyle -> {PointSize[0.021]}, 
>          PlotRange -> All, AxesOrigin -> {0, 0}, 
>          BaseStyle -> {FontWeight -> "Bold", FontSize -> 12}, 
>          LabelStyle -> (FontFamily -> "Ariel")]
>         ListPlot[Table[{k, U[k] /. sol[[1]]}, {k, 0, NN}], PlotRange -> All, 
>          PlotStyle -> {Hue[1], PointSize[0.021]}]
$\endgroup$
3
  • 3
    $\begingroup$ Use exact numbers instead of decimals for your givens and it works fine. $\endgroup$
    – Bill Watts
    Commented Jul 6 at 20:13
  • $\begingroup$ very nice!! ... thanks you Bill! $\endgroup$
    – user42700
    Commented Jul 6 at 22:19
  • 1
    $\begingroup$ Those > in front of every line mean it is inconvenient to copy-paste your code to try out. Code is already formatted. There's no need for them. $\endgroup$
    – Goofy
    Commented Jul 7 at 4:11

0