The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

HP-12C program
Message #1 Posted by Gerson W. Barbosa on 21 Feb 2012, 5:43 p.m.

001- 1 016- + 002- 0 017- 1/x 003- x<>y 018- STO 1 004- y^x 019- RCL 0 005- STO 0 020- 3 006- ENTER 021- CHS 007- * 022- y^x 008- g LSTx 023- STO+ 1 009- 2 024- 1 010- * 025- STO- 0 011- 1 026- RCL 0 012- + 027- g x=0 013- x<>y 028- g GTO 30 014- 2 029- g GTO 19 015- * 030- RCL 1 031- g GTO 00

Given the proper argument this small HP-12C program will give a meaningful result in about 2 minutes on the classic HP-12C (under a couple of seconds on the HP-12C+).

      
Re: HP-12C program
Message #2 Posted by Paul Dale on 21 Feb 2012, 6:07 p.m.,
in response to message #1 by Gerson W. Barbosa

Very nice!

Not having a 12C to hand, I converted this for the 34S:

    01:  LBL A
    02:  10[^x]
    03:  STO 00
    04:  x[^2]
    05:  RCL L
    06:  RCL+ X
    07:  INC X
    08:  x[<->] Y
    09:  RCL+ X
    10:  +
    11:  1/x
    12:  STO 01
    13:  LBL 00
    14:  RCL 00
    15:  3
    16:  +/-
    17:  y[^x]
    18:  STO+ 01
    19:  DSZ 00
    20:  GTO 00
    21:  RCL 01
    22:  RTN

However, there is an alternative WP 34S program that produces the same limit using four steps including the LBL at the start and the RTN at the end -- so two steps of working code.

- Pauli

            
Re: HP-12C program
Message #3 Posted by Paul Dale on 21 Feb 2012, 6:10 p.m.,
in response to message #2 by Paul Dale

Drat, missed some optimisation in the above code. Change line 18 to + and delete lines 21 and 12.

- Pauli

                  
Re: HP-12C program
Message #4 Posted by Gerson W. Barbosa on 21 Feb 2012, 6:22 p.m.,
in response to message #3 by Paul Dale

I thought of including "optimization of the code is left as an exercise to the reader", but then I realized figuring out what the program did was good exercise enough. That was my first attempt after I noticed it this afternoon. Without the trick, about 50k terms would have to be computed in order to get the same result.

Gerson.

            
Re: HP-12C program
Message #5 Posted by Gerson W. Barbosa on 21 Feb 2012, 6:12 p.m.,
in response to message #2 by Paul Dale

Quote:
However, there is an alternative WP 34S program that produces the same limit using four steps including the LBL at the start and the RTN at the end -- so two steps of working code.

Actually, I've tested my results upon the WP 34S function :-)

Gerson.

      
Re: HP-12C program
Message #6 Posted by Gerson W. Barbosa on 22 Feb 2012, 4:12 a.m.,
in response to message #1 by Gerson W. Barbosa

While we're at it, here's another one for another constant:

001-	1		019-	CHS	
002-	0		020-	STO+ 0	
003-	x<>y		021-	STO* 2	
004-	y^x		022-	RCL 0	
005-	STO 0		023-	2	
006-	ENTER		024-	*	
007-	*		025-	+	
008-	8		026-	ENTER	
009-	*		027-	*	
010-	6		028-	1/x	
011-	+		029-	RCL 2	
012-	1/x		030-	*	
013-	STO 1		031-	STO+ 1	
014-	1		032-	RCL 0	
015-	STO+ 0		033-	g x=0	
016-	STO+ 1		034-	g GTO 36	
017-	STO 2		035-	g GTO 18	
018-	1		036-	RCL 1	
			037-	g GTO 00

Checking the archives, I found an old mini-challenge of Valentin's which is worth mentioning. Crawl's program in Message #52 appears to explore the same idea. I certainly read the thread at the time, but I'd completely forgotten about his particular program. It's worth reading Valentin's original solutions and other therein:

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

I've come up with a slightly faster series. I've started to implement it on the HP-15C LE, but the initialization alone takes up 37 steps. If I manage to optimize it a bit, I'll present it later.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall