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 ! V. All My Articles & other Materials here: Valentin Albillo's HP Collection |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)