The Museum of HP Calculators

HP Forum Archive 19

 How to work Hp50g programs on computer?Message #1 Posted by ferroburak on 24 Nov 2009, 2:15 p.m. Hi, Is there any way to work Hp50g programs on computer?(By means of a simulator or any other things) I need this for my numerical analysis homework. Thanks.

 Re: How to work Hp50g programs on computer?Message #2 Posted by Tim Wessman on 24 Nov 2009, 2:48 p.m.,in response to message #1 by ferroburak Install debug4x. You're welcome. TW

 Re: How to work Hp50g programs on computer?Message #3 Posted by Egan Ford on 24 Nov 2009, 3:00 p.m.,in response to message #1 by ferroburak If you are running Linux or OS/X then try x49gp (http://x49gp.svn.sourceforge.net/viewvc/x49gp/README.QUICKSTART). debug4x also works with Wine on both OS/X and Linux.

 Re: How to work Hp50g programs on computer?Message #4 Posted by ferroburak on 24 Nov 2009, 3:06 p.m.,in response to message #3 by Egan Ford I want to try Calcolo Numerico 1.2 But couldn't undersand how to use debugger. Can you elaborate on this matter? Thanks.

 the question I try to solveMessage #5 Posted by ferroburak on 24 Nov 2009, 4:37 p.m.,in response to message #4 by ferroburak Here's my question f(x)= 1 +5x - cos(0.3x^1/2)^-1 Find it's root between 2.5 and 3.5 by bisection and regula falsi methods. Actually I would appreciate any tool to do this. Thanks. Edited: 24 Nov 2009, 4:42 p.m.

 Re: the question I try to solveMessage #6 Posted by Crawl on 24 Nov 2009, 5:12 p.m.,in response to message #5 by ferroburak Now, you're not trying to get us to do your homework for you, are you? It doesn't matter, I guess, since the problem as given has no solution. The first root is at x=0 and the next one isn't until x=27.161003... (when 0.3*sqrt(x) is close to pi/2).

 NO!Message #7 Posted by ferroburak on 25 Nov 2009, 4:29 a.m.,in response to message #6 by Crawl Quote: Now, you're not trying to get us to do your homework for you, are you? It doesn't matter, I guess, since the problem as given has no solution. The first root is at x=0 and the next one isn't until x=27.161003... (when 0.3*sqrt(x) is close to pi/2). Hi, I didnt say I wanted a solution for my hw. I just wanted to be more precise about what I'm asking. (I also think there is a mistake in the question but that's not the issue..) I want to learn how to solve such an equation with debugxx or any other program that is available on pc. (better be hp 50g since I will start using it in a week!) Thanks.

 Re: NO!Message #8 Posted by Crawl on 25 Nov 2009, 8:49 a.m.,in response to message #7 by ferroburak There are a lot of ways to solve problems like that with the HP50g. For the problem you gave, you might need to divide the given function by x to prevent a solver from simply finding the x=0 root. I found the x=27.161... root by graphing. Using common sense, I knew the zero had to be close to (pi/(2*.3))^2=27.4. For most values of x, the function you gave is close to 5x, but when cos(...) is near zero, 1/cos(...) can take on any value, so that's when there will be a root. I set the window x range from 0 to 30 (25 to 30 gives a zoomed in view) and the y range from -5 to 150 (again based on y~5x). You move the cursor near to the zero you want, hit FCN, then ROOT. If your class requires you to use specific methods (like method of false position) then I assume they might want you to write a program yourself.

 Re: NO!Message #9 Posted by Crawl on 25 Nov 2009, 2:32 p.m.,in response to message #8 by Crawl Well, it turns out I had time today to write a quick HP50g bisection program. Of course, you can do this easily on this calculator. This is the program. I saved it as BI. It assumes a function saved to variable F has been defined. Let's assume we want to find the square root of 2 with the function x^2-2. You enter it on the stack like so. Then hit DEF (left shift on the 2 button) Then you need to have the root bracketed. Put the limits on levels 1 and 2 of the stack. It doesn't matter which is which. 1 and 2 bracket the root in this case. With the variable menu open (press the VAR key), every time you press the BI softkey, a bisection is performed. If you press it repeatedly, it (slowly) converges. Of course, you could also write a program to iterate automatically. Programming a method of false position solver could be an exercise for you. By the way, while the HP50g is a great calculator, it has a learning curve. The sooner you start to use it, the better. Going through the manual can help, of course, but a fun way to gain experience with it is to do challenges posted to the board, like the recent University calculator challenge, or Valentin's challenges.

 Re: NO!Message #10 Posted by C.Ret on 26 Nov 2009, 4:30 a.m.,in response to message #9 by Crawl Thank you for your contribution and great animated GIFs. It seems to me too that no debugger or compilater is required for this roots seeking problem. With great interest, I was comparing your bisection program BI with one of my own HP28’S’ program library. I found a very close looking program there. I still have two questions about your code; why are you storing the mean value in 'N’ , is there any purpose anywhere for further use? Why not arranging the use of local variables A B and N in a more comprehensive way without using any STO command such as : « -> A B « A B + 2 / -> N « A F SIGN N F SIGN == « N B » « A N » IFTE » » » In your original code, 0 is affected to N with no further use The second question; Why are you putting the IF statement at the end of the test, just before the THEN instruction, not at the beginning of it ? I already notice this way used by a lot of HP49 and HP50 code writers! Is there a technical issue there, not to follow the original and more comprehensive syntax structure: « IF test THEN clause1 ELSE clause2 END » There is my an alternative bisjection program peek out of my aged private library, which will run on HP50g as well has it hat does on HP28S so many times: « -> a b @ pickup a & b from stack « a b + 2 / @ compute mid point (n) IF DUP @ leave a copy of n in the stack F @ compute sign of F(n) a F @ compute sign of F(a) * 0 > @ indirectly compare signs THEN b @ leave n & b in stack ELSE a SWAP @ leave a & n in stack END » » ‘BIJ’ STO OR whith out any local variable structure (only stack manipulations): « DUP2 + 2 / DUP F 4 PICK F * 0 > «ROT» «SWAP» IFTE DROP » An alternative to write down an automatic iterative program, would be to use the SOLVER environment and pressing a key during for-looker’s loops, the HP will display intermediate A and B values in the run! These programs remembers me a lot of fun stuff from high school age! Edited: 26 Nov 2009, 5:20 a.m. after one or more responses were posted

 Re: NO!Message #11 Posted by Bart (UK) on 26 Nov 2009, 4:57 a.m.,in response to message #10 by C.Ret Quote: The second question; Why are you putting the IF statement at the end of the test, just before the THEN instruction, not at the beginning of it ? I already notice this way used by a lot of HP49 and HP50 code writers! Is there a technical issue there, not to follow the original and more comprehensive syntax structure: « IF test THEN clause1 ELSE clause2 END » Perhaps they are keeping in line with the RPN idea of arguments first then operation?

 Re: NO!Message #12 Posted by Crawl on 26 Nov 2009, 12:53 p.m.,in response to message #11 by Bart (UK) Quote: Perhaps they are keeping in line with the RPN idea of arguments first then operation? Yeah, that's all it is. When I'm "thinking in RPL", that's the syntax that makes the most sense to me. As for storing 0 in N, that's just how I declare local variables. It seems to me that having all local variables allocated up front is the easiest way to do it. Given a choice between various programming philosophies -- ease of writing, ease of reading, "elegance" -- I'll choose ease of writing.

 Re: NO!Message #13 Posted by Egan Ford on 26 Nov 2009, 1:30 p.m.,in response to message #10 by C.Ret Quote: Why are you putting the IF statement at the end of the test, just before the THEN instruction, not at the beginning of it ? I already notice this way used by a lot of HP49 and HP50 code writers! Is there a technical issue there, not to follow the original and more comprehensive syntax structure: « IF test THEN clause1 ELSE clause2 END » It may be historical. One of the roots of RPL is Forth, so it makes perfect sense. Forth does not give you an option, its always 'test' IF. Of course, Lisp is also a root of RPL and Lisp uses the more conventional 'IF' syntax, i.e. IF 'test'. However, neither Lisp nor Forth 'test' syntax matches the conventional a opr b (Forth: a b opr, Lisp: opr a b). I've written a few identical programs in Forth and Lisp so that I could compare them to RPL. No question RPL is more Forthy and less Lispy. I'd prefer that RPL was more Forthy. Sometimes rigidness makes it easier for groups to collaborate. And, it would be more consistent with the rest of RPL that does not have multiple ways to do some function. Perl is a great example of flexibility taken to extreme. "There's more than one way to do it." is a Perl motto. I'm fairly certain that no two Perl programmers will truly ever understand each other. I believe this because I lead a team of Perl programmers. I often hear, "why did he do it this way?", "what does this do?", "perhaps we should have used Python...", etc... I was once accused of my Perl code looking like it had come from a C programmer. Well it did. I took the statement as a complement. If you have not taken a look at Forth, then give it a go. Forth is freely available for just about every platform from the late 70's until today. Edited: 26 Nov 2009, 1:33 p.m.

 Re: NO!Message #14 Posted by Pal G. on 26 Nov 2009, 11:08 p.m.,in response to message #10 by C.Ret I am busy learning UserRPL, and am intrigued by your two quite different bisection programs, which produce identical results. Did you write it structurally first, then later decide to write it again in "stack manipulation" form, or does a "stack manipulation" decompiler exist?

 Re: NO!Message #15 Posted by C.Ret on 27 Nov 2009, 3:50 a.m.,in response to message #14 by Pal G. @ Crawl You are right in your programming philosophy and nothing is wrong with your code or style. Allocated all the variables at beginning of the program/function makes sense to me too. I use to make it systematically in the old style BASIC line program such as the one on my Commodore C128D computer, this greatly help organize data and memory. It si also sparing running -time or the bad behavior when "out of memory error" runs, which is quite easy to occur on simplest 8-bits computer. It is true that the IF…THEN…ELSE...END statements are not as Reverse Polish notation as the IFT or IFTE are. These two last are much more real post-pone operators like the majority of RPL instructions. Egan points out similarity between UserRPL and FORTH which indeed have IF/ELSE/THEN/ whith a much more “Reverse Polisch” behaviour. @ Egan Ford Thank you for our interesting input and thoughts. I was not aware that userRPL and FORTH have so much in common. Again, you indicate me a good subject of studies and I will certainly past my for-coming weekend in learning a lot of new stuff by reading and experimenting of few bits in FORTH. At first, the IF/ELSE.THEN syntax in FORTH pulzze me. FORTH have so much common syntax and stack operation (i.e. DUP DROP, etc…) . That’s perhaps why the syntax of IF/ELSE/THEN misleads me at first before I realize that the END statement was “missing”. It is fact it is not a lack in FORTH, it is RPL which have one extra statement, making the IF statement useless. In FORTH DUP 6 < IF DROP 5 ELSE 1 - THEN ; In UserRPL IF DUP 6 < THEN DROP 5 ELSE 1 – END These two lines have the same effet on the top value in the stack. Oppositely to FORTH the IF statement in RPL have no effect and the following variation of the code are equivalent: (changing position of IF/ELSE/THEN statements in FORTH will lead to a catastrophe) IF DUP 6 < THEN DROP 5 ELSE 1 - END DUP IF 6 < THEN DROP 5 ELSE 1 - END DUP 6 IF < THEN DROP 5 ELSE 1 - END DUP 6 < IF THEN DROP 5 ELSE 1 - END Amazing ! I never realize that. @ Pal G. Exactly, I generally first wrote first version of code using local variable or algebraic expression or what ever format is convenient depending of source of information. It this first phase, the function/programs are generally like prototypes and the first effort is to avoid any mistake or wrong transcription from the sources. Then after playing with it and using this ‘first generation’ of code, I sometime rewrite most useful section of code in a more compact manner. This is not systematic the great majority of code stay in the ‘easy to write it’ format. Only portion of code I use often will be ‘compilated’ into more ‘compact’ format. It is also copy to another part of the memory (I greatly use sub-directory to organize multiple project on my HP28S and share code have to be move to the top of the sub-directory tree. Since HP28S lacks any export/import capabilities with external PC, printing and saving ‘compact code’ documentation will help re-typing it into the calculator. This appends time to time. As far as I know, there is no “stack manipulation” decompiler on the HP28S, perhaps it may be one develop by the HP48/49/50 active community on these calculators or PC (since these are much more connected than old style HP28C/S).

 Re: NO!Message #16 Posted by Tim Wessman on 25 Nov 2009, 10:31 a.m.,in response to message #7 by ferroburak If you are on windows, debug4x includes an emulator for SW development purposes. Thus you can emulate a 48gx, 48gII, 49g+ or 50g by just clicking on the icon in the menu. TW

 real newbie..Message #17 Posted by ferroburak on 25 Nov 2009, 4:54 p.m.,in response to message #16 by Tim Wessman On debug4x 50g emulator screen I have: So what should I do to clear the screen. (I'm real newbie..)

 Re: real newbie..Message #18 Posted by Crawl on 25 Nov 2009, 5:07 p.m.,in response to message #17 by ferroburak Okay, you seriously need to read the manual. Especially before you ask any more questions. They even have the manual available in multiple languages.

 Re: real newbie..Message #19 Posted by Tim Wessman on 25 Nov 2009, 5:13 p.m.,in response to message #17 by ferroburak Download and go through this quickstart guide first before going into the larger manual. It will help you out and probably be more useful. ftp://hpcalclm:Builder2@ftp.usa.hp.com/ TW

 Re: real newbie..Message #20 Posted by John B. Smitherman on 25 Nov 2009, 5:20 p.m.,in response to message #17 by ferroburak Here's a link to some very good training modules for the 50G: I hope this helps. Regards, John

 Re: check out the price on the link pageMessage #21 Posted by Ken Shaw on 25 Nov 2009, 6:17 p.m.,in response to message #20 by John B. Smitherman HP50g for US\$99.99 Must be a mistake??

 Re: check out the price on the link pageMessage #22 Posted by Bart (UK) on 25 Nov 2009, 6:49 p.m.,in response to message #21 by Ken Shaw However, the picture is of a 40gs, which is listed as \$99.99 (on the "small/medium business -> handhelds" section). Clicking on the "buy online" link it comes up with a 50g for \$149.99. "Pech"

 A few weeks ago...Message #23 Posted by Vieira, Luiz C. (Brazil) on 25 Nov 2009, 5:49 p.m.,in response to message #17 by ferroburak ... we had this thread. Now we seem to face a very distinctive circumstance. Anyway, both posts relate to very new models, and contributors at MoHPC (keep in mind it is a MUSEUM, not a BRAND_NEW forum) have always been very friendly accepting and answering such questions. I for one prefer to stick with Pioneers, Voyagers, Spices and Nuts (Coconuts, Halfnuts, any nuts...). I feel as if I've been out for too long... Sorry, folks; could not help mentioning. Cheers. Luiz (Brazil) Edited: 25 Nov 2009, 5:49 p.m.

 sorry..Message #24 Posted by ferroburak on 25 Nov 2009, 7:00 p.m.,in response to message #23 by Vieira, Luiz C. (Brazil) Imho poor online support Hp gives for its products.. Hp help forum for calculators is dead so I ask all my question here.. Thanks for your help again. Edited: 25 Nov 2009, 7:10 p.m.

 Re: sorry..Message #25 Posted by BruceH on 25 Nov 2009, 7:30 p.m.,in response to message #24 by ferroburak The HP Help Forum is dead because the calcs are so easy to use no one actually need go there. What other reason could there be? ;-) Try asking your questions in comp.sys.hp48 on Usenet. You will get friendly help there.

 Re: sorry..Message #26 Posted by Bart (UK) on 25 Nov 2009, 8:20 p.m.,in response to message #25 by BruceH I pointed him to comp.sys.hp48 in a previous thread, including a link to it on Google groups if he doesn't have a news reader.