Happy Pi day everyone!!
03-15-2019, 05:11 PM
Post: #15
 mpark Junior Member Posts: 23 Joined: Sep 2018
RE: Happy Pi day everyone!!
(03-15-2019 12:45 AM)Valentin Albillo Wrote:
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 !

V.

What the heck!? How does that even work?
 « Next Oldest | Next Newest »

 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!! - Valentin Albillo - 03-14-2019, 03:53 PM RE: Happy Pi day everyone!! - Dieter - 03-14-2019, 08:09 PM RE: Happy Pi day everyone!! - Eddie W. Shore - 03-14-2019, 01:30 PM RE: Happy Pi day everyone!! - Gerson W. Barbosa - 03-14-2019, 08:58 PM RE: Happy Pi day everyone!! - Gerson W. Barbosa - 03-17-2019, 01:48 AM 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!! - Valentin Albillo - 03-15-2019, 05:07 AM RE: Happy Pi day everyone!! - Ángel Martin - 03-15-2019, 06:35 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!! - Geoff Quickfall - 03-15-2019, 07:09 AM RE: Happy Pi day everyone!! - Csaba Tizedes - 03-15-2019, 08:35 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!! - Valentin Albillo - 03-16-2019, 10:43 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)