HomeCVSimulations

Pendulum simulation

θ0\theta_057°
θ0\theta_011°
θ0\theta_06°

How does it work?

If we call θ\theta the angle between the pendulum and the vertical axis, the differential equation which governs the motion of a pendulum is

d2θdt2=glsin(θ)\frac{d^2 \theta}{dt^2} = - \frac{g}{l} \sin(\theta)

So at each step, we compute:

  • θ(t)=glsin(θ(t))\theta''(t) = - \frac{g}{l} \sin (\theta(t))
  • θ(t+dt)θ(t)+dt×θ(t)\theta'(t+dt) \approx \theta'(t) + dt \times \theta''(t)
  • θ(t+dt)θ(t)+dt×θ(t+dt)\theta(t+dt) \approx \theta(t) + dt \times \theta'(t+dt)

Small angles case

When θ\theta is small, we can make the approximation d2θdt2glθ\frac{d^2\theta}{dt^2} \approx - \frac{g}{l} \theta

If we assume that the pendulum is released with zero angular velocity, the solution of this approximation is θ(t)=θ0cos(glt)\theta(t) = \theta_0 \cos (\sqrt{ \frac{g}{l} } t)

More generally, in this approximation the oscillation period is T=2πlgT = 2 \pi \sqrt{ \frac{l}{g}} : it does not depend on θ0\theta_0