04 · Nonlinear dynamics
Double pendulum, phase space and energy error
The full nonlinear equations are integrated with a 2 ms RK4 step. Watch the trajectory, the phase portrait and the relative energy error: a good integrator keeps it near 10⁻⁸, chaos keeps the motion unpredictable.
- RK4
- Nonlinear
- Chaos
- Phase portrait
- Energy drift
- mass 1
- mass 2
- trail
Method
The equations
Full nonlinear form
With θ₁ and θ₂ measured from the downward vertical, the angular accelerations are the standard coupled expressions for two point masses on massless rods. They reduce to the small-angle result only when both angles are small; this simulator does not linearise.
Integration
A fixed-step fourth-order Runge–Kutta integrates the four-state system at 2 ms. The energy
E = T + V is evaluated every step and compared with its initial value. A drift below 10⁻⁶
relative over a minute is the practical sign of a stable integration.
Why it is chaotic
The equations are deterministic, but nearby initial conditions separate exponentially. Doubling the initial angle from 1.6 to 1.7 rad changes the path within a few seconds. That is why the energy check, not the exact trajectory, is the meaningful test of the numerical method.
Formulas
Equations in use
T = ½(m₁+m₂)L₁²ω₁² + ½m₂L₂²ω₂² + m₂L₁L₂ω₁ω₂cos(θ₁−θ₂)
V = −(m₁+m₂)gL₁cosθ₁ − m₂gL₂cosθ₂
state = [θ₁, θ₂, ω₁, ω₂], RK4 with dt = 0.002 s
Change θ1 by 0.1 rad and reset: the first seconds look similar, then the paths diverge. The energy error should stay far below one percent.
Guides