This is a simulation of the spherical pendulum, or pendulum in two dimensions, whose Lagrangian is given by
$$
\mathcal{L} = \dfrac{1}{2}mL^2\dot{\theta}^2 + \dfrac{1}{2}mL^2\dot{\phi}^2\sin^2\ theta +
$$
$$
+ mgL\cos\theta,
$$
where $\theta$ and $\phi$ are the traditional spherical coordinates.
The equations of motion are integrated using the fourth order Runge-Kutta method with time step $h$.
For large initial angles (greater than 120º),
it is necessary to decrease $h$ to guarantee the convergence of the solution.
The acceleration of gravity is defined as $g = 9.8$ m/s².
Read more: