13.2 Example: simple harmonic oscillator
As an example of a system of ODEs, consider a harmonic oscillator. In a harmonic oscillator a particle disturbed from equilibrium is pulled back towards its equilibrium position by a force proportional to its displacement from equilibrium. The system here additionally has a friction force proportional to particle speed which points in the opposite direction of the particle velocity. The system state will be a pair \(y = (y_1, y_2)\) representing position and speed. The change in the system with respect to time is given by the following differential equations.25
\[ \frac{d}{dt} y_1 = y_2 \\ \frac{d}{dt} y_2 = -y_1 - \theta y_2 \]
The state equations implicitly defines the state at future times as a function of an initial state and the system parameters.
References
This example is drawn from the documentation for the Boost Numeric Odeint library (Ahnert and Mulansky 2011), which Stan uses to implement the
rk45
andckrk
solver.↩︎