The Museum of HP Calculators

HP Forum Archive 18

[ Return to Index | Top of Index ]

Yet another 12C mini-challenge (pi)
Message #1 Posted by Gerson W. Barbosa on 9 Jan 2009, 7:45 a.m.

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.

      
Re: Yet another 12C mini-challenge (pi)
Message #2 Posted by Dusan Zivkovic on 9 Jan 2009, 11:04 a.m.,
in response to message #1 by Gerson W. Barbosa

2143 ENTER 22 / SQRT SQRT GTO 00
11 steps, but d'oh, wrong last digit

            
Re: Yet another 12C mini-challenge (pi)
Message #3 Posted by Gerson W. Barbosa on 10 Jan 2009, 6:00 a.m.,
in response to message #2 by Dusan Zivkovic

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.

                  
Re: Yet another 12C mini-challenge (pi)
Message #4 Posted by Dusan Zivkovic on 10 Jan 2009, 12:07 p.m.,
in response to message #3 by Gerson W. Barbosa

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?

                        
Re: Yet another 12C mini-challenge (pi)
Message #5 Posted by Katie Wasserman on 10 Jan 2009, 3:17 p.m.,
in response to message #4 by Dusan Zivkovic

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.

                              
Re: Yet another 12C mini-challenge (pi)
Message #6 Posted by Gerson W. Barbosa on 10 Jan 2009, 5:31 p.m.,
in response to message #5 by Katie Wasserman

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.

http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv016.cgi?read=100992

Regards,

Gerson.

                              
Re: Yet another 12C mini-challenge (pi)
Message #7 Posted by Dusan Zivkovic on 10 Jan 2009, 5:52 p.m.,
in response to message #5 by Katie Wasserman

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.

                        
Re: Yet another 12C mini-challenge (pi)
Message #8 Posted by Gerson W. Barbosa on 10 Jan 2009, 5:52 p.m.,
in response to message #4 by Dusan Zivkovic

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:

http://www.pi314.net/approx.php

I've found one 17-digit pandigital approximation involving ln, sqrt and factorial using one of these.

Regards,

Gerson.

                              
Re: Yet another 12C mini-challenge (pi)
Message #9 Posted by Dusan Zivkovic on 10 Jan 2009, 6:09 p.m.,
in response to message #8 by Gerson W. Barbosa

Hi Gerson,
So it will be pi ~ ln(6635624)/5
6635624 ln 5 / gto 00
11 steps.
Thanks for the hint! :)

                                    
Re: Yet another 12C mini-challenge (pi)
Message #10 Posted by Gerson W. Barbosa on 11 Jan 2009, 9:30 a.m.,
in response to message #9 by Dusan Zivkovic

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.

                                          
Re: Yet another 12C mini-challenge (pi)
Message #11 Posted by Dusan Zivkovic on 11 Jan 2009, 6:51 p.m.,
in response to message #10 by Gerson W. Barbosa

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...

                                                
Re: Yet another 12C mini-challenge (pi)
Message #12 Posted by Gerson W. Barbosa on 12 Jan 2009, 10:16 a.m.,
in response to message #11 by Dusan Zivkovic

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.

                                          
Re: Yet another 12C mini-challenge (pi)
Message #13 Posted by Paul Dale on 14 Jan 2009, 8:27 p.m.,
in response to message #10 by Gerson W. Barbosa

Quote:
Now I wonder if it can be done in 10 steps or less.

Yes it can. See my post below :-)

- Pauli

            
Re: Yet another 12C mini-challenge (pi)
Message #14 Posted by Palmer O. Hanson, Jr. on 10 Jan 2009, 11:13 p.m.,
in response to message #2 by Dusan Zivkovic

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

            
Re: Yet another 12C mini-challenge (pi)
Message #15 Posted by Stuart Sprott on 13 Jan 2009, 5:58 a.m.,
in response to message #2 by Dusan Zivkovic

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.

                  
Re: Yet another 12C mini-challenge (pi)
Message #16 Posted by George Bailey (Bedford Falls) on 13 Jan 2009, 6:06 a.m.,
in response to message #15 by Stuart Sprott

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.

      
Re: Yet another 12C mini-challenge (pi)
Message #17 Posted by Egan Ford on 10 Jan 2009, 10:28 a.m.,
in response to message #1 by Gerson W. Barbosa

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.

            
Re: Yet another 12C mini-challenge (pi)
Message #18 Posted by Gerson W. Barbosa on 10 Jan 2009, 5:38 p.m.,
in response to message #17 by Egan Ford

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.

            
Re: Yet another 12C mini-challenge (pi)
Message #19 Posted by MikeO on 10 Jan 2009, 10:14 p.m.,
in response to message #17 by Egan Ford

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

                  
Re: Yet another 12C mini-challenge (pi)
Message #20 Posted by Egan Ford on 12 Jan 2009, 4:33 p.m.,
in response to message #19 by MikeO

Yes. It was not to be taken seriously.

            
Re: Yet another 12C mini-challenge (pi)
Message #21 Posted by George Bailey (Bedford Falls) on 13 Jan 2009, 6:13 a.m.,
in response to message #17 by Egan Ford

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.

      
Re: Yet another 12C mini-challenge (pi)
Message #22 Posted by Namir on 10 Jan 2009, 11:08 a.m.,
in response to message #1 by Gerson W. Barbosa

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.

            
Re: Yet another 12C mini-challenge (pi)
Message #23 Posted by Gerson W. Barbosa on 10 Jan 2009, 5:42 p.m.,
in response to message #22 by Namir

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.

      
Re: Yet another 12C mini-challenge (pi)
Message #24 Posted by Paul Dale on 11 Jan 2009, 10:18 p.m.,
in response to message #1 by Gerson W. Barbosa

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

            
Re: Yet another 12C mini-challenge (pi)
Message #25 Posted by Gerson W. Barbosa on 12 Jan 2009, 12:30 p.m.,
in response to message #24 by Paul Dale

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.

      
Re: Yet another 12C mini-challenge (pi)
Message #26 Posted by Paul Dale on 13 Jan 2009, 3:32 p.m.,
in response to message #1 by Gerson W. Barbosa

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

      
Re: Yet another 12C mini-challenge (pi)
Message #27 Posted by Paul Dale on 14 Jan 2009, 3:38 p.m.,
in response to message #1 by Gerson W. Barbosa

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

            
Re: Yet another 12C mini-challenge (pi)
Message #28 Posted by Michael Meyer on 14 Jan 2009, 6:53 p.m.,
in response to message #27 by Paul Dale

Nice.

                  
Re: Yet another 12C mini-challenge (pi)
Message #29 Posted by Katie Wasserman on 14 Jan 2009, 8:34 p.m.,
in response to message #28 by Michael Meyer

I'll second that "nice"!

This must have take an awfully long time to figure out, 1 step/hour?

                        
Re: Yet another 12C mini-challenge (pi)
Message #30 Posted by Paul Dale on 14 Jan 2009, 9:49 p.m.,
in response to message #29 by Katie Wasserman

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

            
Re: Yet another 12C mini-challenge (pi)
Message #31 Posted by Dusan Zivkovic on 15 Jan 2009, 5:13 a.m.,
in response to message #27 by Paul Dale

Very nice :)

            
Re: Yet another 12C mini-challenge (pi)
Message #32 Posted by Gerson W. Barbosa on 15 Jan 2009, 10:31 a.m.,
in response to message #27 by Paul Dale

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.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall