How to use Runge–Kutta methods in a second order ODE Consider a second order equation $F=ma=m\ddot{x}$.
In the language of Euler's method

$\ddot{x}(t+dt)=F(t,x(t),\dot x(t))$
$\dot{x}(t+dt)=\dot x(t)+\ddot x(t)dt$
$x(t+dt)=x(t)+\dot x(t)dt$

Basically, the entire iteration was the second order force equation $F(t,x(t),\dot x(t))$.
However, here one wanted to apply Runge–Kutta method(standard &quot;RK4&quot;, not Runge–Kutta–Nyström or else) to solve that equation.
For notation simplicity, let $v\sim \dot x$, $a\sim \ddot x$(velocity and acceleration).
From $x(t),v(t),a(t)$:
$ka1=F(t,x(t),\dot x(t))$; $kv1=v(t)+a(t)\frac{dt}{2}$; $kx1=x(t)+v(t)\frac{dt}{2}$;
$ka2=F(t+\frac{dt}{2},kx1, kv1)$; $kv2=kv1+ka1\cdot \frac{dt}{2}$; $kx2=kx1+kv1\cdot \frac{dt}{2}$;
$ka3=F(t+\frac{dt}{2},kx2, kv2)$; $kv3=kv2+ka2\cdot dt$; $kx3=kx2+kv2\cdot dt$;
and finally
$ka4=F(t+dt,kx3, kv3)$;
The final acceleration was collected to be
Iteration Update Method 01
$\ddot x(t+dt)=(ka1+ka2\cdot 2+ka3\cdot 2+ka4)/6$; where
$\dot x(t+dt)=\dot x(t)+\ddot x(t)dt$;
$x(t+dt)=x(t)+\dot x(t)dt$
with such loop the iteration was able to run in RK4 method and things worked very nicely and coincided with the analytical calculation for an example which Euler method was known to fail.(Tested)
However, my question arise from a mistake where it made the code fail to work. It went like this:
In addition to the $\ddot x(t+dt)$ condition, one further to average the speed directly,
Iteration Update Method 02
$\ddot x(t+dt)=(ka1+ka2\cdot 2+ka3\cdot 2+ka4)/6$;
$\dot x(t+dt)=(\dot x(t)+kv1\cdot 2+kv2\cdot 2+kv3)/6$; and
$x(t+dt)=x(t)+\dot x(t)dt$;
Notice that the new update method attempted to use the $\dot x(t)$  to take care of the &quot;overflow&quot;. Intuitively, not only the acceleration $\ddot x$ was &quot;RK4&quot;-ed, but also, the velocity $\dot x$ was &quot;RK4&quot;-ed as well. However, thought still able to produce a sensible graph, the Iteration Update Method 02 was proven to have failed after the analysis.
Question 1: Why Iteration Update Method 01 worked? Even though it approximated $\frac{d^2y(t)}{dt}=f(t,y(t),\dot y(t))$ instead of $\frac{d y(t)}{dt}=f(t,y(t))$?
Question 2: Why Iteration Update Method 02 failed? Shouldn't it work better since it averaged more stuff?
I think there is a mistake in your post: the first equation should be $\ddot{x}(t) = F(t, \dot{x}(t), x(t))$ (and not $\ddot{x}(t + dt)$).
Also, in the computation of $kv_i$ and $kx_i$, it should be $kv_i = v(t) + ka_{i-1}\Delta t$ and $kx_i = x(t) + kv_i\Delta t$ (where $\Delta t = dt$ or $\frac{dt}{2}$). $kv_i$ does not use $kv_{i-1}$ (except in the computation of $ka_{i-1}$), and same thing for $kx_i$.
Question 1: in the differential equation $\ddot{x}(t) = F(t, \dot{x}(t), x(t))$, if you consider the vector $Y(t) = \begin{pmatrix}x(t)\\\dot{x}(t)\end{pmatrix}$, then you have $\dot{Y}(t) = \begin{pmatrix}\dot{x}(t)\\\ddot{x}(t)\end{pmatrix} = \begin{pmatrix}\dot{x}(t)\\F(t, \dot{x}(t), x(t))\end{pmatrix} = \tilde{F}(t, Y(t)) $. That explains why the method works (since the formulas will be the same as with a first order differential equation). Actually, the approximation should be better with the corrections I proposed.
Question 2: With your formulas, a bit of simplification gets you $v(t+dt) = v(t) + \frac{dt}{6}\left(5a(t) + 2ka_1 + 2ka_2\right)$ which is not coherent.
Even with the corrections I proposed, it is incorrect. My guess is that you should compute $x(t+dt)$ and $\dot{x}(t+dt)$ as a whole (as in the vector $Y(t)$) instead of trying to compute them one after the other. The system $\left\{\begin{array}{rcl}\dot{x}(t+dt) &amp;= &amp;\dot{x}(t) + \ddot{x}(t)dt\\ x(t+dt) &amp;=&amp;x(t) + \dot{x}(t)dt\end{array}\right.$ can be seen as $Y(t+dt) = Y(t) + \dot{Y}(t)dt$.