› Simple Pendulum Simulator (RK4) Back
High-School Physics / Vibration Analysis

Simple Pendulum Simulator (RK4)

Adjust pendulum length, initial angle, damping coefficient, and gravitational acceleration for real-time RK4 numerical integration. Explore nonlinear oscillations across pendulum animation, angular displacement waveform, and phase space (θ-ω plane) tabs.

Parameters

Presets
Results
—
Period T (linear approximation)
—
Current angle θ
—
Angular velocity ω = dθ/dt
—
Total energy ratio
Pendulum Animation
Angular Displacement vs Time
Phase Space
Live values while swinging
0.0°
Angle θ
0.00
Angular velocity ω [rad/s]
0.00
Period T [s]
0.00
Speed v [m/s]
0.0
Kinetic KE [J/kg]
0.0
Potential PE [J/kg]
Pendulum (with force and velocity vectors)
Gravity mg Restoring force mg·sinθ (tangential) Velocity v Actual pendulum Small-angle ideal (T=2π√(L/g))
Energy balance (per unit mass)
Kinetic KE
0.0 J/kg
Potential PE
0.0 J/kg
Total E
0.0 J/kg
Without damping the total energy is constant: KE is largest at the bottom and PE at the extremes, as energy shifts between KE and PE.
Phase
Theory & Key Formulas

$$T = 2\pi\sqrt{\frac{L}{g}}$$

Small-amplitude period [s] ($L$: string length [m], $g$: gravitational acceleration [m/s²]). It does not depend on mass or amplitude (isochronism).

$$\ddot{\theta} + \gamma\,\dot{\theta} + \frac{g}{L}\sin\theta = 0$$

Nonlinear equation of motion ($\gamma$: damping coefficient), integrated numerically with RK4 keeping $\sin\theta$.

$$E = \frac{1}{2}L^2\dot{\theta}^2 + gL(1-\cos\theta)$$

Total energy per unit mass [J/kg]: the sum of kinetic and potential energy (conserved without damping).

Check: $L=1,\ g=9.81$ → small-angle $T\approx 2.006$ s. At $\theta_0=120^\circ$, $T\approx 2.75$ s: the period lengthens at large amplitude.

Conversation: deepen your understanding
🙋
I've heard the term "isochronism" — is it really true that the period stays the same even if the swing amplitude changes? It seems like a big swing would take more time...
🎓
"For small amplitudes" it's the same — that's the key. Try θ₀=5° and 10°, you'll get almost the same period. But switch to the "Large amplitude" preset (θ₀=120°) and the period clearly becomes longer. That's because the approximation sinθ ≈ θ breaks down and nonlinearity kicks in. Galileo observed a "small-swing pendulum," which is why he discovered isochronism.
🙋
When I turn on damping, the amplitude gradually decreases. Does isochronism hold even with damping?
🎓
For small amplitudes and linear damping, the period stays almost the same. The period of a damped oscillation is T_d = 2π/√(ω₀² - γ²/4), so if γ is small, the difference from T₀ is tiny. The important thing is that "the amplitude decays exponentially." Look at the angular displacement tab — the envelope follows e^(-γt/2). Building vibration dampers and car shock absorbers use this damping force.
🙋
I looked at the phase space tab — without damping it's a closed ellipse, and with damping it becomes a spiral. What does that mean?
🎓
A closed ellipse is evidence of energy conservation. Going around the same ellipse forever = sustained oscillation. A spiral means the trajectory is sucked into the origin (rest) = energy dissipates and stops. Just by looking at the "flow pattern" in the phase plane, you can instantly see the system's stability and long-term behavior — this is a very important concept in CAE vibration analysis and control design.
🙋
With the Moon (g=1.62) preset, the period became about 2.5 times longer. If I took a pendulum clock to the Moon, it would be off, right?
🎓
Since T ∝ 1/√g, on the Moon T_moon/T_earth = √(9.81/1.62) ≈ 2.46. A pendulum that ticks every second on Earth ticks only every 2.46 seconds on the Moon, so the clock runs about 2.46 times slow. Real precision pendulum clocks show errors even from altitude and latitude (tiny variations in g), so they needed corrections for height above sea level. GPS satellite clocks, by contrast, are corrected for general-relativistic time dilation: in high orbits where gravity is weaker, clocks run fast.
🙋
How is RK4 different from the Euler method? Why do we use RK4?
🎓
The Euler method (first-order accuracy) accumulates O(dt²) error per step, causing energy to increase or diverge in long simulations. For a pendulum, the amplitude will spontaneously grow after dozens of swings. RK4 (fourth-order accuracy) has O(dt⁵) error, giving much better precision for the same time step. In CAE structural dynamics, choosing between Newmark-β, Runge-Kutta, and other time integration methods is a key trade-off between "numerical dissipation and computational cost."
Frequently Asked Questions

How to Use

  1. Set pendulum length (L) in meters using slider vL; typical range 0.5–2.0 m for laboratory setups.
  2. Adjust initial angle θ₀ in degrees (sT0) between 5–60° to observe nonlinear effects; small angles (<10°) approximate simple harmonic motion.
  3. Input damping coefficient (drag) and gravitational acceleration (g, default 9.81 m/s²) to match experimental conditions.
  4. Click simulate to run 4th-order Runge–Kutta integration with real-time θ and ω output.

Worked Example

With L = 1.0 m, g = 9.81 m/s² and θ₀ = 30°, the linear approximation gives T = 2.006 s, but because of the nonlinear term the actual period is T = 2.041 s. At θ₀ = 60° the actual period lengthens to T = 2.153 s, and at θ₀ = 80° to T = 2.282 s. Raising the damping coefficient γ makes the amplitude decay exponentially, and the angular-displacement tab shows the envelope e^(−γt/2).

Practical Notes

  1. Use damping coefficients 0.01–0.1 s⁻¹ to model realistic laboratory pendulums; higher values simulate high-viscosity fluids or heavy damping.
  2. RK4 step size automatically scales; for angles >45°, expect 10–15% deviation from small-angle approximation T = 2π√(L/g).
  3. Energy ratio tracks conservation; ratios <0.95 indicate numerical drift or insufficient RK4 resolution—reduce step size if needed.
  4. Compare Earth (g=9.81) versus lunar conditions (g=1.62 m/s²) to validate gravitational scaling on period.