Yet another 12C mini-challenge (pi) « Next Oldest | Next Newest »

 ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 01-09-2009, 07:45 AM Try to write an 11-step program to display 3.141592654 on the HP-12C. ```[1] [0] [4] [3] [4] [8] [ENTER] [3] [3] [2] [1] [5] [/] [GTO 00] (14 steps) ``` Too many steps! ```[3] [.] [1] [4] [1] [5] [9] [2] [6] [5] [4] [GTO 00] (12 steps) ``` Still too many steps... Gerson. ▼ Dusan Zivkovic Member Posts: 54 Threads: 2 Joined: Jul 2008 01-09-2009, 11:04 AM 2143 ENTER 22 / SQRT SQRT GTO 00 11 steps, but d'oh, wrong last digit ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 01-10-2009, 06:00 AM Actually 3 is the correct ninth decimal digit but for the sake of rounding 4 is better. A very nice attemp anyway! I'll post my solution next week (in case anyone doesn't come up with it before). Regards, Gerson. ▼ Dusan Zivkovic Member Posts: 54 Threads: 2 Joined: Jul 2008 01-10-2009, 12:07 PM Hi again Gerson, 11 steps, 396 enter 4 y^x ln 58 sqrt / (Thanks to Srinivasa Ramanujan's achievements.) D'oh, it's 12 steps; forgot the final gto 00. However, this can be 11 on 12CP as it's got x^2 key. Would that count? ▼ Katie Wasserman Posting Freak Posts: 1,477 Threads: 71 Joined: Jan 2005 01-10-2009, 03:17 PM Dusan, I think that you (almost?) have a winner with just a little math you can write this as: ```[3] [9] [6] [g][ln] [4] [x] [5] [8] [g][sqrt] [/] [g][GTO][0][0] ``` The answer should be 3.14159265414... but on the original 12C it shows as 3.141592653 on the newer models it's 3.141592654. Edited: 10 Jan 2009, 3:22 p.m. ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 01-10-2009, 05:31 PM Hi Katie, Yes, Dusan is on the right track. You're advice to him is fine, however a slight modification has still to be made in order to both calculator display the same answers. I could post your modified program now but I think you prefer to find it by yourselves. You are very close now! In fact, the idea of this mini-challenge arose from your 12-step solution in an old thread you started, even though rather than using an approximation you've actually computed the constant, which is really nicer. Regards, Gerson. Dusan Zivkovic Member Posts: 54 Threads: 2 Joined: Jul 2008 01-10-2009, 05:52 PM Thanks Katie. I also got 3 as the last digit after little math, and thought it was "as good" as my first attempt up the thread. I've now checked it on a 12CP25AE and it indeed produced a 4 as the last digit. I then played around with other calcs out of curiosity, and 41CV, 15C and 34C all ended up with a 3 as the last digit. Sharps of all ages - 1211, 1500, 1403 and E500 - all produced a 4, which was also the case with Casio 730p and TI 59. Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 01-10-2009, 05:52 PM Hi Dusan, Most of these ln approximations are attributed to Ramanujan. For this problem I tried some of Roy William's e^(pi*sqrt(n)), for integer n. Scroll down the page until you get to Curiosités: I've found one 17-digit pandigital approximation involving ln, sqrt and factorial using one of these. Regards, Gerson. ▼ Dusan Zivkovic Member Posts: 54 Threads: 2 Joined: Jul 2008 01-10-2009, 06:09 PM Hi Gerson, So it will be pi ~ ln(6635624)/5 6635624 ln 5 / gto 00 11 steps. Thanks for the hint! :) ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 01-11-2009, 09:30 AM You have found a new solution. Congratulations! Now I wonder if it can be done in 10 steps or less. My hint was making a slight modification in Katie's rewriting of your first approximation: ```[3] [9] [6] [g][ln] [5] [8] [g][sqrt] [/] [4] [x] [g][GTO][0][0] ``` Here is the pandigital approximation I have mentioned: ```'LN(((8-1)!+2*5!)^sqrt(9)+(3!)!+4!)/sqrt(67)' = 3.14159265358979323957 = pi + 0.00000 00000 00000 00111 ``` This can be rewritten to use only 8 digits instead of the 9 digits from 1 through 9: ```'LN((7!+2*5!)^3+6!+4!)/sqrt(67)' ``` On the HP-200LX, this gives out 3.141592653589793, also matching the machine's built-in approximation. Regards, Gerson. ▼ Dusan Zivkovic Member Posts: 54 Threads: 2 Joined: Jul 2008 01-11-2009, 06:51 PM The pandigital approximation doesn't seem promising as a way towards a "10 steps or fewer" solution. Too many inputs, too many operations. But maybe someone will prove me wrong. Let's wait and see. In the meantime, I couldn't resist trying it on a Sharp PC-E500, in DEFDBL mode, and it produced 3.1415926535897932396. One significant digit more than 200LX... just to reassure me that Sharp's "plasticky thing" which served me so well for the last 20-odd years always was such a great machine... ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 01-12-2009, 10:16 AM Quote: The pandigital approximation doesn't seem promising as a way towards a "10 steps or fewer" solution. Actually, pandigital approximations are another kind of puzzle/problem. The goal is to obtain an approximation using all the digits from 0 to 9 (or from 1 to 9) only once. Pi Approximations in the MathWorld site presents a couple of them, but limited to 10 or 11 digits. Regards, Gerson. Paul Dale Posting Freak Posts: 3,229 Threads: 42 Joined: Jul 2006 01-14-2009, 08:27 PM Quote:Now I wonder if it can be done in 10 steps or less. Yes it can. See my post below :-) - Pauli Palmer O. Hanson, Jr. Posting Freak Posts: 901 Threads: 113 Joined: Jun 2007 01-10-2009, 11:13 PM Quote: 2143 ENTER 22 / SQRT SQRT GTO 00 11 steps, but d'oh, wrong last digit You can change the last digit from a three to a four by addiing the steps ln ex I realize that makes it thirteen steps, but it makes a nice demonstration of the interesting things that happen with the log functions. Palmer Stuart Sprott Junior Member Posts: 36 Threads: 7 Joined: Sep 2007 01-13-2009, 05:58 AM Quote: 2143 ENTER 22 / SQRT SQRT GTO 00 11 steps, but d'oh, wrong last digit I have got to admit that I like this method the best of all. It is extremely easy to remember and as a Surveyor it is all that is needed in the practical world. Given a circle of radius 100 Ks the error in calculating the circumference would be only 0.2 MM. That is good enough for me. ▼ George Bailey (Bedford Falls) Senior Member Posts: 335 Threads: 12 Joined: Dec 2007 01-13-2009, 06:06 AM Quote: It is extremely easy to remember and as a Surveyor it is all that is needed in the practical world. For the practical world it would be even easier to remember 3.14159 - and still be sufficient... ;-) Edited: 13 Jan 2009, 6:06 a.m. Egan Ford Posting Freak Posts: 1,619 Threads: 147 Joined: May 2006 01-10-2009, 10:28 AM Quote: Try to write an 11-step program to display 3.141592654 on the HP-12C. 9 Steps: ```01 3 02 ENTER 03 2 04 EEX 05 9 06 CHS 07 + 08 PSE 09 GTO 03 ``` You'll have to wait for it, but it will display the digits of Pi for a brief period of time. ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 01-10-2009, 05:38 PM Well, I was thinking of displaying all ten digits at once, so that the routine could be used as a pi key replacement and at least one step shorter than just entering the digits one by one. Anyway, your algorithm-oriented program is very interesting. Please see the link to Katie's program above. Regards, Gerson. MikeO Member Posts: 121 Threads: 21 Joined: Jun 2008 01-10-2009, 10:14 PM I estimate about 2.99 years to see the answer with Egan's approach. Approximately 26,220 hours, 51 minutes, 42 seconds with an iteration every 1 1/3 second. That's a long wait ;) -Mike ▼ Egan Ford Posting Freak Posts: 1,619 Threads: 147 Joined: May 2006 01-12-2009, 04:33 PM Yes. It was not to be taken seriously. George Bailey (Bedford Falls) Senior Member Posts: 335 Threads: 12 Joined: Dec 2007 01-13-2009, 06:13 AM Quote: 9 Steps: ```01 3 02 ENTER 03 2 04 EEX 05 9 06 CHS 07 + 08 PSE 09 GTO 03 ``` Why sooooo loooong???? 4 Steps: ```01 2 02 + 03 PSE 04 GTO 01 ``` Just remember to imagine the . between 3 and 1 in a couple of months and to clear the X register before you start. ;-) Hail to the 12C who might well be able to do it on one set of batteries. Edited: 13 Jan 2009, 6:14 a.m. Namir Posting Freak Posts: 2,247 Threads: 200 Joined: Jun 2005 01-10-2009, 11:08 AM Here is my answer: [3] [5] [5] [ENTER] [1] [1] [3] [/] [GTO 00] 9 steps!! Why do we count the last since the machine seems to insert it automatically (yes? no?). Namir Edited: 10 Jan 2009, 11:10 a.m. ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 01-10-2009, 05:42 PM Hi Namir, This well known approximation is really excellent but not close enough to our purpose. Thanks for your interest! Regards, Gerson. P.S.: Answering your question, I decided to include the final GTO 00 as a standard but you can compare programs lenghts without considering it, if you wish. Edited: 10 Jan 2009, 5:56 p.m. Paul Dale Posting Freak Posts: 3,229 Threads: 42 Joined: Jul 2006 01-11-2009, 10:18 PM I've got an almost that is so beautiful that I have to post it here: ``` 5 LN . 5 1 2 3 / gives 3.141592645 ``` 9 steps (8 without the GTO 00 at the end) Alas, it is also so far... - Pauli ▼ Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 01-12-2009, 12:30 PM Really beautiful despite the exchanged two last digits. And it does use one keyboard row (123). Thanks for posting it! Keyboard rows, columns and diagonals make for some interesting expressions, nothing to do with this problem though: ```sqrt(9 + (sqrt(741/852) - 2^-14))^2) = 3.141592665 789/123 - sqrt(2) = 5.00042 10 atan(620/7410) - sqrt(8) = 44.99995688° atan(123/456) = 15.096° atan(456/789) = 30.026° ``` Just to mention a few... Gerson. Paul Dale Posting Freak Posts: 3,229 Threads: 42 Joined: Jul 2006 01-13-2009, 03:32 PM Getting closer.... ```4 1 LN 5 y^x 1 %T 3 + ``` In ten steps (including the final GTO 00) gives 3.141592653 Now to see if I can get that final digit up by one. - Pauli Paul Dale Posting Freak Posts: 3,229 Threads: 42 Joined: Jul 2006 01-14-2009, 03:38 PM More playing and a better result that more than achieves the challenge: ``` 8 e^x 1 4 8 - 8 9 %T ``` This gives the result asked for to all digits. It requires 10 steps (including the GTO 00 at the end) besting the target of 11. The 148 can be replaced by: ``` 5 e^x INTG ``` without changing the result but it doesn't save any steps :-( The only down side is %T leaves a value in Y. - Pauli ▼ Michael Meyer Senior Member Posts: 472 Threads: 58 Joined: Apr 2008 01-14-2009, 06:53 PM Nice. ▼ Katie Wasserman Posting Freak Posts: 1,477 Threads: 71 Joined: Jan 2005 01-14-2009, 08:34 PM I'll second that "nice"! This must have take an awfully long time to figure out, 1 step/hour? ▼ Paul Dale Posting Freak Posts: 3,229 Threads: 42 Joined: Jul 2006 01-14-2009, 09:49 PM Quote:This must have take an awfully long time to figure out, 1 step/hour? I don't think I'll comment on this :-) - Pauli Dusan Zivkovic Member Posts: 54 Threads: 2 Joined: Jul 2008 01-15-2009, 05:13 AM Very nice :) Gerson W. Barbosa Posting Freak Posts: 2,761 Threads: 100 Joined: Jul 2005 01-15-2009, 10:31 AM Quote:```8 e^x 1 4 8 - 8 9 %T ``` Very very nice! Quote: This gives the result asked for to all digits. It requires 10 steps (including the GTO 00 at the end) besting the target of 11. I had a hunch YOU would beat the 11-step limit, considering your previous solutions to similar problems. Congratulations! Quote: The only down side is %T leaves a value in Y. This prevents the routine from being used as an actual PI replacement in programs - Anyway, saving at least stack register X was NOT a requirement. Regards, Gerson.

 Possibly Related Threads... Thread Author Replies Views Last Post [OT] Mathematica free for Raspberry PI BruceH 32 6,050 11-23-2013, 05:24 AM Last Post: Nick_S Computing pi with the PC-1300S Kiyoshi Akima 0 786 11-17-2013, 12:24 AM Last Post: Kiyoshi Akima Calculating Pi LHH 9 2,144 09-27-2013, 10:50 PM Last Post: Gerson W. Barbosa HPCC Mini Conference 2013 hugh steers 6 1,603 09-13-2013, 04:27 PM Last Post: BruceH Visualization of pi Bruce Bergman 13 2,798 08-17-2013, 05:00 PM Last Post: Howard Owen Picture from the Mini-HHC (LA) Geir Isene 11 2,296 07-07-2013, 01:06 PM Last Post: Jim Horn OT: Happy Pi Day! Eddie W. Shore 13 2,630 03-22-2013, 10:44 AM Last Post: Les Koller Totally OT ... Pi Day for my car Maximilian Hohmann 18 3,257 03-10-2013, 01:15 PM Last Post: chris smith My birthday, so a little commemorative mini-challenge ! Valentin Albillo 43 5,855 03-07-2013, 03:44 AM Last Post: Walter B [WP34S] A funny bug in Pi (prod) Eduardo Duenez 3 1,066 01-28-2013, 03:41 AM Last Post: Walter B

Forum Jump: