This question is more about how to tackle a problem numerically.
In a small project I wanted to simulate the coorbital motion of Janus and Epimetheus. This is basically a three body problem. I choose Saturn to be fixed at the origin, let $r_1$ and $r_2$ be the location vectors of janus and epimetheus, respectively. Since the effect occurs when Janus and Epimetheus are very close together I picked relative coordinates for a better resolution, i.e. $r=r_1-r_2$ and $R=r_1+r_2$. Now I get the following equations of motion:
$$
\frac {d^2}{dt^2} \binom{R}{r} = - G (m_2\pm m_1) \frac R {R^3} - 4 M G \left(\frac {r+R}{(r+R)^3} \mp \frac {r-R}{(r-R)^3}\right )
$$
where $m_i$ corresponds to the masses of the moons, $M$ is the mass of Saturn and $G$ the gravitational constant. The problem arises when I try to solve this numerically. One has to deal with values of completely different magnitudes, i.e. $M \sim e^{28}$ and $m_i \sim e^{17}$. And $r$, $R$ are in the regions of 0 to 150 000.
To be honest I am not sure if this is the place forum to discuss such numerical problems.
More Information:
Code is written in Matlab and I use a standard ODE solver to obtain the result. However this is breaking down because the step size cannot be reduced under machine precision. (I find this not to be surprising because one has to deal with the already mentioned orders of magnitude).
This post has been migrated from (A51.SE)