Consider that I am solving a second order ODE using RK2/RK4. The ODE represents simple equations of motion: Equations of motion I am trying to solve:
\begin{align} \frac{dx}{dt} &= v \\[.3em] m·\frac{dv}{dt}&= f_{p}(x)+f_{g}(x,v) \end{align}
Now along with $x$ and $v$, I also require to compute the $f_{p}(x)+f_{g}(x,v)$ at each time-step $h$. In such case what should I take velocity and position pair at that particular time-step? I ask this since RK4 generates multiple pairs of $x$ and $v$ at each time-step.
Method Runge Kutta $4^{th}$ order
Basic Formulae \begin{align} x^{'}&=x_{0}+ \frac{1}{6}(k_{0}+2k_{1}+2k_{2}+k_{3}) \\ v^{'}&=v_{0}+ \frac{1}{6}(l_{0}+2l_{1}+2l_{2}+l_{3}) \end{align}
Calculation of coefficients \begin{align} k_0 &= h v_0 \\ l_0 &= \frac {h (F_{p}(x_0) +F_g(x_0,v_0)) }{ m} \\[.5em] k_1 &= h (v_0+ \frac{l_0}{2}) \\ l_1 &= \frac {h (F_{p}(x_0 + \frac {k_0}{2}) +F_g(x_0 + \frac {k_0}{2}, v_0 + \frac {l_0}{2})) }{ m} \\[.5em] k_2 &= h (v_0+ \frac{ l_1}{2}) \\ l_2 &= \frac {h (F_{p}(x_0 + \frac {k_1}{2}) +F_g(x_0 + \frac {k_1}{2}, v_0 + \frac {l_1}{2})) }{ m} \\[.5em] k_3 &= h (v_0+ {l_2}) \\ l_3 &= \frac {h (F_{p}(x_0 + {k_2}) +F_g(x_0 + {k_2},v_0 + {l_2})) }{ m} \end{align}