When we solve differential equation numerically using NDSolve then sometimes we get error like NDSolve::mxst: Maximum steps reached

According to Mathematica docs the solution is to increase MaxSteps. For example if you used MaxSteps -> 100 and limit of x 0 to 100 but Mathematica calculated up to the x=50 then increasing steps MaxSteps -> 200 will solve your problem.

My problem is what i got from mathematica is -

During evaluation of In[212]:= NDSolve::mxst: 
     Maximum number of 10000 steps reached 
     at the point x == 2.1685790754404513`*^-14.

So even if i want to got from limit 0 to 2 for x then my steps should be 10^14 times larger. It will take a huge huge computing time. How much it may take for core i3 processor? Is there any other way to compute quickly or solve this problem of maxsteps in any other way?


v[x_] := {v1[x], v2[x]} ;
ini = v[0] == {1, 0};  
soln = NDSolve[LogicalExpand[I v'[x] == H.v[x] && ini], {v1, v2}, {x, x1, x2}]

where H is matrix

  • $\begingroup$ Can you give the actual problem you're trying to solve? What you've mentioned isn't sufficient for us to help you. $\endgroup$ Jan 28, 2012 at 12:25
  • $\begingroup$ @J.M. Thanks. But actual problem is large. Other part of the problem is actually about the construction and taking Matrix H to its final form. without construction of H its just these tree lines of codes and plotting. Then... I need to send you the whole file you need see actual thing. $\endgroup$
    – Mush
    Jan 28, 2012 at 12:37
  • $\begingroup$ Then I suppose you could upload your Mathematica notebook to some file host like Sendspace or iFile. $\endgroup$ Jan 28, 2012 at 12:45
  • $\begingroup$ The largest eigenvalue of H is about 7.4*10^16 which would mean that you'll get a highly oscillatory solution with a wavelength of about 10^-16 so I guess you would need a step size < 10^-18 or so (and you would need to worry about PrecisionGoal and WorkingPrecision). $\endgroup$
    – Heike
    Jan 28, 2012 at 15:43

1 Answer 1


NDSolve uses adaptive methods to obtain a good solution. It dynamically changes the step size during integration.

I recommend you take a look at the Advanced Numerical Differential Equation Solving tutorial (ODE section), which has a very detailed description of how NDSolve work, what methods are available, and how you can tweak them.

You can start with

NDSolve[..., Method -> {"FixedStep", Method -> "ExplicitEuler"}, StartingStepSize ->  ... ]

to figure out what is going on (this will likely not give you a precise solution though). There's a good chance that your differential equation is very troublesome to solve, so automatic method selection will not work well. In this case you'll need to study the methods available, and make a suitable choice yourself.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.