It was said in a comment that I should recude integration tolerance to eps. https://scicomp.stackexchange.com/questions/18929/what-does-this-matlab-error-message-mean I read the manual and I still don't know how to do it. Can you please tell me how to reduce integration tolerance in matlab?
The error message
Warning: Failure at t=3.974486e+03. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (7.275958e-12) at time t.
usually means that your error tolerances are too tight.
In brief, variable time-step integrators will adapt the time step based on weighted norm that more or less computes the ratio of the supplied error tolerances to the current local error estimate. Roughly speaking, if the error tolerances are smaller, the next time step will be smaller; if the error tolerances are larger, the next time step will be larger. There is usually a minimum time step size for integration, so what you are seeing is that the outcome of the error test is to shrink the time step, but the time step is already at its minimum value, so it cannot be decreased any more.
If looser error tolerances do not yield a reasonable solution, it usually suggests one of the following possibilities:
- you're using the wrong integration method; this usually happens with stiff solvers, in which case, you should consider using an implicit, stiff ODE solver
- your system is poorly behaved (the right-hand side might not be Lipschitz, for instance); in that case, you need to consider changing the model you're solving
- you introduced some sort of accidental bug in your right-hand side; in that case, you need to test your code and fix that bug
Choose the type of tolerance you want to set (
odeset() to define the options for your ODE solver, call the ODE solver and pass the desired options. For example:
options = odeset('RelTol',eps); [T,Y] = ode45(odefun,tspan,y0,options);
There is extensive documentation about these functions that can be accessed by entering
doc odeset or
doc ode45 in MATLAB's command prompt.