Post Reply 
The new dfc and dfc2f functions in action
07-10-2018, 06:42 PM
Post: #10
RE: The new dfc and dfc2f functions in action
Uh oh... Problem found. The algorithm explained above (as well as Dale's and Didier's programs which implement it) is supposed to find the simplest fraction between two inputs EXclusive (the output is not supposed to be either of the inputs). But it can return a wrong result in one particular situation, namely, when the larger input is identical to the calculated output. Example:

Input 1 = 3/2 = continued fraction [ 1 2 ]
Input 2 = 4/3 = continued fraction [ 1 3 ]
The algorithm says to find the first elements that differ (in this example, 2 and 3), take the smaller one (2), add 1 to it (3), and terminate the continued fraction with that (which yields [ 1 3 ] which is equal to 4/3, which is one of the original inputs... and even worse, the OTHER input is simpler!).

[Image: edfc.png]

Bummer. The program could easily be patched by testing (after the algorithm finishes) to see if the output equals the larger input, but a meaningful change inside the algorithm itself would be more elegant (i.e. soul-satisfying). An alternative is to modify it to change its goal to be finding the simplest fraction between two inputs INclusive... but that would require modifying the algorithm too, I think. Hmmm. I feel like an ape staring up at a monolith.

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: The new dfc and dfc2f functions in action - Joe Horn - 07-10-2018 06:42 PM



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