INFINITE Pi

by charlesglorioso in Workshop > Science

1358 Views, 6 Favorites, 0 Comments

INFINITE Pi

INFINITE Pi

Pi Day was invented at the Exploratorium in San Francisco in 1988 when Larry Shaw 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

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.

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 Bailey–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...

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. Full credit is due to Jurs 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.

Downloads

IT WORKS

INFINITE Pi
PIHex_startA.png
PiHex_100A.png
PiHex_500A.png
PiHex_1000A.png

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 Pi 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.

In the attached video, I have skipped ahead somewhat to show that effect without you having to get bored too.

I have also included stills at the start, 100th, 500th and 1000th digits for anyone with a really short attention span.

Because most of us are not used to seeing Pi in hexadecimal, here are the first 320 digits.

3.243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89452821E638D01377BE5466CF34E90C6CC0AC29B7C97C50DD3F84D5B5B54709179216D5D98979FB1BD1310BA698DFB5AC2FFD72DBD01ADFB7B8E1AFED6A267E96BA7C9045F12C7F9924A19947B3916CF70801F2E2858EFC16636920D871574E69A458FEA3F4933D7E0D95748F728EB658718BCD5882154AEE7B54A41DC25A59B5

And a link to the first 8366 digits.

https://gist.github.com/retrohacker/e5fff72b7b75ee...

NEXT STEPS

Should I get motivated, the logical next step would be to actually code one of the decimal solutions for StreetWriter to print. It will likely be less infinite.