# How to solve this error? Error:"Nonlinear iteration is not converging with step size reduced to hmin (9.59393e-15) at time 2.70045. Try reducing the minimum step size and/or relax the relative error tolerance."

272 views (last 30 days)
yash agarwal on 26 Feb 2021
Commented: Walter Roberson on 21 Nov 2021
How to solve this error?
Error:"Nonlinear iteration is not converging with step size reduced to hmin (9.59393e-15) at time 2.70045. Try reducing the minimum step size and/or relax the relative error tolerance."
i have already tried and reduced the minimum step size and incresedRelaxed the tolerance and still the error persists for ode15s solver.

Swetha Polemoni on 1 Mar 2021
Hi,
This may occur when one of your signals is either diverging to +infinity or -infinity or changing too rapidly based on solver settings
##### 2 CommentsShowHide 1 older comment
Walter Roberson on 21 Nov 2021
NO, there is no other way to rectify that error. There are only a small number of possibilities:
1. The system and its first 2 derivatives are continuous over the entire domain of integration, and there are no numeric problems -- in which case the problem just doesn't happen
2. The system and its first 2 derivatives are theoretically continuous over the entire domain of integration, but there are numeric issues, such as if you had (x-1)^2/(x-1) and x needs to pass through 1, then in theory this is continuous but if you are not careful in how you write the code then you get a division by 0 -- in which case the code needs to be written more carefully to avoid the numeric problems
3. If the system is piecewise continuous, and there is well-defined behaviour at the discontinuities, and the discontinuities are at predictable times -- in which case you need to carefully control the tspan of each call so that each call is within a continuous section, and then when the call returns, adjust the system from outside the ode* funciton and restart from the time boundary. For example a system that has an injection of drug or energy at periodic intervals
4. If the system is piecewise continuous, and there is well-defined behaviour at the discontinuities -- in which case you need to write event functions to terminate the ode*() call, adjust the system from outside of the ode* function, and restart from the event boundary; for example a bouncing ball
5. In all other cases, the system is not suitable for use with the variable-step ode* functions.
In particular, the ode functions are not suitable if the code uses randomness. They are also not suitable in most cases where the code has if statements or interp*() calls with default interpolation methods. (There are some cases in which it is safe to use if or interp1(), if you know what you are doing.)