Postfix notation

Postfix notation is a mathematical notation. It is a way to write down equations and other mathematical formulae. Postfix notation is also known as Reverse Polish Notation. The notation was invented by Charles Hamblin in 1920. He wanted to simplify writing logic equations. He used Jan Łukasiewicz's prefix notation.

Postfix-dia.svg
Prefix notation
Infix notation
Postfix notation

When postfix notation is used, no grouping elements (like parenthesis) are needed.

Some computer languages, like Postscript use Postfix notation. It is also used in some models of Hewlett-Packard calculators

With postfix notation, the operations are noted after their arguments. Because of this, postfix is relatively easy to do with computers that have a stack to do calculations.

Further Explanation

Reverse Polish Notation uses a system that involve "stacks", each of which stores a certain value in specific ranks.[1] The stacks usually start off with the first stack (often called the X stack), followed by the second stack (often called the Y stack), the third stack, and so on. New values can be entered on the first stack by pushing up the stack ranks by one. On a Reverse Polish Notation calculator, the "Enter" function would do the same.

Using a common operator (plus, minus, multiply, or divide) will make the operator act from the first stack to the second stack. For example, the Reverse Polish Notation "12 3 /" means "take the numbers 12 and 3, then divide 12 by 3". On a Reverse Polish Calculator, this is written as "12 Enter 3 /", to denote each declared ranking up of the stacks.

Reverse Polish Notation is able to deal with expressions involving brackets too. Suppose there is a normal equation "4 * (5 + 8)". In Reverse Polish Notation, this expression will be formatted as "5 8 + 4 *". The "5 8 +" part refers to the bracket "5 + 8" to equal 13. The "4 *" part refers to multiplying the result together to get 52. On that step, the resulting stack from adding 5 and 8 is automatically raised one rank after adding in the new value 4. Then using the multiply operator will multiply the sum of 5 and 8 by 4 will equal 52.

Documentation included with early Hewlett-Packard calculators explained RPN as the same method you would use to evaluate an expression using paper and pencil. Basically, first you write down the arguments and then perform the arithmetic function. From the calculator's perspective, you must provide the argument(s) before calling the function. The benefit of a calculator with RPN is that you are always certain to which numbers (or intermediate calculation results) a function is being applied.

Postfix Notation Media

References

  1. "Reverse Polish Notation (RPN)". techopedia.com. Retrieved February 7, 2019.