I defined a potential function as
$$ U(z) = |z| $$
this encodes a pressure field (or kind of). Assuming I have a particle of mass $m = 1$ I got the following motion equation
$$ \ddot{z} = -\frac{z}{|z|} $$
And I'm attempting solve this using Runge-Kutta. With such goal in mind I defined $y = \dot{z}$ And I got the following system
$$ \left\{ \begin{array}{l} \dot{y} = - \frac{z}{|z|} \\ \dot{z} = y \end{array} \right. \Rightarrow \dot{\begin{pmatrix} z \\ y\end{pmatrix}} = f(z,y) $$
My RK iteration would be set up as follows
\begin{equation} \begin{array}{l} \dot{\begin{pmatrix} k_{1,z} \\ k_{1,y}\end{pmatrix}} = \Delta t f(z_n,y_n) \\ \dot{\begin{pmatrix} k_{2,z} \\ k_{2,y}\end{pmatrix}} = \Delta t f(z_n+k_{1,z}/2,y_n+k_{1,y}/2) \\ \dot{\begin{pmatrix} k_{3,z} \\ k_{3,y}\end{pmatrix}} = \Delta t f(z_n+k_{2,z}/2,y_n+k_{2,y}/2) \\ \dot{\begin{pmatrix} k_{4,z} \\ k_{4,y}\end{pmatrix}} = \Delta t f(z_n+k_{3,z},y_n+k_{3,y}) \end{array} \end{equation} and then I'd update $z,y$ as
\begin{equation} \begin{array}{l} z_{n+1} = z_n + \frac{1}{6} \left( k_{1,z} + 2k_{2,z} + 2k_{3,z} + k_{4,z}\right) \\ y_{n+1} = y_n + \frac{1}{6} \left( k_{1,y} + 2k_{2,y} + 2k_{3,y} + k_{4,y}\right) \\ \end{array} \end{equation}
Am I missing anything here? because when I run it my point initially goes down (like for 3 iterations) and then it goes up again (I'm expecting the point to go to $z = 0$, what am I missing? Initial condition is $z_0 = 10$ and $\dot{z}_0 = 0$
(If the formulation isn't the problem it must be my coding).
The RHS is the opposite of the sign function applied to $z$. Hence you have a uniformly decelerated motion which alternates between the positive and negative regions, periodically. The analytical solution is straightforward.