Post Reply 
Happy Pi day everyone!!
03-15-2019, 12:45 AM
Post: #9
RE: Happy Pi day everyone!!
 
Hi, all:
       
This must be one of the least known ways to compute Pi (no circles, trigonometry or integrals in sight). Here's my implementation for the HP-71B, a user-defined function trivially easy to convert to RPN, RPL or whatever:

       1   DEF FNP(N)
       2       T = N
       3       FOR I = N-1 TO 2 STEP -1
       4             T = CEIL(T/I)*I
       5       NEXT I
       6       FNP = N*N/T
       7   END DEF

It would easily fit in just one line but this way its simplicity might be even clearer.
Let's see the function's value for N = 10, 100, ..., 1000000:

DESTROY ALL @ FIX 5

FNP(10)          -> 2.94118
FNP(100)         -> 3.09215
FNP(1000)        -> 3.13903
FNP(10000)       -> 3.14133
FNP(100000)      -> 3.14153
FNP(1000000)     -> 3.14159

The limit for  N -> Inf   is exactly Pi, of course.

Happy  Pi  Day ! Smile

V.
 

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Happy Pi day everyone!! - Namir - 03-14-2019, 12:25 PM
RE: Happy Pi day everyone!! - ttw - 03-14-2019, 12:34 PM
RE: Happy Pi day everyone!! - Dieter - 03-14-2019, 08:09 PM
RE: Happy Pi day everyone!! - Thomas Klemm - 03-14-2019, 10:12 PM
RE: Happy Pi day everyone!! - DA74254 - 03-14-2019, 10:34 PM
RE: Happy Pi day everyone!! - Valentin Albillo - 03-15-2019 12:45 AM
RE: Happy Pi day everyone!! - mpark - 03-15-2019, 05:11 PM
RE: Happy Pi day everyone!! - EdS2 - 03-16-2019, 07:50 AM
RE: Happy Pi day everyone!! - Carsen - 03-15-2019, 04:31 AM
RE: Happy Pi day everyone!! - Carsen - 03-16-2019, 06:27 AM
RE: Happy Pi day everyone!! - Thomas Okken - 03-17-2019, 12:38 AM
RE: Happy Pi day everyone!! - Thomas Klemm - 03-16-2019, 03:18 PM
RE: Happy Pi day everyone!! - EdS2 - 03-18-2019, 08:07 AM
RE: Happy Pi day everyone!! - ttw - 03-16-2019, 04:23 PM
RE: Happy Pi day everyone!! - Thomas Klemm - 03-16-2019, 05:11 PM
RE: Happy Pi day everyone!! - Thomas Klemm - 03-16-2019, 06:14 PM
RE: Happy Pi day everyone!! - ttw - 03-17-2019, 12:56 AM
RE: Happy Pi day everyone!! - Thomas Klemm - 03-18-2019, 05:40 PM



User(s) browsing this thread: 1 Guest(s)