return to main page
Return to 1401 Software Development

Pi to 500 places from a smaller 1401


by Ed Thelen December 13, 2007

The running time for the 5,000 and 2,000 character Pi routines were so long that I cut it even further, to 500 characters. The 5050 character fields have been reduced to 550 for faster operation.

for more details of this method for obtaining Pi, see Bigger Pi.

The AutoCoder source listing is here
The AutoCoder assembly listing is here
The "object deck", program cards to be loaded into the 1401 is here .
And the result is here. :-))


The AutoCoder source listing

     *   1         2         3         4         5         6         7         8
     *78901234567890123456789012345678901234567890123456789012345678901234567890
     * label   | op | OPERATION                                         |xxxxxxx
               JOB       SubRoutine  PI
     *  
     * SO - WE HAVE 500 VALID PI CHARACTERS ? :-))
     * NOW LETS PRETTY IT UP A BIT, ORGANIZE SUBROUTINES
     *   CALL A SUBROUTINE DEPENDS UPON 
     *       IF THE INDEX REGISTER OPTION IS INSTALLED,
     *            ANY BRANCH LEAVES THE ADDRESS OF THE NEXT SEQUENTIAL
     *                  INSTRUCTION IF THE BRANCH NOT TAKEN IN THE 
     *                  B ADDRESS REGISTER   :-))
     *     THE ARCTAN ROUTINE IS WRITTEN AS A SUBROUTINE.
     *
               CTL       6611  *6=16,000C;6=16,000T;1=OBJDECK;,1=MODADD
     *   1         2         3         4         5         6         7         8
     *78901234567890123456789012345678901234567890123456789012345678901234567890
     * label   | op | OPERATION                                         |xxxxxxx
               ORG  87
     X1        DSA  0                  index register 1
               ORG  92
*    X2        DSA  0                  index register 2
*              ORG  97
*    X3        DSA  0                  index register 3
     *
     * start storage areas 
     *  small areas
*              ORG  100     * PUT SMALL STUFF IN PUNCH AREA
     ITCNT     DCW  000000    * ITERATION COUNTER, STARTS AT ZERO
     DIVBAS    DCW  000000   * DIVISOR FOR BASET
     IX2P1     DCW  000000   * ITCNT times 2 plus 1, DIVISOR FOR INTER
     C0        DCW  000000
     C1        DCW  000001
     C2        DCW  000002
     C25       DCW  000025  * 5^2
     C239P2    DCW  057121  * 239^2
     CNTZRO    DCW  000000  * COUNT LEADING ZEROS, DONE YET?
     CF        DCW  1         *  "1"=ADD, "0" OR OTHER = SUBTRACT
     LC0L9     DCW  000000000
     *
     *    COMPUTE    16*ARCTAN(1/5)
     START     MCW  @+@,ACCUM&549   * ZERO ACCUMULATOR, FORCE POSITIVE
               MCW  @0@,ACCUM&548
               B    START1           * SKIP PRINT AREA
               ORG  335
     START1    MCW  ACCUM&548,ACCUM&547 
               MCW  @0@,BASET&548  * ZERO BASE
               MCW  BASET&548,BASET&547
     * BIG REGISTERS SET 
               MCW  @80@,BASET&8  * SET A HIGH ORDER TO 1*5*16
               MCW  @1@,CF        * SET NEXT TO ADD
               MCW  C25,DIVBAS              * SET NEXT TO ADD
               B    ATAN          *** CALL ATAN SUBROUTINE
     *
     * NOW, ADD MINUS 4*ARCTAN(1/239) TO ABOVE  16*ARCTAN(1/5)
     * DO NOT ZERO ACCUMULATOR
     START2    MCW  @0@,BASET&548  * ZERO BASE
               MCW  BASET&548,BASET&547
               MCW  @956@,BASET&8   * SET A HIGH ORDER TO 1*4*239
               MCW  @0@,CF          * SET NEXT SUBTRACT
               MCW  C239P2,DIVBAS   * SET SET BASE DIVISOR
               B    ATAN            *** CALL ATAN SUBROUTINE
     * WE NOW HAVE PI IN MEMORY, PRINT IT OUT
               B    PRINT           * CALL PRINT ROUTINE
     HALT      H    START           *** HALT HERE - 
     *
     ATAN      SBR  ATANX&3         * SET RETURN
               MCW  C0,CNTZRO       * CLEAR LEADING ZERO COUNTER
               MCW  C0,ITCNT        * ZERO ITERATION CNTR
               MCW  C1,IX2P1        * INIT INTER DIVISOR
               MCW  @000@,X1        * CLEAR ASSOCIATED INDEX REGISTER
     ATANL     MCW  @+@,BASET&549  * SET POSITIVE SIGN
               D    DIVBAS,BASET&6     * TRIAL ARITH
               MCW  BASET&542,BASET&549  * SHIFT QUOTIENT
               MCW  LC0L9,BASET&6      * REMOVE UNSHIFTED
               MCW  BASET&549,INTER&549  * MOVE QUOTIENT TO NEXT
               MCW  @+@,INTER&549     * SET POSITIVE SIGN
               D    IX2P1,INTER&6    DIVIDE INTERMEDIATE
               MCW  INTER&542,INTER&549   * SHIFT INTERMEDIATE
               MCW  LC0L9,INTER&6        * REMOVE UNSHIFTED
               MCW  @+@,INTER&549  * SET UP BASE
               BCE  ATANA,CF,1        * COMPARE FOR ADD
     ATANS     MCW  @1@,CF              * SET NEXT ADD
               S    INTER&549,ACCUM&549   * DO THE SUBTRACTION
               B    ATANW                * GO TO WRAP-UP
     ATANA     A    INTER&549,ACCUM&549   * ADD TO ACCUMULATOR
               MCW  @0@,CF              * SET NEXT SUBTRACT
     ATANW     A    C1,ITCNT            * INC ITERATION COUNT
               A    C2,IX2P1            * FORM NEXT DIVISOR
     ATANB     BCE  ATANI,BASET&X1,0   * CHAR = 0, DONE?
               B    ATANL                * GO DO ANOTHER LOOP PASS
     ATANI     A    C1,CNTZRO           * INCREMENT # LEADING ZEROS
               SBR  X1,1&X1             * INCREMENT X1
               C    CNTZRO,@549@         * CHECK END
               BU   ATANB              * NO, CHECK MORE ZEROS
     ATANX     B    0                  *** RETURN TO CALL
     *        
     *   
     * -------------------------------------------------------------
     *
     *  NOW WE PRINT THAT BABY OUT :-))
     * PROPOSED FORMAT
     * 2
     * 0        1         2         3         4         5         6         7         8
     * 12345678901234567890123456789012345678901234567890123456789012345678901234567890  
     *                                                        3. * 10E-00000
     * + NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN  * 10E-00050
     * + NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN  * 10E-00100
     PRINT     SBR  PRINTX&3
     PRINTD    MCW  @008@,X1   * CLEAR PICKUP X
               MCW  C0,ITCNT   * CLEAR TOTAL CH MOVED
               CS   332    * start clearing down to 200, PRINT AREA
               CS
               MCW  @. * 10E-00000@,269
               SW   265                    * SET WORD MARK IN EXPONENT FIELD
               MCW  ACCUM&X1,256  MOVE 5TH FIELD
               SBR  X1,10&X1     * STEP X1
               W           *write the print area to the printer
     *
     PR1LOP    CS   252        * CLEAR PREVIOUS NUMERICS
               SW   203,214    * SET WORD MARKS FOR B FIELD
               SW   225,236
               SW   247,265
               A    @00050@,269 * ADD 50 TO EXPONENT
               MCW  ACCUM&X1,212  MOVE 1ST FIELD
               SBR  X1,10&X1     * STEP X1
               MCW  ACCUM&X1,223  MOVE 2ND FIELD
               SBR  X1,10&X1     * STEP X1
               MCW  ACCUM&X1,234  MOVE 3RD FIELD
               SBR  X1,10&X1     * STEP X1
               MCW  ACCUM&X1,245  MOVE 4TH FIELD
               SBR  X1,10&X1     * STEP X1
               MCW  ACCUM&X1,256  MOVE 5TH FIELD
               SBR  X1,10&X1     * STEP X1
               W           *write the print area to the printer
               A    @000050@,ITCNT   * ADD 50 TO TOTAL DIGITS
               C    @000500@,ITCNT   * TEST FOR END
               BL   PR1LOP         * END IS HIGHER THAN COUNT
     PRINTX    B    0              *** RETURN TO CALL
     *
     *
     *  large areas Ron Mak says that blanks process as zeros
     *          ORG  780
     *FLDLEN    EQU  550      * LENGTH OF THE 3 BIG FIELDS
     BASET     DA   1X550,C  * BASE, 1ST DIVISION HERE
     INTER     DA   1X550,C  * INTERMEDIATE BUFFER, 2ND DIVISION HERE
     ACCUM     DA   1X550,C  * ACCUMULATOR, ANSWER IS FORMED HERE
     *   1         2         3         4         5         6         7         8
     *78901234567890123456789012345678901234567890123456789012345678901234567890
     * label   | op | OPERATION                                         |xxxxxxx
     *
     *** Nov 15
     * Machin's method -
     * PI = 16arctan(1/5) - 4arctan(1/239)
     * An arctan series is 1/n - 1/(3xn^3) + 1/(5xn^5) - ...
     *   
     *** Nov 16
     * In any case,
     *Lets do arctan(x),  x = 1/5
     *   0.19739555984988075837004976519479
     *then  16ARCTAN(1/5)
     *   3.1583289575980921339207962431166
     * then arctan(1/239)
     *   0.0041840760020747238645382149592855
     * times 4
     *   0.016736304008298895458152859837142
     * Pi = 
     *    3.1415926535897932384626433832795
     * :-))
     *
     * Set N to 1/x = 5      (this is the fancy footwork :-))
     *
     * 1) a) form three large as practical equal sized areas in memory. 
     *       lets call them "Accumulator",       ACCUM
     *                      "Intermediate",      INTER
     *                      "Base of next term"  BASET
     *     b) form smaller working areas
     *          iteration counter ITCNT    used for observation
     *                  starts at zero, counts up after a pass
     *          divisor of BASET, DIVBAS,   usually 5^2 or 239^2
     *                  5^2 = 25,   239^2 = 57121
     *          add/subtract control flag, CF , toggled after a pass
     *                0 means add, other is subtract
     *          divisor of INTER is IX2P1 , ITCNT times 2 plus 1
     *   
     * 2) figure where the decimal point will be
     *     (same relative place in each area)
     *     ( several characters or words to the "right" of 
     *       the top significance.)
     *
     * 3) a) zero the  ACCUM
     *     b) ( INTER does not need initialization)
     *    c) set X (5.0 in our example) into BASET
     *    d) set counter N to 1
     *
     * 4) While BASET is non-zero
     *    a) Divide BASET by X^2  ( 25 in our example ) giving BASET
     *    b) Divide BASET by (2xN - 1) giving INTER
     *    c) If N is odd, add Intermediate to Accumulator
     *           else, subtract Intermediate from Accumulator 
     *    d) Add 1 to N (assure that machine can divide by 2N)
     *
     * 5) Accumulator is a fine approximation of arctan(x)   ;-))
               END  START  * LAST CARD IN DECK, TRANSFER ADDRESS



The AutoCoder assembly listing

 
 CLEAR STORAGE 1     ,008015,022026,030037,044,049,053053N000000N00001026                                         1
 CLEAR STORAGE 2     L068116,105106,110117B101/I9I#071029C029056B026/B001/0991,001/001117I0?                      2
 BOOTSTRAP           ,008015,022029,036040,047054,061068,072/061039              ,0010011040                      3
0                                                                                                         PAGE    1
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
  101         *   1         2         3         4         5         6         7         8
  102         *78901234567890123456789012345678901234567890123456789012345678901234567890
  103         * LABEL   | OP | OPERATION                                         |XXXXXXX
1                               SUBROUTINE  PI                                                            PAGE    2
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
  104                JOB        SUBROUTINE  PI
  105         * LETS GO FOR 8,000 CHARACTERS OF MEMORY
  106         * SO - WE HAVE 500 VALID PI CHARACTERS ? :-))
  107         * NOW LETS PRETTY IT UP A BIT, ORGANIZE SUBROUTINES
  108         *   CALL A SUBROUTINE DEPENDS UPON
  109         *       IF THE INDEX REGISTER OPTION IS INSTALLED,
  110         *            ANY BRANCH LEAVES THE ADDRESS OF THE NEXT SEQUENTIAL
  111         *                  INSTRUCTION IF THE BRANCH NOT TAKEN IN THE
  112         *                  B ADDRESS REGISTER   :-))
  113         *     THE ARCTAN ROUTINE IS WRITTEN AS A SUBROUTINE.
  114         *
  115                CTL        6611  *6=16,000C;6=16,000T;1=OBJDECK;,1=MODADD
  116         *   1         2         3         4         5         6         7         8
  117         *78901234567890123456789012345678901234567890123456789012345678901234567890
  118         * LABEL   | OP | OPERATION                                         |XXXXXXX
  119                ORG   87                                                                 0087
  120         X1     DSA   0                  INDEX REGISTER 1                      3  0089  000                  4
  121                ORG   92                                                                 0092
  122 *       X2     DSA   0                  INDEX REGISTER 2                      3  0094  000                  5
  123 *              ORG   97                                                                 0097
  124 *       X3     DSA   0                  INDEX REGISTER 3                      3  0099  000                  6
  125         *
  126         * START STORAGE AREAS
  127         *  SMALL AREAS
  128 *              ORG   100     * PUT SMALL STUFF IN PUNCH AREA                            0100
  129         ITCNT  DCW   000000    * ITERATION COUNTER, STARTS AT ZERO            6  0105                       6
  130         DIVBAS DCW   000000   * DIVISOR FOR BASET                             6  0111                       6
  131         IX2P1  DCW   000000   * ITCNT TIMES 2 PLUS 1, DIVISOR FOR INTER       6  0117                       6
  132         C0     DCW   000000                                                   6  0123                       6
  133         C1     DCW   000001                                                   6  0129                       6
  134         C2     DCW   000002                                                   6  0135                       6
  135         C25    DCW   000025  * 5^2                                            6  0141                       7
  136         C239P2 DCW   057121  * 239^2                                          6  0147                       7
  137         CNTZRO DCW   000000  * COUNT LEADING ZEROS, DONE YET?                 6  0153                       7
  138         CF     DCW   1         *  "1"=ADD, "0" OR OTHER = SUBTRACT            1  0154                       7
  139         LC0L9  DCW   000000000                                                9  0163                       7
  140         *
  141         *    COMPUTE    16*ARCTAN(1/5)
  142         START  MCW   @+@,ACCUM&549   * ZERO ACCUMULATOR, FORCE POSITIVE       7  0164  M M51 M50            7
  143                MCW   @0@,ACCUM&548                                            7  0171  M M52 M49            8
  144                B     START1           * SKIP PRINT AREA                       4  0178  B 335                8
  145                ORG   335                                                                0335
  146         START1 MCW   ACCUM&548,ACCUM&547                                      7  0335  M M49 M48            9
  147                MCW   @0@,BASET&548  * ZERO BASE                               7  0342  M M52 T49            9
  148                MCW   BASET&548,BASET&547                                      7  0349  M T49 T48            9
  149         * BIG REGISTERS SET
  150                MCW   @80@,BASET&8  * SET A HIGH ORDER TO 1*5*16               7  0356  M M54 809            9
  151                MCW   @1@,CF        * SET NEXT TO ADD                          7  0363  M M55 154            9
  152                MCW   C25,DIVBAS              * SET NEXT TO ADD                7  0370  M 141 111           10
  153                B     ATAN          *** CALL ATAN SUBROUTINE                   4  0377  B 428               10
1                               SUBROUTINE  PI                                                            PAGE    3
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
  154         *
  155         * NOW, ADD MINUS 4*ARCTAN(1/239) TO ABOVE  16*ARCTAN(1/5)
  156         * DO NOT ZERO ACCUMULATOR
  157         START2 MCW   @0@,BASET&548  * ZERO BASE                               7  0381  M M52 T49           10
  158                MCW   BASET&548,BASET&547                                      7  0388  M T49 T48           10
  159                MCW   @956@,BASET&8   * SET A HIGH ORDER TO 1*4*239            7  0395  M M58 809           10
  160                MCW   @0@,CF          * SET NEXT SUBTRACT                      7  0402  M M52 154           10
  161                MCW   C239P2,DIVBAS   * SET SET BASE DIVISOR                   7  0409  M 147 111           11
  162                B     ATAN            *** CALL ATAN SUBROUTINE                 4  0416  B 428               11
  163         * WE NOW HAVE PI IN MEMORY, PRINT IT OUT
  164                B     PRINT           * CALL PRINT ROUTINE                     4  0420  B 626               11
  165         HALT   H     START           *** HALT HERE -                          4  0424  . 164               11
  166         *
  167         ATAN   SBR   ATANX&3         * SET RETURN                             4  0428  H 625               11
  168                MCW   C0,CNTZRO       * CLEAR LEADING ZERO COUNTER             7  0432  M 123 153           11
  169                MCW   C0,ITCNT        * ZERO ITERATION CNTR                    7  0439  M 123 105           11
  170                MCW   C1,IX2P1        * INIT INTER DIVISOR                     7  0446  M 129 117           12
  171                MCW   @000@,X1        * CLEAR ASSOCIATED INDEX REGISTER        7  0453  M M61 089           12
  172         ATANL  MCW   @+@,BASET&549  * SET POSITIVE SIGN                       7  0460  M M51 T50           12
  173                D     DIVBAS,BASET&6     * TRIAL ARITH                         7  0467  % 111 807           12
  174                MCW   BASET&542,BASET&549  * SHIFT QUOTIENT                    7  0474  M T43 T50           12
  175                MCW   LC0L9,BASET&6      * REMOVE UNSHIFTED                    7  0481  M 163 807           13
  176                MCW   BASET&549,INTER&549  * MOVE QUOTIENT TO NEXT             7  0488  M T50 Z00           13
  177                MCW   @+@,INTER&549     * SET POSITIVE SIGN                    7  0495  M M51 Z00           13
  178                D     IX2P1,INTER&6    DIVIDE INTERMEDIATE                     7  0502  % 117 T57           13
  179                MCW   INTER&542,INTER&549   * SHIFT INTERMEDIATE               7  0509  M Y93 Z00           13
  180                MCW   LC0L9,INTER&6        * REMOVE UNSHIFTED                  7  0516  M 163 T57           14
  181                MCW   @+@,INTER&549  * SET UP BASE                             7  0523  M M51 Z00           14
  182                BCE   ATANA,CF,1        * COMPARE FOR ADD                      8  0530  B 556 154 1         14
  183         ATANS  MCW   @1@,CF              * SET NEXT ADD                       7  0538  M M55 154           14
  184                S     INTER&549,ACCUM&549   * DO THE SUBTRACTION               7  0545  S Z00 M50           14
  185                B     ATANW                * GO TO WRAP-UP                     4  0552  B 570               15
  186         ATANA  A     INTER&549,ACCUM&549   * ADD TO ACCUMULATOR               7  0556  A Z00 M50           15
  187                MCW   @0@,CF              * SET NEXT SUBTRACT                  7  0563  M M52 154           15
  188         ATANW  A     C1,ITCNT            * INC ITERATION COUNT                7  0570  A 129 105           15
  189                A     C2,IX2P1            * FORM NEXT DIVISOR                  7  0577  A 135 117           15
  190         ATANB  BCE   ATANI,BASET&X1,0   * CHAR = 0, DONE?                     8  0584  B 596 8'1 0         16
  191                B     ATANL                * GO DO ANOTHER LOOP PASS           4  0592  B 460               16
  192         ATANI  A     C1,CNTZRO           * INCREMENT # LEADING ZEROS          7  0596  A 129 153           16
  193                SBR   X1,1&X1             * INCREMENT X1                       7  0603  H 089 0'1           16
  194                C     CNTZRO,@549@         * CHECK END                         7  0610  C 153 M64           16
  195                BU    ATANB              * NO, CHECK MORE ZEROS                5  0617  B 584 /             16
  196         ATANX  B     0                  *** RETURN TO CALL                    4  0622  B 000               17
  197         *
  198         *
  199         * -------------------------------------------------------------
  200         *
  201         *  NOW WE PRINT THAT BABY OUT :-))
  202         * PROPOSED FORMAT
  203         * 2
1                               SUBROUTINE  PI                                                            PAGE    4
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
  204         * 0        1         2         3         4         5         6         7
  205         * 1234567890123456789012345678901234567890123456789012345678901234567890123
  206         *                                                        3. * 10E-00000
  207         * + NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN  * 10E-00050
  208         * + NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN NNNNNNNNNN  * 10E-00100
  209         PRINT  SBR   PRINTX&3                                                 4  0626  H 800               17
  210         PRINTD MCW   @008@,X1   * CLEAR PICKUP X                              7  0630  M M67 089           17
  211                MCW   C0,ITCNT   * CLEAR TOTAL CH MOVED                        7  0637  M 123 105           17
  212                CS    332    * START CLEARING DOWN TO 200, PRINT AREA          4  0644  / 332               17
  213                CS                                                             1  0648  /                   17
  214                MCW   @. * 10E-00000@,269                                      7  0649  M M80 269           17
  215                SW    265                    * SET WORD MARK IN EXPONENT F     4  0656  , 265               18
  216                MCW   ACCUM&X1,256  MOVE 5TH FIELD                             7  0660  M Z'1 256           18
  217                SBR   X1,10&X1     * STEP X1                                   7  0667  H 089 0/0           18
  218                W            *WRITE THE PRINT AREA TO THE PRINTER              1  0674  2                   18
  219         *
  220         PR1LOP CS    252        * CLEAR PREVIOUS NUMERICS                     4  0675  / 252               18
  221                SW    203,214    * SET WORD MARKS FOR B FIELD                  7  0679  , 203 214           18
  222                SW    225,236                                                  7  0686  , 225 236           18
  223                SW    247,265                                                  7  0693  , 247 265           19
  224                A     @00050@,269 * ADD 50 TO EXPONENT                         7  0700  A M85 269           19
  225                MCW   ACCUM&X1,212  MOVE 1ST FIELD                             7  0707  M Z'1 212           19
  226                SBR   X1,10&X1     * STEP X1                                   7  0714  H 089 0/0           19
  227                MCW   ACCUM&X1,223  MOVE 2ND FIELD                             7  0721  M Z'1 223           19
  228                SBR   X1,10&X1     * STEP X1                                   7  0728  H 089 0/0           20
  229                MCW   ACCUM&X1,234  MOVE 3RD FIELD                             7  0735  M Z'1 234           20
  230                SBR   X1,10&X1     * STEP X1                                   7  0742  H 089 0/0           20
  231                MCW   ACCUM&X1,245  MOVE 4TH FIELD                             7  0749  M Z'1 245           20
  232                SBR   X1,10&X1     * STEP X1                                   7  0756  H 089 0/0           20
  233                MCW   ACCUM&X1,256  MOVE 5TH FIELD                             7  0763  M Z'1 256           21
  234                SBR   X1,10&X1     * STEP X1                                   7  0770  H 089 0/0           21
  235                W            *WRITE THE PRINT AREA TO THE PRINTER              1  0777  2                   21
  236                A     @000050@,ITCNT   * ADD 50 TO TOTAL DIGITS                7  0778  A M91 105           21
  237                C     @000500@,ITCNT   * TEST FOR END                          7  0785  C M97 105           21
  238                BL    PR1LOP         * END IS HIGHER THAN COUNT                5  0792  B 675 T             21
  239         PRINTX B     0              *** RETURN TO CALL                        4  0797  B 000               21
  240         *
  241         *
  242         *  LARGE AREAS RON MAK SAYS THAT BLANKS PROCESS AS ZEROS
  243         *          ORG  780
  244         *FLDLEN    EQU  550      * LENGTH OF THE 3 BIG FIELDS
  245         BASET  DA    1X550,C  * BASE, 1ST DIVISION HERE                          0801   1350
  246         INTER  DA    1X550,C  * INTERMEDIATE BUFFER, 2ND DIVISION HERE           1351   1900
  247         ACCUM  DA    1X550,C  * ACCUMULATOR, ANSWER IS FORMED HERE               1901   2450
  248         *   1         2         3         4         5         6         7         8
  249         *78901234567890123456789012345678901234567890123456789012345678901234567890
  250         * LABEL   | OP | OPERATION                                         |XXXXXXX
  251         *
  252         *** NOV 15
  253         * MACHIN'S METHOD -
1                               SUBROUTINE  PI                                                            PAGE    5
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
  254         * PI = 16ARCTAN(1/5) - 4ARCTAN(1/239)
  255         * AN ARCTAN SERIES IS 1/N - 1/(3XN^3) + 1/(5XN^5) - ...
  256         *
  257         *** NOV 16
  258         * IN ANY CASE,
  259         *LETS DO ARCTAN(X),  X = 1/5
  260         *   0.19739555984988075837004976519479
  261         *THEN  16ARCTAN(1/5)
  262         *   3.1583289575980921339207962431166
  263         * THEN ARCTAN(1/239)
  264         *   0.0041840760020747238645382149592855
  265         * TIMES 4
  266         *   0.016736304008298895458152859837142
  267         * PI =
  268         *    3.1415926535897932384626433832795
  269         * :-))
  270         *
  271         * SET N TO 1/X = 5      (THIS IS THE FANCY FOOTWORK :-))
  272         *
  273         * 1) A) FORM THREE LARGE AS PRACTICAL EQUAL SIZED AREAS IN MEMORY.
  274         *       LETS CALL THEM "ACCUMULATOR",       ACCUM
  275         *                      "INTERMEDIATE",      INTER
  276         *                      "BASE OF NEXT TERM"  BASET
  277         *     B) FORM SMALLER WORKING AREAS
  278         *          ITERATION COUNTER ITCNT    USED FOR OBSERVATION
  279         *                  STARTS AT ZERO, COUNTS UP AFTER A PASS
  280         *          DIVISOR OF BASET, DIVBAS,   USUALLY 5^2 OR 239^2
  281         *                  5^2 = 25,   239^2 = 57121
  282         *          ADD/SUBTRACT CONTROL FLAG, CF , TOGGLED AFTER A PASS
  283         *                0 MEANS ADD, OTHER IS SUBTRACT
  284         *          DIVISOR OF INTER IS IX2P1 , ITCNT TIMES 2 PLUS 1
  285         *
  286         * 2) FIGURE WHERE THE DECIMAL POINT WILL BE
  287         *     (SAME RELATIVE PLACE IN EACH AREA)
  288         *     ( SEVERAL CHARACTERS OR WORDS TO THE "RIGHT" OF
  289         *       THE TOP SIGNIFICANCE.)
  290         *
  291         * 3) A) ZERO THE  ACCUM
  292         *     B) ( INTER DOES NOT NEED INITIALIZATION)
  293         *    C) SET X (5.0 IN OUR EXAMPLE) INTO BASET
  294         *    D) SET COUNTER N TO 1
  295         *
  296         * 4) WHILE BASET IS NON-ZERO
  297         *    A) DIVIDE BASET BY X^2  ( 25 IN OUR EXAMPLE ) GIVING BASET
  298         *    B) DIVIDE BASET BY (2XN - 1) GIVING INTER
  299         *    C) IF N IS ODD, ADD INTERMEDIATE TO ACCUMULATOR
  300         *           ELSE, SUBTRACT INTERMEDIATE FROM ACCUMULATOR
  301         *    D) ADD 1 TO N (ASSURE THAT MACHINE CAN DIVIDE BY 2N)
  302         *
  303         * 5) ACCUMULATOR IS A FINE APPROXIMATION OF ARCTAN(X)   ;-))
1                               SUBROUTINE  PI                                                            PAGE    6
0 SEQ PG LIN  LABEL  OP    OPERANDS                                            SFX CT  LOCN  INSTRUCTION TYPE  CARD
 
                     DCW   @+@                                                      1  2451              LIT     66
                     DCW   @0@                                                      1  2452              LIT     66
                     DCW   @80@                                                     2  2454              LIT     66
                     DCW   @1@                                                      1  2455              LIT     67
                     DCW   @956@                                                    3  2458              LIT     67
                     DCW   @000@                                                    3  2461              LIT     67
                     DCW   @549@                                                    3  2464              LIT     67
                     DCW   @008@                                                    3  2467              LIT     67
                     DCW   @. * 10E-00000@                                         13  2480              LIT     67
                     DCW   @00050@                                                  5  2485              LIT     67
                     DCW   @000050@                                                 6  2491              LIT     68
                     DCW   @000500@                                                 6  2497              LIT     68
  304                END   START  * LAST CARD IN DECK, TRANSFER ADDRESS                      / 164 080
1                               SUBROUTINE  PI                                                            PAGE    7
0SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  SYMBOL  ADDRESS  

 ACCUM    1901    ATAN      428    ATANA     556    ATANB     584    ATANI     596    ATANL     460    ATANS     538   
 ATANW     570    ATANX     622    BASET     801    C0        123    C1        129    C2        135    C239P2    147   
 C25       141    CF        154    CNTZRO    153    DIVBAS    111    HALT      424    INTER    1351    ITCNT     105   
 IX2P1     117    LC0L9     163    PR1LOP    675    PRINT     626    PRINTD    630    PRINTX    797    START     164   
 START1    335    START2    381    X1         89    X2         94    X3         99   



Object code for the 500 character Pi

,008015,022026,030037,044,049,053053N000000N00001026                   0001     
L068116,105106,110117B101/I9I#071029C029056B026/B001/0991,001/001117I0?0002     
,008015,022029,036040,047054,061068,072/061039              ,00100110400003     
000                                    L003089,040040,040040,04004010400004     
000                                    L003094,040040,040040,04004010400005     
000000000000000000000000000000001000002L039135,100106,112118,12413010400006     
0000250571210000001000000000MM51M50    L035170,142148,154155,16404010400007     
MM52M49B335                            L011181,178040,040040,04004010400008     
MM49M48MM52T49MT49T48MM54809MM55154    L035369,342349,356363,04004010400009     
M141111B428MM52T49MT49T48MM58809MM52154L039408,377381,388395,40204010400010     
M147111B428B626.164H625M123153M123105  L037445,416420,424428,43243910400011     
M129117MM61089MM51T50%111807MT43T50    L035480,453460,467474,04004010400012     
M163807MT50Z00MM51Z00%117T57MY93Z00    L035515,488495,502509,04004010400013     
M163T57MM51Z00B5561541MM55154SZ00M50   L036551,523530,538545,04004010400014     
B570AZ00M50MM52154A129105A135117       L032583,556563,570577,04004010400015     
B5968'10B460A129153H0890'1C153M64B584/ L038621,592596,603610,61704010400016     
B000H800MM67089M123105/332/MM80269     L034655,626630,637644,64864910400017     
,265MZ'1256H0890/02/252,203214,225236  L037692,660667,674675,67968610400018     
,247265AM85269MZ'1212H0890/0MZ'1223    L035727,700707,714721,04004010400019     
H0890/0MZ'1234H0890/0MZ'1245H0890/0    L035762,735742,749756,04004010400020     
MZ'1256H0890/02AM91105CM97105B675TB000 L038800,770777,778785,79279710400021     
                                       L039839)801801,040040,04004010400022     
                                       L039878)840840,040040,04004010400023     
                                       L039917)879879,040040,04004010400024     
                                       L039956)918918,040040,04004010400025     
                                       L039995)957957,040040,04004010400026     
                                       L039'34)996996,040040,04004010400027     
                                       L039'73)'35'35,040040,04004010400028     
                                       L039/12)'74'74,040040,04004010400029     
                                       L039/51)/13/13,040040,04004010400030     
                                       L039/90)/52/52,040040,04004010400031     
                                       L039S29)/91/91,040040,04004010400032     
                                       L039S68)S30S30,040040,04004010400033     
                                       L039T07)S69S69,040040,04004010400034     
                                       L039T46)T08T08,040040,04004010400035     
                                       L004T50)T47T47,801040,04004010400036     
                                       L039T89)T51T51,040040,04004010400037     
                                       L039U28)T90T90,040040,04004010400038     
                                       L039U67)U29U29,040040,04004010400039     
                                       L039V06)U68U68,040040,04004010400040     
                                       L039V45)V07V07,040040,04004010400041     
                                       L039V84)V46V46,040040,04004010400042     
                                       L039W23)V85V85,040040,04004010400043     
                                       L039W62)W24W24,040040,04004010400044     
                                       L039X01)W63W63,040040,04004010400045     
                                       L039X40)X02X02,040040,04004010400046     
                                       L039X79)X41X41,040040,04004010400047     
                                       L039Y18)X80X80,040040,04004010400048     
                                       L039Y57)Y19Y19,040040,04004010400049     
                                       L039Y96)Y58Y58,040040,04004010400050     
                                       L004Z00)Y97Y97,T51040,04004010400051     
                                       L039Z39)Z01Z01,040040,04004010400052     
                                       L039Z78)Z40Z40,040040,04004010400053     
                                       L039!17)Z79Z79,040040,04004010400054     
                                       L039!56)!18!18,040040,04004010400055     
                                       L039!95)!57!57,040040,04004010400056     
                                       L039J34)!96!96,040040,04004010400057     
                                       L039J73)J35J35,040040,04004010400058     
                                       L039K12)J74J74,040040,04004010400059     
                                       L039K51)K13K13,040040,04004010400060     
                                       L039K90)K52K52,040040,04004010400061     
                                       L039L29)K91K91,040040,04004010400062     
                                       L039L68)L30L30,040040,04004010400063     
                                       L039M07)L69L69,040040,04004010400064     
                                       L039M46)M08M08,040040,04004010400065     
    +080                               L008M54)M47M47,Z01M51,M52M5310400066     
1956000549008. * 10E-0000000050        L031M85,M56M59,M62M65,M68M8110400067     
000050000500                           L012M97,M92040,040040,04004010400068     
                                       /164080                         0069 

And the result (simulation running time unnoticeable on a fast PC)
                                               000000003. * 10E-00000
  1415926535 8979323846 2643383279 5028841971 6939937510. * 10E-00050
  5820974944 5923078164 0628620899 8628034825 3421170679. * 10E-00100
  8214808651 3282306647 0938446095 5058223172 5359408128. * 10E-00150
  4811174502 8410270193 8521105559 6446229489 5493038196. * 10E-00200
  4428810975 6659334461 2847564823 3786783165 2712019091. * 10E-00250
  4564856692 3460348610 4543266482 1339360726 0249141273. * 10E-00300
  7245870066 0631558817 4881520920 9628292540 9171536436. * 10E-00350
  7892590360 0113305305 4882046652 1384146951 9415116094. * 10E-00400
  3305727036 5759591953 0921861173 8193261179 3105118548. * 10E-00450
  0744623799 6274956735 1885752724 8912279381 8301194912. * 10E-00500