Pi Approximation Day
|
07-22-2022, 11:47 PM
Post: #1
|
|||
|
|||
Pi Approximation Day
Since today is Pi Approximation Day, just another one for the collection. Not an outstanding approximation, but this might fit into the Exotic Ones category:
\(e^{\sqrt[11_{3}]{\frac{2222_{4}-\frac{1}{22_{9}^{2}+22_{16}^{2}+\frac{1}{1111_{7}}}}{99_{10}}}}\) |
|||
07-23-2022, 01:20 AM
Post: #2
|
|||
|
|||
RE: Pi Approximation Day
.
Hi, all, I can't let Pi Approximation Day (22/7) pass by without my humble contribution, so here you are. 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: 01 LBL "?" 02 10 03 STO ST Y 04 LBL 00 05 RCL ST Y 06 RCL× ST Z 07 RCL+ ST Z 08 RCLx ST X 09 RCL× ST L 10 1/X 11 - 12 DSE ST Y 13 GTO 00 14 SQRT 15 END See if you can fathom how/why it works. Regards. V. All My Articles & other Materials here: Valentin Albillo's HP Collection |
|||
07-23-2022, 02:20 AM
Post: #3
|
|||
|
|||
RE: Pi Approximation Day | |||
07-23-2022, 07:00 AM
Post: #4
|
|||
|
|||
RE: Pi Approximation Day | |||
07-23-2022, 10:56 AM
Post: #5
|
|||
|
|||
RE: Pi Approximation Day | |||
07-23-2022, 11:26 AM
Post: #6
|
|||
|
|||
RE: Pi Approximation Day
(07-23-2022 10:56 AM)Albert Chan Wrote:(07-22-2022 11:47 PM)Gerson W. Barbosa Wrote: \(e^{\sqrt[11_{3}]{\frac{2222_{4}-\frac{1}{22_{9}^{2}+22_{16}^{2}+\frac{1}{1111_{7}}}}{99_{10}}}}\) My wife says they are the radix (for example 16 as a subscript indicates a hexadecimal number) and the good old exponent. |
|||
07-23-2022, 11:36 AM
Post: #7
|
|||
|
|||
RE: Pi Approximation Day
(07-23-2022 11:26 AM)vaklaff Wrote:(07-23-2022 10:56 AM)Albert Chan Wrote: What is subscript / superscript notation mean? Yes, they are base and exponent, respectively. In order to avoid confusion I should have written (22₉)² instead, for instance. That’s 20² = 400. |
|||
07-23-2022, 11:44 AM
Post: #8
|
|||
|
|||
RE: Pi Approximation Day
(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! 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. Thank you Valentin, it's a pleasure to read you again. J-F |
|||
07-23-2022, 11:59 AM
(This post was last modified: 07-23-2022 03:19 PM by Gerson W. Barbosa.)
Post: #9
|
|||
|
|||
RE: Pi Approximation Day
(07-23-2022 07:00 AM)J-F Garnier Wrote:(07-23-2022 02:20 AM)Thomas Klemm Wrote: It uses Ramanujan's formula: I had found the general term 1/(x^2 + x)^3 when I saw Thomas Klemm’s post. After driving almost 400 km during the day, I was glad he was that fast :-) Not as fun, but we can still rewrite Valentin’s intentionally slightly obfuscated program: Code:
1E1 -> 3,141592850081697528137175603520803 1E2 -> 3,141592653592821635772340191552596 1E3 -> 3,141592653589793270134930833666846 1E6 -> 3,141592653589793238462643383279535 pi —-> 3,141592653589793238462643383279503 Edited to fix a typo |
|||
07-23-2022, 03:18 PM
(This post was last modified: 07-23-2022 03:18 PM by C.Ret.)
Post: #10
|
|||
|
|||
RE: Pi Approximation Day
(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! I'm trying to fit it to my HP-41C, but I must have missed something. Especially at step 09 RCL× ST L; where is the LAST register initialized on the first pass? Why isn't this a problem regardless of what is previously stored in the LAST register? Is this a specific HP-42S trick, does memory recall arithmetic modify the LAST register? I'm stuck; need a little more beers to drink and any good advice to hear ! |
|||
07-23-2022, 03:41 PM
Post: #11
|
|||
|
|||
RE: Pi Approximation Day | |||
07-23-2022, 05:18 PM
(This post was last modified: 07-23-2022 05:30 PM by C.Ret.)
Post: #12
|
|||
|
|||
RE: Pi Approximation Day
(07-23-2022 03:41 PM)Gerson W. Barbosa Wrote:(07-23-2022 03:18 PM)C.Ret Wrote: Is this a specific HP-42S trick, does memory recall arithmetic modify the LAST register?Yes, it does, unlike memory store arithmetic: Thank you for your quick response; this is a different behavior from the HP-15C memory recall arithmetic logic. That explain why I was so lost. 001 LBL "WLP 002 10 003 ENTER^ 004 LBL 00 005 RCL Y 006 X^2 007 LASTX 008 + 009 -3 010 Y^X 011 - 012 DSE Y 013 GTO 00 014 SQRT 015 END With FIX 7 display format, this little program give a better approximation of PI than 22/07. Surprisingly, the number of instructions is the same as Valentin Albillo's original code. \( \sqrt{10-\frac{1}{\left ( 10^2+10 \right )^3}-\frac{1}{\left ( 9^2+9 \right )^3}-\frac{1}{\left ( 8^2+8 \right )^3}-\cdots -\frac{1}{\left ( 2^2+2 \right )^3}-\frac{1}{\left ( 1^2+1 \right )^3}} = \sqrt{ \frac{2\,780\,722\,699}{281\,746\,080} } \approx \pi \) |
|||
07-23-2022, 06:46 PM
Post: #13
|
|||
|
|||
RE: Pi Approximation Day
(07-23-2022 11:59 AM)Gerson W. Barbosa Wrote: Not as fun, but we can still rewrite Valentin’s intentionally slightly obfuscated program Without recall-arithmetic it uses even fewer bytes: Code: 00 { 27-Byte Prgm } Using a register we can translate it for other HP calculators as well. HP-15C: Code: 001 { 44 0 } STO 0 HP-25: Code: 01: 23 00 : STO 0 We can even do it on the HP-35 if we consider the following manual steps a program. Initialize: Code: CLR Repeat until 0: Code: ENTER↑ ENTER↑ × + Finalize: Code: R↓ While we could start subtracting the terms from an initial value of 10, it is better to start the summation from 0 to avoid cancellation. |
|||
07-23-2022, 09:09 PM
Post: #14
|
|||
|
|||
RE: Pi Approximation Day
(07-23-2022 06:46 PM)Thomas Klemm Wrote: We can even do it on the HP-35 if we consider the following manual steps a program. For this, back in the days, you would have used an HP-35 Key Sequence Form. |
|||
07-23-2022, 10:08 PM
Post: #15
|
|||
|
|||
RE: Pi Approximation Day
(07-23-2022 06:46 PM)Thomas Klemm Wrote: Without recall-arithmetic it uses even fewer bytes: Thanks. I tend to value least number of steps over least number of bytes on the HP-42S where memory is not a concern, but I’ve just noticed there’s no reason at all to use recall arithmetic in my step 05 above when a simple X↑2 instruction suffices. |
|||
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 |
|||
07-24-2022, 07:03 AM
Post: #17
|
|||
|
|||
RE: Pi Approximation Day
(07-23-2022 11:31 PM)Valentin Albillo Wrote: Running it on Free42 Decimal produces the following results for N=100, 1000, 10000 and 100000 terms: This is the table I got using Valentin's program with the additional value for 1000000: 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 845 (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 453 (28 digits save 3 ulp) 1000000 3.14159 26535 89793 23846 26433 83283 745 (31 digits save 4 ulp) ------------------------------------------------- PI 3.14159 26535 89793 23846 26433 83279 502 Please note the slight differences for 1000 and 100000. This is the table I got using Gerson's program that adds 10 at the end: 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) 1000000 3.14159 26535 89793 23846 26433 83279 535 (33 digits save 3 ulp) ------------------------------------------------- PI 3.14159 26535 89793 23846 26433 83279 502 Interestingly it agrees exactly with Valentin's table. For 1000000 it shows the effect of cancellation when starting with 10. Somewhat related: Programming Exercise (HP-15C, 15C LE - and others) |
|||
07-24-2022, 09:37 AM
Post: #18
|
|||
|
|||
RE: Pi Approximation Day
I'm curious about the PI number...
How many decimals in the PI are needed to get acceptable results in practical everyday calculations? Is 3.14 enough ? Or do you have to use more? ( i think you have, but how many?) |
|||
07-24-2022, 10:58 AM
Post: #19
|
|||
|
|||
RE: Pi Approximation Day
Hello!
(07-24-2022 09:37 AM)Dan C Wrote: How many decimals in the PI are needed to get acceptable results in practical everyday calculations? Is 3.14 enough ? Or do you have to use more? ( i think you have, but how many?) For my own personal everyday applications involving Pi (like tinkering around the house and garden) 3.0 is a good enough approximation :-) At work, many years ago, we were doing microvave imaging measurements and calculations. These involved propagation models with many e^i*Pi terms. Even using (then) state-of-the art measuring equipment (mostly from Hp of course, Agilent had not been sourced out then) no more then 4 (or maybe 5 for theoretical calculations) decimal places were required. Everything else would have been drowned in the noise anyway. Regards Max |
|||
07-24-2022, 11:29 AM
Post: #20
|
|||
|
|||
RE: Pi Approximation Day
(07-24-2022 10:58 AM)Maximilian Hohmann Wrote: Hello! Thanks for your input! So in real life calculations you are fine with PI at 3.1415, and that will do in most situations. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 6 Guest(s)