This webpage uses the Runge-Kutta-Fehlberg fourth-order method with fifth-order error checking (RKF45) to approximate the solution to the problem of a single pendulum. To calculate the equations of motion, we must first determine the Lagrangian which is defined as the kinetic energy minus the potential energy. The kinetic energy of the bob is simply its mass times its velocity squared over two. The kinetic energy of the rod has a term like this, too, (although the velocity we will focus on will be the velocity of its centre of mass) but we must also consider its rotational velocity. As for the potential energy of the bob and rod, it will simply be the mass of them times by the y-coordinate of its centre of mass.
Where g is the acceleration due to gravity in metres per second squared, l is the length of the pendulum in metres, θ is the angle from the positive x axis (in radians). mb is the mass of the bob in kilograms. vb is the velocity vector for the bob in metres per second. vr,cm is the velocity of the rod's centre of mass in metres per second. mr is the mass of the rod in kilograms. t is the time in seconds. Icm is the moment of inertia around the centre of mass of the rod. It would be 12mrl2.[1] Velocity squared, for the bob, in polar coordinates is given by l˙2+l2θ˙2 but here l is a constant and hence its time derivative is zero. As for the velocity of the rod's centre of mass, we will assume the rod is uniform in mass and hence its centre of mass is in its centre, which we will assume is midway between the bob and the origin. Hence its velocity will be half that of the bob.
Next we will calculate the generalized dissipation force Qi which is defined as being the dot product of the dissipation force vector with generalized basis vector for each component of a physical system. Here there are two components of the system: the rod and the bob. The dissipation force vector will be assumed to be FD,j=−(bj+cj∣vj∣)vj.