Archive for the ‘maths’ Category

Why 22/7 is a better π day than 3.14

March 15, 2013

On March 14th, i tweeted “Surely today is American pi day. I’ll be celebrating on July 22nd along with the rest of the sane date ordering world.

Apart from poking gentle fun at date ordering, i do have mathematical reasons to like 22/7 more. As i mentioned in a follow up tweet, 22/7 is a better approximation to π than 3.14 in an absolute sense – 22/7 is within 0.0013 of π, whereas 3.14 differs from π by just under 0.0016. I am swimming against the tide though – even Wikipedia calls 22/7 Pi Approximation Day, reserving Pi Day for the less accurate 3.14.

However, it was a reply from a friend pointing me at All Rational Approximations of Pi Are Useless which spurred me to action, in as much as blogging is action. Apart from the fact the provocative title is demonstrably false – i use a rational approximation of π (typically 3) all the time to estimate the volume of cake tins amongst other things, that article really deserves critiquing. The claim is that rational approximations are useless because they are no better than remembering decimal digits. Already we can see this depends on what you mean by better – 22/7 is better than 3.14 for the same number of digits, if by better you mean “closer in absolute value”. Ah, but his version of better is “correct digits when expanded in base 10” – in other words – a definition skewed towards base 10!

Let’s think it through a bit more – in base 10, we have 3.14 = 3 + 1/10 + 4/100, whereas π = 3 + 1/10 + 4/100 + 1/1000 + 5/10000 + …

So what is a fair comparison for 22/7 ? Surely its base 7! Here, 22/7 = 3 + 1/7, whereas π = 3 + 1/7 + 0/49 + 0/343 – 3/2041 + … . The denominators here are the powers of 7, and i’ll allowed myself “negative digits” to make clear how close the value is. So in fact, 22/7 gets three fractional base 7 digits right, for only one fractional part (1/7). The approximation 3.14 needed two fractional parts (1/10 and 4/100) to get, umm, 2 digits right … hopeless!

Another way to think about how good a rational approximation p/q is to an irrational a is to look at the absolute difference between p/q and a as a power of q. In symbols, find k so that |p/q – a| < 1/qk. One way to think about this is that this is what matching to k places base q means. Another way to think about it is that for any q you can get within 1/2q of a just by picking the p that makes p/q closest. It’s only for special q that you can do better. How does 22/7 do ? Well, the absolute difference between 22/7 and π is about 7 to the power 3.4 – which accords with our 3 digits right above. There are other great appromxiations, for example 333/106 gives just over 2 by this measure, and 355/113 gives 3.2 by this measure.

Back to the article – the author finds 355/106 by brute force, and then searches to 10,000 to no avail. There’s a good reason for that – the next great rational approximation of π is 103993/33102. Of course, the way to find these is not brute force, but by thinking. That is to say, by doing maths – specifically the theory of continued fractions. His brute force technique finds 99/70 as an approximation to √2 – again, this value is predicted by the theory of continued fractions – it takes about under 60 seconds of hand computation to find it once you have the theory – no need to throw the massive computation engine of Mathematica against a problem which has an elegant and well understood theory behind it.

A mathematician and friend who will remain nameless for now once suggested to me that Kepler would not have made his ground breaking work in planetary motion if he had had access to Mathematica. At the time, planetary motion was predicted via epicycles, an approximation technique. The claim is that it was the difficulty in getting better approximations via epicycles – the calculation just gets too hard – that drove Kepler to look for, and find, a correct theoretical solution that was also elegant and practical for computation. Had humanity had a computation engine capable of computing epicycles, it might have been generations before his inventions were made in the absence of their mother necessity.


I want to leave it there, but feel i must observe that i’m not against machine computation – far from it – computers have enabled fantastic progress and contributed significantly to human wellbeing. However, i do have a sympathy for the point of view that being required to find a theoretical solution in order to make practical progress can lead to discoveries that you miss if you’re overly focused on answers because you can find them easily. It’s the journey, not the destination.