John S wrote:> On 5/1/2012 6:28 PM, Tim Wescott wrote: >> On Tue, 01 May 2012 18:21:29 -0500, John S wrote: >> >>> On 5/1/2012 6:16 PM, Tim Wescott wrote: >>>> Instead of doing productive work, I just spent a few enjoyable minutes >>>> with Scilab finding approximations to pi of the form m/n. >>>> >>>> Because I'm posting to a couple of nerd groups, I can be confident that >>>> most of you probably know 22/7 off the tops of your heads. >>>> >>>> What interested me is how spotty things are -- after 22/7, the error >>>> drops for a bit until you get down to 355/113 (which, if you're at an >>>> equal level of nerdiness to me will ring a bell, but not have been >>>> swimming around in your brain to be found). >>>> >>>> But what's _really_ interesting, is that the next better fit isn't >>>> found until you get up to 52163/16604. Then things get steadily better >>>> until you hit 104348/33215 -- at which point the next lowest ratio >>>> which improves anything is 208341/66317, then 312689/99532. At this >>>> point I decided that I would post my answers for your amusement, and >>>> get back to being productive. >>>> >>>> Discrete math is so fun. And these newfangled chips are just >>>> destroying the joy, by making floating point efficient and cheap enough >>>> that you don't need to know little tricks like pi = (almost) 355/113. >>>> >>>> >>> I like the idea that both 22 and 7 each fit into a byte whereas 355 does >>> not. And, 22/7 is hi by only .04%. Beautiful! >>> >>> John S >> >> 245/78. It's only a bit better than twice as good as 22/7 -- then along >> comes 355/113, which is over 1000 times better than 245/78. >> > > 245/78 is more easily forgotten.but highly mnenomic - it's 2345678 with the 3 dropped and the 6 turned into a divide sign... -- Les Cargill
Pi approximation games
Started by ●May 1, 2012
Reply by ●May 1, 20122012-05-01
Reply by ●May 1, 20122012-05-01
Tim Wescott <tim@seemywebsite.com> wrote:>Instead of doing productive work, I just spent a few enjoyable minutes >with Scilab finding approximations to pi of the form m/n. > >Because I'm posting to a couple of nerd groups, I can be confident that >most of you probably know 22/7 off the tops of your heads.Now you mention it :-)>Discrete math is so fun. And these newfangled chips are just destroying >the joy, by making floating point efficient and cheap enough that you >don't need to know little tricks like pi = (almost) 355/113.You can always declare a constant or use pi=4*arctan(1) although I seldomly see the latter. -- Failure does not prove something is impossible, failure simply indicates you are not using the right tools... nico@nctdevpuntnl (punt=.) --------------------------------------------------------------
Reply by ●May 1, 20122012-05-01
On 5/1/2012 6:30 PM, Joel Koltner wrote:> Tim Wescott wrote: >> Discrete math is so fun. And these newfangled chips are just destroying >> the joy, by making floating point efficient and cheap enough that you >> don't need to know little tricks like pi = (almost) 355/113. > > --> http://xkcd.com/1047/ > > :-) >Off the subject, but this one is really funny... http://xkcd.com/1020/
Reply by ●May 1, 20122012-05-01
John S <Sophi.2@invalid.org> writes:> On 5/1/2012 6:30 PM, Joel Koltner wrote: >> Tim Wescott wrote: >>> Discrete math is so fun. And these newfangled chips are just destroying >>> the joy, by making floating point efficient and cheap enough that you >>> don't need to know little tricks like pi = (almost) 355/113. >> >> --> http://xkcd.com/1047/ >> >> :-) >> > > Off the subject, but this one is really funny... > > http://xkcd.com/1020/That's mean - at the end "not all these are wrong" - several looked close (at least in my head). -- Randy Yates DSP/Firmware Engineer 919-577-9882 (H) 919-720-2916 (C)
Reply by ●May 1, 20122012-05-01
In comp.dsp Tim Wescott <tim@seemywebsite.com> wrote:> Instead of doing productive work, I just spent a few enjoyable minutes > with Scilab finding approximations to pi of the form m/n.> Because I'm posting to a couple of nerd groups, I can be confident > that most of you probably know 22/7 off the tops of your heads.> What interested me is how spotty things are -- after 22/7, the error > drops for a bit until you get down to 355/113 (which, if you're at an > equal level of nerdiness to me will ring a bell, but not have been > swimming around in your brain to be found).Yes. It was the first problem in the book for the HP 25C calculator that I got many years ago.> But what's _really_ interesting, is that the next better fit > isn't found until you get up to 52163/16604. Then things get > steadily better until you hit 104348/33215 -- at which point > the next lowest ratio which improves anything is 208341/66317, > then 312689/99532. At this point I decided that I would post > my answers for your amusement, and get back to being productive.There is an algorithm that some calculators use for converting a decimal result to a fraction. If I remember, that one easily finds successively better fractions approximating any given value. I don't remember the details, but I do remember how funny it is, in that at one point it takes two fractions, and adds their numerators and denominators, before goint to the next step. I believe it is described in the manual for one of the HP calculators that does that conversion. Otherwise, I have the TI-92, which will generate fraction (rational) results, then you ask for an approximate result. Some calculations will give a symbolic pi result.> Discrete math is so fun. And these newfangled chips are just > destroying the joy, by making floating point efficient and > cheap enough that you don't need to know little tricks > like pi = (almost) 355/113.-- glen
Reply by ●May 2, 20122012-05-02
>Instead of doing productive work, I just spent a few enjoyable minutes >with Scilab finding approximations to pi of the form m/n. > >Because I'm posting to a couple of nerd groups, I can be confident that >most of you probably know 22/7 off the tops of your heads. > >What interested me is how spotty things are -- after 22/7, the error >drops for a bit until you get down to 355/113 (which, if you're at an >equal level of nerdiness to me will ring a bell, but not have been >swimming around in your brain to be found). > >But what's _really_ interesting, is that the next better fit isn't found >until you get up to 52163/16604. Then things get steadily better until >you hit 104348/33215 -- at which point the next lowest ratio which >improves anything is 208341/66317, then 312689/99532. At this point I >decided that I would post my answers for your amusement, and get back to >being productive. > >Discrete math is so fun. And these newfangled chips are just destroying >the joy, by making floating point efficient and cheap enough that you >don't need to know little tricks like pi = (almost) 355/113.The approximation I usually use is 314159265358979323/100000000000000000 . It works well for most applications, and is easy to adapt for shorter word lengths. Steve
Reply by ●May 2, 20122012-05-02
On 5/1/12 8:14 PM, Steve Pope wrote:> Tim Wescott<tim@seemywebsite.com> wrote: >...>> >> 245/78. It's only a bit better than twice as good as 22/7 -- then along >> comes 355/113, which is over 1000 times better than 245/78. > > Suppose you do the same thing with the fine structure constant -- > let me know what you discover. >not quite m/n but alpha = cos(pi*137)/137 * tan(pi*(29*137))/(pi*(29*137)) actually i think that sqrt(4*pi*alpha) = 0.30282212 is the more fundamental number than the fine-structure constant. the fine-structure constant should be thought of as a consequence of this number. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●May 2, 20122012-05-02
On 5/1/12 11:33 PM, steveu wrote:> > The approximation I usually use is 314159265358979323/100000000000000000 . > It works well for most applications, and is easy to adapt for shorter word > lengths.i think that maybe the state of Indiana can legislate that value for pi. their other attempt wasn't so good. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●May 2, 20122012-05-02
On 5/1/12 7:35 PM, Joel Koltner wrote:> John S wrote: >> I like the idea that both 22 and 7 each fit into a byte whereas 355 does >> not. And, 22/7 is hi by only .04%. Beautiful! > > Jack Crenshaw's book, "Math Toolkit for Real-Time Programming" > (http://www.amazon.com/Math-Toolkit-Real-Time-Programming-ebook/dp/B003WUYQVY) > spends a lot of time discussing how to make "good enough" approximations > of various, e.g., transcendental functions... and how to know when "good > enough" really is. It's quite handy for this sort of thing...i've sent him some series that were simpler and better than his (at least those that were published at the time). i have no idea what rules of optimization he was using. he wrote back. didn't see anything happen about it since. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●May 2, 20122012-05-02
John S <Sophi.2@invalid.org> writes:> On 5/1/2012 6:16 PM, Tim Wescott wrote: >> Instead of doing productive work, I just spent a few enjoyable minutes >> with Scilab finding approximations to pi of the form m/n. >> >> Because I'm posting to a couple of nerd groups, I can be confident that >> most of you probably know 22/7 off the tops of your heads. >> >> What interested me is how spotty things are -- after 22/7, the error >> drops for a bit until you get down to 355/113 (which, if you're at an >> equal level of nerdiness to me will ring a bell, but not have been >> swimming around in your brain to be found). >> >> But what's _really_ interesting, is that the next better fit isn't found >> until you get up to 52163/16604. Then things get steadily better until >> you hit 104348/33215 -- at which point the next lowest ratio which >> improves anything is 208341/66317, then 312689/99532. At this point I >> decided that I would post my answers for your amusement, and get back to >> being productive. >> >> Discrete math is so fun. And these newfangled chips are just destroying >> the joy, by making floating point efficient and cheap enough that you >> don't need to know little tricks like pi = (almost) 355/113. >> > > I like the idea that both 22 and 7 each fit into a byte whereas 355 > does not. And, 22/7 is hi by only .04%. Beautiful!We had a teacher that insisted it was exactly equal! -- John Devereux