## 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(t

_{0}) = x_{0}, x'(t_{0}) = x'_{0}.

To convert this initial-value problem to an equivalent one for a pair of first-order differential equations, introduce the variables

x

_{1}= x

x_{2}= x' .

Now, the differential equations for x

_{1}' and x_{2}' become the following pair

x

_{1}' = x_{2}

x_{2}' = f(t, x_{1}, x_{2})

with the initial conditions

x

_{1}(t_{0}) = x_{0}, x_{2}(t_{0}) = 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~~O~~be 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

x

_{1}=~~O~~

x_{2}=~~O~~' ,

that is, x

_{1}is the angular displacement and x_{2}is the angular velocity. Now, the equations for x_{1}' and x_{2}' become the following pair

x

_{1}' = x_{2}

x_{2}' = - (g / l) sin(x_{1}) - (c /(l m)) x_{2}.

These are the equations stored in the ODE Library of Phaser under the name

Pendulum ODE.