← Back to all simulationsSimulation

Pendulum Simulator

Adjust the pendulum's length and how far you pull it back before releasing it, and watch how little of that actually changes the swing's timing — and where the textbook formula starts getting it wrong.

Swing over time

How far the bob is from vertical, second by second. The two lines start together and drift apart as the swing gets wider.

+20°−20°0 s4.04 s
Real swing, solved step by stepTextbook formula

period: 2.021s

Period (real)
2.021 s
Period (textbook)
2.006 s
Textbook is off by
0.76%

Solved step by step with Runge-Kutta, then checked against the exact period written with an elliptic integral (2.021 s): the two agree to within <0.001%.

Assumes a point mass on a massless rigid rod, no air resistance, and no friction at the pivot. Each of those would stretch the real period slightly longer.

Pendulum length1m
Release angle20°

The math behind it

A pendulum's period — the time for one full back-and-forth swing — depends on surprisingly little. Ignoring air resistance, it comes down to just the length of the pendulum and the strength of gravity:

period = 2π × √(length ÷ gravity)

Notice what's missing from that formula: mass. A heavier bob and a lighter one, released from the same height on the same length of string, swing at exactly the same rate — one of the most famous, counterintuitive results in classical mechanics. Amplitude barely matters either, as long as the swing stays reasonably small: a wider swing travels farther each cycle, but it also moves faster, and the two effects almost cancel out.

Where that formula stops being true

Almost cancel out. That formula isn't the period of a pendulum — it's the period of a pendulum swinging through a small angle. Getting there means replacing sin θ with θ, which is close enough to true near the bottom of the swing and drifts further from it the wider the swing gets. Pull the release angle up to 45° and the real pendulum takes about 4% longer per swing than the formula claims.

Four percent sounds like nothing. A pendulum clock running 4% slow loses about an hour a day, which is why clock pendulums are built to swing through just a few degrees — small enough that the approximation is nearly exact, and the clock keeps time.

So this simulator doesn't use that formula to draw the swing. It solves the equation the approximation came from — the bob's angular acceleration is −(g/length) × sin(angle) — advancing the angle and speed one small time step at a time with a method called fourth-order Runge-Kutta. The solid line is that solution; the dashed line is what the textbook formula predicts. The vertical marks show where each one says the first full swing finishes.

There is an exact answer for the period, written with something called an elliptic integral, and the simulator works that out too — not to draw anything, but to check the step-by-step solution against it. That comparison is printed under the diagram, and it usually agrees to less than a thousandth of a percent. Checking a numerical answer against an exact one, wherever an exact one exists, is the habit that makes the numerical answers trustworthy everywhere else.

More on energy as a concept →