ODE problem : Unable to meet integration tolerances
15 views (last 30 days)
Show older comments
Hello,
I'm trying to solve a differential non linear equation with very high values (each constant is like 10^-20 or 10^20 or even more). And i got problems of tolerances. I've tried that :
options=odeset('RelTol',1e-30,'AbsTol',1e-30)
xvalues=30:200;
[x,y]=ode45('fun',xvalues,1, options)
Where the function is, as i told you, with very big values (for example, a term with exp(x)...)
""Warning: RelTol has been increased to
2.22045e-14.
Warning: Failure at t=3.000000e+01. Unable
to meet integration tolerances without
reducing the step size below the smallest
value allowed (1.136868e-13) at time t. ""
If you have any idea, help me !!!
Thank you
Fred
2 Comments
Walter Roberson
on 15 May 2015
Could I ask you to show your ODE in symbolic form? I have not done much work with transforming back from ode45 calls into formulae and I suspect I got it wrong when I did.
Could you confirm your boundary condition is that the derivative evaluated at the initial coordinate, xvalues(1), 35, should be 1? The documentation is not explicit about the fact that the initial (t,y) will have t be the first time and y be the initial condition, but my tests confirm it in practice. (An alternative reading would be that the initial values should be for an implicit time of 0, which would seem less practical, but I wanted to be sure I got the theory right.)
Accepted Answer
Star Strider
on 15 May 2015
I would increase the tolerance (to perhaps 1E-8 or more) rather than decrease it, but that may not solve your problem.
The warning is that at t=30, your ODE is most likely encountering a singularity. First, plot it to see what it is doing, then start it again at some value greater than t=30 (perhaps t=35) and see what it does, then experiment further to get the result you want. You may have to do a piecewise integration. That may not work in the end (you may not be able to integrate it beyond t=30 regardless), but unless you experiment with it, you will never know.
6 Comments
Walter Roberson
on 15 May 2015
Star Strider, note you ran the ode from time 0 rather than from time 35, but you did not change the initial condition from being 1.
More Answers (2)
Walter Roberson
on 15 May 2015
You can never get a relative tolerance of 1E-30 with double precision floating point numbers. The absolute least relative tolerance that could make sense is eps(1) = 2.22044604925031e-16 as that represents the relative difference between adjacent double precision floating point numbers.
An absolute tolerance of 1E-30 might make sense in some situations, but only when the values being computed are in the range of roughly 1E-18 to 1E-24.
If you have large values such as 1E+20 in your calculation, to get down below 1E+4 (eps(1) times the large value) you need to be dividing by large values or you need to be hoping for extreme cancellation of values.
I think you need to be re-thinking your tolerances.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!