The best rational approximations to a number can be obtained from its continued fraction representation. Simply truncating the continued fraction gives a smaller list of approximants which are accurate relative to the size of their denominators, and truncating and possibly reducing the last number in the continued fraction gives a longer list of continued fractions which are the best in a looser sense.
http://code.jsoftware.com/wiki/Essays/Continued_Fractions https://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations Here are the first few terms in π's continued fraction representation: (<.,[:%1|{:)^:10 ]1p1 3 7 15 1 292 1 1 1 2 1 3.93464 The first six approximants: ]a =: (+%)/\ x:<. (<.,[:%1|{:)^:5 ]1p1 3 22r7 333r106 355r113 103993r33102 104348r33215 Numerator, denominator, and absolute error: (2&x: ,. -&1p1) a 3 1 _0.141593 22 7 0.00126449 333 106 _8.32196e_5 355 113 2.66764e_7 103993 33102 _5.77891e_10 104348 33215 3.31628e_10 Marshall On Wed, Mar 09, 2016 at 02:44:28PM -0700, Don Guinn wrote: > Rational numbers have always fascinated me. I wanted to build a gear train > for a science fair where the gears form a loop where the gear train does > not mesh. But only after many thousands of revolutions. Then a sign on the > front asking people to break the gears by turning the crank. > > Long ago the Hammond organ used a gear train to approximate the twelfth > root of two and powers of it to build the notes in the octave. Now > electronics do that more effectively. > > The ratio Roger showed in a previous post are too large to be pleasing. > Smaller numbers in the ratio could still be useful and still be accurate > enough for some purposes. > > I realize that this request is a little vague, but this is just an > extention to the original challenge. > On Mar 9, 2016 9:38 AM, "Raul Miller" <[email protected]> wrote: > > > That seems a bit underspecified, or open-ended, at the moment. > > > > For example, pi could be 1p1 (or o.1) or pi could be any of a number > > of algorithms: https://en.wikipedia.org/wiki/Category:Pi_algorithms > > > > Meanwhile, there's also the precision aspect - that could also be > > specified in a variety of ways. > > > > In other words, you might be asking for something like this: > > 7%~x:<.0.5+7*1p1 > > 22r7 > > > > Or you might have something different in mind, like perhaps this: > > ~.@(#~ (= <./)@:|@:-&1p1),%/~i.100x > > 22r7 > > > > Or, significantly slower, but almost tolerable: > > ~.@(#~ (= <./)@:|@:-&1p1),%/~i.1000x > > 355r113 > > > > Or, ... any of a variety of other mechanisms... (and even brute force > > search techniques could be made to be significantly more efficient - a > > moment's thought would show that incorporating the rounding technique, > > for example, could have increased the speed of that last search by > > something near a factor of 1000). > > > > Anyways, if you can say a bit more about what you were aiming for, > > maybe we could do a better job of getting there? > > > > Thanks, > > > > -- > > Raul > > > > On Wed, Mar 9, 2016 at 11:18 AM, Don Guinn <[email protected]> wrote: > > > How about rounding to a rational of some precision like pi rounded to > > 22r7 ? > > > On Mar 9, 2016 8:52 AM, "Kip Murray" <[email protected]> wrote: > > > > > >> Thanks, Roger and Raul. Not understanding GCD +. I had a Rube > > Goldberg > > >> solution involving Format ": and Do ". --Kip > > >> > > >> On Wednesday, March 9, 2016, Roger Hui <[email protected]> > > wrote: > > >> > > >> > den and num illustrate different ways of computing the same thing, > > >> > hopefully in so doing improves understanding. If you want speed 2&x: > > is > > >> > going to be faster. > > >> > > > >> > Also, watch this: > > >> > > > >> > 2 x: o. 1 > > >> > 1285290289249 409120605684 > > >> > x: o. 1 > > >> > 1285290289249r409120605684 > > >> > > > >> > 2 x:!.0 o. 1 > > >> > 884279719003555 281474976710656 > > >> > x:!.0 o. 1 > > >> > 884279719003555r281474976710656 > > >> > > > >> > > > >> > > > >> > > > >> > On Wed, Mar 9, 2016 at 7:20 AM, Mike Day <[email protected] > > >> > <javascript:;>> wrote: > > >> > > > >> > > Roger, are these (among) recommended and preferred methods for > > >> > > recovering num & den, or do they just show an elegant way of > > >> > > avoiding 2 x: ? > > >> > > > > >> > > Thanks, > > >> > > > > >> > > Mike > > >> > > > > >> > > > > >> > > On 09/03/2016 04:32, Roger Hui wrote: > > >> > > > > >> > >> x=: %/?2$10^8x > > >> > >> x > > >> > >> 69904549r40669028 > > >> > >> > > >> > >> den=: [: % 1 +. ] > > >> > >> num=: * den > > >> > >> > > >> > >> den x > > >> > >> 40669028 > > >> > >> num x > > >> > >> 69904549 > > >> > >> > > >> > >> > > >> > >> > > >> > >> > > >> > >> On Tue, Mar 8, 2016 at 7:28 PM, Kip Murray <[email protected] > > >> > <javascript:;>> > > >> > >> wrote: > > >> > >> > > >> > >> That's great! It's still a nice puzzle to write your own. --Kip > > >> > >>> > > >> > >>> On Tuesday, March 8, 2016, Raul Miller <[email protected] > > >> > <javascript:;>> wrote: > > >> > >>> > > >> > >>> 2 x: 6r4 > > >> > >>>> 3 2 > > >> > >>>> > > >> > >>>> -- > > >> > >>>> Raul > > >> > >>>> > > >> > >>>> > > >> > >>>> On Tue, Mar 8, 2016 at 10:04 PM, Kip Murray < > > [email protected] > > >> > <javascript:;> > > >> > >>>> <javascript:;>> wrote: > > >> > >>>> > > >> > >>>>> How do you find the numerator and denominator in lowest terms > > of a > > >> > >>>>> > > >> > >>>> rational > > >> > >>>> > > >> > >>>>> fraction? For example, > > >> > >>>>> > > >> > >>>>> nd 6r4 > > >> > >>>>> 3 2 > > >> > >>>>> > > >> > >>>>> --Kip Murray > > >> > >>>>> > > >> > >>>>> > > >> > >>>>> > > >> > >>>>> -- > > >> > >>>>> Sent from Gmail Mobile > > >> > >>>>> > > >> > ---------------------------------------------------------------------- > > >> > >>>>> For information about J forums see > > >> > http://www.jsoftware.com/forums.htm > > >> > >>>>> > > >> > >>>> > > >> ---------------------------------------------------------------------- > > >> > >>>> For information about J forums see > > >> > http://www.jsoftware.com/forums.htm > > >> > >>>> > > >> > >>> > > >> > >>> > > >> > >>> -- > > >> > >>> Sent from Gmail Mobile > > >> > >>> > > >> ---------------------------------------------------------------------- > > >> > >>> For information about J forums see > > >> http://www.jsoftware.com/forums.htm > > >> > >>> > > >> > >>> > > >> ---------------------------------------------------------------------- > > >> > >> For information about J forums see > > >> http://www.jsoftware.com/forums.htm > > >> > >> > > >> > > > > >> > > > > >> > > --- > > >> > > This email has been checked for viruses by Avast antivirus software. > > >> > > https://www.avast.com/antivirus > > >> > > > > >> > > > > ---------------------------------------------------------------------- > > >> > > For information about J forums see > > http://www.jsoftware.com/forums.htm > > >> > ---------------------------------------------------------------------- > > >> > For information about J forums see > > http://www.jsoftware.com/forums.htm > > >> > > >> > > >> > > >> -- > > >> Sent from Gmail Mobile > > >> ---------------------------------------------------------------------- > > >> For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > > > For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
