This is at least my ninth year of writing about Pi Day—here is my post from 2010. Of course it's called Pi Day because the date, 3/14, is similar to the first three digits of pi (3.1415 …). At this point I've built up a whole library of fun things in honor of Pi Day.
Here is a new one. You can calculate the digits of pi using elastic collisions between two objects of different masses and a wall. Let me explain with this diagram.
There are two balls, A and B. Ball A has a larger mass and is initially moving. It collides with ball B such that ball B speeds up and ball A slows down just a little bit (this is a perfectly elastic collision). After this, ball B starts moving toward the wall and eventually bounces off it back toward ball A for another collision. This continues until ball A is moving away from the wall instead of toward it, and there are no longer any collisions.
Now for the pi part. If you know that the mass of ball A is 100 times greater than that of ball B, there will be 31 collisions. If the ratio of masses is 10,000 to 1, there will be 314 collisions. Yes, that is the first 3 digits of pi. If you had a mass ratio of 1 million to 1, you would get 3,141 collisions. (Remember the first few digits of pi are 3.1415 …) In general, if you want "d" digits of pi, then you need mass A divided by mass B to be 100 raised to the d-1 power.
This is not a very efficient method for calculating the digits of pi, but it seems to work. Here is a great video from 3Brown1Blue that explains this situation. Also, here is an older video from Numberphile that also goes over this problem.
It works. There are 31 collisions in this model—which are the first two digits of pi. What if you want three digits? You can try changing the masses, but it doesn't work. The problem is that when the large mass gets very close to the wall with the small mass in between them, things don't happen the way you intend. You can actually get the small mass interacting with both the wall and the big mass at the same time. Although this is realistic, it doesn't give us the best calculation of pi.
So, how do you fix it? I have a couple of options (and you can try this as your homework assignment). The first method would be to fix this numerical spring-based model. I think that if you change the time step (dt) and the spring constant (k) as the balls collide, you can get a better answer. Here's what you would do. As the balls get closer together, make a smaller time step and a larger spring constant. This would make the ball–ball collision more accurate in the cases where the smaller ball is getting crushed.
The next option is to just abandon the spring-based collision model. Instead, you could calculate the velocities of the balls analytically after each collision. Surprisingly, a one-dimensional, perfectly elastic collision isn't such a simple problem to solve. But don't worry, I did it for you and covered all the details. I even made a python function that takes the two objects with the starting velocities and returns the velocities after the collision. Yes, I really gave you a head start on this last problem. Maybe I will save this for next year's Pi Day.
- There's a way to keep parents from fleeing STEM careers
- The NSA open sourced a powerful cybersecurity tool
- Amazon's algorithms have curated a dystopian bookstore
- How Arrivo got Colorado to back this highway scheme
- Boss acting nicer recently? You may have VR to thank
- 👀 Looking for the latest gadgets? Check out our latest buying guides and best deals all year round
- 📩 Hungry for even more deep dives on your next favorite topic? Sign up for the Backchannel newsletter