Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

My ODE:

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

share|improve this question
    
Can you give the actual problem you're trying to solve? What you've mentioned isn't sufficient for us to help you. –  J. M. Jan 28 '12 at 12:25
    
@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. –  Mush Jan 28 '12 at 12:37
    
Then I suppose you could upload your Mathematica notebook to some file host like Sendspace or iFile. –  J. M. Jan 28 '12 at 12:45
    
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). –  Heike Jan 28 '12 at 15:43
    
Thank you @Heike –  Mush Jan 28 '12 at 16:24
add comment

1 Answer

up vote 6 down vote accepted

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.

share|improve this answer
    
Thank you. You are right –  Mush Jan 28 '12 at 16:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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