Why do colliding blocks compute pi?
Last lesson I left you with a puzzle. The setup involves two sliding blocks in a perfectly idealized world where there’s no friction, and all collisions are perfectly elastic, meaning no energy is lost.
One block is sent towards another, smaller one, which starts off stationary, and there’s a wall behind it so that the small one bounces back and forth until it redirects the big block’s momentum enough to outpace it away from the wall.
If that first block has a mass which is some power of 100 times the mass of the second, for example 1,000,000 times as much, an insanely surprising fact pops out: The total number of collisions has the same starting digits as ! In this example, that’s 3,141 collisions.
If the first block has one trillion times the mass of the second, there would be 3,141,592 collisions, almost all of which happen in one huge burst.
So why does this happen?! Why should show up in such an unexpected place, and in such an unexpected manner?
First and foremost, this is a lesson about using a phase space, also commonly called a configuration space, to solve problems. So rest assured that you’re not just learning about an esoteric algorithm for . The tactic here is core to many other fields.
Conservation of Energy and Momentum
To start, when the blocks collide, how do you figure out their velocities after the collision? The key is to use the conservation of energy and the conservation of momentum.
Let’s call their masses and , and their velocities and . Those velocities will be the variables changing throughout the process.
At any given moment, the total kinetic energy is . Even though and will change as the blocks get bumped around, the value of this expression must remain constant.
The total momentum of the two blocks is . This also remains constant when the blocks hit each other, but it can change as the second block bounces off the wall. In reality, that second block would transfer its momentum to the wall during this collision. Again, we’re being idealistic, thinking of the wall as having infinite mass, so such a momentum transfer won’t actually move the wall.
So we’ve got two equations and two unknowns. To put these to use, let’s try drawing a picture to represent the equations.
Velocity Phase Space
You might start by focusing on this energy equation. Since and are changing, maybe you think to represent this equation on a coordinate plane where the -coordinate represents , and the -coordinate represents . So individual points on this plane encode the pair of velocities of our block.
Phase Space Transitions
On our phase diagram, the graph of the energy equation forms the shape of an ellipse. Each point on this ellipse gives you a pair of velocities that satisfy the conservation of energy equation, meaning all points of this ellipse correspond to the same total kinetic energy.
In fact, let’s actually change our coordinates a little to make this a perfect circle, since we know we’re on a hunt for . Instead of having the x-coordinate represent , let it be , which for the example shown stretches our figure in the x-direction by . Likewise, have the y-coordinate represent .
That way, when you look at this conservation of energy equation, it’s saying , which is the equation for a circle. (The radius of the circle depends on the total kinetic energy.)
At the beginning, when the first block is sliding to the left and the second one is stationary, we are at the leftmost point on the circle, where the -coordinate is negative and the -coordinate is . But what about after the first collision? How do we know what happens? Conservation of energy tells us we must jump to some other point on this circle. But which one?
Well, use the conservation of momentum! This tells us that before and after a collision, the value must stay constant.
In our rescaled coordinates, we can express the conservation of momentum as the expression , which is the equation for a line with the slope . The position of the line depends on what that constant momentum is. But we know it must pass through our first point, which locks us into place.
Just to be clear what all this is saying: All other pairs of velocities which would give the same momentum live on the line, just as all other pairs of velocities which give the same energy live on our circle.
So notice, these two constraints narrow our options down to just one other point that we could jump to:
And it should make sense that it’s something where the -coordinate gets a little less negative and the -coordinate becomes negative, because that corresponds to our big block slowing down a little while the little block zooms off towards the wall.
When the second block bounces off the wall, its speed stays the same, but its velocity will go from negative to positive. In the diagram, this corresponds to reflecting about the -axis, since the -coordinate gets multiplied by .
Then again, the next collision corresponds to a jump along a line of slope , since staying on such a line is what conservation of momentum looks like in this diagram.
And from here, you can fill in the rest for how block collisions correspond to hopping around the circle in our picture.
We keep going like this until we know that the blocks will never touch again. This happens when both velocities are positive (which means the blocks are both moving to the right), and the big block is moving faster than the small one. That corresponds to this triangular region of the diagram:
So in our process, we keep bouncing until we land in that region.
The Power of Phase Diagrams
What we’ve drawn here is called a “phase diagram”, which is a simple but powerful idea in math where you encode the state of some system (in this case the velocities of our sliding blocks) as a single point in some abstract space.
What’s powerful here is that it turns questions about dynamics into questions about geometry. In this case, the dynamical idea of all pairs of velocities that conserve energy corresponds to the geometric object of a circle, and counting the total number of collisions turns into counting the number of hops along these lines, alternating between vertical and diagonal.
But our question remains. Why is it that when the mass ratio is a power of 100, the number of steps shows the digits of ?
Well, if you stare at this picture, maybe, just maybe, you might notice that all the arc-lengths between the points of this circle seem to be about the same.
It’s not immediately obvious that this should be true. But if it is, it means that computing the value of that one arc length should be enough to figure out how many collisions it takes to get around the circle to the end zone.
The key here is to use the ever-helpful inscribed angle theorem, which says that whenever you form an angle using three points on a circle (, , and ), it will be exactly half the angle formed by , the circle’s center, and .
can be anywhere on this circle, except in that arc between and , and this fact will be true.
So now look at our phase space, and focus specifically on these three points:
Remember, the vertical hop corresponds to the small block bouncing off the wall, and the second hop along a slope of corresponds to a momentum-conserving block collision.
Let’s call the angle between these lines . Then using the inscribed angle theorem, the arc length between these bottom two points will be (measured in radians).
Notice, since all the diagonal momentum lines are parallel, the same reasoning means that all of these arcs must also be .
So each collision creates a new arc which covers another radians of the circle.
We stop once we’re in the endzone, which corresponds to both blocks moving to the right, with the smaller one going slower. But you can also think of this as stopping at the point when adding another arc of would overlap with a previous one.
In other words, the blocks will collide however many times you can add to itself before it covers more than radians.
Or, simplifying things a little, we want to know the largest integer multiple of that doesn’t surpass .
For example, if was 0.01 radians, then multiplying by 314 would put you a little less than , but multiplying by 315 would bring you over .
So the answer would be 314, meaning that if our mass ratio were one such that , the blocks would collide 314 times.
Computing Theta ()
You know what we need to do now. Let’s go ahead and actually compute the value , say, when the mass ratio is 100 : 1. Remember that the rise-over-run slope of this constant momentum line is , which in the example image below, where the large block has a mass of 100kg, is a slope of -10.
That would mean the tangent of the angle , opposite over adjacent, is the run over the negative rise, which is 1/10 in this example. So .
In general, .
If you go and plug these into a calculator, you’ll notice that the arctan of each small value is quite close to the value itself.
For example, , corresponding to a big mass of 10,000 kilograms, is extremely close to 1/100.
In fact, it’s so close that for the sake of our central question, it might as well be 1/100. That is, analogous to what we saw a moment ago, adding this to itself 314 times won’t surpass , but the 315th time would.
Remember, all of this is just a way of counting how many jumps on the phase diagram it takes to get to the end zone, which is really just a way of counting how many times the blocks collide. So this result, 314, explains why a mass ratio of 10,000 gives 314 collisions.
Likewise, a mass ratio of 1,000,000 : 1 will give an angle of in our diagram. This is extremely close to 1/1,000. And again, if we ask about the largest integer multiple of this that doesn’t surpass , it’s the same as it would be for the precise value of 1/1,000. Namely, 3,141.
These are the first four digits of , because that is by definition what the digits of mean. And this explains why with a mass ratio of 1,000,000, the number of collisions is 3,141.
All this relies on the hope that the inverse tangent of a small value is sufficiently close to the value itself, which is another way of saying that the tangent of a small value is approximately that value.
Intuitively, there’s a nice reason why this is true. Looking at a unit circle, the tangent of any given angle is the height of this little triangle divided by its width.
When that angle is really small, the width is basically 1, and the height is basically the same as the arc length along the circle, which by definition is .
To be more precise about it, the Taylor series expansion of shows that this approximation will only have a cubic error term. So for example, differs from by something on the order of 1/1,000,000.
So even if we consider 314 steps with this angle, the error between the actual value of and the approximation of 0.01 won’t have a chance to accumulate enough to be significant.
Let’s zoom out and sum up: When blocks collide, you can figure out how their velocities change by slicing a line through a circle in a velocity phase diagram, with each curve representing a conservation law.
Most notably, the conservation of energy plants the circular seed that ultimately blossoms into the we find in the final count.
Specifically, due to some inscribed angle geometry, the points we hit on this circle are spaced out evenly, separated by the angle we were calling .
This lets us rephrase the question of counting collisions as instead asking how many times we must add to itself before it surpasses .
If looks like 0.001, the answer to that question has the same first digits as pi.
And is so well approximated by for small values that when the mass ratio is some power of 100, is sufficiently close to to give the same final count.
I’ll emphasize again what this phase space allowed us to do, because this is a lesson useful for all sorts of math, like differential equations, chaos theory, and other flavors of dynamics: By representing the relevant state of your system as a single point in an abstract space, it lets you translate problems of dynamics into problems of geometry.
I repeat myself because I don’t want you to come away just remembering a neat puzzle where shows up unexpectedly; I want you to think of this surprise appearance as a distilled remnant of the deeper relationship at play.
And if this solution leaves you feeling satisfied, it shouldn’t. Because there is another perspective, more clever and pretty than this one, due to Galperin in the original paper on this phenomenon, which invites us to draw a striking parallel between the dynamics of these blocks, and that of a beam of light bouncing between two mirrors.
Trust me, I’ve saved the best for last on this topic, so I hope to see you again in the next lesson.
Special thanks to those below for supporting the original video behind this post, and to current patrons for funding ongoing projects. If you find these lessons valuable, consider joining.