PHASER HelpTip
Converting Second-Order ODE to a First-order System:
Phaser is designed for systems of first-order ordinary differential equations (ODE). Therefore, when faced with a differential equation involving higher-order derivatives, it is necessary to convert it to an equivalent system of first-order equations.
Consider, for instance, the second-order differential equation
    x'' = f(t, x, x')
with the initial conditions
    x(t0) = x0  ,     x'(t0) = x'0   .
To convert this initial-value problem to an equivalent one for a pair of first-order differential equations, introduce the variables
    x1 = x
    x2 = x'   .
Now, the differential equations for x1' and x2' become the following pair
    x1' = x2
    x2' = f(t, x1, x2)
with the initial conditions
    x1 (t0) = x0   ,     x2(t0) = x'0   .
Example: The motions of many simple mechanical systems are governed by Newton's Second Law F = m a , where F is the net force acting on the system, m is the mass, and a is the acceleration which is the second derivative of the displacement with respect to time. Consequently, a = F/m is a natural second-order differential equation.
As a specific example, let us consider the planar pendulum. If we let
Obe the displacement angle of the pendulum from the vertical position, then, according to Newton's Second Law, the motion of the pendulum is governed by the second-order differential equation
O'' = - (g / l) sin(O) - (c /(l m))O'   ,
where g is the gravitational constant, l is the length of the pendulum, m is the mass of the pendulum, and c is the friction constant.
To convert this second-order differential equation to an equivalent pair of first-order equations, we introduce the variables
    x1 =
O
    x2 =O'  ,
that is, x1 is the angular displacement and x2 is the angular velocity. Now, the equations for x1' and x2' become the following pair
    x1' = x2
    x2' = - (g / l) sin(x1) - (c /(l m)) x2.
These are the equations stored in the ODE Library of Phaser under the name Pendulum ODE.