Pendulum motion simulation

What is this?

This interactive canvas demonstrates a simple pendulum, modeled using the Euler method for numerical integration.

Deriving the physics of pendulum motion

Consider an ideal mathematical model of a pendulum. A point mass, is suspended from a fixed pivot point by a rigid, weightless rod. Newton's second law of motion can then be used to find the force acting on the mass. The law states that "The net force F\vec F on an object is proportional to the acceleration α\alpha and the mass m of the object." Formulated as:

F=mα\vec F = m \alpha

Two forces act on the bob: the tension in the rod and the force of gravity. The tension force exerted by the rod is cancelled by the component of gravity acting along the rod. This is easily seen when the pendulum is at rest in the vertical position. Because the bob is restricted to move in a circle, the gravitational force can be split into tangential and radial components. Only the tangential component is of interest, since the radial is cancelled by tension, and can be derived using trigonometry:

Ftan=mgsin(θ)=mαF_{tan} = -mg \sin(\theta) = m\alpha

Where g is the gravitational acceleration, and theta is the angle between the rod and the vertical. The negative sign indicates that this force acts to restore the pendulum to its equilibrium position.

Diagram of a simple pendulumFigure: Simple pendulum diagram. [1]

Arriving at the motion of a pendulum

The motion of the pendulum is defined by the angle θ\theta, in radians. The distance moved by the bob is given by the arc length s=lθs=l \theta, where l is the rod length. The angular velocity is the time derivative of distance, and the angular acceleration is the time derivative of the velocity:

vtan=dsdt=ldθdtv_{tan} = \frac{ds}{dt}=l \frac{d\theta}{dt}
αtan=dvdt=ld2θdt2\alpha_{tan} = \frac{dv}{dt}=l \frac{d^2\theta}{dt^2}

Using the previous force equation, we finally arrive at the second order differential equation describing the motion of a simple pendulum:

mgsin(θ)=mld2θdt2-mg \sin(\theta) = ml \frac{d^2\theta}{dt^2} \Leftrightarrow
d2θdt2+glsin(θ)=0\frac{d^2\theta}{dt^2} + \frac{g}{l} \sin(\theta) = 0

Because of the sine function, this is a non-linear second order ordinary differential equation. It is difficult to solve, and a solution cannot be written using elementary functions (continuous in their domain). Thus, for practical purposes, numerical methods like Euler or Runge-Kutta methods can be used to simulate the pendulum motion.