One million digits of π

Spring 2020 | Made with p5.js

100 digits of pi

Animations of lines drawing

1000 digits of pi

6000 digits of pi

I was doing some calculus homework in the spring of 2020, and we were using the value π (pi) a lot. A question came to mind:

What would a “square spiral” of π look like?

For example, the first digits after the decimal place are 1-4-1. If you were to walk, you would walk 1 unit forward, turn right, walk 4 units forward, turn right, etc.

I had always meant to learn how to make something with p5.js, and got to work making this prototype over reading week. Since I knew this would be a project I would want to quickly change the outputs on, I constructed it so there are user-friendly settings at the top of the code, to quickly change parameters for the number of digits to use, size, exporting images, etc. The animation only displays in the browser window, so it calculates the entire size of the finished image and scales it so you can see the entire thing.

The most interesting part of this project was showing it to people. Every person that saw this smiled and immediately came up with more questions, “what if you made it show [x] instead?” which was probably the highest amount of non-math people I have seen get excited about the digits of pi.

Future plans include a display on Pi Day (March 14) for the math department, a high-quality print, cleaning up the code a bit, and adding more parameters (e.g. change colour every time three digits in a row are the same).

Even those who can’t code can play around with this!

1 million digits of pi

This took 4 hours to generate!