## run control

The basics of how to develop, test, and use models.
ylzang
Posts: 27
Joined: Sun Mar 08, 2015 3:38 am

### run control

Code: Select all

``````dt = 0.2
tstop = 500
while (t<tstop) {
dt = 0.02
tstop = 700
while (t<tstop) {
count+=1``````
For the first period, when t< 500 ms, it was calculated at t = 0.2,0.4..., and finally 500. For the second period, in my simulation, it was calculated at 500.02, 500.04,... and finally 700.02. Why the the time point at 700.02 can be calculated? I think the last time point should be 700. Thanks.
ted
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: run control

Sounds like finite precision arithmetic and roundoff error. At a minimum read this:
viewtopic.php?f=8&t=1686&p=12613
ylzang
Posts: 27
Joined: Sun Mar 08, 2015 3:38 am

### Re: run control

ted wrote:Sounds like finite precision arithmetic and roundoff error. At a minimum read this:
viewtopic.php?f=8&t=1686&p=12613
just the roundoff error? the default value of float_epsilon is 1e-11. Do you mean I cannot control the last recorded data point to be at 700 ms? I understand the second last point may be like 699.999999... . It is still smaller than 700, so the next time point close to 700.02 will be calculated. I knew this before, just did not realise it may cause problems even setting the float_epsilon to be 1e-11.
ted
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: run control

Code: Select all

``````oc>x = 0
oc>for i=1,2500 x+=0.2
oc>x
500
oc>x-500
-1.9838353e-11
oc>x = 0
oc>for i=1,35000 x+=0.02
oc>x-700
-3.4663117e-10``````
Got it now?
ylzang
Posts: 27
Joined: Sun Mar 08, 2015 3:38 am

### Re: run control

ted wrote:

Code: Select all

``````oc>x = 0
oc>for i=1,2500 x+=0.2
oc>x
500
oc>x-500
-1.9838353e-11
oc>x = 0
oc>for i=1,35000 x+=0.02
oc>x-700
-3.4663117e-10``````
Got it now?
got it.