Pi Approximation Day
|
07-23-2022, 11:31 PM
Post: #16
|
|||
|
|||
RE: Pi Approximation Day
.
Hi, Jean-François, (07-23-2022 11:44 AM)J-F Garnier Wrote:(07-23-2022 01:20 AM)Valentin Albillo Wrote: Set FIX 6 and then run on your HP-42S (physical or virtual) this little piece of mystery code I've hastily concocted and see what you get: Thank you very much for your appreciation. Quote:It uses the specific HP-42S stack capability, running it on my trusty 32S would require a few more steps. Of course the interest is in this 42S version. The little code I gave was intentionally obfuscated and particularized to add just 10 terms, to try and hide the "10" as if it were only the loop counter. My general non-obfuscated version which will add N terms is this 14-step, 26-byte HP-42S program: 01 LBL "?" 02 10 03 LBL 00 04 RCL ST Y 05 X↑2 06 RCL+ ST L 07 X↑2 08 RCL× ST L 09 1/X 10 - 11 DSE ST Y 12 GTO 00 13 SQRT 14 END Key in N and XEQ "?". Running it on Free42 Decimal produces the following results for N=100, 1000, 10000 and 100000 terms: PI 3.14159 26535 89793 23846 26433 83279 502 ------------------------------------------------- 100 3.14159 26535 92821 63577 23401 91552 596 (13 digits save 3 ulp) 1000 3.14159 26535 89793 27013 49308 33666 846 (18 digits save 4 ulp) 10000 3.14159 26535 89793 23846 29615 34056 207 (23 digits save 3 ulp) 100000 3.14159 26535 89793 23846 26433 86462 443 (28 digits save 3 ulp) ------------------------------------------------- PI 3.14159 26535 89793 23846 26433 83279 502 I like this series for Pi very much: it converges very fast (order 6), the general term is extremely simple to program needing just 6 steps, and this makes for speedy looping and very short running times, e.g. using as little as 100 terms gets you better than 12-digit accuracy and on Free42 it runs instantly. Quote:Thank you Valentin, it's a pleasure to read you again. Thank you, J-F, your feedback is most appreciated and if more people would do likewise that would surely motivate me to post again. Best regards. V. All My Articles & other Materials here: Valentin Albillo's HP Collection |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)