Convert ODE to first-order form I am struggling to understand reducing higher order DE to first-order form. Say I have an equation of motion,
$$m \frac{d^2}{dt^2} 
\left(
\begin{array}{c}
x \\
y 
\end{array}
\right) =
-\frac{GmM}{{(x^2+y^2)}^\frac{3}{2}}
\left(
\begin{array}{c}
x \\
y 
\end{array}
\right),$$
how to reduce to the first-order form? I want to use Euler or Runge-Kutta on the result.
I think I understand that I should create some variable, $r$, which do something along the lines of
$$\mathbf{r} =
\left(
\begin{array}{c}
x \\
y 
\end{array}
\right), 
\frac{d}{dt}\left(\frac{d\mathbf{r}}{dt}\right) = f(x, x', t) = 
\left(
\begin{array}{c}
f_x \\
f_y 
\end{array}
\right),$$ and then
$$\mathbf{v} = \frac{d\mathbf{r}}{dt} = \frac{d}{dt}\left(\begin{array}{c}x\\y\end{array}\right)
=
\left(
\begin{array}{c}
v_x \\
v_y 
\end{array}
\right)
,$$
and ultimately
$$
\frac{d}{dt}
\left(
\begin{array}{c}
x \\
y \\
v_x \\
v_y 
\end{array}
\right)
=
\left(
\begin{array}{c}
v_x \\
v_y \\
f_x \\
f_y
\end{array}
\right)
$$
This is from some lectures I've found in various corners of the internet; I am truly lost. I realize I've not yet made any changes to the original equation, but I just don't know what to do! Can any of you please give me some pointers to where I'm going or what I'm doing? Much appreciated. It does feel like I am wandering about not knowing which direction I'm supposed to go.
 A: You have the first-order form as
$$
\frac{d}{dt}
\left(
\begin{array}{c}
x \\
y \\
v_x \\
v_y 
\end{array}
\right)
=
\left(
\begin{array}{c}
v_x \\
v_y \\
f_x \\
f_y
\end{array}
\right).
$$
So you have $\frac{d}{dt}{v_x} = f_x$ and $\frac{d}{dt}{v_y} = f_y$, where $f_x$ and $f_y$ are given in terms of $x$ and $y$ with some constants like masses and the gravitational constant. Similarly, you have first-order differential equations $\frac{dx}{dt} = v_x$ and $\frac{dy}{dt} = v_y$. You should have the time interval and initial conditions $x(t_0)$ and $y(t_0)$, and $v_x(t_0)$ and $v_y(t_0)$.
These are now ready for numerical integrations. But first, try to understand what's going on.
Imagine you are starting on some initial time, for instance, $t_0 = 0$. At that point, you know positions and velocities (you have your initial conditions). Since you know the initial velocity, you can predict where your $x$ and $y$ will be at the next time step $t_1$, approximately (fairly accurate if your $dt$ is small enough). You then basically have your $x_1$ and $y_1$ (you can draw a line from $x_0$ to $x_1$, for instance.
With the same logic as above, you have your original equation of motion, where you can plug in your initial conditions and predict where your $v_x$ and $v_y$ will be at $t_1$ (since you have a "slope" equation for them).
With your new data points (positions and velocities) at the next $t_1$, you just iterate over and over and you will be able to graph trajectories for both positions and velocities.
Numerical integration methods (Euler or R-K) more ore less carry out the above calculations for you.
