Documentation for calc-pi-x86-64-asm
Frequently Asked Questions
Why did you write this program?
What is your largest pi calculation?
Has the program been formally tested?
Does the program have automated testing?
Why does the program appear to hang?
Can this be used to set any speed records?
Do high precision pi calculations matter?

Q: Why did you write this program?

A: Because it was interesting. My hope is that it may inspire others to try writing a program of their own.

My primary goal in writing this program was to learn some 64 bit assembly language. In 1983, I wrote a 6502 assembly program to calculate pi to 600 digits on an Apple []. For me, it was a nostalgic revisit to the past, but with a much faster computer.

Q: What is your largest pi calculation?

In February 2015, I used this program to calculate pi to 50,000,000 digits. The calculation took 28 days 6 hours and 27 minutes. It was run on a Dell XPS with i7-4790 desktop circa 2014.

Q: Has the program been formally tested?

A: No formal testing or validation has been performed.

Q: Does the program have automated testing?

A: No automated tests have been written.

In the case of more complex functions, try a reciprocal function. For example, to test square root of 2, square the result and see if it returns to 2.00000...
In the case of pi, sin(π/6)=1/2 can be used as a simple test. However, calculation of sin(π/6) may take a lot more time than the original calculation of pi, so reduced accuracy may be needed. It would look like this:
Op Code: c.pi
Op Code: 6
Op Code: /
Op Code: f.sin

pi        +3.14159265358979323846264338327950288419716939937510 E-0
pi/6      +5.23598775598298873077107230546583814032861566562517 E-0
sin(pi/6) +5.00000000000000000000000000000000000000000000000000 E-1

Q: Why does the program appear to hang?

A: This is a complex question. How do you know it is hung? Some calculations take a long time to complete. Given my limited programming experience, it may simply be a software bug.

One thing to watch for is very large or very small exponents when they appear in the calculator preview. The base-10 conversions can take excessive time to compute. To avoid this. Preview can be turned off with the "quiet" command to prevent printing the preview register values.

The other suggestion is to try a calculation at lower accuracy to make sure it works properly, then increase accuracy in steps while keeping track of time needed to scale the calculation to larger accuracy. Time needed to scale calculation is certainly not linear and the time can increase quite quickly. (see
tutorial)

Q: Can this be used to set any speed records?

A: No, highly unlikely. This program uses conventional binary arithmetic functions for multiplication and division. This involves classic binary methods of shifting bits left or right combined with addition and subtraction. These methods do not scale well past about a million digits. The current record for pi is 50 trillion digits. (over a million times more accuracy than the capabilities of this program)

Other programs use more abstract methods for multiplication and division typically involving Fast Fourier Transforms (FFT) for ultra fast multiplication. The alternate FFT type calculation can be multi-tasked across multiple cores. This program is a single thread application. (see
links and references)

Q: Do high precision pi calculations matter?

A: Perhaps not

First consider something really big. The estimated diameter of the observable universe is about 93 billion light years (9.3x10+10 ly). A light year is defined as 9460730472580800 meters (9.46x10+15 m). Now think of something really small. The size of a proton is small, on the order of 0.8 fm (femtometer = 10-15 meters). Now compare the two. The size of the observable universe would be (9.3x10+10 ly)*(9.45x10+15 m/ly)(1x10+15 fm/m) = 8.8x10+41 fm). Ok, rounding this off to orders of magnitude, lets approximate the size of a proton to be 1 femtometer and size of the observable universe to be 10+42 femtometers. This means it would take 42 digits to write the size of the observable universe in femtometers as in integer. The formula for the circumference of a circle is (Circumference) = (π) x (Diameter).

Thus, having π to 42 significant digits would be roughly sufficient to calculate the circumference of a circle the size of the observable universe to the accuracy of the size of a proton.