Simulate the Physics of a Pendulum's Periodic Swing

This example simulates and explores the behavior of a simple pendulum by deriving its equation of motion, and solving the equation analytically for small angles and numerically for any angle.

Table of contents

Derive the Equation of Motion

Linearize the Equation of Motion

Solve Equation of Motion Analytically

Physical Significance of

Plot Pendulum Motion

Understanding Non-Linear Pendulum Motion Using Constant Energy Paths

Solve Non-Linear Equation of Motion

Solve Equation of Motion for Closed Energy Contours

Solve Equation of Motion for Open Energy Contours

Conclusion

1. Derive the Equation of Motion

The pendulum is a simple mechanical system that follows a differential equation. The pendulum is at rest in a vertical position. We displace the pendulum by an angle and release it. The force of gravity pulls it back towards its resting position, its momentum causes it to overshoot and come to an angle (if there are no frictional forces), and so forth. The restoring force is , the gravitational force along the pendulum's motion (with a minus sign to remind us that it pulls back to the vertical position). Thus, according to Newton's second law, the mass times the acceleration must equal .

syms magtheta(t)
eqn = m*a == -m*g*sin(theta)

eqn(t) =

The acceleration of the mass at the end of the pendulum is

Substitute for a by using subs.

syms r
eqn = subs(eqn,a,r*diff(theta,2))

eqn(t) =

Isolate the angular acceleration in eqn by using isolate.

eqn = isolate(eqn,diff(theta,2))

eqn =

Collect constants and into a single parameter, called the natural frequency,

syms omega_0
eqn = subs(eqn,g/r,omega_0^2)

eqn =

2. Linearize the Equation of Motion

This equation is difficult to solve analytically because it is non-linear. Assuming the angles are small, we can linearize the equation by using the Taylor expansion of .

4. Physical Significance of

is called the phase. The cosine function repeats every . The time needed to change by is called the time period

From the equation, the time period is directly proportional to the pendulum's length. However, does not depend on the mass because its moment of inertia and its weight are both directly proportional to its mass.

The time period does not depend on the initial conditions but the amplitude does. Instead, the period is governed by the equation of motion.

To understand the non-linear motion of a pendulum, visualize the pendulum path by using the equation for total energy. Since the non-linear motion must conserve total energy, paths that have constant energy describe the non-linear motion.

The total energy is

We can use the trigonometric identity

Use the relation to write the scaled energy as

Since energy is conserved, the pendulum's motion can be described by constant energy paths in phase space, which is the abstract space with coordinates vs. . We can visualize these paths using fcontour.

The curves are symmetric about the axis and axis, and are periodic along the axis. There are two regions of distinct behavior. The lower energies of the contour plot close upon themselves: the pendulum swings back and forth between two maximum angles and velocities.

The higher energies of the contour plot do not close upon themselves because the pendulum always moves in one angular direction.

7. Solve Non-Linear Equations of Motion

The non-linear equations of motion are a second-order differential equation. Numerically solve these equations by using the ode45 solver. Because ode45 only accepts first-order systems, reduce the system to a first-order system. Then, generate function handles that are the input to ode45.

10. Conclusion

We have derived the simple pendulum's equation of motion, linearized and solved its equation of motion analytically, visualized its energy contours to understand the system qualitatively, and solved the general equation of motion numerically for particular initial conditions.