Simulating Pi Calculation with Collision Counts
billiardpi
Created: 2025/3/22

Did you know that you can calculate the value of π just by counting the number of collisions between two objects?

It sounds mysterious, but let's explore it with a simulation!

Simulation

Mass Ratio
x Scale

Count the number of collisions when two objects collide elastically. Start by pressing the START/STOP button and observe how many collisions occur. Then, try changing the mass ratio of the two objects and see how the number of collisions changes.

The mass ratio represents the ratio of the mass of the blue object to the green object.

Did you notice that the number of collisions corresponds to the first few digits of π?

Specifically, when the mass ratio is 102(n1)10^{2(n-1)}, the number of collisions matches the first nn digits of π.

Keep in mind that when the mass ratio is 10410^4, the last (314th) collision takes a very long time.

In this simulation, you can observe up to n=3n=3. If you follow the graph link, you can simulate for any nn, but for n4n\geqq 4, it takes too long, so it's not recommended...

Supplement

Due to calculation precision and speed, this simulation takes longer than the actual collisions would in reality. Especially when the two objects are very close, collisions happen at an astonishing speed in real life.

Why Does π Appear?

Let's explore why π appears. There are various proofs, but we'll explain the most famous method using a circle.

As shown in the figure, consider the xx axis, and let the masses of the two objects be m,Mm,M and their velocities be v,Vv,V respectively. Assume that at time t=0t=0, v=0,V=V0v=0,V=V_0.

Since the collisions between the objects and the wall are elastic, the total energy of the two objects is conserved.

This is expressed by the law of conservation of energy:

12mv2+12MV2=12MV02\frac12mv^2+\frac12MV^2=\frac12MV_0^2

Now, let v=mv,V=MVv'=\sqrt mv,\,V'=\sqrt MV . Then:

v2+V2=(MV0)2v'^2+V'^2=\left(\sqrt MV_0\right)^2

This means that v,V\bm{v',V'} lie on the circumference of a circle with radius MV0\bm{\sqrt MV_0}!

At t=0t=0, the point is at the rightmost position on the graph above.

Next, consider how v,Vv',V' change. Just before and after the collision between the two objects, the law of conservation of momentum holds. That is:

mv+MV=Cmv+MV=C

(where CC is a constant).

Thus:

mv+MV=C  V=Mmv+C\sqrt mv'+\sqrt MV' = C\ \Leftrightarrow\ V'=-\sqrt{\frac Mm}v'+C'

This means that just before and after the collision, v,Vv',V' lie on a straight line with a slope of Mm-\sqrt{\dfrac Mm} .

For example, after one collision, v,Vv',V' will be at the red point in the figure, which lies on the straight line with a slope of Mm-\sqrt{\dfrac Mm} passing through the previous point.

Next, the lighter object collides with the left wall. Its velocity becomes v-v due to the collision, so on the circle, it becomes v-v' :

Repeat this process, and it looks like this:

Here, considering that the slope of the straight line is always Mm-\sqrt{\dfrac Mm} , the angle θ\theta satisfies:

tanθ=mM  θ=arctan(mM)\tan\theta=\sqrt{\dfrac mM}\ \Leftrightarrow\ \theta = \arctan\left({\sqrt{\dfrac mM}}\right)

By the inscribed angle theorem:

As shown in the figure above.

Each collision adds one point. As seen in the figure, this corresponds to the number of 2θ2\theta .

Thus, the number of collisions is:

2π2θ=πarctan(mM)\frac{2\pi}{2\theta}=\frac{\pi}{\arctan\left({\sqrt{\dfrac mM}}\right)}

and its integer part.

When the mass ratio is 102(n1)10^{2(n-1)} , this becomes:

πarctan(102(n1))π10(n1)=10(n1)π\frac{\pi}{\arctan\left({\sqrt{10^{-2(n-1)}}}\right)}\fallingdotseq\frac{\pi}{10^{-(n-1)}}=10^{(n-1)}\pi

The number of collisions matches the first nn digits of π\pi !

Here, the approximation:

tanxx xarctanx\tan x\fallingdotseq x\quad\therefore\ x\fallingdotseq\arctan x

was used for x1x\ll 1 .

Original Paper

This phenomenon became widely known after Gregory Galperin published it in his 2003 paper "PLAYING POOL WITH π."

You can read it at the following URL: here (as of March 2025).

This article left some parts simplified, but the paper dives deeper into the validity of:

πarctan(10(n1))π10(n1)\frac{\pi}{\arctan\left(10^{-(n-1)}\right)}\fallingdotseq\frac{\pi}{10^{-(n-1)}}

and provides further insights.

SHARE
Images are created with the Desmos Graphing Calculator, used with permission from Desmos Studio PBC.
© 2024 UNS Physics. All Rights Reserved.