Simple pendulum Runge-Kutta-Fehlberg solver without error analysis

This webpage uses the Runge-Kutta-Fehlberg fourth-order method with fifth-order error checking (RKF45) to approximate the solution to the problem of the simple pendulum:

d2θdt2=glcosθ\begin{aligned} \dfrac{d^2 \theta}{dt^2} = -\dfrac{g}{l} \cos{\theta} \end{aligned}

where gg is the acceleration due to gravity in metres per second squared, ll is the length of the pendulum in metres, θ\theta is the angle from the positive xx axis (in radians) and tt is the time in seconds. Below you can specify the various parameters for the problem we will solve.

Our θ\theta approximations are substituted in, and our θ˙\dot{\theta} RKF45 approximation is subtracted from this value. From this equation, the period TT of the problem is approximated when the conditions for periodicity are satisfied, namely using the equation

T=2θminθmaxdθθ˙02+2gl(sinθ0sinθ)\begin{aligned} T &= 2 \left|\int_{\theta_\mathrm{min}}^{\theta_\mathrm{max}} \dfrac{d\theta}{\sqrt{\dot{\theta}_0^2 + \dfrac{2g}{l} (\sin{\theta_0} - \sin{\theta})}}\right| \end{aligned}

where θmin\theta_\mathrm{min} and θmax\theta_\mathrm{max} are the two closest values for which θ˙=0\dot{\theta} = 0. TT is calculated using Chebyshev-Gauss quadrature (Simpson's rule could not be used as there are unremovable singularities at the endpoints which makes Simpson's rule markedly less accurate).

Simulation parameter form.
Parameter Value Explanation
Acceleration due to gravity.
Length of pendulum in metres.
End time for the simulation in seconds. Default is four times the period of the problem.
Initial angle relative to the positive xx-axis.
Initial rate of change of the aforementioned angle.
Number of quadrature nodes used to approximate period
Error tolerance.
Tolerance type, can be either absolute (0) or relative (1).
Initial step size.
Minimum allowed step size.
Time increment for skipping ahead in animation.
Time you want to skip ahead to in animation when you press the skip button.
Width (in px) of Plotly windows used for plotting and animation below.
Height (in px) of Plotly windows used for plotting and animation below.
Proportion of animation time passed per real time. tScale=1.0t_{\mathrm{Scale}}=1.0 means animation and real time match. tScale<1.0t_{\mathrm{Scale}}<1.0 means the animation is going more slowly than real time. tScale>1.0t_{\mathrm{Scale}}>1.0 means it is going more rapidly.


Information Data Notes
TT: Period of the problem, auto-calculated.
θmin\theta_\mathrm{min} The value of θmin\theta_\mathrm{min} used in the above period equation.
θmax\theta_\mathrm{max} The value of θmax\theta_\mathrm{max} used in the above period equation.
RKF45 step number Number of steps used in our Runge-Kutta-Fehlberg approximation of the solution.