DSPRelated.com
Forums

Pi approximation games

Started by Tim Wescott May 1, 2012
On 05/02/2012 01:16 AM, 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. >
You might find fun at the opposite game too, have a look: http://mathworld.wolfram.com/AlmostInteger.html bye, -- piergiorgio
On 02/05/2012 16:20, George Herold wrote:

<snip>
> > Grin... I always just let 2*pi = 10, so pi = 5! >
That's known as a 'Selleck' or a 'Magnum PI'. Cheers -- Syd
On Wed, 02 May 2012 21:09:05 +0200, Piergiorgio Sartor
<piergiorgio.sartor.this.should.not.be.used@nexgo.REMOVETHIS.de>
wrote:

>On 05/02/2012 01:16 AM, 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. >> > >You might find fun at the opposite game too, have a look: > >http://mathworld.wolfram.com/AlmostInteger.html > >bye,
This is cool. http://mathworld.wolfram.com/ResistorNetwork.html I did this by hand recently... http://dl.dropbox.com/u/53724080/Circuits/R-pak_values.JPG One could also do the set of possible voltage dividers and corresponding opamp gains. -- 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
halong <ccon67@netscape.net> writes:

> On May 2, 1:44&nbsp;am, John Devereux <j...@devereux.me.uk> wrote: >> spop...@speedymail.org (Steve Pope) writes: >> > John Devereux &nbsp;<j...@devereux.me.uk> wrote: >> >> >>John S <Soph...@invalid.org> writes: >> >> >>> 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! >> >> > I recall the time when you couldn't consider 25.4 mm to be exactly >> > one inch. &nbsp;But, they fudged enough standards so that it is now exact. >> >> Aha, good idea, we should standardize pi to a more convenient value! :) >> > > But who want to use your PY to calculate the circle circumference, > with given diameter
Err... well it will give the correct result in a sufficiently curved space-time. I can't help it if people are using it in the wrong universe! -- John Devereux
I wonder if there's a theorem that states: given a small positive number
epsilon, there exists a rational number that is within epsilon to pi. 
David Drumm <drumm@n_o_s_p_a_m.coherentlogix.com> wrote:

> I wonder if there's a theorem that states: given a small > positive number epsilon, there exists a rational number > that is within epsilon to pi.
Well, you can always write the appropriate number of decimal digits in the numerator, and the appropriate power of 10 in the denominator. The interesting cases are those where the total digits of the numerator and denominator is (much) less than the number of digits that are correct in the approximation. While one can always loop over the denominator and test the result, I believe that there is an algorithm that will quickly find the best approximations. -- glen
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).
See: http://www.mindspring.com/~alanh/fracs.html
> 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.
According to the above, they go 3/1, 22/7, 333/106, 355/113, 103993/33102, 104348/33215, the next two you note, and then 833719/265381, well, try out the site. (snip) The javascript code for the above site, which says no license and free to copy, uses the following to do the computation: var maxNumerator = getMaxNumerator(d); var d2 = d; var calcD, prevCalcD = NaN; for (var i = 2; i < 1000; i++) { var L2 = Math.floor(d2); numerators[i] = L2 * numerators[i-1] + numerators[i-2]; if (Math.abs(numerators[i]) > maxNumerator) return; denominators[i] = L2 * denominators[i-1] + denominators[i-2]; calcD = numerators[i] / denominators[i]; if (calcD == prevCalcD) return; appendFractionsOutput(numerators[i], denominators[i]); if (calcD == d) return; prevCalcD = calcD; d2 = 1/(d2-L2); } I haven't gone through it in detail, but you can see that it is pretty fast. Each is generated directly from the previous one, with no loop through successive denominators. -- glen
glen herrmannsfeldt  <gah@ugcs.caltech.edu> wrote:

>David Drumm <drumm@n_o_s_p_a_m.coherentlogix.com> wrote:
>> I wonder if there's a theorem that states: given a small >> positive number epsilon, there exists a rational number >> that is within epsilon to pi.
>Well, you can always write the appropriate number of decimal >digits in the numerator, and the appropriate power of 10 in >the denominator.
It's not the same exact question, but I thought that whether there is always a rational number between two transcendental numbers depend on the Axiom of Choice. I could be mistaken here, it's been a long time. Steve
glen herrmannsfeldt wrote:
> In comp.dsp VWWall <vwall@large.invalid> wrote: > > (snip) > >> kilogram (kg) > >> "The kilogram is equal to the mass of the international >> prototype of the kilogram." > > There are at least two projects to redefine the kilogram, such > that it isn't dependent on a physical object. > > One involves a more accurate determination of Avogadro's number. >
Avogadro's number is currently: 6.02214129*10^23 entities per mole and has an uncertainty of plus or minus 27 counts in its last two digits. Another requires the precise definition of Planck's constant which is: 6.62606957*10^&minus;34 and has an uncertainty of plus or minus 29 counts in its last two digits. I wonder if either or both of these "constants" can be defined as the ratio of integers. :-) -- Virg Wall
VWWall wrote:
> glen herrmannsfeldt wrote: >> In comp.dsp VWWall <vwall@large.invalid> wrote: >> >> (snip) >> >>> kilogram (kg) >> >>> "The kilogram is equal to the mass of the international prototype of >>> the kilogram." >> >> There are at least two projects to redefine the kilogram, such >> that it isn't dependent on a physical object. >> >> One involves a more accurate determination of Avogadro's number. >> > Avogadro's number is currently: 6.02214129*10^23 entities per mole and > has an uncertainty of plus or minus 27 counts in its last two digits. >
Any uncertainty is an artifact of measurement. It's a *count*, so ...
> Another requires the precise definition of Planck's constant which is: > > 6.62606957*10^&minus;34 and has an uncertainty of plus or minus 29 counts in > its last two digits. > > I wonder if either or both of these "constants" can be defined as the > ratio of integers. :-) >
Avogadro's Number is a natural number - so yes. -- Les Cargill