Sunday, April 12, 2009

Infix to postfix or prefix?

The order of operations or precedence rule is used to determine the order in which operations need to be performed. The order of operations is just a protocol used for easier and common understanding of expressions and is not based on any mathematical or logical theorem. The history of the order of precedence is not very clear and its origins cannot be attributed to any single source. The originator of this rule was not brilliant enough to suggest the post or pre fix notation :)

Various acronyms such as (all of which represent the same order of precedence):
PEMDAS - Parentheses Exponents Multiplication Division Addition Subtraction Also remembered using the sentence - "Please Excuse My Dear Aunt Sally"
BEDMAS - Brackets Exponents Division Multiplication Addition Subtraction
BIDMAS - Brackets Indices Division Multiplication Addition Subtraction
BIMDAS - Brackets Indices Multiplication Division Addition Subtraction
BIODMAS- Brackets Indices Of Division Multiplication Addition Subtraction
BODMAS - Brackets Of Division Multiplication Addition Subtraction
BOMDAS - Brackets Of Multiplication Division Addition Subtraction
BPODMAS- Brackets Power Of Division Multiplication Addition Subtraction

The Microsoft calculator program uses the order of operations in the scientific mode but ignored it in the standard mode. The Google calculator adheres to the order of preference strictly as can be see in the result of 6*3/4^2*3+2*(3/6-4)*3^(2-4).

Humans require the order of operations as we use conventional infix notation. However, the computers use a postfix notation like Reverse Polish notation , which obviates the need for the order of operations. Few computer languages use a prefix notation, which does not require the order of precedence as well. So should humans try to move from the infix to postfix or prefix notation?

1 comment:

Anonymous said...

The lunch was spectacular and served by their full-time maid[url=http://www.moidohod.com].[/url]