Post Reply 
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:

Wonderful little program!

Thank you very much for your appreciation. Smile

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
 
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Pi Approximation Day - Gerson W. Barbosa - 07-22-2022, 11:47 PM
RE: Pi Approximation Day - J-F Garnier - 07-23-2022, 11:44 AM
RE: Pi Approximation Day - C.Ret - 07-23-2022, 03:18 PM
RE: Pi Approximation Day - C.Ret - 07-23-2022, 05:18 PM
RE: Pi Approximation Day - Steve Simpkin - 07-24-2022, 11:59 AM
RE: Pi Approximation Day - Valentin Albillo - 07-23-2022 11:31 PM
RE: Pi Approximation Day - Thomas Klemm - 07-23-2022, 02:20 AM
RE: Pi Approximation Day - J-F Garnier - 07-23-2022, 07:00 AM
RE: Pi Approximation Day - Albert Chan - 07-23-2022, 10:56 AM
RE: Pi Approximation Day - vaklaff - 07-23-2022, 11:26 AM
RE: Pi Approximation Day - Thomas Klemm - 07-23-2022, 06:46 PM
RE: Pi Approximation Day - Didier Lachieze - 07-23-2022, 09:09 PM
RE: Pi Approximation Day - Thomas Klemm - 07-24-2022, 07:03 AM
RE: Pi Approximation Day - Dan C - 07-24-2022, 09:37 AM
RE: Pi Approximation Day - Dan C - 07-24-2022, 11:29 AM
RE: Pi Approximation Day - Thomas Klemm - 07-24-2022, 11:30 AM
RE: Pi Approximation Day - Ajaja - 07-24-2022, 01:28 PM
RE: Pi Approximation Day - Thomas Klemm - 07-24-2022, 03:52 PM
RE: Pi Approximation Day - Albert Chan - 07-24-2022, 07:13 PM
RE: Pi Approximation Day - pauln - 07-24-2022, 06:39 PM
RE: Pi Approximation Day - EdS2 - 07-24-2022, 09:10 PM
RE: Pi Approximation Day - pauln - 07-24-2022, 11:27 PM
RE: Pi Approximation Day - Thomas Klemm - 07-24-2022, 10:16 PM
RE: Pi Approximation Day - Albert Chan - 07-25-2022, 12:03 AM
RE: Pi Approximation Day - Thomas Klemm - 07-25-2022, 06:38 AM
RE: Pi Approximation Day - Thomas Klemm - 07-25-2022, 09:28 PM
RE: Pi Approximation Day - Albert Chan - 07-26-2022, 12:51 AM
RE: Pi Approximation Day - pauln - 07-26-2022, 01:27 AM
RE: Pi Approximation Day - Albert Chan - 07-26-2022, 12:27 PM
RE: Pi Approximation Day - Thomas Klemm - 07-26-2022, 05:24 AM
RE: Pi Approximation Day - Thomas Klemm - 07-26-2022, 01:38 PM
RE: Pi Approximation Day - EdS2 - 08-03-2022, 04:53 PM
RE: Pi Approximation Day - Thomas Klemm - 08-07-2022, 11:42 AM



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