DSPRelated.com
Forums

Pi approximation games

Started by Tim Wescott May 1, 2012
On 02/05/2012 12:12, Uwe Hercksen wrote:
> > > David Brown schrieb: > >> At university I remember a project that involved calculating all the >> digits of pi. > > Hello, > > it is known since centuries that calculating all the > digits of pi is not possible. Pi has an infinite number of digits. > > Bye >
<http://en.wikipedia.org/wiki/Lazy_evaluation> The most relevant section, "working with infinite data structures", is missing - but I hope you get the point anyway. mvh., David
On 02/05/2012 09:07, Martin Brown wrote:

<snip>

> As a physicist I found the classic approximations > > pi^2 = g > pi x 10^7 seconds in a year > > quite handy to within 1% slide rule accuracy
Which is why a 1m pendulum has a half period of ~1 second using the classic formula two pi root ell over gee or: l g / sqrt pi * 2 * in RPN Cheers -- Syd
In article <jnq291$5dj$1@speranza.aioe.org>,
glen herrmannsfeldt  <gah@ugcs.caltech.edu> wrote:
>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.
That is standard fare in continued fractions. Everybody interested in these kind of approximations should take a look at this fascinating subject.
> >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
It depends. Pi has been calculated to billions of decimals. Simple floating point doesn't get you there. Groetjes Albert -- -- Albert van der Horst, UTRECHT,THE NETHERLANDS Economic growth -- being exponential -- ultimately falters. albert@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst
On Wed, 02 May 2012 11:10:53 +0200, David Brown
<david@westcontrol.removethisbit.com> wrote:

>On 02/05/2012 01:16, 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. >> > >Wikipedia is often a great starting point for these sorts of things. It >typically has enough information to give you some hints - but not so >much that you can't have fun finding out more: > ><http://en.wikipedia.org/wiki/Pi#Continued_fractions> > > >At university I remember a project that involved calculating all the >digits of pi. It was written using a functional programming language >(similar to Haskell) - the result was an unending list of the digits of >pi. But since the language used lazy evaluation, it didn't bother >calculating the entries until you tried to print them out. I used >polynomial expansions of arctan() to do the sums.
There was a short PDP-8 assembly program that printed the digits of e forever. -- John Larkin Highland Technology Inc www.highlandtechnology.com jlarkin at highlandtechnology dot com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom timing and laser controllers Photonics and fiberoptic TTL data links VME analog, thermocouple, LVDT, synchro, tachometer Multichannel arbitrary waveform generators
John Larkin wrote:

> There was a short PDP-8 assembly program that printed the digits of e > forever.
In order ? Mel.
On Tuesday, May 1, 2012 7:16:25 PM UTC-4, 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. > > -- > 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
Looking at a slide rule with a folded scale, a reasonable approximation to pi is immediately seen to be sqrt(10). rel. err less than 1%. Clay
<mwilson@the-wire.com> wrote in message news:jnrgfo$ccj$1@dont-email.me...
> John Larkin wrote: > >> There was a short PDP-8 assembly program that printed the digits of e >> forever. > > In order ? > > Mel. >
LOL
On Wed, 02 May 2012 10:31:20 -0400, mwilson@the-wire.com wrote:

>John Larkin wrote: > >> There was a short PDP-8 assembly program that printed the digits of e >> forever. > >In order ? > > Mel.
Yes. -- John Larkin Highland Technology Inc www.highlandtechnology.com jlarkin at highlandtechnology dot com Precision electronic instrumentation Picosecond-resolution Digital Delay and Pulse generators Custom timing and laser controllers Photonics and fiberoptic TTL data links VME analog, thermocouple, LVDT, synchro, tachometer Multichannel arbitrary waveform generators
On May 1, 8:26=A0pm, John Larkin <jlar...@highlandtechnology.com> wrote:
> On Tue, 01 May 2012 18:16:25 -0500, Tim Wescott <t...@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. =A0Then things get steadily better unti=
l
> >you hit 104348/33215 -- at which point the next lowest ratio which > >improves anything is 208341/66317, then 312689/99532. =A0At this point I > >decided that I would post my answers for your amusement, and get back to > >being productive. > > >Discrete math is so fun. =A0And these newfangled chips are just destroyi=
ng
> >the joy, by making floating point efficient and cheap enough that you > >don't need to know little tricks like pi =3D (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.
Grin... I always just let 2*pi =3D 10, so pi =3D 5! (and then remember there's a 1.59 floating around) George H.
> > We are increasingly using floats in embedded stuff. Our ARM LPC3250 > has SIMD hardware FP operations. > > -- > > John Larkin =A0 =A0 =A0 =A0 Highland Technology, Inc > > jlarkin at highlandtechnology dot comhttp://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 =A0 acquisition and simulation- Hide quot=
ed text -
> > - Show quoted text -

David Brown schrieb:

> <http://en.wikipedia.org/wiki/Lazy_evaluation> > > The most relevant section, "working with infinite data structures", is > missing - but I hope you get the point anyway.
Hello, even with infinite data structures, with finite time and finite RAM, it is not possible to compute all digits of pi. Bye