Professional Documents
Culture Documents
Hewlett-Packard RPN
Primary Components
Number Entry Convention
The Automatic Memory Stack
Other Features of HP RPN
Algebraic Systems
Primary Approaches
Simple Algebraic
Algebraic with Hierarchy
Algebraic with Parentheses
Algebraic with Hierarchy and Parentheses
Number Entry Conventions
Summary
Confidence in Accuracy of Results
Simplicity of Operation
Efficiency
Advanced Calculator Logic
HP RPN/Algebraic
A Comparative Analysis
Introduction
This booklet discusses in depth the logic systems Bm A few specialfeatures such as stack manipulation
available on advanced hand-held calculators in use operations and an additional register to provide
today. Logic systems have a great effect on the overall flexibility to the user to manipulate and review
effectiveness of calculators: the logic system of a par- the numbers in his calculations and to recover
ticular calculator determines directly how quickly, from errors he may have made.
accurately, and simply the user can obtain answers.
The RPN system as implemented on Hewlett Pack-
ard calculators (hereafter referred to as HP RPN) is
Number Entry Convention
discussed first, followed by the various algebraic sys- At the heart of the HP RPN system, the number
tems as offered on most competing brands. HP RPN is entry convention follows the rules of “Reverse Polish
then contrasted with the most sophisticated of the Notation’ (RPN) as developed in 1949 by Polish
algebraic systems, and benefits of each are demon- mathematician Jan Lukasiewicz. RPN allows the
strated through the use of example problems. placement of the operator immediately after the
No attempt is made to evaluate each system’s effec- operand(s), eliminating all ambiguity regarding the
tiveness in programming. Rather the discussion is order of execution in compound expressions. Thus,
limited to the basic system feaures as encountered in algebraic hierarchy rules and inserted parentheses are
manual keystroke solutions. However, the benefits of not needed to clarify the order of execution.
a particular system in manual solutions (e.g. effi-
ciency, ease-of-use) generally apply to programming Consider how the following expression is evaluated
effectiveness as well. by hand:
This booklet will be of particular interest to educa-
5+6
tors who are involved with teaching calculator usage
or assisting students in gaining the most from their
calculators. It will also be of interest to users in any The first number is written and then the second
field who are either evaluating alternatives for pur- number. Finally, the add operation is performed, and
chase or striving to increase their effectiveness in the answer is obtained:
utilizing their existing machines through greater un-
derstanding of the logic system. 5 —O
@— 11
Hewlett-Packard RPN
In effect, the following sequence was followed, read-
Primary Components ing from left to right:
The basic elements of HP RPN are:
HB A number entry convention which provides for a
56+
consistent approach to all types of operations.
B Four special memories logically arranged in a
‘stack’ which operates automatically to manage This, in essence, is the RPN convention. The argu-
the storage and recall of numbers involved in ment (in this case two arguments) precedes the
calculations. operator — this is called “postfix’’ notation.
In an HP RPNcalculator, the key sequence follows No ENTER was necessary because only one
directly: number was operated on. As a point of contrast, it is
important to note that algebraic systems operate in
Bm Key in the first argument 5 exactly this way for single-number operations, but for
MW Press the key to two-number operations the function is placed be-
separate the first argument tween the numbers and must be followed by an = key.
from the second The number entry methods of most algebraic ma-
Bm Key in the second argument 6 chines are inconsistent in that they use a combination
Wm Press the key of algebraic (two-number functions) and RPN
(single-number functions).
The result, 11, immediately appears in the display
when the + key is pressed. The only new element in The Automatic Memory Stack
this key sequence is the ENTER used to separate the The HP RPN logic system combines an “automatic
two arguments. The ENTER key is used only for memory stack’ with the RPN number entry conven-
separating the first from the second number in any tion just discussed. The stack provides an automatic
operation requiring keyboard entry of two numbers in mechanism for temporarily storing arguments and
sequence. That is the only function of the ENTER key. intermediate results and making them accessible at
As problems become more complex, the RPN con- the appropriate point in a calculation sequence. In
vention works in the same way: essence, the stack is responsible for the “housekeep-
ing” or management of arguments awaiting their
16+30-11+17—-14 operations.
The stack consists of four storage registers, logically
Press Display Comments arranged to provide a last-in, first-out storage and re-
trieval of arguments in a calculation. This can best
16 16.00 be illustrated if the registers are pictured one above
30 46.00 (16 + 30) the other:
113 3500 (16+30-11]
17 3) 52.00 (16 +30—-11+17) 3 <N =
14 2) 38.00 (16+30—-11+17— 14)
Press Display
DISPLAY
5 5
2.2361
Notice that just before the + key is pressed, the two added together to get (12 +3)+(5 x4). Continuing
numbers are logically arranged in the stack the same with the problem, this addition is performed followed
way as they would be if the problem were being by the calculation of (2 X 3) =6 in the denominator.
worked by hand:
T
Z
Y
X| 24
KEYS
T —— KEYS (J 5 x]
DISPLAY
Vx
AeBy ren TH
The problem will be worked for an object traveling
at 350 knots at an altitude of 25,500 feet. The problem
is attacked from the innermost set of parentheses,
thus beginning with: Ly —
Z| JL
2
Y[ 21 |
350 knots X| 276 || .58
661.5
x)
3
y
X<N-
| 1.14
1 =
T( 10 J )
Z , JL J
YL 14 JL JL J
X | 5 1 70 | [84
5 J
The HP RPN system enabled this calculation to be The add operation has now been reversed.
attacked and worked in the same order as if it were
worked longhand with pencil and paper.
As each function key was pressed, the result of that
operation was immediately displayed in the X register,
providing feedback of the intermediate results.
Other Features of HP RPN
There are a few additional features of the HP RPN
system which contribute to its utility in solving prob-
lems. These features deal with the ability to manipu-
late data in the stack registers. Since operations are
not stored and held pending in this system,this ability In a similar manner, if the wrong function key was
can be valuable in rearranging or duplicating argu- pressed, a user can recall LAST X, reverse the func-
ments prior to actual execution of the next operation tion, and then proceed with the correct operation.
to be performed. This may be especially helpful in
error recovery. Stack Manipulation Keys
Besides the ENTER key, two other keys are provided
LAST X Register which offer a means to rearrange arguments in the
In the following diagrams, notice the addition of a stack. These are the X-exchange-Y key and the roll-
fifth register, called LAST X. Essentially, every time a down key.
user presses a function key that puts a new number X 2 Y simply exchanges the contents of these two
in the X register, the previous number goes into the registers without affecting the other stack contents:
LAST X register. To illustrate, consider the prob-
lem3+4=7:
TT __ [—______
2)
a —
2 . 22. 22. 6 6
i | In 2 is calculated
469 Result off [x] 6. Multiply held
square root. pending until
® 2x72°
Cos 72 is calculated multiplicand
In2 is entered and
calculated.
17 | 17 is added to Cos
= 28.14 Result of mul- 4.69 Result of
The function keys always follow directly the num- tiplication. square root.
bers to be operated on, whether the function is a 17. 17. =) 28.14 Result of pre-
single-argument function (Cos, In) or a two-argument vious multi-
plication, di-
function ( x, +, +). vide held
pending.
In algebraic, the order of key entry is as follows:
= 166 Result of divi- 17 17
KEY OPERATION PERFORMED sion.
Divide is entered, awaiting the 2.26 Result of add. (5:8) 0.60 Result of sine.
Final answer.
second argument for divide.
2 | 2 is entered prior to 1n, and the = 2.26 Result of pre-
vious addi-
(in) In is calculated immediately. tion. Final an-
Plus is entered, awaiting the SWEr.
second argument.
17 The second argument for the In the HP RPN system, the display always shows
plus is entered. the results (intermediate answers) of the function just
pressed. This allows the user to check for resonable-
3 Equals is entered, signaling the ness all the way through a calculation or discover
end of the calculation.
where a computational problem occurs. The cal-
Note how for two-argument operations (x, +, +) the culator always executes a function the instant it is
operator is entered between the arguments; but for pressed, it does not require storing operations for later
one argument operations, (Cos, In) the operator is execution (pending operations).
entered after the argument. This characteristic is a In this algebraic system, the display sometimes
departure from the idealized algebraic system covered shows results of a previous operation when a later
in the last section and results in an inconsistency that operation is pressed and sometimes shows the results
must be understood and managed by the user. of the operation last pressed. It is a characteristic of the
algebraic system that there is inconsistency in the In this algebraic system, the display contents have
relationship of the display contents and the function lost virtually any usefulness to the user. In essence,
order. the man/machine dialogue has become a man-to-
When parentheses are included, this characteristic machine monologue until the last = key is pressed.
is more dramatically illustrated. In HP RPN, a prob- The resultis that the calculator does not aid the user
lem with parentheses is worked beginning at the in- in following through his calculation, thus increasing
nermost set of parentheses, as it would be done by his own responsibility to do so and adding to the
hand. In algebraic, it is worked from left to right. probability of making an error.
Consider the following problem:
5% (4+(3 x(2—6)) Keystroke Efficiency
In the problem previously worked:
HP RPN ALGEBRAIC 5x (4+(3 x(2 —6))), note the number of keystrokes
Key Display Comments Key Display Comments required to work the problem in the two systems. In
HP RPN, 10 keystrokes were required; in algebraic, 16
2. 2. 5 5 keystrokes were required.
2.00 x) 5. Multiply The HP RPN system does not require the entry of
held pend- parentheses into the calculator, resulting in fewer
ing.
keystrokes. It is widely accepted that in problems
6. 6. © with even moderate complexity, algebraic systems
=] - 4.00 Result of 4 4 will require a greater number of keystrokes due to the
the sub- necessity to enter parentheses. Although parentheses
tract. are required to remove ambiguity in written expres-
3 3 4 Add held sions, they are not required in the operation of the HP
pending. RPN system.
x] -12.00 Result of |[([@ 4. This feature of HP RPN is also important in pro-
the multi- grammable calculators because it conserves program
ply. memory space.
4. 4. 3 3
3
8
‘Plus’ mistakenly pressed.
‘Plus’ mistakenly pressed.
6
Bring the last number(6) back
= Try to recover by first adding,
into X. (Using LAST X is not
6 then subtracting the 6.
necessary, just convenient.)
J] Now multiply as originally =] Subtract it, thus reversing the
intended. incorrect addition.
6
Bring it back again.
= Incorrect answeris displayed as J Multiply it as intended and
—22.
get correct answer of 48.
This procedure failed to correct the error. The prob- Logically, what has been done here is as follows:
lem occurs because of the built-in hierarchy which
causes execution as shown below: 5 8 14 8
(5+3)+6—6x6 8 14 8 48
—
or
Another approach would have been to key in zero Because intermediate results are calculated as each
(instead of six) once the user realized he had mis- operation is entered, then operations can be reversed.
takenly pressed the plus key. This would seem to Further, the LAST X function ensures accurate recall
cancel the effect of the mistake, then the multiply of the number incorrectly operated on.
could be performed. However, the answer will again Another type of error that can occur is incorrect
be wrong, but different than before: entry of parentheses.
(17 —5)
or
8+0=8
16-4
One method which will work is to prematurely
complete the calculation by pressing =, thus com- Assume that the numerator was evaluated cor-
pleting all pending operations and allowing a new rectly; but when the divide operation was performed,
calculation to begin. the user left out the parentheses for the denominator
as follows:
(5+3)+0=8
8 X6 =48 (17-52 +16 —4 =4
Of course, if this simple expression were imbedded The result is incorrect, of course, because the divide
in a longer expression, pressing the[ =] would cause all operation utilized 16 as the denominator, rather than
open parentheses to be closed and all pending opera- 12, (16 —4). The correct answeris 12.
tions to be executed. The result may bear no relation- To recover, the user may try to reverse the sequence,
ship to the desired calculation. but the built-in hierarchy will work against him:
(17-5) +16 —4 +4 x 16 incorrect calculations, then re-enters them properly.
— Logically, the sequenceis as follows:
attempt to reverse the sequence