How does it work?
If we call θ the angle between the pendulum and the vertical axis, the differential equation which governs the motion of a pendulum is
dt2d2θ=−lgsin(θ)
So at each step, we compute:
- θ′′(t)=−lgsin(θ(t))
- θ′(t+dt)≈θ′(t)+dt×θ′′(t)
- θ(t+dt)≈θ(t)+dt×θ′(t+dt)
Small angles case
When θ is small, we can make the approximation dt2d2θ≈−lgθ
If we assume that the pendulum is released with zero angular velocity, the solution of this approximation is θ(t)=θ0cos(lgt)
More generally, in this approximation the oscillation period is T=2πgl : it does not depend on θ0