HP-12C program



#2

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


#3

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


#4

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


- Pauli


#5

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.

#6

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.

#7

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.


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 775 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  HP 12C, 12C Platinum & 15C iOS App Walter Lam 2 432 06-02-2011, 01:25 PM
Last Post: Andrés C. Rodríguez (Argentina)
  HP-12C erase program steps x34 7 751 02-13-2011, 03:52 PM
Last Post: Bart (UK)
  HP-41 MCODE: Making an MCODE program call another MCODE program Geir Isene 10 968 01-13-2008, 05:58 AM
Last Post: Raymond Del Tondo
  HP-12C Platinum Trigs Program Gerson W. Barbosa 14 1,162 08-07-2006, 05:49 PM
Last Post: Bruce Horrocks
  Modified Dietz program for 12C Matt 26 1,654 06-17-2006, 01:56 PM
Last Post: Les Wright
  12C vs 12C Platinum Cash Flows Katie Wasserman 10 900 12-28-2005, 10:12 PM
Last Post: tony(nz)
  12c: Anyone have a good way to program this? :-) Gene Wright 12 846 12-23-2005, 05:10 AM
Last Post: tony(nz)
  New Trigonometric Functions Program for the New 12C Platinum Gerson W. Barbosa 2 341 11-11-2005, 11:21 AM
Last Post: Gerson W. Barbosa
  HP-12C program Mike (Stgt) 4 463 07-16-2005, 07:58 AM
Last Post: Mike (Stgt)

Forum Jump: