Where deterministic physics meets the unpredictable!
The double pendulum is a canonical example of deterministic chaos. The equations are completely known, yet long-term prediction is impossible because infinitely small differences in initial conditions lead to completely different outcomes.
"Does the flap of a butterfly's wings in Brazil set off a tornado in Texas?"
— Edward Lorenz, 1972
Source: src/examples/02_double_pendulum/
Watch a single double pendulum evolve from a dramatic initial position (both arms at 135°).
Initial Conditions:
θ₁ = 135° (upper arm)
θ₂ = 135° (lower arm)
ω₁ = ω₂ = 0 (released from rest)
Energy Conservation Check:
Initial energy: -9.633814 J
Final energy: -9.633814 J
Energy drift: 0.000001% ← RK4 is EXCELLENT!
Outputs:
double_pendulum_angles.txt- θ₁(t) and θ₂(t)double_pendulum_phase_space.txt- Chaotic attractor visualizationdouble_pendulum_trajectory.txt- Full trajectory for animation
THE ESSENCE OF CHAOS: Two pendulums starting with just 0.001° difference!
Pendulum A: θ₁ = 90.000°, θ₂ = 90°
Pendulum B: θ₁ = 90.001°, θ₂ = 90°
└── JUST 0.001° !!
Divergence Over Time:
Time (s) Angle Difference
--------------------------------
0.0 0.0010 deg
2.0 0.0089 deg
5.0 0.4721 deg
8.0 47.2314 deg ← 47,000× amplification!!!
The difference grows EXPONENTIALLY! This is the butterfly effect in action.
Verify that numerical integration preserves the conserved quantities:
- Total mechanical energy E = T + V should remain constant
- RK4 typically achieves <0.001% drift over 10 seconds
- This validates our numerical approach
A double pendulum consists of:
- Mass 1 (m₁) at the end of rod of length l₁
- Mass 2 (m₂) at the end of rod of length l₂, attached to m₁
From Lagrangian mechanics (L = T - V):
Angular accelerations:
These are nonlinear coupled ODEs — no closed-form solution exists!
| Feature | Usage |
|---|---|
IODESystem |
Define double pendulum dynamics |
ODESystemFixedStepSolver |
Fixed-step integration |
StepCalculators::RK4_Basic |
4th-order Runge-Kutta |
PolynomInterpRealFunc |
Smooth interpolation for plotting |
SplineInterpParametricCurve |
Phase space trajectory |
Visualizer |
Multi-function plotting |
src/examples/02_double_pendulum/
├── main.cpp # Demo scenarios
├── DoublePendulum.h # Self-contained physics
└── CMakeLists.txt
# Build
cmake --build build --target Example02_DoublePendulum
# Run
./build/src/examples/Release/Example02_DoublePendulum======================================================================
MML DOUBLE PENDULUM - CHAOS DEMONSTRATION
======================================================================
The double pendulum is a classic example of deterministic chaos.
The motion is completely determined by the equations, yet
impossible to predict long-term due to extreme sensitivity
to initial conditions.
"Does the flap of a butterfly's wings in Brazil set off
a tornado in Texas?" - Edward Lorenz, 1972
======================================================================
SCENARIO 1: Chaotic Double Pendulum Motion
======================================================================
Physical Parameters:
Mass 1: 1 kg, Length 1: 1 m
Mass 2: 1 kg, Length 2: 1 m
Initial Conditions:
Theta 1: 135 degrees
Theta 2: 135 degrees
(Both arms pointing up-left - dramatic start!)
Solving for 10 seconds... Done! (2001 time steps)
Energy Conservation Check:
Initial energy: -9.633814 J
Final energy: -9.633814 J
Energy drift: 0.000001%
✓ Single trajectory complete!
Chaos ≠ Randomness!
| Property | Random | Chaotic |
|---|---|---|
| Deterministic | No | Yes |
| Predictable (short-term) | No | Yes |
| Predictable (long-term) | No | No |
| Sensitive to initial conditions | N/A | EXTREMELY |
Chaos is deterministic unpredictability. The equations completely determine the future, but we can never know initial conditions with infinite precision.
- Chaos from simplicity: Just 2 coupled oscillators → infinite complexity
- Exponential divergence: Errors grow as e^(λt) where λ is the Lyapunov exponent
- Phase space: The "attractor" shows structure in apparent randomness
- Energy conservation: Validates numerical accuracy despite chaotic behavior
- MML workflow: Same ODE framework handles simple and chaotic systems
- Example 00: N-Body Gravity (another chaotic system!)
- Example 04: Lorentz Transformations (Edward Lorenz discovered chaos!)
- Strogatz, Nonlinear Dynamics and Chaos - THE textbook on chaos
- Lorenz (1963), "Deterministic Nonperiodic Flow" - Original chaos paper
- Wikipedia: "Double Pendulum" - Good mathematical treatment
