# How can I reduce integration tolerance in matlab?

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
• Thank you for the answer. I found that setting options = odeset('RelTol',2e+02); yields a solution but it does not look right. So I must check my calculations. – Niklas R. Mar 3 '15 at 23:25
• @Niklas: That's not surprising; it sets your relative tolerance to 200, while it should usually be a small positive number < 1. This will simply make the algorithm accept wildly inaccurate solutions. – cfh Mar 4 '15 at 12:30

Choose the type of tolerance you want to set (RelTol, AbsTol, or NormControl), use 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.