Tags

, , , ,

Here’s a question for you.  Take a look at the picture below:

bodmas1What do you think is the answer to the bottom line?  Here’s how you might work it out.  From the top line, a bottle of champagne has a value of 10 from which we can deduce that in the second line, a Christmas pudding has a value of 5 and, finally, that the four mince pies in the third line have a collective value of 4 thus making one mince pie equal a value of 1.

bodmas2Now, how about the bottom line?  If we replace the Christmas goodies with their values, we get either 60 or 15 depending on how we evaluate the two mathematical operators, plus and multiply.

bodmas3Hmm, so what is the correct answer?  Is it “5 plus 1” times 10 to equal 60, or is it “1 times 10” plus 5 to equal 15?

When I first encountered this type of problem, my answer was “It depends.  It depends where the brackets are.  If it’s (5 + 1) x 10, then the answer is 60 but if it’s (1 x 10) + 5 then the answer is 15.”  “Oh no,” went up the cry.  “Remember BODMAS!”  “What the hell is BODMAS?” I queried.  In solemn tones, came the reply: “You must execute the operators according to an order of precedence given by Brackets followed by Order (exponents such as a power of a number e.g. the number 2 in 72 = 49), followed by Division, followed by Multiplication, followed by Addition and ending with Subtraction.  So, in the expression 5 + 1 x 10, first you execute the multiplication, 1 x 10 = 10, and then the addition + 5 to produce the correct answer 15.”  “What!” I exclaimed.  “Who invented this arbitrary rule?”  “Everyone knows about BODMAS,” came the stern riposte.  “You would have been taught it at school.”  “Oh no I wasn’t,” I replied.  “Oh yes you were,” came the rebuttal.  “Oh no …”  And so it went on but, eventually, I bowed to the greater knowledge of my antagonist and accepted that BODMAS was an accepted convention which must have passed me by during my mathematical education, both at school and on my engineering degree course at university.

And so it had.  I had been taught that the answer to an expression such as 5 + 1 x 10 was ambiguous and always required brackets to resolve the ambiguity but, apparently, the order of precedence defined by BODMAS is widely taught at school and is used to evaluate the result of such ambiguous expressions. (In the USA, the acronym is PEDMAS where P strands for Parentheses and E for Exponent.) I’ve no idea who first formulated this order but it does seem somewhat arbitrary—why do multiplication and division precede addition and subtraction, for example—and what happens if the application of the order appears to produce alternative but seemingly correct answers?  Take a look at this example:  1/2 x 4.  Is this 1/(2 x 4) = 0.125 i.e. multiplication before division) or (1/2) x 4 = 2 i.e. division before multiplication?  Given that division is multiplication by a fraction and subtraction is addition of a negative number, there is no essential difference between multiplication and division or between addition and subtraction so each pair of operators have equal precedence and are executed in the left-to-right order in which they occur.  Therefore, the correct answer is (1/2) x 4 = 2.

What about Excel?   Excel is widely used for spreadsheet calculations so how does it handle ambiguous expressions?  As it turns out, Excel is based on the BODMAS ordering convention but doesn’t always get it right.  For example, how does Excel evaluate bodmas4a  more usually written as 4^3^2? (Excel uses the caret symbol, ^, to indicate “to the power of”.)  Conventional mathematics (called right associative) would evaluate the higher order exponent first to produce:

bodmas5Whereas Excel (BODMAS) evaluates the exponents in left-to-right order:

bodmas6If you want Excel to produce the conventional result, you must force the order like this 4^(3^2) which kind of defeats the objective.  Ah well, you can’t win ‘em all.

One final comment.  There are other ways of writing down mathematical expressions without using brackets but which are not ambiguous in their evaluation.  One that I am very familiar with from my days at university is the Reverse Polish Notation, RPN, so-named after the Polish logician Jan Lukasiewicz, 1878 – 1956.  Very briefly, the RPN lists operands (usually two at a time) followed by the appropriate operator in order of evaluation, left to right.  Thus, the 3-operand 2-operator expression (5 + 1 x 10) would be rearranged to read (1 10 x 5 +) indicating that first 1 and 10 are multiplied together and then the intermediate result is added to 5 to produce the final result 15.  RPN expressions look strange at first sight but, in fact, lend themselves to efficient and correct evaluation in a computer system based on the use of a temporary storage area (called a stack) in which are stored intermediate results.  My familiarity with the unambiguous RPN is probably the reason I hiccupped when I first came across the BODMAS evaluation process.

Try this.  How do you express bodmas4a in RPN assuming the exponent operator has two operands and raises the first to the power of the second i.e.  72 is written 7 2 ^, not 2 7 ^?  The answer is below.

bodmas7(^_^)

bodmas8

 

 

Advertisements