Category Archives: math

Post Pi Day Post

Well, Pi Day has come and gone, so what’s left for a Pi nerd to look forward to? Tau Day? Heresy! That other Pi Day, July 22nd (22/7)? Pa-lease. Accept the fact that it’s OK to talk about Pi when it’s not Pi Day? Sure, why not?

A random thought caught my attention after I posted my article Pi Day Rematch: Apple II vs. HP-41C that suggested that I could have been more fair to the HP-41C by highlighting some of it’s obvious strengths, e.g. portability and energy efficiency. And, I got a lot of personal emails expressing that thought as well. (In my defense, it wasn’t I that compared the two in the first place–some people are just too serious :-).

Lets be honest, was there any doubt in anybody’s mind that a late ’70s pocket calculator could best an Apple II in a 1000 digit drag race? Or ENIAC for that matter? However, what if, you had to compute Pi within a fixed energy budget of 1 Wh or on a flight to Paris? Which would you choose?


Energy Efficiency

I remember a time when the energy utilization of home computing equipment was never given a second thought other than, “turn it off before you go to bed.” Fast-forward to today: Our consumer electronics have a plethora of energy saving options, e.g. my computer suspends when not in use, my external drives spin down when unused, my fridge has a vacation mode, all my LCD TVs have a green mode (my Sharp rates your energy efficiency with green leaves (0-5)), my electric utility company wants to control my air conditioner, etc… Today, energy utilization matters. So, lets pretend it mattered in 1980. You’ve got a 1 Wh budget to compute Pi to 1000 digits. What do you use, the Apple II or the HP-41C?

The community members of comp.sys.apple2 and MoHPC were kind enough to measure the power consumption of the Apple II and HP-41C and reported 24 Watts and 72 mW respectively.

The best Apple II and HP-41C times reported by my tests were 194 seconds and 08:21:57 (30,117 seconds) respectively making the energy used 24W*(194/3600) = 1.29 Wh and 0.072W*(30117/3600) = 0.60 Wh.

It should be obvious why. The Apple II, as a general-purpose computer, has a lot of unused powered components where as the HP-41C, while still a computer, is a limited-purpose device for specific computational tasks. To further handicap the Apple II, the Apple II has to convert from AC to DC. The drop in efficiency for retro tech could be as high as 50%. However, none of that takes away from the fact that for computational intensive tasks, at least those involving Pi, the HP-41C is more efficient.

The table below contains all the benchmarks that I ran with their estimated energy usage. The original Apple Pi uses more than 1000 times the energy of the HP-41C; a whopping 1KWh!


Platform
Code
Base Time(s) Watts Wh
HP-41C
RPN
105 30117 0.072 0.60
Apple II
Assembly
10 194 24 1.29
Apple II
MAF
216 1496 24 9.97
Apple II
cc65 2.13
216 1514 24 10.09
Apple II
Aztec C
216 2180 24 14.53
Apple II
Integer BASIC
10 150410 24 1002.73


Portability

The HP-41C is a remarkable late-’70s gadget. It has a display, an alphanumeric keyboard, a file system, removable storage, expandable memory, and sports general purpose programmable I/O (via HP-IL); all the earmarks of a ’70s computer, and it fits in your pocket.

Lets say that you are traveling non-stop to Paris from my hometown, and in the 10-11 Hr journey you need to compute at least 704 digits of Pi so that you can personally confirm that the digits of Pi in the Palais de la Découverte “π Room”, that were originally incorrect until corrected in 1945, are actually correct[1, pp. 50].

No contest here. There isn’t a pocket-able Apple II product unless you count emulation on the iPhone/iPad. What you need is a very capable, energy efficient, pocket computer–the HP-41C. 704 digits in < 10-11 Hr? No problem, it'd take a little over 4 hours. You can use the rest of your time to compute e. Too bad there isn’t an “e room”, or is there?


The “π Room”

No, I didn’t compute Pi on my way to Paris, but just knowing that I could have with my 41CX in my pocket reassured me. :-)

All Pi nerds (make that all nerds) that find themselves in Paris should make the pilgrimage to Palais de la Découverte to visit the only “π Room” in existence (or so I have been able to find). This science museum is a short walk from the Eiffel Tower, so if you are willing to spend the time to see a marvel of French engineering, then you might as well go see the most fabulous piece of calculation ever performed[2, pp.406] by an Englishman.


William Shanks of England

William Shanks (1812 – 1882) was an amateur mathematician and IMHO is still the king of all Pi nerds. William Shanks computed Pi to 707 places over a 15+ year period with nothing but pen, paper, and his wits[2, pp. 305]. A stunning achievement and the last computation of its kind, however, there is an error, can you see it?


Proceedings of the Royal Society of London, 21 (1873), 319.

An example of a mechanical desk calculator available in 1945

No? Don’t worry, nobody else did either until 72 years later when another Englishman, D. F. Ferguson, in 1945 using a mechanical desk calculator checked Shanks’ results and discovered that Shanks was only correct up to digit 527[2, pp. 592]. Fortunately (for Shanks), Shanks never knew of his error. He passed away with the belief that he had achieved the unachievable.

Ferguson’s Pi were last non-digital calculations[2, pp. 627]; the era of supermen manually computing Pi ended in 1949 when ENIAC cranked out 2047 digits over a three-day holiday weekend[2, pp. 277].

Shanks’ Pi with corrections:


Value of π = 3 ·

· 
1
4
1
5
9
  
2
6
5
3
5
  
8
9
7
9
3
  
2
3
8
4
6
  
2
6
4
3
3
  
8
3
2
7
9
  
5
0
2
8
8
  
4
1
9
7
1
  
6
9
3
9
9
  
3
7
5
1
0
  
5
8
2
0
9
  
7
4
9
4
4
5
9
2
3
0
  
7
8
1
6
4
  
0
6
2
8
6
  
2
0
8
9
9
  
8
6
2
8
0
  
3
4
8
2
5
  
3
4
2
1
1
  
7
0
6
7
9
  
8
2
1
4
8
  
0
8
6
5
1
  
3
2
8
2
3
  
0
6
6
4
7
0
9
3
8
4
  
4
6
0
9
5
  
5
0
5
8
2
  
2
3
1
7
2
  
5
3
5
9
4
  
0
8
1
2
8
  
4
8
1
1
1
  
7
4
5
0
2
  
8
4
1
0
2
  
7
0
1
9
3
  
8
5
2
1
1
  
0
5
5
5
9
6
4
4
6
2
  
2
9
4
8
9
  
5
4
9
3
0
  
3
8
1
9
6
  
4
4
2
8
8
  
1
0
9
7
5
  
6
6
5
9
3
  
3
4
4
6
1
  
2
8
4
7
5
  
6
4
8
2
3
  
3
7
8
6
7
  
8
3
1
6
5
2
7
1
2
0
  
1
9
0
9
1
  
4
5
6
4
8
  
5
6
6
9
2
  
3
4
6
0
3
  
4
8
6
1
0
  
4
5
4
3
2
  
6
6
4
8
2
  
1
3
3
9
3
  
6
0
7
2
6
  
0
2
4
9
1
  
4
1
2
7
3
7
2
4
5
8
  
7
0
0
6
6
  
0
6
3
1
5
  
5
8
8
1
7
  
4
8
8
1
5
  
2
0
9
2
0
  
9
6
2
8
2
  
9
2
5
4
0
  
9
1
7
1
5
  
3
6
4
3
6
  
7
8
9
2
5
  
9
0
3
6
0
0
1
1
3
3
  
0
5
3
0
5
  
4
8
8
2
0
  
4
6
6
5
2
  
1
3
8
4
1
  
4
6
9
5
1
  
9
4
1
5
1
  
1
6
0
9
4
  
3
3
0
5
7
  
2
7
0
3
6
  
5
7
5
9
5
  
9
1
9
5
3
0
9
2
1
8
  
6
1
1
7
3
  
8
1
9
3
2
  
6
1
1
7
9
  
3
1
0
5
1
  
1
8
5
4
8
  
0
7
4
4
6
  
2
3
7
9
9
  
6
2
7
4
9
  
5
6
7
3
5
  
1
8
8
5
7
  
5
2
7
2
4
8
9
1
2
2
  
7
9
3
8
1
  
8
3
0
1
1
  
9
4
9
1
2
  
9
8
3
3
6
  
7
3
3
6
2
  
4
4
0
6
5
  
6
6
4
3
0
  
8
6
0
2
1
  
3
9
4
9
4
  
6
3
9
5
2
  
2
4
7
3
7
1
9
0
7
0
  
2
1
7
9
8
  
6
0
9
4
3
  
7
0
2
7
7
  
0
5
3
9
2
  
1
7
1
7
6
  
2
9
3
1
7
  
6
7
5
2
3
  
8
4
6
7
4
  
8
1
8
4
6
  
7
6
6
9
4
  
0
5
1
3
2
0
0
0
5
6
  
8
1
2
7
1
  
4
5
2
6
3
  
5
6
0
8
2
  
7
7
8
5
7
  
7
1
3
4
2
  
7
5
7
7
8
  
9
6
0
9
1
  
7
3
6
3
7
  
1
7
8
7
2
  
1
4
6
8
4
  
4
0
9
0
1
2
2
4
9
5
  
3
4
3
0
1
  
4
6
5
4
9
  
5
8
5
3
7
  
1
0
5
0
7
  
9
2
2
7
9
  
6
8
9
2
5
  
8
9
2
3
5
  
4
2
0
1
9
  
9
6
  &c.
  April 14, 2011.


The “π Room” Corrected

Unfortunately, I have been unable to find any pictures of the original 1937 “π Room”. I would have really liked to have seen a before and after. Sadly, I can only give you my picture of the after:

8 6 0 2 1 3 9 4 … Yep, they fixed it.


One More Thing

There is a bonus for the retro nerd at the Palais de la Découverte: 8-bit restrooms:

Au Revoir.


Print References

  1. Arndt, Jörg, and Christoph Haenel. [Pi] – unleased . 2. ed. Berlin: Springer, 2001. Print.
  2. Berggren, Lennart, Jonathan M. Borwein, and Peter B. Borwein. Pi, a source book . 3rd ed. New York: Springer, 2004. Print.
  3. Beckmann, Petr. A history of [pi] (pi) . 4th ed. New York: Barnes & Noble, 19931971. Print.

Credits

  1. Pi Day Deathmatch Poster. Dhemerae Ford (dhemerae@gmail.com).
  2. First Pi Room Picture: http://www.palais-decouverte.fr/index.php?id=824
  3. William Shanks Picture: http://shankfamily.us/images/WilliamShank1821e.jpg
  4. Mechanical Desk Calculator Picture: http://upload.wikimedia.org/wikipedia/commons/e/ee/Comptometer_Model_WM.jpg

Pi Day Rematch: Apple II vs. HP-41C

Yes, the thought of two vintage computing devices battling as digital gladiators in a cage match to the death under the watchful eye of our supercomputer overlord, the HAL 9000, is amusing at best. But this is Pi Day, and what better way to celebrate than with silicon blood. Who knows, perhaps this did happen a long time ago in The Grid.

Let the games begin!


Mano-a-mano

In a battle before time itself (I’m referring to the lack of a clock in the Apple II and 41C), this David and Goliath-esque story started to unfold as I was cleaning my office not too long ago. (Cleaning my office is really an excuse to get my retro on.)

I’ve always been a fan (and user) of the Apple II, RPN calculators, and of course, Pi. It’s no wonder that I have stacks of machines, journals, books, magazines, printouts, etc… related to all three topics.

As I was filtering through stacks of papers to determine the value of each scrap of paper, I stumbled across a 1980 article by Ron Knapp, PI TO 1,110 PLACES[1]. I had forgotten about this article. I remember printing it out along with a 1981 followup article by the same author, FASTEST PI TO 1,000 PLACES[2]. At the time I was interested in the relative 1000-digit Pi performance of all ’80s calculators, and gravitated towards the newer, faster code, and had forgotten to read the first article.

So, I read it. Hmmm…

The run-time for this program is relatively short: 30 places in 2 min., 90 places in 9 min., 200 places in 34 min., 1000 places in 11 ½ hr., and 1160 places in 15 ¼ hr. When you consider that an article in “The Best of Micro” some time ago stated that an Apple II had been programmed to calculate “pi” to 1000 places in 40 hours–the run-time for the 41-C, a shirt-pocked calculator, seems very fast indeed[2].

Wow! Really? Can this be true? I was determined to get to the bottom of this. I’ll be “cleaning” my office for a bit longer.


Confirming the Results

It didn’t take too long to track down the source of Ron Knapp’s statement; Robert J. Bishop’s article, APPLE PI[3]:

Since the program is written entirely in BASIC it is understandably slow[3].

Ah ha! BASIC! That explains everything. Right?

I knew from my Apple II days in high school that machine language was faster than BASIC, as was Pascal. But is a circa 1977 computer running BASIC really 4-5 times slower than a circa 1979 pocket calculator? I wanted to see the results myself, and find out why?.

I do not have a clock card in my Apple //c, nor did I have the time to fashion one out of a serial cable and a GPS unit (I’ve done this before), and I am not going to sit around with a stopwatch; I opted to use Virtual ][ on my Mac. IMHO, Virtual ][ is the most authentic Apple II series emulator available. And thankfully Virtual ][ emulates a clock card.

For the HP-41C I’ll be using my HP-41CX. The 41C and 41CX run at the same speed (the X in CX stands for eXpanded memory). Fortunately the CX (unlike the C) has a clock built-in.

I modified both programs to output to a printer and to leverage the clocks so that I could get an accurate reading of the performance. The output with source for the Apple II and HP-41C can be obtained here and here.

The results:


APPLE II
START: MON MAR 7 10:40:40 PM THE VALUE OF PI TO 1001 DECIMAL PLACES: 3.14159265358979323846264338327950288419  7169399375105820974944592307816406286208 9986280348253421170679821480865132823066 4709384460955058223172535940812848111745 0284102701938521105559644622948954930381 9644288109756659334461284756482337867831 6527120190914564856692346034861045432664 8213393607260249141273724587006606315588 1748815209209628292540917153643678925903 6001133053054882046652138414695194151160 9433057270365759591953092186117381932611 7931051185480744623799627495673518857527 2489122793818301194912983367336244065664 3086021394946395224737190702179860943702 7705392171762931767523846748184676694051 3200056812714526356082778577134275778960 9173637178721468440901224953430146549585 3710507922796892589235420199561121290219 6086403441815981362977477130996051870721 1349999998372978049951059731732816096318 5950244594553469083026425223082533446850 3526193118817101000313783875288658753320 8381420617177669147303598253490428755468 7311595628638823537875937519577818577805 3217122680661300192787661119590921642019 898 END: WED MAR 9 4:27:30 PM


41 hours, 46 minutes, and 50 seconds. Confirmed, BASIC is indeed slow.

NOTE: I had to compute 1001 digits of Pi to get 1000 accurate digits.


HP-41C
3. 14159 26535 89793 23846 98336 73362 44065 66430 26433 83279 50288 41971 86021 39494 63952 24737 69399 37510 58209 74944 19070 21798 60943 70277 59230 78164 06286 20899 05392 17176 29317 67523 86280 34825 34211 70679 84674 81846 76694 05132 82148 08651 32823 06647 00056 81271 45263 56082 09384 46095 50582 23172 77857 71342 75778 96091 53594 08128 48111 74502 73637 17872 14684 40901 84102 70193 85211 05559 22495 34301 46549 58537 64462 29489 54930 38196 10507 92279 68925 89235 44288 10975 66593 34461 42019 95611 21290 21960 28475 64823 37867 83165 86403 44181 59813 62977 27120 19091 45648 56692 47713 09960 51870 72113 34603 48610 45432 66482 49999 99837 29780 49951 13393 60726 02491 41273 05973 17328 16096 31859 72458 70066 06315 58817 50244 59455 34690 83026 48815 20920 96282 92540 42522 30825 33446 85035 91715 36436 78925 90360 26193 11881 71010 00313 01133 05305 48820 46652 78387 52886 58753 32083 13841 46951 94151 16094 81420 61717 76691 47303 33057 27036 57595 91953 59825 34904 28755 46873 09218 61173 81932 61179 11595 62863 88235 37875 31051 18548 07446 23799 93751 95778 18577 80532 62749 56735 18857 52724 17122 68066 13001 92787 89122 79381 83011 94912 66111 95909 21642 01989 TIME: 30116.94 SEC

8 hours, 21 minutes, and 56.94 seconds.

NOTE: I did not use Ron’s original 1980 program (where the first stone was thrown), but opted to use the optimized 1981 version instead. The Apple II would have taking a a beating in either case.


And the Winner Is…

Ron was right to boast. I have been unable to find any public Apple II results dated before 1982 to take back the title, Microcomputer/Calculator Class: Fastest Pi to 1000 digits.

To add insult to injury, in 1949, the hulking 30-ton giant ENIAC enslaved a team of four humans and computed Pi to 2037 digits in 70 wall clock hours over a three day holiday weekend. ENIAC throughout the computation also reversed the calculations to check for errors. The humans were leveraged as bio-mechanical RAM since ENIAC could only hold 200 decimal numbers in memory. Team ENIAC worked in shifts collecting, organizing, and feeding IBM punch cards. All compute, check, and human interaction took 70 hours[4, pp. 277-281, 731].

I’ll demonstrate later that 2037 digits in 70 hours is computationally the same as 1000 digits in ~17 hours. The Apple II in 1978 cannot best a 30-something-year-old cyborg?

Why? Did all three use the same algorithm? In the same way? Are there technological factors or limitations? Can the Apple II best the HP-41C and ENIAC?

To answer all those questions we need to better understand how to compute Pi to 1000 digits.


Computing Pi with arctan

There are many different methods to compute the digits of Pi by hand or with a computer. The arctan formulas since the second half of the 17th century have been the most popular for computing a relatively small (less than a million) number of Pi digits[5, pp. 65, 205]. So it is no surprise that Ron, Robert, and Team ENIAC used arctan as well. Specifically, Machin’s formula.


Machin’s arctan Formula

John Machin discovered and used this formula in 1706 to compute the first 100 digits of Pi[5, p. 72]. It has been the most widely used formula by Pi digit hunters until the early ’80’s when the state-of-the-art shifted to Gauss AGM and other exotic formulas[5, pp. 206]. However, Machin is still very popular because it’s easy to implement, fast, and has a low memory footprint. All three are important factors when using retro tech.

Many mathematical functions can be numerically computed with a series which is relatively easy to calculate. The arctan function possesses just such a series which was discovered by James Gregory in 1671[5, p. 67].

Combine the two and voilà! We have something that we can compute efficiently that will converge quickly.

The first series converges with log10(52) = 1.3979 decimal places per series term and the second converges with log10(2392) = 4.7568 decimal places per series term[5, p. 72].

The total number of terms required for each series for 1000 decimal Pi digits can be calculated with ⎡1000 / log10(52)⎤ = 716 and ⎡1000 / log10(2392)⎤ = 211 respectively. 927 terms total.

NOTE: The ⎡ ⎤ brackets is defined as round up to the next integer.
NOTE: The number of terms does not change if the numeric base for computation changes. IOW, it is constant. More on this later.
TIP: http://www.codecogs.com/latex/eqneditor.php was used to create all equations used in this article.


Arbitrary-Precision Arithmetic

Go ahead, load up that last equation into Apple’s Integer BASIC and see what you get for Pi. 3? Don’t worry, you are are in good company; the biblical value of Pi = 3[6, p. 174] :-). Apple’s Floating Point BASIC doesn’t fair well either; at best, it would have computed 10 or 11 digits.

Clearly we are going to have to create some arbitrary-precision (AP) arithmetic code. The good news is that all we need is add, subtract, multiply, and divide. The simplest method for all four is to go old skool. That’s right, the same way you learned how to do this in elementary school is still applicable today. Simply represent each digit in an array and perform the operations the same way you would with pen and paper. Get out a pen and paper and try it!

It’s easier than it sounds. Although the adds and subtracts will be AP +/- AP, the multiply and divides will be AP ∗/÷ SP (single-precision). Now that’s even easier. AP:AP mult/div is harder and the subject of many papers and AP libraries.

For each operation, as your code loops from the least significant digit to the most significant digit (except divide, go the other way), the four arithmetic routines will perform two basic operations per iteration; add, sub, mult, div, and then a carry. I understand that this is an oversimplification, and if you want a clearer understanding, then I suggest you look at some code. However, the point I am trying to make is that if the number of digits doubles (e.g. computing Pi to 2000 digits), then the number of operations for AP:AP add/sub and SP:AP div/mult also doubles. It also works the other way. If I can half the number of digits, then I half my number of operations, and therefore half the time for basic arithmetic operations.


Covering Your Bases

The amount of effort it takes an 8-bit computer to add two base 10 numbers is the same effort as adding two base 256 (28) numbers. Therefore, if you can pack your 1000 digit base 10 arrays into fewer base 256 digits, then you can also reduce the number of operations and get a proportional speed up in time. Your new array size will = ⎡number of decimal digits / log10base⎤.

A few examples based on 1000 decimal digits of Pi:


Base Calculation
Array Size
10 ⎡1000 / log1010⎤
1000
28 (256) ⎡1000 / log10(28)⎤
416
216 (65536) ⎡1000 / log10(216)⎤
208
100,000 ⎡1000 / log10100,000⎤
200
10,000,000,000 ⎡1000 / log1010,000,000,000⎤
100


The speed-up should be proportional to the array size assuming that a larger base will not have a disproportional overhead. E.g. The 6502, an 8-bit processor, will take more that twice the instructions to add two 16-bit numbers compared to two 8-bit numbers. However using 16-bit numbers on an 8-bit system is still more efficient that using base 10.

There is a caveat when not using base 10, 100, 1000, etc…; the end result must be converted back to base 10 if you are truly computing 1000 decimal digits of Pi. This adds a bit of overhead to the end of the computation, however it is only a fraction (e.g. 1/6th for base 216 to base 10) of the total computation.

I am assuming that ENIAC can leverage it’s double precision support and use base 1010 (10,000,000,000) and therefore only require an array of 100 base 1010 digits for 1000 decimal digits of Pi. Ron’s HP-41C program uses base 105 (100,000) requiring only 200 base 105 digit arrays. Robert’s Apple Pi uses base 10 requiring 1000 digit arrays.

This begins to shed some light on why Apple Pi performs so poorly. If Apple Pi could use base 100,000 or base 10,000,000,000 then its time would be reduced by a factor of 5 and 10 respectively. However, Integer BASIC and the 6502 are not designed to support this. ENIAC and the HP-41C are both designed and optimized for base 1010. As they should be; they are calculators.


Computation Complexity

Earlier I said, I’ll demonstrate later that 2037 digits in 70 hours is computationally the same as 1000 digits in ~17 hours.

That statement makes two assumptions. The first is that Team ENIAC used the Gregory expansion of Machin’s arctan formula, and the second is that their AP arithmetic scaled linearly. If that is the case, as is the case with Ron’s and Robert’s programs, and since the number of terms and the number of digits is a fixed ratio based on the desired number of digits; then if the number of desired digits double, then so does the number of terms to be computed and the size of the array to hold the digits, and therefore the amount of computation is double * double. IOW, the computational complexity is O(n2).

Simply put, if I double the digits the time increases by four. Therefore, the estimated time for ENIAC to compute 1000 digits is: 70 hr * (1000/2037)2 = 16.87 hr.


Back to Apple Pi

The number of terms to be computed will be constant regardless of the program’s numeric base. That leaves optimizing the arithmetic routines. Assuming that Robert’s BASIC program could be rewritten in base 256 (and it cannot without a lot of effort; effort that would not yield sufficient benefit), then the best speed up would be 41.78 hr * (416/1000) = 17.38 hr. Still deficient.

When writing fundamental AP routines it helps to have unsigned double precision integer support; if not, make your base the square-root of (the largest positive integer + 1), e.g. the largest HP-41C positive integer is 9,999,999,999, making the optimal base 100,000 since the HP-41C does not have double precision integer support. Because of the wacky integer support in Integer BASIC, the largest base would be 181 and not offer up enough performance.

Bottom line, Integer BASIC is most likely our culprit. In 1978 Robert had very few options. BASIC and assembly language were the dominate languages, and if I were in Robert’s shoes I would have picked BASIC too (Robert wrote the program in less than 40 hours)[3]. However, there was another option; Apple FORTH from Programma Consultants[7, p. 26]. And by 1980, when Ron first mentioned the Apple II’s poor performance, there were many more Apple languages to choose from, such as FORTRAN and Pascal.


Pi Day Rematch: Apple II vs. HP-41C

FORTH seems promising for a few reasons; one, it was available in 1978; two, it’s most like RPN, making a comparison to the 41C a bit more apples to apples; and three, with FORTH it will be easy to use a larger base (I used base 216) thus reducing the size of the arrays. Lastly, FORTH is fast.

Unfortunately I was unable to locate a copy of Apple FORTH from Programma Consultants, so I opted to use Mad Apple Forth (MAF) as a substitute. My program with timings can be located here. I didn’t have time to figure out how to access the clock card from MAF, so I used the Virtual ][ record function and then noted the time stamps on the output.

Start:       22:44:47
Print:       23:05:24
End:         23:09:43
Total Time:  00:24:56

The HP-41C and ENIAC were both schooled by the Apple II with FORTH.


HP-41C cries foul!

If you could only use what came in the box with your Apple II or HP-41C, then what would be the results? Fortunately the Apple II mini-assembler is in the box.

In 1982 Glen Bredon wrote an APPLE PI program in assembly that blows the battery door off the 41C with a time of 194 seconds. Game over! The Apple II wins again!

My 1496 sec. FORTH version doesn’t hold an LED to assembly.

If you are looking for Glen’s program, it is packaged with the Merlin Assembler.


HP-41C Machine Language

To be thorough I asked a friend of mine to compute Pi on the 41C with a 100% machine language (ML) program. He came back with 5 hours, 9 minutes. No question, the Apple II is king.


Victory Lap

In my quest to best the 41C, I tried C as well. The C language hit the seen in the mid ’80s making it easier to write and port over existing Pi programs.

Why not rub it in a bit?


C Version C Year Base
Time (s)
Aztec K&R C 3.2b 1986 216
2180
Aztec K&R C 3.2b 1986 10
6746
cc65 ANSI C 2.12 2010 216
1764
cc65 ANSI C 2.13 2010 216
1514
cc65 ANSI C 2.13 2010 10
4241


Summary

BASIC sucks. The HP-41C is truly awesome, and for a time bested the Apple II in the Fastest to Compute 1000 digits of Pi benchmark. But, in the end, the true potential of the Apple II smoked the 41C.

BTW, you’ll never need more than 50 digits of Pi[5, p. 153].


On the other hand…

To continue reading this fascinating tale click here.


Some Great Pi Books

If you like Pi, especially computing Pi, then I recommend the following three books[4, 5, 6]:

Print References

  1. Knapp, Ron. PI TO 1,110 PLACES. PPC Calculator Journal Jun. 1980: 9-10.
  2. Knapp, Ron. FASTEST PI TO 1,000 PLACES. PPC Calculator Journal Aug.-Dec. 1981: 68-69
  3. Bishop, Robert J. APPLE PI. MICRO THE 6502 JOURNAL Aug.-Sep. 1978: 15-16.
  4. Berggren, Lennart, Jonathan M. Borwein, and Peter B. Borwein. Pi, a source book . 3rd ed. New York: Springer, 2004. Print.
  5. Arndt, Jörg, and Christoph Haenel. [Pi] – unleased . 2. ed. Berlin: Springer, 2001. Print.
  6. Beckmann, Petr. A history of [pi] (pi) . 4th ed. New York: Barnes & Noble, 19931971. Print.
  7. Apple Computer Inc. the best of the user group newsletters for 1978. Contact ’78 Dec. 1978: 26.

Credits

  1. Pi Day Deathmatch Poster. Dhemerae Ford (dhemerae@gmail.com).
  2. ENIAC photo (linked). Wikipedia.