Colliding Blocks & Pi
Push a heavy block into a light one by a wall and count the collisions: with masses 100ⁿ apart, the count gives the digits of π.
Count the collisions: when the big block is 100, 10,000 or a million times heavier, the count gives the digits of π. Drag the big block back and let go to push it, the further the faster, or tap to start again.
How is Colliding Blocks & Pi working for you?
About Colliding Blocks & Pi
- Discovered
- Gregory Galperin, 2003
- Mass ratio 100ⁿ
- The first n + 1 digits of π
- Collisions
- Computed exactly, one event at a time
- Largest case
- 3,141,592 collisions at a ratio of 10¹²
Good for: Short breaks
Put a small block on a frictionless floor between a wall and a much heavier block, and push the heavy block toward it. The small block shuttles back and forth between the wall and the big block, faster and faster, until the big block turns around and everything slides away. Count the collisions. With equal masses there are 3. Make the big block 100 times heavier and there are 31; 10,000 times heavier, 314; a million times heavier, 3,141. Every factor of 100 in mass adds the next digit of π. Gregory Galperin described and proved this in 2003 in a paper called Playing pool with π.
The simulator computes every collision exactly. Between collisions the blocks slide at constant speed, so the moment of the next collision can be calculated, and each perfectly elastic collision keeps the total energy and, between the two blocks, the total momentum, following the laws Christiaan Huygens set out in 1669. There is no time step to introduce errors, so even the 3,141,592 collisions of the 7-digit case come out right. Near the wall the collisions come far too fast to see, so Slow motion spreads the burst over a few seconds while the counter climbs.
The phase circle shows why π appears. Plot the big block's velocity times the square root of its mass across and the small block's velocity times the square root of its mass up: conservation of energy keeps this point on a circle. A collision between the blocks moves it along a straight line of constant momentum and a wall bounce flips it from top to bottom, so each pair turns it around the circle by the same angle 2θ, where θ = arctan √(m/M). The collisions stop when the point reaches the narrow wedge where the small block can never catch up again, so the count is the largest N with N × θ < π, and for masses 100ⁿ apart, θ is almost exactly 1/10ⁿ. In 2020 Adam Brown showed that the same geometry describes Grover's quantum search algorithm.
How to use Colliding Blocks & Pi
- Pick the digits. Choose a preset from 1 to 7 digits, or move Big block mass. Each factor of 100 in mass adds a digit of π to the count; other masses give other counts, still the largest N with N × θ < π.
- Push the block. Drag the big block back and let go: the further you pull it, the faster it slides in. Push speed does the same from the panel. Tap the board or press Restart to run it again.
- Watch the count. The counter shows every collision. When no more are possible, the digits of π that the count matches are highlighted, and the readout below explains the number. Each finished run adds a row to the Runs table with its mass and count; Reset clears the table.
- Read the phase circle. The white point is the state of both blocks. Each collision moves it along a gold line, block collisions along lines of constant momentum and wall bounces straight up or down, until it reaches the green wedge where the collisions stop.
- Slow it down or speed it up. Slow motion spreads the burst of collisions near the wall over about five seconds. Turn it off and millions of collisions finish in a fraction of a second. A long wait for the next collision plays in fast forward.
- Listen and export. Click sound plays a click for each collision. Save a PNG, a video or GIF, or the first 10,000 collisions with their times and velocities and the Runs table as CSV files. Record full run starts the blocks again and records until the last collision.
Frequently asked questions
Why does the number of collisions give the digits of π?
Because of a circle. Energy conservation puts the state of the two blocks on a circle, and each block collision followed by a wall bounce turns it by the same small angle 2θ, with θ = arctan √(m/M). The collisions end once the state has gone half way around, so the count is how many steps of θ fit into π. When the big block is 100ⁿ times heavier, θ is almost exactly 1/10ⁿ, and the number of steps is π × 10ⁿ rounded down: the first n + 1 digits of π.
Is energy really conserved?
Yes. The floor has no friction and every collision is perfectly elastic, so no energy is lost; the stats line shows the kinetic energy as a share of the start, which stays at 100% up to rounding in the last decimal places. Momentum is kept in collisions between the blocks, but the wall pushes back on the small block, so the total momentum changes at every wall bounce.
Why not simulate with small time steps?
With a mass ratio of 10¹² the small block ends up moving about a million times faster than the big block was pushed, in a gap less than a millionth of the one it started in. A fixed time step would skip collisions or let the blocks pass through each other. Instead the simulator works out exactly when the next collision happens and jumps straight to it, which is why the counts come out exact.
Does it work for any masses?
Any mass ratio gives a count: the largest whole number N with N × θ < π. A big block 10 times heavier gives 10 collisions, since θ = arctan √(1/10) fits into π a little over 10 times. Only powers of 100 make the count give the digits of π. One caveat: θ is very slightly smaller than 1/10ⁿ, so the count would come out one too high if the digits of π right after the ones being counted were a long run of 9s. Nobody has proved that never happens, though such a run of 9s would be very unlikely.
What does this have to do with quantum computing?
In 2020 the physicist Adam Brown showed that the blocks follow the same geometry as Grover's quantum search algorithm, which finds one marked item among N in about (π/4)√N steps by turning a state through a small fixed angle each step. The count of collisions grows like π times the square root of the mass ratio for the same reason.
References
- Huygens, C. (1669). A summary account of the laws of motion, communicated by Mr. Christian Hugens in a letter to the R. Society. Philosophical Transactions of the Royal Society of London 4(46), 925–928.
- Galperin, G. (2003). Playing pool with π (the number π from a billiard point of view). Regular and Chaotic Dynamics 8(4), 375–394.
- Brown, A. R. (2020). Playing pool with |ψ⟩: from bouncing billiards to quantum search. Quantum 4, 357.





