(02-04-2015 06:52 AM)Katie Wasserman Wrote: A lot of this is fluff but not all, William Kahan has some papers on this site. For example this one on rational arithmetic in floating point. He gives programs for the 67/97 and the 71b and mentions the 15C and 41C.
Thanks for sharing the paper.
Cheers
Thomas
Usage:
Code:
The stack holds four integers X, Y, Z, T construed as two rational numbers Y/X and T/Z ,
both presumed to be in lowest terms (ilt). If not, pressing [E] will reduce Y/X to lowest
terms while leaving T/Z unchanged. The four rational operations are performed by pressing one of
the keys [A], [B], [C], [D] to invoke reliable programs, or [a], [b], [c], [d] to invoke obvious
programs. The reliable programs accept integers as large as 1,999,999,999 and deliver exactly
correct results up to 8,000,000,000 . Specifically, the programs ...
Add: Press [A] or [a] to put Y/X := (T/Z) + (Y/X) ilt, leaving T/Z unchanged.
Subtract: Press [B] or [b] to put Y/X := (T/Z) - (Y/X) ilt, leaving T/Z unchanged.
Multiply: Press [C] or [c] to put Y/X := (T/Z) * (Y/X) ilt, leaving T/Z unchanged.
Divide: Press [D] or [d] to put Y/X := (T/Z) / (Y/X) ilt, leaving T/Z unchanged.
Reduce: Press [E] to put Y/X := (Y/X) ilt, leaving T/Z unchanged.
GCD: Press [e] to put X := Greatest Common Divisor of X and Y .
REM: Press [GSB] [8] to put X := Y - nX and n : = Integer nearest Y/X into reg. 8 .
The programs use registers 0 to 8 and I, and labels 2 to 8 too.
Example:
\(\frac{123,456,799}{123,456}-\frac{988,297,396}{988,291}=\frac{31}{189751872}\)
1234 56799.
[ENTER↑]
123456.
[ENTER↑]
9882 97396.
[ENTER↑]
988291.
\([\)B]
1897 51872.
[x<>y]
31.
Program:
Code:
LBL A
CHS
LBL B
GSB 7
X<>Y
R^
STO 4
GSB e
X=0?
EEX
STO 5
STO/ 0
STO/ 4
RCL 1
X<>Y
GSB 8
RCL 4
*
STO 6
RCL 3
R^
GSB 8
RCL 0
STO 7
*
RCL 6
-
GSB e
STO/ 5
RCL 1
X<>Y
GSB 8
RCL 4
STO* 0
*
STO 1
RCL 8
STO 6
RCL 3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