Reputation
239
Top tag
Next privilege 250 Rep.
View close votes
Badges
1 8
Newest
 Curious
Impact
~3k people reached

  • 0 posts edited
  • 0 helpful flags
  • 19 votes cast
Mar
29
comment Speeding up a differential equation system with nested modulo periodic events
Thx so much - this works perfectly for me, and it's so much faster and reliable!
Mar
29
accepted Speeding up a differential equation system with nested modulo periodic events
Mar
29
revised Speeding up a differential equation system with nested modulo periodic events
edited title
Mar
29
revised Speeding up a differential equation system with nested modulo periodic events
added 2468 characters in body
Mar
29
comment Speeding up a differential equation system with nested modulo periodic events
I was thinking doubleMod[t_, a_, b_] := MemberQ[Table[Mod[t - (i - 1) b, a] == 0, {i, Ceiling[a/b]}], True] should be able to fix things, but it doesn't - any thoughts why this event then doesn't get detected, because if you plot it the value of the condition over time it shows the right values? As in ListPlot[Table[{t, Boole[doubleMod[t, tg1 + ts1, tg1]]}, {t, 0, 20, 1/10}]] which is then identical to ListPlot[Table[{t, Boole[Mod[Mod[t, tg1 + ts1], tg1] == 0]}, {t, 0, 20, 1/10}]]
Mar
29
comment Speeding up a differential equation system with nested modulo periodic events
The issue apparently is something with the doubleMod function - e.g. Mod[Mod[1, tg1 + ts1], tg1] == 0 gives False, whereas doubleMod[1, tg1 + ts1, tg1] gives {False,False} - I tried changing the doubleMod function to doubleMod[t_, a_, b_] /; Mod[a, b] == 0 := Mod[t, b] == 0 doubleMod[t_, a_, b_] := Max[Boole[Table[Mod[t - (i - 1) b, a] == 0, {i, Ceiling[a/b]}]]] == 1 but no joy yet... Any thoughts?
Mar
29
comment Speeding up a differential equation system with nested modulo periodic events
So basically I have three main types of events here - I have regrowth after dilution (here at t=0, t=1, t=2, t=5, t=6 etc), treatments (here at t=3, t=7, etc) and regrowth after treatment and dilution (here at t=4 and t=8) and the lags are different after dilution vs after treatment. Would it help by any chance to put the time values of these events in a list first, and then checking if t is a member of any of these lists to check event locations?
Mar
29
comment Speeding up a differential equation system with nested modulo periodic events
Thanks millions for this! I notice there must still be a slight mistake though, as the graph, with identical parameters, is not exactly the same - in my example I have short delay nlagdil followed by exponential increase at rate nr and 10^6 fold dilution, repeated 3 times, followed by treatment and exponential decay at rate nm and 100 fold dilution, followed by long delay nlagtreat and exponential growth at rate nlagdil, and then repeated. In your code, the mortality doesn't seem to go on for long enough and the long delay nlagtreat is missing. (Btw my actual eqn are a system of diff eqns)
Mar
28
asked Speeding up a differential equation system with nested modulo periodic events
Dec
9
revised Mathematica 10 issue: working with Entities slows down recurrence equations
edited title
Dec
9
revised Mathematica 10 issue: working with Entities slows down recurrence equations
edited title
Dec
9
accepted Mathematica 10 issue: working with Entities slows down recurrence equations
Dec
9
comment Mathematica 10 issue: working with Entities slows down recurrence equations
Thx millions for this - that works great!! I also added names = cities[[All, 1]]
Dec
9
comment Mathematica 10 issue: working with Entities slows down recurrence equations
Many thanks - SetSystemOptions["DataOptions" -> "ReturnQuantities" -> False] indeed seems to solve the issue using a global option. How would I have to use EntityValue to get names = CityData[{All, country}]; citypop = Table[CityData[names[[i]], "Population"], {i, 1, Length[names]}]; citycoords = Table[CityData[names[[i]], "Coordinates"], {i, 1, Length[names]}]; working though without setting global options?
Dec
9
revised Mathematica 10 issue: working with Entities slows down recurrence equations
edited title
Dec
9
asked Mathematica 10 issue: working with Entities slows down recurrence equations
Dec
3
comment Maximising solutions of NDSolve
Many thanks for this - really useful that - didn't know about that syntax to suppress symbolic evaluation - great, thx millions!
Dec
3
accepted Maximising solutions of NDSolve
Dec
3
revised Maximising solutions of NDSolve
added 412 characters in body
Dec
3
revised Maximising solutions of NDSolve
deleted 31 characters in body