I have an ODE system that increases in size according to the rules
n = 5;
T = 50;
nu = 0.05;
vars = Table[Subscript[x, j][t], {i, n}, {j, i}];
eqns = Table[{Subscript[x, j]'[t] ==
Subscript[x, j][
t] (1 - Subscript[x, j][t] -
nu (Sum[ Subscript[x, k][t] Boole[k != j], {k, i}]) ),
Subscript[x, j][0] ==
If[j == 1 && i == 1, 0.7,
If[j == i,
0.01 Subscript[x, RandomInteger[{1, j - 1}]][t] /. t -> T,
Subscript[x, j][t] /. t -> T]]}, {i, n}, {j, i}]
I want solve the differential equation of n variables, with initial conditions defined using the previous differential equation solution of n-1 variables and with an initial condition for the last variable (which randomly depends on one of the previous variables).
I'm having trouble building the initial conditions, present in the code above
Subscript[x, j][0] ==
If[j == 1 && i == 1, 0.7,
If[j == i,
0.01 Subscript[x, RandomInteger[{1, j - 1}]][t] /. t -> T,
Subscript[x, j][t] /. t -> T]]
Where the first initial condition {x1[0]=0.7}
The next {x1[0]=x1[Last time in j past],x2[0]=[Last time in j past]}
. . .
{{x1[0]=[Last time in j past],x2[0]=x2[Last time in j past],x3[0]==x3[Last time in j past],x4[0]=x4[Last time in j past],x5=0.01xSubscript[RandomInteger[1,j-1]][Last time in j past]}
can anybody help me?
n = 5; T = 50; nu = 0.05; vars = Table[Subscript[x, j][t], {i, n}, {j, i}]; eqns = Table[{Subscript[x, j]'[t] == Subscript[x, j][ t] (1 - Subscript[x, j][t] - nu (Sum[ Subscript[x, k][t] Boole[k != j], {k, i}]) ), Subscript[x, j][0] == If[j == 1 && i == 1, 0.7, If[j == i, 0.01 Subscript[x, RandomInteger[{1, j - 1}]][t] /. t -> T, Subscript[x, j][t] /. t -> T]]}, {i, n}, {j, i}] sol0 = Table[s = NDSolve[eqns[[l]], vars[[l]], {t, 0, T}], {l, n}]
I forgot to add the NDSOlve part $\endgroup$j=1 Subscript [x, 1] [0] = 0.7
. Forj = 2
, the initial conditionsSubscript [x, 1] [0] = Subscript [x, 1] [T], Subscript [x, 2] [0]= Subscript [x, 1] [T]
, WhereSubscript [x, 1] [T]
is the last value of the interpolation obtained atj = 1
. $\endgroup$