Why do I receive a warning about integration tolerance when using the ODE solver functions?
22 views (last 30 days)
Show older comments
MathWorks Support Team
on 22 Jan 2010
Edited: MathWorks Support Team
on 19 Feb 2021
The following code:
ode23(@(t,y)1/(t-2),[0 2],5)
produces this warning:
ERROR: Warning: Failure at t=2.000000e+000.
Unable to meet integration tolerances without reducing the
step size below the smallest value allowed (7.105427e-015) at time t.
Accepted Answer
MathWorks Support Team
on 19 Feb 2021
Edited: MathWorks Support Team
on 19 Feb 2021
This error message indicates that the problem you are trying to solve is too stiff for the ODE solver you are trying to use, or that it includes a singularity.
In the first case, you will need to find a solver which can handle stiffer problems than the solver you are currently using. The stiff ODE solvers that are available in MATLAB are ODE15s, ODE23s, and ODE23tb.
For more information about the differences between the non-stiff and the stiff ODE solvers, please see Section 7.9 of "Numerical Computing with MATLAB". by Cleve Moler, at the following URL:
In the second case, eliminating the singularity from the region over which you are attempting to integrate should eliminate the problem. The following code produces a warning:
ode15s(@(t,y)1/(t-2),[0 2],5)
Changing the above code to:
ode15s(@(t,y)1/(t-2),[0 1.999],5)
%
avoids the singularity at t = 2.
If you are using a version of MATLAB prior to MATLAB 7.0 (R14), you will need to define the function to be integrated as an inline function or in a function file. Here an inline function is used:
O=inline('1/(t-2)','t','y')
ode15s(O,[0 1.999],5)
0 Comments
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!