'InitialStep' and 'MaxStep' in ode45

John B. Thoo jthoo at yccd.edu
Sat Jul 25 01:59:08 CDT 2009


Hi, everyone.  I have a question about 'InitialStep' and 'MaxStep' in  
ode45.

I tried to solve an equation using

     [T, u] = ode45 (@F, [t0 tf], [u0, u0_t]);

and this is what I got:

octave-3.2.0:4> run_twoway
warning: Option "RelTol" not set, new value 0.000001 is used
warning: Option "AbsTol" not set, new value 0.000001 is used
warning: Option "InitialStep" not set, new value 1.200000 is used
warning: Option "MaxStep" not set, new value 1.200000 is used
error: Solving has not been successful. The iterative integration  
loop exited at time t = 5.818179 before endpoint at tend = 12.000000  
was reached. This may happen if the stepsize grows smaller than  
defined in vminstepsize. Try to reduce the value of "InitialStep" and/ 
or "MaxStep" with the command "odeset".
octave-3.2.0:4>

So I halved tend and set 'InitialStep' and 'MaxStep' as follows:

     options = odeset ('InitialStep', 1.0e-3, 'MaxStep', 1.0e-3, ...
                       'RelTol', 1.0e-6, 'AbsTol', 1.0e-6);
     [T, u] = ode45 (@F, [t0 tf], [u0, u0_t], options);

This time I got:

octave-3.2.0:4> run_twoway
error: Solving has not been successful. The iterative integration  
loop exited at time t = 5.553544 before endpoint at tend = 6.000000  
was reached. This may happen if the stepsize grows smaller than  
defined in vminstepsize. Try to reduce the value of "InitialStep" and/ 
or "MaxStep" with the command "odeset".
octave-3.2.0:4>


My question is this:

   If the first time 'InitialStep' and 'MaxStep' were set at 1.2  
resulted in ode45 exiting prematurely at time t = 5.818179, then why  
does decreasing 'InitialStep' and 'MaxStep' result in the solver  
exiting prematurely at a *shorter* time t = 5.553544?

Another question:

   How should I choose to set 'InitialStep' and 'MaxStep'?  And  
should they always be set to the same value?

Thanks.

---John.


More information about the Help-octave mailing list