Yet another 12C mini-challenge (pi)



#2

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.


#3

2143 ENTER 22 / SQRT SQRT GTO 00


11 steps, but d'oh, wrong last digit


#4

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.


#5

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?


#6

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.


#7

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.

#8

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.

#9

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.


#10

Hi Gerson,


So it will be pi ~ ln(6635624)/5


6635624
ln
5
/
gto 00


11 steps.


Thanks for the hint! :)


#11

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.


#12

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


#13

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.

#14

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

Yes it can. See my post below :-)

- Pauli

#15

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

#16

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.


#17

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.

#18

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.


#19

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.

#20

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


#21

Yes. It was not to be taken seriously.

#22

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.

#23

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.


#24

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.

#25

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


#26

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.

#27

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

#28

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


#29

Nice.


#30

I'll second that "nice"!

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


#31

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

#32

Very nice :)

#33

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 1,871 11-23-2013, 05:24 AM
Last Post: Nick_S
  Computing pi with the PC-1300S Kiyoshi Akima 0 188 11-17-2013, 12:24 AM
Last Post: Kiyoshi Akima
  Calculating Pi LHH 9 582 09-27-2013, 10:50 PM
Last Post: Gerson W. Barbosa
  HPCC Mini Conference 2013 hugh steers 6 440 09-13-2013, 04:27 PM
Last Post: BruceH
  Visualization of pi Bruce Bergman 13 770 08-17-2013, 05:00 PM
Last Post: Howard Owen
  Picture from the Mini-HHC (LA) Geir Isene 11 660 07-07-2013, 01:06 PM
Last Post: Jim Horn
  OT: Happy Pi Day! Eddie W. Shore 13 766 03-22-2013, 10:44 AM
Last Post: Les Koller
  Totally OT ... Pi Day for my car Maximilian Hohmann 18 988 03-10-2013, 01:15 PM
Last Post: chris smith
  My birthday, so a little commemorative mini-challenge ! Valentin Albillo 43 1,989 03-07-2013, 03:44 AM
Last Post: Walter B
  [WP34S] A funny bug in Pi (prod) Eduardo Duenez 3 356 01-28-2013, 03:41 AM
Last Post: Walter B

Forum Jump: