pi is computed using the formula pi = 16*arctan(1/5) - 4*arctan(1/239) and the arctangents are evaluated using the series arctan(x) = x - x^3 + x^5 - x^7 ... --- --- --- 3 5 7 The arithmetic is done using 'digits' in base 2^39 p1=100 p10=1000 space for sum p11=200p10 space for term p12=200p11 space for x^(2n+1) referred to as proto-term 70s200(60 adds (t=0) or subtracts (t=1) term p11 to/from sum p10 ---> 79sp62(61 preserve digit count | 31s-2p11 | 76t1 load + or - digit | 30s-2p11 | 53p63 >-- ignore zero digit | 75sp61 | go to next digit and exit at end | 60f0 | exit setting s to position of last non-zero digit | | | -> 62p80(64 | mask off wrong bit | | 109s-2p10 | store corrected digit, overflow not yet cleared | | 73s2 | carry to next digit | | 31p81 | | | 76t1 | load +1 or -1 to carry | | 30p81 | | | 79s0(63 <-- store digit position in 0, set into s on exit | | 32s-2p10 add digit from sum | | 109s-2p10 store in sum, maybe wrong if overflow | -< 55p64 jump if overflow | 70s0(62 recover digit count after carrys --< 75sp61 go to next digit and exit at end 60f0 19f2(50 Divides pre-term (p12) by integer 51r1 start at digit s since earlier ones zero --> 47sp12(52 | 45f2 | 48sp12 store result in pre-term p12 | 76s198 --< 74sp52 60f0 19f2(51 same as subroutine p50 except result in term p11 51r1 47sp12(53 45f2 48sp11 76s198 74sp53 60f0 102f0(3 start 70s200 9s-2p10 clear sum to zero 75sr-1 70t0 set t=0 for first series ----> 79tp99(98 preserve t | | 70s400 | 9s-2p11 clear pre-term and term to zero | 75sr-1 | | 4tp83 | 46f0 fetch multiplier 16 or 4 | 19p12 store in pre-term | 4tp82 | 46f0 fetch denominator 5 or 239 | 19f4 save in 4 | 34f4 square it | 48f6 save in 6 | | 30f4 load denominator | 70s0 s=0 to start division at most significant digit | 58p50 divide | 46f1 | 58p51 divide by 1 to move pre-term to term | 58p60 add term to sum | | 46f1 | 19f10 set count of terms in 10 to 1 | | 70s0 start next division at most significan end | --> 30f6(97 load 5^2 or 239^2 | | 58p50 divide pre-term by this | | 46f2 | | 38f10 increment count of terms | | 58p51 term = pre-term/count | | | | 3t0 | | 70t1 replace t by 1-t so next term subtracted | | 58p60 add term to sum, s set to last non-zero digit | | 73s4 adjust s for start of next division | | | | 76s180 continue until sufficient zero digits in term | --< 50p97 | | 70t0(99 restore t, destroyed by sign changes | 72t1 set t=1 for second series | 76t2 exit after two series ----< 50p98 80s1p10(46 print rountine, get integer part 110s951 look up tape code 66s20 107s30 print digit 107f28 print . 107f2 print cr 107f8 print lf 70t0 set count of groups of 10 decimal digits ----> 44f198p10(89 initial K to a 'digit' in base 2^39 =d | 70s198 count of 'digits' in base 2^39 | 51r1 clear A | --> 36*n1e10(88 10^10d in A | | 44s-2p10 load next digit to K | | 19s-2p10 store part of product, overwriting next digit | | 48f2 | | 30f2 | | 32sp10 add other half of product | | 109sp10 store ignoring overflow | | 56r2 if overflow there is a carry | | 51p87 | | 62p80 mask off wrong bit if overflow | | 19sp10 store correct result | | 51r1 clear A | | 47p81 set L=1 if there was overflow | ---<75sp88(87 count digits | | 6f39 move any carry from L to M | 32p10 add on digit in base 10^10 | 59f21 print | 76t198 test for 100 prints ----< 74tp89 101f0 stop r127r2047 127t2047(80 mask for removing overflow bit 0f0 0f1(81 1 as integer 0f5(82 denominators 0f239 0f16(83 multipliers 0f4 1/n.7001911915 digit and page layouts 3/25 4/5 sp3