Overview
Postfix notation, commonly called Reverse Polish Notation (RPN), is a way of writing arithmetic and logical expressions in which operators follow their operands rather than appearing between them. Infix expressions such as "3 + 4" become "3 4 +" in postfix. Because the order of operations and grouping are encoded by the sequence itself, postfix eliminates the need for parentheses in most cases. For a general introduction see background on postfix.
Unlike ordinary infix notation used in everyday mathematics, postfix is particularly well suited to mechanical and programmatic evaluation. A simple stack machine can evaluate postfix expressions by pushing operands and applying operators as they appear. For technical contexts and further reading, consult technical overview and historical surveys such as studies of notation.
History and development
The idea of alternative notations for logic and arithmetic dates to the work of logicians in the early 20th century. Jan Łukasiewicz proposed what is now called Polish (prefix) notation in the 1920s to remove ambiguities from logical formulas. The related idea of placing operators after operands — postfix or Reverse Polish Notation — was developed and promoted in the mid-20th century as a practical evaluation scheme for computers and calculators; Charles Hamblin played a key role in popularizing postfix notation for use in logic and computing. For biographical and historical references, see Hamblin's work and treatments of Łukasiewicz and Polish notation.
How it works: characteristics and evaluation
Postfix expressions list operands first and then operators. The standard procedure to evaluate a postfix expression is:
- Scan the expression from left to right.
- When an operand is encountered, push it onto a stack.
- When an operator is encountered, pop the required number of operands from the stack, apply the operator, and push the result back on the stack.
- At the end, the stack contains the result.
Example: the infix expression "(3 + 4) * 5" becomes "3 4 + 5 *" in postfix. Evaluation proceeds by pushing 3 and 4, applying + to get 7, pushing 5, then applying * to get 35. A more elaborate example used in tutorials is "5 1 2 + 4 * + 3 -", which evaluates to 14 and demonstrates nested operations without parentheses. See an implementation note at calculator languages.
Uses and applications
- Calculators: Many Hewlett-Packard handheld calculators used RPN as a primary input mode because it reduces keystrokes and parentheses; see HP calculator history and user guides at product references.
- Programming languages and formats: Some languages and document formats for graphics and printers (notably PostScript) use postfix-style syntax internally, which simplifies parsing on devices with constrained resources.
- Compilers and interpreters: Postfix is an intermediate representation in compilers and in stack-based virtual machines, where its evaluation model maps directly to push/pop bytecode.
Although uncommon for handwritten algebra, postfix remains important in teaching, computer science, and embedded systems because of its deterministic evaluation and minimal parsing requirements. It is also a useful mental model for understanding expression trees and evaluation order.
Notable distinctions: Prefix (Polish) notation places operators before operands; postfix places them after. Both eliminate the need for parentheses, but they differ in readability for humans and in the ways they fit particular machines or languages. RPN is closely connected to the stack data structure: understanding one clarifies the other.
Further reading and tool implementations can be found through introductory texts and online resources; a selection of entry points is provided above for readers who wish to explore algorithms, historical context, and practical uses.