What is Reverse Polish Notation (RPN)?
Reverse polish notation, or RPN, is one of the three commonly used calculation notations. The other two are polish notation and infix notation. The latter, infix notation, is the one most commonly used across the world and is probably the form of notation that is most familiar to readers. Infix notation is the standard taught in schools, with the operator placed “in” the formula. For example, to show the calculation 10 plus 5, infix notation is written as 10 + 5.
In contrast, the polish and reverse polish notations place the operator on either side of the numbers. Polish notation would note the above calculation as + 10 5. Reverse polish notation is simply the opposite of that, with the operator appearing after the numbers. The infix notation formula of 10 + 5 is noted as 10 5 + in RPN.
Why use RPN?
At first glance, reverse polish notation may seem rather complicated or confusing, but it is actually a rather intuitive notation. When performing RPN calculations, the user follows the logical flow of the calculation. In contrast, infix notation requires the user to input a formula or calculation from left to right, regardless of whether the calculation is performed in that order.
One of the gold standard calculators used in the field of banking is the HP 12C calculator. This calculator uses reverse polish notation and is widely lauded for its efficiency and intuitiveness.
Example of an RPN Calculation
Assume a user is calculating the future value of $1,000 deposited today over the course of the next five years. In the first year, it will only earn 2%, but in years two and three, it will earn 5% each year, before reverting back to 2% for the last two years.
The formula to find the future value is:
FV = 1,000 x (1 + 0.02) x (1 + 0.05)^2 x (1 + 0.02)^2
In a traditional infix calculator, the simplest way to enter this function would be:
1000 [X] 1.02 [X] [OPEN PARENTHESIS] 1.05 [^] 2 [CLOSE PARENTHESIS] [X] [OPEN PARENTHESIS] 1.02 [^] 2 [CLOSE PARENTHESIS] [EQUALS]
With a reverse polish notation calculator, the simplest way to enter this function would be:
1000 [ENTER] 1.02 [X] 1.05 [ENTER] 2 [yx] [X] 1.02 [ENTER] 2 [yx] [X]
The RPN calculator uses 3 fewer strokes than the infix calculator, which saves time and is more efficient in the long run. Additionally, the user must remember the stack of parentheses applied in the infix calculator, which can become burdensome for longer calculations. An RPN calculator can perform parenthetical functions retroactively.
Thank you for reading this guide to RPN and how to make your complex calculations more efficient. For more financial analyst tools and training, please check out these additional resources: