The Museum of HP Calculators

HP Forum Archive 20

 A few simple HP 35s programsMessage #1 Posted by Lode on 3 July 2011, 5:14 p.m. Hi, I made a few simple programs for the HP 35s which make it a little bit better imho :) I tried to let each one keep as much of the original stack as possible intact, this didn't succeed for every function however. There are: extract im/re, ->R, ->P, lambertw, complex loggamma, complex conjugate, complex asin/acos/atan and complex sqrt. They're almost all located on or near a key where either a function is similar, or the letter is a good mnemonic. The polar/rect and lambertw ones were inspired by posts from here but made simpler. What do you think of the programs? Got any tips to improve them? Are there any HP-35s related resources for other useful programs or programming tips and techniques? I found the Matrix Multitool which is very nice, but for the rest I only find surveying related programs... Any ideas for *games* that can be programmed on a device like this? Thanks! ```//Get re in x and im in y. Located on the imaginary number key. lbl g eqn: abs(regx-sq(abs(regx))/regx)/2 x<>y 1/x clx eqn: abs(lastx+sq(abs(lastx))/lastx)/2 rtn //Complex conjugate, on the +/- key lbl n 1/x clx sq(abs(lastx))/lastx rtn //LambertW, on the W key. Makes a mess of the stack. lbl w sto j fn= v solve i rollup x<>y rtn //LambertW helper function (too bad this costs a whole label, why can't you give line numbers to SOLVE??) lbl v rcl i e^x lastx * rcl j - rtn //Polar to rect, on the R key representing ->R lbl r eqn: regy*sin(regx) enter eqn: regx*cos(regy) rtn //Rect to polar, on the S key because it's next to the R. Unfortunately lets the oldest stack value get lost. lbl s i * + arg lastx abs rtn //Complex loggamma, on the z key which is above '!'. lbl z 1/x clx eqn: 0.918938533205+(lastx-0.5)*ln(lastx)-lastx+1/(12*lastx)-1/(360*lastx^3)+1/(1260*lastx^5) rtn //Square root of complex numbers, on the square root key lbl k 1/x clx eqn: lastx^0.5i0 rtn //Complex asin, on the sin key (why doesn't it support this by default anyway?) lbl h 1/x clx eqn: -i*ln(i*lastx+(1-lastx*lastx)^0.5i0) rtn //Complex acos, on the cos key lbl i 1/x clx eqn: -i*ln(lastx+((lastx*lastx-1)^035i0)) rtn //Complex atan, on the tan key lbl j 1/x clx eqn: 0.5*i*ln((1-i*lastx)/(1+i*lastx)) rtn ```

 Re: A few simple HP 35s programsMessage #2 Posted by Paul Dale on 4 July 2011, 1:28 a.m.,in response to message #1 by Lode I wrote a game for the 35s which still hasn't made it into the software library but is available as an article and buried in the archives. Also, we did a group effort on R->P and P->R functions, again available as an article. These behave the same as internal commands with respects to stack operations, LastX etc. - Pauli

 Re: A few simple HP 35s programsMessage #3 Posted by Lode on 4 July 2011, 3:36 p.m.,in response to message #2 by Paul Dale Why is there so much flag 10 logic in these R/P examples? If it's to clear it for the equation, isn't just a single "CF 10" enough? If it's to keep the original state of flag 10: is that really so important to be worth so much extra lines (not to me)? If a program wants to display a message it will set the flag anyway... The game looks cool! It's going to be a LOT of work to type it over though! I wish there existed a way to automate this inputting. When typing over the "Matrix Multitool", there was one big problem I had: since the calculator updates line numbers automatically when inserting lines, it sometimes messes with line numbers if you need to correct a mistake on an earlier line. It was hell. When I typed that matrix program, I had already added the "RTN" at the end while still typing all previous lines. It had changed almost all GTO's and XEQ's that pointed to the future, into line number 442. When going back to correct each of those, due to deleting and readding the GTO line, some others got messed up as well, etc... Any tips on efficiently entering a long program and not letting it mess up line numbers?

 Re: A few simple HP 35s programsMessage #4 Posted by Paul Dale on 4 July 2011, 5:38 p.m.,in response to message #3 by Lode Quote:Why is there so much flag 10 logic in these R/P examples? The logic is there so they act exactly like internal commands -- don't care about the state of the device on entry and don't change the state of the device on exit. Equations don't work if flag 10 is set so that has to be cleared and restored. Quote:If it's to clear it for the equation, isn't just a single "CF 10" enough? If it's to keep the original state of flag 10: is that really so important to be worth so much extra lines (not to me)? A nice simple solution is to remove the bits you don't want. The 35s isn't even remotely short of program memory so the extra lines are kind of moot. Quote:If a program wants to display a message it will set the flag anyway... And if the program neglects to clear this flag afterwards? What about a program that sets it to display messages and then does a rectangular polar conversion. These commands are designed to work regardless. Still, take out the bits you don't want or do your own. Quote:Any tips on efficiently entering a long program and not letting it mess up line numbers? Nope, it is just painful. When developing the game, I retyped it when substantial changes were made to avoid these issues. - Pauli

Go back to the main exhibit hall