Is there any method to deal with this problem? I am using Mathematica to solve the differential equations, but the calculating time is so long because of the large domain $x\in[0,10^{6})$. In fact I don't need the valves of y at x=0,0.01,0.02,0.03....I just need the values at x=0,1000,2000... or even less dilute. But to get the value at x=1000, the program must go through x=0.01,0.02...this the reason why it cost so much time. I am wondering whether this a clever method could facilitate this process (like, the computer doesn't need to store the values at x=0.01,0.02..., but just use these numbers as a bridge to calculate the following points).

Thanks a lot!

  • 4
    $\begingroup$ Your question is really unclear without an MCVE. Mature ODE solvers (such as those in Mathematica) use reasonable adaptive timestep choices, so your description of the problem's cause is likely wrong. It would help if you posted the equation you're trying to solve and your code. $\endgroup$
    – Kirill
    Commented Oct 16, 2016 at 23:21
  • $\begingroup$ @user22013 can you try doing the simulation with an implicit method and just increase the stepsize? What information are you trying to capture from this simulation over such a large timeframe? $\endgroup$
    – spektr
    Commented Oct 17, 2016 at 23:54
  • $\begingroup$ There's no way to answer this question without more information (particularly, whether the problem is actually stiff). But using a stiff solver will most likely alleviate the issue you describe. $\endgroup$ Commented Oct 18, 2016 at 5:12

2 Answers 2


Actuallly you can scale the variable of the problem into a different interval. Transform $ x \in [0,a]$ where ($a=10^6$) to $\xi \in [0,1]$ by the formula $ \xi = \frac{x}{a} $.

Thus, using the chain rule we have $\frac{d y }{ d x } = \frac{d y}{ d \xi } \frac{d \xi }{ d x } = \frac{ 1}{ a } \frac{d y}{ d \xi } $. Hence, replacing $\frac{d y }{ d x }$ by $\frac{ 1}{ a } \frac{d y}{ d \xi } $ in your equation, you can solve a new prolem of $y = y(\xi)$ in a shorter duration, say $[0,1]$.

  • $\begingroup$ Thanks. I have tried this method, but it doesn't work, because as we shorten the domain range by changing the variable, the stepsize adopted by the program also becomes very small. As a result, the total steps needed remain the same. $\endgroup$
    – user22013
    Commented Oct 17, 2016 at 22:33
  • 1
    $\begingroup$ why don't you post your problem right here? so that we can analyze its stability with respect to step size. If you have to work with such small step size, then i guess, you probably are working with an explicit scheme, which mostly requires stability condition. If so, you may need to switch to an implicit scheme. $\endgroup$
    – tqviet
    Commented Oct 18, 2016 at 15:35

@tqviet already says this in a some way, but let me phrase it differently: $10^6$ is not a large end time by itself. It seems like a large number because it has 6 zeros at the end, but it all depends on (i) which units you compute it, (ii) how fast the effects are that you are trying to model.

To give examples: If I told you that you had to compute to $10^6$ picoseconds, you would probably not think of that as a long time -- it is, after all, just $10^{-6}$ seconds. But what really matters is how long that is in relation to the things you try to describe. Even $10^6$ years is not very much if you try to simulate the evolution of a galaxy -- these things happen on time scales of billions of years, so $10^6$ could probably be done in one or just a few time steps. On the other hand, if you try to simulate the weather -- which works on time scales of hours -- then $10^6$ years clearly is a very very long time. Indeed, if your goal were to simulate the motion of electrons in semiconductors -- which works on time scales of nanoseconds or even less -- then $10^6$ years is an even longer time interval. In other words, it really depends on what you are looking at.

This leads to the last observation: You are using time steps of size $0.01$. But why? Because you think that time steps need to be small (so significantly smaller than 1, in whatever unit you are using), or because the dynamics of your system happen on time scales of 0.01 time units? In the latter case, the choice is clearly valid. But if the dynamics of your system happen on time scales of ~100 or ~1000 or even more time units, then there is no need for such small time steps: you should be able to use $\Delta t=10, 100$, or even more. In that case, you will be at your end time very quickly indeed.

  • $\begingroup$ Thanks for your explanation. In fact I am calculating a damping oscillation system. The damping term of the equation is very small, so only after t=10^6 s, can the damping effect becomes evident. But the oscillating is so fast, the period is about 1s, so the step size cannot be very small in order to calculate the ODE correctly. So the dynamics of the system happen in a short time scale. $\endgroup$
    – user22013
    Commented Oct 17, 2016 at 22:37
  • $\begingroup$ I think you need a high order accurate implicit method that allows large time steps while not losing accuracy. Have you looked at DG in time methods ? See e.g., arxiv.org/abs/1610.01324 $\endgroup$
    – cfdlab
    Commented Oct 18, 2016 at 3:20
  • $\begingroup$ Thanks. But, mathematically speaking, $10^6$ or $10^9$ make no sense to me. What I mentioned is to answer the question exactly, however, scaling the problem from a large range to the unit range is also a good way to control the game, e.g. bringing the $a=10^6$ into the equation, we can analyze the stability w.r.t the step size and the $a$. It is just the first step before we touch the goal ;) $\endgroup$
    – tqviet
    Commented Oct 18, 2016 at 15:49
  • 3
    $\begingroup$ If you need to resolve $O(10^6)$ oscillations, then you will need $O(10^6)$ time steps. This is independent of (i) how you scale time, (ii) what integrator you choose. It's just going to take a long time -- there is nothing you can do about that. $\endgroup$ Commented Oct 18, 2016 at 16:17

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.