(11C) Arithmetic with Fractions
09-17-2018, 04:04 PM (This post was last modified: 09-19-2018 05:09 PM by Albert Chan.)
Post: #11
 Albert Chan Senior Member Posts: 1,785 Joined: Jul 2018
RE: (11C) Arithmetic with Fractions
(09-17-2018 01:12 AM)Albert Chan Wrote:  Hi, Thomas Klemm,

Thanks for the link to Kahan paper. I tried it, it work perfectly.

However, Kahan's example does not shown the algorithm's power.
Doing the math as fixed fraction already avoid the overflow problem ...

I made up a better example, to show Kahan's algorithm, where mixed fraction trick won't work:

M/N = 1234567/12345648 - 635720/6357263

From Kahan's paper: (using HP-12C, with my Mod/Gcd program)
G = gcd(12345648, 6357263) = 181
b = 12345648 / 181 = 68208
d = 6357263 / 181 = 35123
a = 1234567 % 181 = 147
c = 635720 % 181 = 48
ad - bc = 147*35123 - 68208*48 = 1889097 = 181 * 10437
g =gcd(G, ad - bc) = 181

M = 10437 + Det({{6820, 68208}, {3512, 35123}}) = 10437 - 7636 = 2,801
N = G/g * b * d = 68208 * 35123 = 2,395,669,584
 « Next Oldest | Next Newest »

 Messages In This Thread (11C) Arithmetic with Fractions - Gamo - 09-15-2018, 07:02 AM RE: (11C) Arithmetic with Fractions - Dieter - 09-16-2018, 04:58 PM RE: (11C) Arithmetic with Fractions - Thomas Klemm - 09-16-2018, 09:17 PM RE: (11C) Arithmetic with Fractions - Dieter - 09-16-2018, 10:06 PM RE: (11C) Arithmetic with Fractions - Steve Simpkin - 09-17-2018, 01:46 AM RE: (11C) Arithmetic with Fractions - Thomas Klemm - 09-16-2018, 11:41 PM RE: (11C) Arithmetic with Fractions - Dieter - 09-18-2018, 06:51 PM RE: (11C) Arithmetic with Fractions - Valentin Albillo - 09-18-2018, 09:25 PM RE: (11C) Arithmetic with Fractions - Dieter - 09-18-2018, 10:38 PM RE: (11C) Arithmetic with Fractions - Massimo Gnerucci - 09-19-2018, 07:45 AM RE: (11C) Arithmetic with Fractions - Albert Chan - 09-17-2018, 01:12 AM RE: (11C) Arithmetic with Fractions - Albert Chan - 09-17-2018 04:04 PM RE: (11C) Arithmetic with Fractions - Gamo - 09-17-2018, 03:47 AM RE: (11C) Arithmetic with Fractions - Carsen - 09-17-2018, 08:14 AM RE: (11C) Arithmetic with Fractions - Gamo - 09-17-2018, 09:40 AM RE: (11C) Arithmetic with Fractions - Albert Chan - 09-17-2018, 06:44 PM RE: (11C) Arithmetic with Fractions - Thomas Klemm - 09-18-2018, 07:19 PM RE: (11C) Arithmetic with Fractions - Thomas Klemm - 09-18-2018, 07:29 PM RE: (11C) Arithmetic with Fractions - Gamo - 09-22-2018, 06:33 AM RE: (11C) Arithmetic with Fractions - Dieter - 09-24-2018, 12:59 PM RE: (11C) Arithmetic with Fractions - Dieter - 09-24-2018, 05:29 PM

User(s) browsing this thread: 1 Guest(s)