In this model, we neglect the effect of air friction, so the pendulum's mass is only submitted to two forces: its weight, and the tension of the cord.
If we call the angle between the pendulum and the vertical axis, it can be shown that the differential equation which governs the motion of a pendulum is
Hence, to make this simulation, at each step we compute:
When is small, we can make the approximation
If we assume that the pendulum is released with zero angular velocity, the solution of this approximation is
More generally, in this approximation the oscillation period is : it does not depend on
You can see this here by launching the simulation with two different small angles : these two pendulums will swing in sync for a long time.