NDSolve::ndsz NDSolveValue::ndsz ParametricNDSolve::ndsz ParametricNDSolveValue::ndsz

Details

  • This message is generated when the adaptive algorithm used by NDSolve requires a step size that is too small for numerically reliable calculations.
  • Off[message] switches off the message; On[message] switches it on. For example: Off[NDSolve::ndsz].

Examples

Basic Examples  (7)

The singularity at is obvious in the equation. You will not be able to numerically get past this point:

An error occurs because the solution is singular:

You can see that there might be potential problems with a singularity by putting the equation in normal form (solving for the highestorder derivative):

If ever becomes 2, then the denominator becomes 0, so you get an infinite first derivative. This is exactly what is happening. Close to the point indicated in the error message, approaches 2, so you get a divergence:

There is nothing you can do to numerically get past a singularity. However, if you pick a different initial condition, the function will remain below 2 throughout the entire range:

Here is a system with a singularity:

To identify where the singularity is, solve each equation for its highest-order derivative. There are no problems with the first equation. Nothing is in the denominator, so nothing should go to infinity:

Solving the second equation for shows that there will be a problem when goes to zero. This is what causes the singularity. Getting around this might be impossible. A different set of "StartingInitialConditions" might allow NDSolve to search in a region of parameter space where this denominator does not go to zero, but that would require a lot of guessing and checking and is not guaranteed to work:

Here there is no singularity because is not part of the region, but you are still getting the NDSolve::ndsz message:

Due to the very large range and the use of machine-precision numbers, this is caused by round-off errors or precision loss. Verify this by solving the equation at a higher precision. To do this, rationalize the equations and use the WorkingPrecision option:

Alternatively, you can try the Automatic method. This highlights an important point. It is often useful to remove any explicitly specified method and see how well the Automatic method works:

Verify that the increased precision solution and the Automatic method solution agree:

There is no singularity in this system, but you still get the NDSolve::ndsz message:

The problem is that the equation becomes extremely stiff. However, to make matters worse, "StiffnessSwitching" or using an increased WorkingPrecision does not help:

Since the conditions are specified on both ends of the boundary, this is a boundary value problem. Therefore, you can try using the shooting method. This does work. However, the solution is very dependent on the starting initial conditions:

One useful way to get around these situations is to use a fixed-step method combined with an implicit method. Implicit methods are used to get past stiff systems, while the fixed-step part prevents NDSolve from constantly reducing the step size, which is triggering the errors and aborts the calculation. However, this may come at the cost of reduced accuracy:

Here is a boundary value problem:

These can be solved with the finite element method, which is automatically chosen once boundary conditions are expressed in NeumannValue or DirichletCondition:

Here is a system of equations:

Using the shooting method helps: