Math · Live Demo

Pi from Collisions

One of my favorite surprises in math, ported from my Python sim. Slide a big block into a small one against a wall, count every perfectly elastic collision, and the digits of pi appear. Make the big block 100 times heavier and you get one more digit each time.

  • Setup. A small block at rest, a heavy block moving in, and a wall on the left.
  • Mass ratio. Pick 1, 100, or 10000 and the collision count becomes 3, then 31, then 314.
  • Why. Elastic collisions conserve energy and momentum, which traces a circle, and pi follows.
JavaScriptCanvasPhysicsMath
View source on GitHub
0 collisions
Mass ratio:

Count the collisions: 3, then 31, then 314. The digits of pi fall out of pure physics.