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)?
x1'[n]
is discretized as(x1[n+1]-x1[n])/dn
wheredn
is the step-size (1
). So to make them more comparable, you need to subtractx[n]
from the right-hand side of the differential equations. In this case, they match in long-term behavior. $\endgroup$