How to measure pi with Raspberry Pi

Apparently, some people celebrate Pi Day by measuring pi with random objects. This was news to me when I stumbled across this fantastic post by Jim Hall, who had a go for this year’s Pi Day using a Raspberry Pi 3 Model B. Here’s the story of how Jim measured pi using a Raspberry Pi.

A pencil, some paper, and a Pi

All you need is graph paper, a ruler, a pen, and one of our tiny computers. This is very much a visual gag, so if you’re still confused, let me illustrate for you with words. Our boards have mounting holes, which you can see below: they’re the four holes, one in each corner, bordered in yellow. Jim has secured his Raspberry Pi to a piece of graph paper with a drawing pin through one of those holes. Sticking a pencil through another hole lets him swivel the board around on the paper, drawing a perfect circle.

measure pi with raspberry pi

As most people learned at school and subsequently dismissed from their memory in favour of more everyday facts like how to fold a fitted sheet, the value of pi is the ratio of the circumference of a circle to its diameter. So, now we’ve drawn our circle, we can measure its circumference and diameter and use them to calculate pi.

Smaller and smaller segments

However, it’s tricky to measure all the way around a circle, so Jim starts by drawing straight lines to divide it into smaller and smaller segments. We’ll end up with one that has bit of circle circumference that’s short enough to measure approximately as if it were a straight line. Using graph paper makes it easy to divide the circle into halves, quarters, and eighths. After that, some careful work with a ruler comes into play.

measure pi with raspberry pi
Lines and lines and lines and lines

The smallest wedge Jim was able to draw reasonably precisely was 1/128 of the circle. From there, he measured the segment’s 1/128 of the circumference as if it were a straight line: not perfectly accurate, but good enough for our purposes. He then multiplied this measurement by 128 to estimate the whole circumference, and measured the diameter easily along one of the lines through the circle’s centre. Divide the circumference by the diameter and you get your very own approximation of pi.

If this all sounds a bit too confusing to even attempt, don’t be deterred! Jim has written a step-by-step guide, making this maths challenge super accessible. There are only four steps. Give it go!

3 comments

Nicko avatar

If you really want a cool way to calculate pi with a Pi then you could do it with a camera module, some robotic Lego and the solution to the problem known as “Buffon’s needle problem”.

If you drop a stick of length l in a random orientation onto a surface that has parallel lines on it with spacing t (which needs to be greater than l) then the probability that the stick will cross one of the lines is (2.l)/(pi.t). If you do it enough times then you can estimate pi by counting how often the stick crosses the lines. Doing it by hand enough times to get a good estimate is pretty boring, but building a setup with some robotics and a camera to do it for you might be a lot of fun!

Daghankee avatar

Pis and pis and pis.

Ashley Whittaker avatar

exACTLY

Comments are closed