# Coupled second-order differential equations using runge kutta 45

As a little summer project I have tried to make a ballistic calculator for when I play football, (following an example from a book), just to learn some numerical methods while doing so. My problem is that I cant seem to find much on the Runge-Kutta 5 method (method recommended) for systems of second order differential equations.

My equations (simplified a bit) is

$$\cfrac{d^2x}{dt^2} = K_x(y) \cdot \sqrt{\dot{x}^2+\dot{y}^2+\dot{z}^2} \cdot \dot{x} + C_x(y)$$

$$\cfrac{d^2y}{dt^2} = K_y(y) \cdot \sqrt{\dot{x}^2+\dot{y}^2+\dot{z}^2} \cdot \dot{y} + C_y(y)$$

$$\cfrac{d^2z}{dt^2} = K_z(y) \cdot \sqrt{\dot{x}^2+\dot{y}^2+\dot{z}^2} \cdot \dot{z} + C_z(y)$$

With the initial conditions being

$$\dot{x}(0)=v_{x0}$$,
$$\dot{y}(0)=v_{y0}$$,
$$\dot{z}(0)=v_{z0}$$.

$$x(0)=x_0$$,
$$y(0)=y_0$$,
$$z(0)=z_0$$.

So far I have proceeded as I usually do when implementing the Runge-Kutta method up to this point (which is just the first step)

$$\cfrac{d^2x}{dt^2} = f(t, x, y, z, \dot{x}, \dot{y}, \dot{z})$$

$$\cfrac{d^2x}{dt^2} = f(t, x, y, z, \dot{x}, \dot{y}, \dot{z})$$

$$\cfrac{d^2x}{dt^2} = f(t, x, y, z, \dot{x}, \dot{y}, \dot{z})$$

How can I proceed from this point? Bonus if someone knows some good literature on the subject.

• Crucial edit made $K (y)$ – Peter Aug 17 '20 at 9:36

A equation like $$\frac{d^2x}{dt^2} = f(t, x, \dot{x})$$ and $$\dot{x}(0)=\dot{x}_0, x(0)=x_0$$ can be converted to with an auxiliary variable $$\xi$$ $$\frac{dx}{dt} = \xi \\ \frac{d\xi}{dt} = f(t, x, \xi)$$ with initial conditions $$\xi(0)=\dot{x}_0$$ and $$x(0)=x_0$$. Now, each equation is first order but you have two equations.
If you write this as a vector this leads to $$\frac{d}{dt}\left(\begin{array}{c}x\\\xi\end{array}\right) = \left(\begin{array}{c}\xi\\ f(t,x,\xi)\end{array}\right)\\$$ and you can pass this to your first order ODE integrator of your choice.
• So I will get something like $\dot{x} = \xi$ $\dot{y} = \zeta$ $\dot{z} = \phi$ $\cfrac{d\xi}{dt} = f1(t, x, y, z, \xi, \zeta, \phi)$ $\cfrac{d\zeta}{dt} = f2(t, x, y, z, \xi, \zeta, \phi)$ $\cfrac{d\phi}{dt} = f3(t, x, y, z, \xi, \zeta, \phi)$ $\cfrac{d}{dt} [x, y, z, \xi, \zeta, \phi]^T = [\xi, \zeta, \phi, f1(t, x, y, z, \xi, \zeta, \phi), f1(t....), f1(t....)]^T$ – Peter Aug 17 '20 at 10:31
• yes, you need an auxiliary variable for $\dot{x}$, $\dot{y}$ and $\dot{z}$ in your case. So you end up with a system of 6 equations, which three are trivial. Though your rhs will probably have three different $f_i$. – Bort Aug 17 '20 at 10:33