50G fraction question Q-> function max denominator
11-08-2019, 07:01 PM
Post: #14
 Albert Chan Senior Member Posts: 2,551 Joined: Jul 2018
RE: 50G fraction question Q-> function max denominator
(10-29-2019 02:16 PM)DavidM Wrote:  After thinking about this question a bit, a slightly different idea came to mind. I was wondering how I would determine which fraction whose denominator is a power of two would be the best fit for a given real number. I'm sure there's a more elegant way to do this, but I came up with the following brute-force approach which simply checks each possibility starting with "/2" and multiplying the denominator by 2 up to the specified limit. The closest combination is then returned as a symbolic number in the form "a+b/c" (or simply "b/c" as appropriate) ...

For x best estimate with maximum denominator D, *AND* final denominator divides D, simply calculate round(x D) / D

Example:

x = e, D=512 => round(e * 512) / 512 = 1392 / 512 = 2 + 23/32
x = Pi, D=3600 => round(Pi * 3600) / 3600 = 11310 / 3600 = 3 + 17/120
 « Next Oldest | Next Newest »

 Messages In This Thread 50G fraction question Q-> function max denominator - 100LL - 10-24-2019, 02:58 PM RE: 50G fraction question Q-> function max denominator - ijabbott - 10-24-2019, 04:24 PM RE: 50G fraction question Q-> function max denominator - burkhard - 10-24-2019, 09:09 PM RE: 50G fraction question Q-> function max denominator - Joe Horn - 10-24-2019, 09:59 PM RE: 50G fraction question Q-> function max denominator - cdmackay - 10-24-2019, 11:02 PM RE: 50G fraction question Q-> function max denominator - Joe Horn - 10-25-2019, 05:26 AM RE: 50G fraction question Q-> function max denominator - 100LL - 10-25-2019, 01:47 PM RE: 50G fraction question Q-> function max denominator - cdmackay - 10-25-2019, 04:52 PM RE: 50G fraction question Q-> function max denominator - 100LL - 10-25-2019, 09:42 PM RE: 50G fraction question Q-> function max denominator - Joe Horn - 10-25-2019, 11:42 PM RE: 50G fraction question Q-> function max denominator - ijabbott - 10-26-2019, 08:56 AM RE: 50G fraction question Q-> function max denominator - DavidM - 10-29-2019, 02:16 PM RE: 50G fraction question Q-> function max denominator - DavidM - 11-08-2019, 05:54 PM RE: 50G fraction question Q-> function max denominator - Albert Chan - 11-08-2019 07:01 PM RE: 50G fraction question Q-> function max denominator - DavidM - 11-08-2019, 08:43 PM RE: 50G fraction question Q-> function max denominator - Joe Horn - 11-08-2019, 09:01 PM RE: 50G fraction question Q-> function max denominator - Albert Chan - 11-08-2019, 10:05 PM RE: 50G fraction question Q-> function max denominator - DavidM - 11-09-2019, 01:46 PM

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