The equation of motion consists of three terms, and can be written as a second-order differential equation:
d 2(theta)/ dt2 = -(1/q) (omega)-sin(theta)+Acos(phi).
Many parameters, such as the mass of the pendulum bob, the length of the pendulum, the acceleration due to gravity, and the natural oscillation frequency of the pendulum, are set to 1 in this situation.
The left-hand side of the equation represents the angular acceleration of the pendulum. If there is no damping and no driving torque then the angular acceleration is proportional to the negative of the sin of the angular displacement (theta), which explains the second term on the right-hand side.
If there is damping then the damping is proportional, and opposite in direction, to the angular velocity, omega. This explains the second term on the right, where q is the damping parameter.
The last term on the right represents the driving torque, characterized by the amplitude A and the driving frequency omega_drive. The equation involves phi, but phi = omega_drive multiplied by time.
The equation is solved numerically and the motion of the object is shown along with various graphs to help us see what is going on.