1,000,000 Digits Isn’t Nearly Enough: A Few Thoughts on π

1,000,000 Digits Isn’t Nearly Enough: A Few Thoughts on π

A few years ago, I sat down at my computer intending to write a short essay on one of my favorite subjects, π.  I thought I would start by computing π to as many digits as possible.  It was at that point that I realized that I had never computed π, and I had no idea how to do it.  I knew about the old methods, like those of people like Archimedes, but I had no idea how to compute the digits using modern methods and a computer.  As odd as it sounds, it simply had never come up.  I was truly stunned as I sat motionless in my chair, unsure of what I was supposed to do.  It never occurred to me that if I were tasked with computing π, I would have no idea where to start.  It really was a strange and confusing feeling.

After I stopped rolling around on the floor (I couldn’t quite get into the fetal position), I started my research into how to compute π.  I quickly found that the process is not straightforward, and it certainly is not trivial.  I eventually found a freeware program called y-cruncher, which will compute π to n digits, depending entirely on the amount of RAM in your computer.  This was also a surprise to me.  I wasn’t quite sure what RAM had to do with the calculation then, but I have a better idea now.  All the previous numbers in π must be loaded into memory because they are used to derive the next digit, and the next, and the next.  Who knew?  I suspected that something like this might be the case, but I was surprised that hard drive space wasn’t used instead of RAM.

I loaded up the y-cruncher program on the killer computer I built a few weeks ago and looked over the settings.  After it scanned my system, the clever code told me that I could compute 5 billion digits of π with no problem.  Of course, I took the program up on its offer.  Before I knew what had happened, I had a file on my hard drive that contained 5 billion digits of π.  Amazing.  As I tried to load the 4.8GB file into a text editor, I ran into another unexpected problem.

Have you ever tried to open a large text document?  I mean a very large text document, say one with 5 billion digits?  It is not a simple thing.  Notepad won’t do it; Word can’t handle it, and on and on and on.  A developer wrote a program for Windows specifically for large files called Notepad++, but it wouldn’t open it either.  Fortunately, I am very familiar with a suite of programs called LibreOffice.  It mimics Microsoft Office and, best of all, the programs are free.  LibreOffice Writer has been my preferred text editor for years.  For now, the critical point is that LibreOffice claims not to have a file size limit.

I opened LibreOffice 6.2 and had a go at loading my giant file.  The file is so large that it crashed my computer, I mean the whole thing.  The program ran for hours, chugging along, trying its best to load the entire file.  It was taking so long that I went to the gym.  When I came back, the file was still loading.  I got something to eat, and when I came back to my computer room, I found that the system had crashed.

Not one to give up that easily, I tried loading it again.  This time it just crashed the LibreOffice program.  Progress!  Then it crashed again.  As of now, the file has processed about 140,000,000 characters out of the 5 billion total.  Will the file open?  I am not sure, but even if it does fully open, I doubt I will be able to search through it.  It is just too big.

At this moment, LibreOffice is using over 18 GBs of the 32 GBs of spiffy new RAM I installed in my new system.  The program is plugging along.  It has processed over 250,000,000 characters.  Sure, that is a lot of numbers, but it is only a small fraction of the total.

The program has been trying to open the file for about a day now.  After numerous crashes, it still has a long way to go.  I am writing this post while LibreOffice is working hard to fulfill my request.   It has over 625,000,000 characters open, we have reached a milestone, it is over 10% of the total.  The font is 10 point Liberation Mono, the page count is about 11,000.

Strangely, LibreOffice is splitting the digits into words.  Every 10,000 digits of π are counted as one word.  How odd.  I have no idea why it is doing that.  Apparently, no one else does either.  I have been doing some searching, and it appears I am the first person to ask such a question.  Everyone else probably instantly went to the proper program, the one known by scientists and mathematicians to be the go-to program for such nonsense.  I have been out of that loop for a long time, I stopped getting the flyers and emails years ago…

After a bunch of time and effort, I managed to get over 1 billion of the digits to appear in LibreOffice.  That was the limit, my system would not allow it to load more. Why?  Once again, we are back to the limitations my new computer has due to the amount of RAM I installed.  32 GBs, which is overkill for almost any system, simply falls short in this instance.  LibreOffice used it all up and wanted more.  The program crashed one final time, and then I gave up.

In the future, I will load a file with hundreds of millions of digits, or maybe even a billion, and see what I can find.  I am sure there is some interesting stuff in there.  Do we get 20 consecutive zeroes?  How about forty 9s in a row?  Is my phone number with area code in there?  How about my social security number?  In due time, we should have answers to these questions and more.

 

 

 

 

Posted on

Leave a Reply

Your email address will not be published. Required fields are marked *