Thursday, October 6, 2011

RPL Programming Tutorial - Part 1 - HP 49g+/50g: Your First Program


RPL Tutorial - Part 1

Introduction

This is a first in a series of RPL programming tutorial with the Hewlett Packard HP 50g Graphics Calculator. RPL stands for the Reverse Polish Lisp programming language. RPL is similar to RPN, since RPL is a combination of RPN (Reverse Polish Notation), Lisp, and Forth.

This series of tutorials cover basic RPL programming. There is a wide variety of mathematical programs, applications, and analysis that can be done with the HP 50g calculator. My goal of this series is to introduce readers to RPL programming so that they get a working knowledge of RPL programming.

The Hewlett Packard graphing series, starting with the HP 28C in the late 1980s, through the HP 48S series, the HP 48G series, the HP 49G at the turn of the century, and the 49g+ all operate on RPL. If you have a 50g or a 49g+, you can follow the programs in this tutorial keystroke by keystroke. Most of the programs shown in this series can be programmed on the 48S, 48G, and the 28 series - but please check your manual: these are older calculators that require different keystrokes.

For example, the programming commands are accessed on the 48S and 48G just by pressing the [PRG] key on the top row. However, on the 49g+ and 50g, you will need to press [LS] [EVAL] to access the program commands.

The author owns a 48SX, 48G, 49g+, and a 50g.

Getting Started

Shift and Soft Keys

For the HP 50g:

[LS] represents the Left Shift key. It is the third key up from the ON button on the left hand side of the keyboard. The key's color is white.

[RS] represents the Right Shfit key. if is the second key up from the ON button on the left hand side of the keyboard. The key's color is orange.

[ALPHA] is the Alpha Key, which allows the user to type alpha and other characters. This is important in naming programs and variables. For the programs in the tutorials, I will use one letter names for variables (i.e. A, B, C, etc..)

Pressing [ALPHA] twice will lock the keyboard into Alpha-Lock mode. This allows you to type more than one letter in succession. Press [ALPHA] again to leave Alpha-Lock mode.

The [ALPHA] key, which is yellow in color, is the fourth key from the ON button on the left hand side of the keyboard.

Finally, the top row of the keyboard consists of six soft keys, labeled F1 to F6. The functions of the soft keys change depending on which menu is currently active.

HP 49g+ Shfit Key Colors:
[ALPHA] - yellow
[LS] - green
[RS] - red

HP 50g Shift Key Colors:
[ALPHA] - yellow
[LS] - white
[RS] - orange

Setting the 50g to RPN Mode

All the programs shown in this tutorial series will be operated in RPN (Reverse Polish Notation) mode. To set the 50g in RPN mode:

1. Press the [MODE] key.
2, Press [F2] (CHOOSE) and select RPN.

Your calculator is set. (49g+ users follow the same instructions)

Setting Soft Menus

Personally I like using soft menus. The HP 49g+ and 50g gives a user a choice to operate using soft menus or scrolling menus. All of the keystrokes in the programs in this tutorial assume that you are using soft keys. To set the calculator for soft keys:

1. Press the [MODE] key
2. Press [F1] (FLAGS) to bring up the calcualtor's flags. Flags are binary operators that dictates the various modes of the calculator. Note: There are user flags that you can set for programming purposes.
3. Scroll up until you see "117" on the left side. If there is a check mark next the 117, the calculator will read "117: Soft MENU". Otherwise, the calculator will read "117: CHOOSE boxes". Press [F3] until 117 is checked. Then press [F6] (OK) twice.

We want the calculator to read "√ 117 Soft MENU". 49g+ users will follow the same instructions.
Programming Basics

Brackets

Programs are enclosed with "pointy" brackets. ( << >> ) All the programming instructions are included with a set of brackets. We can enclose programming instructions in many sets of brackets.

How to Name Programs

You can name a program almost any name you want. Program names are enclosed in single quotes. ( ' ' ) Named programs are shown in the Variables menu. You can simply access the Variables menu by press the [VAR] key. Variables most recently stored are listed first.

Note that:

1. Variable names can be used to name not only programs, but real numbers, complex numbers, constants, graphic databases, matrices, vectors, lists, and even quotes.

2. The Variables menu will only show the first five characters. When a menu is showing (this works with almost any soft menu), you can press [RS] [down arrow] to have the calculator list the full name of each of the commands shown in the current soft menu.
(Edited 4/12/2013: Thank you to Félix Hernández for correcting me on this step - much appreciated!) 

3. Variables must start with a letter and can be of any length. No spaces are allowed in variable names.

Acceptable: 'PROG1', 'MYPROG', 'CHANGE%'
Not Acceptable: '123', 'COOL PROGRAM'

How to Name a Program:

1. Press [ ' ].
2. Press [ALPHA] [ALPHA] and type the name. The alphabetic characters are the yellow letters on the keys. Lower case letters can be accessed by first pressing [LS] before the letter. You can access other characters as well by first pressing [RS] before the appropriate key. When done press [ENTER].
3. Press [STO>].

How to delete a Program:

1. Press [ ' ]
2. Press [VAR] and find the program (or variable) you want to delete. Press the appropriate soft key to recall the name.
3. Press [TOOL] then [F5] (PURGE). The program (variable) is deleted.

Your First Program

Finally! Now we get to the good stuff - programming! Programming is one of my favorite features of graphing calculators.

The first program we are going to do is a simple one: find the area of a circle of a given radius. This program takes the radius from Level 1 of the stack and returns a numeric approximation of the area.

Commands Used

&rarr NUM: Convert the contents of Level 1 to an approximate answer.

The Program ACIR

For each program, I will list a series of keystrokes. Following the keystrokes, any notes will be italicized .

Ready?

[RS] [ + ] (<< >>)
* Start the program
[LS] [ √ ] (x^2)
* Square function - labeled as SQ
[LS] [SPC] (π)
* Inserts π
[ x ]
[RS] [ENTER] (->NUM)
* Convert answer to an approximation
[ENTER]
* Terminate program

[ ' ] [ALPHA] [ALPHA]
[F1] (A) [F3] (C) [TOOL] (I) [ √ ] (R) [ENTER] [STO>]


Store the program in variable ACIR

The Program:

<< SQ π * ->NUM >>

Running ACIR

1. Type the radius.
2. Press [VAR] - find ACIR and press the appropriate soft key. Press [NXT] if necessary.

An alternative way:

1. Type the radius.
2. Press [ ' ] [ALPHA] [ALPHA] type ACIR and press [ENTER].
3. Press [EVAL] to run the program.

Results:

Radius = 6; Result = 113.09734
Radius = 4.08; Result = 52.29621

Hint: You can look at program (to edit, view, etc), by pressing [ ' ], typing the name, and pressing [LS] [STO>] (RCL) .

Be sure to check this blog for future tutorials on RPL Programming. Up next, local variables. See you next time! - Eddie

This tutorial is property of Edward Shore. Mass reproduction or distribution requires express permission by the author.

TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...