It must be 35 years or more since I first heard on Reverse Polish Notation. It is one of those ideas that seems to have been around forever, but has never quite become mainstream. And, for me, it has always been intriguing. I suppose my interest comes from always enjoying mathematics (well, arithmetic really) and having a liking for more efficient ways to do things. That is what RPN really is: a more efficient way to do sums …
Anyone with the most basic education can do sums. For example, I am sure that there is nobody reading this who cannot perform this calculation (maybe with the aid of a calculator): 4 x 5 + 2 x 6 and arrive at the right answer (which is 32 by the way). To do this calculation, apart from knowing how to multiply and perform addition, you need to know that multiplication takes precedence over addition. In other words, we could re-write the sum like this: (4 x 5) + (2 x 6).
To perform the calculation using a pocket calculator is surprisingly complex. The result of the first multiplication must be saved (in the memory) until the second one is ready. You would need to key in something like 4 x 5 = STORE 2 x 6 = + RECALL = which is not totally intuitive in my view. Some calculators “know” about the operator precedence and others have parentheses keys, which enable much more intuitive use, but it can still be hard to follow a more complex calculation.
Enter RPN. This alternative way to do sums, which is available on quite a few calculators, does away with the need for memories, parentheses and operator precedence at a stroke. The idea is that you enter some data (a number) and it gets put on a stack. The next number is put on the stack on top of the first. Operators, like multiply, simply use the top two items on the stack and place the result back on the stack and on the display. So, to do this sum using an RPN calculator, you would key in: 4 ENTER 5 ENTER x 2 ENTER 6 ENTER x +.
Many calculators make it even simpler by eliminating some use of the ENTER key before an operator, but even in this example there are less keystrokes that a normal calculator. Once upon a time, to try out RPN, you would need to buy an expensive pocket calculator from HP. Now there are many cheap or free programs for PCs, smartphones or iPad that give you the chance to experiment with the technique. Give it a try. You might just get hooked and never be able to go back to a conventional calculator again.