I have been working on a derivation that deals with 2 bodies of equal mass being attracted by an effect similar to gravity. I have gotten to a point of attempting to numerically evaluate parameters for curve fitting as a means of testing my solution against a known value. My solution is the curve resulting from modifications to the outputs of an $ RK4 $ approximation. Before i try fitting the curve i need to approximate the form this curve.
I found this which gives the answer to dt as a function of dr.
And i looked at the original source post.
However time is my independent variable and r is my dependent for an $ RK4 $ . Using $Gm_1m_2/r^2=F$ where $m_1=m_2$ results in $ 2Gm_1/r^2=a$ . I then substituted that into $r=_v0t +.5at^2$ where $v_0t=0$ because $v_0=0$. This gives me $ r=.5(2Gm_1/r^2)t^2$. And the first derivative for the purposes with respect to time for $ RK4$ is $dr/dt=2Gm_1t/r^2$. Thus my approximation should resemble $r^3=2Gm_1t^2$
The first substitution gives me math heebie jeebies as r is a function of both r and t but i can't see what is wrong with it. If i try to integrate a with respect to $t $ i get the "messy" eqn. So I am assuming my math heebie jeebies is correct. Unfortunately the full problem I am working is complex and pushing some math boundaries with both the programs and others understanding so I need an independent set of eyes to explain how I am screwing up.
You should not be using $r=v_0t+at^2/2$ as that applies only to constant acceleration and you do not have constant acceleration. It can be used as an approximation to the change in position over a small time interval $\delta t$ over which the acceleration is approximately constant to calculate the change in $r$ over that time interval. $$ v(t+\delta t)=v(t)+a\delta t \\ r(t+\delta t)= r(t)+v(t)\delta t + a(r(t)) \delta t^2/2 $$ This will allow you to numerically integrate the equations of motion with the corresponding formula for the change in velocity $v=v_0+at$. But this is essentially a slightly modified variant of Euler's method, not RK4.
You can perform the first step of the integration by observing that: $$ a=\frac{dv}{dt}=\frac{dv}{dr}\frac{dr}{dt}=v\frac{dv}{dr}=\frac{2Gm}{r^2} $$ which is an ODE of variables separable type and so can be integrated to give the relationship between $v$ and $r$.