HP 50g: Programming simple functions.

Programming HP 50G with SysRPL

Most of the programming in HP 50g are done in SysRPL language, a reverse polish notation language
with features for handling
list and objects. In this blog we start with our first example program: compute the area of a
circle which is given by A = \pi r^2. Our calc will expect the value of the radius to be on the stack.

  1. Set the calculator to RPN mode if it is in Algebraic mode. If it is,
    Press \fbox{MODE}\, \fbox{+/-W} \fbox{F6-OK} in sequence. Otherwise go to Step 2.

  2. Press \fbox{RS}\,\fbox{+} for "<<>>"" The last key is found in the last column of the second row.
    Your calc will now be in program mode with a matched pair
    of "<<" and ">>" shown. Now type in the following after the opening "<<":

    x^2 RS .
    LS SPC RS .  
    *   RS .
    RS ->NUM

    The "RS ." combination inserts a carriage return. The Left shift SPC combination represents the \pi constant.
    The "RS ->NUM" combination converts the answer to numeric value.

  3. Press ENTER key. Immediately the display screen will output << SQ \pi * ->NUM >>.
    This small program is pushed to the stack
    and will be at level 1.

  4. Save and give a name to your program.

    Enter the string CAREA enclosed in single quotes then press the STO key.
    Now your program is stored in variable named CAREA.

    Press the VAR key and your program should be displayed in the soft menu as CAREA.

  5. Test your program.

    Enter value of 3, then press the softkey assigned to CAREA (In my calc, it is assigned to F1.)You may hve to press NXT key
    if you have lots of variables.
    If you see the value 28.2743338823, congratulations! you are on the right track.
    Otherwise you may have to edit your program and save the changes back (To be explained in a future post).

Programming in algebraic mode with DEFINE.

Simple functions can be programmed in algebraic mode.
Our circle area for example may be entered in algebraic mode

DEFINE(AREA(x)= SQ(x) * 3.14159265359)

We have to type in the actual value of pi since the ->NUM command does not work inside user defined programs with DEFINE.you dont have to type in the letters D E F I N E But rather press LS 2 (for DEF) when you create simple functions. Don't forget the closing parenthesis and press the ENTER key. A variable will then be automatically created taking its name from the the name of your function

Whan you have to use it, you recall its name either by typing its name
or pressing the softkey assigned to the variable and then the argument enclosed in parenthesis.
It is a bother entering parentheses and that's why rpn is a natural fit with calculators.

Moreover the program you created in rpn mode can also be used in algebraic mode! For example
the previous CAREA rpn function may be called with an argument as in CAREA(3). Clever chaps at HP!

Having the best of both worlds, algebraic formulas inside RPL programs

In rpn mode, once can edit and do the following:

-> r   
'3.14159265 * r^2'

The keystokes "-> r" pops the topmost stack value and store it into the local variable r.
a formula with algebraic syntax may be inserted inside RPL programs by enclosing them in quotes.

2 Responses to “HP 50g: Programming simple functions.”

  1. Abraham3 Says:

    I am much obliged for:

    "The keystokes "-> r" pops the topmost stack value and store it into the local variable r."

    In weeks of reading through the Manual and Users guide available for the HP-50G I had yet to come across that rather crucial piece of information. Those manuals are astoundingly abysmal pieces of work. The number of blatant errors is astoundingly high leaving me to strenuously suspect that the subtle errors are at least as commonplace. I have been attempting to write a program to take in ten values, do some calculations with them and pop out an answer. I have been working on it for almost three weeks now and have yet to fully comprehend the blinking INPUT statement. I'm a g*ddamned graduate engineer with 30 years in the field. I've been programming HP calculators since the late 70s. Why is there no stinking SYNTAX REFERENCE for RPL?

    Oh well. Enough venting. Thanks for your help.

  2. ernie Says:

    Well sir, thanks for the critical plaints, and please be also positive. Turn you badly needed critical energies to writing say, The Dummies Guide to the HP 50G. I think I saw one for the TI-89. Them small calculator buttons are getting in my way. As for the RPL syntax reference, these are scattered in the Internet. I think the documentation for the older HP48G are so MUCH BETTER!, and that is where I sometimes get ideas.

    I think calculators are reaching their end of amazing portable, inexpensive computing service era to engineers and scientists.

    I am blown away by the capabilities of the Iphone with symbolic math software and fantastic plotting capabilities.

    Still I will continue to add articles to the HP 50G whenever I can. I still find them sophisticated tools.