3
$\begingroup$

I have the following system which I model as difference equations and solve with RecurrenceTable:

sol = RecurrenceTable[{
   x1[n + 1] == 1/3 x2[n] + 1/3 x3[n] + 1/3 x4[n],
   x2[n + 1] == 1/3 x1[n] + 1/3 x3[n] + 1/3 x4[n],
   x3[n + 1] == 1/3 x1[n] + 1/3 x2[n] + 1/3 x4[n],
   x4[n + 1] == 1/3 x1[n] + 1/3 x2[n] + 1/3 x3[n], x1[0] == 0.1, 
   x2[0] == 1, x3[0] == 1, x4[0] == 1}, {x1, x2, x3, x4}, {n, 0, 20}]

and which converges to some value as expected given that the Matrix M of coefficients has a spectral radius of <=1:

M = {{0, 1/3, 1/3, 1/3}, {1/3, 0, 1/3, 1/3}, {1/3, 1/3, 0, 1/3}, {1/3,
     1/3, 1/3, 0}};
Eigensystem@M

Now I use NDSolve for the same system:

sol = NDSolve[{
   x1'[n] == 1/3 x2[n] + 1/3 x3[n] + 1/3 x4[n],
   x2'[n] == 1/3 x1[n] + 1/3 x3[n] + 1/3 x4[n],
   x3'[n] == 1/3 x1[n] + 1/3 x2[n] + 1/3 x4[n],
   x4'[n] == 1/3 x1[n] + 1/3 x2[n] + 1/3 x3[n], x1[0] == 0.1, 
   x2[0] == 1, x3[0] == 1, x4[0] == 1}, {x1, x2, x3, x4}, {n, 0, 20}]

and the solutions go to infinity. However the Matrix did not change and I would have expected that the system also converges.

Can somebody explain to me how these differences arise (or what I'm doing wrong)?

$\endgroup$
2
  • 2
    $\begingroup$ The solutions differ because they're different systems. Of course the first is discrete-time and the second is continuous-time. However the biggest difference is that x1'[n] is discretized as (x1[n+1]-x1[n])/dn where dn is the step-size (1). So to make them more comparable, you need to subtract x[n] from the right-hand side of the differential equations. In this case, they match in long-term behavior. $\endgroup$
    – Chris K
    Commented Mar 23, 2022 at 15:24
  • $\begingroup$ Thanks, that makes sense. $\endgroup$
    – holistic
    Commented Mar 23, 2022 at 19:53

1 Answer 1

6
$\begingroup$

The discrete-time system can be approximated with a continuous-time system using ToContinuousTimeModel to produce approximate results.

ssmd = StateSpaceModel[{M, Table[{0}, 4]}, SamplingPeriod -> 1];
OutputResponse[{%, {0.1, 1, 1, 1}}, Table[0, 20]];
pd = ListLinePlot[%, DataRange -> {0, 20}, PlotRange -> All, 
   PlotMarkers -> Automatic];

ssmc = ToContinuousTimeModel[ssmd, Method -> "ForwardRectangularRule"];
OutputResponse[{%, {0.1, 1, 1, 1}}, 0, {t, 0, 20}];
pc = Plot[%, {t, 0, 20}, PlotRange -> All, PlotStyle -> Dashed]

Show[pd, pc]

The dashed response of the approximated system and the original system. enter image description here

The approximated matrix of the continuous-time system is different

Normal[ssmc][[1]]

$$\left( \begin{array}{cccc} -1 & \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\ \frac{1}{3} & -1 & \frac{1}{3} & \frac{1}{3} \\ \frac{1}{3} & \frac{1}{3} & -1 & \frac{1}{3} \\ \frac{1}{3} & \frac{1}{3} & \frac{1}{3} & -1 \\ \end{array} \right)$$

and will have a different eigensystem.

(OutputResponse is essentially using RecurrenceTable and NDSolve under the hood.)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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