# Thread: Runge-Kutta method with different step length on different variables?

1. ## Runge-Kutta method with different step length on different variables?

Hi, is it possible to use a Runge-Kutta method (for example Euler's method to take one), and calculate more carefully depending on the behavior of a variable? For example, if one is to simulate a system of planets which attract each other according to the laws of physics, the calculations will have to be more carefully if there are two planets that are very close to each other, since every derivative will change more rapidly.

Now, I know that this can be solved using variable step length. However, calculating planets' orbits around each other in a computer program charges the processor heavily - calculating every planet's orbit more carefully by reducing the step length will slow down the whole process and make the program lag. In contrary, running the simulation with the same step length as before will really decrease the accuracy of the orbits of the two planets that are close to each other.

Ideally, only the orbits of the two planets that are close to each other would have to be calculated more carefully, maybe by reducing the step length for only those planets in, if it in some way is possible. Do you know of any way to do this, or if it the method is used in applications? Is there some other way to increase the accuracy when calculating the orbits for only those two planets? It's easy when all variables in a differential equation have the same step length. But when They get different step length, it gets more complicated...

2. Just off the top of my head...

The problem is precision. As soon as you make a large error, such as too big a step size, all your fine adjustments after that are meaningless.

In this case, too big a step size on where the planet is will have your planets close to each other when they should not be. Who cares about their joint close behavior when they should not even be there?

3. Maybe they actually should be there? Anyway, the system with planets was just an example. Consider gas molecules if you want. Or whatever else that consists of a number of elements where each one of the elements usually behaves quite peaceful but then once in a while behaves chaotically for a short period of time due to external conditions.

4. Fair enough. Why does it have to be one model? Why not drop into "close" behavior when you observe the chaos?

5. How would this "close" behaviour look? Would it make the simulation more accurate, or how would it improve the simulation?

6. Not sure. Just thinking out loud. It depends on exactly what your model is. I suppose it could be:

1) Gross behavior for basic movements when nothing is close to anything else and everything is behaving nicely.

2) Hold just about everything when something interesting happens, draw a much smaller sphere of influence, and barely track those things that are not directly interesting.

Really, without a much better description of what is going on, it's pretty tough to give any better direction.

7. I was just speaking in general terms; I have not planet to make a space simulator. Although I have actually made a particle simulator before, where every particle attracted every other particle, and where the force between two particles was inversely proportional to the distance in square.

What I want is a method that is applicable to all models and to all kind of differential equations that can be numerically solved using an explicit (a regular) Runge-Kutta method. Now I'm not sure if there is any general solution to the problem I introduced, but it would have been very handy if there was.