INFINITE Pi
Introduction: INFINITE Pi
Pi Day was invented at the Exploratorium in San Francisco in 1988 when <PERSON> came to work on March 14 with several pies that he shared with staff at 1:59 in the afternoon. pi (π) = 3.14159.
https://www.exploratorium.edu/pi
So, Pi Day is coming and with it, an Instructables contest.
In previous years I have done various projects to celebrate Pi Day, including using StreetWriter to write Pi to 300 places at the Exploratorium.
Unfortunately, StreetWriter itself was the subject of a past Instructable, so I couldn't enter it into this contest.
Supplies
One StreetWriter
https://www.instructables.com/StreetWriter/
Step 1: THE IDEA
OK, I can't enter StreetWriter into the contest, but I can use it as a platform or, if you prefer, as a printer.
StreetWriter's normal mode is to fetch text from a file on an SDCard, and print out the chracters one at a time in water on the pavement. The Pi day video above used a text file containing Pi to 300 places.
It takes about 100 linear feet to print it all.
This year's idea is to see if it is possible to use the Arduino Uno that controls StreetWriter to compute the digits of Pi on the fly and print them one at a time as they are computed, rather than just reading them from a file.
This approach might allow StreetWriter to produce INFINITE Pi.
Step 2: THE RESEARCH
I am a strong believer in building on the work of others, rather than starting from scratch, so the next step is research. What has been done to compute Pi one digit at a time, and how has that been computer coded?
On the first question, I found it to be an amazingly hot topic, with the latest math breakthroughs being as recently as 1995-1996, the <PERSON>–Borwein–Plouffe formula.
https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwe...
As a result of the recent interest in the topic, many people have created computer code to implement this and other approaches to the problem. One example showing multiple languages and approaches is at:
https://rosettacode.org/wiki/Pi#Python
What I learned from the research is that computing each Pi digit requires access to all previous digits, and increasingly significant computer memory, and computer power. Not a likely candidate for INFINITE Pi from an Uno.
However, there is a way!! It turns out that if you compute Pi in hexadecimal, rather than decimal, each digit can be computed without reference to any prior digits, and the computation is fairly straightforward.
https://math.hmc.edu/funfacts/finding-the-n-th-dig...
Step 3: THE CODE
The revelation that it might be possible to compute Pi in hexadecimal on an Uno, led to the next step.
Has someone already coded that?
Yep!!
https://forum.arduino.cc/index.php?topic=478781.30
And here is the code. 974
Full credit is due to <PERSON> at the forum link above for this code.
His program runs on an Uno and allows about 4100 digits of Pi to be computed within the 16 bit resolution of the Uno. While this is not truly INFINITE Pi, it is close enough for engineering purposes.
In fact, it is possible to reset the computational range in the program and then run it again for digits above 4100 in order to keep going. Try it.
The program, computes a digit, prints it and then computes another. It continues until all the digits in the requested range have been printed and then prints out the total time of the task. Neat!!
When you run the program, you will notice that after a bit, digits start appearing more slowly.
This should produce a nice effect on StreetWriter as the digits begin to appear with more spacing between them as it prints along.
Step 4: IT WORKS
So, the task is to take StreetWriter code, and merge in Jurs' code so that instead of fetching digits from a file, StreetWriter computes a digit of <PERSON> then prints it on the pavement, then computes the next digit of Pi and prints that.
It continues to do this until it runs out of water or space to write, or until I get bored.
And as it writes digits of Pi in hexadecimal. and as the time required to compute each digit increases, the spacing between digits on the pavement increases. 125