/decimal-computation-schmid-1974

APL and other artifacts from Schmid, H. Decimal Computation. (Wiley, New York, 1974) ISBN 978-0-471-76180-8

decimal-computation-schmid-1974

APL and other artifacts from the book Decimal Computation. Schmid, H. (Wiley, New York, 1974) ISBN 978-0-471-76180-8

APL

The apl directory contains APL code from the appendices from the book.

The code has been tested under Dyalog (version on 18.2 and 19.0 on MacOs Sonoma M1). The code is traditional APL not the modern dfn style. To get it to run under Dyalog, one line of code was modified to use the format ⍕ (thorn) which is the modern equivalent of the DFT formatting function used in the book's code. Note DFT was an APL/360 format command -- see https://dl.acm.org/doi/pdf/10.1145/585882.585894 for details.

Use

Clone the repo and run the Dyalog RIDE UI.

Create a linked namespace to read the code into the workspace (this assumes a Mac/unix -- change the slashes for Windows) Replace the stuff in curly braces to your local directory.

      ]LINK.Create decimalcomputation {full-directory-spec-to-local-repo}/decimal-computation-schmid-1974/apl

RIDE should reply with

Linked: #.decimalcomputation → {full-directory-spec-to-local-repo}/decimal-computation-schmid-1974/apl

To check status use

      ]LINK.status

Once loaded, you can test the APL. The following function call should generate Table 7.3 on page 168 of the book.

      #.decimalcomputation.COSANDSIN 30

Appendix B.3 LOG

This generates table 6.3. Note the function is changed as the error value generated in the book was different to that generated by Dyalog -some debugging infomation was added to print the S-register and the logarithm values.

Note the use of PP to set the printing precision (and the _ character that indicates that the machines resolution has been exceeded.) Plus FR is used to set the floating point representation which can be with 645 which is normal precision double or high precision 128-bit usong 1287.

      ⎕PP←16
      ⎕FR←645
      #.decimalcomoputation.LOG 2.1
STEP I.    A[I].   P-REGISTER. S-REGISTER
   0 0 0.0000000000000000  2.100000000000000_  0.0000000000000000
   1¯1 0.1000000000000000  0.2100000000000000  2.302585092994046_
   2 0 2.000000000000000_  0.4200000000000000  1.609437912434100_
   3 0 2.000000000000000_  0.8400000000000001  0.9162907318741548
   4 0 2.000000000000000_  1.680000000000000_  0.2231435513142095
   5 1 0.9000000000000000  1.512000000000000_  0.3285040669720358
   6 1 0.9000000000000000  1.360800000000000_  0.4338645826298621
   7 1 0.9000000000000000  1.224720000000000_  0.5392250982876883
   8 1 0.9000000000000000  1.102248000000000_  0.6445856139455146
   9 1 0.9000000000000000  0.9920232000000003  0.7499461296033410
  10 2 1.010000000000000_  1.001943432000000_  0.7399957987501729
  11 3 0.9990000000000000  1.000941488568000_  0.7409962990837564
  12 3 0.9990000000000000  0.9999405470794321  0.7419967994173400
  13 4 1.000100000000000_  1.000040541134140_  0.7418968044170067
  14 5 0.9999900000000000  1.000030540728729_  0.7419068044670070
  15 5 0.9999900000000000  1.000020540423321_  0.7419168045170073
  16 5 0.9999900000000000  1.000010540217917_  0.7419268045670075
  17 5 0.9999900000000000  1.000000540112515_  0.7419368046170078
  18 5 0.9999900000000000  0.9999905401071139  0.7419468046670081
  19 6 1.000001000000000_  0.9999915400976539  0.7419458046675083
  20 6 1.000001000000000_  0.9999925400891939  0.7419448046680084
  21 6 1.000001000000000_  0.9999935400817339  0.7419438046685085
  22 6 1.000001000000000_  0.9999945400752739  0.7419428046690086
  23 6 1.000001000000000_  0.9999955400698138  0.7419418046695088
  24 6 1.000001000000000_  0.9999965400653539  0.7419408046700089
  25 6 1.000001000000000_  0.9999975400618939  0.7419398046705090
  26 6 1.000001000000000_  0.9999985400594339  0.7419388046710091
 
TABLE 6-2:GENERATING LOG X WITH THE SEQUENTIAL TABLE LOOKUP TECHNIQUE
THIS EXAMPLE ILLUSTRATES THAT LOG(2.1) CAN BE GENERATED
IN 27 STEPS WITH AN ERROR OF ONLY 5.400573679370524E¯7
S= 0.7419368046720094
MACHINE LOG X= 0.7419373447293773

            ⎕FR←1287
      #.decimalcomputation.LOG 2.1
STEP I.    A[I].   P-REGISTER. S-REGISTER
   0 00.00000000000000002.10000000000000000.0000000000000000
   1¯10.10000000000000000.21000000000000002.3025850929940457
   2 02.00000000000000000.42000000000000001.6094379124341004
   3 02.00000000000000000.84000000000000000.9162907318741551
   4 02.00000000000000001.68000000000000000.2231435513142098
   5 10.90000000000000001.51200000000000000.3285040669720361
   6 10.90000000000000001.36080000000000000.4338645826298624
   7 10.90000000000000001.22472000000000000.5392250982876887
   8 10.90000000000000001.10224800000000000.6445856139455150
   9 10.90000000000000000.99202320000000000.7499461296033413
  10 21.01000000000000001.00194343200000000.7399957987501732
  11 30.99900000000000001.00094148856800000.7409962990837567
  12 30.99900000000000000.99994054707943200.7419967994173402
  13 41.00010000000000001.00004054113413990.7418968044170069
  14 50.99999000000000001.00003054072872860.7419068044670073
  15 50.99999000000000001.00002054042332130.7419168045170076
  16 50.99999000000000001.00001054021791710.7419268045670079
  17 50.99999000000000001.00000054011251490.7419368046170083
  18 50.99999000000000000.99999054010711380.7419468046670086
  19 61.00000100000000000.99999154009765390.7419458046675086
  20 61.00000100000000000.99999254008919400.7419448046680086
  21 61.00000100000000000.99999354008173410.7419438046685086
  22 61.00000100000000000.99999454007527420.7419428046690086
  23 61.00000100000000000.99999554006981420.7419418046695086
  24 61.00000100000000000.99999654006535430.7419408046700086
  25 61.00000100000000000.99999754006189440.7419398046705086
  26 61.00000100000000000.99999854005943440.7419388046710086
 
TABLE 6-2:GENERATING LOG X WITH THE SEQUENTIAL TABLE LOOKUP TECHNIQUE
THIS EXAMPLE ILLUSTRATES THAT LOG(2.1) CAN BE GENERATED
IN 27 STEPS WITH AN ERROR OF ONLY 5.400573687114162E¯7
S= 0.7419368046720086
MACHINE LOG X= 0.7419373447293773

Appendix C.1 COSANDSIN

This is the first function from Appendix C.

      #.decimalcomputation.COSANDSIN 30
      #.decimalcomputation.COSANDSIN 30

The results should be

   N.   I.   J.         X.         Y       SUM MU    PRODUCT K. 
    0    0    0    1.000000    0.000000    0.000000    1.000000
    1    0    1    1.000000    1.000000   45.000000    1.414214
    2    1    1    1.100000    0.900000   39.289407    1.421267
    3    1    2    1.190000    0.790000   33.578814    1.428356
    4    1    3    1.269000    0.671000   27.868221    1.435480
    5    1    4    1.201900    0.797900   33.578814    1.442639
    6    1    5    1.281690    0.677710   27.868221    1.449835
    7    1    6    1.213919    0.805879   33.578814    1.457066
    8    1    7    1.294507    0.684487   27.868221    1.464333
    9    1    8    1.226058    0.813938   33.578814    1.471636
   10    1    9    1.307452    0.691332   27.868221    1.478976
   11    2    1    1.300539    0.704406   28.441159    1.479050
   12    2    2    1.293495    0.717412   29.014098    1.479124
   13    2    3    1.286320    0.730347   29.587037    1.479198
   14    2    4    1.279017    0.743210   30.159975    1.479272
   15    2    5    1.286449    0.730420   29.587037    1.479346
   16    2    6    1.279145    0.743284   30.159975    1.479420
   17    2    7    1.286578    0.730493   29.587037    1.479494
   18    2    8    1.279273    0.743359   30.159975    1.479568
   19    2    9    1.286706    0.730566   29.587037    1.479642
   20    3    1    1.285976    0.731853   29.644332    1.479643
   21    3    2    1.285244    0.733139   29.701628    1.479643
   22    3    3    1.284511    0.734424   29.758924    1.479644
   23    3    4    1.283776    0.735708   29.816220    1.479645
   24    3    5    1.283041    0.736992   29.873515    1.479646
   25    3    6    1.282304    0.738275   29.930811    1.479646
   26    3    7    1.281565    0.739558   29.988107    1.479647
   27    3    8    1.280826    0.740839   30.045403    1.479648
   28    3    9    1.281567    0.739558   29.988107    1.479648
   29    4    1    1.281493    0.739686   29.993837    1.479649
   30    4    2    1.281419    0.739815   29.999566    1.479649
COSL=X÷PK=     0.8659791861
ERROR=COSL-X÷PK= ¯0.0000462177248
SINL=Y÷PK.     0.5000800429
ERROR=SINL-Y÷PK= 0.00008004290462