Print

# why RPN? - and how to use it

Just a small example for non-RPN users, to show the superiority of RPN for chain calculations:

Solve the following simple expression

(3+5 ) / ( 7+6)

 Mode Process Key Strokes Additional Information Algebraic 1.Add 3+5=8 2.Write down the answer or store it in memory. 3.Add 7+6=13 4.Divide ‘8’ from step 1, by 13 from step 3 to get x=0.62 13 Additional effort to write down initial answer, while you calculated the second answer. RPN 1.Touch 3, then ‘ENTER’ 2.Touch 5, then ‘+ ‘ 3.Touch 7, then ‘ENTER’ 4.Touch 6 then ’+’ 5.Touch the divide key and x=0.62 9 No need to write anything down.

This short example was taken from a HP presentation.

Here you have a Java RPN calculator to try (look how nice it is):

## RPN Characteristics

• Calculations occur as soon as an operator is specified. Thus, expressions are not entered wholesale from right to left but calculated one piece at a time, most efficiently from the center outwards.
• The automatic stack permits the automatic storage of intermediate results for use later: this key feature is what permits RPN calculators to easily evaluate expressions of arbitrary complexity: they do not have limits on the complexity of expression they can evaluate.
• Brackets and parentheses are unnecessary: the user simply performs calculations in the order that is required, letting the automatic stack store intermediate results on the fly for later use. Likewise, there is no requirement for the precedence rules required in infix notation.
• In RPN calculators, no equals key is required to force computation to occur.
• RPN calculators do, however, require an enter key to separate two adjacent numeric operands.
• The machine state is always a stack of values awaiting operation; it is impossible to enter an operator onto the stack. This makes use conceptually easy compared to more complex entry methods.
• Educationally, RPN calculators have the advantage that the user must understand the expression being calculated: it is not possible to simply copy the expression from paper into the machine and read off the answer without understanding. One must calculate from the middle of the expression, which is only meaningful if the user understands what he or she is doing.
• Reverse Polish notation also reflects the way calculations are done on pen and paper. One first writes the numbers down and then performs the calculation. Thus the concept is easy to teach.
• The widespread use of electronic calculators using infix in educational systems can make RPN impractical at times, not conforming to standard teaching methods. The fact that RPN has no use for parentheses means it is faster and easier to calculate expressions, particularly the more complex ones, than with an infix calculator, owing to fewer keystrokes and greater visibility of intermediate results. It is also easy for a computer to convert infix notation to postfix, most notably via Dijkstra's shunting-yard algorithm—seeconverting from infix notation below.
• Users must know the size of the stack, because practical implementations of RPN use different sizes for the stack. For example, the algebraic expression , if performed with a stack size of 4 and executed from left to right, would exhaust the stack. The answer might be given as an erroneous imaginary number instead of approximately 0.5 as a real number.
• When writing RPN on paper (something that some users of RPN may not do) adjacent numbers need a separator between them. Using a space requires clear handwriting to prevent confusion. For example, 12 34 + could look like 123 4 +, while something like 12, 34 + is straightforward.
• RPN is very easy to write and makes practical sense when it is adopted. The "learning" process to adopt RPN in writing usually comes later than adopting RPN on a calculator so that one may communicate more easily with non-RPN users.

You can see here a video with a demo of how RPN works:

Eddie's Math and calculator blog includes a  comprehensive RPL programming tutorial, of great interest. Good examples and good approach: