Polish Notation Converter
Convert expressions between infix, prefix, and postfix (Reverse Polish) notation. Free tool using the shunting-yard algorithm for students and programmers.
About This Calculator
Our Polish Notation Converter helps you transform arithmetic expressions between infix (standard), prefix (Polish), and postfix (Reverse Polish) notation. Whether you are a student studying the shunting-yard algorithm, a programmer implementing expression parsers, or a math enthusiast exploring alternate notations, this tool handles conversions instantly using well-established algorithms.
Standard arithmetic notation -- called infix notation -- places operators between operands like 3 + 4 x 5. This requires operator precedence rules (multiplication before addition) and parentheses for grouping, which can make parsing complex. Polish notation, invented by Jan Łukasiewicz in 1924, moves operators before their operands (prefix: + 3 x 4 5), while Reverse Polish notation (RPN) places operators after (postfix: 3 4 5 x +). Both eliminate parentheses entirely. This converter uses Dijkstra's shunting-yard algorithm for infix-to-postfix conversion and a modified reverse-scan approach for infix-to-prefix conversion.
Regional Notes
India (IN): Polish notation is taught in computer science engineering programs as part of data structures and compiler design curricula. The shunting-yard algorithm and stack-based RPN evaluation are standard topics for GATE and university exams.
United States (US): CS students learn Polish notation in algorithms and data structures courses. RPN is still used on some financial calculators and in SAT/AP Computer Science expression evaluation problems.
United Kingdom (UK): A-level Computer Science curricula cover infix, prefix, and postfix notations, including the shunting-yard algorithm and stack-based evaluation. RPN appears in GCSE and A-level exam questions on expression trees and stacks.
Frequently Asked Questions
What is Polish notation?
Polish notation, also called prefix notation, is a way of writing arithmetic expressions where operators appear before their operands. For example, instead of writing 3 + 4 (infix), you write + 3 4. It was invented by Polish logician Jan Łukasiewicz in 1924 and eliminates the need for parentheses and operator precedence rules.
What is Reverse Polish notation (postfix)?
Reverse Polish notation (RPN), also called postfix notation, places operators after their operands. For example, 3 4 + means 3 + 4. RPN became popular in computing because it is efficient for stack-based evaluation and requires less memory. Hewlett-Packard calculators in the 1970s famously used RPN.
How does the shunting-yard algorithm convert infix to postfix?
The shunting-yard algorithm, invented by Edsger Dijkstra, converts infix expressions to postfix by reading tokens left to right. Numbers go directly to the output, operators are moved to an operator stack based on precedence, and parentheses handle grouping. The result is a postfix expression that removes all parentheses and precedence ambiguity.
How do you evaluate a Reverse Polish notation expression?
To evaluate an RPN expression, scan tokens left to right using a stack. When you see a number, push it onto the stack. When you see an operator, pop the top two numbers from the stack, apply the operator, and push the result back. The final stack value is the result. This simple stack-based evaluation makes RPN ideal for computers.
What operators are supported by this converter?
This converter supports the standard arithmetic operators: addition (+), subtraction (-), multiplication (*), division (/), and exponentiation (^). It handles parentheses in infix expressions and respects standard operator precedence: exponentiation highest, then multiplication/division, then addition/subtraction.
Is Polish notation still used today?
While most everyday mathematics uses infix notation, Polish and Reverse Polish notations remain relevant. RPN is used in some financial calculators, programming language compilers use it internally for expression evaluation, and it appears in computer science education to teach stack-based algorithms and expression parsing.
How is prefix notation different from postfix notation?
In prefix (Polish) notation, operators precede their operands like + 3 4, while in postfix (Reverse Polish) notation, operators follow their operands like 3 4 +. Both eliminate the need for parentheses, but they are evaluated in opposite directions. Prefix is scanned right-to-left, while postfix is scanned left-to-right.