Post Reply 
(11C) Arithmetic with Fractions
09-16-2018, 11:41 PM (This post was last modified: 09-18-2018 07:07 PM by Thomas Klemm.)
Post: #5
RE: (11C) Arithmetic with Fractions
(09-16-2018 10:06 PM)Dieter Wrote:  A better algorithm would first determine the LCM of the denominators.

But even then the nominator numerator would be 100 instead of 31 due to rounding to 10 significant digits:

\(\begin{align*}
\frac{123,456,799}{123,456}-\frac{988,297,396}{988,291} &= \frac{123,456,799\times1,537}{123,456\times1,537}-\frac{988,297,396\times192}{988,291\times192} \\
&= \frac{189,753,100,063}{189,751,872}-\frac{189,753,100,032}{189,751,872} \\
&= \frac{189,753,100,063-189,753,100,032}{189,751,872} \\
&= \frac{31}{189751872}
\end{align*}
\)

W. Kahan explains in the linked paper how to avoid this.

Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(11C) Arithmetic with Fractions - Gamo - 09-15-2018, 07:02 AM
RE: (11C) Arithmetic with Fractions - Thomas Klemm - 09-16-2018 11:41 PM
RE: (11C) Arithmetic with Fractions - Gamo - 09-17-2018, 03:47 AM
RE: (11C) Arithmetic with Fractions - Gamo - 09-17-2018, 09:40 AM
RE: (11C) Arithmetic with Fractions - Gamo - 09-22-2018, 06:33 AM



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