# Simple pendulum period at large angles: the exact formula in JavaScript

A simple pendulum's period is T = 2π√(L/g) only for small swings. At larger angles the true period is longer, and you can compute it exactly with the arithmetic-geometric mean (AGM) in a few lines of JavaScript. Below I compare the textbook formula, a short series and the exact value for a 1 m pendulum. (I build [PractiSci](https://www.practisci.in), which has a free virtual pendulum lab.)

## What is the period of a simple pendulum?

For small angles T₀ = 2π√(L/g). With L = 1 m and g = 9.81 m/s² that is 2.006 s. The formula assumes sin θ ≈ θ, which is only good for a few degrees.

## How do I get the exact period at large angles?

The exact period is T = T₀ / AGM(1, cos(θ₀/2)). The AGM converges in a handful of steps:

```js
const g = 9.81, L = 1.0;
const T0 = 2 * Math.PI * Math.sqrt(L / g);

function agm(a, b) {
  while (Math.abs(a - b) > 1e-15) [a, b] = [(a + b) / 2, Math.sqrt(a * b)];
  return a;
}
const exact = (deg) => T0 / agm(1, Math.cos((deg * Math.PI / 180) / 2));
const series = (deg) => {
  const t = deg * Math.PI / 180;
  return T0 * (1 + t * t / 16 + 11 * t ** 4 / 3072);
};
```

## How wrong is the small-angle formula?

| Amplitude | Exact period (s) | Longer than T₀ by | Series (s) |
|---|---|---|---|
| 5° | 2.0070 | 0.05% | 2.0070 |
| 10° | 2.0099 | 0.19% | 2.0099 |
| 20° | 2.0215 | 0.77% | 2.0215 |
| 30° | 2.0410 | 1.74% | 2.0410 |
| 45° | 2.0863 | 4.00% | 2.0861 |
| 60° | 2.1529 | 7.32% | 2.1522 |
| 90° | 2.3678 | 18.03% | 2.3592 |

Up to about 10° the error is under 0.2%, which is why the school experiment uses small swings. At 90° the period is already 18% longer.

## FAQ

### Does the mass of the bob change the period?
No. The mass cancels out of the equation of motion, so only L and g matter.

### Why do we measure 20 oscillations in the practical?
Timing 20 swings divides the reaction-time error of your stopwatch by 20.

### Where can I try it?
In the free [simple pendulum lab](https://www.practisci.in/labs/11-13-simple-pendulum) you change the length and the amplitude and time the swings. The [oscillations topic guide](https://www.practisci.in/topics/oscillations-and-waves) explains the theory.
