I've generated a solution for a planet motion around the Sun (placed at the reference frame center). I wanted to test what would I get for the error of the method I'm using (Runge Kutta with 4 stages, with semimajor axis and Sun mass as distance and mass units, and time units evaluated in order to have $G=1$) by evaluating it with Richardson extrapolation, as described here, using specifically the perihelion of the orbit. I got this
What I actualy do is this (I'm using matlab)
p = 4
r_001 = radius(J_001,1);
r_002 = radius(J_002,1);
pers_001 = r_001(islocalmin(r_001));
pers_002 = r_002(islocalmin(r_002));
T_pers = (pers_002 - pers_001)./(2^(p+1) - 1);
figure;plot(1:length(T_pers),T_pers)
grid on
r_001
and r_002
are the position vector of the planet calculated with h/2
and h
respectively, with h
being the time-step used of $0.001$ and $0.002$. pers_001
and pers_002
takes the perihelion positions present in the two different position vectors. T_pers
is the truncation error for every perihelion and it is presented in the picture above. This result seems good to me if I look at the order of the error, but that "modulated spikes thing" is something I didn't expect, what could be the reason? I mean I suppose the method's code is not wrong, since the general oscillation in perihelion position is of order $10^{-7} A.U.$, as can be seen from the plot below
EDIT
@Lutz Lehmann, yes the equation I'm using is precisely what you wrote, there's just the Sun mass at numerator also, but it's very close to one anyway. Plus I'm considering three dimensions, so for instance I use $\ddot{\vec{r}} = M_{\odot}\vec{r}/\lvert r \rvert^3$. I tried to verify what would have happened by changing $h$, and I actually got this (truncation errors)
The last picture is the same as the one before for the truncatin error, but the subplot ruins the details a bit. It seems actually something related to the aliasing since the amplitude of the effect decrease with $h$. So for some reason I periodically have a "bad" approximation of the perihelion (in respect of the other estimations).