This question is part of an assignment in numerical methods class. I am supposed to find the position and velocity of a spaceship flying around the Earth and Moon. I am given initial values of the position and speed, and functions that describe the acceleration of the spaceship, so this can be solved using the Runge-Kutta methods.
Description
The position of the spaceship can be described as $(x(t), y(t))$ for any time point $t$. Similarly, the velocity is $(x'(t), y'(t))$ — so you can see, the spaceship moves in two-dimensional space. Its acceleration is described by the following system of differential equations
$x'' = f(x, y, x', y')$
$y'' = g(x, y, x', y')$
(From now on I'll use the notations $u = x'$ and $w= y'$.)
I am also given the initial values $x_0, y_0, u_0, w_0$.
Final approximation of position
In the RK4 method, you calculate four intermediate approximations, $k_1, k_2, k_3, k_4$; the final approximation will be given by a weighted average of these intermediate approximations:
$$u_{i+1} = u_i + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4)$$
Assuming I already calculated the intermediate approximations (I'll get to that), the speeds $u$ and $w$ are simply calculated using the above method. How about the positions, though? I don't have functions that describe the speed ($f$ and $g$ describe the acceleration). It is correct for me to say the following?
$x_{i+1} = x_i + u_i \cdot \Delta t$
$y_{i+1} = y_i + w_i \cdot \Delta t$
Intermediate approximations of position
Given that I need to approximate four things ($x, y, u, w$), I will need four different sets of intermediate approximations; the first one ($k_1$) would be $k_{1x}, k_{1y}, k_{1u}, k_{1w}$.
The intermediate approximations for the speed are easy to calculate (because I know the accelerations $f$ and $g$). However, for calculating $k_{1x}$ and $k_{1y}$, I don't know how the approximations should be done. This is what I tried, but it did not work properly (over time, the spaceship would get very far away from the Moon and Earth when it shouldn't have):
$k_{1x} = \Delta t \cdot u_i$
$k_{1y} = \Delta t \cdot w_i$
What would be a better way to calculate the intermediate and final approximations of the position?