DSPRelated.com
Forums

Pi approximation games

Started by Tim Wescott May 1, 2012
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.

-- 
My liberal friends think I'm a conservative kook.
My conservative friends think I'm a liberal kook.
Why am I not happy that they have found common ground?

Tim Wescott, Communications, Control, Circuits & Software
http://www.wescottdesign.com
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
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. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
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/ :-)
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...
Tim Wescott  <tim@seemywebsite.com> 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.
Suppose you do the same thing with the fine structure constant -- let me know what you discover. Steve
On Tue, 01 May 2012 18:16:25 -0500, 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). > >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 once knew pi to 100 places, but now I've forgotten everything past 19. -- John Larkin Highland Technology, Inc jlarkin at highlandtechnology dot com http://www.highlandtechnology.com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom laser drivers and controllers Photonics and fiberoptic TTL data links VME thermocouple, LVDT, synchro acquisition and simulation
On Tue, 01 May 2012 18:16:25 -0500, 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). > >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.
My old HP35 calculators have a key for pi. The newer ones hide it, a tiny pastel shift key thing. So I just key in 3.14. Rob down the hall uses 3. We are increasingly using floats in embedded stuff. Our ARM LPC3250 has SIMD hardware FP operations. -- John Larkin Highland Technology, Inc jlarkin at highlandtechnology dot com http://www.highlandtechnology.com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom laser drivers and controllers Photonics and fiberoptic TTL data links VME thermocouple, LVDT, synchro acquisition and simulation
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.
"John S" <Sophi.2@invalid.org> wrote in message news:jnpvhd$qj3$1@dont-email.me...
> > 245/78 is more easily forgotten.
I learned to twin the first 3 odd digits - 113355. Then divide the first 3 into the last 3. Easily remembered. Art