We do these things, not because they are difficult, but because they are ridiculous
– Matt Parker, probably
Matt Parker is going to the moon. I mean, not literally. Everyone’s favourite Stand-Up Mathematician is the sort of person who’s more likely to go to hyperspace than to space. However, when Matt was approached to do “something ridiculous” with spare computing power on a lunar rover, there was only ever going to be one outcome: an attempt to calculate \( \pi \) on the moon.
But… why?
That is an excellent question, beautifully presented. I compliment you for asking it. Next!
Moon-te Carlo
Because it’s important to do ridiculous things properly — there’s no point in going to the moon and doing calculations you could do on Earth — Matt made the decision to approximate \( \pi \) using the readings from the rover as a source of randomness for a Monte Carlo calculation.
Monte Carlo methods are typically used to work things out when it’s too difficult or too boring to do them analytically. While there were some earlier randomised calculation methods — Buffon’s needle, for example — the first real Monte Carlo experiment was done by Stanisław Ulam while recovering from an illness. Ulam wondered how likely it was that a game of solitaire would come out successfully and, rather than calculate it properly, decided to play a hundred games and count how many they won. It was a short step from there to the atomic bomb.
Matt showed the standard Monte Carlo approach to calculating \( \pi \) in the video announcing the moon \( \pi \) project — it’s often used as a simple example when introducing the idea. If you put a circular dartboard in a square box that just fits it, and threw darts at the box, assuming you were equally likely to hit any point in the box, each dart would have a probability of \( \frac{\pi}{4} \) of hitting the dartboard. If you threw 100 darts and 80 of them hit the board, you would conclude that \( \frac{\pi}{4} \approx 0.8 \) and that \( \pi \approx 3.2 \). Throwing more darts should get you a better estimate — although rather slowly. If you throw \( N \) darts, the standard error of your probability is proportional to \( N^{-\frac{1}{2}} \), which means becoming half as inaccurate requires four times as many darts.

Holding out for a Hero
Matt famously thinks Heron’s formula is one of trigonometry’s most remarkable results. It’s been known to make Matt extremely emotional. So, naturally, my first thought was “I bet an approach based on Heron’s formula could converge more quickly.”
And it could! The approach entailed starting with a right-angled triangle with legs of length one inside a unit circle in the first quadrant. It would then pick a random x-coordinate between 0 and 1, figure out the corresponding point on the arc, and add a triangle based on the two adjacent points. Here’s the code. It converges to several decimal places within 10,000 iterations.



But that’s not really Monte Carlo, now, is it?
That is an excellent question, beautifully presented. I complime… what do you mean, I need to answer it? Who’s writing… OK. Fine. Sheesh.
You’re right, this isn’t a traditional Monte Carlo method. While it uses random points, it doesn’t use them to generate a probability. I do still maintain that it’s technically a Monte Carlo method, using a very involved adaptive weighting function, but I take the point.
What about proper Monte Carlo methods?
A less sophisticated (but still significantly more efficient than the integration-by-darts method) approach is to use the fact that \( x^2 + y^2 = 1 \) on the unit circle. If you pick an \( x \) value at random, you can immediately calculate the probability of a random \( y \) value giving a point inside the circle — it’s \( \sqrt{1- x^2} \). Rather than sample and add 1 or 0 to your total to approximate the probability, why not just add the probability? This converges very nicely.

I’m not officially allowed to reveal that the reason for my interest in calculating \( \pi \) on the moon is that I’m helping to design Matt’s experiment, or that my codename is FizzBuzz Aldrin. (Is that lede sufficiently buried? Excellent.) And I’m definitely not officially allowed to say what we’re actually doing, because I imagine Matt will want to do a video about it.
However, I can say that the method above is equivalent to the fact that the expected distance between a point on the unit circle and an axis — any axis — is \( \frac{\pi}{4} \). By extension, using the magical incantation “SYMMETRY!” and a magisterial wave of the hand, it turns out that any point on a unit sphere is — on average — \( \frac{\pi}{4} \) from any axis of the sphere. That’s a fact that could be exploited, just to pick a random example, by a simulated rover making random moves on the surface in a sort of random moonwalk.
It would take small steps for a rover, and giant LOOPs for Matt-kind.
- You can donate to Matt’s kickstarter here, if you’re so inclined. At the time of writing, they’ve raised well over a quarter of a million pounds towards their £75k target, so I’m looking forward to them launching their own space mission before long.
- If you’re a teacher who wants to be involved, you can sign up here. Get the kiddos to estimate \( \pi \) by hand and they’ll get (I understand) a certificate, possibly their own value of lunar \( \pi \), and their name in a text file that goes to the moon. [Edited 2025-06-26 for formatting and to clarify that the personal \( \pi \) value is not guaranteed.]