Richard Lemmens website

Copyright:
Non Commercial
Share Alike

Polish notation

If I write "1 + 1 = 2", everybody understands what I mean. But if I write "+ 1 1 = 2", most people will think I made an error. I did not, however; I just used a different way to write down arithmetical expressions. This type of notation is called "Polish notation", or more generally "prefix notation". It was invented by the Polish logician Jan Lukasiewicz around 1920, but never became widely popular, probably because the conventional "infix" notation was already too strongly entrenched in people's minds. That is a pity, because the prefix notation is in some areas superior to infix. Allow me to demonstrate.

First we must understand the differences between the two notations.
"1 + 1 = 2" is a short, mathematical notation for "Take the number 1 and another number 1 and apply the operator 'plus' to them, which adds the two numbers up. The result is the number two."
"+ 1 1 = 2" means exactly the same; only the notation is different.
In the conventional infix notation the operator is put between its two arguments, hence the name "infix". In prefix notation the operator is put in front, thus the name "prefix". Of course there is third way, called "postfix" notation, where the operator is put at the end, like this: "1 1 + = 2". I will not discuss postfix here any further, as its differences with infix are very similar to those of prefix.
In mathemetics, prefix notation is rather common. An arithmetical "operator" is nothing more than a function. Using common mathematical notation, I could also write the example expression as "plus(1,1) = 2". This should be familiar to anyone who has a basic knowledge of mathematics. Notice how similar that way of writing is to prefix notation.

Now why is prefix better than the regular infix?
Consider the following infix expression: "1 + 2 * 3 = 7". This is correct only when we give the multiplication operator precedence over the plus operator: First calculate 2 * 3 = 6, then 1 + 6 = 7. If we had given the plus operator precendence, the result would have been different: 1 + 2 = 3 and then 3 * 3 = 9.
With infix notation, there are two ways out of this ambiguity. The first is to use semantic conventions, like "multiplication has precendence over addition". The second is to use extra syntax, for instance by using parentheses, like so: "1 + (2 * 3) = 7". Both require a little extra help to support the original notation. But prefix notation requires neither.
In prefix notation one can write the example expression unambiguously like "+ 1 * 2 3". This means "apply the plus operator to the number 1 and the result of the application of the multiply operator to the numbers 2 and 3".
If we would prefer the other interpretation, we should have written "* + 1 2 3", again unambiguous. When we consider the operators to be nothing but functions, the expressions look like this: "plus(1,multiply(2,3))" and "multiply(plus(1,2),3)". Of course the prefix notation is shorter because its syntax uses very few characters.

I would like to state that knowing and understanding prefix, infix and postfix notation is a must for everybody who wants to learn mathematics beyond elementary school level. You don't have to use them all and are certainly not advised to mix them, but knowledge of these different types of notations increases you insight and will help you step beyond simple arithmetic into the wider field of mathematics.
If you still don't believe and need to see, try your luck at one of the scientific calculators from Texas Instruments. These use reverse Polish notation, which is the same as postfix notation and offers the same benefits over infix as prefix does.